@needle-tools/engine 3.35.0-beta → 3.35.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1641,13 +1641,13 @@ vec3 nonPerturbedNormal = normal;`,j8=`#ifdef USE_NORMALMAP_OBJECTSPACE
1641
1641
  #endif
1642
1642
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1643
1643
  uniform sampler2D iridescenceThicknessMap;
1644
- #endif`,e5=`#ifdef OPAQUE
1644
+ #endif`,eV=`#ifdef OPAQUE
1645
1645
  diffuseColor.a = 1.0;
1646
1646
  #endif
1647
1647
  #ifdef USE_TRANSMISSION
1648
1648
  diffuseColor.a *= material.transmissionAlpha;
1649
1649
  #endif
1650
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,t5=`vec3 packNormalToRGB( const in vec3 normal ) {
1650
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,tV=`vec3 packNormalToRGB( const in vec3 normal ) {
1651
1651
  return normalize( normal ) * 0.5 + 0.5;
1652
1652
  }
1653
1653
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1688,9 +1688,9 @@ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const
1688
1688
  }
1689
1689
  float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1690
1690
  return ( near * far ) / ( ( far - near ) * depth - far );
1691
- }`,i5=`#ifdef PREMULTIPLIED_ALPHA
1691
+ }`,iV=`#ifdef PREMULTIPLIED_ALPHA
1692
1692
  gl_FragColor.rgb *= gl_FragColor.a;
1693
- #endif`,n5=`vec4 mvPosition = vec4( transformed, 1.0 );
1693
+ #endif`,nV=`vec4 mvPosition = vec4( transformed, 1.0 );
1694
1694
  #ifdef USE_BATCHING
1695
1695
  mvPosition = batchingMatrix * mvPosition;
1696
1696
  #endif
@@ -1698,22 +1698,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1698
1698
  mvPosition = instanceMatrix * mvPosition;
1699
1699
  #endif
1700
1700
  mvPosition = modelViewMatrix * mvPosition;
1701
- gl_Position = projectionMatrix * mvPosition;`,s5=`#ifdef DITHERING
1701
+ gl_Position = projectionMatrix * mvPosition;`,sV=`#ifdef DITHERING
1702
1702
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1703
- #endif`,r5=`#ifdef DITHERING
1703
+ #endif`,rV=`#ifdef DITHERING
1704
1704
  vec3 dithering( vec3 color ) {
1705
1705
  float grid_position = rand( gl_FragCoord.xy );
1706
1706
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1707
1707
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1708
1708
  return color + dither_shift_RGB;
1709
1709
  }
1710
- #endif`,o5=`float roughnessFactor = roughness;
1710
+ #endif`,oV=`float roughnessFactor = roughness;
1711
1711
  #ifdef USE_ROUGHNESSMAP
1712
1712
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1713
1713
  roughnessFactor *= texelRoughness.g;
1714
- #endif`,a5=`#ifdef USE_ROUGHNESSMAP
1714
+ #endif`,aV=`#ifdef USE_ROUGHNESSMAP
1715
1715
  uniform sampler2D roughnessMap;
1716
- #endif`,l5=`#if NUM_SPOT_LIGHT_COORDS > 0
1716
+ #endif`,lV=`#if NUM_SPOT_LIGHT_COORDS > 0
1717
1717
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1718
1718
  #endif
1719
1719
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -1890,7 +1890,7 @@ gl_Position = projectionMatrix * mvPosition;`,s5=`#ifdef DITHERING
1890
1890
  return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1891
1891
  #endif
1892
1892
  }
1893
- #endif`,c5=`#if NUM_SPOT_LIGHT_COORDS > 0
1893
+ #endif`,cV=`#if NUM_SPOT_LIGHT_COORDS > 0
1894
1894
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1895
1895
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1896
1896
  #endif
@@ -1928,7 +1928,7 @@ gl_Position = projectionMatrix * mvPosition;`,s5=`#ifdef DITHERING
1928
1928
  };
1929
1929
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1930
1930
  #endif
1931
- #endif`,h5=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1931
+ #endif`,hV=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1932
1932
  vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1933
1933
  vec4 shadowWorldPosition;
1934
1934
  #endif
@@ -1960,7 +1960,7 @@ gl_Position = projectionMatrix * mvPosition;`,s5=`#ifdef DITHERING
1960
1960
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1961
1961
  }
1962
1962
  #pragma unroll_loop_end
1963
- #endif`,u5=`float getShadowMask() {
1963
+ #endif`,uV=`float getShadowMask() {
1964
1964
  float shadow = 1.0;
1965
1965
  #ifdef USE_SHADOWMAP
1966
1966
  #if NUM_DIR_LIGHT_SHADOWS > 0
@@ -1992,12 +1992,12 @@ gl_Position = projectionMatrix * mvPosition;`,s5=`#ifdef DITHERING
1992
1992
  #endif
1993
1993
  #endif
1994
1994
  return shadow;
1995
- }`,d5=`#ifdef USE_SKINNING
1995
+ }`,dV=`#ifdef USE_SKINNING
1996
1996
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
1997
1997
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
1998
1998
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1999
1999
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2000
- #endif`,f5=`#ifdef USE_SKINNING
2000
+ #endif`,fV=`#ifdef USE_SKINNING
2001
2001
  uniform mat4 bindMatrix;
2002
2002
  uniform mat4 bindMatrixInverse;
2003
2003
  uniform highp sampler2D boneTexture;
@@ -2012,7 +2012,7 @@ gl_Position = projectionMatrix * mvPosition;`,s5=`#ifdef DITHERING
2012
2012
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2013
2013
  return mat4( v1, v2, v3, v4 );
2014
2014
  }
2015
- #endif`,p5=`#ifdef USE_SKINNING
2015
+ #endif`,pV=`#ifdef USE_SKINNING
2016
2016
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2017
2017
  vec4 skinned = vec4( 0.0 );
2018
2018
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2020,7 +2020,7 @@ gl_Position = projectionMatrix * mvPosition;`,s5=`#ifdef DITHERING
2020
2020
  skinned += boneMatZ * skinVertex * skinWeight.z;
2021
2021
  skinned += boneMatW * skinVertex * skinWeight.w;
2022
2022
  transformed = ( bindMatrixInverse * skinned ).xyz;
2023
- #endif`,m5=`#ifdef USE_SKINNING
2023
+ #endif`,mV=`#ifdef USE_SKINNING
2024
2024
  mat4 skinMatrix = mat4( 0.0 );
2025
2025
  skinMatrix += skinWeight.x * boneMatX;
2026
2026
  skinMatrix += skinWeight.y * boneMatY;
@@ -2031,17 +2031,17 @@ gl_Position = projectionMatrix * mvPosition;`,s5=`#ifdef DITHERING
2031
2031
  #ifdef USE_TANGENT
2032
2032
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2033
2033
  #endif
2034
- #endif`,g5=`float specularStrength;
2034
+ #endif`,gV=`float specularStrength;
2035
2035
  #ifdef USE_SPECULARMAP
2036
2036
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2037
2037
  specularStrength = texelSpecular.r;
2038
2038
  #else
2039
2039
  specularStrength = 1.0;
2040
- #endif`,v5=`#ifdef USE_SPECULARMAP
2040
+ #endif`,vV=`#ifdef USE_SPECULARMAP
2041
2041
  uniform sampler2D specularMap;
2042
- #endif`,A5=`#if defined( TONE_MAPPING )
2042
+ #endif`,AV=`#if defined( TONE_MAPPING )
2043
2043
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2044
- #endif`,y5=`#ifndef saturate
2044
+ #endif`,yV=`#ifndef saturate
2045
2045
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2046
2046
  #endif
2047
2047
  uniform float toneMappingExposure;
@@ -2138,7 +2138,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2138
2138
  float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);
2139
2139
  return mix(color, vec3(1, 1, 1), g);
2140
2140
  }
2141
- vec3 CustomToneMapping( vec3 color ) { return color; }`,_5=`#ifdef USE_TRANSMISSION
2141
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,_V=`#ifdef USE_TRANSMISSION
2142
2142
  material.transmission = transmission;
2143
2143
  material.transmissionAlpha = 1.0;
2144
2144
  material.thickness = thickness;
@@ -2159,7 +2159,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_5=`#ifdef USE_TRANSMISS
2159
2159
  material.attenuationColor, material.attenuationDistance );
2160
2160
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2161
2161
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2162
- #endif`,b5=`#ifdef USE_TRANSMISSION
2162
+ #endif`,bV=`#ifdef USE_TRANSMISSION
2163
2163
  uniform float transmission;
2164
2164
  uniform float thickness;
2165
2165
  uniform float attenuationDistance;
@@ -2265,7 +2265,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_5=`#ifdef USE_TRANSMISS
2265
2265
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2266
2266
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2267
2267
  }
2268
- #endif`,x5=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2268
+ #endif`,xV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2269
2269
  varying vec2 vUv;
2270
2270
  #endif
2271
2271
  #ifdef USE_MAP
@@ -2335,7 +2335,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_5=`#ifdef USE_TRANSMISS
2335
2335
  #ifdef USE_THICKNESSMAP
2336
2336
  uniform mat3 thicknessMapTransform;
2337
2337
  varying vec2 vThicknessMapUv;
2338
- #endif`,w5=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2338
+ #endif`,wV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2339
2339
  varying vec2 vUv;
2340
2340
  #endif
2341
2341
  #ifdef USE_MAP
@@ -2429,7 +2429,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_5=`#ifdef USE_TRANSMISS
2429
2429
  #ifdef USE_THICKNESSMAP
2430
2430
  uniform mat3 thicknessMapTransform;
2431
2431
  varying vec2 vThicknessMapUv;
2432
- #endif`,S5=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2432
+ #endif`,SV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2433
2433
  vUv = vec3( uv, 1 ).xy;
2434
2434
  #endif
2435
2435
  #ifdef USE_MAP
@@ -2500,7 +2500,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_5=`#ifdef USE_TRANSMISS
2500
2500
  #endif
2501
2501
  #ifdef USE_THICKNESSMAP
2502
2502
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2503
- #endif`,C5=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2503
+ #endif`,CV=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2504
2504
  vec4 worldPosition = vec4( transformed, 1.0 );
2505
2505
  #ifdef USE_BATCHING
2506
2506
  worldPosition = batchingMatrix * worldPosition;
@@ -2509,12 +2509,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_5=`#ifdef USE_TRANSMISS
2509
2509
  worldPosition = instanceMatrix * worldPosition;
2510
2510
  #endif
2511
2511
  worldPosition = modelMatrix * worldPosition;
2512
- #endif`;const E5=`varying vec2 vUv;
2512
+ #endif`;const EV=`varying vec2 vUv;
2513
2513
  uniform mat3 uvTransform;
2514
2514
  void main() {
2515
2515
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2516
2516
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2517
- }`,M5=`uniform sampler2D t2D;
2517
+ }`,MV=`uniform sampler2D t2D;
2518
2518
  uniform float backgroundIntensity;
2519
2519
  varying vec2 vUv;
2520
2520
  void main() {
@@ -2526,14 +2526,14 @@ void main() {
2526
2526
  gl_FragColor = texColor;
2527
2527
  #include <tonemapping_fragment>
2528
2528
  #include <colorspace_fragment>
2529
- }`,T5=`varying vec3 vWorldDirection;
2529
+ }`,TV=`varying vec3 vWorldDirection;
2530
2530
  #include <common>
2531
2531
  void main() {
2532
2532
  vWorldDirection = transformDirection( position, modelMatrix );
2533
2533
  #include <begin_vertex>
2534
2534
  #include <project_vertex>
2535
2535
  gl_Position.z = gl_Position.w;
2536
- }`,I5=`#ifdef ENVMAP_TYPE_CUBE
2536
+ }`,IV=`#ifdef ENVMAP_TYPE_CUBE
2537
2537
  uniform samplerCube envMap;
2538
2538
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2539
2539
  uniform sampler2D envMap;
@@ -2556,14 +2556,14 @@ void main() {
2556
2556
  gl_FragColor = texColor;
2557
2557
  #include <tonemapping_fragment>
2558
2558
  #include <colorspace_fragment>
2559
- }`,R5=`varying vec3 vWorldDirection;
2559
+ }`,RV=`varying vec3 vWorldDirection;
2560
2560
  #include <common>
2561
2561
  void main() {
2562
2562
  vWorldDirection = transformDirection( position, modelMatrix );
2563
2563
  #include <begin_vertex>
2564
2564
  #include <project_vertex>
2565
2565
  gl_Position.z = gl_Position.w;
2566
- }`,P5=`uniform samplerCube tCube;
2566
+ }`,PV=`uniform samplerCube tCube;
2567
2567
  uniform float tFlip;
2568
2568
  uniform float opacity;
2569
2569
  varying vec3 vWorldDirection;
@@ -2573,7 +2573,7 @@ void main() {
2573
2573
  gl_FragColor.a *= opacity;
2574
2574
  #include <tonemapping_fragment>
2575
2575
  #include <colorspace_fragment>
2576
- }`,B5=`#include <common>
2576
+ }`,BV=`#include <common>
2577
2577
  #include <batching_pars_vertex>
2578
2578
  #include <uv_pars_vertex>
2579
2579
  #include <displacementmap_pars_vertex>
@@ -2600,7 +2600,7 @@ void main() {
2600
2600
  #include <logdepthbuf_vertex>
2601
2601
  #include <clipping_planes_vertex>
2602
2602
  vHighPrecisionZW = gl_Position.zw;
2603
- }`,D5=`#if DEPTH_PACKING == 3200
2603
+ }`,DV=`#if DEPTH_PACKING == 3200
2604
2604
  uniform float opacity;
2605
2605
  #endif
2606
2606
  #include <common>
@@ -2630,7 +2630,7 @@ void main() {
2630
2630
  #elif DEPTH_PACKING == 3201
2631
2631
  gl_FragColor = packDepthToRGBA( fragCoordZ );
2632
2632
  #endif
2633
- }`,O5=`#define DISTANCE
2633
+ }`,OV=`#define DISTANCE
2634
2634
  varying vec3 vWorldPosition;
2635
2635
  #include <common>
2636
2636
  #include <batching_pars_vertex>
@@ -2657,7 +2657,7 @@ void main() {
2657
2657
  #include <worldpos_vertex>
2658
2658
  #include <clipping_planes_vertex>
2659
2659
  vWorldPosition = worldPosition.xyz;
2660
- }`,L5=`#define DISTANCE
2660
+ }`,LV=`#define DISTANCE
2661
2661
  uniform vec3 referencePosition;
2662
2662
  uniform float nearDistance;
2663
2663
  uniform float farDistance;
@@ -2681,13 +2681,13 @@ void main () {
2681
2681
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2682
2682
  dist = saturate( dist );
2683
2683
  gl_FragColor = packDepthToRGBA( dist );
2684
- }`,k5=`varying vec3 vWorldDirection;
2684
+ }`,kV=`varying vec3 vWorldDirection;
2685
2685
  #include <common>
2686
2686
  void main() {
2687
2687
  vWorldDirection = transformDirection( position, modelMatrix );
2688
2688
  #include <begin_vertex>
2689
2689
  #include <project_vertex>
2690
- }`,F5=`uniform sampler2D tEquirect;
2690
+ }`,FV=`uniform sampler2D tEquirect;
2691
2691
  varying vec3 vWorldDirection;
2692
2692
  #include <common>
2693
2693
  void main() {
@@ -2696,7 +2696,7 @@ void main() {
2696
2696
  gl_FragColor = texture2D( tEquirect, sampleUV );
2697
2697
  #include <tonemapping_fragment>
2698
2698
  #include <colorspace_fragment>
2699
- }`,U5=`uniform float scale;
2699
+ }`,UV=`uniform float scale;
2700
2700
  attribute float lineDistance;
2701
2701
  varying float vLineDistance;
2702
2702
  #include <common>
@@ -2718,7 +2718,7 @@ void main() {
2718
2718
  #include <logdepthbuf_vertex>
2719
2719
  #include <clipping_planes_vertex>
2720
2720
  #include <fog_vertex>
2721
- }`,N5=`uniform vec3 diffuse;
2721
+ }`,NV=`uniform vec3 diffuse;
2722
2722
  uniform float opacity;
2723
2723
  uniform float dashSize;
2724
2724
  uniform float totalSize;
@@ -2746,7 +2746,7 @@ void main() {
2746
2746
  #include <colorspace_fragment>
2747
2747
  #include <fog_fragment>
2748
2748
  #include <premultiplied_alpha_fragment>
2749
- }`,z5=`#include <common>
2749
+ }`,zV=`#include <common>
2750
2750
  #include <batching_pars_vertex>
2751
2751
  #include <uv_pars_vertex>
2752
2752
  #include <envmap_pars_vertex>
@@ -2778,7 +2778,7 @@ void main() {
2778
2778
  #include <worldpos_vertex>
2779
2779
  #include <envmap_vertex>
2780
2780
  #include <fog_vertex>
2781
- }`,G5=`uniform vec3 diffuse;
2781
+ }`,GV=`uniform vec3 diffuse;
2782
2782
  uniform float opacity;
2783
2783
  #ifndef FLAT_SHADED
2784
2784
  varying vec3 vNormal;
@@ -2826,7 +2826,7 @@ void main() {
2826
2826
  #include <fog_fragment>
2827
2827
  #include <premultiplied_alpha_fragment>
2828
2828
  #include <dithering_fragment>
2829
- }`,H5=`#define LAMBERT
2829
+ }`,HV=`#define LAMBERT
2830
2830
  varying vec3 vViewPosition;
2831
2831
  #include <common>
2832
2832
  #include <batching_pars_vertex>
@@ -2865,7 +2865,7 @@ void main() {
2865
2865
  #include <envmap_vertex>
2866
2866
  #include <shadowmap_vertex>
2867
2867
  #include <fog_vertex>
2868
- }`,Q5=`#define LAMBERT
2868
+ }`,QV=`#define LAMBERT
2869
2869
  uniform vec3 diffuse;
2870
2870
  uniform vec3 emissive;
2871
2871
  uniform float opacity;
@@ -2922,7 +2922,7 @@ void main() {
2922
2922
  #include <fog_fragment>
2923
2923
  #include <premultiplied_alpha_fragment>
2924
2924
  #include <dithering_fragment>
2925
- }`,V5=`#define MATCAP
2925
+ }`,VV=`#define MATCAP
2926
2926
  varying vec3 vViewPosition;
2927
2927
  #include <common>
2928
2928
  #include <batching_pars_vertex>
@@ -2956,7 +2956,7 @@ void main() {
2956
2956
  #include <clipping_planes_vertex>
2957
2957
  #include <fog_vertex>
2958
2958
  vViewPosition = - mvPosition.xyz;
2959
- }`,j5=`#define MATCAP
2959
+ }`,jV=`#define MATCAP
2960
2960
  uniform vec3 diffuse;
2961
2961
  uniform float opacity;
2962
2962
  uniform sampler2D matcap;
@@ -3002,7 +3002,7 @@ void main() {
3002
3002
  #include <fog_fragment>
3003
3003
  #include <premultiplied_alpha_fragment>
3004
3004
  #include <dithering_fragment>
3005
- }`,W5=`#define NORMAL
3005
+ }`,WV=`#define NORMAL
3006
3006
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3007
3007
  varying vec3 vViewPosition;
3008
3008
  #endif
@@ -3035,7 +3035,7 @@ void main() {
3035
3035
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3036
3036
  vViewPosition = - mvPosition.xyz;
3037
3037
  #endif
3038
- }`,q5=`#define NORMAL
3038
+ }`,qV=`#define NORMAL
3039
3039
  uniform float opacity;
3040
3040
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3041
3041
  varying vec3 vViewPosition;
@@ -3057,7 +3057,7 @@ void main() {
3057
3057
  #ifdef OPAQUE
3058
3058
  gl_FragColor.a = 1.0;
3059
3059
  #endif
3060
- }`,X5=`#define PHONG
3060
+ }`,XV=`#define PHONG
3061
3061
  varying vec3 vViewPosition;
3062
3062
  #include <common>
3063
3063
  #include <batching_pars_vertex>
@@ -3096,7 +3096,7 @@ void main() {
3096
3096
  #include <envmap_vertex>
3097
3097
  #include <shadowmap_vertex>
3098
3098
  #include <fog_vertex>
3099
- }`,Y5=`#define PHONG
3099
+ }`,YV=`#define PHONG
3100
3100
  uniform vec3 diffuse;
3101
3101
  uniform vec3 emissive;
3102
3102
  uniform vec3 specular;
@@ -3155,7 +3155,7 @@ void main() {
3155
3155
  #include <fog_fragment>
3156
3156
  #include <premultiplied_alpha_fragment>
3157
3157
  #include <dithering_fragment>
3158
- }`,J5=`#define STANDARD
3158
+ }`,JV=`#define STANDARD
3159
3159
  varying vec3 vViewPosition;
3160
3160
  #ifdef USE_TRANSMISSION
3161
3161
  varying vec3 vWorldPosition;
@@ -3198,7 +3198,7 @@ void main() {
3198
3198
  #ifdef USE_TRANSMISSION
3199
3199
  vWorldPosition = worldPosition.xyz;
3200
3200
  #endif
3201
- }`,K5=`#define STANDARD
3201
+ }`,KV=`#define STANDARD
3202
3202
  #ifdef PHYSICAL
3203
3203
  #define IOR
3204
3204
  #define USE_SPECULAR
@@ -3320,7 +3320,7 @@ void main() {
3320
3320
  #include <fog_fragment>
3321
3321
  #include <premultiplied_alpha_fragment>
3322
3322
  #include <dithering_fragment>
3323
- }`,Z5=`#define TOON
3323
+ }`,ZV=`#define TOON
3324
3324
  varying vec3 vViewPosition;
3325
3325
  #include <common>
3326
3326
  #include <batching_pars_vertex>
@@ -3357,7 +3357,7 @@ void main() {
3357
3357
  #include <worldpos_vertex>
3358
3358
  #include <shadowmap_vertex>
3359
3359
  #include <fog_vertex>
3360
- }`,$5=`#define TOON
3360
+ }`,$V=`#define TOON
3361
3361
  uniform vec3 diffuse;
3362
3362
  uniform vec3 emissive;
3363
3363
  uniform float opacity;
@@ -3410,7 +3410,7 @@ void main() {
3410
3410
  #include <fog_fragment>
3411
3411
  #include <premultiplied_alpha_fragment>
3412
3412
  #include <dithering_fragment>
3413
- }`,eV=`uniform float size;
3413
+ }`,e5=`uniform float size;
3414
3414
  uniform float scale;
3415
3415
  #include <common>
3416
3416
  #include <color_pars_vertex>
@@ -3441,7 +3441,7 @@ void main() {
3441
3441
  #include <clipping_planes_vertex>
3442
3442
  #include <worldpos_vertex>
3443
3443
  #include <fog_vertex>
3444
- }`,tV=`uniform vec3 diffuse;
3444
+ }`,t5=`uniform vec3 diffuse;
3445
3445
  uniform float opacity;
3446
3446
  #include <common>
3447
3447
  #include <color_pars_fragment>
@@ -3466,7 +3466,7 @@ void main() {
3466
3466
  #include <colorspace_fragment>
3467
3467
  #include <fog_fragment>
3468
3468
  #include <premultiplied_alpha_fragment>
3469
- }`,iV=`#include <common>
3469
+ }`,i5=`#include <common>
3470
3470
  #include <batching_pars_vertex>
3471
3471
  #include <fog_pars_vertex>
3472
3472
  #include <morphtarget_pars_vertex>
@@ -3489,7 +3489,7 @@ void main() {
3489
3489
  #include <worldpos_vertex>
3490
3490
  #include <shadowmap_vertex>
3491
3491
  #include <fog_vertex>
3492
- }`,nV=`uniform vec3 color;
3492
+ }`,n5=`uniform vec3 color;
3493
3493
  uniform float opacity;
3494
3494
  #include <common>
3495
3495
  #include <packing>
@@ -3505,7 +3505,7 @@ void main() {
3505
3505
  #include <tonemapping_fragment>
3506
3506
  #include <colorspace_fragment>
3507
3507
  #include <fog_fragment>
3508
- }`,sV=`uniform float rotation;
3508
+ }`,s5=`uniform float rotation;
3509
3509
  uniform vec2 center;
3510
3510
  #include <common>
3511
3511
  #include <uv_pars_vertex>
@@ -3531,7 +3531,7 @@ void main() {
3531
3531
  #include <logdepthbuf_vertex>
3532
3532
  #include <clipping_planes_vertex>
3533
3533
  #include <fog_vertex>
3534
- }`,rV=`uniform vec3 diffuse;
3534
+ }`,r5=`uniform vec3 diffuse;
3535
3535
  uniform float opacity;
3536
3536
  #include <common>
3537
3537
  #include <uv_pars_fragment>
@@ -3556,7 +3556,7 @@ void main() {
3556
3556
  #include <tonemapping_fragment>
3557
3557
  #include <colorspace_fragment>
3558
3558
  #include <fog_fragment>
3559
- }`,zt={alphahash_fragment:EQ,alphahash_pars_fragment:MQ,alphamap_fragment:TQ,alphamap_pars_fragment:IQ,alphatest_fragment:RQ,alphatest_pars_fragment:PQ,aomap_fragment:BQ,aomap_pars_fragment:DQ,batching_pars_vertex:OQ,batching_vertex:LQ,begin_vertex:kQ,beginnormal_vertex:FQ,bsdfs:UQ,iridescence_fragment:NQ,bumpmap_pars_fragment:zQ,clipping_planes_fragment:GQ,clipping_planes_pars_fragment:HQ,clipping_planes_pars_vertex:QQ,clipping_planes_vertex:VQ,color_fragment:jQ,color_pars_fragment:WQ,color_pars_vertex:qQ,color_vertex:XQ,common:YQ,cube_uv_reflection_fragment:JQ,defaultnormal_vertex:KQ,displacementmap_pars_vertex:ZQ,displacementmap_vertex:$Q,emissivemap_fragment:e8,emissivemap_pars_fragment:t8,colorspace_fragment:i8,colorspace_pars_fragment:n8,envmap_fragment:s8,envmap_common_pars_fragment:r8,envmap_pars_fragment:o8,envmap_pars_vertex:a8,envmap_physical_pars_fragment:y8,envmap_vertex:l8,fog_vertex:c8,fog_pars_vertex:h8,fog_fragment:u8,fog_pars_fragment:d8,gradientmap_pars_fragment:f8,lightmap_fragment:p8,lightmap_pars_fragment:m8,lights_lambert_fragment:g8,lights_lambert_pars_fragment:v8,lights_pars_begin:A8,lights_toon_fragment:_8,lights_toon_pars_fragment:b8,lights_phong_fragment:x8,lights_phong_pars_fragment:w8,lights_physical_fragment:S8,lights_physical_pars_fragment:C8,lights_fragment_begin:E8,lights_fragment_maps:M8,lights_fragment_end:T8,logdepthbuf_fragment:I8,logdepthbuf_pars_fragment:R8,logdepthbuf_pars_vertex:P8,logdepthbuf_vertex:B8,map_fragment:D8,map_pars_fragment:O8,map_particle_fragment:L8,map_particle_pars_fragment:k8,metalnessmap_fragment:F8,metalnessmap_pars_fragment:U8,morphinstance_vertex:N8,morphcolor_vertex:z8,morphnormal_vertex:G8,morphtarget_pars_vertex:H8,morphtarget_vertex:Q8,normal_fragment_begin:V8,normal_fragment_maps:j8,normal_pars_fragment:W8,normal_pars_vertex:q8,normal_vertex:X8,normalmap_pars_fragment:Y8,clearcoat_normal_fragment_begin:J8,clearcoat_normal_fragment_maps:K8,clearcoat_pars_fragment:Z8,iridescence_pars_fragment:$8,opaque_fragment:e5,packing:t5,premultiplied_alpha_fragment:i5,project_vertex:n5,dithering_fragment:s5,dithering_pars_fragment:r5,roughnessmap_fragment:o5,roughnessmap_pars_fragment:a5,shadowmap_pars_fragment:l5,shadowmap_pars_vertex:c5,shadowmap_vertex:h5,shadowmask_pars_fragment:u5,skinbase_vertex:d5,skinning_pars_vertex:f5,skinning_vertex:p5,skinnormal_vertex:m5,specularmap_fragment:g5,specularmap_pars_fragment:v5,tonemapping_fragment:A5,tonemapping_pars_fragment:y5,transmission_fragment:_5,transmission_pars_fragment:b5,uv_pars_fragment:x5,uv_pars_vertex:w5,uv_vertex:S5,worldpos_vertex:C5,background_vert:E5,background_frag:M5,backgroundCube_vert:T5,backgroundCube_frag:I5,cube_vert:R5,cube_frag:P5,depth_vert:B5,depth_frag:D5,distanceRGBA_vert:O5,distanceRGBA_frag:L5,equirect_vert:k5,equirect_frag:F5,linedashed_vert:U5,linedashed_frag:N5,meshbasic_vert:z5,meshbasic_frag:G5,meshlambert_vert:H5,meshlambert_frag:Q5,meshmatcap_vert:V5,meshmatcap_frag:j5,meshnormal_vert:W5,meshnormal_frag:q5,meshphong_vert:X5,meshphong_frag:Y5,meshphysical_vert:J5,meshphysical_frag:K5,meshtoon_vert:Z5,meshtoon_frag:$5,points_vert:eV,points_frag:tV,shadow_vert:iV,shadow_frag:nV,sprite_vert:sV,sprite_frag:rV},Fe={common:{diffuse:{value:new xe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Lt},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Lt}},envmap:{envMap:{value:null},envMapRotation:{value:new Lt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Lt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Lt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Lt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Lt},normalScale:{value:new te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Lt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Lt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Lt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Lt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new xe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0},uvTransform:{value:new Lt}},sprite:{diffuse:{value:new xe(16777215)},opacity:{value:1},center:{value:new te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Lt},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0}}},Ts={basic:{uniforms:mr([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.fog]),vertexShader:zt.meshbasic_vert,fragmentShader:zt.meshbasic_frag},lambert:{uniforms:mr([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,Fe.lights,{emissive:{value:new xe(0)}}]),vertexShader:zt.meshlambert_vert,fragmentShader:zt.meshlambert_frag},phong:{uniforms:mr([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,Fe.lights,{emissive:{value:new xe(0)},specular:{value:new xe(1118481)},shininess:{value:30}}]),vertexShader:zt.meshphong_vert,fragmentShader:zt.meshphong_frag},standard:{uniforms:mr([Fe.common,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.roughnessmap,Fe.metalnessmap,Fe.fog,Fe.lights,{emissive:{value:new xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:zt.meshphysical_vert,fragmentShader:zt.meshphysical_frag},toon:{uniforms:mr([Fe.common,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.gradientmap,Fe.fog,Fe.lights,{emissive:{value:new xe(0)}}]),vertexShader:zt.meshtoon_vert,fragmentShader:zt.meshtoon_frag},matcap:{uniforms:mr([Fe.common,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,{matcap:{value:null}}]),vertexShader:zt.meshmatcap_vert,fragmentShader:zt.meshmatcap_frag},points:{uniforms:mr([Fe.points,Fe.fog]),vertexShader:zt.points_vert,fragmentShader:zt.points_frag},dashed:{uniforms:mr([Fe.common,Fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:zt.linedashed_vert,fragmentShader:zt.linedashed_frag},depth:{uniforms:mr([Fe.common,Fe.displacementmap]),vertexShader:zt.depth_vert,fragmentShader:zt.depth_frag},normal:{uniforms:mr([Fe.common,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,{opacity:{value:1}}]),vertexShader:zt.meshnormal_vert,fragmentShader:zt.meshnormal_frag},sprite:{uniforms:mr([Fe.sprite,Fe.fog]),vertexShader:zt.sprite_vert,fragmentShader:zt.sprite_frag},background:{uniforms:{uvTransform:{value:new Lt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:zt.background_vert,fragmentShader:zt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Lt}},vertexShader:zt.backgroundCube_vert,fragmentShader:zt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:zt.cube_vert,fragmentShader:zt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:zt.equirect_vert,fragmentShader:zt.equirect_frag},distanceRGBA:{uniforms:mr([Fe.common,Fe.displacementmap,{referencePosition:{value:new w},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:zt.distanceRGBA_vert,fragmentShader:zt.distanceRGBA_frag},shadow:{uniforms:mr([Fe.lights,Fe.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:zt.shadow_vert,fragmentShader:zt.shadow_frag}};Ts.physical={uniforms:mr([Ts.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Lt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Lt},clearcoatNormalScale:{value:new te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Lt},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Lt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Lt},sheen:{value:0},sheenColor:{value:new xe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Lt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Lt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Lt},transmissionSamplerSize:{value:new te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Lt},attenuationDistance:{value:0},attenuationColor:{value:new xe(0)},specularColor:{value:new xe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Lt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Lt},anisotropyVector:{value:new te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Lt}}]),vertexShader:zt.meshphysical_vert,fragmentShader:zt.meshphysical_frag};const Dy={r:0,b:0,g:0},nu=new Gi,oV=new we;function aV(s,e,t,i,n,r,o){const a=new xe(0);let l=r===!0?0:1,c,u,d=null,f=0,p=null;function m(v,g){let _=!1,y=g.isScene===!0?g.background:null;y&&y.isTexture&&(y=(g.backgroundBlurriness>0?t:e).get(y)),y===null?A(a,l):y&&y.isColor&&(A(y,1),_=!0);const b=s.xr.getEnvironmentBlendMode();b==="additive"?i.buffers.color.setClear(0,0,0,1,o):b==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(s.autoClear||_)&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),y&&(y.isCubeTexture||y.mapping===Ep)?(u===void 0&&(u=new pe(new Li(1,1,1),new Pt({name:"BackgroundCubeMaterial",uniforms:pp(Ts.backgroundCube.uniforms),vertexShader:Ts.backgroundCube.vertexShader,fragmentShader:Ts.backgroundCube.fragmentShader,side:_n,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(E,M,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(u)),nu.copy(g.backgroundRotation),nu.x*=-1,nu.y*=-1,nu.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(nu.y*=-1,nu.z*=-1),u.material.uniforms.envMap.value=y,u.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=g.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(oV.makeRotationFromEuler(nu)),u.material.toneMapped=vi.getTransfer(y.colorSpace)!==Oi,(d!==y||f!==y.version||p!==s.toneMapping)&&(u.material.needsUpdate=!0,d=y,f=y.version,p=s.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new pe(new zn(2,2),new Pt({name:"BackgroundMaterial",uniforms:pp(Ts.background.uniforms),vertexShader:Ts.background.vertexShader,fragmentShader:Ts.background.fragmentShader,side:Bs,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,c.material.toneMapped=vi.getTransfer(y.colorSpace)!==Oi,y.matrixAutoUpdate===!0&&y.updateMatrix(),c.material.uniforms.uvTransform.value.copy(y.matrix),(d!==y||f!==y.version||p!==s.toneMapping)&&(c.material.needsUpdate=!0,d=y,f=y.version,p=s.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function A(v,g){v.getRGB(Dy,bF(s)),i.buffers.color.setClear(Dy.r,Dy.g,Dy.b,g,o)}return{getClearColor:function(){return a},setClearColor:function(v,g=1){a.set(v),l=g,A(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,A(a,l)},render:m}}function lV(s,e,t,i){const n=s.getParameter(s.MAX_VERTEX_ATTRIBS),r=i.isWebGL2?null:e.get("OES_vertex_array_object"),o=i.isWebGL2||r!==null,a={},l=v(null);let c=l,u=!1;function d(O,V,L,k,G){let Y=!1;if(o){const $=A(k,L,V);c!==$&&(c=$,p(c.object)),Y=g(O,k,L,G),Y&&_(O,k,L,G)}else{const $=V.wireframe===!0;(c.geometry!==k.id||c.program!==L.id||c.wireframe!==$)&&(c.geometry=k.id,c.program=L.id,c.wireframe=$,Y=!0)}G!==null&&t.update(G,s.ELEMENT_ARRAY_BUFFER),(Y||u)&&(u=!1,C(O,V,L,k),G!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.get(G).buffer))}function f(){return i.isWebGL2?s.createVertexArray():r.createVertexArrayOES()}function p(O){return i.isWebGL2?s.bindVertexArray(O):r.bindVertexArrayOES(O)}function m(O){return i.isWebGL2?s.deleteVertexArray(O):r.deleteVertexArrayOES(O)}function A(O,V,L){const k=L.wireframe===!0;let G=a[O.id];G===void 0&&(G={},a[O.id]=G);let Y=G[V.id];Y===void 0&&(Y={},G[V.id]=Y);let $=Y[k];return $===void 0&&($=v(f()),Y[k]=$),$}function v(O){const V=[],L=[],k=[];for(let G=0;G<n;G++)V[G]=0,L[G]=0,k[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:V,enabledAttributes:L,attributeDivisors:k,object:O,attributes:{},index:null}}function g(O,V,L,k){const G=c.attributes,Y=V.attributes;let $=0;const re=L.getAttributes();for(const ce in re)if(re[ce].location>=0){const ie=G[ce];let me=Y[ce];if(me===void 0&&(ce==="instanceMatrix"&&O.instanceMatrix&&(me=O.instanceMatrix),ce==="instanceColor"&&O.instanceColor&&(me=O.instanceColor)),ie===void 0||ie.attribute!==me||me&&ie.data!==me.data)return!0;$++}return c.attributesNum!==$||c.index!==k}function _(O,V,L,k){const G={},Y=V.attributes;let $=0;const re=L.getAttributes();for(const ce in re)if(re[ce].location>=0){let ie=Y[ce];ie===void 0&&(ce==="instanceMatrix"&&O.instanceMatrix&&(ie=O.instanceMatrix),ce==="instanceColor"&&O.instanceColor&&(ie=O.instanceColor));const me={};me.attribute=ie,ie&&ie.data&&(me.data=ie.data),G[ce]=me,$++}c.attributes=G,c.attributesNum=$,c.index=k}function y(){const O=c.newAttributes;for(let V=0,L=O.length;V<L;V++)O[V]=0}function b(O){E(O,0)}function E(O,V){const L=c.newAttributes,k=c.enabledAttributes,G=c.attributeDivisors;L[O]=1,k[O]===0&&(s.enableVertexAttribArray(O),k[O]=1),G[O]!==V&&((i.isWebGL2?s:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](O,V),G[O]=V)}function M(){const O=c.newAttributes,V=c.enabledAttributes;for(let L=0,k=V.length;L<k;L++)V[L]!==O[L]&&(s.disableVertexAttribArray(L),V[L]=0)}function T(O,V,L,k,G,Y,$){$===!0?s.vertexAttribIPointer(O,V,L,G,Y):s.vertexAttribPointer(O,V,L,k,G,Y)}function C(O,V,L,k){if(i.isWebGL2===!1&&(O.isInstancedMesh||k.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;y();const G=k.attributes,Y=L.getAttributes(),$=V.defaultAttributeValues;for(const re in Y){const ce=Y[re];if(ce.location>=0){let Re=G[re];if(Re===void 0&&(re==="instanceMatrix"&&O.instanceMatrix&&(Re=O.instanceMatrix),re==="instanceColor"&&O.instanceColor&&(Re=O.instanceColor)),Re!==void 0){const ie=Re.normalized,me=Re.itemSize,be=t.get(Re);if(be===void 0)continue;const Ve=be.buffer,je=be.type,Ge=be.bytesPerElement,dt=i.isWebGL2===!0&&(je===s.INT||je===s.UNSIGNED_INT||Re.gpuType===ZM);if(Re.isInterleavedBufferAttribute){const tt=Re.data,W=tt.stride,Ne=Re.offset;if(tt.isInstancedInterleavedBuffer){for(let ye=0;ye<ce.locationSize;ye++)E(ce.location+ye,tt.meshPerAttribute);O.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=tt.meshPerAttribute*tt.count)}else for(let ye=0;ye<ce.locationSize;ye++)b(ce.location+ye);s.bindBuffer(s.ARRAY_BUFFER,Ve);for(let ye=0;ye<ce.locationSize;ye++)T(ce.location+ye,me/ce.locationSize,je,ie,W*Ge,(Ne+me/ce.locationSize*ye)*Ge,dt)}else{if(Re.isInstancedBufferAttribute){for(let tt=0;tt<ce.locationSize;tt++)E(ce.location+tt,Re.meshPerAttribute);O.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=Re.meshPerAttribute*Re.count)}else for(let tt=0;tt<ce.locationSize;tt++)b(ce.location+tt);s.bindBuffer(s.ARRAY_BUFFER,Ve);for(let tt=0;tt<ce.locationSize;tt++)T(ce.location+tt,me/ce.locationSize,je,ie,me*Ge,me/ce.locationSize*tt*Ge,dt)}}else if($!==void 0){const ie=$[re];if(ie!==void 0)switch(ie.length){case 2:s.vertexAttrib2fv(ce.location,ie);break;case 3:s.vertexAttrib3fv(ce.location,ie);break;case 4:s.vertexAttrib4fv(ce.location,ie);break;default:s.vertexAttrib1fv(ce.location,ie)}}}}M()}function B(){Q();for(const O in a){const V=a[O];for(const L in V){const k=V[L];for(const G in k)m(k[G].object),delete k[G];delete V[L]}delete a[O]}}function S(O){if(a[O.id]===void 0)return;const V=a[O.id];for(const L in V){const k=V[L];for(const G in k)m(k[G].object),delete k[G];delete V[L]}delete a[O.id]}function R(O){for(const V in a){const L=a[V];if(L[O.id]===void 0)continue;const k=L[O.id];for(const G in k)m(k[G].object),delete k[G];delete L[O.id]}}function Q(){z(),u=!0,c!==l&&(c=l,p(c.object))}function z(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:d,reset:Q,resetDefaultState:z,dispose:B,releaseStatesOfGeometry:S,releaseStatesOfProgram:R,initAttributes:y,enableAttribute:b,disableUnusedAttributes:M}}function cV(s,e,t,i){const n=i.isWebGL2;let r;function o(u){r=u}function a(u,d){s.drawArrays(r,u,d),t.update(d,r,1)}function l(u,d,f){if(f===0)return;let p,m;if(n)p=s,m="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),m="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[m](r,u,d,f),t.update(d,r,f)}function c(u,d,f){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<f;m++)this.render(u[m],d[m]);else{p.multiDrawArraysWEBGL(r,u,0,d,0,f);let m=0;for(let A=0;A<f;A++)m+=d[A];t.update(m,r,1)}}this.setMode=o,this.render=a,this.renderInstances=l,this.renderMultiDraw=c}function hV(s,e,t){let i;function n(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function r(T){if(T==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&s.constructor.name==="WebGL2RenderingContext";let a=t.precision!==void 0?t.precision:"highp";const l=r(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,d=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),f=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),A=s.getParameter(s.MAX_VERTEX_ATTRIBS),v=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),g=s.getParameter(s.MAX_VARYING_VECTORS),_=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),y=f>0,b=o||e.has("OES_texture_float"),E=y&&b,M=o?s.getParameter(s.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:n,getMaxPrecision:r,precision:a,logarithmicDepthBuffer:u,maxTextures:d,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:m,maxAttributes:A,maxVertexUniforms:v,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:y,floatFragmentTextures:b,floatVertexTextures:E,maxSamples:M}}function uV(s){const e=this;let t=null,i=0,n=!1,r=!1;const o=new Ar,a=new Lt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){const p=d.length!==0||f||i!==0||n;return n=f,i=d.length,p},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,f){t=u(d,f,0)},this.setState=function(d,f,p){const m=d.clippingPlanes,A=d.clipIntersection,v=d.clipShadows,g=s.get(d);if(!n||m===null||m.length===0||r&&!v)r?u(null):c();else{const _=r?0:i,y=_*4;let b=g.clippingState||null;l.value=b,b=u(m,f,y,p);for(let E=0;E!==y;++E)b[E]=t[E];g.clippingState=b,this.numIntersection=A?this.numPlanes:0,this.numPlanes+=_}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,f,p,m){const A=d!==null?d.length:0;let v=null;if(A!==0){if(v=l.value,m!==!0||v===null){const g=p+A*4,_=f.matrixWorldInverse;a.getNormalMatrix(_),(v===null||v.length<g)&&(v=new Float32Array(g));for(let y=0,b=p;y!==A;++y,b+=4)o.copy(d[y]).applyMatrix4(_,a),o.normal.toArray(v,b),v[b+3]=o.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=A,e.numIntersection=0,v}}function dV(s){let e=new WeakMap;function t(o,a){return a===zo?o.mapping=pc:a===up&&(o.mapping=Eh),o}function i(o){if(o&&o.isTexture){const a=o.mapping;if(a===zo||a===up)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new fT(l.height);return c.fromEquirectangularTexture(s,o),e.set(o,c),o.addEventListener("dispose",n),t(c.texture,o.mapping)}else return null}}return o}function n(o){const a=o.target;a.removeEventListener("dispose",n);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function r(){e=new WeakMap}return{get:i,dispose:r}}class yc extends jv{constructor(e=-1,t=1,i=1,n=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,r,o){this.view===null&&(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=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,o=i+e,a=n+t,l=n-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const kf=4,KP=[.125,.215,.35,.446,.526,.582],Tu=20,yS=new yc,ZP=new xe;let _S=null,bS=0,xS=0;const Cu=(1+Math.sqrt(5))/2,rf=1/Cu,$P=[new w(1,1,1),new w(-1,1,1),new w(1,1,-1),new w(-1,1,-1),new w(0,Cu,rf),new w(0,Cu,-rf),new w(rf,0,Cu),new w(-rf,0,Cu),new w(Cu,rf,0),new w(-Cu,rf,0)];class r1{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,n=100){_S=this._renderer.getRenderTarget(),bS=this._renderer.getActiveCubeFace(),xS=this._renderer.getActiveMipmapLevel(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,i,n,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=nB(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=iB(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(_S,bS,xS),e.scissorTest=!1,Oy(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===pc||e.mapping===Eh?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),_S=this._renderer.getRenderTarget(),bS=this._renderer.getActiveCubeFace(),xS=this._renderer.getActiveMipmapLevel();const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Mt,minFilter:Mt,generateMipmaps:!1,type:cn,format:Ai,colorSpace:yi,depthBuffer:!1},n=tB(e,t,i),{_lodMax:r}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=eB(r),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=tB(e,t,i);const{_lodMax:o}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=eB(o)),this._blurMaterial=fV(o,e,t)}return n}_compileMaterial(e){const t=new pe(this._lodPlanes[0],e);this._renderer.compile(t,yS)}_sceneToCubeUV(e,t,i,n){const a=new Qt(90,1,t,i),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(ZP),u.toneMapping=ho,u.autoClear=!1;const p=new ai({name:"PMREM.Background",side:_n,depthWrite:!1,depthTest:!1}),m=new pe(new Li,p);let A=!1;const v=e.background;v?v.isColor&&(p.color.copy(v),e.background=null,A=!0):(p.color.copy(ZP),A=!0);for(let g=0;g<6;g++){const _=g%3;_===0?(a.up.set(0,l[g],0),a.lookAt(c[g],0,0)):_===1?(a.up.set(0,0,l[g]),a.lookAt(0,c[g],0)):(a.up.set(0,l[g],0),a.lookAt(0,0,c[g]));const y=this._cubeSize;Oy(n,_*y,g>2?y:0,y,y),u.setRenderTarget(n),A&&u.render(m,a),u.render(e,a)}m.geometry.dispose(),m.material.dispose(),u.toneMapping=f,u.autoClear=d,e.background=v}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===pc||e.mapping===Eh;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=nB()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=iB());const r=n?this._cubemapMaterial:this._equirectMaterial,o=new pe(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const l=this._cubeSize;Oy(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,yS)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let n=1;n<this._lodPlanes.length;n++){const r=Math.sqrt(this._sigmas[n]*this._sigmas[n]-this._sigmas[n-1]*this._sigmas[n-1]),o=$P[(n-1)%$P.length];this._blur(e,n-1,n,r,o)}t.autoClear=i}_blur(e,t,i,n,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,n,"latitudinal",r),this._halfBlur(o,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,r,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,d=new pe(this._lodPlanes[n],c),f=c.uniforms,p=this._sizeLods[i]-1,m=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Tu-1),A=r/m,v=isFinite(r)?1+Math.floor(u*A):Tu;v>Tu&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Tu}`);const g=[];let _=0;for(let T=0;T<Tu;++T){const C=T/A,B=Math.exp(-C*C/2);g.push(B),T===0?_+=B:T<v&&(_+=2*B)}for(let T=0;T<g.length;T++)g[T]=g[T]/_;f.envMap.value=e.texture,f.samples.value=v,f.weights.value=g,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);const{_lodMax:y}=this;f.dTheta.value=m,f.mipInt.value=y-i;const b=this._sizeLods[n],E=3*b*(n>y-kf?n-y+kf:0),M=4*(this._cubeSize-b);Oy(t,E,M,3*b,2*b),l.setRenderTarget(t),l.render(d,yS)}}function eB(s){const e=[],t=[],i=[];let n=s;const r=s-kf+1+KP.length;for(let o=0;o<r;o++){const a=Math.pow(2,n);t.push(a);let l=1/a;o>s-kf?l=KP[o-s+kf-1]:o===0&&(l=0),i.push(l);const c=1/(a-2),u=-c,d=1+c,f=[u,u,d,u,d,d,u,u,d,d,u,d],p=6,m=6,A=3,v=2,g=1,_=new Float32Array(A*m*p),y=new Float32Array(v*m*p),b=new Float32Array(g*m*p);for(let M=0;M<p;M++){const T=M%3*2/3-1,C=M>2?0:-1,B=[T,C,0,T+2/3,C,0,T+2/3,C+1,0,T,C,0,T+2/3,C+1,0,T,C+1,0];_.set(B,A*m*M),y.set(f,v*m*M);const S=[M,M,M,M,M,M];b.set(S,g*m*M)}const E=new wt;E.setAttribute("position",new it(_,A)),E.setAttribute("uv",new it(y,v)),E.setAttribute("faceIndex",new it(b,g)),e.push(E),n>kf&&n--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function tB(s,e,t){const i=new Yt(s,e,t);return i.texture.mapping=Ep,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Oy(s,e,t,i,n){s.viewport.set(e,t,i,n),s.scissor.set(e,t,i,n)}function fV(s,e,t){const i=new Float32Array(Tu),n=new w(0,1,0);return new Pt({name:"SphericalGaussianBlur",defines:{n:Tu,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:pT(),fragmentShader:`
3559
+ }`,zt={alphahash_fragment:EQ,alphahash_pars_fragment:MQ,alphamap_fragment:TQ,alphamap_pars_fragment:IQ,alphatest_fragment:RQ,alphatest_pars_fragment:PQ,aomap_fragment:BQ,aomap_pars_fragment:DQ,batching_pars_vertex:OQ,batching_vertex:LQ,begin_vertex:kQ,beginnormal_vertex:FQ,bsdfs:UQ,iridescence_fragment:NQ,bumpmap_pars_fragment:zQ,clipping_planes_fragment:GQ,clipping_planes_pars_fragment:HQ,clipping_planes_pars_vertex:QQ,clipping_planes_vertex:VQ,color_fragment:jQ,color_pars_fragment:WQ,color_pars_vertex:qQ,color_vertex:XQ,common:YQ,cube_uv_reflection_fragment:JQ,defaultnormal_vertex:KQ,displacementmap_pars_vertex:ZQ,displacementmap_vertex:$Q,emissivemap_fragment:e8,emissivemap_pars_fragment:t8,colorspace_fragment:i8,colorspace_pars_fragment:n8,envmap_fragment:s8,envmap_common_pars_fragment:r8,envmap_pars_fragment:o8,envmap_pars_vertex:a8,envmap_physical_pars_fragment:y8,envmap_vertex:l8,fog_vertex:c8,fog_pars_vertex:h8,fog_fragment:u8,fog_pars_fragment:d8,gradientmap_pars_fragment:f8,lightmap_fragment:p8,lightmap_pars_fragment:m8,lights_lambert_fragment:g8,lights_lambert_pars_fragment:v8,lights_pars_begin:A8,lights_toon_fragment:_8,lights_toon_pars_fragment:b8,lights_phong_fragment:x8,lights_phong_pars_fragment:w8,lights_physical_fragment:S8,lights_physical_pars_fragment:C8,lights_fragment_begin:E8,lights_fragment_maps:M8,lights_fragment_end:T8,logdepthbuf_fragment:I8,logdepthbuf_pars_fragment:R8,logdepthbuf_pars_vertex:P8,logdepthbuf_vertex:B8,map_fragment:D8,map_pars_fragment:O8,map_particle_fragment:L8,map_particle_pars_fragment:k8,metalnessmap_fragment:F8,metalnessmap_pars_fragment:U8,morphinstance_vertex:N8,morphcolor_vertex:z8,morphnormal_vertex:G8,morphtarget_pars_vertex:H8,morphtarget_vertex:Q8,normal_fragment_begin:V8,normal_fragment_maps:j8,normal_pars_fragment:W8,normal_pars_vertex:q8,normal_vertex:X8,normalmap_pars_fragment:Y8,clearcoat_normal_fragment_begin:J8,clearcoat_normal_fragment_maps:K8,clearcoat_pars_fragment:Z8,iridescence_pars_fragment:$8,opaque_fragment:eV,packing:tV,premultiplied_alpha_fragment:iV,project_vertex:nV,dithering_fragment:sV,dithering_pars_fragment:rV,roughnessmap_fragment:oV,roughnessmap_pars_fragment:aV,shadowmap_pars_fragment:lV,shadowmap_pars_vertex:cV,shadowmap_vertex:hV,shadowmask_pars_fragment:uV,skinbase_vertex:dV,skinning_pars_vertex:fV,skinning_vertex:pV,skinnormal_vertex:mV,specularmap_fragment:gV,specularmap_pars_fragment:vV,tonemapping_fragment:AV,tonemapping_pars_fragment:yV,transmission_fragment:_V,transmission_pars_fragment:bV,uv_pars_fragment:xV,uv_pars_vertex:wV,uv_vertex:SV,worldpos_vertex:CV,background_vert:EV,background_frag:MV,backgroundCube_vert:TV,backgroundCube_frag:IV,cube_vert:RV,cube_frag:PV,depth_vert:BV,depth_frag:DV,distanceRGBA_vert:OV,distanceRGBA_frag:LV,equirect_vert:kV,equirect_frag:FV,linedashed_vert:UV,linedashed_frag:NV,meshbasic_vert:zV,meshbasic_frag:GV,meshlambert_vert:HV,meshlambert_frag:QV,meshmatcap_vert:VV,meshmatcap_frag:jV,meshnormal_vert:WV,meshnormal_frag:qV,meshphong_vert:XV,meshphong_frag:YV,meshphysical_vert:JV,meshphysical_frag:KV,meshtoon_vert:ZV,meshtoon_frag:$V,points_vert:e5,points_frag:t5,shadow_vert:i5,shadow_frag:n5,sprite_vert:s5,sprite_frag:r5},Fe={common:{diffuse:{value:new xe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Lt},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Lt}},envmap:{envMap:{value:null},envMapRotation:{value:new Lt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Lt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Lt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Lt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Lt},normalScale:{value:new te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Lt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Lt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Lt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Lt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new xe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0},uvTransform:{value:new Lt}},sprite:{diffuse:{value:new xe(16777215)},opacity:{value:1},center:{value:new te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Lt},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0}}},Ts={basic:{uniforms:mr([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.fog]),vertexShader:zt.meshbasic_vert,fragmentShader:zt.meshbasic_frag},lambert:{uniforms:mr([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,Fe.lights,{emissive:{value:new xe(0)}}]),vertexShader:zt.meshlambert_vert,fragmentShader:zt.meshlambert_frag},phong:{uniforms:mr([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,Fe.lights,{emissive:{value:new xe(0)},specular:{value:new xe(1118481)},shininess:{value:30}}]),vertexShader:zt.meshphong_vert,fragmentShader:zt.meshphong_frag},standard:{uniforms:mr([Fe.common,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.roughnessmap,Fe.metalnessmap,Fe.fog,Fe.lights,{emissive:{value:new xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:zt.meshphysical_vert,fragmentShader:zt.meshphysical_frag},toon:{uniforms:mr([Fe.common,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.gradientmap,Fe.fog,Fe.lights,{emissive:{value:new xe(0)}}]),vertexShader:zt.meshtoon_vert,fragmentShader:zt.meshtoon_frag},matcap:{uniforms:mr([Fe.common,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,{matcap:{value:null}}]),vertexShader:zt.meshmatcap_vert,fragmentShader:zt.meshmatcap_frag},points:{uniforms:mr([Fe.points,Fe.fog]),vertexShader:zt.points_vert,fragmentShader:zt.points_frag},dashed:{uniforms:mr([Fe.common,Fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:zt.linedashed_vert,fragmentShader:zt.linedashed_frag},depth:{uniforms:mr([Fe.common,Fe.displacementmap]),vertexShader:zt.depth_vert,fragmentShader:zt.depth_frag},normal:{uniforms:mr([Fe.common,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,{opacity:{value:1}}]),vertexShader:zt.meshnormal_vert,fragmentShader:zt.meshnormal_frag},sprite:{uniforms:mr([Fe.sprite,Fe.fog]),vertexShader:zt.sprite_vert,fragmentShader:zt.sprite_frag},background:{uniforms:{uvTransform:{value:new Lt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:zt.background_vert,fragmentShader:zt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Lt}},vertexShader:zt.backgroundCube_vert,fragmentShader:zt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:zt.cube_vert,fragmentShader:zt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:zt.equirect_vert,fragmentShader:zt.equirect_frag},distanceRGBA:{uniforms:mr([Fe.common,Fe.displacementmap,{referencePosition:{value:new w},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:zt.distanceRGBA_vert,fragmentShader:zt.distanceRGBA_frag},shadow:{uniforms:mr([Fe.lights,Fe.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:zt.shadow_vert,fragmentShader:zt.shadow_frag}};Ts.physical={uniforms:mr([Ts.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Lt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Lt},clearcoatNormalScale:{value:new te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Lt},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Lt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Lt},sheen:{value:0},sheenColor:{value:new xe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Lt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Lt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Lt},transmissionSamplerSize:{value:new te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Lt},attenuationDistance:{value:0},attenuationColor:{value:new xe(0)},specularColor:{value:new xe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Lt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Lt},anisotropyVector:{value:new te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Lt}}]),vertexShader:zt.meshphysical_vert,fragmentShader:zt.meshphysical_frag};const Dy={r:0,b:0,g:0},nu=new Gi,o5=new we;function a5(s,e,t,i,n,r,o){const a=new xe(0);let l=r===!0?0:1,c,u,d=null,f=0,p=null;function m(v,g){let _=!1,y=g.isScene===!0?g.background:null;y&&y.isTexture&&(y=(g.backgroundBlurriness>0?t:e).get(y)),y===null?A(a,l):y&&y.isColor&&(A(y,1),_=!0);const b=s.xr.getEnvironmentBlendMode();b==="additive"?i.buffers.color.setClear(0,0,0,1,o):b==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(s.autoClear||_)&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),y&&(y.isCubeTexture||y.mapping===Ep)?(u===void 0&&(u=new pe(new Li(1,1,1),new Pt({name:"BackgroundCubeMaterial",uniforms:pp(Ts.backgroundCube.uniforms),vertexShader:Ts.backgroundCube.vertexShader,fragmentShader:Ts.backgroundCube.fragmentShader,side:_n,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(E,M,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(u)),nu.copy(g.backgroundRotation),nu.x*=-1,nu.y*=-1,nu.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(nu.y*=-1,nu.z*=-1),u.material.uniforms.envMap.value=y,u.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=g.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(o5.makeRotationFromEuler(nu)),u.material.toneMapped=vi.getTransfer(y.colorSpace)!==Oi,(d!==y||f!==y.version||p!==s.toneMapping)&&(u.material.needsUpdate=!0,d=y,f=y.version,p=s.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new pe(new zn(2,2),new Pt({name:"BackgroundMaterial",uniforms:pp(Ts.background.uniforms),vertexShader:Ts.background.vertexShader,fragmentShader:Ts.background.fragmentShader,side:Bs,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,c.material.toneMapped=vi.getTransfer(y.colorSpace)!==Oi,y.matrixAutoUpdate===!0&&y.updateMatrix(),c.material.uniforms.uvTransform.value.copy(y.matrix),(d!==y||f!==y.version||p!==s.toneMapping)&&(c.material.needsUpdate=!0,d=y,f=y.version,p=s.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function A(v,g){v.getRGB(Dy,bF(s)),i.buffers.color.setClear(Dy.r,Dy.g,Dy.b,g,o)}return{getClearColor:function(){return a},setClearColor:function(v,g=1){a.set(v),l=g,A(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,A(a,l)},render:m}}function l5(s,e,t,i){const n=s.getParameter(s.MAX_VERTEX_ATTRIBS),r=i.isWebGL2?null:e.get("OES_vertex_array_object"),o=i.isWebGL2||r!==null,a={},l=v(null);let c=l,u=!1;function d(O,V,L,k,G){let Y=!1;if(o){const $=A(k,L,V);c!==$&&(c=$,p(c.object)),Y=g(O,k,L,G),Y&&_(O,k,L,G)}else{const $=V.wireframe===!0;(c.geometry!==k.id||c.program!==L.id||c.wireframe!==$)&&(c.geometry=k.id,c.program=L.id,c.wireframe=$,Y=!0)}G!==null&&t.update(G,s.ELEMENT_ARRAY_BUFFER),(Y||u)&&(u=!1,C(O,V,L,k),G!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.get(G).buffer))}function f(){return i.isWebGL2?s.createVertexArray():r.createVertexArrayOES()}function p(O){return i.isWebGL2?s.bindVertexArray(O):r.bindVertexArrayOES(O)}function m(O){return i.isWebGL2?s.deleteVertexArray(O):r.deleteVertexArrayOES(O)}function A(O,V,L){const k=L.wireframe===!0;let G=a[O.id];G===void 0&&(G={},a[O.id]=G);let Y=G[V.id];Y===void 0&&(Y={},G[V.id]=Y);let $=Y[k];return $===void 0&&($=v(f()),Y[k]=$),$}function v(O){const V=[],L=[],k=[];for(let G=0;G<n;G++)V[G]=0,L[G]=0,k[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:V,enabledAttributes:L,attributeDivisors:k,object:O,attributes:{},index:null}}function g(O,V,L,k){const G=c.attributes,Y=V.attributes;let $=0;const re=L.getAttributes();for(const ce in re)if(re[ce].location>=0){const ie=G[ce];let me=Y[ce];if(me===void 0&&(ce==="instanceMatrix"&&O.instanceMatrix&&(me=O.instanceMatrix),ce==="instanceColor"&&O.instanceColor&&(me=O.instanceColor)),ie===void 0||ie.attribute!==me||me&&ie.data!==me.data)return!0;$++}return c.attributesNum!==$||c.index!==k}function _(O,V,L,k){const G={},Y=V.attributes;let $=0;const re=L.getAttributes();for(const ce in re)if(re[ce].location>=0){let ie=Y[ce];ie===void 0&&(ce==="instanceMatrix"&&O.instanceMatrix&&(ie=O.instanceMatrix),ce==="instanceColor"&&O.instanceColor&&(ie=O.instanceColor));const me={};me.attribute=ie,ie&&ie.data&&(me.data=ie.data),G[ce]=me,$++}c.attributes=G,c.attributesNum=$,c.index=k}function y(){const O=c.newAttributes;for(let V=0,L=O.length;V<L;V++)O[V]=0}function b(O){E(O,0)}function E(O,V){const L=c.newAttributes,k=c.enabledAttributes,G=c.attributeDivisors;L[O]=1,k[O]===0&&(s.enableVertexAttribArray(O),k[O]=1),G[O]!==V&&((i.isWebGL2?s:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](O,V),G[O]=V)}function M(){const O=c.newAttributes,V=c.enabledAttributes;for(let L=0,k=V.length;L<k;L++)V[L]!==O[L]&&(s.disableVertexAttribArray(L),V[L]=0)}function T(O,V,L,k,G,Y,$){$===!0?s.vertexAttribIPointer(O,V,L,G,Y):s.vertexAttribPointer(O,V,L,k,G,Y)}function C(O,V,L,k){if(i.isWebGL2===!1&&(O.isInstancedMesh||k.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;y();const G=k.attributes,Y=L.getAttributes(),$=V.defaultAttributeValues;for(const re in Y){const ce=Y[re];if(ce.location>=0){let Re=G[re];if(Re===void 0&&(re==="instanceMatrix"&&O.instanceMatrix&&(Re=O.instanceMatrix),re==="instanceColor"&&O.instanceColor&&(Re=O.instanceColor)),Re!==void 0){const ie=Re.normalized,me=Re.itemSize,be=t.get(Re);if(be===void 0)continue;const Ve=be.buffer,je=be.type,Ge=be.bytesPerElement,dt=i.isWebGL2===!0&&(je===s.INT||je===s.UNSIGNED_INT||Re.gpuType===ZM);if(Re.isInterleavedBufferAttribute){const tt=Re.data,W=tt.stride,Ne=Re.offset;if(tt.isInstancedInterleavedBuffer){for(let ye=0;ye<ce.locationSize;ye++)E(ce.location+ye,tt.meshPerAttribute);O.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=tt.meshPerAttribute*tt.count)}else for(let ye=0;ye<ce.locationSize;ye++)b(ce.location+ye);s.bindBuffer(s.ARRAY_BUFFER,Ve);for(let ye=0;ye<ce.locationSize;ye++)T(ce.location+ye,me/ce.locationSize,je,ie,W*Ge,(Ne+me/ce.locationSize*ye)*Ge,dt)}else{if(Re.isInstancedBufferAttribute){for(let tt=0;tt<ce.locationSize;tt++)E(ce.location+tt,Re.meshPerAttribute);O.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=Re.meshPerAttribute*Re.count)}else for(let tt=0;tt<ce.locationSize;tt++)b(ce.location+tt);s.bindBuffer(s.ARRAY_BUFFER,Ve);for(let tt=0;tt<ce.locationSize;tt++)T(ce.location+tt,me/ce.locationSize,je,ie,me*Ge,me/ce.locationSize*tt*Ge,dt)}}else if($!==void 0){const ie=$[re];if(ie!==void 0)switch(ie.length){case 2:s.vertexAttrib2fv(ce.location,ie);break;case 3:s.vertexAttrib3fv(ce.location,ie);break;case 4:s.vertexAttrib4fv(ce.location,ie);break;default:s.vertexAttrib1fv(ce.location,ie)}}}}M()}function B(){Q();for(const O in a){const V=a[O];for(const L in V){const k=V[L];for(const G in k)m(k[G].object),delete k[G];delete V[L]}delete a[O]}}function S(O){if(a[O.id]===void 0)return;const V=a[O.id];for(const L in V){const k=V[L];for(const G in k)m(k[G].object),delete k[G];delete V[L]}delete a[O.id]}function R(O){for(const V in a){const L=a[V];if(L[O.id]===void 0)continue;const k=L[O.id];for(const G in k)m(k[G].object),delete k[G];delete L[O.id]}}function Q(){z(),u=!0,c!==l&&(c=l,p(c.object))}function z(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:d,reset:Q,resetDefaultState:z,dispose:B,releaseStatesOfGeometry:S,releaseStatesOfProgram:R,initAttributes:y,enableAttribute:b,disableUnusedAttributes:M}}function c5(s,e,t,i){const n=i.isWebGL2;let r;function o(u){r=u}function a(u,d){s.drawArrays(r,u,d),t.update(d,r,1)}function l(u,d,f){if(f===0)return;let p,m;if(n)p=s,m="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),m="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[m](r,u,d,f),t.update(d,r,f)}function c(u,d,f){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<f;m++)this.render(u[m],d[m]);else{p.multiDrawArraysWEBGL(r,u,0,d,0,f);let m=0;for(let A=0;A<f;A++)m+=d[A];t.update(m,r,1)}}this.setMode=o,this.render=a,this.renderInstances=l,this.renderMultiDraw=c}function h5(s,e,t){let i;function n(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function r(T){if(T==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&s.constructor.name==="WebGL2RenderingContext";let a=t.precision!==void 0?t.precision:"highp";const l=r(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,d=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),f=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),A=s.getParameter(s.MAX_VERTEX_ATTRIBS),v=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),g=s.getParameter(s.MAX_VARYING_VECTORS),_=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),y=f>0,b=o||e.has("OES_texture_float"),E=y&&b,M=o?s.getParameter(s.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:n,getMaxPrecision:r,precision:a,logarithmicDepthBuffer:u,maxTextures:d,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:m,maxAttributes:A,maxVertexUniforms:v,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:y,floatFragmentTextures:b,floatVertexTextures:E,maxSamples:M}}function u5(s){const e=this;let t=null,i=0,n=!1,r=!1;const o=new Ar,a=new Lt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){const p=d.length!==0||f||i!==0||n;return n=f,i=d.length,p},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,f){t=u(d,f,0)},this.setState=function(d,f,p){const m=d.clippingPlanes,A=d.clipIntersection,v=d.clipShadows,g=s.get(d);if(!n||m===null||m.length===0||r&&!v)r?u(null):c();else{const _=r?0:i,y=_*4;let b=g.clippingState||null;l.value=b,b=u(m,f,y,p);for(let E=0;E!==y;++E)b[E]=t[E];g.clippingState=b,this.numIntersection=A?this.numPlanes:0,this.numPlanes+=_}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,f,p,m){const A=d!==null?d.length:0;let v=null;if(A!==0){if(v=l.value,m!==!0||v===null){const g=p+A*4,_=f.matrixWorldInverse;a.getNormalMatrix(_),(v===null||v.length<g)&&(v=new Float32Array(g));for(let y=0,b=p;y!==A;++y,b+=4)o.copy(d[y]).applyMatrix4(_,a),o.normal.toArray(v,b),v[b+3]=o.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=A,e.numIntersection=0,v}}function d5(s){let e=new WeakMap;function t(o,a){return a===zo?o.mapping=pc:a===up&&(o.mapping=Eh),o}function i(o){if(o&&o.isTexture){const a=o.mapping;if(a===zo||a===up)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new fT(l.height);return c.fromEquirectangularTexture(s,o),e.set(o,c),o.addEventListener("dispose",n),t(c.texture,o.mapping)}else return null}}return o}function n(o){const a=o.target;a.removeEventListener("dispose",n);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function r(){e=new WeakMap}return{get:i,dispose:r}}class yc extends jv{constructor(e=-1,t=1,i=1,n=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,r,o){this.view===null&&(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=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,o=i+e,a=n+t,l=n-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const kf=4,KP=[.125,.215,.35,.446,.526,.582],Tu=20,yS=new yc,ZP=new xe;let _S=null,bS=0,xS=0;const Cu=(1+Math.sqrt(5))/2,rf=1/Cu,$P=[new w(1,1,1),new w(-1,1,1),new w(1,1,-1),new w(-1,1,-1),new w(0,Cu,rf),new w(0,Cu,-rf),new w(rf,0,Cu),new w(-rf,0,Cu),new w(Cu,rf,0),new w(-Cu,rf,0)];class r1{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,n=100){_S=this._renderer.getRenderTarget(),bS=this._renderer.getActiveCubeFace(),xS=this._renderer.getActiveMipmapLevel(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,i,n,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=nB(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=iB(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(_S,bS,xS),e.scissorTest=!1,Oy(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===pc||e.mapping===Eh?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),_S=this._renderer.getRenderTarget(),bS=this._renderer.getActiveCubeFace(),xS=this._renderer.getActiveMipmapLevel();const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Mt,minFilter:Mt,generateMipmaps:!1,type:cn,format:Ai,colorSpace:yi,depthBuffer:!1},n=tB(e,t,i),{_lodMax:r}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=eB(r),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=tB(e,t,i);const{_lodMax:o}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=eB(o)),this._blurMaterial=f5(o,e,t)}return n}_compileMaterial(e){const t=new pe(this._lodPlanes[0],e);this._renderer.compile(t,yS)}_sceneToCubeUV(e,t,i,n){const a=new Qt(90,1,t,i),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(ZP),u.toneMapping=ho,u.autoClear=!1;const p=new ai({name:"PMREM.Background",side:_n,depthWrite:!1,depthTest:!1}),m=new pe(new Li,p);let A=!1;const v=e.background;v?v.isColor&&(p.color.copy(v),e.background=null,A=!0):(p.color.copy(ZP),A=!0);for(let g=0;g<6;g++){const _=g%3;_===0?(a.up.set(0,l[g],0),a.lookAt(c[g],0,0)):_===1?(a.up.set(0,0,l[g]),a.lookAt(0,c[g],0)):(a.up.set(0,l[g],0),a.lookAt(0,0,c[g]));const y=this._cubeSize;Oy(n,_*y,g>2?y:0,y,y),u.setRenderTarget(n),A&&u.render(m,a),u.render(e,a)}m.geometry.dispose(),m.material.dispose(),u.toneMapping=f,u.autoClear=d,e.background=v}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===pc||e.mapping===Eh;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=nB()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=iB());const r=n?this._cubemapMaterial:this._equirectMaterial,o=new pe(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const l=this._cubeSize;Oy(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,yS)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let n=1;n<this._lodPlanes.length;n++){const r=Math.sqrt(this._sigmas[n]*this._sigmas[n]-this._sigmas[n-1]*this._sigmas[n-1]),o=$P[(n-1)%$P.length];this._blur(e,n-1,n,r,o)}t.autoClear=i}_blur(e,t,i,n,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,n,"latitudinal",r),this._halfBlur(o,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,r,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,d=new pe(this._lodPlanes[n],c),f=c.uniforms,p=this._sizeLods[i]-1,m=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Tu-1),A=r/m,v=isFinite(r)?1+Math.floor(u*A):Tu;v>Tu&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Tu}`);const g=[];let _=0;for(let T=0;T<Tu;++T){const C=T/A,B=Math.exp(-C*C/2);g.push(B),T===0?_+=B:T<v&&(_+=2*B)}for(let T=0;T<g.length;T++)g[T]=g[T]/_;f.envMap.value=e.texture,f.samples.value=v,f.weights.value=g,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);const{_lodMax:y}=this;f.dTheta.value=m,f.mipInt.value=y-i;const b=this._sizeLods[n],E=3*b*(n>y-kf?n-y+kf:0),M=4*(this._cubeSize-b);Oy(t,E,M,3*b,2*b),l.setRenderTarget(t),l.render(d,yS)}}function eB(s){const e=[],t=[],i=[];let n=s;const r=s-kf+1+KP.length;for(let o=0;o<r;o++){const a=Math.pow(2,n);t.push(a);let l=1/a;o>s-kf?l=KP[o-s+kf-1]:o===0&&(l=0),i.push(l);const c=1/(a-2),u=-c,d=1+c,f=[u,u,d,u,d,d,u,u,d,d,u,d],p=6,m=6,A=3,v=2,g=1,_=new Float32Array(A*m*p),y=new Float32Array(v*m*p),b=new Float32Array(g*m*p);for(let M=0;M<p;M++){const T=M%3*2/3-1,C=M>2?0:-1,B=[T,C,0,T+2/3,C,0,T+2/3,C+1,0,T,C,0,T+2/3,C+1,0,T,C+1,0];_.set(B,A*m*M),y.set(f,v*m*M);const S=[M,M,M,M,M,M];b.set(S,g*m*M)}const E=new wt;E.setAttribute("position",new it(_,A)),E.setAttribute("uv",new it(y,v)),E.setAttribute("faceIndex",new it(b,g)),e.push(E),n>kf&&n--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function tB(s,e,t){const i=new Yt(s,e,t);return i.texture.mapping=Ep,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Oy(s,e,t,i,n){s.viewport.set(e,t,i,n),s.scissor.set(e,t,i,n)}function f5(s,e,t){const i=new Float32Array(Tu),n=new w(0,1,0);return new Pt({name:"SphericalGaussianBlur",defines:{n:Tu,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:pT(),fragmentShader:`
3560
3560
 
3561
3561
  precision mediump float;
3562
3562
  precision mediump int;
@@ -3706,7 +3706,7 @@ void main() {
3706
3706
  gl_Position = vec4( position, 1.0 );
3707
3707
 
3708
3708
  }
3709
- `}function pV(s){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const l=a.mapping,c=l===zo||l===up,u=l===pc||l===Eh;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let d=e.get(a);return t===null&&(t=new r1(s)),d=c?t.fromEquirectangular(a,d):t.fromCubemap(a,d),e.set(a,d),d.texture}else{if(e.has(a))return e.get(a).texture;{const d=a.image;if(c&&d&&d.height>0||u&&d&&n(d)){t=new r1(s);const f=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,f),a.addEventListener("dispose",r),f.texture}else return null}}}return a}function n(a){let l=0;const c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function r(a){const l=a.target;l.removeEventListener("dispose",r);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function mV(s){const e={};function t(i){if(e[i]!==void 0)return e[i];let n;switch(i){case"WEBGL_depth_texture":n=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=s.getExtension(i)}return e[i]=n,n}return{has:function(i){return t(i)!==null},init:function(i){i.isWebGL2?(t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance")):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(i){const n=t(i);return n===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),n}}}function gV(s,e,t,i){const n={},r=new WeakMap;function o(d){const f=d.target;f.index!==null&&e.remove(f.index);for(const m in f.attributes)e.remove(f.attributes[m]);for(const m in f.morphAttributes){const A=f.morphAttributes[m];for(let v=0,g=A.length;v<g;v++)e.remove(A[v])}f.removeEventListener("dispose",o),delete n[f.id];const p=r.get(f);p&&(e.remove(p),r.delete(f)),i.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function a(d,f){return n[f.id]===!0||(f.addEventListener("dispose",o),n[f.id]=!0,t.memory.geometries++),f}function l(d){const f=d.attributes;for(const m in f)e.update(f[m],s.ARRAY_BUFFER);const p=d.morphAttributes;for(const m in p){const A=p[m];for(let v=0,g=A.length;v<g;v++)e.update(A[v],s.ARRAY_BUFFER)}}function c(d){const f=[],p=d.index,m=d.attributes.position;let A=0;if(p!==null){const _=p.array;A=p.version;for(let y=0,b=_.length;y<b;y+=3){const E=_[y+0],M=_[y+1],T=_[y+2];f.push(E,M,M,T,T,E)}}else if(m!==void 0){const _=m.array;A=m.version;for(let y=0,b=_.length/3-1;y<b;y+=3){const E=y+0,M=y+1,T=y+2;f.push(E,M,M,T,T,E)}}else return;const v=new(gF(f)?uT:hT)(f,1);v.version=A;const g=r.get(d);g&&e.remove(g),r.set(d,v)}function u(d){const f=r.get(d);if(f){const p=d.index;p!==null&&f.version<p.version&&c(d)}else c(d);return r.get(d)}return{get:a,update:l,getWireframeAttribute:u}}function vV(s,e,t,i){const n=i.isWebGL2;let r;function o(p){r=p}let a,l;function c(p){a=p.type,l=p.bytesPerElement}function u(p,m){s.drawElements(r,m,a,p*l),t.update(m,r,1)}function d(p,m,A){if(A===0)return;let v,g;if(n)v=s,g="drawElementsInstanced";else if(v=e.get("ANGLE_instanced_arrays"),g="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[g](r,m,a,p*l,A),t.update(m,r,A)}function f(p,m,A){if(A===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let g=0;g<A;g++)this.render(p[g]/l,m[g]);else{v.multiDrawElementsWEBGL(r,m,0,a,p,0,A);let g=0;for(let _=0;_<A;_++)g+=m[_];t.update(g,r,1)}}this.setMode=o,this.setIndex=c,this.render=u,this.renderInstances=d,this.renderMultiDraw=f}function AV(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,o,a){switch(t.calls++,o){case s.TRIANGLES:t.triangles+=a*(r/3);break;case s.LINES:t.lines+=a*(r/2);break;case s.LINE_STRIP:t.lines+=a*(r-1);break;case s.LINE_LOOP:t.lines+=a*r;break;case s.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function n(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:n,update:i}}function yV(s,e){return s[0]-e[0]}function _V(s,e){return Math.abs(e[1])-Math.abs(s[1])}function bV(s,e,t){const i={},n=new Float32Array(8),r=new WeakMap,o=new Ze,a=[];for(let c=0;c<8;c++)a[c]=[c,0];function l(c,u,d){const f=c.morphTargetInfluences;if(e.isWebGL2===!0){const p=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,m=p!==void 0?p.length:0;let A=r.get(u);if(A===void 0||A.count!==m){let Q=function(){S.dispose(),r.delete(u),u.removeEventListener("dispose",Q)};A!==void 0&&A.texture.dispose();const v=u.morphAttributes.position!==void 0,g=u.morphAttributes.normal!==void 0,_=u.morphAttributes.color!==void 0,y=u.morphAttributes.position||[],b=u.morphAttributes.normal||[],E=u.morphAttributes.color||[];let M=0;v===!0&&(M=1),g===!0&&(M=2),_===!0&&(M=3);let T=u.attributes.position.count*M,C=1;T>e.maxTextureSize&&(C=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const B=new Float32Array(T*C*4*m),S=new ox(B,T,C,m);S.type=Ni,S.needsUpdate=!0;const R=M*4;for(let z=0;z<m;z++){const O=y[z],V=b[z],L=E[z],k=T*C*4*z;for(let G=0;G<O.count;G++){const Y=G*R;v===!0&&(o.fromBufferAttribute(O,G),B[k+Y+0]=o.x,B[k+Y+1]=o.y,B[k+Y+2]=o.z,B[k+Y+3]=0),g===!0&&(o.fromBufferAttribute(V,G),B[k+Y+4]=o.x,B[k+Y+5]=o.y,B[k+Y+6]=o.z,B[k+Y+7]=0),_===!0&&(o.fromBufferAttribute(L,G),B[k+Y+8]=o.x,B[k+Y+9]=o.y,B[k+Y+10]=o.z,B[k+Y+11]=L.itemSize===4?o.w:1)}}A={count:m,texture:S,size:new te(T,C)},r.set(u,A),u.addEventListener("dispose",Q)}if(c.isInstancedMesh===!0&&c.morphTexture!==null)d.getUniforms().setValue(s,"morphTexture",c.morphTexture,t);else{let v=0;for(let _=0;_<f.length;_++)v+=f[_];const g=u.morphTargetsRelative?1:1-v;d.getUniforms().setValue(s,"morphTargetBaseInfluence",g),d.getUniforms().setValue(s,"morphTargetInfluences",f)}d.getUniforms().setValue(s,"morphTargetsTexture",A.texture,t),d.getUniforms().setValue(s,"morphTargetsTextureSize",A.size)}else{const p=f===void 0?0:f.length;let m=i[u.id];if(m===void 0||m.length!==p){m=[];for(let y=0;y<p;y++)m[y]=[y,0];i[u.id]=m}for(let y=0;y<p;y++){const b=m[y];b[0]=y,b[1]=f[y]}m.sort(_V);for(let y=0;y<8;y++)y<p&&m[y][1]?(a[y][0]=m[y][0],a[y][1]=m[y][1]):(a[y][0]=Number.MAX_SAFE_INTEGER,a[y][1]=0);a.sort(yV);const A=u.morphAttributes.position,v=u.morphAttributes.normal;let g=0;for(let y=0;y<8;y++){const b=a[y],E=b[0],M=b[1];E!==Number.MAX_SAFE_INTEGER&&M?(A&&u.getAttribute("morphTarget"+y)!==A[E]&&u.setAttribute("morphTarget"+y,A[E]),v&&u.getAttribute("morphNormal"+y)!==v[E]&&u.setAttribute("morphNormal"+y,v[E]),n[y]=M,g+=M):(A&&u.hasAttribute("morphTarget"+y)===!0&&u.deleteAttribute("morphTarget"+y),v&&u.hasAttribute("morphNormal"+y)===!0&&u.deleteAttribute("morphNormal"+y),n[y]=0)}const _=u.morphTargetsRelative?1:1-g;d.getUniforms().setValue(s,"morphTargetBaseInfluence",_),d.getUniforms().setValue(s,"morphTargetInfluences",n)}}return{update:l}}function xV(s,e,t,i){let n=new WeakMap;function r(l){const c=i.render.frame,u=l.geometry,d=e.get(l,u);if(n.get(d)!==c&&(e.update(d),n.set(d,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),n.get(l)!==c&&(t.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,s.ARRAY_BUFFER),n.set(l,c))),l.isSkinnedMesh){const f=l.skeleton;n.get(f)!==c&&(f.update(),n.set(f,c))}return d}function o(){n=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:r,dispose:o}}class Ip extends Dt{constructor(e,t,i,n,r,o,a,l,c,u){if(u=u!==void 0?u:vh,u!==vh&&u!==Mh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===vh&&(i=fa),i===void 0&&u===Mh&&(i=ac),super(null,n,r,o,a,l,u,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Ht,this.minFilter=l!==void 0?l:Ht,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const wF=new Dt,SF=new Ip(1,1);SF.compareFunction=aT;const CF=new ox,EF=new ax,MF=new Wv,sB=[],rB=[],oB=new Float32Array(16),aB=new Float32Array(9),lB=new Float32Array(4);function Rp(s,e,t){const i=s[0];if(i<=0||i>0)return s;const n=e*t;let r=sB[n];if(r===void 0&&(r=new Float32Array(n),sB[n]=r),e!==0){i.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,s[o].toArray(r,a)}return r}function Zn(s,e){if(s.length!==e.length)return!1;for(let t=0,i=s.length;t<i;t++)if(s[t]!==e[t])return!1;return!0}function $n(s,e){for(let t=0,i=e.length;t<i;t++)s[t]=e[t]}function lx(s,e){let t=rB[e];t===void 0&&(t=new Int32Array(e),rB[e]=t);for(let i=0;i!==e;++i)t[i]=s.allocateTextureUnit();return t}function wV(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function SV(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Zn(t,e))return;s.uniform2fv(this.addr,e),$n(t,e)}}function CV(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Zn(t,e))return;s.uniform3fv(this.addr,e),$n(t,e)}}function EV(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Zn(t,e))return;s.uniform4fv(this.addr,e),$n(t,e)}}function MV(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(Zn(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),$n(t,e)}else{if(Zn(t,i))return;lB.set(i),s.uniformMatrix2fv(this.addr,!1,lB),$n(t,i)}}function TV(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(Zn(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),$n(t,e)}else{if(Zn(t,i))return;aB.set(i),s.uniformMatrix3fv(this.addr,!1,aB),$n(t,i)}}function IV(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(Zn(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),$n(t,e)}else{if(Zn(t,i))return;oB.set(i),s.uniformMatrix4fv(this.addr,!1,oB),$n(t,i)}}function RV(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function PV(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Zn(t,e))return;s.uniform2iv(this.addr,e),$n(t,e)}}function BV(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Zn(t,e))return;s.uniform3iv(this.addr,e),$n(t,e)}}function DV(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Zn(t,e))return;s.uniform4iv(this.addr,e),$n(t,e)}}function OV(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function LV(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Zn(t,e))return;s.uniform2uiv(this.addr,e),$n(t,e)}}function kV(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Zn(t,e))return;s.uniform3uiv(this.addr,e),$n(t,e)}}function FV(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Zn(t,e))return;s.uniform4uiv(this.addr,e),$n(t,e)}}function UV(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n);const r=this.type===s.SAMPLER_2D_SHADOW?SF:wF;t.setTexture2D(e||r,n)}function NV(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTexture3D(e||EF,n)}function zV(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTextureCube(e||MF,n)}function GV(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTexture2DArray(e||CF,n)}function HV(s){switch(s){case 5126:return wV;case 35664:return SV;case 35665:return CV;case 35666:return EV;case 35674:return MV;case 35675:return TV;case 35676:return IV;case 5124:case 35670:return RV;case 35667:case 35671:return PV;case 35668:case 35672:return BV;case 35669:case 35673:return DV;case 5125:return OV;case 36294:return LV;case 36295:return kV;case 36296:return FV;case 35678:case 36198:case 36298:case 36306:case 35682:return UV;case 35679:case 36299:case 36307:return NV;case 35680:case 36300:case 36308:case 36293:return zV;case 36289:case 36303:case 36311:case 36292:return GV}}function QV(s,e){s.uniform1fv(this.addr,e)}function VV(s,e){const t=Rp(e,this.size,2);s.uniform2fv(this.addr,t)}function jV(s,e){const t=Rp(e,this.size,3);s.uniform3fv(this.addr,t)}function WV(s,e){const t=Rp(e,this.size,4);s.uniform4fv(this.addr,t)}function qV(s,e){const t=Rp(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function XV(s,e){const t=Rp(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function YV(s,e){const t=Rp(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function JV(s,e){s.uniform1iv(this.addr,e)}function KV(s,e){s.uniform2iv(this.addr,e)}function ZV(s,e){s.uniform3iv(this.addr,e)}function $V(s,e){s.uniform4iv(this.addr,e)}function e6(s,e){s.uniform1uiv(this.addr,e)}function t6(s,e){s.uniform2uiv(this.addr,e)}function i6(s,e){s.uniform3uiv(this.addr,e)}function n6(s,e){s.uniform4uiv(this.addr,e)}function s6(s,e,t){const i=this.cache,n=e.length,r=lx(t,n);Zn(i,r)||(s.uniform1iv(this.addr,r),$n(i,r));for(let o=0;o!==n;++o)t.setTexture2D(e[o]||wF,r[o])}function r6(s,e,t){const i=this.cache,n=e.length,r=lx(t,n);Zn(i,r)||(s.uniform1iv(this.addr,r),$n(i,r));for(let o=0;o!==n;++o)t.setTexture3D(e[o]||EF,r[o])}function o6(s,e,t){const i=this.cache,n=e.length,r=lx(t,n);Zn(i,r)||(s.uniform1iv(this.addr,r),$n(i,r));for(let o=0;o!==n;++o)t.setTextureCube(e[o]||MF,r[o])}function a6(s,e,t){const i=this.cache,n=e.length,r=lx(t,n);Zn(i,r)||(s.uniform1iv(this.addr,r),$n(i,r));for(let o=0;o!==n;++o)t.setTexture2DArray(e[o]||CF,r[o])}function l6(s){switch(s){case 5126:return QV;case 35664:return VV;case 35665:return jV;case 35666:return WV;case 35674:return qV;case 35675:return XV;case 35676:return YV;case 5124:case 35670:return JV;case 35667:case 35671:return KV;case 35668:case 35672:return ZV;case 35669:case 35673:return $V;case 5125:return e6;case 36294:return t6;case 36295:return i6;case 36296:return n6;case 35678:case 36198:case 36298:case 36306:case 35682:return s6;case 35679:case 36299:case 36307:return r6;case 35680:case 36300:case 36308:case 36293:return o6;case 36289:case 36303:case 36311:case 36292:return a6}}class c6{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=HV(t.type)}}class h6{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=l6(t.type)}}class u6{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const n=this.seq;for(let r=0,o=n.length;r!==o;++r){const a=n[r];a.setValue(e,t[a.id],i)}}}const wS=/(\w+)(\])?(\[|\.)?/g;function cB(s,e){s.seq.push(e),s.map[e.id]=e}function d6(s,e,t){const i=s.name,n=i.length;for(wS.lastIndex=0;;){const r=wS.exec(i),o=wS.lastIndex;let a=r[1];const l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===n){cB(t,c===void 0?new c6(a,s,e):new h6(a,s,e));break}else{let d=t.map[a];d===void 0&&(d=new u6(a),cB(t,d)),t=d}}}class c_{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const r=e.getActiveUniform(t,n),o=e.getUniformLocation(t,r.name);d6(r,o,this)}}setValue(e,t,i,n){const r=this.map[t];r!==void 0&&r.setValue(e,i,n)}setOptional(e,t,i){const n=t[i];n!==void 0&&this.setValue(e,i,n)}static upload(e,t,i,n){for(let r=0,o=t.length;r!==o;++r){const a=t[r],l=i[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,n)}}static seqWithValue(e,t){const i=[];for(let n=0,r=e.length;n!==r;++n){const o=e[n];o.id in t&&i.push(o)}return i}}function hB(s,e,t){const i=s.createShader(e);return s.shaderSource(i,t),s.compileShader(i),i}const f6=37297;let p6=0;function m6(s,e){const t=s.split(`
3709
+ `}function p5(s){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const l=a.mapping,c=l===zo||l===up,u=l===pc||l===Eh;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let d=e.get(a);return t===null&&(t=new r1(s)),d=c?t.fromEquirectangular(a,d):t.fromCubemap(a,d),e.set(a,d),d.texture}else{if(e.has(a))return e.get(a).texture;{const d=a.image;if(c&&d&&d.height>0||u&&d&&n(d)){t=new r1(s);const f=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,f),a.addEventListener("dispose",r),f.texture}else return null}}}return a}function n(a){let l=0;const c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function r(a){const l=a.target;l.removeEventListener("dispose",r);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function m5(s){const e={};function t(i){if(e[i]!==void 0)return e[i];let n;switch(i){case"WEBGL_depth_texture":n=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=s.getExtension(i)}return e[i]=n,n}return{has:function(i){return t(i)!==null},init:function(i){i.isWebGL2?(t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance")):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(i){const n=t(i);return n===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),n}}}function g5(s,e,t,i){const n={},r=new WeakMap;function o(d){const f=d.target;f.index!==null&&e.remove(f.index);for(const m in f.attributes)e.remove(f.attributes[m]);for(const m in f.morphAttributes){const A=f.morphAttributes[m];for(let v=0,g=A.length;v<g;v++)e.remove(A[v])}f.removeEventListener("dispose",o),delete n[f.id];const p=r.get(f);p&&(e.remove(p),r.delete(f)),i.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function a(d,f){return n[f.id]===!0||(f.addEventListener("dispose",o),n[f.id]=!0,t.memory.geometries++),f}function l(d){const f=d.attributes;for(const m in f)e.update(f[m],s.ARRAY_BUFFER);const p=d.morphAttributes;for(const m in p){const A=p[m];for(let v=0,g=A.length;v<g;v++)e.update(A[v],s.ARRAY_BUFFER)}}function c(d){const f=[],p=d.index,m=d.attributes.position;let A=0;if(p!==null){const _=p.array;A=p.version;for(let y=0,b=_.length;y<b;y+=3){const E=_[y+0],M=_[y+1],T=_[y+2];f.push(E,M,M,T,T,E)}}else if(m!==void 0){const _=m.array;A=m.version;for(let y=0,b=_.length/3-1;y<b;y+=3){const E=y+0,M=y+1,T=y+2;f.push(E,M,M,T,T,E)}}else return;const v=new(gF(f)?uT:hT)(f,1);v.version=A;const g=r.get(d);g&&e.remove(g),r.set(d,v)}function u(d){const f=r.get(d);if(f){const p=d.index;p!==null&&f.version<p.version&&c(d)}else c(d);return r.get(d)}return{get:a,update:l,getWireframeAttribute:u}}function v5(s,e,t,i){const n=i.isWebGL2;let r;function o(p){r=p}let a,l;function c(p){a=p.type,l=p.bytesPerElement}function u(p,m){s.drawElements(r,m,a,p*l),t.update(m,r,1)}function d(p,m,A){if(A===0)return;let v,g;if(n)v=s,g="drawElementsInstanced";else if(v=e.get("ANGLE_instanced_arrays"),g="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[g](r,m,a,p*l,A),t.update(m,r,A)}function f(p,m,A){if(A===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let g=0;g<A;g++)this.render(p[g]/l,m[g]);else{v.multiDrawElementsWEBGL(r,m,0,a,p,0,A);let g=0;for(let _=0;_<A;_++)g+=m[_];t.update(g,r,1)}}this.setMode=o,this.setIndex=c,this.render=u,this.renderInstances=d,this.renderMultiDraw=f}function A5(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,o,a){switch(t.calls++,o){case s.TRIANGLES:t.triangles+=a*(r/3);break;case s.LINES:t.lines+=a*(r/2);break;case s.LINE_STRIP:t.lines+=a*(r-1);break;case s.LINE_LOOP:t.lines+=a*r;break;case s.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function n(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:n,update:i}}function y5(s,e){return s[0]-e[0]}function _5(s,e){return Math.abs(e[1])-Math.abs(s[1])}function b5(s,e,t){const i={},n=new Float32Array(8),r=new WeakMap,o=new Ze,a=[];for(let c=0;c<8;c++)a[c]=[c,0];function l(c,u,d){const f=c.morphTargetInfluences;if(e.isWebGL2===!0){const p=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,m=p!==void 0?p.length:0;let A=r.get(u);if(A===void 0||A.count!==m){let Q=function(){S.dispose(),r.delete(u),u.removeEventListener("dispose",Q)};A!==void 0&&A.texture.dispose();const v=u.morphAttributes.position!==void 0,g=u.morphAttributes.normal!==void 0,_=u.morphAttributes.color!==void 0,y=u.morphAttributes.position||[],b=u.morphAttributes.normal||[],E=u.morphAttributes.color||[];let M=0;v===!0&&(M=1),g===!0&&(M=2),_===!0&&(M=3);let T=u.attributes.position.count*M,C=1;T>e.maxTextureSize&&(C=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const B=new Float32Array(T*C*4*m),S=new ox(B,T,C,m);S.type=Ni,S.needsUpdate=!0;const R=M*4;for(let z=0;z<m;z++){const O=y[z],V=b[z],L=E[z],k=T*C*4*z;for(let G=0;G<O.count;G++){const Y=G*R;v===!0&&(o.fromBufferAttribute(O,G),B[k+Y+0]=o.x,B[k+Y+1]=o.y,B[k+Y+2]=o.z,B[k+Y+3]=0),g===!0&&(o.fromBufferAttribute(V,G),B[k+Y+4]=o.x,B[k+Y+5]=o.y,B[k+Y+6]=o.z,B[k+Y+7]=0),_===!0&&(o.fromBufferAttribute(L,G),B[k+Y+8]=o.x,B[k+Y+9]=o.y,B[k+Y+10]=o.z,B[k+Y+11]=L.itemSize===4?o.w:1)}}A={count:m,texture:S,size:new te(T,C)},r.set(u,A),u.addEventListener("dispose",Q)}if(c.isInstancedMesh===!0&&c.morphTexture!==null)d.getUniforms().setValue(s,"morphTexture",c.morphTexture,t);else{let v=0;for(let _=0;_<f.length;_++)v+=f[_];const g=u.morphTargetsRelative?1:1-v;d.getUniforms().setValue(s,"morphTargetBaseInfluence",g),d.getUniforms().setValue(s,"morphTargetInfluences",f)}d.getUniforms().setValue(s,"morphTargetsTexture",A.texture,t),d.getUniforms().setValue(s,"morphTargetsTextureSize",A.size)}else{const p=f===void 0?0:f.length;let m=i[u.id];if(m===void 0||m.length!==p){m=[];for(let y=0;y<p;y++)m[y]=[y,0];i[u.id]=m}for(let y=0;y<p;y++){const b=m[y];b[0]=y,b[1]=f[y]}m.sort(_5);for(let y=0;y<8;y++)y<p&&m[y][1]?(a[y][0]=m[y][0],a[y][1]=m[y][1]):(a[y][0]=Number.MAX_SAFE_INTEGER,a[y][1]=0);a.sort(y5);const A=u.morphAttributes.position,v=u.morphAttributes.normal;let g=0;for(let y=0;y<8;y++){const b=a[y],E=b[0],M=b[1];E!==Number.MAX_SAFE_INTEGER&&M?(A&&u.getAttribute("morphTarget"+y)!==A[E]&&u.setAttribute("morphTarget"+y,A[E]),v&&u.getAttribute("morphNormal"+y)!==v[E]&&u.setAttribute("morphNormal"+y,v[E]),n[y]=M,g+=M):(A&&u.hasAttribute("morphTarget"+y)===!0&&u.deleteAttribute("morphTarget"+y),v&&u.hasAttribute("morphNormal"+y)===!0&&u.deleteAttribute("morphNormal"+y),n[y]=0)}const _=u.morphTargetsRelative?1:1-g;d.getUniforms().setValue(s,"morphTargetBaseInfluence",_),d.getUniforms().setValue(s,"morphTargetInfluences",n)}}return{update:l}}function x5(s,e,t,i){let n=new WeakMap;function r(l){const c=i.render.frame,u=l.geometry,d=e.get(l,u);if(n.get(d)!==c&&(e.update(d),n.set(d,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),n.get(l)!==c&&(t.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,s.ARRAY_BUFFER),n.set(l,c))),l.isSkinnedMesh){const f=l.skeleton;n.get(f)!==c&&(f.update(),n.set(f,c))}return d}function o(){n=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:r,dispose:o}}class Ip extends Dt{constructor(e,t,i,n,r,o,a,l,c,u){if(u=u!==void 0?u:vh,u!==vh&&u!==Mh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===vh&&(i=fa),i===void 0&&u===Mh&&(i=ac),super(null,n,r,o,a,l,u,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Ht,this.minFilter=l!==void 0?l:Ht,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const wF=new Dt,SF=new Ip(1,1);SF.compareFunction=aT;const CF=new ox,EF=new ax,MF=new Wv,sB=[],rB=[],oB=new Float32Array(16),aB=new Float32Array(9),lB=new Float32Array(4);function Rp(s,e,t){const i=s[0];if(i<=0||i>0)return s;const n=e*t;let r=sB[n];if(r===void 0&&(r=new Float32Array(n),sB[n]=r),e!==0){i.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,s[o].toArray(r,a)}return r}function Zn(s,e){if(s.length!==e.length)return!1;for(let t=0,i=s.length;t<i;t++)if(s[t]!==e[t])return!1;return!0}function $n(s,e){for(let t=0,i=e.length;t<i;t++)s[t]=e[t]}function lx(s,e){let t=rB[e];t===void 0&&(t=new Int32Array(e),rB[e]=t);for(let i=0;i!==e;++i)t[i]=s.allocateTextureUnit();return t}function w5(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function S5(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Zn(t,e))return;s.uniform2fv(this.addr,e),$n(t,e)}}function C5(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Zn(t,e))return;s.uniform3fv(this.addr,e),$n(t,e)}}function E5(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Zn(t,e))return;s.uniform4fv(this.addr,e),$n(t,e)}}function M5(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(Zn(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),$n(t,e)}else{if(Zn(t,i))return;lB.set(i),s.uniformMatrix2fv(this.addr,!1,lB),$n(t,i)}}function T5(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(Zn(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),$n(t,e)}else{if(Zn(t,i))return;aB.set(i),s.uniformMatrix3fv(this.addr,!1,aB),$n(t,i)}}function I5(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(Zn(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),$n(t,e)}else{if(Zn(t,i))return;oB.set(i),s.uniformMatrix4fv(this.addr,!1,oB),$n(t,i)}}function R5(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function P5(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Zn(t,e))return;s.uniform2iv(this.addr,e),$n(t,e)}}function B5(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Zn(t,e))return;s.uniform3iv(this.addr,e),$n(t,e)}}function D5(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Zn(t,e))return;s.uniform4iv(this.addr,e),$n(t,e)}}function O5(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function L5(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Zn(t,e))return;s.uniform2uiv(this.addr,e),$n(t,e)}}function k5(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Zn(t,e))return;s.uniform3uiv(this.addr,e),$n(t,e)}}function F5(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Zn(t,e))return;s.uniform4uiv(this.addr,e),$n(t,e)}}function U5(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n);const r=this.type===s.SAMPLER_2D_SHADOW?SF:wF;t.setTexture2D(e||r,n)}function N5(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTexture3D(e||EF,n)}function z5(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTextureCube(e||MF,n)}function G5(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTexture2DArray(e||CF,n)}function H5(s){switch(s){case 5126:return w5;case 35664:return S5;case 35665:return C5;case 35666:return E5;case 35674:return M5;case 35675:return T5;case 35676:return I5;case 5124:case 35670:return R5;case 35667:case 35671:return P5;case 35668:case 35672:return B5;case 35669:case 35673:return D5;case 5125:return O5;case 36294:return L5;case 36295:return k5;case 36296:return F5;case 35678:case 36198:case 36298:case 36306:case 35682:return U5;case 35679:case 36299:case 36307:return N5;case 35680:case 36300:case 36308:case 36293:return z5;case 36289:case 36303:case 36311:case 36292:return G5}}function Q5(s,e){s.uniform1fv(this.addr,e)}function V5(s,e){const t=Rp(e,this.size,2);s.uniform2fv(this.addr,t)}function j5(s,e){const t=Rp(e,this.size,3);s.uniform3fv(this.addr,t)}function W5(s,e){const t=Rp(e,this.size,4);s.uniform4fv(this.addr,t)}function q5(s,e){const t=Rp(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function X5(s,e){const t=Rp(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function Y5(s,e){const t=Rp(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function J5(s,e){s.uniform1iv(this.addr,e)}function K5(s,e){s.uniform2iv(this.addr,e)}function Z5(s,e){s.uniform3iv(this.addr,e)}function $5(s,e){s.uniform4iv(this.addr,e)}function e6(s,e){s.uniform1uiv(this.addr,e)}function t6(s,e){s.uniform2uiv(this.addr,e)}function i6(s,e){s.uniform3uiv(this.addr,e)}function n6(s,e){s.uniform4uiv(this.addr,e)}function s6(s,e,t){const i=this.cache,n=e.length,r=lx(t,n);Zn(i,r)||(s.uniform1iv(this.addr,r),$n(i,r));for(let o=0;o!==n;++o)t.setTexture2D(e[o]||wF,r[o])}function r6(s,e,t){const i=this.cache,n=e.length,r=lx(t,n);Zn(i,r)||(s.uniform1iv(this.addr,r),$n(i,r));for(let o=0;o!==n;++o)t.setTexture3D(e[o]||EF,r[o])}function o6(s,e,t){const i=this.cache,n=e.length,r=lx(t,n);Zn(i,r)||(s.uniform1iv(this.addr,r),$n(i,r));for(let o=0;o!==n;++o)t.setTextureCube(e[o]||MF,r[o])}function a6(s,e,t){const i=this.cache,n=e.length,r=lx(t,n);Zn(i,r)||(s.uniform1iv(this.addr,r),$n(i,r));for(let o=0;o!==n;++o)t.setTexture2DArray(e[o]||CF,r[o])}function l6(s){switch(s){case 5126:return Q5;case 35664:return V5;case 35665:return j5;case 35666:return W5;case 35674:return q5;case 35675:return X5;case 35676:return Y5;case 5124:case 35670:return J5;case 35667:case 35671:return K5;case 35668:case 35672:return Z5;case 35669:case 35673:return $5;case 5125:return e6;case 36294:return t6;case 36295:return i6;case 36296:return n6;case 35678:case 36198:case 36298:case 36306:case 35682:return s6;case 35679:case 36299:case 36307:return r6;case 35680:case 36300:case 36308:case 36293:return o6;case 36289:case 36303:case 36311:case 36292:return a6}}class c6{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=H5(t.type)}}class h6{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=l6(t.type)}}class u6{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const n=this.seq;for(let r=0,o=n.length;r!==o;++r){const a=n[r];a.setValue(e,t[a.id],i)}}}const wS=/(\w+)(\])?(\[|\.)?/g;function cB(s,e){s.seq.push(e),s.map[e.id]=e}function d6(s,e,t){const i=s.name,n=i.length;for(wS.lastIndex=0;;){const r=wS.exec(i),o=wS.lastIndex;let a=r[1];const l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===n){cB(t,c===void 0?new c6(a,s,e):new h6(a,s,e));break}else{let d=t.map[a];d===void 0&&(d=new u6(a),cB(t,d)),t=d}}}class c_{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const r=e.getActiveUniform(t,n),o=e.getUniformLocation(t,r.name);d6(r,o,this)}}setValue(e,t,i,n){const r=this.map[t];r!==void 0&&r.setValue(e,i,n)}setOptional(e,t,i){const n=t[i];n!==void 0&&this.setValue(e,i,n)}static upload(e,t,i,n){for(let r=0,o=t.length;r!==o;++r){const a=t[r],l=i[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,n)}}static seqWithValue(e,t){const i=[];for(let n=0,r=e.length;n!==r;++n){const o=e[n];o.id in t&&i.push(o)}return i}}function hB(s,e,t){const i=s.createShader(e);return s.shaderSource(i,t),s.compileShader(i),i}const f6=37297;let p6=0;function m6(s,e){const t=s.split(`
3710
3710
  `),i=[],n=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=n;o<r;o++){const a=o+1;i.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return i.join(`
3711
3711
  `)}function g6(s){const e=vi.getPrimaries(vi.workingColorSpace),t=vi.getPrimaries(s);let i;switch(e===t?i="":e===nv&&t===iv?i="LinearDisplayP3ToLinearSRGB":e===iv&&t===nv&&(i="LinearSRGBToLinearDisplayP3"),s){case yi:case Mp:return[i,"LinearTransferOETF"];case gt:case Vv:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",s),[i,"LinearTransferOETF"]}}function uB(s,e,t){const i=s.getShaderParameter(e,s.COMPILE_STATUS),n=s.getShaderInfoLog(e).trim();if(i&&n==="")return"";const r=/ERROR: 0:(\d+)/.exec(n);if(r){const o=parseInt(r[1]);return t.toUpperCase()+`
3712
3712
 
@@ -3808,7 +3808,7 @@ void main() {
3808
3808
 
3809
3809
  }
3810
3810
 
3811
- }`;class tj{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const n=new Dt,r=e.properties.get(n);r.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}render(e,t){if(this.texture!==null){if(this.mesh===null){const i=t.cameras[0].viewport,n=new Pt({extensions:{fragDepth:!0},vertexShader:$6,fragmentShader:ej,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new pe(new zn(20,20),n)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}}class ij extends ps{constructor(e,t){super();const i=this;let n=null,r=1,o=null,a="local-floor",l=1,c=null,u=null,d=null,f=null,p=null,m=null;const A=new tj,v=t.getContextAttributes();let g=null,_=null;const y=[],b=[],E=new te;let M=null;const T=new Qt;T.layers.enable(1),T.viewport=new Ze;const C=new Qt;C.layers.enable(2),C.viewport=new Ze;const B=[T,C],S=new gT;S.layers.enable(1),S.layers.enable(2);let R=null,Q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ie){let me=y[ie];return me===void 0&&(me=new SS,y[ie]=me),me.getTargetRaySpace()},this.getControllerGrip=function(ie){let me=y[ie];return me===void 0&&(me=new SS,y[ie]=me),me.getGripSpace()},this.getHand=function(ie){let me=y[ie];return me===void 0&&(me=new SS,y[ie]=me),me.getHandSpace()};function z(ie){const me=b.indexOf(ie.inputSource);if(me===-1)return;const be=y[me];be!==void 0&&(be.update(ie.inputSource,ie.frame,c||o),be.dispatchEvent({type:ie.type,data:ie.inputSource}))}function O(){n.removeEventListener("select",z),n.removeEventListener("selectstart",z),n.removeEventListener("selectend",z),n.removeEventListener("squeeze",z),n.removeEventListener("squeezestart",z),n.removeEventListener("squeezeend",z),n.removeEventListener("end",O),n.removeEventListener("inputsourceschange",V);for(let ie=0;ie<y.length;ie++){const me=b[ie];me!==null&&(b[ie]=null,y[ie].disconnect(me))}R=null,Q=null,A.reset(),e.setRenderTarget(g),p=null,f=null,d=null,n=null,_=null,Re.stop(),i.isPresenting=!1,e.setPixelRatio(M),e.setSize(E.width,E.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ie){r=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ie){a=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(ie){c=ie},this.getBaseLayer=function(){return f!==null?f:p},this.getBinding=function(){return d},this.getFrame=function(){return m},this.getSession=function(){return n},this.setSession=async function(ie){if(n=ie,n!==null){if(g=e.getRenderTarget(),n.addEventListener("select",z),n.addEventListener("selectstart",z),n.addEventListener("selectend",z),n.addEventListener("squeeze",z),n.addEventListener("squeezestart",z),n.addEventListener("squeezeend",z),n.addEventListener("end",O),n.addEventListener("inputsourceschange",V),v.xrCompatible!==!0&&await t.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(E),n.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const me={antialias:n.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(n,t,me),n.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),_=new Yt(p.framebufferWidth,p.framebufferHeight,{format:Ai,type:di,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let me=null,be=null,Ve=null;v.depth&&(Ve=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,me=v.stencil?Mh:vh,be=v.stencil?ac:fa);const je={colorFormat:t.RGBA8,depthFormat:Ve,scaleFactor:r};d=new XRWebGLBinding(n,t),f=d.createProjectionLayer(je),n.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),_=new Yt(f.textureWidth,f.textureHeight,{format:Ai,type:di,depthTexture:new Ip(f.textureWidth,f.textureHeight,be,void 0,void 0,void 0,void 0,void 0,void 0,me),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const Ge=e.properties.get(_);Ge.__ignoreDepthValues=f.ignoreDepthValues}_.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await n.requestReferenceSpace(a),Re.setContext(n),Re.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode};function V(ie){for(let me=0;me<ie.removed.length;me++){const be=ie.removed[me],Ve=b.indexOf(be);Ve>=0&&(b[Ve]=null,y[Ve].disconnect(be))}for(let me=0;me<ie.added.length;me++){const be=ie.added[me];let Ve=b.indexOf(be);if(Ve===-1){for(let Ge=0;Ge<y.length;Ge++)if(Ge>=b.length){b.push(be),Ve=Ge;break}else if(b[Ge]===null){b[Ge]=be,Ve=Ge;break}if(Ve===-1)break}const je=y[Ve];je&&je.connect(be)}}const L=new w,k=new w;function G(ie,me,be){L.setFromMatrixPosition(me.matrixWorld),k.setFromMatrixPosition(be.matrixWorld);const Ve=L.distanceTo(k),je=me.projectionMatrix.elements,Ge=be.projectionMatrix.elements,dt=je[14]/(je[10]-1),tt=je[14]/(je[10]+1),W=(je[9]+1)/je[5],Ne=(je[9]-1)/je[5],ye=(je[8]-1)/je[0],ke=(Ge[8]+1)/Ge[0],Se=dt*ye,$e=dt*ke,Je=Ve/(-ye+ke),st=Je*-ye;me.matrixWorld.decompose(ie.position,ie.quaternion,ie.scale),ie.translateX(st),ie.translateZ(Je),ie.matrixWorld.compose(ie.position,ie.quaternion,ie.scale),ie.matrixWorldInverse.copy(ie.matrixWorld).invert();const Bt=dt+Je,N=tt+Je,D=Se-st,fe=$e+(Ve-st),ve=W*tt/N*Bt,Ie=Ne*tt/N*Bt;ie.projectionMatrix.makePerspective(D,fe,ve,Ie,Bt,N),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert()}function Y(ie,me){me===null?ie.matrixWorld.copy(ie.matrix):ie.matrixWorld.multiplyMatrices(me.matrixWorld,ie.matrix),ie.matrixWorldInverse.copy(ie.matrixWorld).invert()}this.updateCamera=function(ie){if(n===null)return;A.texture!==null&&(A.depthNear>0&&(ie.near=A.depthNear),A.depthFar>0&&(ie.far=A.depthFar)),S.near=C.near=T.near=ie.near,S.far=C.far=T.far=ie.far,(R!==S.near||Q!==S.far)&&(n.updateRenderState({depthNear:S.near,depthFar:S.far}),R=S.near,Q=S.far,T.near=R,T.far=Q,C.near=R,C.far=Q,T.updateProjectionMatrix(),C.updateProjectionMatrix(),ie.updateProjectionMatrix());const me=ie.parent,be=S.cameras;Y(S,me);for(let Ve=0;Ve<be.length;Ve++)Y(be[Ve],me);be.length===2?G(S,T,C):S.projectionMatrix.copy(T.projectionMatrix),$(ie,S,me)};function $(ie,me,be){be===null?ie.matrix.copy(me.matrixWorld):(ie.matrix.copy(be.matrixWorld),ie.matrix.invert(),ie.matrix.multiply(me.matrixWorld)),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.updateMatrixWorld(!0),ie.projectionMatrix.copy(me.projectionMatrix),ie.projectionMatrixInverse.copy(me.projectionMatrixInverse),ie.isPerspectiveCamera&&(ie.fov=fp*2*Math.atan(1/ie.projectionMatrix.elements[5]),ie.zoom=1)}this.getCamera=function(){return S},this.getFoveation=function(){if(!(f===null&&p===null))return l},this.setFoveation=function(ie){l=ie,f!==null&&(f.fixedFoveation=ie),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ie)},this.hasDepthSensing=function(){return A.texture!==null};let re=null;function ce(ie,me){if(u=me.getViewerPose(c||o),m=me,u!==null){const be=u.views;p!==null&&(e.setRenderTargetFramebuffer(_,p.framebuffer),e.setRenderTarget(_));let Ve=!1;be.length!==S.cameras.length&&(S.cameras.length=0,Ve=!0);for(let Ge=0;Ge<be.length;Ge++){const dt=be[Ge];let tt=null;if(p!==null)tt=p.getViewport(dt);else{const Ne=d.getViewSubImage(f,dt);tt=Ne.viewport,Ge===0&&(e.setRenderTargetTextures(_,Ne.colorTexture,f.ignoreDepthValues?void 0:Ne.depthStencilTexture),e.setRenderTarget(_))}let W=B[Ge];W===void 0&&(W=new Qt,W.layers.enable(Ge),W.viewport=new Ze,B[Ge]=W),W.matrix.fromArray(dt.transform.matrix),W.matrix.decompose(W.position,W.quaternion,W.scale),W.projectionMatrix.fromArray(dt.projectionMatrix),W.projectionMatrixInverse.copy(W.projectionMatrix).invert(),W.viewport.set(tt.x,tt.y,tt.width,tt.height),Ge===0&&(S.matrix.copy(W.matrix),S.matrix.decompose(S.position,S.quaternion,S.scale)),Ve===!0&&S.cameras.push(W)}const je=n.enabledFeatures;if(je&&je.includes("depth-sensing")){const Ge=d.getDepthInformation(be[0]);Ge&&Ge.isValid&&Ge.texture&&A.init(e,Ge,n.renderState)}}for(let be=0;be<y.length;be++){const Ve=b[be],je=y[be];Ve!==null&&je!==void 0&&je.update(Ve,me,c||o)}A.render(e,S),re&&re(ie,me),me.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:me}),m=null}const Re=new xF;Re.setAnimationLoop(ce),this.setAnimationLoop=function(ie){re=ie},this.dispose=function(){}}}const su=new Gi,nj=new we;function sj(s,e){function t(v,g){v.matrixAutoUpdate===!0&&v.updateMatrix(),g.value.copy(v.matrix)}function i(v,g){g.color.getRGB(v.fogColor.value,bF(s)),g.isFog?(v.fogNear.value=g.near,v.fogFar.value=g.far):g.isFogExp2&&(v.fogDensity.value=g.density)}function n(v,g,_,y,b){g.isMeshBasicMaterial||g.isMeshLambertMaterial?r(v,g):g.isMeshToonMaterial?(r(v,g),d(v,g)):g.isMeshPhongMaterial?(r(v,g),u(v,g)):g.isMeshStandardMaterial?(r(v,g),f(v,g),g.isMeshPhysicalMaterial&&p(v,g,b)):g.isMeshMatcapMaterial?(r(v,g),m(v,g)):g.isMeshDepthMaterial?r(v,g):g.isMeshDistanceMaterial?(r(v,g),A(v,g)):g.isMeshNormalMaterial?r(v,g):g.isLineBasicMaterial?(o(v,g),g.isLineDashedMaterial&&a(v,g)):g.isPointsMaterial?l(v,g,_,y):g.isSpriteMaterial?c(v,g):g.isShadowMaterial?(v.color.value.copy(g.color),v.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(v,g){v.opacity.value=g.opacity,g.color&&v.diffuse.value.copy(g.color),g.emissive&&v.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(v.map.value=g.map,t(g.map,v.mapTransform)),g.alphaMap&&(v.alphaMap.value=g.alphaMap,t(g.alphaMap,v.alphaMapTransform)),g.bumpMap&&(v.bumpMap.value=g.bumpMap,t(g.bumpMap,v.bumpMapTransform),v.bumpScale.value=g.bumpScale,g.side===_n&&(v.bumpScale.value*=-1)),g.normalMap&&(v.normalMap.value=g.normalMap,t(g.normalMap,v.normalMapTransform),v.normalScale.value.copy(g.normalScale),g.side===_n&&v.normalScale.value.negate()),g.displacementMap&&(v.displacementMap.value=g.displacementMap,t(g.displacementMap,v.displacementMapTransform),v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias),g.emissiveMap&&(v.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,v.emissiveMapTransform)),g.specularMap&&(v.specularMap.value=g.specularMap,t(g.specularMap,v.specularMapTransform)),g.alphaTest>0&&(v.alphaTest.value=g.alphaTest);const _=e.get(g),y=_.envMap,b=_.envMapRotation;if(y&&(v.envMap.value=y,su.copy(b),su.x*=-1,su.y*=-1,su.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(su.y*=-1,su.z*=-1),v.envMapRotation.value.setFromMatrix4(nj.makeRotationFromEuler(su)),v.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=g.reflectivity,v.ior.value=g.ior,v.refractionRatio.value=g.refractionRatio),g.lightMap){v.lightMap.value=g.lightMap;const E=s._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=g.lightMapIntensity*E,t(g.lightMap,v.lightMapTransform)}g.aoMap&&(v.aoMap.value=g.aoMap,v.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,v.aoMapTransform))}function o(v,g){v.diffuse.value.copy(g.color),v.opacity.value=g.opacity,g.map&&(v.map.value=g.map,t(g.map,v.mapTransform))}function a(v,g){v.dashSize.value=g.dashSize,v.totalSize.value=g.dashSize+g.gapSize,v.scale.value=g.scale}function l(v,g,_,y){v.diffuse.value.copy(g.color),v.opacity.value=g.opacity,v.size.value=g.size*_,v.scale.value=y*.5,g.map&&(v.map.value=g.map,t(g.map,v.uvTransform)),g.alphaMap&&(v.alphaMap.value=g.alphaMap,t(g.alphaMap,v.alphaMapTransform)),g.alphaTest>0&&(v.alphaTest.value=g.alphaTest)}function c(v,g){v.diffuse.value.copy(g.color),v.opacity.value=g.opacity,v.rotation.value=g.rotation,g.map&&(v.map.value=g.map,t(g.map,v.mapTransform)),g.alphaMap&&(v.alphaMap.value=g.alphaMap,t(g.alphaMap,v.alphaMapTransform)),g.alphaTest>0&&(v.alphaTest.value=g.alphaTest)}function u(v,g){v.specular.value.copy(g.specular),v.shininess.value=Math.max(g.shininess,1e-4)}function d(v,g){g.gradientMap&&(v.gradientMap.value=g.gradientMap)}function f(v,g){v.metalness.value=g.metalness,g.metalnessMap&&(v.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,v.metalnessMapTransform)),v.roughness.value=g.roughness,g.roughnessMap&&(v.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,v.roughnessMapTransform)),e.get(g).envMap&&(v.envMapIntensity.value=g.envMapIntensity)}function p(v,g,_){v.ior.value=g.ior,g.sheen>0&&(v.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),v.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(v.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,v.sheenColorMapTransform)),g.sheenRoughnessMap&&(v.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,v.sheenRoughnessMapTransform))),g.clearcoat>0&&(v.clearcoat.value=g.clearcoat,v.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(v.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,v.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(v.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===_n&&v.clearcoatNormalScale.value.negate())),g.iridescence>0&&(v.iridescence.value=g.iridescence,v.iridescenceIOR.value=g.iridescenceIOR,v.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(v.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,v.iridescenceMapTransform)),g.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),g.transmission>0&&(v.transmission.value=g.transmission,v.transmissionSamplerMap.value=_.texture,v.transmissionSamplerSize.value.set(_.width,_.height),g.transmissionMap&&(v.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,v.transmissionMapTransform)),v.thickness.value=g.thickness,g.thicknessMap&&(v.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=g.attenuationDistance,v.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(v.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(v.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=g.specularIntensity,v.specularColor.value.copy(g.specularColor),g.specularColorMap&&(v.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,v.specularColorMapTransform)),g.specularIntensityMap&&(v.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,v.specularIntensityMapTransform))}function m(v,g){g.matcap&&(v.matcap.value=g.matcap)}function A(v,g){const _=e.get(g).light;v.referencePosition.value.setFromMatrixPosition(_.matrixWorld),v.nearDistance.value=_.shadow.camera.near,v.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function rj(s,e,t,i){let n={},r={},o=[];const a=t.isWebGL2?s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(_,y){const b=y.program;i.uniformBlockBinding(_,b)}function c(_,y){let b=n[_.id];b===void 0&&(m(_),b=u(_),n[_.id]=b,_.addEventListener("dispose",v));const E=y.program;i.updateUBOMapping(_,E);const M=e.render.frame;r[_.id]!==M&&(f(_),r[_.id]=M)}function u(_){const y=d();_.__bindingPointIndex=y;const b=s.createBuffer(),E=_.__size,M=_.usage;return s.bindBuffer(s.UNIFORM_BUFFER,b),s.bufferData(s.UNIFORM_BUFFER,E,M),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,y,b),b}function d(){for(let _=0;_<a;_++)if(o.indexOf(_)===-1)return o.push(_),_;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(_){const y=n[_.id],b=_.uniforms,E=_.__cache;s.bindBuffer(s.UNIFORM_BUFFER,y);for(let M=0,T=b.length;M<T;M++){const C=Array.isArray(b[M])?b[M]:[b[M]];for(let B=0,S=C.length;B<S;B++){const R=C[B];if(p(R,M,B,E)===!0){const Q=R.__offset,z=Array.isArray(R.value)?R.value:[R.value];let O=0;for(let V=0;V<z.length;V++){const L=z[V],k=A(L);typeof L=="number"||typeof L=="boolean"?(R.__data[0]=L,s.bufferSubData(s.UNIFORM_BUFFER,Q+O,R.__data)):L.isMatrix3?(R.__data[0]=L.elements[0],R.__data[1]=L.elements[1],R.__data[2]=L.elements[2],R.__data[3]=0,R.__data[4]=L.elements[3],R.__data[5]=L.elements[4],R.__data[6]=L.elements[5],R.__data[7]=0,R.__data[8]=L.elements[6],R.__data[9]=L.elements[7],R.__data[10]=L.elements[8],R.__data[11]=0):(L.toArray(R.__data,O),O+=k.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,Q,R.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function p(_,y,b,E){const M=_.value,T=y+"_"+b;if(E[T]===void 0)return typeof M=="number"||typeof M=="boolean"?E[T]=M:E[T]=M.clone(),!0;{const C=E[T];if(typeof M=="number"||typeof M=="boolean"){if(C!==M)return E[T]=M,!0}else if(C.equals(M)===!1)return C.copy(M),!0}return!1}function m(_){const y=_.uniforms;let b=0;const E=16;for(let T=0,C=y.length;T<C;T++){const B=Array.isArray(y[T])?y[T]:[y[T]];for(let S=0,R=B.length;S<R;S++){const Q=B[S],z=Array.isArray(Q.value)?Q.value:[Q.value];for(let O=0,V=z.length;O<V;O++){const L=z[O],k=A(L),G=b%E;G!==0&&E-G<k.boundary&&(b+=E-G),Q.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),Q.__offset=b,b+=k.storage}}}const M=b%E;return M>0&&(b+=E-M),_.__size=b,_.__cache={},this}function A(_){const y={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(y.boundary=4,y.storage=4):_.isVector2?(y.boundary=8,y.storage=8):_.isVector3||_.isColor?(y.boundary=16,y.storage=12):_.isVector4?(y.boundary=16,y.storage=16):_.isMatrix3?(y.boundary=48,y.storage=48):_.isMatrix4?(y.boundary=64,y.storage=64):_.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",_),y}function v(_){const y=_.target;y.removeEventListener("dispose",v);const b=o.indexOf(y.__bindingPointIndex);o.splice(b,1),s.deleteBuffer(n[y.id]),delete n[y.id],delete r[y.id]}function g(){for(const _ in n)s.deleteBuffer(n[_]);o=[],n={},r={}}return{bind:l,update:c,dispose:g}}class _c{constructor(e={}){const{canvas:t=vF(),context:i=null,depth:n=!0,stencil:r=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let f;i!==null?f=i.getContextAttributes().alpha:f=o;const p=new Uint32Array(4),m=new Int32Array(4);let A=null,v=null;const g=[],_=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=gt,this._useLegacyLights=!1,this.toneMapping=ho,this.toneMappingExposure=1;const y=this;let b=!1,E=0,M=0,T=null,C=-1,B=null;const S=new Ze,R=new Ze;let Q=null;const z=new xe(0);let O=0,V=t.width,L=t.height,k=1,G=null,Y=null;const $=new Ze(0,0,V,L),re=new Ze(0,0,V,L);let ce=!1;const Re=new qv;let ie=!1,me=!1,be=null;const Ve=new we,je=new te,Ge=new w,dt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function tt(){return T===null?k:1}let W=i;function Ne(I,U){for(let H=0;H<I.length;H++){const q=I[H],X=t.getContext(q,U);if(X!==null)return X}return null}try{const I={alpha:!0,depth:n,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${fc}`),t.addEventListener("webglcontextlost",ae,!1),t.addEventListener("webglcontextrestored",Z,!1),t.addEventListener("webglcontextcreationerror",Be,!1),W===null){const U=["webgl2","webgl","experimental-webgl"];if(y.isWebGL1Renderer===!0&&U.shift(),W=Ne(U,I),W===null)throw Ne(U)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&W instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),W.getShaderPrecisionFormat===void 0&&(W.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(I){throw console.error("THREE.WebGLRenderer: "+I.message),I}let ye,ke,Se,$e,Je,st,Bt,N,D,fe,ve,Ie,Ee,vt,at,Oe,He,yt,Le,Kt,lt,qe,ct,nt;function Tt(){ye=new mV(W),ke=new hV(W,ye,e),ye.init(ke),qe=new TF(W,ye,ke),Se=new J6(W,ye,ke),$e=new AV(W),Je=new U6,st=new K6(W,ye,Se,Je,ke,qe,$e),Bt=new dV(y),N=new pV(y),D=new CQ(W,ke),ct=new lV(W,ye,D,ke),fe=new gV(W,D,$e,ct),ve=new xV(W,fe,D,$e),Le=new bV(W,ke,st),Oe=new uV(Je),Ie=new F6(y,Bt,N,ye,ke,ct,Oe),Ee=new sj(y,Je),vt=new z6,at=new W6(ye,ke),yt=new aV(y,Bt,N,Se,ve,f,l),He=new Y6(y,ve,ke),nt=new rj(W,$e,ke,Se),Kt=new cV(W,ye,$e,ke),lt=new vV(W,ye,$e,ke),$e.programs=Ie.programs,y.capabilities=ke,y.extensions=ye,y.properties=Je,y.renderLists=vt,y.shadowMap=He,y.state=Se,y.info=$e}Tt();const j=new ij(y,W);this.xr=j,this.getContext=function(){return W},this.getContextAttributes=function(){return W.getContextAttributes()},this.forceContextLoss=function(){const I=ye.get("WEBGL_lose_context");I&&I.loseContext()},this.forceContextRestore=function(){const I=ye.get("WEBGL_lose_context");I&&I.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(I){I!==void 0&&(k=I,this.setSize(V,L,!1))},this.getSize=function(I){return I.set(V,L)},this.setSize=function(I,U,H=!0){if(j.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}V=I,L=U,t.width=Math.floor(I*k),t.height=Math.floor(U*k),H===!0&&(t.style.width=I+"px",t.style.height=U+"px"),this.setViewport(0,0,I,U)},this.getDrawingBufferSize=function(I){return I.set(V*k,L*k).floor()},this.setDrawingBufferSize=function(I,U,H){V=I,L=U,k=H,t.width=Math.floor(I*H),t.height=Math.floor(U*H),this.setViewport(0,0,I,U)},this.getCurrentViewport=function(I){return I.copy(S)},this.getViewport=function(I){return I.copy($)},this.setViewport=function(I,U,H,q){I.isVector4?$.set(I.x,I.y,I.z,I.w):$.set(I,U,H,q),Se.viewport(S.copy($).multiplyScalar(k).round())},this.getScissor=function(I){return I.copy(re)},this.setScissor=function(I,U,H,q){I.isVector4?re.set(I.x,I.y,I.z,I.w):re.set(I,U,H,q),Se.scissor(R.copy(re).multiplyScalar(k).round())},this.getScissorTest=function(){return ce},this.setScissorTest=function(I){Se.setScissorTest(ce=I)},this.setOpaqueSort=function(I){G=I},this.setTransparentSort=function(I){Y=I},this.getClearColor=function(I){return I.copy(yt.getClearColor())},this.setClearColor=function(){yt.setClearColor.apply(yt,arguments)},this.getClearAlpha=function(){return yt.getClearAlpha()},this.setClearAlpha=function(){yt.setClearAlpha.apply(yt,arguments)},this.clear=function(I=!0,U=!0,H=!0){let q=0;if(I){let X=!1;if(T!==null){const de=T.texture.format;X=de===nT||de===iT||de===tT}if(X){const de=T.texture.type,he=de===di||de===fa||de===tx||de===ac||de===$M||de===eT,Ae=yt.getClearColor(),Pe=yt.getClearAlpha(),De=Ae.r,Qe=Ae.g,Ye=Ae.b;he?(p[0]=De,p[1]=Qe,p[2]=Ye,p[3]=Pe,W.clearBufferuiv(W.COLOR,0,p)):(m[0]=De,m[1]=Qe,m[2]=Ye,m[3]=Pe,W.clearBufferiv(W.COLOR,0,m))}else q|=W.COLOR_BUFFER_BIT}U&&(q|=W.DEPTH_BUFFER_BIT),H&&(q|=W.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),W.clear(q)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",ae,!1),t.removeEventListener("webglcontextrestored",Z,!1),t.removeEventListener("webglcontextcreationerror",Be,!1),vt.dispose(),at.dispose(),Je.dispose(),Bt.dispose(),N.dispose(),ve.dispose(),ct.dispose(),nt.dispose(),Ie.dispose(),j.dispose(),j.removeEventListener("sessionstart",ji),j.removeEventListener("sessionend",$t),be&&(be.dispose(),be=null),nn.stop()};function ae(I){I.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function Z(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;const I=$e.autoReset,U=He.enabled,H=He.autoUpdate,q=He.needsUpdate,X=He.type;Tt(),$e.autoReset=I,He.enabled=U,He.autoUpdate=H,He.needsUpdate=q,He.type=X}function Be(I){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",I.statusMessage)}function le(I){const U=I.target;U.removeEventListener("dispose",le),ze(U)}function ze(I){Xe(I),Je.remove(I)}function Xe(I){const U=Je.get(I).programs;U!==void 0&&(U.forEach(function(H){Ie.releaseProgram(H)}),I.isShaderMaterial&&Ie.releaseShaderCache(I))}this.renderBufferDirect=function(I,U,H,q,X,de){U===null&&(U=dt);const he=X.isMesh&&X.matrixWorld.determinant()<0,Ae=P(I,U,H,q,X);Se.setMaterial(q,he);let Pe=H.index,De=1;if(q.wireframe===!0){if(Pe=fe.getWireframeAttribute(H),Pe===void 0)return;De=2}const Qe=H.drawRange,Ye=H.attributes.position;let Ke=Qe.start*De,rt=(Qe.start+Qe.count)*De;de!==null&&(Ke=Math.max(Ke,de.start*De),rt=Math.min(rt,(de.start+de.count)*De)),Pe!==null?(Ke=Math.max(Ke,0),rt=Math.min(rt,Pe.count)):Ye!=null&&(Ke=Math.max(Ke,0),rt=Math.min(rt,Ye.count));const xt=rt-Ke;if(xt<0||xt===1/0)return;ct.setup(X,q,Ae,H,Pe);let fi,Gt=Kt;if(Pe!==null&&(fi=D.get(Pe),Gt=lt,Gt.setIndex(fi)),X.isMesh)q.wireframe===!0?(Se.setLineWidth(q.wireframeLinewidth*tt()),Gt.setMode(W.LINES)):Gt.setMode(W.TRIANGLES);else if(X.isLine){let Et=q.linewidth;Et===void 0&&(Et=1),Se.setLineWidth(Et*tt()),X.isLineSegments?Gt.setMode(W.LINES):X.isLineLoop?Gt.setMode(W.LINE_LOOP):Gt.setMode(W.LINE_STRIP)}else X.isPoints?Gt.setMode(W.POINTS):X.isSprite&&Gt.setMode(W.TRIANGLES);if(X.isBatchedMesh)Gt.renderMultiDraw(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount);else if(X.isInstancedMesh)Gt.renderInstances(Ke,xt,X.count);else if(H.isInstancedBufferGeometry){const Et=H._maxInstanceCount!==void 0?H._maxInstanceCount:1/0,Ei=Math.min(H.instanceCount,Et);Gt.renderInstances(Ke,xt,Ei)}else Gt.render(Ke,xt)};function Zt(I,U,H){I.transparent===!0&&I.side===mi&&I.forceSinglePass===!1?(I.side=_n,I.needsUpdate=!0,Jt(I,U,H),I.side=Bs,I.needsUpdate=!0,Jt(I,U,H),I.side=mi):Jt(I,U,H)}this.compile=function(I,U,H=null){H===null&&(H=I),v=at.get(H),v.init(),_.push(v),H.traverseVisible(function(X){X.isLight&&X.layers.test(U.layers)&&(v.pushLight(X),X.castShadow&&v.pushShadow(X))}),I!==H&&I.traverseVisible(function(X){X.isLight&&X.layers.test(U.layers)&&(v.pushLight(X),X.castShadow&&v.pushShadow(X))}),v.setupLights(y._useLegacyLights);const q=new Set;return I.traverse(function(X){const de=X.material;if(de)if(Array.isArray(de))for(let he=0;he<de.length;he++){const Ae=de[he];Zt(Ae,H,X),q.add(Ae)}else Zt(de,H,X),q.add(de)}),_.pop(),v=null,q},this.compileAsync=function(I,U,H=null){const q=this.compile(I,U,H);return new Promise(X=>{function de(){if(q.forEach(function(he){Je.get(he).currentProgram.isReady()&&q.delete(he)}),q.size===0){X(I);return}setTimeout(de,10)}ye.get("KHR_parallel_shader_compile")!==null?de():setTimeout(de,10)})};let _i=null;function Vi(I){_i&&_i(I)}function ji(){nn.stop()}function $t(){nn.start()}const nn=new xF;nn.setAnimationLoop(Vi),typeof self<"u"&&nn.setContext(self),this.setAnimationLoop=function(I){_i=I,j.setAnimationLoop(I),I===null?nn.stop():nn.start()},j.addEventListener("sessionstart",ji),j.addEventListener("sessionend",$t),this.render=function(I,U){if(U!==void 0&&U.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),j.enabled===!0&&j.isPresenting===!0&&(j.cameraAutoUpdate===!0&&j.updateCamera(U),U=j.getCamera()),I.isScene===!0&&I.onBeforeRender(y,I,U,T),v=at.get(I,_.length),v.init(),_.push(v),Ve.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Re.setFromProjectionMatrix(Ve),me=this.localClippingEnabled,ie=Oe.init(this.clippingPlanes,me),A=vt.get(I,g.length),A.init(),g.push(A),mn(I,U,0,y.sortObjects),A.finish(),y.sortObjects===!0&&A.sort(G,Y),this.info.render.frame++,ie===!0&&Oe.beginShadows();const H=v.state.shadowsArray;if(He.render(H,I,U),ie===!0&&Oe.endShadows(),this.info.autoReset===!0&&this.info.reset(),(j.enabled===!1||j.isPresenting===!1||j.hasDepthSensing()===!1)&&yt.render(A,I),v.setupLights(y._useLegacyLights),U.isArrayCamera){const q=U.cameras;for(let X=0,de=q.length;X<de;X++){const he=q[X];Wr(A,I,he,he.viewport)}}else Wr(A,I,U);T!==null&&(st.updateMultisampleRenderTarget(T),st.updateRenderTargetMipmap(T)),I.isScene===!0&&I.onAfterRender(y,I,U),ct.resetDefaultState(),C=-1,B=null,_.pop(),_.length>0?v=_[_.length-1]:v=null,g.pop(),g.length>0?A=g[g.length-1]:A=null};function mn(I,U,H,q){if(I.visible===!1)return;if(I.layers.test(U.layers)){if(I.isGroup)H=I.renderOrder;else if(I.isLOD)I.autoUpdate===!0&&I.update(U);else if(I.isLight)v.pushLight(I),I.castShadow&&v.pushShadow(I);else if(I.isSprite){if(!I.frustumCulled||Re.intersectsSprite(I)){q&&Ge.setFromMatrixPosition(I.matrixWorld).applyMatrix4(Ve);const he=ve.update(I),Ae=I.material;Ae.visible&&A.push(I,he,Ae,H,Ge.z,null)}}else if((I.isMesh||I.isLine||I.isPoints)&&(!I.frustumCulled||Re.intersectsObject(I))){const he=ve.update(I),Ae=I.material;if(q&&(I.boundingSphere!==void 0?(I.boundingSphere===null&&I.computeBoundingSphere(),Ge.copy(I.boundingSphere.center)):(he.boundingSphere===null&&he.computeBoundingSphere(),Ge.copy(he.boundingSphere.center)),Ge.applyMatrix4(I.matrixWorld).applyMatrix4(Ve)),Array.isArray(Ae)){const Pe=he.groups;for(let De=0,Qe=Pe.length;De<Qe;De++){const Ye=Pe[De],Ke=Ae[Ye.materialIndex];Ke&&Ke.visible&&A.push(I,he,Ke,H,Ge.z,Ye)}}else Ae.visible&&A.push(I,he,Ae,H,Ge.z,null)}}const de=I.children;for(let he=0,Ae=de.length;he<Ae;he++)mn(de[he],U,H,q)}function Wr(I,U,H,q){const X=I.opaque,de=I.transmissive,he=I.transparent;v.setupLightsView(H),ie===!0&&Oe.setGlobalState(y.clippingPlanes,H),de.length>0&&Bc(X,de,U,H),q&&Se.viewport(S.copy(q)),X.length>0&&qr(X,U,H),de.length>0&&qr(de,U,H),he.length>0&&qr(he,U,H),Se.buffers.depth.setTest(!0),Se.buffers.depth.setMask(!0),Se.buffers.color.setMask(!0),Se.setPolygonOffset(!1)}function Bc(I,U,H,q){if((H.isScene===!0?H.overrideMaterial:null)!==null)return;const de=ke.isWebGL2;be===null&&(be=new Yt(1,1,{generateMipmaps:!0,type:ye.has("EXT_color_buffer_half_float")?cn:di,minFilter:br,samples:de?4:0})),y.getDrawingBufferSize(je),de?be.setSize(je.x,je.y):be.setSize(eb(je.x),eb(je.y));const he=y.getRenderTarget();y.setRenderTarget(be),y.getClearColor(z),O=y.getClearAlpha(),O<1&&y.setClearColor(16777215,.5),y.clear();const Ae=y.toneMapping;y.toneMapping=ho,qr(I,H,q),st.updateMultisampleRenderTarget(be),st.updateRenderTargetMipmap(be);let Pe=!1;for(let De=0,Qe=U.length;De<Qe;De++){const Ye=U[De],Ke=Ye.object,rt=Ye.geometry,xt=Ye.material,fi=Ye.group;if(xt.side===mi&&Ke.layers.test(q.layers)){const Gt=xt.side;xt.side=_n,xt.needsUpdate=!0,Dc(Ke,H,q,rt,xt,fi),xt.side=Gt,xt.needsUpdate=!0,Pe=!0}}Pe===!0&&(st.updateMultisampleRenderTarget(be),st.updateRenderTargetMipmap(be)),y.setRenderTarget(he),y.setClearColor(z,O),y.toneMapping=Ae}function qr(I,U,H){const q=U.isScene===!0?U.overrideMaterial:null;for(let X=0,de=I.length;X<de;X++){const he=I[X],Ae=he.object,Pe=he.geometry,De=q===null?he.material:q,Qe=he.group;Ae.layers.test(H.layers)&&Dc(Ae,U,H,Pe,De,Qe)}}function Dc(I,U,H,q,X,de){I.onBeforeRender(y,U,H,q,X,de),I.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,I.matrixWorld),I.normalMatrix.getNormalMatrix(I.modelViewMatrix),X.onBeforeRender(y,U,H,q,I,de),X.transparent===!0&&X.side===mi&&X.forceSinglePass===!1?(X.side=_n,X.needsUpdate=!0,y.renderBufferDirect(H,U,q,X,I,de),X.side=Bs,X.needsUpdate=!0,y.renderBufferDirect(H,U,q,X,I,de),X.side=mi):y.renderBufferDirect(H,U,q,X,I,de),I.onAfterRender(y,U,H,q,X,de)}function Jt(I,U,H){U.isScene!==!0&&(U=dt);const q=Je.get(I),X=v.state.lights,de=v.state.shadowsArray,he=X.state.version,Ae=Ie.getParameters(I,X.state,de,U,H),Pe=Ie.getProgramCacheKey(Ae);let De=q.programs;q.environment=I.isMeshStandardMaterial?U.environment:null,q.fog=U.fog,q.envMap=(I.isMeshStandardMaterial?N:Bt).get(I.envMap||q.environment),q.envMapRotation=q.environment!==null&&I.envMap===null?U.environmentRotation:I.envMapRotation,De===void 0&&(I.addEventListener("dispose",le),De=new Map,q.programs=De);let Qe=De.get(Pe);if(Qe!==void 0){if(q.currentProgram===Qe&&q.lightsStateVersion===he)return fy(I,Ae),Qe}else Ae.uniforms=Ie.getUniforms(I),I.onBuild(H,Ae,y),I.onBeforeCompile(Ae,y),Qe=Ie.acquireProgram(Ae,Pe),De.set(Pe,Qe),q.uniforms=Ae.uniforms;const Ye=q.uniforms;return(!I.isShaderMaterial&&!I.isRawShaderMaterial||I.clipping===!0)&&(Ye.clippingPlanes=Oe.uniform),fy(I,Ae),q.needsLights=J(I),q.lightsStateVersion=he,q.needsLights&&(Ye.ambientLightColor.value=X.state.ambient,Ye.lightProbe.value=X.state.probe,Ye.directionalLights.value=X.state.directional,Ye.directionalLightShadows.value=X.state.directionalShadow,Ye.spotLights.value=X.state.spot,Ye.spotLightShadows.value=X.state.spotShadow,Ye.rectAreaLights.value=X.state.rectArea,Ye.ltc_1.value=X.state.rectAreaLTC1,Ye.ltc_2.value=X.state.rectAreaLTC2,Ye.pointLights.value=X.state.point,Ye.pointLightShadows.value=X.state.pointShadow,Ye.hemisphereLights.value=X.state.hemi,Ye.directionalShadowMap.value=X.state.directionalShadowMap,Ye.directionalShadowMatrix.value=X.state.directionalShadowMatrix,Ye.spotShadowMap.value=X.state.spotShadowMap,Ye.spotLightMatrix.value=X.state.spotLightMatrix,Ye.spotLightMap.value=X.state.spotLightMap,Ye.pointShadowMap.value=X.state.pointShadowMap,Ye.pointShadowMatrix.value=X.state.pointShadowMatrix),q.currentProgram=Qe,q.uniformsList=null,Qe}function dm(I){if(I.uniformsList===null){const U=I.currentProgram.getUniforms();I.uniformsList=c_.seqWithValue(U.seq,I.uniforms)}return I.uniformsList}function fy(I,U){const H=Je.get(I);H.outputColorSpace=U.outputColorSpace,H.batching=U.batching,H.instancing=U.instancing,H.instancingColor=U.instancingColor,H.instancingMorph=U.instancingMorph,H.skinning=U.skinning,H.morphTargets=U.morphTargets,H.morphNormals=U.morphNormals,H.morphColors=U.morphColors,H.morphTargetsCount=U.morphTargetsCount,H.numClippingPlanes=U.numClippingPlanes,H.numIntersection=U.numClipIntersection,H.vertexAlphas=U.vertexAlphas,H.vertexTangents=U.vertexTangents,H.toneMapping=U.toneMapping}function P(I,U,H,q,X){U.isScene!==!0&&(U=dt),st.resetTextureUnits();const de=U.fog,he=q.isMeshStandardMaterial?U.environment:null,Ae=T===null?y.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:yi,Pe=(q.isMeshStandardMaterial?N:Bt).get(q.envMap||he),De=q.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,Qe=!!H.attributes.tangent&&(!!q.normalMap||q.anisotropy>0),Ye=!!H.morphAttributes.position,Ke=!!H.morphAttributes.normal,rt=!!H.morphAttributes.color;let xt=ho;q.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(xt=y.toneMapping);const fi=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Gt=fi!==void 0?fi.length:0,Et=Je.get(q),Ei=v.state.lights;if(ie===!0&&(me===!0||I!==B)){const sn=I===B&&q.id===C;Oe.setState(q,I,sn)}let _t=!1;q.version===Et.__version?(Et.needsLights&&Et.lightsStateVersion!==Ei.state.version||Et.outputColorSpace!==Ae||X.isBatchedMesh&&Et.batching===!1||!X.isBatchedMesh&&Et.batching===!0||X.isInstancedMesh&&Et.instancing===!1||!X.isInstancedMesh&&Et.instancing===!0||X.isSkinnedMesh&&Et.skinning===!1||!X.isSkinnedMesh&&Et.skinning===!0||X.isInstancedMesh&&Et.instancingColor===!0&&X.instanceColor===null||X.isInstancedMesh&&Et.instancingColor===!1&&X.instanceColor!==null||X.isInstancedMesh&&Et.instancingMorph===!0&&X.morphTexture===null||X.isInstancedMesh&&Et.instancingMorph===!1&&X.morphTexture!==null||Et.envMap!==Pe||q.fog===!0&&Et.fog!==de||Et.numClippingPlanes!==void 0&&(Et.numClippingPlanes!==Oe.numPlanes||Et.numIntersection!==Oe.numIntersection)||Et.vertexAlphas!==De||Et.vertexTangents!==Qe||Et.morphTargets!==Ye||Et.morphNormals!==Ke||Et.morphColors!==rt||Et.toneMapping!==xt||ke.isWebGL2===!0&&Et.morphTargetsCount!==Gt)&&(_t=!0):(_t=!0,Et.__version=q.version);let Ri=Et.currentProgram;_t===!0&&(Ri=Jt(q,U,X));let ar=!1,Wi=!1,ui=!1;const jt=Ri.getUniforms(),gs=Et.uniforms;if(Se.useProgram(Ri.program)&&(ar=!0,Wi=!0,ui=!0),q.id!==C&&(C=q.id,Wi=!0),ar||B!==I){jt.setValue(W,"projectionMatrix",I.projectionMatrix),jt.setValue(W,"viewMatrix",I.matrixWorldInverse);const sn=jt.map.cameraPosition;sn!==void 0&&sn.setValue(W,Ge.setFromMatrixPosition(I.matrixWorld)),ke.logarithmicDepthBuffer&&jt.setValue(W,"logDepthBufFC",2/(Math.log(I.far+1)/Math.LN2)),(q.isMeshPhongMaterial||q.isMeshToonMaterial||q.isMeshLambertMaterial||q.isMeshBasicMaterial||q.isMeshStandardMaterial||q.isShaderMaterial)&&jt.setValue(W,"isOrthographic",I.isOrthographicCamera===!0),B!==I&&(B=I,Wi=!0,ui=!0)}if(X.isSkinnedMesh){jt.setOptional(W,X,"bindMatrix"),jt.setOptional(W,X,"bindMatrixInverse");const sn=X.skeleton;sn&&(ke.floatVertexTextures?(sn.boneTexture===null&&sn.computeBoneTexture(),jt.setValue(W,"boneTexture",sn.boneTexture,st)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}X.isBatchedMesh&&(jt.setOptional(W,X,"batchingTexture"),jt.setValue(W,"batchingTexture",X._matricesTexture,st));const Sl=H.morphAttributes;if((Sl.position!==void 0||Sl.normal!==void 0||Sl.color!==void 0&&ke.isWebGL2===!0)&&Le.update(X,H,Ri),(Wi||Et.receiveShadow!==X.receiveShadow)&&(Et.receiveShadow=X.receiveShadow,jt.setValue(W,"receiveShadow",X.receiveShadow)),q.isMeshGouraudMaterial&&q.envMap!==null&&(gs.envMap.value=Pe,gs.flipEnvMap.value=Pe.isCubeTexture&&Pe.isRenderTargetTexture===!1?-1:1),Wi&&(jt.setValue(W,"toneMappingExposure",y.toneMappingExposure),Et.needsLights&&F(gs,ui),de&&q.fog===!0&&Ee.refreshFogUniforms(gs,de),Ee.refreshMaterialUniforms(gs,q,k,L,be),c_.upload(W,dm(Et),gs,st)),q.isShaderMaterial&&q.uniformsNeedUpdate===!0&&(c_.upload(W,dm(Et),gs,st),q.uniformsNeedUpdate=!1),q.isSpriteMaterial&&jt.setValue(W,"center",X.center),jt.setValue(W,"modelViewMatrix",X.modelViewMatrix),jt.setValue(W,"normalMatrix",X.normalMatrix),jt.setValue(W,"modelMatrix",X.matrixWorld),q.isShaderMaterial||q.isRawShaderMaterial){const sn=q.uniformsGroups;for(let Oc=0,yH=sn.length;Oc<yH;Oc++)if(ke.isWebGL2){const IP=sn[Oc];nt.update(IP,Ri),nt.bind(IP,Ri)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Ri}function F(I,U){I.ambientLightColor.needsUpdate=U,I.lightProbe.needsUpdate=U,I.directionalLights.needsUpdate=U,I.directionalLightShadows.needsUpdate=U,I.pointLights.needsUpdate=U,I.pointLightShadows.needsUpdate=U,I.spotLights.needsUpdate=U,I.spotLightShadows.needsUpdate=U,I.rectAreaLights.needsUpdate=U,I.hemisphereLights.needsUpdate=U}function J(I){return I.isMeshLambertMaterial||I.isMeshToonMaterial||I.isMeshPhongMaterial||I.isMeshStandardMaterial||I.isShadowMaterial||I.isShaderMaterial&&I.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(I,U,H){Je.get(I.texture).__webglTexture=U,Je.get(I.depthTexture).__webglTexture=H;const q=Je.get(I);q.__hasExternalTextures=!0,q.__autoAllocateDepthBuffer=H===void 0,q.__autoAllocateDepthBuffer||ye.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),q.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(I,U){const H=Je.get(I);H.__webglFramebuffer=U,H.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(I,U=0,H=0){T=I,E=U,M=H;let q=!0,X=null,de=!1,he=!1;if(I){const Pe=Je.get(I);Pe.__useDefaultFramebuffer!==void 0?(Se.bindFramebuffer(W.FRAMEBUFFER,null),q=!1):Pe.__webglFramebuffer===void 0?st.setupRenderTarget(I):Pe.__hasExternalTextures&&st.rebindTextures(I,Je.get(I.texture).__webglTexture,Je.get(I.depthTexture).__webglTexture);const De=I.texture;(De.isData3DTexture||De.isDataArrayTexture||De.isCompressedArrayTexture)&&(he=!0);const Qe=Je.get(I).__webglFramebuffer;I.isWebGLCubeRenderTarget?(Array.isArray(Qe[U])?X=Qe[U][H]:X=Qe[U],de=!0):ke.isWebGL2&&I.samples>0&&st.useMultisampledRTT(I)===!1?X=Je.get(I).__webglMultisampledFramebuffer:Array.isArray(Qe)?X=Qe[H]:X=Qe,S.copy(I.viewport),R.copy(I.scissor),Q=I.scissorTest}else S.copy($).multiplyScalar(k).floor(),R.copy(re).multiplyScalar(k).floor(),Q=ce;if(Se.bindFramebuffer(W.FRAMEBUFFER,X)&&ke.drawBuffers&&q&&Se.drawBuffers(I,X),Se.viewport(S),Se.scissor(R),Se.setScissorTest(Q),de){const Pe=Je.get(I.texture);W.framebufferTexture2D(W.FRAMEBUFFER,W.COLOR_ATTACHMENT0,W.TEXTURE_CUBE_MAP_POSITIVE_X+U,Pe.__webglTexture,H)}else if(he){const Pe=Je.get(I.texture),De=U||0;W.framebufferTextureLayer(W.FRAMEBUFFER,W.COLOR_ATTACHMENT0,Pe.__webglTexture,H||0,De)}C=-1},this.readRenderTargetPixels=function(I,U,H,q,X,de,he){if(!(I&&I.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ae=Je.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget&&he!==void 0&&(Ae=Ae[he]),Ae){Se.bindFramebuffer(W.FRAMEBUFFER,Ae);try{const Pe=I.texture,De=Pe.format,Qe=Pe.type;if(De!==Ai&&qe.convert(De)!==W.getParameter(W.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ye=Qe===cn&&(ye.has("EXT_color_buffer_half_float")||ke.isWebGL2&&ye.has("EXT_color_buffer_float"));if(Qe!==di&&qe.convert(Qe)!==W.getParameter(W.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Qe===Ni&&(ke.isWebGL2||ye.has("OES_texture_float")||ye.has("WEBGL_color_buffer_float")))&&!Ye){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=I.width-q&&H>=0&&H<=I.height-X&&W.readPixels(U,H,q,X,qe.convert(De),qe.convert(Qe),de)}finally{const Pe=T!==null?Je.get(T).__webglFramebuffer:null;Se.bindFramebuffer(W.FRAMEBUFFER,Pe)}}},this.copyFramebufferToTexture=function(I,U,H=0){const q=Math.pow(2,-H),X=Math.floor(U.image.width*q),de=Math.floor(U.image.height*q);st.setTexture2D(U,0),W.copyTexSubImage2D(W.TEXTURE_2D,H,0,0,I.x,I.y,X,de),Se.unbindTexture()},this.copyTextureToTexture=function(I,U,H,q=0){const X=U.image.width,de=U.image.height,he=qe.convert(H.format),Ae=qe.convert(H.type);st.setTexture2D(H,0),W.pixelStorei(W.UNPACK_FLIP_Y_WEBGL,H.flipY),W.pixelStorei(W.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),W.pixelStorei(W.UNPACK_ALIGNMENT,H.unpackAlignment),U.isDataTexture?W.texSubImage2D(W.TEXTURE_2D,q,I.x,I.y,X,de,he,Ae,U.image.data):U.isCompressedTexture?W.compressedTexSubImage2D(W.TEXTURE_2D,q,I.x,I.y,U.mipmaps[0].width,U.mipmaps[0].height,he,U.mipmaps[0].data):W.texSubImage2D(W.TEXTURE_2D,q,I.x,I.y,he,Ae,U.image),q===0&&H.generateMipmaps&&W.generateMipmap(W.TEXTURE_2D),Se.unbindTexture()},this.copyTextureToTexture3D=function(I,U,H,q,X=0){if(y.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const de=Math.round(I.max.x-I.min.x),he=Math.round(I.max.y-I.min.y),Ae=I.max.z-I.min.z+1,Pe=qe.convert(q.format),De=qe.convert(q.type);let Qe;if(q.isData3DTexture)st.setTexture3D(q,0),Qe=W.TEXTURE_3D;else if(q.isDataArrayTexture||q.isCompressedArrayTexture)st.setTexture2DArray(q,0),Qe=W.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}W.pixelStorei(W.UNPACK_FLIP_Y_WEBGL,q.flipY),W.pixelStorei(W.UNPACK_PREMULTIPLY_ALPHA_WEBGL,q.premultiplyAlpha),W.pixelStorei(W.UNPACK_ALIGNMENT,q.unpackAlignment);const Ye=W.getParameter(W.UNPACK_ROW_LENGTH),Ke=W.getParameter(W.UNPACK_IMAGE_HEIGHT),rt=W.getParameter(W.UNPACK_SKIP_PIXELS),xt=W.getParameter(W.UNPACK_SKIP_ROWS),fi=W.getParameter(W.UNPACK_SKIP_IMAGES),Gt=H.isCompressedTexture?H.mipmaps[X]:H.image;W.pixelStorei(W.UNPACK_ROW_LENGTH,Gt.width),W.pixelStorei(W.UNPACK_IMAGE_HEIGHT,Gt.height),W.pixelStorei(W.UNPACK_SKIP_PIXELS,I.min.x),W.pixelStorei(W.UNPACK_SKIP_ROWS,I.min.y),W.pixelStorei(W.UNPACK_SKIP_IMAGES,I.min.z),H.isDataTexture||H.isData3DTexture?W.texSubImage3D(Qe,X,U.x,U.y,U.z,de,he,Ae,Pe,De,Gt.data):q.isCompressedArrayTexture?W.compressedTexSubImage3D(Qe,X,U.x,U.y,U.z,de,he,Ae,Pe,Gt.data):W.texSubImage3D(Qe,X,U.x,U.y,U.z,de,he,Ae,Pe,De,Gt),W.pixelStorei(W.UNPACK_ROW_LENGTH,Ye),W.pixelStorei(W.UNPACK_IMAGE_HEIGHT,Ke),W.pixelStorei(W.UNPACK_SKIP_PIXELS,rt),W.pixelStorei(W.UNPACK_SKIP_ROWS,xt),W.pixelStorei(W.UNPACK_SKIP_IMAGES,fi),X===0&&q.generateMipmaps&&W.generateMipmap(Qe),Se.unbindTexture()},this.initTexture=function(I){I.isCubeTexture?st.setTextureCube(I,0):I.isData3DTexture?st.setTexture3D(I,0):I.isDataArrayTexture||I.isCompressedArrayTexture?st.setTexture2DArray(I,0):st.setTexture2D(I,0),Se.unbindTexture()},this.resetState=function(){E=0,M=0,T=null,Se.reset(),ct.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Za}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Vv?"display-p3":"srgb",t.unpackColorSpace=vi.workingColorSpace===Mp?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===gt?i1:Xk}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===i1?gt:yi}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class IF extends _c{}IF.prototype.isWebGL1Renderer=!0;class cx{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new xe(e),this.density=t}clone(){return new cx(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let hx=class RF{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new xe(e),this.near=t,this.far=i}clone(){return new RF(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class ir extends ge{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Gi,this.environmentRotation=new Gi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Yv{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=sv,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=uo()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return AF("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=t.array[i+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=uo()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=uo()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const lr=new w;class xr{constructor(e,t,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)lr.fromBufferAttribute(this,t),lr.applyMatrix4(e),this.setXYZ(t,lr.x,lr.y,lr.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)lr.fromBufferAttribute(this,t),lr.applyNormalMatrix(e),this.setXYZ(t,lr.x,lr.y,lr.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)lr.fromBufferAttribute(this,t),lr.transformDirection(e),this.setXYZ(t,lr.x,lr.y,lr.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=yr(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=qt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=qt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=qt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=qt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=qt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=yr(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=yr(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=yr(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=yr(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array),n=qt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array),n=qt(n,this.array),r=qt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return new it(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new xr(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class vT extends Nt{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new xe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let of;const vm=new w,af=new w,lf=new w,cf=new te,Am=new te,PF=new we,Ly=new w,ym=new w,ky=new w,yB=new te,CS=new te,_B=new te;let BF=class extends ge{constructor(e=new vT){if(super(),this.isSprite=!0,this.type="Sprite",of===void 0){of=new wt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Yv(t,5);of.setIndex([0,1,2,0,2,3]),of.setAttribute("position",new xr(i,3,0,!1)),of.setAttribute("uv",new xr(i,2,3,!1))}this.geometry=of,this.material=e,this.center=new te(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),af.setFromMatrixScale(this.matrixWorld),PF.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),lf.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&af.multiplyScalar(-lf.z);const i=this.material.rotation;let n,r;i!==0&&(r=Math.cos(i),n=Math.sin(i));const o=this.center;Fy(Ly.set(-.5,-.5,0),lf,o,af,n,r),Fy(ym.set(.5,-.5,0),lf,o,af,n,r),Fy(ky.set(.5,.5,0),lf,o,af,n,r),yB.set(0,0),CS.set(1,0),_B.set(1,1);let a=e.ray.intersectTriangle(Ly,ym,ky,!1,vm);if(a===null&&(Fy(ym.set(-.5,.5,0),lf,o,af,n,r),CS.set(0,1),a=e.ray.intersectTriangle(Ly,ky,ym,!1,vm),a===null))return;const l=e.ray.origin.distanceTo(vm);l<e.near||l>e.far||t.push({distance:l,point:vm.clone(),uv:_r.getInterpolation(vm,Ly,ym,ky,yB,CS,_B,new te),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function Fy(s,e,t,i,n,r){cf.subVectors(s,t).addScalar(.5).multiply(i),n!==void 0?(Am.x=r*cf.x-n*cf.y,Am.y=n*cf.x+r*cf.y):Am.copy(cf),s.copy(e),s.x+=Am.x,s.y+=Am.y,s.applyMatrix4(PF)}const Uy=new w,bB=new w;let AT=class extends ge{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,n=t.length;i<n;i++){const r=t[i];this.addLevel(r.object.clone(),r.distance,r.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const n=this.levels;let r;for(r=0;r<n.length&&!(t<n[r].distance);r++);return n.splice(r,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,n;for(i=1,n=t.length;i<n;i++){let r=t[i].distance;if(t[i].object.visible&&(r-=r*t[i].hysteresis),e<r)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Uy.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(Uy);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Uy.setFromMatrixPosition(e.matrixWorld),bB.setFromMatrixPosition(this.matrixWorld);const i=Uy.distanceTo(bB)/e.zoom;t[0].object.visible=!0;let n,r;for(n=1,r=t.length;n<r;n++){let o=t[n].distance;if(t[n].object.visible&&(o-=o*t[n].hysteresis),i>=o)t[n-1].object.visible=!1,t[n].object.visible=!0;else break}for(this._currentLevel=n-1;n<r;n++)t[n].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let n=0,r=i.length;n<r;n++){const o=i[n];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}};const xB=new w,wB=new Ze,SB=new Ze,oj=new w,CB=new we,Ny=new w,ES=new In,EB=new we,MS=new Hr;class ga extends pe{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=kE,this.bindMatrix=new we,this.bindMatrixInverse=new we,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ti),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Ny),this.boundingBox.expandByPoint(Ny)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new In),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Ny),this.boundingSphere.expandByPoint(Ny)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ES.copy(this.boundingSphere),ES.applyMatrix4(n),e.ray.intersectsSphere(ES)!==!1&&(EB.copy(n).invert(),MS.copy(e.ray).applyMatrix4(EB),!(this.boundingBox!==null&&MS.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,MS)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Ze,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.fromBufferAttribute(t,i);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===kE?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===zk?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;wB.fromBufferAttribute(n.attributes.skinIndex,e),SB.fromBufferAttribute(n.attributes.skinWeight,e),xB.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const o=SB.getComponent(r);if(o!==0){const a=wB.getComponent(r);CB.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(oj.copy(xB).applyMatrix4(CB),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Jv extends ge{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Nr extends Dt{constructor(e=null,t=1,i=1,n,r,o,a,l,c=Ht,u=Ht,d,f){super(null,o,a,l,c,u,n,r,d,f),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const MB=new we,aj=new we;class Pp{constructor(e=[],t=[]){this.uuid=uo(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new we)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new we;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let r=0,o=e.length;r<o;r++){const a=e[r]?e[r].matrixWorld:aj;MB.multiplyMatrices(a,t[r]),MB.toArray(i,r*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new Pp(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new Nr(t,e,e,Ai,Ni);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){const r=e.bones[i];let o=t[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new Jv),this.bones.push(o),this.boneInverses.push(new we().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let n=0,r=t.length;n<r;n++){const o=t[n];e.bones.push(o.uuid);const a=i[n];e.boneInverses.push(a.toArray())}return e}}class Lr extends it{constructor(e,t,i,n=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const hf=new we,TB=new we,zy=[],IB=new Ti,lj=new we,_m=new pe,bm=new In;class ux extends pe{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Lr(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,lj)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Ti),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,hf),IB.copy(e.boundingBox).applyMatrix4(hf),this.boundingBox.union(IB)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new In),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,hf),bm.copy(e.boundingSphere).applyMatrix4(hf),this.boundingSphere.union(bm)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,n=this.morphTexture.source.data.data,r=i.length+1,o=e*r+1;for(let a=0;a<i.length;a++)i[a]=n[o+a]}raycast(e,t){const i=this.matrixWorld,n=this.count;if(_m.geometry=this.geometry,_m.material=this.material,_m.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),bm.copy(this.boundingSphere),bm.applyMatrix4(i),e.ray.intersectsSphere(bm)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,hf),TB.multiplyMatrices(i,hf),_m.matrixWorld=TB,_m.raycast(e,zy);for(let o=0,a=zy.length;o<a;o++){const l=zy[o];l.instanceId=r,l.object=this,t.push(l)}zy.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Lr(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new Nr(new Float32Array(n*this.count),n,this.count,pa,Ni));const r=this.morphTexture.source.data.data;let o=0;for(let c=0;c<i.length;c++)o+=i[c];const a=this.geometry.morphTargetsRelative?1:1-o,l=n*e;r[l]=a,r.set(i,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}function cj(s,e){return s.z-e.z}function hj(s,e){return e.z-s.z}class uj{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t){const i=this.pool,n=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});const r=i[this.index];n.push(r),this.index++,r.start=e.start,r.count=e.count,r.z=t}reset(){this.list.length=0,this.index=0}}const uf="batchId",Gc=new we,RB=new we,dj=new we,PB=new we,TS=new qv,Gy=new Ti,ru=new In,xm=new w,IS=new uj,js=new pe,Hy=[];function fj(s,e,t=0){const i=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const n=s.count;for(let r=0;r<n;r++)for(let o=0;o<i;o++)e.setComponent(r+t,o,s.getComponent(r,o))}else e.array.set(s.array,t*i);e.needsUpdate=!0}class DF extends pe{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,i=t*2,n){super(new wt,n),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new Nr(t,e,e,Ai,Ni);this._matricesTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,n=this._maxGeometryCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const a in e.attributes){const l=e.getAttribute(a),{array:c,itemSize:u,normalized:d}=l,f=new c.constructor(i*u),p=new l.constructor(f,u,d);p.setUsage(l.usage),t.setAttribute(a,p)}if(e.getIndex()!==null){const a=i>65536?new Uint32Array(r):new Uint16Array(r);t.setIndex(new it(a,1))}const o=n>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(uf,new it(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(uf))throw new Error(`BatchedMesh: Geometry cannot use attribute "${uf}"`);const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(i===uf)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const n=e.getAttribute(i),r=t.getAttribute(i);if(n.itemSize!==r.itemSize||n.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ti);const e=this._geometryCount,t=this.boundingBox,i=this._active;t.makeEmpty();for(let n=0;n<e;n++)i[n]!==!1&&(this.getMatrixAt(n,Gc),this.getBoundingBoxAt(n,Gy).applyMatrix4(Gc),t.union(Gy))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new In);const e=this._geometryCount,t=this.boundingSphere,i=this._active;t.makeEmpty();for(let n=0;n<e;n++)i[n]!==!1&&(this.getMatrixAt(n,Gc),this.getBoundingSphereAt(n,ru).applyMatrix4(Gc),t.union(ru))}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const n={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let r=null;const o=this._reservedRanges,a=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(r=o[o.length-1]),t===-1?n.vertexCount=e.getAttribute("position").count:n.vertexCount=t,r===null?n.vertexStart=0:n.vertexStart=r.vertexStart+r.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(i===-1?n.indexCount=c.count:n.indexCount=i,r===null?n.indexStart=0:n.indexStart=r.indexStart+r.indexCount),n.indexStart!==-1&&n.indexStart+n.indexCount>this._maxIndexCount||n.vertexStart+n.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const d=this._visibility,f=this._active,p=this._matricesTexture,m=this._matricesTexture.image.data;d.push(!0),f.push(!0);const A=this._geometryCount;this._geometryCount++,dj.toArray(m,A*16),p.needsUpdate=!0,o.push(n),a.push({start:u?n.indexStart:n.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Ti,sphereInitialized:!1,sphere:new In});const v=this.geometry.getAttribute(uf);for(let g=0;g<n.vertexCount;g++)v.setX(n.vertexStart+g,A);return v.needsUpdate=!0,this.setGeometryAt(A,e),A}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,n=i.getIndex()!==null,r=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(n&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=a.vertexStart,c=a.vertexCount;for(const p in i.attributes){if(p===uf)continue;const m=t.getAttribute(p),A=i.getAttribute(p);fj(m,A,l);const v=m.itemSize;for(let g=m.count,_=c;g<_;g++){const y=l+g;for(let b=0;b<v;b++)A.setComponent(y,b,0)}A.needsUpdate=!0}if(n){const p=a.indexStart;for(let m=0;m<o.count;m++)r.setX(p+m,l+o.getX(m));for(let m=o.count,A=a.indexCount;m<A;m++)r.setX(p+m,l);r.needsUpdate=!0}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const d=this._drawRanges[e],f=t.getAttribute("position");return d.count=n?o.count:f.count,this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._active;return e>=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;const n=this._bounds[e],r=n.box,o=this.geometry;if(n.boxInitialized===!1){r.makeEmpty();const a=o.index,l=o.attributes.position,c=this._drawRanges[e];for(let u=c.start,d=c.start+c.count;u<d;u++){let f=u;a&&(f=a.getX(f)),r.expandByPoint(xm.fromBufferAttribute(l,f))}n.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(this._active[e]===!1)return null;const n=this._bounds[e],r=n.sphere,o=this.geometry;if(n.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,Gy),Gy.getCenter(r.center);const a=o.index,l=o.attributes.position,c=this._drawRanges[e];let u=0;for(let d=c.start,f=c.start+c.count;d<f;d++){let p=d;a&&(p=a.getX(p)),xm.fromBufferAttribute(l,p),u=Math.max(u,r.center.distanceToSquared(xm))}r.radius=Math.sqrt(u),n.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const i=this._active,n=this._matricesTexture,r=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||i[e]===!1?this:(t.toArray(r,e*16),n.needsUpdate=!0,this)}getMatrixAt(e,t){const i=this._active,n=this._matricesTexture.image.data,r=this._geometryCount;return e>=r||i[e]===!1?null:t.fromArray(n,e*16)}setVisibleAt(e,t){const i=this._visibility,n=this._active,r=this._geometryCount;return e>=r||n[e]===!1||i[e]===t?this:(i[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._visibility,i=this._active,n=this._geometryCount;return e>=n||i[e]===!1?!1:t[e]}raycast(e,t){const i=this._visibility,n=this._active,r=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,l=this.geometry;js.material=this.material,js.geometry.index=l.index,js.geometry.attributes=l.attributes,js.geometry.boundingBox===null&&(js.geometry.boundingBox=new Ti),js.geometry.boundingSphere===null&&(js.geometry.boundingSphere=new In);for(let c=0;c<o;c++){if(!i[c]||!n[c])continue;const u=r[c];js.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(c,js.matrixWorld).premultiply(a),this.getBoundingBoxAt(c,js.geometry.boundingBox),this.getBoundingSphereAt(c,js.geometry.boundingSphere),js.raycast(e,Hy);for(let d=0,f=Hy.length;d<f;d++){const p=Hy[d];p.object=this,p.batchId=c,t.push(p)}Hy.length=0}js.material=null,js.geometry.index=null,js.geometry.attributes={},js.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,i,n,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=n.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,l=this._active,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,p=this.perObjectFrustumCulled;p&&(PB.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),TS.setFromProjectionMatrix(PB,e.coordinateSystem));let m=0;if(this.sortObjects){RB.copy(this.matrixWorld).invert(),xm.setFromMatrixPosition(i.matrixWorld).applyMatrix4(RB);for(let g=0,_=c.length;g<_;g++)if(c[g]&&l[g]){this.getMatrixAt(g,Gc),this.getBoundingSphereAt(g,ru).applyMatrix4(Gc);let y=!1;if(p&&(y=!TS.intersectsSphere(ru)),!y){const b=xm.distanceTo(ru.center);IS.push(f[g],b)}}const A=IS.list,v=this.customSort;v===null?A.sort(r.transparent?hj:cj):v.call(this,A,i);for(let g=0,_=A.length;g<_;g++){const y=A[g];u[m]=y.start*a,d[m]=y.count,m++}IS.reset()}else for(let A=0,v=c.length;A<v;A++)if(c[A]&&l[A]){let g=!1;if(p&&(this.getMatrixAt(A,Gc),this.getBoundingSphereAt(A,ru).applyMatrix4(Gc),g=!TS.intersectsSphere(ru)),!g){const _=f[A];u[m]=_.start*a,d[m]=_.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,t,i,n,r,o){this.onBeforeRender(e,null,n,r,o)}}class Rn extends Nt{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const BB=new w,DB=new w,OB=new we,RS=new Hr,Qy=new In;let Mn=class extends ge{constructor(e=new wt,t=new Rn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let n=1,r=t.count;n<r;n++)BB.fromBufferAttribute(t,n-1),DB.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=BB.distanceTo(DB);e.setAttribute("lineDistance",new ut(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Qy.copy(i.boundingSphere),Qy.applyMatrix4(n),Qy.radius+=r,e.ray.intersectsSphere(Qy)===!1)return;OB.copy(n).invert(),RS.copy(e.ray).applyMatrix4(OB);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new w,u=new w,d=new w,f=new w,p=this.isLineSegments?2:1,m=i.index,v=i.attributes.position;if(m!==null){const g=Math.max(0,o.start),_=Math.min(m.count,o.start+o.count);for(let y=g,b=_-1;y<b;y+=p){const E=m.getX(y),M=m.getX(y+1);if(c.fromBufferAttribute(v,E),u.fromBufferAttribute(v,M),RS.distanceSqToSegment(c,u,f,d)>l)continue;f.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(f);C<e.near||C>e.far||t.push({distance:C,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{const g=Math.max(0,o.start),_=Math.min(v.count,o.start+o.count);for(let y=g,b=_-1;y<b;y+=p){if(c.fromBufferAttribute(v,y),u.fromBufferAttribute(v,y+1),RS.distanceSqToSegment(c,u,f,d)>l)continue;f.applyMatrix4(this.matrixWorld);const M=e.ray.origin.distanceTo(f);M<e.near||M>e.far||t.push({distance:M,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};const LB=new w,kB=new w;class Ao extends Mn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let n=0,r=t.count;n<r;n+=2)LB.fromBufferAttribute(t,n),kB.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+LB.distanceTo(kB);e.setAttribute("lineDistance",new ut(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class yT extends Mn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class dx extends Nt{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new xe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const FB=new we,a1=new Hr,Vy=new In,jy=new w;class _T extends ge{constructor(e=new wt,t=new dx){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Vy.copy(i.boundingSphere),Vy.applyMatrix4(n),Vy.radius+=r,e.ray.intersectsSphere(Vy)===!1)return;FB.copy(n).invert(),a1.copy(e.ray).applyMatrix4(FB);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=i.index,d=i.attributes.position;if(c!==null){const f=Math.max(0,o.start),p=Math.min(c.count,o.start+o.count);for(let m=f,A=p;m<A;m++){const v=c.getX(m);jy.fromBufferAttribute(d,v),UB(jy,v,l,n,e,t,this)}}else{const f=Math.max(0,o.start),p=Math.min(d.count,o.start+o.count);for(let m=f,A=p;m<A;m++)jy.fromBufferAttribute(d,m),UB(jy,m,l,n,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function UB(s,e,t,i,n,r,o){const a=a1.distanceSqToPoint(s);if(a<t){const l=new w;a1.closestPointToPoint(s,l),l.applyMatrix4(i);const c=n.ray.origin.distanceTo(l);if(c<n.near||c>n.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class OF extends Dt{constructor(e,t,i,n,r,o,a,l,c){super(e,t,i,n,r,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Mt,this.magFilter=r!==void 0?r:Mt,this.generateMipmaps=!1;const u=this;function d(){u.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class pj extends Dt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ht,this.minFilter=Ht,this.generateMipmaps=!1,this.needsUpdate=!0}}class rl extends Dt{constructor(e,t,i,n,r,o,a,l,c,u,d,f){super(null,o,a,l,c,u,n,r,d,f),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class LF extends rl{constructor(e,t,i,n,r,o){super(e,t,i,r,o),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=us}}class kF extends rl{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,pc),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class bT extends Dt{constructor(e,t,i,n,r,o,a,l,c){super(e,t,i,n,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class wa{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,n=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),r+=i.distanceTo(n),t.push(r),n=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let n=0;const r=i.length;let o;t?o=t:o=e*i[r-1];let a=0,l=r-1,c;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),c=i[n]-o,c<0)a=n+1;else if(c>0)l=n-1;else{l=n;break}if(n=l,i[n]===o)return n/(r-1);const u=i[n],f=i[n+1]-u,p=(o-u)/f;return(n+p)/(r-1)}getTangent(e,t){let n=e-1e-4,r=e+1e-4;n<0&&(n=0),r>1&&(r=1);const o=this.getPoint(n),a=this.getPoint(r),l=t||(o.isVector2?new te:new w);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new w,n=[],r=[],o=[],a=new w,l=new we;for(let p=0;p<=e;p++){const m=p/e;n[p]=this.getTangentAt(m,new w)}r[0]=new w,o[0]=new w;let c=Number.MAX_VALUE;const u=Math.abs(n[0].x),d=Math.abs(n[0].y),f=Math.abs(n[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),f<=c&&i.set(0,0,1),a.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],a),o[0].crossVectors(n[0],r[0]);for(let p=1;p<=e;p++){if(r[p]=r[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(n[p-1],n[p]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(An(n[p-1].dot(n[p]),-1,1));r[p].applyMatrix4(l.makeRotationAxis(a,m))}o[p].crossVectors(n[p],r[p])}if(t===!0){let p=Math.acos(An(r[0].dot(r[e]),-1,1));p/=e,n[0].dot(a.crossVectors(r[0],r[e]))>0&&(p=-p);for(let m=1;m<=e;m++)r[m].applyMatrix4(l.makeRotationAxis(n[m],p*m)),o[m].crossVectors(n[m],r[m])}return{tangents:n,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class fx extends wa{constructor(e=0,t=0,i=1,n=1,r=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new te){const i=t,n=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(o?r=0:r=n),this.aClockwise===!0&&!o&&(r===n?r=-n:r=r-n);const a=this.aStartAngle+e*r;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),d=Math.sin(this.aRotation),f=l-this.aX,p=c-this.aY;l=f*u-p*d+this.aX,c=f*d+p*u+this.aY}return i.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class FF extends fx{constructor(e,t,i,n,r,o){super(e,t,i,i,n,r,o),this.isArcCurve=!0,this.type="ArcCurve"}}function xT(){let s=0,e=0,t=0,i=0;function n(r,o,a,l){s=r,e=a,t=-3*r+3*o-2*a-l,i=2*r-2*o+a+l}return{initCatmullRom:function(r,o,a,l,c){n(o,a,c*(a-r),c*(l-o))},initNonuniformCatmullRom:function(r,o,a,l,c,u,d){let f=(o-r)/c-(a-r)/(c+u)+(a-o)/u,p=(a-o)/u-(l-o)/(u+d)+(l-a)/d;f*=u,p*=u,n(o,a,f,p)},calc:function(r){const o=r*r,a=o*r;return s+e*r+t*o+i*a}}}const Wy=new w,PS=new xT,BS=new xT,DS=new xT;class UF extends wa{constructor(e=[],t=!1,i="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=n}getPoint(e,t=new w){const i=t,n=this.points,r=n.length,o=(r-(this.closed?0:1))*e;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:l===0&&a===r-1&&(a=r-2,l=1);let c,u;this.closed||a>0?c=n[(a-1)%r]:(Wy.subVectors(n[0],n[1]).add(n[0]),c=Wy);const d=n[a%r],f=n[(a+1)%r];if(this.closed||a+2<r?u=n[(a+2)%r]:(Wy.subVectors(n[r-1],n[r-2]).add(n[r-1]),u=Wy),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(d),p),A=Math.pow(d.distanceToSquared(f),p),v=Math.pow(f.distanceToSquared(u),p);A<1e-4&&(A=1),m<1e-4&&(m=A),v<1e-4&&(v=A),PS.initNonuniformCatmullRom(c.x,d.x,f.x,u.x,m,A,v),BS.initNonuniformCatmullRom(c.y,d.y,f.y,u.y,m,A,v),DS.initNonuniformCatmullRom(c.z,d.z,f.z,u.z,m,A,v)}else this.curveType==="catmullrom"&&(PS.initCatmullRom(c.x,d.x,f.x,u.x,this.tension),BS.initCatmullRom(c.y,d.y,f.y,u.y,this.tension),DS.initCatmullRom(c.z,d.z,f.z,u.z,this.tension));return i.set(PS.calc(l),BS.calc(l),DS.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(new w().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function NB(s,e,t,i,n){const r=(i-e)*.5,o=(n-t)*.5,a=s*s,l=s*a;return(2*t-2*i+r+o)*l+(-3*t+3*i-2*r-o)*a+r*s+t}function mj(s,e){const t=1-s;return t*t*e}function gj(s,e){return 2*(1-s)*s*e}function vj(s,e){return s*s*e}function xg(s,e,t,i){return mj(s,e)+gj(s,t)+vj(s,i)}function Aj(s,e){const t=1-s;return t*t*t*e}function yj(s,e){const t=1-s;return 3*t*t*s*e}function _j(s,e){return 3*(1-s)*s*s*e}function bj(s,e){return s*s*s*e}function wg(s,e,t,i,n){return Aj(s,e)+yj(s,t)+_j(s,i)+bj(s,n)}class wT extends wa{constructor(e=new te,t=new te,i=new te,n=new te){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new te){const i=t,n=this.v0,r=this.v1,o=this.v2,a=this.v3;return i.set(wg(e,n.x,r.x,o.x,a.x),wg(e,n.y,r.y,o.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class NF extends wa{constructor(e=new w,t=new w,i=new w,n=new w){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new w){const i=t,n=this.v0,r=this.v1,o=this.v2,a=this.v3;return i.set(wg(e,n.x,r.x,o.x,a.x),wg(e,n.y,r.y,o.y,a.y),wg(e,n.z,r.z,o.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class ST extends wa{constructor(e=new te,t=new te){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new te){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new te){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class zF extends wa{constructor(e=new w,t=new w){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new w){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new w){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class CT extends wa{constructor(e=new te,t=new te,i=new te){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new te){const i=t,n=this.v0,r=this.v1,o=this.v2;return i.set(xg(e,n.x,r.x,o.x),xg(e,n.y,r.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class ET extends wa{constructor(e=new w,t=new w,i=new w){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new w){const i=t,n=this.v0,r=this.v1,o=this.v2;return i.set(xg(e,n.x,r.x,o.x),xg(e,n.y,r.y,o.y),xg(e,n.z,r.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class MT extends wa{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new te){const i=t,n=this.points,r=(n.length-1)*e,o=Math.floor(r),a=r-o,l=n[o===0?o:o-1],c=n[o],u=n[o>n.length-2?n.length-1:o+1],d=n[o>n.length-3?n.length-1:o+2];return i.set(NB(a,l.x,c.x,u.x,d.x),NB(a,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(new te().fromArray(n))}return this}}var tb=Object.freeze({__proto__:null,ArcCurve:FF,CatmullRomCurve3:UF,CubicBezierCurve:wT,CubicBezierCurve3:NF,EllipseCurve:fx,LineCurve:ST,LineCurve3:zF,QuadraticBezierCurve:CT,QuadraticBezierCurve3:ET,SplineCurve:MT});class GF extends wa{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new tb[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),n=this.getCurveLengths();let r=0;for(;r<n.length;){if(n[r]>=i){const o=n[r]-i,a=this.curves[r],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,n=this.curves.length;i<n;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let n=0,r=this.curves;n<r.length;n++){const o=r[n],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){const u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const n=e.curves[t];this.curves.push(new tb[n.type]().fromJSON(n))}return this}}class av extends GF{constructor(e){super(),this.type="Path",this.currentPoint=new te,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new ST(this.currentPoint.clone(),new te(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,n){const r=new CT(this.currentPoint.clone(),new te(e,t),new te(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this}bezierCurveTo(e,t,i,n,r,o){const a=new wT(this.currentPoint.clone(),new te(e,t),new te(i,n),new te(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new MT(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,n,r,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,i,n,r,o),this}absarc(e,t,i,n,r,o){return this.absellipse(e,t,i,i,n,r,o),this}ellipse(e,t,i,n,r,o,a,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,n,r,o,a,l),this}absellipse(e,t,i,n,r,o,a,l){const c=new fx(e,t,i,n,r,o,a,l);if(this.curves.length>0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Kv extends wt{constructor(e=[new te(0,-.5),new te(.5,0),new te(0,.5)],t=12,i=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:n},t=Math.floor(t),n=An(n,0,Math.PI*2);const r=[],o=[],a=[],l=[],c=[],u=1/t,d=new w,f=new te,p=new w,m=new w,A=new w;let v=0,g=0;for(let _=0;_<=e.length-1;_++)switch(_){case 0:v=e[_+1].x-e[_].x,g=e[_+1].y-e[_].y,p.x=g*1,p.y=-v,p.z=g*0,A.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(A.x,A.y,A.z);break;default:v=e[_+1].x-e[_].x,g=e[_+1].y-e[_].y,p.x=g*1,p.y=-v,p.z=g*0,m.copy(p),p.x+=A.x,p.y+=A.y,p.z+=A.z,p.normalize(),l.push(p.x,p.y,p.z),A.copy(m)}for(let _=0;_<=t;_++){const y=i+_*u*n,b=Math.sin(y),E=Math.cos(y);for(let M=0;M<=e.length-1;M++){d.x=e[M].x*b,d.y=e[M].y,d.z=e[M].x*E,o.push(d.x,d.y,d.z),f.x=_/t,f.y=M/(e.length-1),a.push(f.x,f.y);const T=l[3*M+0]*b,C=l[3*M+1],B=l[3*M+0]*E;c.push(T,C,B)}}for(let _=0;_<t;_++)for(let y=0;y<e.length-1;y++){const b=y+_*e.length,E=b,M=b+e.length,T=b+e.length+1,C=b+1;r.push(E,M,C),r.push(T,C,M)}this.setIndex(r),this.setAttribute("position",new ut(o,3)),this.setAttribute("uv",new ut(a,2)),this.setAttribute("normal",new ut(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kv(e.points,e.segments,e.phiStart,e.phiLength)}}class px extends Kv{constructor(e=1,t=1,i=4,n=8){const r=new av;r.absarc(0,-t/2,e,Math.PI*1.5,0),r.absarc(0,t/2,e,0,Math.PI*.5),super(r.getPoints(i),n),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:n}}static fromJSON(e){return new px(e.radius,e.length,e.capSegments,e.radialSegments)}}class mx extends wt{constructor(e=1,t=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);const r=[],o=[],a=[],l=[],c=new w,u=new te;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let d=0,f=3;d<=t;d++,f+=3){const p=i+d/t*n;c.x=e*Math.cos(p),c.y=e*Math.sin(p),o.push(c.x,c.y,c.z),a.push(0,0,1),u.x=(o[f]/e+1)/2,u.y=(o[f+1]/e+1)/2,l.push(u.x,u.y)}for(let d=1;d<=t;d++)r.push(d,d+1,0);this.setIndex(r),this.setAttribute("position",new ut(o,3)),this.setAttribute("normal",new ut(a,3)),this.setAttribute("uv",new ut(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mx(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Sn extends wt{constructor(e=1,t=1,i=1,n=32,r=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:l};const c=this;n=Math.floor(n),r=Math.floor(r);const u=[],d=[],f=[],p=[];let m=0;const A=[],v=i/2;let g=0;_(),o===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new ut(d,3)),this.setAttribute("normal",new ut(f,3)),this.setAttribute("uv",new ut(p,2));function _(){const b=new w,E=new w;let M=0;const T=(t-e)/i;for(let C=0;C<=r;C++){const B=[],S=C/r,R=S*(t-e)+e;for(let Q=0;Q<=n;Q++){const z=Q/n,O=z*l+a,V=Math.sin(O),L=Math.cos(O);E.x=R*V,E.y=-S*i+v,E.z=R*L,d.push(E.x,E.y,E.z),b.set(V,T,L).normalize(),f.push(b.x,b.y,b.z),p.push(z,1-S),B.push(m++)}A.push(B)}for(let C=0;C<n;C++)for(let B=0;B<r;B++){const S=A[B][C],R=A[B+1][C],Q=A[B+1][C+1],z=A[B][C+1];u.push(S,R,z),u.push(R,Q,z),M+=6}c.addGroup(g,M,0),g+=M}function y(b){const E=m,M=new te,T=new w;let C=0;const B=b===!0?e:t,S=b===!0?1:-1;for(let Q=1;Q<=n;Q++)d.push(0,v*S,0),f.push(0,S,0),p.push(.5,.5),m++;const R=m;for(let Q=0;Q<=n;Q++){const O=Q/n*l+a,V=Math.cos(O),L=Math.sin(O);T.x=B*L,T.y=v*S,T.z=B*V,d.push(T.x,T.y,T.z),f.push(0,S,0),M.x=V*.5+.5,M.y=L*.5*S+.5,p.push(M.x,M.y),m++}for(let Q=0;Q<n;Q++){const z=E+Q,O=R+Q;b===!0?u.push(O,O+1,z):u.push(O+1,O,z),C+=3}c.addGroup(g,C,b===!0?1:2),g+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Sn(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class gx extends Sn{constructor(e=1,t=1,i=32,n=1,r=!1,o=0,a=Math.PI*2){super(0,e,t,i,n,r,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:o,thetaLength:a}}static fromJSON(e){return new gx(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Fh extends wt{constructor(e=[],t=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:n};const r=[],o=[];a(n),c(i),u(),this.setAttribute("position",new ut(r,3)),this.setAttribute("normal",new ut(r.slice(),3)),this.setAttribute("uv",new ut(o,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function a(_){const y=new w,b=new w,E=new w;for(let M=0;M<t.length;M+=3)p(t[M+0],y),p(t[M+1],b),p(t[M+2],E),l(y,b,E,_)}function l(_,y,b,E){const M=E+1,T=[];for(let C=0;C<=M;C++){T[C]=[];const B=_.clone().lerp(b,C/M),S=y.clone().lerp(b,C/M),R=M-C;for(let Q=0;Q<=R;Q++)Q===0&&C===M?T[C][Q]=B:T[C][Q]=B.clone().lerp(S,Q/R)}for(let C=0;C<M;C++)for(let B=0;B<2*(M-C)-1;B++){const S=Math.floor(B/2);B%2===0?(f(T[C][S+1]),f(T[C+1][S]),f(T[C][S])):(f(T[C][S+1]),f(T[C+1][S+1]),f(T[C+1][S]))}}function c(_){const y=new w;for(let b=0;b<r.length;b+=3)y.x=r[b+0],y.y=r[b+1],y.z=r[b+2],y.normalize().multiplyScalar(_),r[b+0]=y.x,r[b+1]=y.y,r[b+2]=y.z}function u(){const _=new w;for(let y=0;y<r.length;y+=3){_.x=r[y+0],_.y=r[y+1],_.z=r[y+2];const b=v(_)/2/Math.PI+.5,E=g(_)/Math.PI+.5;o.push(b,1-E)}m(),d()}function d(){for(let _=0;_<o.length;_+=6){const y=o[_+0],b=o[_+2],E=o[_+4],M=Math.max(y,b,E),T=Math.min(y,b,E);M>.9&&T<.1&&(y<.2&&(o[_+0]+=1),b<.2&&(o[_+2]+=1),E<.2&&(o[_+4]+=1))}}function f(_){r.push(_.x,_.y,_.z)}function p(_,y){const b=_*3;y.x=e[b+0],y.y=e[b+1],y.z=e[b+2]}function m(){const _=new w,y=new w,b=new w,E=new w,M=new te,T=new te,C=new te;for(let B=0,S=0;B<r.length;B+=9,S+=6){_.set(r[B+0],r[B+1],r[B+2]),y.set(r[B+3],r[B+4],r[B+5]),b.set(r[B+6],r[B+7],r[B+8]),M.set(o[S+0],o[S+1]),T.set(o[S+2],o[S+3]),C.set(o[S+4],o[S+5]),E.copy(_).add(y).add(b).divideScalar(3);const R=v(E);A(M,S+0,_,R),A(T,S+2,y,R),A(C,S+4,b,R)}}function A(_,y,b,E){E<0&&_.x===1&&(o[y]=_.x-1),b.x===0&&b.z===0&&(o[y]=E/2/Math.PI+.5)}function v(_){return Math.atan2(_.z,-_.x)}function g(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fh(e.vertices,e.indices,e.radius,e.details)}}class vx extends Fh{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,n=1/i,r=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],o=[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];super(r,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new vx(e.radius,e.detail)}}const qy=new w,Xy=new w,OS=new w,Yy=new _r;class TT extends wt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const n=Math.pow(10,4),r=Math.cos(Hu*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],u=["a","b","c"],d=new Array(3),f={},p=[];for(let m=0;m<l;m+=3){o?(c[0]=o.getX(m),c[1]=o.getX(m+1),c[2]=o.getX(m+2)):(c[0]=m,c[1]=m+1,c[2]=m+2);const{a:A,b:v,c:g}=Yy;if(A.fromBufferAttribute(a,c[0]),v.fromBufferAttribute(a,c[1]),g.fromBufferAttribute(a,c[2]),Yy.getNormal(OS),d[0]=`${Math.round(A.x*n)},${Math.round(A.y*n)},${Math.round(A.z*n)}`,d[1]=`${Math.round(v.x*n)},${Math.round(v.y*n)},${Math.round(v.z*n)}`,d[2]=`${Math.round(g.x*n)},${Math.round(g.y*n)},${Math.round(g.z*n)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let _=0;_<3;_++){const y=(_+1)%3,b=d[_],E=d[y],M=Yy[u[_]],T=Yy[u[y]],C=`${b}_${E}`,B=`${E}_${b}`;B in f&&f[B]?(OS.dot(f[B].normal)<=r&&(p.push(M.x,M.y,M.z),p.push(T.x,T.y,T.z)),f[B]=null):C in f||(f[C]={index0:c[_],index1:c[y],normal:OS.clone()})}}for(const m in f)if(f[m]){const{index0:A,index1:v}=f[m];qy.fromBufferAttribute(a,A),Xy.fromBufferAttribute(a,v),p.push(qy.x,qy.y,qy.z),p.push(Xy.x,Xy.y,Xy.z)}this.setAttribute("position",new ut(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Qu extends av{constructor(e){super(e),this.uuid=uo(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,n=this.holes.length;i<n;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const n=e.holes[t];this.holes.push(new av().fromJSON(n))}return this}}const xj={triangulate:function(s,e,t=2){const i=e&&e.length,n=i?e[0]*t:s.length;let r=HF(s,0,n,t,!0);const o=[];if(!r||r.next===r.prev)return o;let a,l,c,u,d,f,p;if(i&&(r=Mj(s,e,r,t)),s.length>80*t){a=c=s[0],l=u=s[1];for(let m=t;m<n;m+=t)d=s[m],f=s[m+1],d<a&&(a=d),f<l&&(l=f),d>c&&(c=d),f>u&&(u=f);p=Math.max(c-a,u-l),p=p!==0?32767/p:0}return lv(r,o,t,a,l,p,0),o}};function HF(s,e,t,i,n){let r,o;if(n===Uj(s,e,t,i)>0)for(r=e;r<t;r+=i)o=zB(r,s[r],s[r+1],o);else for(r=t-i;r>=e;r-=i)o=zB(r,s[r],s[r+1],o);return o&&Ax(o,o.next)&&(hv(o),o=o.next),o}function nd(s,e){if(!s)return s;e||(e=s);let t=s,i;do if(i=!1,!t.steiner&&(Ax(t,t.next)||ln(t.prev,t,t.next)===0)){if(hv(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function lv(s,e,t,i,n,r,o){if(!s)return;!o&&r&&Bj(s,i,n,r);let a=s,l,c;for(;s.prev!==s.next;){if(l=s.prev,c=s.next,r?Sj(s,i,n,r):wj(s)){e.push(l.i/t|0),e.push(s.i/t|0),e.push(c.i/t|0),hv(s),s=c.next,a=c.next;continue}if(s=c,s===a){o?o===1?(s=Cj(nd(s),e,t),lv(s,e,t,i,n,r,2)):o===2&&Ej(s,e,t,i,n,r):lv(nd(s),e,t,i,n,r,1);break}}}function wj(s){const e=s.prev,t=s,i=s.next;if(ln(e,t,i)>=0)return!1;const n=e.x,r=t.x,o=i.x,a=e.y,l=t.y,c=i.y,u=n<r?n<o?n:o:r<o?r:o,d=a<l?a<c?a:c:l<c?l:c,f=n>r?n>o?n:o:r>o?r:o,p=a>l?a>c?a:c:l>c?l:c;let m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&Uf(n,a,r,l,o,c,m.x,m.y)&&ln(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Sj(s,e,t,i){const n=s.prev,r=s,o=s.next;if(ln(n,r,o)>=0)return!1;const a=n.x,l=r.x,c=o.x,u=n.y,d=r.y,f=o.y,p=a<l?a<c?a:c:l<c?l:c,m=u<d?u<f?u:f:d<f?d:f,A=a>l?a>c?a:c:l>c?l:c,v=u>d?u>f?u:f:d>f?d:f,g=l1(p,m,e,t,i),_=l1(A,v,e,t,i);let y=s.prevZ,b=s.nextZ;for(;y&&y.z>=g&&b&&b.z<=_;){if(y.x>=p&&y.x<=A&&y.y>=m&&y.y<=v&&y!==n&&y!==o&&Uf(a,u,l,d,c,f,y.x,y.y)&&ln(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=A&&b.y>=m&&b.y<=v&&b!==n&&b!==o&&Uf(a,u,l,d,c,f,b.x,b.y)&&ln(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=g;){if(y.x>=p&&y.x<=A&&y.y>=m&&y.y<=v&&y!==n&&y!==o&&Uf(a,u,l,d,c,f,y.x,y.y)&&ln(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=_;){if(b.x>=p&&b.x<=A&&b.y>=m&&b.y<=v&&b!==n&&b!==o&&Uf(a,u,l,d,c,f,b.x,b.y)&&ln(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Cj(s,e,t){let i=s;do{const n=i.prev,r=i.next.next;!Ax(n,r)&&QF(n,i,i.next,r)&&cv(n,r)&&cv(r,n)&&(e.push(n.i/t|0),e.push(i.i/t|0),e.push(r.i/t|0),hv(i),hv(i.next),i=s=r),i=i.next}while(i!==s);return nd(i)}function Ej(s,e,t,i,n,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Lj(o,a)){let l=VF(o,a);o=nd(o,o.next),l=nd(l,l.next),lv(o,e,t,i,n,r,0),lv(l,e,t,i,n,r,0);return}a=a.next}o=o.next}while(o!==s)}function Mj(s,e,t,i){const n=[];let r,o,a,l,c;for(r=0,o=e.length;r<o;r++)a=e[r]*i,l=r<o-1?e[r+1]*i:s.length,c=HF(s,a,l,i,!1),c===c.next&&(c.steiner=!0),n.push(Oj(c));for(n.sort(Tj),r=0;r<n.length;r++)t=Ij(n[r],t);return t}function Tj(s,e){return s.x-e.x}function Ij(s,e){const t=Rj(s,e);if(!t)return e;const i=VF(t,s);return nd(i,i.next),nd(t,t.next)}function Rj(s,e){let t=e,i=-1/0,n;const r=s.x,o=s.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){const f=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=r&&f>i&&(i=f,n=t.x<t.next.x?t:t.next,f===r))return n}t=t.next}while(t!==e);if(!n)return null;const a=n,l=n.x,c=n.y;let u=1/0,d;t=n;do r>=t.x&&t.x>=l&&r!==t.x&&Uf(o<c?r:i,o,l,c,o<c?i:r,o,t.x,t.y)&&(d=Math.abs(o-t.y)/(r-t.x),cv(t,s)&&(d<u||d===u&&(t.x>n.x||t.x===n.x&&Pj(n,t)))&&(n=t,u=d)),t=t.next;while(t!==a);return n}function Pj(s,e){return ln(s.prev,s,e.prev)<0&&ln(e.next,s,s.next)<0}function Bj(s,e,t,i){let n=s;do n.z===0&&(n.z=l1(n.x,n.y,e,t,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==s);n.prevZ.nextZ=null,n.prevZ=null,Dj(n)}function Dj(s){let e,t,i,n,r,o,a,l,c=1;do{for(t=s,s=null,r=null,o=0;t;){for(o++,i=t,a=0,e=0;e<c&&(a++,i=i.nextZ,!!i);e++);for(l=c;a>0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(n=t,t=t.nextZ,a--):(n=i,i=i.nextZ,l--),r?r.nextZ=n:s=n,n.prevZ=r,r=n;t=i}r.nextZ=null,c*=2}while(o>1);return s}function l1(s,e,t,i,n){return s=(s-t)*n|0,e=(e-i)*n|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function Oj(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function Uf(s,e,t,i,n,r,o,a){return(n-o)*(e-a)>=(s-o)*(r-a)&&(s-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(r-a)>=(n-o)*(i-a)}function Lj(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!kj(s,e)&&(cv(s,e)&&cv(e,s)&&Fj(s,e)&&(ln(s.prev,s,e.prev)||ln(s,e.prev,e))||Ax(s,e)&&ln(s.prev,s,s.next)>0&&ln(e.prev,e,e.next)>0)}function ln(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function Ax(s,e){return s.x===e.x&&s.y===e.y}function QF(s,e,t,i){const n=Ky(ln(s,e,t)),r=Ky(ln(s,e,i)),o=Ky(ln(t,i,s)),a=Ky(ln(t,i,e));return!!(n!==r&&o!==a||n===0&&Jy(s,t,e)||r===0&&Jy(s,i,e)||o===0&&Jy(t,s,i)||a===0&&Jy(t,e,i))}function Jy(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function Ky(s){return s>0?1:s<0?-1:0}function kj(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&QF(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function cv(s,e){return ln(s.prev,s,s.next)<0?ln(s,e,s.next)>=0&&ln(s,s.prev,e)>=0:ln(s,e,s.prev)<0||ln(s,s.next,e)<0}function Fj(s,e){let t=s,i=!1;const n=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&n<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==s);return i}function VF(s,e){const t=new c1(s.i,s.x,s.y),i=new c1(e.i,e.x,e.y),n=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=n,n.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function zB(s,e,t,i){const n=new c1(s,e,t);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function hv(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function c1(s,e,t){this.i=s,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Uj(s,e,t,i){let n=0;for(let r=e,o=t-i;r<t;r+=i)n+=(s[o]-s[r])*(s[r+1]+s[o+1]),o=r;return n}class ol{static area(e){const t=e.length;let i=0;for(let n=t-1,r=0;r<t;n=r++)i+=e[n].x*e[r].y-e[r].x*e[n].y;return i*.5}static isClockWise(e){return ol.area(e)<0}static triangulateShape(e,t){const i=[],n=[],r=[];GB(e),HB(i,e);let o=e.length;t.forEach(GB);for(let l=0;l<t.length;l++)n.push(o),o+=t[l].length,HB(i,t[l]);const a=xj.triangulate(i,n);for(let l=0;l<a.length;l+=3)r.push(a.slice(l,l+3));return r}}function GB(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function HB(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class yx extends wt{constructor(e=new Qu([new te(.5,.5),new te(-.5,.5),new te(-.5,-.5),new te(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,n=[],r=[];for(let a=0,l=e.length;a<l;a++){const c=e[a];o(c)}this.setAttribute("position",new ut(n,3)),this.setAttribute("uv",new ut(r,2)),this.computeVertexNormals();function o(a){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,A=t.bevelOffset!==void 0?t.bevelOffset:0,v=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,_=t.UVGenerator!==void 0?t.UVGenerator:Nj;let y,b=!1,E,M,T,C;g&&(y=g.getSpacedPoints(u),b=!0,f=!1,E=g.computeFrenetFrames(u,!1),M=new w,T=new w,C=new w),f||(v=0,p=0,m=0,A=0);const B=a.extractPoints(c);let S=B.shape;const R=B.holes;if(!ol.isClockWise(S)){S=S.reverse();for(let W=0,Ne=R.length;W<Ne;W++){const ye=R[W];ol.isClockWise(ye)&&(R[W]=ye.reverse())}}const z=ol.triangulateShape(S,R),O=S;for(let W=0,Ne=R.length;W<Ne;W++){const ye=R[W];S=S.concat(ye)}function V(W,Ne,ye){return Ne||console.error("THREE.ExtrudeGeometry: vec does not exist"),W.clone().addScaledVector(Ne,ye)}const L=S.length,k=z.length;function G(W,Ne,ye){let ke,Se,$e;const Je=W.x-Ne.x,st=W.y-Ne.y,Bt=ye.x-W.x,N=ye.y-W.y,D=Je*Je+st*st,fe=Je*N-st*Bt;if(Math.abs(fe)>Number.EPSILON){const ve=Math.sqrt(D),Ie=Math.sqrt(Bt*Bt+N*N),Ee=Ne.x-st/ve,vt=Ne.y+Je/ve,at=ye.x-N/Ie,Oe=ye.y+Bt/Ie,He=((at-Ee)*N-(Oe-vt)*Bt)/(Je*N-st*Bt);ke=Ee+Je*He-W.x,Se=vt+st*He-W.y;const yt=ke*ke+Se*Se;if(yt<=2)return new te(ke,Se);$e=Math.sqrt(yt/2)}else{let ve=!1;Je>Number.EPSILON?Bt>Number.EPSILON&&(ve=!0):Je<-Number.EPSILON?Bt<-Number.EPSILON&&(ve=!0):Math.sign(st)===Math.sign(N)&&(ve=!0),ve?(ke=-st,Se=Je,$e=Math.sqrt(D)):(ke=Je,Se=st,$e=Math.sqrt(D/2))}return new te(ke/$e,Se/$e)}const Y=[];for(let W=0,Ne=O.length,ye=Ne-1,ke=W+1;W<Ne;W++,ye++,ke++)ye===Ne&&(ye=0),ke===Ne&&(ke=0),Y[W]=G(O[W],O[ye],O[ke]);const $=[];let re,ce=Y.concat();for(let W=0,Ne=R.length;W<Ne;W++){const ye=R[W];re=[];for(let ke=0,Se=ye.length,$e=Se-1,Je=ke+1;ke<Se;ke++,$e++,Je++)$e===Se&&($e=0),Je===Se&&(Je=0),re[ke]=G(ye[ke],ye[$e],ye[Je]);$.push(re),ce=ce.concat(re)}for(let W=0;W<v;W++){const Ne=W/v,ye=p*Math.cos(Ne*Math.PI/2),ke=m*Math.sin(Ne*Math.PI/2)+A;for(let Se=0,$e=O.length;Se<$e;Se++){const Je=V(O[Se],Y[Se],ke);Ve(Je.x,Je.y,-ye)}for(let Se=0,$e=R.length;Se<$e;Se++){const Je=R[Se];re=$[Se];for(let st=0,Bt=Je.length;st<Bt;st++){const N=V(Je[st],re[st],ke);Ve(N.x,N.y,-ye)}}}const Re=m+A;for(let W=0;W<L;W++){const Ne=f?V(S[W],ce[W],Re):S[W];b?(T.copy(E.normals[0]).multiplyScalar(Ne.x),M.copy(E.binormals[0]).multiplyScalar(Ne.y),C.copy(y[0]).add(T).add(M),Ve(C.x,C.y,C.z)):Ve(Ne.x,Ne.y,0)}for(let W=1;W<=u;W++)for(let Ne=0;Ne<L;Ne++){const ye=f?V(S[Ne],ce[Ne],Re):S[Ne];b?(T.copy(E.normals[W]).multiplyScalar(ye.x),M.copy(E.binormals[W]).multiplyScalar(ye.y),C.copy(y[W]).add(T).add(M),Ve(C.x,C.y,C.z)):Ve(ye.x,ye.y,d/u*W)}for(let W=v-1;W>=0;W--){const Ne=W/v,ye=p*Math.cos(Ne*Math.PI/2),ke=m*Math.sin(Ne*Math.PI/2)+A;for(let Se=0,$e=O.length;Se<$e;Se++){const Je=V(O[Se],Y[Se],ke);Ve(Je.x,Je.y,d+ye)}for(let Se=0,$e=R.length;Se<$e;Se++){const Je=R[Se];re=$[Se];for(let st=0,Bt=Je.length;st<Bt;st++){const N=V(Je[st],re[st],ke);b?Ve(N.x,N.y+y[u-1].y,y[u-1].x+ye):Ve(N.x,N.y,d+ye)}}}ie(),me();function ie(){const W=n.length/3;if(f){let Ne=0,ye=L*Ne;for(let ke=0;ke<k;ke++){const Se=z[ke];je(Se[2]+ye,Se[1]+ye,Se[0]+ye)}Ne=u+v*2,ye=L*Ne;for(let ke=0;ke<k;ke++){const Se=z[ke];je(Se[0]+ye,Se[1]+ye,Se[2]+ye)}}else{for(let Ne=0;Ne<k;Ne++){const ye=z[Ne];je(ye[2],ye[1],ye[0])}for(let Ne=0;Ne<k;Ne++){const ye=z[Ne];je(ye[0]+L*u,ye[1]+L*u,ye[2]+L*u)}}i.addGroup(W,n.length/3-W,0)}function me(){const W=n.length/3;let Ne=0;be(O,Ne),Ne+=O.length;for(let ye=0,ke=R.length;ye<ke;ye++){const Se=R[ye];be(Se,Ne),Ne+=Se.length}i.addGroup(W,n.length/3-W,1)}function be(W,Ne){let ye=W.length;for(;--ye>=0;){const ke=ye;let Se=ye-1;Se<0&&(Se=W.length-1);for(let $e=0,Je=u+v*2;$e<Je;$e++){const st=L*$e,Bt=L*($e+1),N=Ne+ke+st,D=Ne+Se+st,fe=Ne+Se+Bt,ve=Ne+ke+Bt;Ge(N,D,fe,ve)}}}function Ve(W,Ne,ye){l.push(W),l.push(Ne),l.push(ye)}function je(W,Ne,ye){dt(W),dt(Ne),dt(ye);const ke=n.length/3,Se=_.generateTopUV(i,n,ke-3,ke-2,ke-1);tt(Se[0]),tt(Se[1]),tt(Se[2])}function Ge(W,Ne,ye,ke){dt(W),dt(Ne),dt(ke),dt(Ne),dt(ye),dt(ke);const Se=n.length/3,$e=_.generateSideWallUV(i,n,Se-6,Se-3,Se-2,Se-1);tt($e[0]),tt($e[1]),tt($e[3]),tt($e[1]),tt($e[2]),tt($e[3])}function dt(W){n.push(l[W*3+0]),n.push(l[W*3+1]),n.push(l[W*3+2])}function tt(W){r.push(W.x),r.push(W.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return zj(t,i,e)}static fromJSON(e,t){const i=[];for(let r=0,o=e.shapes.length;r<o;r++){const a=t[e.shapes[r]];i.push(a)}const n=e.options.extrudePath;return n!==void 0&&(e.options.extrudePath=new tb[n.type]().fromJSON(n)),new yx(i,e.options)}}const Nj={generateTopUV:function(s,e,t,i,n){const r=e[t*3],o=e[t*3+1],a=e[i*3],l=e[i*3+1],c=e[n*3],u=e[n*3+1];return[new te(r,o),new te(a,l),new te(c,u)]},generateSideWallUV:function(s,e,t,i,n,r){const o=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],d=e[i*3+2],f=e[n*3],p=e[n*3+1],m=e[n*3+2],A=e[r*3],v=e[r*3+1],g=e[r*3+2];return Math.abs(a-u)<Math.abs(o-c)?[new te(o,1-l),new te(c,1-d),new te(f,1-m),new te(A,1-g)]:[new te(a,1-l),new te(u,1-d),new te(p,1-m),new te(v,1-g)]}};function zj(s,e,t){if(t.shapes=[],Array.isArray(s))for(let i=0,n=s.length;i<n;i++){const r=s[i];t.shapes.push(r.uuid)}else t.shapes.push(s.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class _x extends Fh{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,n=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],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];super(n,r,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new _x(e.radius,e.detail)}}class nc extends Fh{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],n=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,n,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new nc(e.radius,e.detail)}}class sd extends wt{constructor(e=.5,t=1,i=32,n=1,r=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:n,thetaStart:r,thetaLength:o},i=Math.max(3,i),n=Math.max(1,n);const a=[],l=[],c=[],u=[];let d=e;const f=(t-e)/n,p=new w,m=new te;for(let A=0;A<=n;A++){for(let v=0;v<=i;v++){const g=r+v/i*o;p.x=d*Math.cos(g),p.y=d*Math.sin(g),l.push(p.x,p.y,p.z),c.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,u.push(m.x,m.y)}d+=f}for(let A=0;A<n;A++){const v=A*(i+1);for(let g=0;g<i;g++){const _=g+v,y=_,b=_+i+1,E=_+i+2,M=_+1;a.push(y,b,M),a.push(b,E,M)}}this.setIndex(a),this.setAttribute("position",new ut(l,3)),this.setAttribute("normal",new ut(c,3)),this.setAttribute("uv",new ut(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new sd(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class bx extends wt{constructor(e=new Qu([new te(0,.5),new te(-.5,-.5),new te(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],n=[],r=[],o=[];let a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(a,l,u),a+=l,l=0;this.setIndex(i),this.setAttribute("position",new ut(n,3)),this.setAttribute("normal",new ut(r,3)),this.setAttribute("uv",new ut(o,2));function c(u){const d=n.length/3,f=u.extractPoints(t);let p=f.shape;const m=f.holes;ol.isClockWise(p)===!1&&(p=p.reverse());for(let v=0,g=m.length;v<g;v++){const _=m[v];ol.isClockWise(_)===!0&&(m[v]=_.reverse())}const A=ol.triangulateShape(p,m);for(let v=0,g=m.length;v<g;v++){const _=m[v];p=p.concat(_)}for(let v=0,g=p.length;v<g;v++){const _=p[v];n.push(_.x,_.y,0),r.push(0,0,1),o.push(_.x,_.y)}for(let v=0,g=A.length;v<g;v++){const _=A[v],y=_[0]+d,b=_[1]+d,E=_[2]+d;i.push(y,b,E),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return Gj(t,e)}static fromJSON(e,t){const i=[];for(let n=0,r=e.shapes.length;n<r;n++){const o=t[e.shapes[n]];i.push(o)}return new bx(i,e.curveSegments)}}function Gj(s,e){if(e.shapes=[],Array.isArray(s))for(let t=0,i=s.length;t<i;t++){const n=s[t];e.shapes.push(n.uuid)}else e.shapes.push(s.uuid);return e}class Sa extends wt{constructor(e=1,t=32,i=16,n=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:r,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(o+a,Math.PI);let c=0;const u=[],d=new w,f=new w,p=[],m=[],A=[],v=[];for(let g=0;g<=i;g++){const _=[],y=g/i;let b=0;g===0&&o===0?b=.5/t:g===i&&l===Math.PI&&(b=-.5/t);for(let E=0;E<=t;E++){const M=E/t;d.x=-e*Math.cos(n+M*r)*Math.sin(o+y*a),d.y=e*Math.cos(o+y*a),d.z=e*Math.sin(n+M*r)*Math.sin(o+y*a),m.push(d.x,d.y,d.z),f.copy(d).normalize(),A.push(f.x,f.y,f.z),v.push(M+b,1-y),_.push(c++)}u.push(_)}for(let g=0;g<i;g++)for(let _=0;_<t;_++){const y=u[g][_+1],b=u[g][_],E=u[g+1][_],M=u[g+1][_+1];(g!==0||o>0)&&p.push(y,b,M),(g!==i-1||l<Math.PI)&&p.push(b,E,M)}this.setIndex(p),this.setAttribute("position",new ut(m,3)),this.setAttribute("normal",new ut(A,3)),this.setAttribute("uv",new ut(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Sa(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class xx extends Fh{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],n=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,n,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new xx(e.radius,e.detail)}}class Jl extends wt{constructor(e=1,t=.4,i=12,n=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:n,arc:r},i=Math.floor(i),n=Math.floor(n);const o=[],a=[],l=[],c=[],u=new w,d=new w,f=new w;for(let p=0;p<=i;p++)for(let m=0;m<=n;m++){const A=m/n*r,v=p/i*Math.PI*2;d.x=(e+t*Math.cos(v))*Math.cos(A),d.y=(e+t*Math.cos(v))*Math.sin(A),d.z=t*Math.sin(v),a.push(d.x,d.y,d.z),u.x=e*Math.cos(A),u.y=e*Math.sin(A),f.subVectors(d,u).normalize(),l.push(f.x,f.y,f.z),c.push(m/n),c.push(p/i)}for(let p=1;p<=i;p++)for(let m=1;m<=n;m++){const A=(n+1)*p+m-1,v=(n+1)*(p-1)+m-1,g=(n+1)*(p-1)+m,_=(n+1)*p+m;o.push(A,v,_),o.push(v,g,_)}this.setIndex(o),this.setAttribute("position",new ut(a,3)),this.setAttribute("normal",new ut(l,3)),this.setAttribute("uv",new ut(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jl(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class wx extends wt{constructor(e=1,t=.4,i=64,n=8,r=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:n,p:r,q:o},i=Math.floor(i),n=Math.floor(n);const a=[],l=[],c=[],u=[],d=new w,f=new w,p=new w,m=new w,A=new w,v=new w,g=new w;for(let y=0;y<=i;++y){const b=y/i*r*Math.PI*2;_(b,r,o,e,p),_(b+.01,r,o,e,m),v.subVectors(m,p),g.addVectors(m,p),A.crossVectors(v,g),g.crossVectors(A,v),A.normalize(),g.normalize();for(let E=0;E<=n;++E){const M=E/n*Math.PI*2,T=-t*Math.cos(M),C=t*Math.sin(M);d.x=p.x+(T*g.x+C*A.x),d.y=p.y+(T*g.y+C*A.y),d.z=p.z+(T*g.z+C*A.z),l.push(d.x,d.y,d.z),f.subVectors(d,p).normalize(),c.push(f.x,f.y,f.z),u.push(y/i),u.push(E/n)}}for(let y=1;y<=i;y++)for(let b=1;b<=n;b++){const E=(n+1)*(y-1)+(b-1),M=(n+1)*y+(b-1),T=(n+1)*y+b,C=(n+1)*(y-1)+b;a.push(E,M,C),a.push(M,T,C)}this.setIndex(a),this.setAttribute("position",new ut(l,3)),this.setAttribute("normal",new ut(c,3)),this.setAttribute("uv",new ut(u,2));function _(y,b,E,M,T){const C=Math.cos(y),B=Math.sin(y),S=E/b*y,R=Math.cos(S);T.x=M*(2+R)*.5*C,T.y=M*(2+R)*B*.5,T.z=M*Math.sin(S)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wx(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Sx extends wt{constructor(e=new ET(new w(-1,-1,0),new w(-1,1,0),new w(1,1,0)),t=64,i=1,n=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:n,closed:r};const o=e.computeFrenetFrames(t,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new w,l=new w,c=new te;let u=new w;const d=[],f=[],p=[],m=[];A(),this.setIndex(m),this.setAttribute("position",new ut(d,3)),this.setAttribute("normal",new ut(f,3)),this.setAttribute("uv",new ut(p,2));function A(){for(let y=0;y<t;y++)v(y);v(r===!1?t:0),_(),g()}function v(y){u=e.getPointAt(y/t,u);const b=o.normals[y],E=o.binormals[y];for(let M=0;M<=n;M++){const T=M/n*Math.PI*2,C=Math.sin(T),B=-Math.cos(T);l.x=B*b.x+C*E.x,l.y=B*b.y+C*E.y,l.z=B*b.z+C*E.z,l.normalize(),f.push(l.x,l.y,l.z),a.x=u.x+i*l.x,a.y=u.y+i*l.y,a.z=u.z+i*l.z,d.push(a.x,a.y,a.z)}}function g(){for(let y=1;y<=t;y++)for(let b=1;b<=n;b++){const E=(n+1)*(y-1)+(b-1),M=(n+1)*y+(b-1),T=(n+1)*y+b,C=(n+1)*(y-1)+b;m.push(E,M,C),m.push(M,T,C)}}function _(){for(let y=0;y<=t;y++)for(let b=0;b<=n;b++)c.x=y/t,c.y=b/n,p.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new Sx(new tb[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class IT extends wt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,n=new w,r=new w;if(e.index!==null){const o=e.attributes.position,a=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:a.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const d=l[c],f=d.start,p=d.count;for(let m=f,A=f+p;m<A;m+=3)for(let v=0;v<3;v++){const g=a.getX(m+v),_=a.getX(m+(v+1)%3);n.fromBufferAttribute(o,g),r.fromBufferAttribute(o,_),QB(n,r,i)===!0&&(t.push(n.x,n.y,n.z),t.push(r.x,r.y,r.z))}}}else{const o=e.attributes.position;for(let a=0,l=o.count/3;a<l;a++)for(let c=0;c<3;c++){const u=3*a+c,d=3*a+(c+1)%3;n.fromBufferAttribute(o,u),r.fromBufferAttribute(o,d),QB(n,r,i)===!0&&(t.push(n.x,n.y,n.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new ut(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function QB(s,e,t){const i=`${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`,n=`${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`;return t.has(i)===!0||t.has(n)===!0?!1:(t.add(i),t.add(n),!0)}var VB=Object.freeze({__proto__:null,BoxGeometry:Li,CapsuleGeometry:px,CircleGeometry:mx,ConeGeometry:gx,CylinderGeometry:Sn,DodecahedronGeometry:vx,EdgesGeometry:TT,ExtrudeGeometry:yx,IcosahedronGeometry:_x,LatheGeometry:Kv,OctahedronGeometry:nc,PlaneGeometry:zn,PolyhedronGeometry:Fh,RingGeometry:sd,ShapeGeometry:bx,SphereGeometry:Sa,TetrahedronGeometry:xx,TorusGeometry:Jl,TorusKnotGeometry:wx,TubeGeometry:Sx,WireframeGeometry:IT});class Cx extends Nt{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new xe(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Zv extends Pt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class zr extends Nt{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new xe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kh,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Gi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(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.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class mo extends zr{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new te(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return An(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new xe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new xe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new xe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class jF extends Nt{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new xe(16777215),this.specular=new xe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kh,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Gi,this.combine=Qv,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(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.envMapRotation.copy(e.envMapRotation),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.flatShading=e.flatShading,this.fog=e.fog,this}}class WF extends Nt{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new xe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kh,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,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.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Ex extends Nt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kh,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(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.flatShading=e.flatShading,this}}class qF extends Nt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kh,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Gi,this.combine=Qv,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(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.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.envMapRotation.copy(e.envMapRotation),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.flatShading=e.flatShading,this.fog=e.fog,this}}class XF extends Nt{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new xe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kh,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(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.flatShading=e.flatShading,this.fog=e.fog,this}}class YF extends Rn{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function ku(s,e,t){return!s||!t&&s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function JF(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function KF(s){function e(n,r){return s[n]-s[r]}const t=s.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i}function h1(s,e,t){const i=s.length,n=new s.constructor(i);for(let r=0,o=0;o!==i;++r){const a=t[r]*e;for(let l=0;l!==e;++l)n[o++]=s[a+l]}return n}function RT(s,e,t,i){let n=1,r=s[0];for(;r!==void 0&&r[i]===void 0;)r=s[n++];if(r===void 0)return;let o=r[i];if(o!==void 0)if(Array.isArray(o))do o=r[i],o!==void 0&&(e.push(r.time),t.push.apply(t,o)),r=s[n++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[i],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=s[n++];while(r!==void 0);else do o=r[i],o!==void 0&&(e.push(r.time),t.push(o)),r=s[n++];while(r!==void 0)}function Hj(s,e,t,i,n=30){const r=s.clone();r.name=e;const o=[];for(let l=0;l<r.tracks.length;++l){const c=r.tracks[l],u=c.getValueSize(),d=[],f=[];for(let p=0;p<c.times.length;++p){const m=c.times[p]*n;if(!(m<t||m>=i)){d.push(c.times[p]);for(let A=0;A<u;++A)f.push(c.values[p*u+A])}}d.length!==0&&(c.times=ku(d,c.times.constructor),c.values=ku(f,c.values.constructor),o.push(c))}r.tracks=o;let a=1/0;for(let l=0;l<r.tracks.length;++l)a>r.tracks[l].times[0]&&(a=r.tracks[l].times[0]);for(let l=0;l<r.tracks.length;++l)r.tracks[l].shift(-1*a);return r.resetDuration(),r}function Qj(s,e=0,t=s,i=30){i<=0&&(i=30);const n=t.tracks.length,r=e/i;for(let o=0;o<n;++o){const a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;const c=s.tracks.find(function(g){return g.name===a.name&&g.ValueTypeName===l});if(c===void 0)continue;let u=0;const d=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=d/3);let f=0;const p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=p/3);const m=a.times.length-1;let A;if(r<=a.times[0]){const g=u,_=d-u;A=a.values.slice(g,_)}else if(r>=a.times[m]){const g=m*d+u,_=g+d-u;A=a.values.slice(g,_)}else{const g=a.createInterpolant(),_=u,y=d-u;g.evaluate(r),A=g.resultBuffer.slice(_,y)}l==="quaternion"&&new Ce().fromArray(A).normalize().conjugate().toArray(A);const v=c.times.length;for(let g=0;g<v;++g){const _=g*p+f;if(l==="quaternion")Ce.multiplyQuaternionsFlat(c.values,_,A,0,c.values,_);else{const y=p-f*2;for(let b=0;b<y;++b)c.values[_+b]-=A[b]}}}return s.blendMode=rT,s}const Vj={convertArray:ku,isTypedArray:JF,getKeyframeOrder:KF,sortedArray:h1,flattenJSON:RT,subclip:Hj,makeClipAdditive:Qj};class Bp{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],r=t[i-1];e:{t:{let o;i:{n:if(!(e<n)){for(let a=i+2;;){if(n===void 0){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(r=n,n=t[++i],e<n)break t}o=t.length;break i}if(!(e>=r)){const a=t[1];e<a&&(i=2,r=a);for(let l=i-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(n=r,r=t[--i-1],e>=r)break t}o=i,i=0;break i}break e}for(;i<o;){const a=i+o>>>1;e<t[a]?o=a:i=a+1}if(n=t[i],r=t[i-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let o=0;o!==n;++o)t[o]=i[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class ZF extends Bp{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Du,endingEnd:Du}}intervalChanged_(e,t,i){const n=this.parameterPositions;let r=e-2,o=e+1,a=n[r],l=n[o];if(a===void 0)switch(this.getSettings_().endingStart){case Ou:r=e,a=2*t-i;break;case ev:r=n.length-2,a=t+n[r]-n[r+1];break;default:r=e,a=i}if(l===void 0)switch(this.getSettings_().endingEnd){case Ou:o=e,l=2*i-t;break;case ev:o=1,l=i+n[1]-n[0];break;default:o=e-1,l=t}const c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-i),this._offsetPrev=r*u,this._offsetNext=o*u}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this._offsetPrev,d=this._offsetNext,f=this._weightPrev,p=this._weightNext,m=(i-t)/(n-t),A=m*m,v=A*m,g=-f*v+2*f*A-f*m,_=(1+f)*v+(-1.5-2*f)*A+(-.5+f)*m+1,y=(-1-p)*v+(1.5+p)*A+.5*m,b=p*v-p*A;for(let E=0;E!==a;++E)r[E]=g*o[u+E]+_*o[c+E]+y*o[l+E]+b*o[d+E];return r}}class PT extends Bp{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=(i-t)/(n-t),d=1-u;for(let f=0;f!==a;++f)r[f]=o[c+f]*d+o[l+f]*u;return r}}class $F extends Bp{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class Ca{constructor(e,t,i,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=ku(t,this.TimeBufferType),this.values=ku(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:ku(e.times,Array),values:ku(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new $F(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new PT(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ZF(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Th:t=this.InterpolantFactoryMethodDiscrete;break;case dl:t=this.InterpolantFactoryMethodLinear;break;case l_:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Th;case this.InterpolantFactoryMethodLinear:return dl;case this.InterpolantFactoryMethodSmooth:return l_}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let r=0,o=n-1;for(;r!==n&&i[r]<e;)++r;for(;o!==-1&&i[o]>t;)--o;if(++o,r!==0||o!==n){r>=o&&(o=Math.max(o,1),r=o-1);const a=this.getValueSize();this.times=i.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){const l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(n!==void 0&&JF(n))for(let a=0,l=n.length;a!==l;++a){const c=n[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===l_,r=e.length-1;let o=1;for(let a=1;a<r;++a){let l=!1;const c=e[a],u=e[a+1];if(c!==u&&(a!==1||c!==e[0]))if(n)l=!0;else{const d=a*i,f=d-i,p=d+i;for(let m=0;m!==i;++m){const A=t[d+m];if(A!==t[f+m]||A!==t[p+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];const d=a*i,f=o*i;for(let p=0;p!==i;++p)t[f+p]=t[d+p]}++o}}if(r>0){e[o]=e[r];for(let a=r*i,l=o*i,c=0;c!==i;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Ca.prototype.TimeBufferType=Float32Array;Ca.prototype.ValueBufferType=Float32Array;Ca.prototype.DefaultInterpolation=dl;class dd extends Ca{}dd.prototype.ValueTypeName="bool";dd.prototype.ValueBufferType=Array;dd.prototype.DefaultInterpolation=Th;dd.prototype.InterpolantFactoryMethodLinear=void 0;dd.prototype.InterpolantFactoryMethodSmooth=void 0;class Mx extends Ca{}Mx.prototype.ValueTypeName="color";class Ih extends Ca{}Ih.prototype.ValueTypeName="number";class eU extends Bp{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(i-t)/(n-t);let c=e*a;for(let u=c+a;c!==u;c+=4)Ce.slerpFlat(r,0,o,c-a,o,c,l);return r}}class fl extends Ca{InterpolantFactoryMethodLinear(e){return new eU(this.times,this.values,this.getValueSize(),e)}}fl.prototype.ValueTypeName="quaternion";fl.prototype.DefaultInterpolation=dl;fl.prototype.InterpolantFactoryMethodSmooth=void 0;class fd extends Ca{}fd.prototype.ValueTypeName="string";fd.prototype.ValueBufferType=Array;fd.prototype.DefaultInterpolation=Th;fd.prototype.InterpolantFactoryMethodLinear=void 0;fd.prototype.InterpolantFactoryMethodSmooth=void 0;class mc extends Ca{}mc.prototype.ValueTypeName="vector";class Sr{constructor(e,t=-1,i,n=sx){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=uo(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(Wj(i[o]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=i.length;r!==o;++r)t.push(Ca.toJSON(i[r]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,o=[];for(let a=0;a<r;a++){let l=[],c=[];l.push((a+r-1)%r,a,(a+1)%r),c.push(0,1,0);const u=KF(l);l=h1(l,1,u),c=h1(c,1,u),!n&&l[0]===0&&(l.push(r),c.push(c[0])),o.push(new Ih(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const n=e;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===t)return i[n];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){const c=e[a],u=c.name.match(r);if(u&&u.length>1){const d=u[1];let f=n[d];f||(n[d]=f=[]),f.push(c)}}const o=[];for(const a in n)o.push(this.CreateFromMorphTargetSequence(a,n[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(d,f,p,m,A){if(p.length!==0){const v=[],g=[];RT(p,v,g,m),v.length!==0&&A.push(new d(f,v,g))}},n=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let d=0;d<c.length;d++){const f=c[d].keys;if(!(!f||f.length===0))if(f[0].morphTargets){const p={};let m;for(m=0;m<f.length;m++)if(f[m].morphTargets)for(let A=0;A<f[m].morphTargets.length;A++)p[f[m].morphTargets[A]]=-1;for(const A in p){const v=[],g=[];for(let _=0;_!==f[m].morphTargets.length;++_){const y=f[m];v.push(y.time),g.push(y.morphTarget===A?1:0)}n.push(new Ih(".morphTargetInfluence["+A+"]",v,g))}l=p.length*o}else{const p=".bones["+t[d].name+"]";i(mc,p+".position",f,"pos",n),i(fl,p+".quaternion",f,"rot",n),i(mc,p+".scale",f,"scl",n)}}return n.length===0?null:new this(r,l,n,a)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,n=e.length;i!==n;++i){const r=this.tracks[i];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function jj(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ih;case"vector":case"vector2":case"vector3":case"vector4":return mc;case"color":return Mx;case"quaternion":return fl;case"bool":case"boolean":return dd;case"string":return fd}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function Wj(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=jj(s.type);if(s.times===void 0){const t=[],i=[];RT(s.keys,t,i,"value"),s.times=t,s.values=i}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const sc={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(this.files[s]=e)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};class Tx{constructor(e,t,i){const n=this;let r=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,r===!1&&n.onStart!==void 0&&n.onStart(u,o,a),r=!0},this.itemEnd=function(u){o++,n.onProgress!==void 0&&n.onProgress(u,o,a),o===a&&(r=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(u){n.onError!==void 0&&n.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,d){return c.push(u,d),this},this.removeHandler=function(u){const d=c.indexOf(u);return d!==-1&&c.splice(d,2),this},this.getHandler=function(u){for(let d=0,f=c.length;d<f;d+=2){const p=c[d],m=c[d+1];if(p.global&&(p.lastIndex=0),p.test(u))return m}return null}}}const tU=new Tx;class ks{constructor(e){this.manager=e!==void 0?e:tU,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(n,r){i.load(e,n,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}ks.DEFAULT_MATERIAL_NAME="__DEFAULT";const Rl={};class qj extends Error{constructor(e,t){super(e),this.response=t}}class Kn extends ks{constructor(e){super(e)}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=sc.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(Rl[e]!==void 0){Rl[e].push({onLoad:t,onProgress:i,onError:n});return}Rl[e]=[],Rl[e].push({onLoad:t,onProgress:i,onError:n});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=Rl[e],d=c.body.getReader(),f=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),p=f?parseInt(f):0,m=p!==0;let A=0;const v=new ReadableStream({start(g){_();function _(){d.read().then(({done:y,value:b})=>{if(y)g.close();else{A+=b.byteLength;const E=new ProgressEvent("progress",{lengthComputable:m,loaded:A,total:p});for(let M=0,T=u.length;M<T;M++){const C=u[M];C.onProgress&&C.onProgress(E)}g.enqueue(b),_()}})}}});return new Response(v)}else throw new qj(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(a),f=d&&d[1]?d[1].toLowerCase():void 0,p=new TextDecoder(f);return c.arrayBuffer().then(m=>p.decode(m))}}}).then(c=>{sc.add(e,c);const u=Rl[e];delete Rl[e];for(let d=0,f=u.length;d<f;d++){const p=u[d];p.onLoad&&p.onLoad(c)}}).catch(c=>{const u=Rl[e];if(u===void 0)throw this.manager.itemError(e),c;delete Rl[e];for(let d=0,f=u.length;d<f;d++){const p=u[d];p.onError&&p.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Xj extends ks{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Kn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(l){n?n(l):console.error(l),r.manager.itemError(e)}},i,n)}parse(e){const t=[];for(let i=0;i<e.length;i++){const n=Sr.parse(e[i]);t.push(n)}return t}}class Yj extends ks{constructor(e){super(e)}load(e,t,i,n){const r=this,o=[],a=new rl,l=new Kn(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(r.withCredentials);let c=0;function u(d){l.load(e[d],function(f){const p=r.parse(f,!0);o[d]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},c+=1,c===6&&(p.mipmapCount===1&&(a.minFilter=Mt),a.image=o,a.format=p.format,a.needsUpdate=!0,t&&t(a))},i,n)}if(Array.isArray(e))for(let d=0,f=e.length;d<f;++d)u(d);else l.load(e,function(d){const f=r.parse(d,!0);if(f.isCubemap){const p=f.mipmaps.length/f.mipmapCount;for(let m=0;m<p;m++){o[m]={mipmaps:[]};for(let A=0;A<f.mipmapCount;A++)o[m].mipmaps.push(f.mipmaps[m*f.mipmapCount+A]),o[m].format=f.format,o[m].width=f.width,o[m].height=f.height}a.image=o}else a.image.width=f.width,a.image.height=f.height,a.mipmaps=f.mipmaps;f.mipmapCount===1&&(a.minFilter=Mt),a.format=f.format,a.needsUpdate=!0,t&&t(a)},i,n);return a}}class uv extends ks{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=sc.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const a=ov("img");function l(){u(),sc.add(e,this),t&&t(this),r.manager.itemEnd(e)}function c(d){u(),n&&n(d),r.manager.itemError(e),r.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class Jj extends ks{constructor(e){super(e)}load(e,t,i,n){const r=new Wv;r.colorSpace=gt;const o=new uv(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(e[c],function(u){r.images[c]=u,a++,a===6&&(r.needsUpdate=!0,t&&t(r))},void 0,n)}for(let c=0;c<e.length;++c)l(c);return r}}class BT extends ks{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Nr,a=new Kn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(e,function(l){let c;try{c=r.parse(l)}catch(u){if(n!==void 0)n(u);else{console.error(u);return}}c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:us,o.wrapT=c.wrapT!==void 0?c.wrapT:us,o.magFilter=c.magFilter!==void 0?c.magFilter:Mt,o.minFilter=c.minFilter!==void 0?c.minFilter:Mt,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(o.colorSpace=c.colorSpace),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=br),c.mipmapCount===1&&(o.minFilter=Mt),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c)},i,n),o}}class al extends ks{constructor(e){super(e)}load(e,t,i,n){const r=new Dt,o=new uv(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},i,n),r}}let Uh=class extends ge{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new xe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}};class DT extends Uh{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ge.DEFAULT_UP),this.updateMatrix(),this.groundColor=new xe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const LS=new we,jB=new w,WB=new w;class OT{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new te(512,512),this.map=null,this.mapPass=null,this.matrix=new we,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new qv,this._frameExtents=new te(1,1),this._viewportCount=1,this._viewports=[new Ze(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;jB.setFromMatrixPosition(e.matrixWorld),t.position.copy(jB),WB.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(WB),t.updateMatrixWorld(),LS.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(LS),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(LS)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Kj extends OT{constructor(){super(new Qt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=fp*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(i!==t.fov||n!==t.aspect||r!==t.far)&&(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Ix extends Uh{constructor(e,t,i=0,n=Math.PI/3,r=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ge.DEFAULT_UP),this.updateMatrix(),this.target=new ge,this.distance=i,this.angle=n,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new Kj}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const qB=new we,wm=new w,kS=new w;class Zj extends OT{constructor(){super(new Qt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new te(4,2),this._viewportCount=6,this._viewports=[new Ze(2,1,1,1),new Ze(0,1,1,1),new Ze(3,1,1,1),new Ze(1,1,1,1),new Ze(3,0,1,1),new Ze(1,0,1,1)],this._cubeDirections=[new w(1,0,0),new w(-1,0,0),new w(0,0,1),new w(0,0,-1),new w(0,1,0),new w(0,-1,0)],this._cubeUps=[new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,0,1),new w(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,n=this.matrix,r=e.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),wm.setFromMatrixPosition(e.matrixWorld),i.position.copy(wm),kS.copy(i.position),kS.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(kS),i.updateMatrixWorld(),n.makeTranslation(-wm.x,-wm.y,-wm.z),qB.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(qB)}}class $v extends Uh{constructor(e,t,i=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new Zj}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class $j extends OT{constructor(){super(new yc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class mp extends Uh{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ge.DEFAULT_UP),this.updateMatrix(),this.target=new ge,this.shadow=new $j}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class LT extends Uh{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class iU extends Uh{constructor(e,t,i=10,n=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=n}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class nU{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new w)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,n=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*n),t.addScaledVector(o[2],.488603*r),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*n)),t.addScaledVector(o[5],1.092548*(n*r)),t.addScaledVector(o[6],.315392*(3*r*r-1)),t.addScaledVector(o[7],1.092548*(i*r)),t.addScaledVector(o[8],.546274*(i*i-n*n)),t}getIrradianceAt(e,t){const i=e.x,n=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*n),t.addScaledVector(o[2],2*.511664*r),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*n),t.addScaledVector(o[5],2*.429043*n*r),t.addScaledVector(o[6],.743125*r*r-.247708),t.addScaledVector(o[7],2*.429043*i*r),t.addScaledVector(o[8],.429043*(i*i-n*n)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(e,t+n*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(e,t+n*3);return e}static getBasisAt(e,t){const i=e.x,n=e.y,r=e.z;t[0]=.282095,t[1]=.488603*n,t[2]=.488603*r,t[3]=.488603*i,t[4]=1.092548*i*n,t[5]=1.092548*n*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*i*r,t[8]=.546274*(i*i-n*n)}}class sU extends Uh{constructor(e=new nU,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Rx extends ks{constructor(e){super(e),this.textures={}}load(e,t,i,n){const r=this,o=new Kn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(l){n?n(l):console.error(l),r.manager.itemError(e)}},i,n)}parse(e){const t=this.textures;function i(r){return t[r]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",r),t[r]}const n=Rx.createMaterialFromType(e.type);if(e.uuid!==void 0&&(n.uuid=e.uuid),e.name!==void 0&&(n.name=e.name),e.color!==void 0&&n.color!==void 0&&n.color.setHex(e.color),e.roughness!==void 0&&(n.roughness=e.roughness),e.metalness!==void 0&&(n.metalness=e.metalness),e.sheen!==void 0&&(n.sheen=e.sheen),e.sheenColor!==void 0&&(n.sheenColor=new xe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(n.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&n.emissive!==void 0&&n.emissive.setHex(e.emissive),e.specular!==void 0&&n.specular!==void 0&&n.specular.setHex(e.specular),e.specularIntensity!==void 0&&(n.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&n.specularColor!==void 0&&n.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(n.shininess=e.shininess),e.clearcoat!==void 0&&(n.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=e.clearcoatRoughness),e.iridescence!==void 0&&(n.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(n.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(n.transmission=e.transmission),e.thickness!==void 0&&(n.thickness=e.thickness),e.attenuationDistance!==void 0&&(n.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&n.attenuationColor!==void 0&&n.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(n.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(n.fog=e.fog),e.flatShading!==void 0&&(n.flatShading=e.flatShading),e.blending!==void 0&&(n.blending=e.blending),e.combine!==void 0&&(n.combine=e.combine),e.side!==void 0&&(n.side=e.side),e.shadowSide!==void 0&&(n.shadowSide=e.shadowSide),e.opacity!==void 0&&(n.opacity=e.opacity),e.transparent!==void 0&&(n.transparent=e.transparent),e.alphaTest!==void 0&&(n.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(n.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(n.depthFunc=e.depthFunc),e.depthTest!==void 0&&(n.depthTest=e.depthTest),e.depthWrite!==void 0&&(n.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(n.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(n.blendSrc=e.blendSrc),e.blendDst!==void 0&&(n.blendDst=e.blendDst),e.blendEquation!==void 0&&(n.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(n.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(n.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(n.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&n.blendColor!==void 0&&n.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(n.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(n.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(n.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(n.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(n.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(n.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(n.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(n.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(n.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(n.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(n.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(n.rotation=e.rotation),e.linewidth!==void 0&&(n.linewidth=e.linewidth),e.dashSize!==void 0&&(n.dashSize=e.dashSize),e.gapSize!==void 0&&(n.gapSize=e.gapSize),e.scale!==void 0&&(n.scale=e.scale),e.polygonOffset!==void 0&&(n.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(n.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(n.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(n.dithering=e.dithering),e.alphaToCoverage!==void 0&&(n.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(n.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(n.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(n.visible=e.visible),e.toneMapped!==void 0&&(n.toneMapped=e.toneMapped),e.userData!==void 0&&(n.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?n.vertexColors=e.vertexColors>0:n.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const r in e.uniforms){const o=e.uniforms[r];switch(n.uniforms[r]={},o.type){case"t":n.uniforms[r].value=i(o.value);break;case"c":n.uniforms[r].value=new xe().setHex(o.value);break;case"v2":n.uniforms[r].value=new te().fromArray(o.value);break;case"v3":n.uniforms[r].value=new w().fromArray(o.value);break;case"v4":n.uniforms[r].value=new Ze().fromArray(o.value);break;case"m3":n.uniforms[r].value=new Lt().fromArray(o.value);break;case"m4":n.uniforms[r].value=new we().fromArray(o.value);break;default:n.uniforms[r].value=o.value}}if(e.defines!==void 0&&(n.defines=e.defines),e.vertexShader!==void 0&&(n.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(n.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(n.glslVersion=e.glslVersion),e.extensions!==void 0)for(const r in e.extensions)n.extensions[r]=e.extensions[r];if(e.lights!==void 0&&(n.lights=e.lights),e.clipping!==void 0&&(n.clipping=e.clipping),e.size!==void 0&&(n.size=e.size),e.sizeAttenuation!==void 0&&(n.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(n.map=i(e.map)),e.matcap!==void 0&&(n.matcap=i(e.matcap)),e.alphaMap!==void 0&&(n.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(n.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(n.bumpScale=e.bumpScale),e.normalMap!==void 0&&(n.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(n.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),n.normalScale=new te().fromArray(r)}return e.displacementMap!==void 0&&(n.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(n.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(n.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(n.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(n.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(n.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(n.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(n.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(n.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(n.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(n.envMap=i(e.envMap)),e.envMapRotation!==void 0&&n.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(n.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(n.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(n.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(n.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(n.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(n.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(n.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(n.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(n.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(n.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(n.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(n.clearcoatNormalScale=new te().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(n.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(n.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(n.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(n.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(n.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(n.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(n.sheenRoughnessMap=i(e.sheenRoughnessMap)),n}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:Cx,SpriteMaterial:vT,RawShaderMaterial:Zv,ShaderMaterial:Pt,PointsMaterial:dx,MeshPhysicalMaterial:mo,MeshStandardMaterial:zr,MeshPhongMaterial:jF,MeshToonMaterial:WF,MeshNormalMaterial:Ex,MeshLambertMaterial:qF,MeshDepthMaterial:Xv,MeshDistanceMaterial:mT,MeshBasicMaterial:ai,MeshMatcapMaterial:XF,LineDashedMaterial:YF,LineBasicMaterial:Rn,Material:Nt};return new t[e]}}class Ah{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,n=e.length;i<n;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Px extends wt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class rU extends ks{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Kn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(l){n?n(l):console.error(l),r.manager.itemError(e)}},i,n)}parse(e){const t={},i={};function n(p,m){if(t[m]!==void 0)return t[m];const v=p.interleavedBuffers[m],g=r(p,v.buffer),_=Lf(v.type,g),y=new Yv(_,v.stride);return y.uuid=v.uuid,t[m]=y,y}function r(p,m){if(i[m]!==void 0)return i[m];const v=p.arrayBuffers[m],g=new Uint32Array(v).buffer;return i[m]=g,g}const o=e.isInstancedBufferGeometry?new Px:new wt,a=e.data.index;if(a!==void 0){const p=Lf(a.type,a.array);o.setIndex(new it(p,1))}const l=e.data.attributes;for(const p in l){const m=l[p];let A;if(m.isInterleavedBufferAttribute){const v=n(e.data,m.data);A=new xr(v,m.itemSize,m.offset,m.normalized)}else{const v=Lf(m.type,m.array),g=m.isInstancedBufferAttribute?Lr:it;A=new g(v,m.itemSize,m.normalized)}m.name!==void 0&&(A.name=m.name),m.usage!==void 0&&A.setUsage(m.usage),o.setAttribute(p,A)}const c=e.data.morphAttributes;if(c)for(const p in c){const m=c[p],A=[];for(let v=0,g=m.length;v<g;v++){const _=m[v];let y;if(_.isInterleavedBufferAttribute){const b=n(e.data,_.data);y=new xr(b,_.itemSize,_.offset,_.normalized)}else{const b=Lf(_.type,_.array);y=new it(b,_.itemSize,_.normalized)}_.name!==void 0&&(y.name=_.name),A.push(y)}o.morphAttributes[p]=A}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let p=0,m=d.length;p!==m;++p){const A=d[p];o.addGroup(A.start,A.count,A.materialIndex)}const f=e.data.boundingSphere;if(f!==void 0){const p=new w;f.center!==void 0&&p.fromArray(f.center),o.boundingSphere=new In(p,f.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}class eW extends ks{constructor(e){super(e)}load(e,t,i,n){const r=this,o=this.path===""?Ah.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new Kn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(d){n!==void 0&&n(d),console.error("THREE:ObjectLoader: Can't parse "+e+".",d.message);return}const u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){n!==void 0&&n(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}r.parse(c,t)},i,n)}async loadAsync(e,t){const i=this,n=this.path===""?Ah.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;const r=new Kn(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const o=await r.loadAsync(e,t),a=JSON.parse(o),l=a.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(a)}parse(e,t){const i=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),o=this.parseImages(e.images,function(){t!==void 0&&t(c)}),a=this.parseTextures(e.textures,o),l=this.parseMaterials(e.materials,a),c=this.parseObject(e.object,r,l,a,i),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),t!==void 0){let d=!1;for(const f in o)if(o[f].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),n=this.parseGeometries(e.geometries,i),r=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,r),a=this.parseMaterials(e.materials,o),l=this.parseObject(e.object,n,a,o,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,n=e.length;i<n;i++){const r=new Qu().fromJSON(e[i]);t[r.uuid]=r}return t}parseSkeletons(e,t){const i={},n={};if(t.traverse(function(r){r.isBone&&(n[r.uuid]=r)}),e!==void 0)for(let r=0,o=e.length;r<o;r++){const a=new Pp().fromJSON(e[r],n);i[a.uuid]=a}return i}parseGeometries(e,t){const i={};if(e!==void 0){const n=new rU;for(let r=0,o=e.length;r<o;r++){let a;const l=e[r];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":a=n.parse(l);break;default:l.type in VB?a=VB[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}a.uuid=l.uuid,l.name!==void 0&&(a.name=l.name),l.userData!==void 0&&(a.userData=l.userData),i[l.uuid]=a}}return i}parseMaterials(e,t){const i={},n={};if(e!==void 0){const r=new Rx;r.setTextures(t);for(let o=0,a=e.length;o<a;o++){const l=e[o];i[l.uuid]===void 0&&(i[l.uuid]=r.parse(l)),n[l.uuid]=i[l.uuid]}}return n}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const n=e[i],r=Sr.parse(n);t[r.uuid]=r}return t}parseImages(e,t){const i=this,n={};let r;function o(l){return i.manager.itemStart(l),r.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function a(l){if(typeof l=="string"){const c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return o(u)}else return l.data?{data:Lf(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new Tx(t);r=new uv(l),r.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){const d=e[c],f=d.url;if(Array.isArray(f)){const p=[];for(let m=0,A=f.length;m<A;m++){const v=f[m],g=a(v);g!==null&&(g instanceof HTMLImageElement?p.push(g):p.push(new Nr(g.data,g.width,g.height)))}n[d.uuid]=new ic(p)}else{const p=a(d.url);n[d.uuid]=new ic(p)}}}return n}async parseImagesAsync(e){const t=this,i={};let n;async function r(o){if(typeof o=="string"){const a=o,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await n.loadAsync(l)}else return o.data?{data:Lf(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){n=new uv(this.manager),n.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){const l=e[o],c=l.url;if(Array.isArray(c)){const u=[];for(let d=0,f=c.length;d<f;d++){const p=c[d],m=await r(p);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new Nr(m.data,m.width,m.height)))}i[l.uuid]=new ic(u)}else{const u=await r(l.url);i[l.uuid]=new ic(u)}}}return i}parseTextures(e,t){function i(r,o){return typeof r=="number"?r:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",r),o[r])}const n={};if(e!==void 0)for(let r=0,o=e.length;r<o;r++){const a=e[r];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);const l=t[a.image],c=l.data;let u;Array.isArray(c)?(u=new Wv,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new Nr:u=new Dt,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=i(a.mapping,tW)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=i(a.wrap[0],XB),u.wrapT=i(a.wrap[1],XB)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=i(a.minFilter,YB)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,YB)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),n[a.uuid]=u}return n}parseObject(e,t,i,n,r){let o;function a(f){return t[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",f),t[f]}function l(f){if(f!==void 0){if(Array.isArray(f)){const p=[];for(let m=0,A=f.length;m<A;m++){const v=f[m];i[v]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",v),p.push(i[v])}return p}return i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),i[f]}}function c(f){return n[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",f),n[f]}let u,d;switch(e.type){case"Scene":o=new ir,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new xe(e.background):o.background=c(e.background)),e.environment!==void 0&&(o.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new hx(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new cx(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new Qt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new yc(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new LT(e.color,e.intensity);break;case"DirectionalLight":o=new mp(e.color,e.intensity);break;case"PointLight":o=new $v(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new iU(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new Ix(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new DT(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new sU().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),d=l(e.material),o=new ga(u,d),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),d=l(e.material),o=new pe(u,d);break;case"InstancedMesh":u=a(e.geometry),d=l(e.material);const f=e.count,p=e.instanceMatrix,m=e.instanceColor;o=new ux(u,d,f),o.instanceMatrix=new Lr(new Float32Array(p.array),16),m!==void 0&&(o.instanceColor=new Lr(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=a(e.geometry),d=l(e.material),o=new DF(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,d),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(A=>{const v=new Ti;v.min.fromArray(A.boxMin),v.max.fromArray(A.boxMax);const g=new In;return g.radius=A.sphereRadius,g.center.fromArray(A.sphereCenter),{boxInitialized:A.boxInitialized,box:v,sphereInitialized:A.sphereInitialized,sphere:g}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=c(e.matricesTexture.uuid);break;case"LOD":o=new AT;break;case"Line":o=new Mn(a(e.geometry),l(e.material));break;case"LineLoop":o=new yT(a(e.geometry),l(e.material));break;case"LineSegments":o=new Ao(a(e.geometry),l(e.material));break;case"PointCloud":case"Points":o=new _T(a(e.geometry),l(e.material));break;case"Sprite":o=new BF(l(e.material));break;case"Group":o=new kr;break;case"Bone":o=new Jv;break;default:o=new ge}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const f=e.children;for(let p=0;p<f.length;p++)o.add(this.parseObject(f[p],t,i,n,r))}if(e.animations!==void 0){const f=e.animations;for(let p=0;p<f.length;p++){const m=f[p];o.animations.push(r[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);const f=e.levels;for(let p=0;p<f.length;p++){const m=f[p],A=o.getObjectByProperty("uuid",m.object);A!==void 0&&o.addLevel(A,m.distance,m.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const n=t[i.skeleton];n===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(n,i.bindMatrix)}})}}const tW={UVMapping:ex,CubeReflectionMapping:pc,CubeRefractionMapping:Eh,EquirectangularReflectionMapping:zo,EquirectangularRefractionMapping:up,CubeUVReflectionMapping:Ep},XB={RepeatWrapping:Go,ClampToEdgeWrapping:us,MirroredRepeatWrapping:id},YB={NearestFilter:Ht,NearestMipmapNearestFilter:dp,NearestMipmapLinearFilter:Xl,LinearFilter:Mt,LinearMipmapNearestFilter:Gu,LinearMipmapLinearFilter:br};class oU extends ks{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=sc.get(e);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(c=>{t&&t(c),r.manager.itemEnd(e)}).catch(c=>{n&&n(c)});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return sc.add(e,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){n&&n(c),sc.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});sc.add(e,l),r.manager.itemStart(e)}}let Zy;class Bx{static getContext(){return Zy===void 0&&(Zy=new(window.AudioContext||window.webkitAudioContext)),Zy}static setContext(e){Zy=e}}class ib extends ks{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Kn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{const c=l.slice(0);Bx.getContext().decodeAudioData(c,function(d){t(d)}).catch(a)}catch(c){a(c)}},i,n);function a(l){n?n(l):console.error(l),r.manager.itemError(e)}}}const JB=new we,KB=new we,ou=new we;class iW{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Qt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Qt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,ou.copy(e.projectionMatrix);const n=t.eyeSep/2,r=n*t.near/t.focus,o=t.near*Math.tan(Hu*t.fov*.5)/t.zoom;let a,l;KB.elements[12]=-n,JB.elements[12]=n,a=-o*t.aspect+r,l=o*t.aspect+r,ou.elements[0]=2*t.near/(l-a),ou.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(ou),a=-o*t.aspect-r,l=o*t.aspect-r,ou.elements[0]=2*t.near/(l-a),ou.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(ou)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(KB),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(JB)}}class kT{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ZB(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=ZB();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function ZB(){return(typeof performance>"u"?Date:performance).now()}const Ia=new w,$B=new Ce,nW=new w,au=new w;let aU=class extends ge{constructor(){super(),this.type="AudioListener",this.context=Bx.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new kT}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Ia,$B,nW),!(!Number.isFinite(Ia.x)||!Number.isFinite(Ia.y)||!Number.isFinite(Ia.z)))if(au.set(0,0,-1).applyQuaternion($B),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Ia.x,n),t.positionY.linearRampToValueAtTime(Ia.y,n),t.positionZ.linearRampToValueAtTime(Ia.z,n),t.forwardX.linearRampToValueAtTime(au.x,n),t.forwardY.linearRampToValueAtTime(au.y,n),t.forwardZ.linearRampToValueAtTime(au.z,n),t.upX.linearRampToValueAtTime(i.x,n),t.upY.linearRampToValueAtTime(i.y,n),t.upZ.linearRampToValueAtTime(i.z,n)}else t.setPosition(Ia.x,Ia.y,Ia.z),t.setOrientation(au.x,au.y,au.z,i.x,i.y,i.z)}},FT=class extends ge{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}};const lu=new w,e2=new Ce,sW=new w,cu=new w;class lU extends FT{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(lu,e2,sW),cu.set(0,0,1).applyQuaternion(e2);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(lu.x,i),t.positionY.linearRampToValueAtTime(lu.y,i),t.positionZ.linearRampToValueAtTime(lu.z,i),t.orientationX.linearRampToValueAtTime(cu.x,i),t.orientationY.linearRampToValueAtTime(cu.y,i),t.orientationZ.linearRampToValueAtTime(cu.z,i)}else t.setPosition(lu.x,lu.y,lu.z),t.setOrientation(cu.x,cu.y,cu.z)}}class rW{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class cU{constructor(e,t,i){this.binding=e,this.valueSize=i;let n,r,o;switch(t){case"quaternion":n=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:n=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,n=this.valueSize,r=e*n+n;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==n;++a)i[r+a]=i[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(i,r,0,a,n)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,n=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,n=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const l=t*this._origIndex;this._mixBufferRegion(i,n,l,1-r,t)}o>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){a.setValue(i,n);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let r=i,o=n;r!==o;++r)t[r]=t[n+r%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,n,r){if(n>=.5)for(let o=0;o!==r;++o)e[t+o]=e[i+o]}_slerp(e,t,i,n){Ce.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){const o=this._workIndex*r;Ce.multiplyQuaternionsFlat(e,o,e,t,e,i),Ce.slerpFlat(e,t,e,t,e,o,n)}_lerp(e,t,i,n,r){const o=1-n;for(let a=0;a!==r;++a){const l=t+a;e[l]=e[l]*o+e[i+a]*n}}_lerpAdditive(e,t,i,n,r){for(let o=0;o!==r;++o){const a=t+o;e[a]=e[a]+e[i+o]*n}}}const UT="\\[\\]\\.:\\/",oW=new RegExp("["+UT+"]","g"),NT="[^"+UT+"]",aW="[^"+UT.replace("\\.","")+"]",lW=/((?:WC+[\/:])*)/.source.replace("WC",NT),cW=/(WCOD+)?/.source.replace("WCOD",aW),hW=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",NT),uW=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",NT),dW=new RegExp("^"+lW+cW+hW+uW+"$"),fW=["material","materials","bones","map"];class pW{constructor(e,t,i){const n=i||Xt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class Xt{constructor(e,t,i){this.path=t,this.parsedPath=i||Xt.parseTrackName(t),this.node=Xt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Xt.Composite(e,t,i):new Xt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(oW,"")}static parseTrackName(e){const t=dW.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const r=i.nodeName.substring(n+1);fW.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=r)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(r){for(let o=0;o<r.length;o++){const a=r[o];if(a.name===t||a.uuid===t)return a;const l=i(a.children);if(l)return l}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let r=t.propertyIndex;if(e||(e=Xt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const o=e[n];if(o===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+n+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Xt.Composite=pW;Xt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Xt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Xt.prototype.GetterByBindingType=[Xt.prototype._getValue_direct,Xt.prototype._getValue_array,Xt.prototype._getValue_arrayElement,Xt.prototype._getValue_toArray];Xt.prototype.SetterByBindingTypeAndVersioning=[[Xt.prototype._setValue_direct,Xt.prototype._setValue_direct_setNeedsUpdate,Xt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Xt.prototype._setValue_array,Xt.prototype._setValue_array_setNeedsUpdate,Xt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Xt.prototype._setValue_arrayElement,Xt.prototype._setValue_arrayElement_setNeedsUpdate,Xt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Xt.prototype._setValue_fromArray,Xt.prototype._setValue_fromArray_setNeedsUpdate,Xt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class mW{constructor(){this.isAnimationObjectGroup=!0,this.uuid=uo(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,n=arguments.length;i!==n;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,o=r.length;let a,l=e.length,c=this.nCachedObjects_;for(let u=0,d=arguments.length;u!==d;++u){const f=arguments[u],p=f.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(f);for(let A=0,v=o;A!==v;++A)r[A].push(new Xt(f,i[A],n[A]))}else if(m<c){a=e[m];const A=--c,v=e[A];t[v.uuid]=m,e[m]=v,t[p]=A,e[A]=f;for(let g=0,_=o;g!==_;++g){const y=r[g],b=y[A];let E=y[m];y[m]=b,E===void 0&&(E=new Xt(f,i[g],n[g])),y[A]=E}}else e[m]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const l=arguments[o],c=l.uuid,u=t[c];if(u!==void 0&&u>=r){const d=r++,f=e[d];t[f.uuid]=u,e[u]=f,t[c]=d,e[d]=l;for(let p=0,m=n;p!==m;++p){const A=i[p],v=A[d],g=A[u];A[u]=v,A[d]=g}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){const c=arguments[a],u=c.uuid,d=t[u];if(d!==void 0)if(delete t[u],d<r){const f=--r,p=e[f],m=--o,A=e[m];t[p.uuid]=d,e[d]=p,t[A.uuid]=f,e[f]=A,e.pop();for(let v=0,g=n;v!==g;++v){const _=i[v],y=_[f],b=_[m];_[d]=y,_[f]=b,_.pop()}}else{const f=--o,p=e[f];f>0&&(t[p.uuid]=d),e[d]=p,e.pop();for(let m=0,A=n;m!==A;++m){const v=i[m];v[d]=v[f],v.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const i=this._bindingsIndicesByPath;let n=i[e];const r=this._bindings;if(n!==void 0)return r[n];const o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,d=new Array(c);n=r.length,i[e]=n,o.push(e),a.push(t),r.push(d);for(let f=u,p=l.length;f!==p;++f){const m=l[f];d[f]=new Xt(m,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const n=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=i,o[i]=l,o.pop(),r[i]=r[a],r.pop(),n[i]=n[a],n.pop()}}}class hU{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;const r=t.tracks,o=r.length,a=new Array(o),l={endingStart:Du,endingEnd:Du};for(let c=0;c!==o;++c){const u=r[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=sT,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}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const n=this._clip.duration,r=e._clip.duration,o=r/n,a=n/r;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const n=this._mixer,r=n.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=r,l[1]=r+i,c[0]=e/o,c[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,n){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const l=(e-r)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case rT:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case sx:default:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(o),c[u].accumulate(n,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let n=this.time+e,r=this._loopCount;const o=i===Wk;if(e===0)return r===-1?n:o&&(r&1)===1?t-n:n;if(i===$g){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=t||n<0){const a=Math.floor(n/t);n-=t*a,r+=Math.abs(a);const l=this.repetitions-r;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(r&1)===1)return t-n}return n}_setEndings(e,t,i){const n=this._interpolantSettings;i?(n.endingStart=Ou,n.endingEnd=Ou):(e?n.endingStart=this.zeroSlopeAtStart?Ou:Du:n.endingStart=ev,t?n.endingEnd=this.zeroSlopeAtEnd?Ou:Du:n.endingEnd=ev)}_scheduleFading(e,t,i){const n=this._mixer,r=n.time;let o=this._weightInterpolant;o===null&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=r,l[0]=t,a[1]=r+e,l[1]=i,this}}const gW=new Float32Array(1);class Dx extends ps{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,o=e._propertyBindings,a=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let d=0;d!==r;++d){const f=n[d],p=f.name;let m=u[p];if(m!==void 0)++m.referenceCount,o[d]=m;else{if(m=o[d],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const A=t&&t._propertyBindings[d].binding.parsedPath;m=new cU(Xt.create(i,p,A),f.ValueTypeName,f.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),o[d]=m}a[d].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,i)}const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const n=this._actions,r=this._actionsByClip;let o=r[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=o;else{const a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=n.length,n.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],n=e._cacheIndex;i._cacheIndex=n,t[n]=i,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,o=this._actionsByClip,a=o[r],l=a.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;const d=a.actionByRoot,f=(e._localRoot||this._root).uuid;delete d[f],l.length===0&&delete o[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,n=this._nActiveActions++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,n=--this._nActiveActions,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_addInactiveBinding(e,t,i){const n=this._bindingsByRootAndName,r=this._bindings;let o=n[t];o===void 0&&(o={},n[t]=o),o[i]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,n=i.rootNode.uuid,r=i.path,o=this._bindingsByRootAndName,a=o[n],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete a[r],Object.keys(a).length===0&&delete o[n]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,n=this._nActiveBindings++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,n=--this._nActiveBindings,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new PT(new Float32Array(2),new Float32Array(2),1,gW),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=t[n];e.__cacheIndex=n,t[n]=e,r.__cacheIndex=i,t[i]=r}clipAction(e,t,i){const n=t||this._root,r=n.uuid;let o=typeof e=="string"?Sr.findByName(n,e):e;const a=o!==null?o.uuid:e,l=this._actionsByClip[a];let c=null;if(i===void 0&&(o!==null?i=o.blendMode:i=sx),l!==void 0){const d=l.actionByRoot[r];if(d!==void 0&&d.blendMode===i)return d;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;const u=new hU(this,o,t,i);return this._bindAction(u,c),this._addInactiveAction(u,a,r),u}existingAction(e,t){const i=t||this._root,n=i.uuid,r=typeof e=="string"?Sr.findByName(i,e):e,o=r?r.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[n]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,n=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(n,e,r,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,n=this._actionsByClip,r=n[i];if(r!==void 0){const o=r.knownActions;for(let a=0,l=o.length;a!==l;++a){const c=o[a];this._deactivateAction(c);const u=c._cacheIndex,d=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,d._cacheIndex=u,t[u]=d,t.pop(),this._removeInactiveBindingsForAction(c)}delete n[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const o in i){const a=i[o].actionByRoot,l=a[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const n=this._bindingsByRootAndName,r=n[t];if(r!==void 0)for(const o in r){const a=r[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class _e{constructor(e){this.value=e}clone(){return new _e(this.value.clone===void 0?this.value:this.value.clone())}}let vW=0;class AW extends ps{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:vW++}),this.name="",this.usage=sv,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let i=0,n=t.length;i<n;i++){const r=Array.isArray(t[i])?t[i]:[t[i]];for(let o=0;o<r.length;o++)this.uniforms.push(r[o].clone())}return this}clone(){return new this.constructor().copy(this)}}class nb extends Yv{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class yW{constructor(e,t,i,n,r){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=n,this.count=r,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const t2=new we;let pd=class{constructor(e,t,i=0,n=1/0){this.ray=new Hr(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new er,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return t2.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(t2),this}intersectObject(e,t=!0,i=[]){return u1(e,this,i,t),i.sort(i2),i}intersectObjects(e,t=!0,i=[]){for(let n=0,r=e.length;n<r;n++)u1(e[n],this,i,t);return i.sort(i2),i}};function i2(s,e){return s.distance-e.distance}function u1(s,e,t,i){if(s.layers.test(e.layers)&&s.raycast(e,t),i===!0){const n=s.children;for(let r=0,o=n.length;r<o;r++)u1(n[r],e,t,!0)}}class d1{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(An(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class _W{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}const n2=new te;class bW{constructor(e=new te(1/0,1/0),t=new te(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=n2.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(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(e,t){return 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(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,n2).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const s2=new w,$y=new w;class zT{constructor(e=new w,t=new w){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){s2.subVectors(e,this.start),$y.subVectors(this.end,this.start);const i=$y.dot($y);let r=$y.dot(s2)/i;return t&&(r=An(r,0,1)),r}closestPointToPoint(e,t,i){const n=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(n).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const r2=new w;class xW extends ge{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new wt,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){const c=o/l*Math.PI*2,u=a/l*Math.PI*2;n.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new ut(n,3));const r=new Rn({fog:!1,toneMapped:!1});this.cone=new Ao(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),r2.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(r2),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Hc=new w,e0=new we,FS=new we;class wW extends Ao{constructor(e){const t=uU(e),i=new wt,n=[],r=[],o=new xe(0,0,1),a=new xe(0,1,0);for(let c=0;c<t.length;c++){const u=t[c];u.parent&&u.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(o.r,o.g,o.b),r.push(a.r,a.g,a.b))}i.setAttribute("position",new ut(n,3)),i.setAttribute("color",new ut(r,3));const l=new Rn({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,n=i.getAttribute("position");FS.copy(this.root.matrixWorld).invert();for(let r=0,o=0;r<t.length;r++){const a=t[r];a.parent&&a.parent.isBone&&(e0.multiplyMatrices(FS,a.matrixWorld),Hc.setFromMatrixPosition(e0),n.setXYZ(o,Hc.x,Hc.y,Hc.z),e0.multiplyMatrices(FS,a.parent.matrixWorld),Hc.setFromMatrixPosition(e0),n.setXYZ(o+1,Hc.x,Hc.y,Hc.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function uU(s){const e=[];s.isBone===!0&&e.push(s);for(let t=0;t<s.children.length;t++)e.push.apply(e,uU(s.children[t]));return e}class SW extends pe{constructor(e,t,i){const n=new Sa(t,4,2),r=new ai({wireframe:!0,fog:!1,toneMapped:!1});super(n,r),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const CW=new w,o2=new xe,a2=new xe;class EW extends ge{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new nc(t);n.rotateY(Math.PI*.5),this.material=new ai({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),o=new Float32Array(r.count*3);n.setAttribute("color",new it(o,3)),this.add(new pe(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");o2.copy(this.light.color),a2.copy(this.light.groundColor);for(let i=0,n=t.count;i<n;i++){const r=i<n/2?o2:a2;t.setXYZ(i,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(CW.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Ox=class extends Ao{constructor(e=10,t=10,i=4473924,n=8947848){i=new xe(i),n=new xe(n);const r=t/2,o=e/t,a=e/2,l=[],c=[];for(let f=0,p=0,m=-a;f<=t;f++,m+=o){l.push(-a,0,m,a,0,m),l.push(m,0,-a,m,0,a);const A=f===r?i:n;A.toArray(c,p),p+=3,A.toArray(c,p),p+=3,A.toArray(c,p),p+=3,A.toArray(c,p),p+=3}const u=new wt;u.setAttribute("position",new ut(l,3)),u.setAttribute("color",new ut(c,3));const d=new Rn({vertexColors:!0,toneMapped:!1});super(u,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class MW extends Ao{constructor(e=10,t=16,i=8,n=64,r=4473924,o=8947848){r=new xe(r),o=new xe(o);const a=[],l=[];if(t>1)for(let d=0;d<t;d++){const f=d/t*(Math.PI*2),p=Math.sin(f)*e,m=Math.cos(f)*e;a.push(0,0,0),a.push(p,0,m);const A=d&1?r:o;l.push(A.r,A.g,A.b),l.push(A.r,A.g,A.b)}for(let d=0;d<i;d++){const f=d&1?r:o,p=e-e/i*d;for(let m=0;m<n;m++){let A=m/n*(Math.PI*2),v=Math.sin(A)*p,g=Math.cos(A)*p;a.push(v,0,g),l.push(f.r,f.g,f.b),A=(m+1)/n*(Math.PI*2),v=Math.sin(A)*p,g=Math.cos(A)*p,a.push(v,0,g),l.push(f.r,f.g,f.b)}}const c=new wt;c.setAttribute("position",new ut(a,3)),c.setAttribute("color",new ut(l,3));const u=new Rn({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const l2=new w,t0=new w,c2=new w;class dU extends ge{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let n=new wt;n.setAttribute("position",new ut([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Rn({fog:!1,toneMapped:!1});this.lightPlane=new Mn(n,r),this.add(this.lightPlane),n=new wt,n.setAttribute("position",new ut([0,0,0,0,0,1],3)),this.targetLine=new Mn(n,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),l2.setFromMatrixPosition(this.light.matrixWorld),t0.setFromMatrixPosition(this.light.target.matrixWorld),c2.subVectors(t0,l2),this.lightPlane.lookAt(t0),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(t0),this.targetLine.scale.z=c2.length()}}const i0=new w,gn=new jv;class fU extends Ao{constructor(e){const t=new wt,i=new Rn({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,A){l(m),l(A)}function l(m){n.push(0,0,0),r.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(n.length/3-1)}t.setAttribute("position",new ut(n,3)),t.setAttribute("color",new ut(r,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const c=new xe(16755200),u=new xe(16711680),d=new xe(43775),f=new xe(16777215),p=new xe(3355443);this.setColors(c,u,d,f,p)}setColors(e,t,i,n,r){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,n.r,n.g,n.b),a.setXYZ(39,n.r,n.g,n.b),a.setXYZ(40,r.r,r.g,r.b),a.setXYZ(41,r.r,r.g,r.b),a.setXYZ(42,r.r,r.g,r.b),a.setXYZ(43,r.r,r.g,r.b),a.setXYZ(44,r.r,r.g,r.b),a.setXYZ(45,r.r,r.g,r.b),a.setXYZ(46,r.r,r.g,r.b),a.setXYZ(47,r.r,r.g,r.b),a.setXYZ(48,r.r,r.g,r.b),a.setXYZ(49,r.r,r.g,r.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,i=1,n=1;gn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),xn("c",t,e,gn,0,0,-1),xn("t",t,e,gn,0,0,1),xn("n1",t,e,gn,-i,-n,-1),xn("n2",t,e,gn,i,-n,-1),xn("n3",t,e,gn,-i,n,-1),xn("n4",t,e,gn,i,n,-1),xn("f1",t,e,gn,-i,-n,1),xn("f2",t,e,gn,i,-n,1),xn("f3",t,e,gn,-i,n,1),xn("f4",t,e,gn,i,n,1),xn("u1",t,e,gn,i*.7,n*1.1,-1),xn("u2",t,e,gn,-i*.7,n*1.1,-1),xn("u3",t,e,gn,0,n*2,-1),xn("cf1",t,e,gn,-i,0,1),xn("cf2",t,e,gn,i,0,1),xn("cf3",t,e,gn,0,-n,1),xn("cf4",t,e,gn,0,n,1),xn("cn1",t,e,gn,-i,0,-1),xn("cn2",t,e,gn,i,0,-1),xn("cn3",t,e,gn,0,-n,-1),xn("cn4",t,e,gn,0,n,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function xn(s,e,t,i,n,r,o){i0.set(n,r,o).unproject(i);const a=e[s];if(a!==void 0){const l=t.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],i0.x,i0.y,i0.z)}}const n0=new Ti;class GT extends Ao{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(8*3),r=new wt;r.setIndex(new it(i,1)),r.setAttribute("position",new it(n,3)),super(r,new Rn({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&n0.setFromObject(this.object),n0.isEmpty())return;const t=n0.min,i=n0.max,n=this.geometry.attributes.position,r=n.array;r[0]=i.x,r[1]=i.y,r[2]=i.z,r[3]=t.x,r[4]=i.y,r[5]=i.z,r[6]=t.x,r[7]=t.y,r[8]=i.z,r[9]=i.x,r[10]=t.y,r[11]=i.z,r[12]=i.x,r[13]=i.y,r[14]=t.z,r[15]=t.x,r[16]=i.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=i.x,r[22]=t.y,r[23]=t.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class f1 extends Ao{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],r=new wt;r.setIndex(new it(i,1)),r.setAttribute("position",new ut(n,3)),super(r,new Rn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class TW extends Mn{constructor(e,t=1,i=16776960){const n=i,r=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new wt;o.setAttribute("position",new ut(r,3)),o.computeBoundingSphere(),super(o,new Rn({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new wt;l.setAttribute("position",new ut(a,3)),l.computeBoundingSphere(),this.add(new pe(l,new ai({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const h2=new w;let s0,US;class IW extends ge{constructor(e=new w(0,0,1),t=new w(0,0,0),i=1,n=16776960,r=i*.2,o=r*.2){super(),this.type="ArrowHelper",s0===void 0&&(s0=new wt,s0.setAttribute("position",new ut([0,0,0,0,1,0],3)),US=new Sn(0,.5,1,5,1),US.translate(0,-.5,0)),this.position.copy(t),this.line=new Mn(s0,new Rn({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new pe(US,new ai({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,r,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{h2.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(h2,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}let Ho=class extends Ao{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],n=new wt;n.setAttribute("position",new ut(t,3)),n.setAttribute("color",new ut(i,3));const r=new Rn({vertexColors:!0,toneMapped:!1});super(n,r),this.type="AxesHelper"}setColors(e,t,i){const n=new xe,r=this.geometry.attributes.color.array;return n.set(e),n.toArray(r,0),n.toArray(r,3),n.set(t),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};class RW{constructor(){this.type="ShapePath",this.color=new xe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new av,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,n){return this.currentPath.quadraticCurveTo(e,t,i,n),this}bezierCurveTo(e,t,i,n,r,o){return this.currentPath.bezierCurveTo(e,t,i,n,r,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const _=[];for(let y=0,b=g.length;y<b;y++){const E=g[y],M=new Qu;M.curves=E.curves,_.push(M)}return _}function i(g,_){const y=_.length;let b=!1;for(let E=y-1,M=0;M<y;E=M++){let T=_[E],C=_[M],B=C.x-T.x,S=C.y-T.y;if(Math.abs(S)>Number.EPSILON){if(S<0&&(T=_[M],B=-B,C=_[E],S=-S),g.y<T.y||g.y>C.y)continue;if(g.y===T.y){if(g.x===T.x)return!0}else{const R=S*(g.x-T.x)-B*(g.y-T.y);if(R===0)return!0;if(R<0)continue;b=!b}}else{if(g.y!==T.y)continue;if(C.x<=g.x&&g.x<=T.x||T.x<=g.x&&g.x<=C.x)return!0}}return b}const n=ol.isClockWise,r=this.subPaths;if(r.length===0)return[];let o,a,l;const c=[];if(r.length===1)return a=r[0],l=new Qu,l.curves=a.curves,c.push(l),c;let u=!n(r[0].getPoints());u=e?!u:u;const d=[],f=[];let p=[],m=0,A;f[m]=void 0,p[m]=[];for(let g=0,_=r.length;g<_;g++)a=r[g],A=a.getPoints(),o=n(A),o=e?!o:o,o?(!u&&f[m]&&m++,f[m]={s:new Qu,p:A},f[m].s.curves=a.curves,u&&m++,p[m]=[]):p[m].push({h:a,p:A[0]});if(!f[0])return t(r);if(f.length>1){let g=!1,_=0;for(let y=0,b=f.length;y<b;y++)d[y]=[];for(let y=0,b=f.length;y<b;y++){const E=p[y];for(let M=0;M<E.length;M++){const T=E[M];let C=!0;for(let B=0;B<f.length;B++)i(T.p,f[B].p)&&(y!==B&&_++,C?(C=!1,d[B].push(T)):g=!0);C&&d[y].push(T)}}_>0&&g===!1&&(p=d)}let v;for(let g=0,_=f.length;g<_;g++){l=f[g].s,c.push(l),v=p[g];for(let y=0,b=v.length;y<b;y++)l.holes.push(v[y].h)}return c}}class pU extends Yt{constructor(e=1,t=1,i=1,n={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...n,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:fc}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+fc):window.__THREE__=fc);const PW=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Zb,AddEquation:ah,AddOperation:kk,AdditiveAnimationBlendMode:rT,AdditiveBlending:ed,AgXToneMapping:KM,AlphaFormat:Qk,AlwaysCompare:mF,AlwaysDepth:Yb,AlwaysStencilFunc:K_,AmbientLight:LT,AnimationAction:hU,AnimationClip:Sr,AnimationLoader:Xj,AnimationMixer:Dx,AnimationObjectGroup:mW,AnimationUtils:Vj,ArcCurve:FF,ArrayCamera:gT,ArrowHelper:IW,AttachedBindMode:kE,Audio:FT,AudioAnalyser:rW,AudioContext:Bx,AudioListener:aU,AudioLoader:ib,AxesHelper:Ho,BackSide:_n,BasicDepthPacking:Ds,BasicShadowMap:wH,BatchedMesh:DF,Bone:Jv,BooleanKeyframeTrack:dd,Box2:bW,Box3:Ti,Box3Helper:f1,BoxGeometry:Li,BoxHelper:GT,BufferAttribute:it,BufferGeometry:wt,BufferGeometryLoader:rU,ByteType:Gk,Cache:sc,Camera:jv,CameraHelper:fU,CanvasTexture:bT,CapsuleGeometry:px,CatmullRomCurve3:UF,CineonToneMapping:Uk,CircleGeometry:mx,ClampToEdgeWrapping:us,Clock:kT,Color:xe,ColorKeyframeTrack:Mx,ColorManagement:vi,CompressedArrayTexture:LF,CompressedCubeTexture:kF,CompressedTexture:rl,CompressedTextureLoader:Yj,ConeGeometry:gx,ConstantAlphaFactor:Dk,ConstantColorFactor:Pk,CubeCamera:dT,CubeReflectionMapping:pc,CubeRefractionMapping:Eh,CubeTexture:Wv,CubeTextureLoader:Jj,CubeUVReflectionMapping:Ep,CubicBezierCurve:wT,CubicBezierCurve3:NF,CubicInterpolant:ZF,CullFaceBack:BE,CullFaceFront:yk,CullFaceFrontBack:xH,CullFaceNone:Ak,Curve:wa,CurvePath:GF,CustomBlending:YM,CustomToneMapping:Nk,CylinderGeometry:Sn,Cylindrical:_W,Data3DTexture:ax,DataArrayTexture:ox,DataTexture:Nr,DataTextureLoader:BT,DataUtils:Lu,DecrementStencilOp:$k,DecrementWrapStencilOp:tF,DefaultLoadingManager:tU,DepthFormat:vh,DepthStencilFormat:Mh,DepthTexture:Ip,DetachedBindMode:zk,DirectionalLight:mp,DirectionalLightHelper:dU,DiscreteInterpolant:$F,DisplayP3ColorSpace:Vv,DodecahedronGeometry:vx,DoubleSide:mi,DstAlphaFactor:Ek,DstColorFactor:Tk,DynamicCopyUsage:DH,DynamicDrawUsage:Ks,DynamicReadUsage:RH,EdgesGeometry:TT,EllipseCurve:fx,EqualCompare:uF,EqualDepth:cp,EqualStencilFunc:sF,EquirectangularReflectionMapping:zo,EquirectangularRefractionMapping:up,Euler:Gi,EventDispatcher:ps,ExtrudeGeometry:yx,FileLoader:Kn,Float16BufferAttribute:vQ,Float32BufferAttribute:ut,FloatType:Ni,Fog:hx,FogExp2:cx,FramebufferTexture:pj,FrontSide:Bs,Frustum:qv,GLBufferAttribute:yW,GLSL1:LH,GLSL3:Z_,GreaterCompare:dF,GreaterDepth:Kb,GreaterEqualCompare:pF,GreaterEqualDepth:Jb,GreaterEqualStencilFunc:lF,GreaterStencilFunc:oF,GridHelper:Ox,Group:kr,HalfFloatType:cn,HemisphereLight:DT,HemisphereLightHelper:EW,IcosahedronGeometry:_x,ImageBitmapLoader:oU,ImageLoader:uv,ImageUtils:cT,IncrementStencilOp:Zk,IncrementWrapStencilOp:eF,InstancedBufferAttribute:Lr,InstancedBufferGeometry:Px,InstancedInterleavedBuffer:nb,InstancedMesh:ux,Int16BufferAttribute:mQ,Int32BufferAttribute:gQ,Int8BufferAttribute:dQ,IntType:ZM,InterleavedBuffer:Yv,InterleavedBufferAttribute:xr,Interpolant:Bp,InterpolateDiscrete:Th,InterpolateLinear:dl,InterpolateSmooth:l_,InvertStencilOp:iF,KeepStencilOp:ih,KeyframeTrack:Ca,LOD:AT,LatheGeometry:Kv,Layers:er,LessCompare:hF,LessDepth:Kg,LessEqualCompare:aT,LessEqualDepth:td,LessEqualStencilFunc:rF,LessStencilFunc:nF,Light:Uh,LightProbe:sU,Line:Mn,Line3:zT,LineBasicMaterial:Rn,LineCurve:ST,LineCurve3:zF,LineDashedMaterial:YF,LineLoop:yT,LineSegments:Ao,LinearDisplayP3ColorSpace:Mp,LinearEncoding:Xk,LinearFilter:Mt,LinearInterpolant:PT,LinearMipMapLinearFilter:MH,LinearMipMapNearestFilter:EH,LinearMipmapLinearFilter:br,LinearMipmapNearestFilter:Gu,LinearSRGBColorSpace:yi,LinearToneMapping:hp,LinearTransfer:tv,Loader:ks,LoaderUtils:Ah,LoadingManager:Tx,LoopOnce:$g,LoopPingPong:Wk,LoopRepeat:sT,LuminanceAlphaFormat:Vk,LuminanceFormat:ix,MOUSE:wu,Material:Nt,MaterialLoader:Rx,MathUtils:Jn,Matrix3:Lt,Matrix4:we,MaxEquation:H_,Mesh:pe,MeshBasicMaterial:ai,MeshDepthMaterial:Xv,MeshDistanceMaterial:mT,MeshLambertMaterial:qF,MeshMatcapMaterial:XF,MeshNormalMaterial:Ex,MeshPhongMaterial:jF,MeshPhysicalMaterial:mo,MeshStandardMaterial:zr,MeshToonMaterial:WF,MinEquation:LE,MirroredRepeatWrapping:id,MixOperation:Lk,MultiplyBlending:OE,MultiplyOperation:Qv,NearestFilter:Ht,NearestMipMapLinearFilter:CH,NearestMipMapNearestFilter:SH,NearestMipmapLinearFilter:Xl,NearestMipmapNearestFilter:dp,NeutralToneMapping:$b,NeverCompare:cF,NeverDepth:JM,NeverStencilFunc:n1,NoBlending:Zi,NoColorSpace:$s,NoToneMapping:ho,NormalAnimationBlendMode:sx,NormalBlending:gh,NotEqualCompare:fF,NotEqualDepth:Hv,NotEqualStencilFunc:aF,NumberKeyframeTrack:Ih,Object3D:ge,ObjectLoader:eW,ObjectSpaceNormalMap:Yk,OctahedronGeometry:nc,OneFactor:wk,OneMinusConstantAlphaFactor:Ok,OneMinusConstantColorFactor:Bk,OneMinusDstAlphaFactor:Mk,OneMinusDstColorFactor:Ik,OneMinusSrcAlphaFactor:V_,OneMinusSrcColorFactor:Ck,OrthographicCamera:yc,P3Primaries:nv,PCFShadowMap:qM,PCFSoftShadowMap:XM,PMREMGenerator:r1,Path:av,PerspectiveCamera:Qt,Plane:Ar,PlaneGeometry:zn,PlaneHelper:TW,PointLight:$v,PointLightHelper:SW,Points:_T,PointsMaterial:dx,PolarGridHelper:MW,PolyhedronGeometry:Fh,PositionalAudio:lU,PropertyBinding:Xt,PropertyMixer:cU,QuadraticBezierCurve:CT,QuadraticBezierCurve3:ET,Quaternion:Ce,QuaternionKeyframeTrack:fl,QuaternionLinearInterpolant:eU,RED_GREEN_RGTC2_Format:e1,RED_RGTC1_Format:jk,REVISION:fc,RGBADepthPacking:rx,RGBAFormat:Ai,RGBAIntegerFormat:nT,RGBA_ASTC_10x10_Format:XE,RGBA_ASTC_10x5_Format:jE,RGBA_ASTC_10x6_Format:WE,RGBA_ASTC_10x8_Format:qE,RGBA_ASTC_12x10_Format:YE,RGBA_ASTC_12x12_Format:JE,RGBA_ASTC_4x4_Format:Y_,RGBA_ASTC_5x4_Format:NE,RGBA_ASTC_5x5_Format:zE,RGBA_ASTC_6x5_Format:GE,RGBA_ASTC_6x6_Format:Zg,RGBA_ASTC_8x5_Format:HE,RGBA_ASTC_8x6_Format:QE,RGBA_ASTC_8x8_Format:VE,RGBA_BPTC_Format:_g,RGBA_ETC2_EAC_Format:X_,RGBA_PVRTC_2BPPV1_Format:UE,RGBA_PVRTC_4BPPV1_Format:W_,RGBA_S3TC_DXT1_Format:o_,RGBA_S3TC_DXT3_Format:a_,RGBA_S3TC_DXT5_Format:yg,RGB_BPTC_SIGNED_Format:KE,RGB_BPTC_UNSIGNED_Format:ZE,RGB_ETC1_Format:nx,RGB_ETC2_Format:q_,RGB_PVRTC_2BPPV1_Format:FE,RGB_PVRTC_4BPPV1_Format:j_,RGB_S3TC_DXT1_Format:Ag,RGFormat:hh,RGIntegerFormat:iT,RawShaderMaterial:Zv,Ray:Hr,Raycaster:pd,Rec709Primaries:iv,RectAreaLight:iU,RedFormat:pa,RedIntegerFormat:tT,ReinhardToneMapping:Fk,RenderTarget:yF,RepeatWrapping:Go,ReplaceStencilOp:Kk,ReverseSubtractEquation:bk,RingGeometry:sd,SIGNED_RED_GREEN_RGTC2_Format:t1,SIGNED_RED_RGTC1_Format:$E,SRGBColorSpace:gt,SRGBTransfer:Oi,Scene:ir,ShaderChunk:zt,ShaderLib:Ts,ShaderMaterial:Pt,ShadowMaterial:Cx,Shape:Qu,ShapeGeometry:bx,ShapePath:RW,ShapeUtils:ol,ShortType:Hk,Skeleton:Pp,SkeletonHelper:wW,SkinnedMesh:ga,Source:ic,Sphere:In,SphereGeometry:Sa,Spherical:d1,SphericalHarmonics3:nU,SplineCurve:MT,SpotLight:Ix,SpotLightHelper:xW,Sprite:BF,SpriteMaterial:vT,SrcAlphaFactor:Q_,SrcAlphaSaturateFactor:Rk,SrcColorFactor:Sk,StaticCopyUsage:BH,StaticDrawUsage:sv,StaticReadUsage:IH,StereoCamera:iW,StreamCopyUsage:OH,StreamDrawUsage:TH,StreamReadUsage:PH,StringKeyframeTrack:fd,SubtractEquation:_k,SubtractiveBlending:DE,TOUCH:Su,TangentSpaceNormalMap:kh,TetrahedronGeometry:xx,Texture:Dt,TextureLoader:al,TorusGeometry:Jl,TorusKnotGeometry:wx,Triangle:_r,TriangleFanDrawMode:J_,TriangleStripDrawMode:oT,TrianglesDrawMode:qk,TubeGeometry:Sx,UVMapping:ex,Uint16BufferAttribute:hT,Uint32BufferAttribute:uT,Uint8BufferAttribute:fQ,Uint8ClampedBufferAttribute:pQ,Uniform:_e,UniformsGroup:AW,UniformsLib:Fe,UniformsUtils:Tp,UnsignedByteType:di,UnsignedInt248Type:ac,UnsignedIntType:fa,UnsignedShort4444Type:$M,UnsignedShort5551Type:eT,UnsignedShortType:tx,VSMShadowMap:Ua,Vector2:te,Vector3:w,Vector4:Ze,VectorKeyframeTrack:mc,VideoTexture:OF,WebGL1Renderer:IF,WebGL3DRenderTarget:tQ,WebGLArrayRenderTarget:eQ,WebGLCoordinateSystem:Za,WebGLCubeRenderTarget:fT,WebGLMultipleRenderTargets:pU,WebGLRenderTarget:Yt,WebGLRenderer:_c,WebGLUtils:TF,WebGPUCoordinateSystem:rv,WireframeGeometry:IT,WrapAroundEnding:ev,ZeroCurvatureEnding:Du,ZeroFactor:xk,ZeroSlopeEnding:Ou,ZeroStencilOp:Jk,_SRGBAFormat:$_,createCanvasElement:vF,sRGBEncoding:i1},Symbol.toStringTag,{value:"Module"})),NS=new Map;function Gr(s=(e=>(e=globalThis.location)==null?void 0:e.hostname)()){if(NS.has(s))return NS.get(s);const t=/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|localhost/.test(s);return NS.set(s,t),t===!0}function mU(){return window.location.hostname.includes("glitch.me")}var kn=(s=>(s.ContextRegistered="ContextRegistered",s.ContextCreationStart="ContextCreationStart",s.ContextCreated="ContextCreated",s.ContextFirstFrameRendered="ContextFirstFrameRendered",s.ContextDestroyed="ContextDestroyed",s.MissingCamera="MissingCamera",s.ContextClearing="ContextClearing",s.ContextCleared="ContextCleared",s))(kn||{});class hi{static get Current(){return globalThis["NeedleEngine.Context.Current"]}static set Current(e){globalThis["NeedleEngine.Context.Current"]=e}static get All(){return this.Registered}static register(e){this.Registered.push(e),this.dispatchCallback("ContextRegistered",e)}static unregister(e){const t=this.Registered.indexOf(e);t!==-1&&this.Registered.splice(t,1)}static registerCallback(e,t){this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(t)}static unregisterCallback(e,t){if(!this._callbacks[e])return;const i=this._callbacks[e].indexOf(t);i!==-1&&this._callbacks[e].splice(i,1)}static dispatchCallback(e,t,i){if(!this._callbacks[e])return!0;const n={event:e,context:t};if(i)for(const o in i)n[o]=i[o];const r=new Array;return this._callbacks[e].forEach(o=>{const a=o(n);a instanceof Promise&&r.push(a)}),Promise.all(r)}static addContextCreatedCallback(e){this.registerCallback("ContextCreated",e)}static addContextDestroyedCallback(e){this.registerCallback("ContextDestroyed",e)}}h(hi,"Registered",[]),h(hi,"_callbacks",{});const gU=()=>s=>s;function BW(s){return gU()(s)}function DW(){return!!ne("debug")}class Qo{constructor(e,t){h(this,"_factory");h(this,"_cache",[]);h(this,"_maxSize");h(this,"_index",0);this._factory=e,this._maxSize=t}get(){const e=this._index%this._maxSize;return this._index++,this._cache.length<=e&&(this._cache[e]=this._factory()),this._cache[e]}}let HT=!1;const p1=[];setTimeout(()=>{HT&&console.log(p1.sort())},100);function eA(){var s;return new URLSearchParams((s=globalThis.location)==null?void 0:s.search)}function ne(s){HT&&!p1.includes(s)&&p1.push(s);const e=eA();if(e.has(s)){const t=e.get(s);if(t){const i=Number(t);return isNaN(i)?t:i}else return!0}return!1}HT=ne("help")===!0;function OW(s,e){const t=eA();t.has(s)?t.set(s,e):t.append(s,e),document.location.search=t.toString()}function sb(s,e,t=!0){const i=eA();i.has(s)?e===null?i.delete(s):i.set(s,e):e!==null&&i.append(s,e),t?vU(s,i):QT(s,i)}function m1(s,e,t){s.has(e)?s.set(e,t.toString()):s.append(e,t.toString())}function vU(s,e,t){window.history.pushState(t,s,"?"+e.toString())}function QT(s,e,t){window.history.replaceState(t,s,"?"+e.toString())}function LW(s){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=t.length,n=0;n<s;n++)e+=t.charAt(Math.floor(Math.random()*i));return e}function kW(s,e){return Math.floor(Math.random()*(e-s+1))+s}const u2=["smol","tiny","giant","interesting","smart","bright","dull","extreme","beautiful","pretty","dark","epic","salty","silly","funny","lame","lazy","loud","lucky","mad","mean","mighty","mysterious","nasty","odd","old","powerful","quiet","rapid","scary","shiny","shy","silly","smooth","sour","spicy","stupid","sweet","tasty","terrible","ugly","unusual","vast","wet","wild","witty","wrong","zany","zealous","zippy","zombie","zorro"],d2=["cat","dog","mouse","pig","cow","horse","sheep","chicken","duck","goat","panda","tiger","lion","elephant","monkey","bird","fish","snake","frog","turtle","hamster","penguin","kangaroo","whale","dolphin","crocodile","snail","ant","bee","beetle","butterfly","dragon","eagle","fish","giraffe","lizard","panda","penguin","rabbit","snake","spider","tiger","zebra"];function AU(){const s=u2[Math.floor(Math.random()*u2.length)],e=d2[Math.floor(Math.random()*d2.length)];return s+"_"+e}function yU(s){return s=s.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,""),s.trim()}function gp(s,e,t=!0,i=!1){var n;if(e==null)return null;if(e.userData&&e.userData.guid===s)return e;if(e.guid==s)return e;if(i&&(n=e.userData)!=null&&n.components){for(const r of e.userData.components)if(r.guid===s)return r}if(t){if(e.scenes)for(const r in e.scenes){const o=e.scenes[r],a=gp(s,o,t,i);if(a)return a}if(e.children)for(const r in e.children){const o=e.children[r],a=gp(s,o,t,i);if(a)return a}}}function tA(s,e){if(s!=null&&typeof s=="object"){let t;Array.isArray(s)?t=[]:(t=Object.create(s),Object.assign(t,s));for(const i of Object.keys(s)){const n=s[i];e&&!e(s,i,n)?t[i]=n:(n==null?void 0:n.clone)!==void 0&&typeof n.clone=="function"?t[i]=n.clone():t[i]=tA(n,e)}return t}return s}function _a(s){return new Promise((e,t)=>{setTimeout(e,s)})}function _U(s,e){if(s<=0)return Promise.resolve();if(e||(e=hi.Current),!e)return Promise.reject("No context");const t=e.time.frameCount+s;return new Promise((i,n)=>{if(!e)return n("No context");const r=()=>{e.time.frameCount>=t&&(e.pre_update_callbacks.splice(e.pre_update_callbacks.indexOf(r),1),i())};e.pre_update_callbacks.push(r)})}const r0=ne("debugresolveurl"),bU="rel:";function FW(s,e){return bc(s,e)}function bc(s,e){if(e===void 0)return r0&&console.warn("getPath: uri is undefined, returning uri",e),e;if(e.startsWith("./"))return e;if(e.startsWith("http"))return r0&&console.warn("getPath: uri is absolute, returning uri",e),e;if(s===void 0)return r0&&console.warn("getPath: source is undefined, returning uri",e),e;e.startsWith(bU)&&(e=e.substring(4));const t=s.lastIndexOf("/");if(t>=0){const i=s.substring(0,t+1),n=i+e;return r0&&console.log("source:",s,`- changed uri
3811
+ }`;class tj{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const n=new Dt,r=e.properties.get(n);r.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}render(e,t){if(this.texture!==null){if(this.mesh===null){const i=t.cameras[0].viewport,n=new Pt({extensions:{fragDepth:!0},vertexShader:$6,fragmentShader:ej,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new pe(new zn(20,20),n)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}}class ij extends ps{constructor(e,t){super();const i=this;let n=null,r=1,o=null,a="local-floor",l=1,c=null,u=null,d=null,f=null,p=null,m=null;const A=new tj,v=t.getContextAttributes();let g=null,_=null;const y=[],b=[],E=new te;let M=null;const T=new Qt;T.layers.enable(1),T.viewport=new Ze;const C=new Qt;C.layers.enable(2),C.viewport=new Ze;const B=[T,C],S=new gT;S.layers.enable(1),S.layers.enable(2);let R=null,Q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ie){let me=y[ie];return me===void 0&&(me=new SS,y[ie]=me),me.getTargetRaySpace()},this.getControllerGrip=function(ie){let me=y[ie];return me===void 0&&(me=new SS,y[ie]=me),me.getGripSpace()},this.getHand=function(ie){let me=y[ie];return me===void 0&&(me=new SS,y[ie]=me),me.getHandSpace()};function z(ie){const me=b.indexOf(ie.inputSource);if(me===-1)return;const be=y[me];be!==void 0&&(be.update(ie.inputSource,ie.frame,c||o),be.dispatchEvent({type:ie.type,data:ie.inputSource}))}function O(){n.removeEventListener("select",z),n.removeEventListener("selectstart",z),n.removeEventListener("selectend",z),n.removeEventListener("squeeze",z),n.removeEventListener("squeezestart",z),n.removeEventListener("squeezeend",z),n.removeEventListener("end",O),n.removeEventListener("inputsourceschange",V);for(let ie=0;ie<y.length;ie++){const me=b[ie];me!==null&&(b[ie]=null,y[ie].disconnect(me))}R=null,Q=null,A.reset(),e.setRenderTarget(g),p=null,f=null,d=null,n=null,_=null,Re.stop(),i.isPresenting=!1,e.setPixelRatio(M),e.setSize(E.width,E.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ie){r=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ie){a=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(ie){c=ie},this.getBaseLayer=function(){return f!==null?f:p},this.getBinding=function(){return d},this.getFrame=function(){return m},this.getSession=function(){return n},this.setSession=async function(ie){if(n=ie,n!==null){if(g=e.getRenderTarget(),n.addEventListener("select",z),n.addEventListener("selectstart",z),n.addEventListener("selectend",z),n.addEventListener("squeeze",z),n.addEventListener("squeezestart",z),n.addEventListener("squeezeend",z),n.addEventListener("end",O),n.addEventListener("inputsourceschange",V),v.xrCompatible!==!0&&await t.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(E),n.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const me={antialias:n.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(n,t,me),n.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),_=new Yt(p.framebufferWidth,p.framebufferHeight,{format:Ai,type:di,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let me=null,be=null,Ve=null;v.depth&&(Ve=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,me=v.stencil?Mh:vh,be=v.stencil?ac:fa);const je={colorFormat:t.RGBA8,depthFormat:Ve,scaleFactor:r};d=new XRWebGLBinding(n,t),f=d.createProjectionLayer(je),n.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),_=new Yt(f.textureWidth,f.textureHeight,{format:Ai,type:di,depthTexture:new Ip(f.textureWidth,f.textureHeight,be,void 0,void 0,void 0,void 0,void 0,void 0,me),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const Ge=e.properties.get(_);Ge.__ignoreDepthValues=f.ignoreDepthValues}_.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await n.requestReferenceSpace(a),Re.setContext(n),Re.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode};function V(ie){for(let me=0;me<ie.removed.length;me++){const be=ie.removed[me],Ve=b.indexOf(be);Ve>=0&&(b[Ve]=null,y[Ve].disconnect(be))}for(let me=0;me<ie.added.length;me++){const be=ie.added[me];let Ve=b.indexOf(be);if(Ve===-1){for(let Ge=0;Ge<y.length;Ge++)if(Ge>=b.length){b.push(be),Ve=Ge;break}else if(b[Ge]===null){b[Ge]=be,Ve=Ge;break}if(Ve===-1)break}const je=y[Ve];je&&je.connect(be)}}const L=new w,k=new w;function G(ie,me,be){L.setFromMatrixPosition(me.matrixWorld),k.setFromMatrixPosition(be.matrixWorld);const Ve=L.distanceTo(k),je=me.projectionMatrix.elements,Ge=be.projectionMatrix.elements,dt=je[14]/(je[10]-1),tt=je[14]/(je[10]+1),W=(je[9]+1)/je[5],Ne=(je[9]-1)/je[5],ye=(je[8]-1)/je[0],ke=(Ge[8]+1)/Ge[0],Se=dt*ye,$e=dt*ke,Je=Ve/(-ye+ke),st=Je*-ye;me.matrixWorld.decompose(ie.position,ie.quaternion,ie.scale),ie.translateX(st),ie.translateZ(Je),ie.matrixWorld.compose(ie.position,ie.quaternion,ie.scale),ie.matrixWorldInverse.copy(ie.matrixWorld).invert();const Bt=dt+Je,N=tt+Je,D=Se-st,fe=$e+(Ve-st),ve=W*tt/N*Bt,Ie=Ne*tt/N*Bt;ie.projectionMatrix.makePerspective(D,fe,ve,Ie,Bt,N),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert()}function Y(ie,me){me===null?ie.matrixWorld.copy(ie.matrix):ie.matrixWorld.multiplyMatrices(me.matrixWorld,ie.matrix),ie.matrixWorldInverse.copy(ie.matrixWorld).invert()}this.updateCamera=function(ie){if(n===null)return;A.texture!==null&&(A.depthNear>0&&(ie.near=A.depthNear),A.depthFar>0&&(ie.far=A.depthFar)),S.near=C.near=T.near=ie.near,S.far=C.far=T.far=ie.far,(R!==S.near||Q!==S.far)&&(n.updateRenderState({depthNear:S.near,depthFar:S.far}),R=S.near,Q=S.far,T.near=R,T.far=Q,C.near=R,C.far=Q,T.updateProjectionMatrix(),C.updateProjectionMatrix(),ie.updateProjectionMatrix());const me=ie.parent,be=S.cameras;Y(S,me);for(let Ve=0;Ve<be.length;Ve++)Y(be[Ve],me);be.length===2?G(S,T,C):S.projectionMatrix.copy(T.projectionMatrix),$(ie,S,me)};function $(ie,me,be){be===null?ie.matrix.copy(me.matrixWorld):(ie.matrix.copy(be.matrixWorld),ie.matrix.invert(),ie.matrix.multiply(me.matrixWorld)),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.updateMatrixWorld(!0),ie.projectionMatrix.copy(me.projectionMatrix),ie.projectionMatrixInverse.copy(me.projectionMatrixInverse),ie.isPerspectiveCamera&&(ie.fov=fp*2*Math.atan(1/ie.projectionMatrix.elements[5]),ie.zoom=1)}this.getCamera=function(){return S},this.getFoveation=function(){if(!(f===null&&p===null))return l},this.setFoveation=function(ie){l=ie,f!==null&&(f.fixedFoveation=ie),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ie)},this.hasDepthSensing=function(){return A.texture!==null};let re=null;function ce(ie,me){if(u=me.getViewerPose(c||o),m=me,u!==null){const be=u.views;p!==null&&(e.setRenderTargetFramebuffer(_,p.framebuffer),e.setRenderTarget(_));let Ve=!1;be.length!==S.cameras.length&&(S.cameras.length=0,Ve=!0);for(let Ge=0;Ge<be.length;Ge++){const dt=be[Ge];let tt=null;if(p!==null)tt=p.getViewport(dt);else{const Ne=d.getViewSubImage(f,dt);tt=Ne.viewport,Ge===0&&(e.setRenderTargetTextures(_,Ne.colorTexture,f.ignoreDepthValues?void 0:Ne.depthStencilTexture),e.setRenderTarget(_))}let W=B[Ge];W===void 0&&(W=new Qt,W.layers.enable(Ge),W.viewport=new Ze,B[Ge]=W),W.matrix.fromArray(dt.transform.matrix),W.matrix.decompose(W.position,W.quaternion,W.scale),W.projectionMatrix.fromArray(dt.projectionMatrix),W.projectionMatrixInverse.copy(W.projectionMatrix).invert(),W.viewport.set(tt.x,tt.y,tt.width,tt.height),Ge===0&&(S.matrix.copy(W.matrix),S.matrix.decompose(S.position,S.quaternion,S.scale)),Ve===!0&&S.cameras.push(W)}const je=n.enabledFeatures;if(je&&je.includes("depth-sensing")){const Ge=d.getDepthInformation(be[0]);Ge&&Ge.isValid&&Ge.texture&&A.init(e,Ge,n.renderState)}}for(let be=0;be<y.length;be++){const Ve=b[be],je=y[be];Ve!==null&&je!==void 0&&je.update(Ve,me,c||o)}A.render(e,S),re&&re(ie,me),me.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:me}),m=null}const Re=new xF;Re.setAnimationLoop(ce),this.setAnimationLoop=function(ie){re=ie},this.dispose=function(){}}}const su=new Gi,nj=new we;function sj(s,e){function t(v,g){v.matrixAutoUpdate===!0&&v.updateMatrix(),g.value.copy(v.matrix)}function i(v,g){g.color.getRGB(v.fogColor.value,bF(s)),g.isFog?(v.fogNear.value=g.near,v.fogFar.value=g.far):g.isFogExp2&&(v.fogDensity.value=g.density)}function n(v,g,_,y,b){g.isMeshBasicMaterial||g.isMeshLambertMaterial?r(v,g):g.isMeshToonMaterial?(r(v,g),d(v,g)):g.isMeshPhongMaterial?(r(v,g),u(v,g)):g.isMeshStandardMaterial?(r(v,g),f(v,g),g.isMeshPhysicalMaterial&&p(v,g,b)):g.isMeshMatcapMaterial?(r(v,g),m(v,g)):g.isMeshDepthMaterial?r(v,g):g.isMeshDistanceMaterial?(r(v,g),A(v,g)):g.isMeshNormalMaterial?r(v,g):g.isLineBasicMaterial?(o(v,g),g.isLineDashedMaterial&&a(v,g)):g.isPointsMaterial?l(v,g,_,y):g.isSpriteMaterial?c(v,g):g.isShadowMaterial?(v.color.value.copy(g.color),v.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(v,g){v.opacity.value=g.opacity,g.color&&v.diffuse.value.copy(g.color),g.emissive&&v.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(v.map.value=g.map,t(g.map,v.mapTransform)),g.alphaMap&&(v.alphaMap.value=g.alphaMap,t(g.alphaMap,v.alphaMapTransform)),g.bumpMap&&(v.bumpMap.value=g.bumpMap,t(g.bumpMap,v.bumpMapTransform),v.bumpScale.value=g.bumpScale,g.side===_n&&(v.bumpScale.value*=-1)),g.normalMap&&(v.normalMap.value=g.normalMap,t(g.normalMap,v.normalMapTransform),v.normalScale.value.copy(g.normalScale),g.side===_n&&v.normalScale.value.negate()),g.displacementMap&&(v.displacementMap.value=g.displacementMap,t(g.displacementMap,v.displacementMapTransform),v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias),g.emissiveMap&&(v.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,v.emissiveMapTransform)),g.specularMap&&(v.specularMap.value=g.specularMap,t(g.specularMap,v.specularMapTransform)),g.alphaTest>0&&(v.alphaTest.value=g.alphaTest);const _=e.get(g),y=_.envMap,b=_.envMapRotation;if(y&&(v.envMap.value=y,su.copy(b),su.x*=-1,su.y*=-1,su.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(su.y*=-1,su.z*=-1),v.envMapRotation.value.setFromMatrix4(nj.makeRotationFromEuler(su)),v.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=g.reflectivity,v.ior.value=g.ior,v.refractionRatio.value=g.refractionRatio),g.lightMap){v.lightMap.value=g.lightMap;const E=s._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=g.lightMapIntensity*E,t(g.lightMap,v.lightMapTransform)}g.aoMap&&(v.aoMap.value=g.aoMap,v.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,v.aoMapTransform))}function o(v,g){v.diffuse.value.copy(g.color),v.opacity.value=g.opacity,g.map&&(v.map.value=g.map,t(g.map,v.mapTransform))}function a(v,g){v.dashSize.value=g.dashSize,v.totalSize.value=g.dashSize+g.gapSize,v.scale.value=g.scale}function l(v,g,_,y){v.diffuse.value.copy(g.color),v.opacity.value=g.opacity,v.size.value=g.size*_,v.scale.value=y*.5,g.map&&(v.map.value=g.map,t(g.map,v.uvTransform)),g.alphaMap&&(v.alphaMap.value=g.alphaMap,t(g.alphaMap,v.alphaMapTransform)),g.alphaTest>0&&(v.alphaTest.value=g.alphaTest)}function c(v,g){v.diffuse.value.copy(g.color),v.opacity.value=g.opacity,v.rotation.value=g.rotation,g.map&&(v.map.value=g.map,t(g.map,v.mapTransform)),g.alphaMap&&(v.alphaMap.value=g.alphaMap,t(g.alphaMap,v.alphaMapTransform)),g.alphaTest>0&&(v.alphaTest.value=g.alphaTest)}function u(v,g){v.specular.value.copy(g.specular),v.shininess.value=Math.max(g.shininess,1e-4)}function d(v,g){g.gradientMap&&(v.gradientMap.value=g.gradientMap)}function f(v,g){v.metalness.value=g.metalness,g.metalnessMap&&(v.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,v.metalnessMapTransform)),v.roughness.value=g.roughness,g.roughnessMap&&(v.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,v.roughnessMapTransform)),e.get(g).envMap&&(v.envMapIntensity.value=g.envMapIntensity)}function p(v,g,_){v.ior.value=g.ior,g.sheen>0&&(v.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),v.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(v.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,v.sheenColorMapTransform)),g.sheenRoughnessMap&&(v.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,v.sheenRoughnessMapTransform))),g.clearcoat>0&&(v.clearcoat.value=g.clearcoat,v.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(v.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,v.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(v.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===_n&&v.clearcoatNormalScale.value.negate())),g.iridescence>0&&(v.iridescence.value=g.iridescence,v.iridescenceIOR.value=g.iridescenceIOR,v.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(v.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,v.iridescenceMapTransform)),g.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),g.transmission>0&&(v.transmission.value=g.transmission,v.transmissionSamplerMap.value=_.texture,v.transmissionSamplerSize.value.set(_.width,_.height),g.transmissionMap&&(v.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,v.transmissionMapTransform)),v.thickness.value=g.thickness,g.thicknessMap&&(v.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=g.attenuationDistance,v.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(v.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(v.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=g.specularIntensity,v.specularColor.value.copy(g.specularColor),g.specularColorMap&&(v.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,v.specularColorMapTransform)),g.specularIntensityMap&&(v.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,v.specularIntensityMapTransform))}function m(v,g){g.matcap&&(v.matcap.value=g.matcap)}function A(v,g){const _=e.get(g).light;v.referencePosition.value.setFromMatrixPosition(_.matrixWorld),v.nearDistance.value=_.shadow.camera.near,v.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function rj(s,e,t,i){let n={},r={},o=[];const a=t.isWebGL2?s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(_,y){const b=y.program;i.uniformBlockBinding(_,b)}function c(_,y){let b=n[_.id];b===void 0&&(m(_),b=u(_),n[_.id]=b,_.addEventListener("dispose",v));const E=y.program;i.updateUBOMapping(_,E);const M=e.render.frame;r[_.id]!==M&&(f(_),r[_.id]=M)}function u(_){const y=d();_.__bindingPointIndex=y;const b=s.createBuffer(),E=_.__size,M=_.usage;return s.bindBuffer(s.UNIFORM_BUFFER,b),s.bufferData(s.UNIFORM_BUFFER,E,M),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,y,b),b}function d(){for(let _=0;_<a;_++)if(o.indexOf(_)===-1)return o.push(_),_;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(_){const y=n[_.id],b=_.uniforms,E=_.__cache;s.bindBuffer(s.UNIFORM_BUFFER,y);for(let M=0,T=b.length;M<T;M++){const C=Array.isArray(b[M])?b[M]:[b[M]];for(let B=0,S=C.length;B<S;B++){const R=C[B];if(p(R,M,B,E)===!0){const Q=R.__offset,z=Array.isArray(R.value)?R.value:[R.value];let O=0;for(let V=0;V<z.length;V++){const L=z[V],k=A(L);typeof L=="number"||typeof L=="boolean"?(R.__data[0]=L,s.bufferSubData(s.UNIFORM_BUFFER,Q+O,R.__data)):L.isMatrix3?(R.__data[0]=L.elements[0],R.__data[1]=L.elements[1],R.__data[2]=L.elements[2],R.__data[3]=0,R.__data[4]=L.elements[3],R.__data[5]=L.elements[4],R.__data[6]=L.elements[5],R.__data[7]=0,R.__data[8]=L.elements[6],R.__data[9]=L.elements[7],R.__data[10]=L.elements[8],R.__data[11]=0):(L.toArray(R.__data,O),O+=k.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,Q,R.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function p(_,y,b,E){const M=_.value,T=y+"_"+b;if(E[T]===void 0)return typeof M=="number"||typeof M=="boolean"?E[T]=M:E[T]=M.clone(),!0;{const C=E[T];if(typeof M=="number"||typeof M=="boolean"){if(C!==M)return E[T]=M,!0}else if(C.equals(M)===!1)return C.copy(M),!0}return!1}function m(_){const y=_.uniforms;let b=0;const E=16;for(let T=0,C=y.length;T<C;T++){const B=Array.isArray(y[T])?y[T]:[y[T]];for(let S=0,R=B.length;S<R;S++){const Q=B[S],z=Array.isArray(Q.value)?Q.value:[Q.value];for(let O=0,V=z.length;O<V;O++){const L=z[O],k=A(L),G=b%E;G!==0&&E-G<k.boundary&&(b+=E-G),Q.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),Q.__offset=b,b+=k.storage}}}const M=b%E;return M>0&&(b+=E-M),_.__size=b,_.__cache={},this}function A(_){const y={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(y.boundary=4,y.storage=4):_.isVector2?(y.boundary=8,y.storage=8):_.isVector3||_.isColor?(y.boundary=16,y.storage=12):_.isVector4?(y.boundary=16,y.storage=16):_.isMatrix3?(y.boundary=48,y.storage=48):_.isMatrix4?(y.boundary=64,y.storage=64):_.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",_),y}function v(_){const y=_.target;y.removeEventListener("dispose",v);const b=o.indexOf(y.__bindingPointIndex);o.splice(b,1),s.deleteBuffer(n[y.id]),delete n[y.id],delete r[y.id]}function g(){for(const _ in n)s.deleteBuffer(n[_]);o=[],n={},r={}}return{bind:l,update:c,dispose:g}}class _c{constructor(e={}){const{canvas:t=vF(),context:i=null,depth:n=!0,stencil:r=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let f;i!==null?f=i.getContextAttributes().alpha:f=o;const p=new Uint32Array(4),m=new Int32Array(4);let A=null,v=null;const g=[],_=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=gt,this._useLegacyLights=!1,this.toneMapping=ho,this.toneMappingExposure=1;const y=this;let b=!1,E=0,M=0,T=null,C=-1,B=null;const S=new Ze,R=new Ze;let Q=null;const z=new xe(0);let O=0,V=t.width,L=t.height,k=1,G=null,Y=null;const $=new Ze(0,0,V,L),re=new Ze(0,0,V,L);let ce=!1;const Re=new qv;let ie=!1,me=!1,be=null;const Ve=new we,je=new te,Ge=new w,dt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function tt(){return T===null?k:1}let W=i;function Ne(I,U){for(let H=0;H<I.length;H++){const q=I[H],X=t.getContext(q,U);if(X!==null)return X}return null}try{const I={alpha:!0,depth:n,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${fc}`),t.addEventListener("webglcontextlost",ae,!1),t.addEventListener("webglcontextrestored",Z,!1),t.addEventListener("webglcontextcreationerror",Be,!1),W===null){const U=["webgl2","webgl","experimental-webgl"];if(y.isWebGL1Renderer===!0&&U.shift(),W=Ne(U,I),W===null)throw Ne(U)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&W instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),W.getShaderPrecisionFormat===void 0&&(W.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(I){throw console.error("THREE.WebGLRenderer: "+I.message),I}let ye,ke,Se,$e,Je,st,Bt,N,D,fe,ve,Ie,Ee,vt,at,Oe,He,yt,Le,Kt,lt,qe,ct,nt;function Tt(){ye=new m5(W),ke=new h5(W,ye,e),ye.init(ke),qe=new TF(W,ye,ke),Se=new J6(W,ye,ke),$e=new A5(W),Je=new U6,st=new K6(W,ye,Se,Je,ke,qe,$e),Bt=new d5(y),N=new p5(y),D=new CQ(W,ke),ct=new l5(W,ye,D,ke),fe=new g5(W,D,$e,ct),ve=new x5(W,fe,D,$e),Le=new b5(W,ke,st),Oe=new u5(Je),Ie=new F6(y,Bt,N,ye,ke,ct,Oe),Ee=new sj(y,Je),vt=new z6,at=new W6(ye,ke),yt=new a5(y,Bt,N,Se,ve,f,l),He=new Y6(y,ve,ke),nt=new rj(W,$e,ke,Se),Kt=new c5(W,ye,$e,ke),lt=new v5(W,ye,$e,ke),$e.programs=Ie.programs,y.capabilities=ke,y.extensions=ye,y.properties=Je,y.renderLists=vt,y.shadowMap=He,y.state=Se,y.info=$e}Tt();const j=new ij(y,W);this.xr=j,this.getContext=function(){return W},this.getContextAttributes=function(){return W.getContextAttributes()},this.forceContextLoss=function(){const I=ye.get("WEBGL_lose_context");I&&I.loseContext()},this.forceContextRestore=function(){const I=ye.get("WEBGL_lose_context");I&&I.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(I){I!==void 0&&(k=I,this.setSize(V,L,!1))},this.getSize=function(I){return I.set(V,L)},this.setSize=function(I,U,H=!0){if(j.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}V=I,L=U,t.width=Math.floor(I*k),t.height=Math.floor(U*k),H===!0&&(t.style.width=I+"px",t.style.height=U+"px"),this.setViewport(0,0,I,U)},this.getDrawingBufferSize=function(I){return I.set(V*k,L*k).floor()},this.setDrawingBufferSize=function(I,U,H){V=I,L=U,k=H,t.width=Math.floor(I*H),t.height=Math.floor(U*H),this.setViewport(0,0,I,U)},this.getCurrentViewport=function(I){return I.copy(S)},this.getViewport=function(I){return I.copy($)},this.setViewport=function(I,U,H,q){I.isVector4?$.set(I.x,I.y,I.z,I.w):$.set(I,U,H,q),Se.viewport(S.copy($).multiplyScalar(k).round())},this.getScissor=function(I){return I.copy(re)},this.setScissor=function(I,U,H,q){I.isVector4?re.set(I.x,I.y,I.z,I.w):re.set(I,U,H,q),Se.scissor(R.copy(re).multiplyScalar(k).round())},this.getScissorTest=function(){return ce},this.setScissorTest=function(I){Se.setScissorTest(ce=I)},this.setOpaqueSort=function(I){G=I},this.setTransparentSort=function(I){Y=I},this.getClearColor=function(I){return I.copy(yt.getClearColor())},this.setClearColor=function(){yt.setClearColor.apply(yt,arguments)},this.getClearAlpha=function(){return yt.getClearAlpha()},this.setClearAlpha=function(){yt.setClearAlpha.apply(yt,arguments)},this.clear=function(I=!0,U=!0,H=!0){let q=0;if(I){let X=!1;if(T!==null){const de=T.texture.format;X=de===nT||de===iT||de===tT}if(X){const de=T.texture.type,he=de===di||de===fa||de===tx||de===ac||de===$M||de===eT,Ae=yt.getClearColor(),Pe=yt.getClearAlpha(),De=Ae.r,Qe=Ae.g,Ye=Ae.b;he?(p[0]=De,p[1]=Qe,p[2]=Ye,p[3]=Pe,W.clearBufferuiv(W.COLOR,0,p)):(m[0]=De,m[1]=Qe,m[2]=Ye,m[3]=Pe,W.clearBufferiv(W.COLOR,0,m))}else q|=W.COLOR_BUFFER_BIT}U&&(q|=W.DEPTH_BUFFER_BIT),H&&(q|=W.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),W.clear(q)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",ae,!1),t.removeEventListener("webglcontextrestored",Z,!1),t.removeEventListener("webglcontextcreationerror",Be,!1),vt.dispose(),at.dispose(),Je.dispose(),Bt.dispose(),N.dispose(),ve.dispose(),ct.dispose(),nt.dispose(),Ie.dispose(),j.dispose(),j.removeEventListener("sessionstart",ji),j.removeEventListener("sessionend",$t),be&&(be.dispose(),be=null),nn.stop()};function ae(I){I.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function Z(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;const I=$e.autoReset,U=He.enabled,H=He.autoUpdate,q=He.needsUpdate,X=He.type;Tt(),$e.autoReset=I,He.enabled=U,He.autoUpdate=H,He.needsUpdate=q,He.type=X}function Be(I){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",I.statusMessage)}function le(I){const U=I.target;U.removeEventListener("dispose",le),ze(U)}function ze(I){Xe(I),Je.remove(I)}function Xe(I){const U=Je.get(I).programs;U!==void 0&&(U.forEach(function(H){Ie.releaseProgram(H)}),I.isShaderMaterial&&Ie.releaseShaderCache(I))}this.renderBufferDirect=function(I,U,H,q,X,de){U===null&&(U=dt);const he=X.isMesh&&X.matrixWorld.determinant()<0,Ae=P(I,U,H,q,X);Se.setMaterial(q,he);let Pe=H.index,De=1;if(q.wireframe===!0){if(Pe=fe.getWireframeAttribute(H),Pe===void 0)return;De=2}const Qe=H.drawRange,Ye=H.attributes.position;let Ke=Qe.start*De,rt=(Qe.start+Qe.count)*De;de!==null&&(Ke=Math.max(Ke,de.start*De),rt=Math.min(rt,(de.start+de.count)*De)),Pe!==null?(Ke=Math.max(Ke,0),rt=Math.min(rt,Pe.count)):Ye!=null&&(Ke=Math.max(Ke,0),rt=Math.min(rt,Ye.count));const xt=rt-Ke;if(xt<0||xt===1/0)return;ct.setup(X,q,Ae,H,Pe);let fi,Gt=Kt;if(Pe!==null&&(fi=D.get(Pe),Gt=lt,Gt.setIndex(fi)),X.isMesh)q.wireframe===!0?(Se.setLineWidth(q.wireframeLinewidth*tt()),Gt.setMode(W.LINES)):Gt.setMode(W.TRIANGLES);else if(X.isLine){let Et=q.linewidth;Et===void 0&&(Et=1),Se.setLineWidth(Et*tt()),X.isLineSegments?Gt.setMode(W.LINES):X.isLineLoop?Gt.setMode(W.LINE_LOOP):Gt.setMode(W.LINE_STRIP)}else X.isPoints?Gt.setMode(W.POINTS):X.isSprite&&Gt.setMode(W.TRIANGLES);if(X.isBatchedMesh)Gt.renderMultiDraw(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount);else if(X.isInstancedMesh)Gt.renderInstances(Ke,xt,X.count);else if(H.isInstancedBufferGeometry){const Et=H._maxInstanceCount!==void 0?H._maxInstanceCount:1/0,Ei=Math.min(H.instanceCount,Et);Gt.renderInstances(Ke,xt,Ei)}else Gt.render(Ke,xt)};function Zt(I,U,H){I.transparent===!0&&I.side===mi&&I.forceSinglePass===!1?(I.side=_n,I.needsUpdate=!0,Jt(I,U,H),I.side=Bs,I.needsUpdate=!0,Jt(I,U,H),I.side=mi):Jt(I,U,H)}this.compile=function(I,U,H=null){H===null&&(H=I),v=at.get(H),v.init(),_.push(v),H.traverseVisible(function(X){X.isLight&&X.layers.test(U.layers)&&(v.pushLight(X),X.castShadow&&v.pushShadow(X))}),I!==H&&I.traverseVisible(function(X){X.isLight&&X.layers.test(U.layers)&&(v.pushLight(X),X.castShadow&&v.pushShadow(X))}),v.setupLights(y._useLegacyLights);const q=new Set;return I.traverse(function(X){const de=X.material;if(de)if(Array.isArray(de))for(let he=0;he<de.length;he++){const Ae=de[he];Zt(Ae,H,X),q.add(Ae)}else Zt(de,H,X),q.add(de)}),_.pop(),v=null,q},this.compileAsync=function(I,U,H=null){const q=this.compile(I,U,H);return new Promise(X=>{function de(){if(q.forEach(function(he){Je.get(he).currentProgram.isReady()&&q.delete(he)}),q.size===0){X(I);return}setTimeout(de,10)}ye.get("KHR_parallel_shader_compile")!==null?de():setTimeout(de,10)})};let _i=null;function Vi(I){_i&&_i(I)}function ji(){nn.stop()}function $t(){nn.start()}const nn=new xF;nn.setAnimationLoop(Vi),typeof self<"u"&&nn.setContext(self),this.setAnimationLoop=function(I){_i=I,j.setAnimationLoop(I),I===null?nn.stop():nn.start()},j.addEventListener("sessionstart",ji),j.addEventListener("sessionend",$t),this.render=function(I,U){if(U!==void 0&&U.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),j.enabled===!0&&j.isPresenting===!0&&(j.cameraAutoUpdate===!0&&j.updateCamera(U),U=j.getCamera()),I.isScene===!0&&I.onBeforeRender(y,I,U,T),v=at.get(I,_.length),v.init(),_.push(v),Ve.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Re.setFromProjectionMatrix(Ve),me=this.localClippingEnabled,ie=Oe.init(this.clippingPlanes,me),A=vt.get(I,g.length),A.init(),g.push(A),mn(I,U,0,y.sortObjects),A.finish(),y.sortObjects===!0&&A.sort(G,Y),this.info.render.frame++,ie===!0&&Oe.beginShadows();const H=v.state.shadowsArray;if(He.render(H,I,U),ie===!0&&Oe.endShadows(),this.info.autoReset===!0&&this.info.reset(),(j.enabled===!1||j.isPresenting===!1||j.hasDepthSensing()===!1)&&yt.render(A,I),v.setupLights(y._useLegacyLights),U.isArrayCamera){const q=U.cameras;for(let X=0,de=q.length;X<de;X++){const he=q[X];Wr(A,I,he,he.viewport)}}else Wr(A,I,U);T!==null&&(st.updateMultisampleRenderTarget(T),st.updateRenderTargetMipmap(T)),I.isScene===!0&&I.onAfterRender(y,I,U),ct.resetDefaultState(),C=-1,B=null,_.pop(),_.length>0?v=_[_.length-1]:v=null,g.pop(),g.length>0?A=g[g.length-1]:A=null};function mn(I,U,H,q){if(I.visible===!1)return;if(I.layers.test(U.layers)){if(I.isGroup)H=I.renderOrder;else if(I.isLOD)I.autoUpdate===!0&&I.update(U);else if(I.isLight)v.pushLight(I),I.castShadow&&v.pushShadow(I);else if(I.isSprite){if(!I.frustumCulled||Re.intersectsSprite(I)){q&&Ge.setFromMatrixPosition(I.matrixWorld).applyMatrix4(Ve);const he=ve.update(I),Ae=I.material;Ae.visible&&A.push(I,he,Ae,H,Ge.z,null)}}else if((I.isMesh||I.isLine||I.isPoints)&&(!I.frustumCulled||Re.intersectsObject(I))){const he=ve.update(I),Ae=I.material;if(q&&(I.boundingSphere!==void 0?(I.boundingSphere===null&&I.computeBoundingSphere(),Ge.copy(I.boundingSphere.center)):(he.boundingSphere===null&&he.computeBoundingSphere(),Ge.copy(he.boundingSphere.center)),Ge.applyMatrix4(I.matrixWorld).applyMatrix4(Ve)),Array.isArray(Ae)){const Pe=he.groups;for(let De=0,Qe=Pe.length;De<Qe;De++){const Ye=Pe[De],Ke=Ae[Ye.materialIndex];Ke&&Ke.visible&&A.push(I,he,Ke,H,Ge.z,Ye)}}else Ae.visible&&A.push(I,he,Ae,H,Ge.z,null)}}const de=I.children;for(let he=0,Ae=de.length;he<Ae;he++)mn(de[he],U,H,q)}function Wr(I,U,H,q){const X=I.opaque,de=I.transmissive,he=I.transparent;v.setupLightsView(H),ie===!0&&Oe.setGlobalState(y.clippingPlanes,H),de.length>0&&Bc(X,de,U,H),q&&Se.viewport(S.copy(q)),X.length>0&&qr(X,U,H),de.length>0&&qr(de,U,H),he.length>0&&qr(he,U,H),Se.buffers.depth.setTest(!0),Se.buffers.depth.setMask(!0),Se.buffers.color.setMask(!0),Se.setPolygonOffset(!1)}function Bc(I,U,H,q){if((H.isScene===!0?H.overrideMaterial:null)!==null)return;const de=ke.isWebGL2;be===null&&(be=new Yt(1,1,{generateMipmaps:!0,type:ye.has("EXT_color_buffer_half_float")?cn:di,minFilter:br,samples:de?4:0})),y.getDrawingBufferSize(je),de?be.setSize(je.x,je.y):be.setSize(eb(je.x),eb(je.y));const he=y.getRenderTarget();y.setRenderTarget(be),y.getClearColor(z),O=y.getClearAlpha(),O<1&&y.setClearColor(16777215,.5),y.clear();const Ae=y.toneMapping;y.toneMapping=ho,qr(I,H,q),st.updateMultisampleRenderTarget(be),st.updateRenderTargetMipmap(be);let Pe=!1;for(let De=0,Qe=U.length;De<Qe;De++){const Ye=U[De],Ke=Ye.object,rt=Ye.geometry,xt=Ye.material,fi=Ye.group;if(xt.side===mi&&Ke.layers.test(q.layers)){const Gt=xt.side;xt.side=_n,xt.needsUpdate=!0,Dc(Ke,H,q,rt,xt,fi),xt.side=Gt,xt.needsUpdate=!0,Pe=!0}}Pe===!0&&(st.updateMultisampleRenderTarget(be),st.updateRenderTargetMipmap(be)),y.setRenderTarget(he),y.setClearColor(z,O),y.toneMapping=Ae}function qr(I,U,H){const q=U.isScene===!0?U.overrideMaterial:null;for(let X=0,de=I.length;X<de;X++){const he=I[X],Ae=he.object,Pe=he.geometry,De=q===null?he.material:q,Qe=he.group;Ae.layers.test(H.layers)&&Dc(Ae,U,H,Pe,De,Qe)}}function Dc(I,U,H,q,X,de){I.onBeforeRender(y,U,H,q,X,de),I.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,I.matrixWorld),I.normalMatrix.getNormalMatrix(I.modelViewMatrix),X.onBeforeRender(y,U,H,q,I,de),X.transparent===!0&&X.side===mi&&X.forceSinglePass===!1?(X.side=_n,X.needsUpdate=!0,y.renderBufferDirect(H,U,q,X,I,de),X.side=Bs,X.needsUpdate=!0,y.renderBufferDirect(H,U,q,X,I,de),X.side=mi):y.renderBufferDirect(H,U,q,X,I,de),I.onAfterRender(y,U,H,q,X,de)}function Jt(I,U,H){U.isScene!==!0&&(U=dt);const q=Je.get(I),X=v.state.lights,de=v.state.shadowsArray,he=X.state.version,Ae=Ie.getParameters(I,X.state,de,U,H),Pe=Ie.getProgramCacheKey(Ae);let De=q.programs;q.environment=I.isMeshStandardMaterial?U.environment:null,q.fog=U.fog,q.envMap=(I.isMeshStandardMaterial?N:Bt).get(I.envMap||q.environment),q.envMapRotation=q.environment!==null&&I.envMap===null?U.environmentRotation:I.envMapRotation,De===void 0&&(I.addEventListener("dispose",le),De=new Map,q.programs=De);let Qe=De.get(Pe);if(Qe!==void 0){if(q.currentProgram===Qe&&q.lightsStateVersion===he)return fy(I,Ae),Qe}else Ae.uniforms=Ie.getUniforms(I),I.onBuild(H,Ae,y),I.onBeforeCompile(Ae,y),Qe=Ie.acquireProgram(Ae,Pe),De.set(Pe,Qe),q.uniforms=Ae.uniforms;const Ye=q.uniforms;return(!I.isShaderMaterial&&!I.isRawShaderMaterial||I.clipping===!0)&&(Ye.clippingPlanes=Oe.uniform),fy(I,Ae),q.needsLights=J(I),q.lightsStateVersion=he,q.needsLights&&(Ye.ambientLightColor.value=X.state.ambient,Ye.lightProbe.value=X.state.probe,Ye.directionalLights.value=X.state.directional,Ye.directionalLightShadows.value=X.state.directionalShadow,Ye.spotLights.value=X.state.spot,Ye.spotLightShadows.value=X.state.spotShadow,Ye.rectAreaLights.value=X.state.rectArea,Ye.ltc_1.value=X.state.rectAreaLTC1,Ye.ltc_2.value=X.state.rectAreaLTC2,Ye.pointLights.value=X.state.point,Ye.pointLightShadows.value=X.state.pointShadow,Ye.hemisphereLights.value=X.state.hemi,Ye.directionalShadowMap.value=X.state.directionalShadowMap,Ye.directionalShadowMatrix.value=X.state.directionalShadowMatrix,Ye.spotShadowMap.value=X.state.spotShadowMap,Ye.spotLightMatrix.value=X.state.spotLightMatrix,Ye.spotLightMap.value=X.state.spotLightMap,Ye.pointShadowMap.value=X.state.pointShadowMap,Ye.pointShadowMatrix.value=X.state.pointShadowMatrix),q.currentProgram=Qe,q.uniformsList=null,Qe}function dm(I){if(I.uniformsList===null){const U=I.currentProgram.getUniforms();I.uniformsList=c_.seqWithValue(U.seq,I.uniforms)}return I.uniformsList}function fy(I,U){const H=Je.get(I);H.outputColorSpace=U.outputColorSpace,H.batching=U.batching,H.instancing=U.instancing,H.instancingColor=U.instancingColor,H.instancingMorph=U.instancingMorph,H.skinning=U.skinning,H.morphTargets=U.morphTargets,H.morphNormals=U.morphNormals,H.morphColors=U.morphColors,H.morphTargetsCount=U.morphTargetsCount,H.numClippingPlanes=U.numClippingPlanes,H.numIntersection=U.numClipIntersection,H.vertexAlphas=U.vertexAlphas,H.vertexTangents=U.vertexTangents,H.toneMapping=U.toneMapping}function P(I,U,H,q,X){U.isScene!==!0&&(U=dt),st.resetTextureUnits();const de=U.fog,he=q.isMeshStandardMaterial?U.environment:null,Ae=T===null?y.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:yi,Pe=(q.isMeshStandardMaterial?N:Bt).get(q.envMap||he),De=q.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,Qe=!!H.attributes.tangent&&(!!q.normalMap||q.anisotropy>0),Ye=!!H.morphAttributes.position,Ke=!!H.morphAttributes.normal,rt=!!H.morphAttributes.color;let xt=ho;q.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(xt=y.toneMapping);const fi=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Gt=fi!==void 0?fi.length:0,Et=Je.get(q),Ei=v.state.lights;if(ie===!0&&(me===!0||I!==B)){const sn=I===B&&q.id===C;Oe.setState(q,I,sn)}let _t=!1;q.version===Et.__version?(Et.needsLights&&Et.lightsStateVersion!==Ei.state.version||Et.outputColorSpace!==Ae||X.isBatchedMesh&&Et.batching===!1||!X.isBatchedMesh&&Et.batching===!0||X.isInstancedMesh&&Et.instancing===!1||!X.isInstancedMesh&&Et.instancing===!0||X.isSkinnedMesh&&Et.skinning===!1||!X.isSkinnedMesh&&Et.skinning===!0||X.isInstancedMesh&&Et.instancingColor===!0&&X.instanceColor===null||X.isInstancedMesh&&Et.instancingColor===!1&&X.instanceColor!==null||X.isInstancedMesh&&Et.instancingMorph===!0&&X.morphTexture===null||X.isInstancedMesh&&Et.instancingMorph===!1&&X.morphTexture!==null||Et.envMap!==Pe||q.fog===!0&&Et.fog!==de||Et.numClippingPlanes!==void 0&&(Et.numClippingPlanes!==Oe.numPlanes||Et.numIntersection!==Oe.numIntersection)||Et.vertexAlphas!==De||Et.vertexTangents!==Qe||Et.morphTargets!==Ye||Et.morphNormals!==Ke||Et.morphColors!==rt||Et.toneMapping!==xt||ke.isWebGL2===!0&&Et.morphTargetsCount!==Gt)&&(_t=!0):(_t=!0,Et.__version=q.version);let Ri=Et.currentProgram;_t===!0&&(Ri=Jt(q,U,X));let ar=!1,Wi=!1,ui=!1;const jt=Ri.getUniforms(),gs=Et.uniforms;if(Se.useProgram(Ri.program)&&(ar=!0,Wi=!0,ui=!0),q.id!==C&&(C=q.id,Wi=!0),ar||B!==I){jt.setValue(W,"projectionMatrix",I.projectionMatrix),jt.setValue(W,"viewMatrix",I.matrixWorldInverse);const sn=jt.map.cameraPosition;sn!==void 0&&sn.setValue(W,Ge.setFromMatrixPosition(I.matrixWorld)),ke.logarithmicDepthBuffer&&jt.setValue(W,"logDepthBufFC",2/(Math.log(I.far+1)/Math.LN2)),(q.isMeshPhongMaterial||q.isMeshToonMaterial||q.isMeshLambertMaterial||q.isMeshBasicMaterial||q.isMeshStandardMaterial||q.isShaderMaterial)&&jt.setValue(W,"isOrthographic",I.isOrthographicCamera===!0),B!==I&&(B=I,Wi=!0,ui=!0)}if(X.isSkinnedMesh){jt.setOptional(W,X,"bindMatrix"),jt.setOptional(W,X,"bindMatrixInverse");const sn=X.skeleton;sn&&(ke.floatVertexTextures?(sn.boneTexture===null&&sn.computeBoneTexture(),jt.setValue(W,"boneTexture",sn.boneTexture,st)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}X.isBatchedMesh&&(jt.setOptional(W,X,"batchingTexture"),jt.setValue(W,"batchingTexture",X._matricesTexture,st));const Sl=H.morphAttributes;if((Sl.position!==void 0||Sl.normal!==void 0||Sl.color!==void 0&&ke.isWebGL2===!0)&&Le.update(X,H,Ri),(Wi||Et.receiveShadow!==X.receiveShadow)&&(Et.receiveShadow=X.receiveShadow,jt.setValue(W,"receiveShadow",X.receiveShadow)),q.isMeshGouraudMaterial&&q.envMap!==null&&(gs.envMap.value=Pe,gs.flipEnvMap.value=Pe.isCubeTexture&&Pe.isRenderTargetTexture===!1?-1:1),Wi&&(jt.setValue(W,"toneMappingExposure",y.toneMappingExposure),Et.needsLights&&F(gs,ui),de&&q.fog===!0&&Ee.refreshFogUniforms(gs,de),Ee.refreshMaterialUniforms(gs,q,k,L,be),c_.upload(W,dm(Et),gs,st)),q.isShaderMaterial&&q.uniformsNeedUpdate===!0&&(c_.upload(W,dm(Et),gs,st),q.uniformsNeedUpdate=!1),q.isSpriteMaterial&&jt.setValue(W,"center",X.center),jt.setValue(W,"modelViewMatrix",X.modelViewMatrix),jt.setValue(W,"normalMatrix",X.normalMatrix),jt.setValue(W,"modelMatrix",X.matrixWorld),q.isShaderMaterial||q.isRawShaderMaterial){const sn=q.uniformsGroups;for(let Oc=0,yH=sn.length;Oc<yH;Oc++)if(ke.isWebGL2){const IP=sn[Oc];nt.update(IP,Ri),nt.bind(IP,Ri)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Ri}function F(I,U){I.ambientLightColor.needsUpdate=U,I.lightProbe.needsUpdate=U,I.directionalLights.needsUpdate=U,I.directionalLightShadows.needsUpdate=U,I.pointLights.needsUpdate=U,I.pointLightShadows.needsUpdate=U,I.spotLights.needsUpdate=U,I.spotLightShadows.needsUpdate=U,I.rectAreaLights.needsUpdate=U,I.hemisphereLights.needsUpdate=U}function J(I){return I.isMeshLambertMaterial||I.isMeshToonMaterial||I.isMeshPhongMaterial||I.isMeshStandardMaterial||I.isShadowMaterial||I.isShaderMaterial&&I.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(I,U,H){Je.get(I.texture).__webglTexture=U,Je.get(I.depthTexture).__webglTexture=H;const q=Je.get(I);q.__hasExternalTextures=!0,q.__autoAllocateDepthBuffer=H===void 0,q.__autoAllocateDepthBuffer||ye.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),q.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(I,U){const H=Je.get(I);H.__webglFramebuffer=U,H.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(I,U=0,H=0){T=I,E=U,M=H;let q=!0,X=null,de=!1,he=!1;if(I){const Pe=Je.get(I);Pe.__useDefaultFramebuffer!==void 0?(Se.bindFramebuffer(W.FRAMEBUFFER,null),q=!1):Pe.__webglFramebuffer===void 0?st.setupRenderTarget(I):Pe.__hasExternalTextures&&st.rebindTextures(I,Je.get(I.texture).__webglTexture,Je.get(I.depthTexture).__webglTexture);const De=I.texture;(De.isData3DTexture||De.isDataArrayTexture||De.isCompressedArrayTexture)&&(he=!0);const Qe=Je.get(I).__webglFramebuffer;I.isWebGLCubeRenderTarget?(Array.isArray(Qe[U])?X=Qe[U][H]:X=Qe[U],de=!0):ke.isWebGL2&&I.samples>0&&st.useMultisampledRTT(I)===!1?X=Je.get(I).__webglMultisampledFramebuffer:Array.isArray(Qe)?X=Qe[H]:X=Qe,S.copy(I.viewport),R.copy(I.scissor),Q=I.scissorTest}else S.copy($).multiplyScalar(k).floor(),R.copy(re).multiplyScalar(k).floor(),Q=ce;if(Se.bindFramebuffer(W.FRAMEBUFFER,X)&&ke.drawBuffers&&q&&Se.drawBuffers(I,X),Se.viewport(S),Se.scissor(R),Se.setScissorTest(Q),de){const Pe=Je.get(I.texture);W.framebufferTexture2D(W.FRAMEBUFFER,W.COLOR_ATTACHMENT0,W.TEXTURE_CUBE_MAP_POSITIVE_X+U,Pe.__webglTexture,H)}else if(he){const Pe=Je.get(I.texture),De=U||0;W.framebufferTextureLayer(W.FRAMEBUFFER,W.COLOR_ATTACHMENT0,Pe.__webglTexture,H||0,De)}C=-1},this.readRenderTargetPixels=function(I,U,H,q,X,de,he){if(!(I&&I.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ae=Je.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget&&he!==void 0&&(Ae=Ae[he]),Ae){Se.bindFramebuffer(W.FRAMEBUFFER,Ae);try{const Pe=I.texture,De=Pe.format,Qe=Pe.type;if(De!==Ai&&qe.convert(De)!==W.getParameter(W.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ye=Qe===cn&&(ye.has("EXT_color_buffer_half_float")||ke.isWebGL2&&ye.has("EXT_color_buffer_float"));if(Qe!==di&&qe.convert(Qe)!==W.getParameter(W.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Qe===Ni&&(ke.isWebGL2||ye.has("OES_texture_float")||ye.has("WEBGL_color_buffer_float")))&&!Ye){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=I.width-q&&H>=0&&H<=I.height-X&&W.readPixels(U,H,q,X,qe.convert(De),qe.convert(Qe),de)}finally{const Pe=T!==null?Je.get(T).__webglFramebuffer:null;Se.bindFramebuffer(W.FRAMEBUFFER,Pe)}}},this.copyFramebufferToTexture=function(I,U,H=0){const q=Math.pow(2,-H),X=Math.floor(U.image.width*q),de=Math.floor(U.image.height*q);st.setTexture2D(U,0),W.copyTexSubImage2D(W.TEXTURE_2D,H,0,0,I.x,I.y,X,de),Se.unbindTexture()},this.copyTextureToTexture=function(I,U,H,q=0){const X=U.image.width,de=U.image.height,he=qe.convert(H.format),Ae=qe.convert(H.type);st.setTexture2D(H,0),W.pixelStorei(W.UNPACK_FLIP_Y_WEBGL,H.flipY),W.pixelStorei(W.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),W.pixelStorei(W.UNPACK_ALIGNMENT,H.unpackAlignment),U.isDataTexture?W.texSubImage2D(W.TEXTURE_2D,q,I.x,I.y,X,de,he,Ae,U.image.data):U.isCompressedTexture?W.compressedTexSubImage2D(W.TEXTURE_2D,q,I.x,I.y,U.mipmaps[0].width,U.mipmaps[0].height,he,U.mipmaps[0].data):W.texSubImage2D(W.TEXTURE_2D,q,I.x,I.y,he,Ae,U.image),q===0&&H.generateMipmaps&&W.generateMipmap(W.TEXTURE_2D),Se.unbindTexture()},this.copyTextureToTexture3D=function(I,U,H,q,X=0){if(y.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const de=Math.round(I.max.x-I.min.x),he=Math.round(I.max.y-I.min.y),Ae=I.max.z-I.min.z+1,Pe=qe.convert(q.format),De=qe.convert(q.type);let Qe;if(q.isData3DTexture)st.setTexture3D(q,0),Qe=W.TEXTURE_3D;else if(q.isDataArrayTexture||q.isCompressedArrayTexture)st.setTexture2DArray(q,0),Qe=W.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}W.pixelStorei(W.UNPACK_FLIP_Y_WEBGL,q.flipY),W.pixelStorei(W.UNPACK_PREMULTIPLY_ALPHA_WEBGL,q.premultiplyAlpha),W.pixelStorei(W.UNPACK_ALIGNMENT,q.unpackAlignment);const Ye=W.getParameter(W.UNPACK_ROW_LENGTH),Ke=W.getParameter(W.UNPACK_IMAGE_HEIGHT),rt=W.getParameter(W.UNPACK_SKIP_PIXELS),xt=W.getParameter(W.UNPACK_SKIP_ROWS),fi=W.getParameter(W.UNPACK_SKIP_IMAGES),Gt=H.isCompressedTexture?H.mipmaps[X]:H.image;W.pixelStorei(W.UNPACK_ROW_LENGTH,Gt.width),W.pixelStorei(W.UNPACK_IMAGE_HEIGHT,Gt.height),W.pixelStorei(W.UNPACK_SKIP_PIXELS,I.min.x),W.pixelStorei(W.UNPACK_SKIP_ROWS,I.min.y),W.pixelStorei(W.UNPACK_SKIP_IMAGES,I.min.z),H.isDataTexture||H.isData3DTexture?W.texSubImage3D(Qe,X,U.x,U.y,U.z,de,he,Ae,Pe,De,Gt.data):q.isCompressedArrayTexture?W.compressedTexSubImage3D(Qe,X,U.x,U.y,U.z,de,he,Ae,Pe,Gt.data):W.texSubImage3D(Qe,X,U.x,U.y,U.z,de,he,Ae,Pe,De,Gt),W.pixelStorei(W.UNPACK_ROW_LENGTH,Ye),W.pixelStorei(W.UNPACK_IMAGE_HEIGHT,Ke),W.pixelStorei(W.UNPACK_SKIP_PIXELS,rt),W.pixelStorei(W.UNPACK_SKIP_ROWS,xt),W.pixelStorei(W.UNPACK_SKIP_IMAGES,fi),X===0&&q.generateMipmaps&&W.generateMipmap(Qe),Se.unbindTexture()},this.initTexture=function(I){I.isCubeTexture?st.setTextureCube(I,0):I.isData3DTexture?st.setTexture3D(I,0):I.isDataArrayTexture||I.isCompressedArrayTexture?st.setTexture2DArray(I,0):st.setTexture2D(I,0),Se.unbindTexture()},this.resetState=function(){E=0,M=0,T=null,Se.reset(),ct.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Za}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Vv?"display-p3":"srgb",t.unpackColorSpace=vi.workingColorSpace===Mp?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===gt?i1:Xk}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===i1?gt:yi}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class IF extends _c{}IF.prototype.isWebGL1Renderer=!0;class cx{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new xe(e),this.density=t}clone(){return new cx(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let hx=class RF{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new xe(e),this.near=t,this.far=i}clone(){return new RF(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class ir extends ge{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Gi,this.environmentRotation=new Gi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Yv{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=sv,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=uo()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return AF("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=t.array[i+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=uo()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=uo()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const lr=new w;class xr{constructor(e,t,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)lr.fromBufferAttribute(this,t),lr.applyMatrix4(e),this.setXYZ(t,lr.x,lr.y,lr.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)lr.fromBufferAttribute(this,t),lr.applyNormalMatrix(e),this.setXYZ(t,lr.x,lr.y,lr.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)lr.fromBufferAttribute(this,t),lr.transformDirection(e),this.setXYZ(t,lr.x,lr.y,lr.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=yr(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=qt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=qt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=qt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=qt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=qt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=yr(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=yr(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=yr(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=yr(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array),n=qt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=qt(t,this.array),i=qt(i,this.array),n=qt(n,this.array),r=qt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return new it(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new xr(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class vT extends Nt{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new xe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let of;const vm=new w,af=new w,lf=new w,cf=new te,Am=new te,PF=new we,Ly=new w,ym=new w,ky=new w,yB=new te,CS=new te,_B=new te;let BF=class extends ge{constructor(e=new vT){if(super(),this.isSprite=!0,this.type="Sprite",of===void 0){of=new wt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Yv(t,5);of.setIndex([0,1,2,0,2,3]),of.setAttribute("position",new xr(i,3,0,!1)),of.setAttribute("uv",new xr(i,2,3,!1))}this.geometry=of,this.material=e,this.center=new te(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),af.setFromMatrixScale(this.matrixWorld),PF.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),lf.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&af.multiplyScalar(-lf.z);const i=this.material.rotation;let n,r;i!==0&&(r=Math.cos(i),n=Math.sin(i));const o=this.center;Fy(Ly.set(-.5,-.5,0),lf,o,af,n,r),Fy(ym.set(.5,-.5,0),lf,o,af,n,r),Fy(ky.set(.5,.5,0),lf,o,af,n,r),yB.set(0,0),CS.set(1,0),_B.set(1,1);let a=e.ray.intersectTriangle(Ly,ym,ky,!1,vm);if(a===null&&(Fy(ym.set(-.5,.5,0),lf,o,af,n,r),CS.set(0,1),a=e.ray.intersectTriangle(Ly,ky,ym,!1,vm),a===null))return;const l=e.ray.origin.distanceTo(vm);l<e.near||l>e.far||t.push({distance:l,point:vm.clone(),uv:_r.getInterpolation(vm,Ly,ym,ky,yB,CS,_B,new te),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function Fy(s,e,t,i,n,r){cf.subVectors(s,t).addScalar(.5).multiply(i),n!==void 0?(Am.x=r*cf.x-n*cf.y,Am.y=n*cf.x+r*cf.y):Am.copy(cf),s.copy(e),s.x+=Am.x,s.y+=Am.y,s.applyMatrix4(PF)}const Uy=new w,bB=new w;let AT=class extends ge{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,n=t.length;i<n;i++){const r=t[i];this.addLevel(r.object.clone(),r.distance,r.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const n=this.levels;let r;for(r=0;r<n.length&&!(t<n[r].distance);r++);return n.splice(r,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,n;for(i=1,n=t.length;i<n;i++){let r=t[i].distance;if(t[i].object.visible&&(r-=r*t[i].hysteresis),e<r)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Uy.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(Uy);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Uy.setFromMatrixPosition(e.matrixWorld),bB.setFromMatrixPosition(this.matrixWorld);const i=Uy.distanceTo(bB)/e.zoom;t[0].object.visible=!0;let n,r;for(n=1,r=t.length;n<r;n++){let o=t[n].distance;if(t[n].object.visible&&(o-=o*t[n].hysteresis),i>=o)t[n-1].object.visible=!1,t[n].object.visible=!0;else break}for(this._currentLevel=n-1;n<r;n++)t[n].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let n=0,r=i.length;n<r;n++){const o=i[n];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}};const xB=new w,wB=new Ze,SB=new Ze,oj=new w,CB=new we,Ny=new w,ES=new In,EB=new we,MS=new Hr;class ga extends pe{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=kE,this.bindMatrix=new we,this.bindMatrixInverse=new we,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ti),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Ny),this.boundingBox.expandByPoint(Ny)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new In),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Ny),this.boundingSphere.expandByPoint(Ny)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ES.copy(this.boundingSphere),ES.applyMatrix4(n),e.ray.intersectsSphere(ES)!==!1&&(EB.copy(n).invert(),MS.copy(e.ray).applyMatrix4(EB),!(this.boundingBox!==null&&MS.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,MS)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Ze,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.fromBufferAttribute(t,i);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===kE?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===zk?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;wB.fromBufferAttribute(n.attributes.skinIndex,e),SB.fromBufferAttribute(n.attributes.skinWeight,e),xB.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const o=SB.getComponent(r);if(o!==0){const a=wB.getComponent(r);CB.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(oj.copy(xB).applyMatrix4(CB),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Jv extends ge{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Nr extends Dt{constructor(e=null,t=1,i=1,n,r,o,a,l,c=Ht,u=Ht,d,f){super(null,o,a,l,c,u,n,r,d,f),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const MB=new we,aj=new we;class Pp{constructor(e=[],t=[]){this.uuid=uo(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new we)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new we;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let r=0,o=e.length;r<o;r++){const a=e[r]?e[r].matrixWorld:aj;MB.multiplyMatrices(a,t[r]),MB.toArray(i,r*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new Pp(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new Nr(t,e,e,Ai,Ni);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){const r=e.bones[i];let o=t[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new Jv),this.bones.push(o),this.boneInverses.push(new we().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let n=0,r=t.length;n<r;n++){const o=t[n];e.bones.push(o.uuid);const a=i[n];e.boneInverses.push(a.toArray())}return e}}class Lr extends it{constructor(e,t,i,n=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const hf=new we,TB=new we,zy=[],IB=new Ti,lj=new we,_m=new pe,bm=new In;class ux extends pe{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Lr(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,lj)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Ti),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,hf),IB.copy(e.boundingBox).applyMatrix4(hf),this.boundingBox.union(IB)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new In),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,hf),bm.copy(e.boundingSphere).applyMatrix4(hf),this.boundingSphere.union(bm)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,n=this.morphTexture.source.data.data,r=i.length+1,o=e*r+1;for(let a=0;a<i.length;a++)i[a]=n[o+a]}raycast(e,t){const i=this.matrixWorld,n=this.count;if(_m.geometry=this.geometry,_m.material=this.material,_m.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),bm.copy(this.boundingSphere),bm.applyMatrix4(i),e.ray.intersectsSphere(bm)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,hf),TB.multiplyMatrices(i,hf),_m.matrixWorld=TB,_m.raycast(e,zy);for(let o=0,a=zy.length;o<a;o++){const l=zy[o];l.instanceId=r,l.object=this,t.push(l)}zy.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Lr(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new Nr(new Float32Array(n*this.count),n,this.count,pa,Ni));const r=this.morphTexture.source.data.data;let o=0;for(let c=0;c<i.length;c++)o+=i[c];const a=this.geometry.morphTargetsRelative?1:1-o,l=n*e;r[l]=a,r.set(i,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}function cj(s,e){return s.z-e.z}function hj(s,e){return e.z-s.z}class uj{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t){const i=this.pool,n=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});const r=i[this.index];n.push(r),this.index++,r.start=e.start,r.count=e.count,r.z=t}reset(){this.list.length=0,this.index=0}}const uf="batchId",Gc=new we,RB=new we,dj=new we,PB=new we,TS=new qv,Gy=new Ti,ru=new In,xm=new w,IS=new uj,js=new pe,Hy=[];function fj(s,e,t=0){const i=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const n=s.count;for(let r=0;r<n;r++)for(let o=0;o<i;o++)e.setComponent(r+t,o,s.getComponent(r,o))}else e.array.set(s.array,t*i);e.needsUpdate=!0}class DF extends pe{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,i=t*2,n){super(new wt,n),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new Nr(t,e,e,Ai,Ni);this._matricesTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,n=this._maxGeometryCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const a in e.attributes){const l=e.getAttribute(a),{array:c,itemSize:u,normalized:d}=l,f=new c.constructor(i*u),p=new l.constructor(f,u,d);p.setUsage(l.usage),t.setAttribute(a,p)}if(e.getIndex()!==null){const a=i>65536?new Uint32Array(r):new Uint16Array(r);t.setIndex(new it(a,1))}const o=n>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(uf,new it(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(uf))throw new Error(`BatchedMesh: Geometry cannot use attribute "${uf}"`);const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(i===uf)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const n=e.getAttribute(i),r=t.getAttribute(i);if(n.itemSize!==r.itemSize||n.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ti);const e=this._geometryCount,t=this.boundingBox,i=this._active;t.makeEmpty();for(let n=0;n<e;n++)i[n]!==!1&&(this.getMatrixAt(n,Gc),this.getBoundingBoxAt(n,Gy).applyMatrix4(Gc),t.union(Gy))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new In);const e=this._geometryCount,t=this.boundingSphere,i=this._active;t.makeEmpty();for(let n=0;n<e;n++)i[n]!==!1&&(this.getMatrixAt(n,Gc),this.getBoundingSphereAt(n,ru).applyMatrix4(Gc),t.union(ru))}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const n={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let r=null;const o=this._reservedRanges,a=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(r=o[o.length-1]),t===-1?n.vertexCount=e.getAttribute("position").count:n.vertexCount=t,r===null?n.vertexStart=0:n.vertexStart=r.vertexStart+r.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(i===-1?n.indexCount=c.count:n.indexCount=i,r===null?n.indexStart=0:n.indexStart=r.indexStart+r.indexCount),n.indexStart!==-1&&n.indexStart+n.indexCount>this._maxIndexCount||n.vertexStart+n.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const d=this._visibility,f=this._active,p=this._matricesTexture,m=this._matricesTexture.image.data;d.push(!0),f.push(!0);const A=this._geometryCount;this._geometryCount++,dj.toArray(m,A*16),p.needsUpdate=!0,o.push(n),a.push({start:u?n.indexStart:n.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Ti,sphereInitialized:!1,sphere:new In});const v=this.geometry.getAttribute(uf);for(let g=0;g<n.vertexCount;g++)v.setX(n.vertexStart+g,A);return v.needsUpdate=!0,this.setGeometryAt(A,e),A}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,n=i.getIndex()!==null,r=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(n&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=a.vertexStart,c=a.vertexCount;for(const p in i.attributes){if(p===uf)continue;const m=t.getAttribute(p),A=i.getAttribute(p);fj(m,A,l);const v=m.itemSize;for(let g=m.count,_=c;g<_;g++){const y=l+g;for(let b=0;b<v;b++)A.setComponent(y,b,0)}A.needsUpdate=!0}if(n){const p=a.indexStart;for(let m=0;m<o.count;m++)r.setX(p+m,l+o.getX(m));for(let m=o.count,A=a.indexCount;m<A;m++)r.setX(p+m,l);r.needsUpdate=!0}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const d=this._drawRanges[e],f=t.getAttribute("position");return d.count=n?o.count:f.count,this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._active;return e>=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;const n=this._bounds[e],r=n.box,o=this.geometry;if(n.boxInitialized===!1){r.makeEmpty();const a=o.index,l=o.attributes.position,c=this._drawRanges[e];for(let u=c.start,d=c.start+c.count;u<d;u++){let f=u;a&&(f=a.getX(f)),r.expandByPoint(xm.fromBufferAttribute(l,f))}n.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(this._active[e]===!1)return null;const n=this._bounds[e],r=n.sphere,o=this.geometry;if(n.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,Gy),Gy.getCenter(r.center);const a=o.index,l=o.attributes.position,c=this._drawRanges[e];let u=0;for(let d=c.start,f=c.start+c.count;d<f;d++){let p=d;a&&(p=a.getX(p)),xm.fromBufferAttribute(l,p),u=Math.max(u,r.center.distanceToSquared(xm))}r.radius=Math.sqrt(u),n.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const i=this._active,n=this._matricesTexture,r=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||i[e]===!1?this:(t.toArray(r,e*16),n.needsUpdate=!0,this)}getMatrixAt(e,t){const i=this._active,n=this._matricesTexture.image.data,r=this._geometryCount;return e>=r||i[e]===!1?null:t.fromArray(n,e*16)}setVisibleAt(e,t){const i=this._visibility,n=this._active,r=this._geometryCount;return e>=r||n[e]===!1||i[e]===t?this:(i[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._visibility,i=this._active,n=this._geometryCount;return e>=n||i[e]===!1?!1:t[e]}raycast(e,t){const i=this._visibility,n=this._active,r=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,l=this.geometry;js.material=this.material,js.geometry.index=l.index,js.geometry.attributes=l.attributes,js.geometry.boundingBox===null&&(js.geometry.boundingBox=new Ti),js.geometry.boundingSphere===null&&(js.geometry.boundingSphere=new In);for(let c=0;c<o;c++){if(!i[c]||!n[c])continue;const u=r[c];js.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(c,js.matrixWorld).premultiply(a),this.getBoundingBoxAt(c,js.geometry.boundingBox),this.getBoundingSphereAt(c,js.geometry.boundingSphere),js.raycast(e,Hy);for(let d=0,f=Hy.length;d<f;d++){const p=Hy[d];p.object=this,p.batchId=c,t.push(p)}Hy.length=0}js.material=null,js.geometry.index=null,js.geometry.attributes={},js.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,i,n,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=n.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,l=this._active,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,p=this.perObjectFrustumCulled;p&&(PB.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),TS.setFromProjectionMatrix(PB,e.coordinateSystem));let m=0;if(this.sortObjects){RB.copy(this.matrixWorld).invert(),xm.setFromMatrixPosition(i.matrixWorld).applyMatrix4(RB);for(let g=0,_=c.length;g<_;g++)if(c[g]&&l[g]){this.getMatrixAt(g,Gc),this.getBoundingSphereAt(g,ru).applyMatrix4(Gc);let y=!1;if(p&&(y=!TS.intersectsSphere(ru)),!y){const b=xm.distanceTo(ru.center);IS.push(f[g],b)}}const A=IS.list,v=this.customSort;v===null?A.sort(r.transparent?hj:cj):v.call(this,A,i);for(let g=0,_=A.length;g<_;g++){const y=A[g];u[m]=y.start*a,d[m]=y.count,m++}IS.reset()}else for(let A=0,v=c.length;A<v;A++)if(c[A]&&l[A]){let g=!1;if(p&&(this.getMatrixAt(A,Gc),this.getBoundingSphereAt(A,ru).applyMatrix4(Gc),g=!TS.intersectsSphere(ru)),!g){const _=f[A];u[m]=_.start*a,d[m]=_.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,t,i,n,r,o){this.onBeforeRender(e,null,n,r,o)}}class Rn extends Nt{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const BB=new w,DB=new w,OB=new we,RS=new Hr,Qy=new In;let Mn=class extends ge{constructor(e=new wt,t=new Rn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let n=1,r=t.count;n<r;n++)BB.fromBufferAttribute(t,n-1),DB.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=BB.distanceTo(DB);e.setAttribute("lineDistance",new ut(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Qy.copy(i.boundingSphere),Qy.applyMatrix4(n),Qy.radius+=r,e.ray.intersectsSphere(Qy)===!1)return;OB.copy(n).invert(),RS.copy(e.ray).applyMatrix4(OB);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new w,u=new w,d=new w,f=new w,p=this.isLineSegments?2:1,m=i.index,v=i.attributes.position;if(m!==null){const g=Math.max(0,o.start),_=Math.min(m.count,o.start+o.count);for(let y=g,b=_-1;y<b;y+=p){const E=m.getX(y),M=m.getX(y+1);if(c.fromBufferAttribute(v,E),u.fromBufferAttribute(v,M),RS.distanceSqToSegment(c,u,f,d)>l)continue;f.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(f);C<e.near||C>e.far||t.push({distance:C,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{const g=Math.max(0,o.start),_=Math.min(v.count,o.start+o.count);for(let y=g,b=_-1;y<b;y+=p){if(c.fromBufferAttribute(v,y),u.fromBufferAttribute(v,y+1),RS.distanceSqToSegment(c,u,f,d)>l)continue;f.applyMatrix4(this.matrixWorld);const M=e.ray.origin.distanceTo(f);M<e.near||M>e.far||t.push({distance:M,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};const LB=new w,kB=new w;class Ao extends Mn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let n=0,r=t.count;n<r;n+=2)LB.fromBufferAttribute(t,n),kB.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+LB.distanceTo(kB);e.setAttribute("lineDistance",new ut(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class yT extends Mn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class dx extends Nt{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new xe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const FB=new we,a1=new Hr,Vy=new In,jy=new w;class _T extends ge{constructor(e=new wt,t=new dx){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Vy.copy(i.boundingSphere),Vy.applyMatrix4(n),Vy.radius+=r,e.ray.intersectsSphere(Vy)===!1)return;FB.copy(n).invert(),a1.copy(e.ray).applyMatrix4(FB);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=i.index,d=i.attributes.position;if(c!==null){const f=Math.max(0,o.start),p=Math.min(c.count,o.start+o.count);for(let m=f,A=p;m<A;m++){const v=c.getX(m);jy.fromBufferAttribute(d,v),UB(jy,v,l,n,e,t,this)}}else{const f=Math.max(0,o.start),p=Math.min(d.count,o.start+o.count);for(let m=f,A=p;m<A;m++)jy.fromBufferAttribute(d,m),UB(jy,m,l,n,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function UB(s,e,t,i,n,r,o){const a=a1.distanceSqToPoint(s);if(a<t){const l=new w;a1.closestPointToPoint(s,l),l.applyMatrix4(i);const c=n.ray.origin.distanceTo(l);if(c<n.near||c>n.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class OF extends Dt{constructor(e,t,i,n,r,o,a,l,c){super(e,t,i,n,r,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Mt,this.magFilter=r!==void 0?r:Mt,this.generateMipmaps=!1;const u=this;function d(){u.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class pj extends Dt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ht,this.minFilter=Ht,this.generateMipmaps=!1,this.needsUpdate=!0}}class rl extends Dt{constructor(e,t,i,n,r,o,a,l,c,u,d,f){super(null,o,a,l,c,u,n,r,d,f),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class LF extends rl{constructor(e,t,i,n,r,o){super(e,t,i,r,o),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=us}}class kF extends rl{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,pc),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class bT extends Dt{constructor(e,t,i,n,r,o,a,l,c){super(e,t,i,n,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class wa{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,n=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),r+=i.distanceTo(n),t.push(r),n=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let n=0;const r=i.length;let o;t?o=t:o=e*i[r-1];let a=0,l=r-1,c;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),c=i[n]-o,c<0)a=n+1;else if(c>0)l=n-1;else{l=n;break}if(n=l,i[n]===o)return n/(r-1);const u=i[n],f=i[n+1]-u,p=(o-u)/f;return(n+p)/(r-1)}getTangent(e,t){let n=e-1e-4,r=e+1e-4;n<0&&(n=0),r>1&&(r=1);const o=this.getPoint(n),a=this.getPoint(r),l=t||(o.isVector2?new te:new w);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new w,n=[],r=[],o=[],a=new w,l=new we;for(let p=0;p<=e;p++){const m=p/e;n[p]=this.getTangentAt(m,new w)}r[0]=new w,o[0]=new w;let c=Number.MAX_VALUE;const u=Math.abs(n[0].x),d=Math.abs(n[0].y),f=Math.abs(n[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),f<=c&&i.set(0,0,1),a.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],a),o[0].crossVectors(n[0],r[0]);for(let p=1;p<=e;p++){if(r[p]=r[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(n[p-1],n[p]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(An(n[p-1].dot(n[p]),-1,1));r[p].applyMatrix4(l.makeRotationAxis(a,m))}o[p].crossVectors(n[p],r[p])}if(t===!0){let p=Math.acos(An(r[0].dot(r[e]),-1,1));p/=e,n[0].dot(a.crossVectors(r[0],r[e]))>0&&(p=-p);for(let m=1;m<=e;m++)r[m].applyMatrix4(l.makeRotationAxis(n[m],p*m)),o[m].crossVectors(n[m],r[m])}return{tangents:n,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class fx extends wa{constructor(e=0,t=0,i=1,n=1,r=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new te){const i=t,n=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(o?r=0:r=n),this.aClockwise===!0&&!o&&(r===n?r=-n:r=r-n);const a=this.aStartAngle+e*r;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),d=Math.sin(this.aRotation),f=l-this.aX,p=c-this.aY;l=f*u-p*d+this.aX,c=f*d+p*u+this.aY}return i.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class FF extends fx{constructor(e,t,i,n,r,o){super(e,t,i,i,n,r,o),this.isArcCurve=!0,this.type="ArcCurve"}}function xT(){let s=0,e=0,t=0,i=0;function n(r,o,a,l){s=r,e=a,t=-3*r+3*o-2*a-l,i=2*r-2*o+a+l}return{initCatmullRom:function(r,o,a,l,c){n(o,a,c*(a-r),c*(l-o))},initNonuniformCatmullRom:function(r,o,a,l,c,u,d){let f=(o-r)/c-(a-r)/(c+u)+(a-o)/u,p=(a-o)/u-(l-o)/(u+d)+(l-a)/d;f*=u,p*=u,n(o,a,f,p)},calc:function(r){const o=r*r,a=o*r;return s+e*r+t*o+i*a}}}const Wy=new w,PS=new xT,BS=new xT,DS=new xT;class UF extends wa{constructor(e=[],t=!1,i="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=n}getPoint(e,t=new w){const i=t,n=this.points,r=n.length,o=(r-(this.closed?0:1))*e;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:l===0&&a===r-1&&(a=r-2,l=1);let c,u;this.closed||a>0?c=n[(a-1)%r]:(Wy.subVectors(n[0],n[1]).add(n[0]),c=Wy);const d=n[a%r],f=n[(a+1)%r];if(this.closed||a+2<r?u=n[(a+2)%r]:(Wy.subVectors(n[r-1],n[r-2]).add(n[r-1]),u=Wy),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(d),p),A=Math.pow(d.distanceToSquared(f),p),v=Math.pow(f.distanceToSquared(u),p);A<1e-4&&(A=1),m<1e-4&&(m=A),v<1e-4&&(v=A),PS.initNonuniformCatmullRom(c.x,d.x,f.x,u.x,m,A,v),BS.initNonuniformCatmullRom(c.y,d.y,f.y,u.y,m,A,v),DS.initNonuniformCatmullRom(c.z,d.z,f.z,u.z,m,A,v)}else this.curveType==="catmullrom"&&(PS.initCatmullRom(c.x,d.x,f.x,u.x,this.tension),BS.initCatmullRom(c.y,d.y,f.y,u.y,this.tension),DS.initCatmullRom(c.z,d.z,f.z,u.z,this.tension));return i.set(PS.calc(l),BS.calc(l),DS.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(new w().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function NB(s,e,t,i,n){const r=(i-e)*.5,o=(n-t)*.5,a=s*s,l=s*a;return(2*t-2*i+r+o)*l+(-3*t+3*i-2*r-o)*a+r*s+t}function mj(s,e){const t=1-s;return t*t*e}function gj(s,e){return 2*(1-s)*s*e}function vj(s,e){return s*s*e}function xg(s,e,t,i){return mj(s,e)+gj(s,t)+vj(s,i)}function Aj(s,e){const t=1-s;return t*t*t*e}function yj(s,e){const t=1-s;return 3*t*t*s*e}function _j(s,e){return 3*(1-s)*s*s*e}function bj(s,e){return s*s*s*e}function wg(s,e,t,i,n){return Aj(s,e)+yj(s,t)+_j(s,i)+bj(s,n)}class wT extends wa{constructor(e=new te,t=new te,i=new te,n=new te){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new te){const i=t,n=this.v0,r=this.v1,o=this.v2,a=this.v3;return i.set(wg(e,n.x,r.x,o.x,a.x),wg(e,n.y,r.y,o.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class NF extends wa{constructor(e=new w,t=new w,i=new w,n=new w){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new w){const i=t,n=this.v0,r=this.v1,o=this.v2,a=this.v3;return i.set(wg(e,n.x,r.x,o.x,a.x),wg(e,n.y,r.y,o.y,a.y),wg(e,n.z,r.z,o.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class ST extends wa{constructor(e=new te,t=new te){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new te){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new te){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class zF extends wa{constructor(e=new w,t=new w){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new w){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new w){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class CT extends wa{constructor(e=new te,t=new te,i=new te){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new te){const i=t,n=this.v0,r=this.v1,o=this.v2;return i.set(xg(e,n.x,r.x,o.x),xg(e,n.y,r.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class ET extends wa{constructor(e=new w,t=new w,i=new w){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new w){const i=t,n=this.v0,r=this.v1,o=this.v2;return i.set(xg(e,n.x,r.x,o.x),xg(e,n.y,r.y,o.y),xg(e,n.z,r.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class MT extends wa{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new te){const i=t,n=this.points,r=(n.length-1)*e,o=Math.floor(r),a=r-o,l=n[o===0?o:o-1],c=n[o],u=n[o>n.length-2?n.length-1:o+1],d=n[o>n.length-3?n.length-1:o+2];return i.set(NB(a,l.x,c.x,u.x,d.x),NB(a,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(new te().fromArray(n))}return this}}var tb=Object.freeze({__proto__:null,ArcCurve:FF,CatmullRomCurve3:UF,CubicBezierCurve:wT,CubicBezierCurve3:NF,EllipseCurve:fx,LineCurve:ST,LineCurve3:zF,QuadraticBezierCurve:CT,QuadraticBezierCurve3:ET,SplineCurve:MT});class GF extends wa{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new tb[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),n=this.getCurveLengths();let r=0;for(;r<n.length;){if(n[r]>=i){const o=n[r]-i,a=this.curves[r],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,n=this.curves.length;i<n;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let n=0,r=this.curves;n<r.length;n++){const o=r[n],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){const u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const n=e.curves[t];this.curves.push(new tb[n.type]().fromJSON(n))}return this}}class av extends GF{constructor(e){super(),this.type="Path",this.currentPoint=new te,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new ST(this.currentPoint.clone(),new te(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,n){const r=new CT(this.currentPoint.clone(),new te(e,t),new te(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this}bezierCurveTo(e,t,i,n,r,o){const a=new wT(this.currentPoint.clone(),new te(e,t),new te(i,n),new te(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new MT(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,n,r,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,i,n,r,o),this}absarc(e,t,i,n,r,o){return this.absellipse(e,t,i,i,n,r,o),this}ellipse(e,t,i,n,r,o,a,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,n,r,o,a,l),this}absellipse(e,t,i,n,r,o,a,l){const c=new fx(e,t,i,n,r,o,a,l);if(this.curves.length>0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Kv extends wt{constructor(e=[new te(0,-.5),new te(.5,0),new te(0,.5)],t=12,i=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:n},t=Math.floor(t),n=An(n,0,Math.PI*2);const r=[],o=[],a=[],l=[],c=[],u=1/t,d=new w,f=new te,p=new w,m=new w,A=new w;let v=0,g=0;for(let _=0;_<=e.length-1;_++)switch(_){case 0:v=e[_+1].x-e[_].x,g=e[_+1].y-e[_].y,p.x=g*1,p.y=-v,p.z=g*0,A.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(A.x,A.y,A.z);break;default:v=e[_+1].x-e[_].x,g=e[_+1].y-e[_].y,p.x=g*1,p.y=-v,p.z=g*0,m.copy(p),p.x+=A.x,p.y+=A.y,p.z+=A.z,p.normalize(),l.push(p.x,p.y,p.z),A.copy(m)}for(let _=0;_<=t;_++){const y=i+_*u*n,b=Math.sin(y),E=Math.cos(y);for(let M=0;M<=e.length-1;M++){d.x=e[M].x*b,d.y=e[M].y,d.z=e[M].x*E,o.push(d.x,d.y,d.z),f.x=_/t,f.y=M/(e.length-1),a.push(f.x,f.y);const T=l[3*M+0]*b,C=l[3*M+1],B=l[3*M+0]*E;c.push(T,C,B)}}for(let _=0;_<t;_++)for(let y=0;y<e.length-1;y++){const b=y+_*e.length,E=b,M=b+e.length,T=b+e.length+1,C=b+1;r.push(E,M,C),r.push(T,C,M)}this.setIndex(r),this.setAttribute("position",new ut(o,3)),this.setAttribute("uv",new ut(a,2)),this.setAttribute("normal",new ut(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kv(e.points,e.segments,e.phiStart,e.phiLength)}}class px extends Kv{constructor(e=1,t=1,i=4,n=8){const r=new av;r.absarc(0,-t/2,e,Math.PI*1.5,0),r.absarc(0,t/2,e,0,Math.PI*.5),super(r.getPoints(i),n),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:n}}static fromJSON(e){return new px(e.radius,e.length,e.capSegments,e.radialSegments)}}class mx extends wt{constructor(e=1,t=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);const r=[],o=[],a=[],l=[],c=new w,u=new te;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let d=0,f=3;d<=t;d++,f+=3){const p=i+d/t*n;c.x=e*Math.cos(p),c.y=e*Math.sin(p),o.push(c.x,c.y,c.z),a.push(0,0,1),u.x=(o[f]/e+1)/2,u.y=(o[f+1]/e+1)/2,l.push(u.x,u.y)}for(let d=1;d<=t;d++)r.push(d,d+1,0);this.setIndex(r),this.setAttribute("position",new ut(o,3)),this.setAttribute("normal",new ut(a,3)),this.setAttribute("uv",new ut(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mx(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Sn extends wt{constructor(e=1,t=1,i=1,n=32,r=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:l};const c=this;n=Math.floor(n),r=Math.floor(r);const u=[],d=[],f=[],p=[];let m=0;const A=[],v=i/2;let g=0;_(),o===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new ut(d,3)),this.setAttribute("normal",new ut(f,3)),this.setAttribute("uv",new ut(p,2));function _(){const b=new w,E=new w;let M=0;const T=(t-e)/i;for(let C=0;C<=r;C++){const B=[],S=C/r,R=S*(t-e)+e;for(let Q=0;Q<=n;Q++){const z=Q/n,O=z*l+a,V=Math.sin(O),L=Math.cos(O);E.x=R*V,E.y=-S*i+v,E.z=R*L,d.push(E.x,E.y,E.z),b.set(V,T,L).normalize(),f.push(b.x,b.y,b.z),p.push(z,1-S),B.push(m++)}A.push(B)}for(let C=0;C<n;C++)for(let B=0;B<r;B++){const S=A[B][C],R=A[B+1][C],Q=A[B+1][C+1],z=A[B][C+1];u.push(S,R,z),u.push(R,Q,z),M+=6}c.addGroup(g,M,0),g+=M}function y(b){const E=m,M=new te,T=new w;let C=0;const B=b===!0?e:t,S=b===!0?1:-1;for(let Q=1;Q<=n;Q++)d.push(0,v*S,0),f.push(0,S,0),p.push(.5,.5),m++;const R=m;for(let Q=0;Q<=n;Q++){const O=Q/n*l+a,V=Math.cos(O),L=Math.sin(O);T.x=B*L,T.y=v*S,T.z=B*V,d.push(T.x,T.y,T.z),f.push(0,S,0),M.x=V*.5+.5,M.y=L*.5*S+.5,p.push(M.x,M.y),m++}for(let Q=0;Q<n;Q++){const z=E+Q,O=R+Q;b===!0?u.push(O,O+1,z):u.push(O+1,O,z),C+=3}c.addGroup(g,C,b===!0?1:2),g+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Sn(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class gx extends Sn{constructor(e=1,t=1,i=32,n=1,r=!1,o=0,a=Math.PI*2){super(0,e,t,i,n,r,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:o,thetaLength:a}}static fromJSON(e){return new gx(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Fh extends wt{constructor(e=[],t=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:n};const r=[],o=[];a(n),c(i),u(),this.setAttribute("position",new ut(r,3)),this.setAttribute("normal",new ut(r.slice(),3)),this.setAttribute("uv",new ut(o,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function a(_){const y=new w,b=new w,E=new w;for(let M=0;M<t.length;M+=3)p(t[M+0],y),p(t[M+1],b),p(t[M+2],E),l(y,b,E,_)}function l(_,y,b,E){const M=E+1,T=[];for(let C=0;C<=M;C++){T[C]=[];const B=_.clone().lerp(b,C/M),S=y.clone().lerp(b,C/M),R=M-C;for(let Q=0;Q<=R;Q++)Q===0&&C===M?T[C][Q]=B:T[C][Q]=B.clone().lerp(S,Q/R)}for(let C=0;C<M;C++)for(let B=0;B<2*(M-C)-1;B++){const S=Math.floor(B/2);B%2===0?(f(T[C][S+1]),f(T[C+1][S]),f(T[C][S])):(f(T[C][S+1]),f(T[C+1][S+1]),f(T[C+1][S]))}}function c(_){const y=new w;for(let b=0;b<r.length;b+=3)y.x=r[b+0],y.y=r[b+1],y.z=r[b+2],y.normalize().multiplyScalar(_),r[b+0]=y.x,r[b+1]=y.y,r[b+2]=y.z}function u(){const _=new w;for(let y=0;y<r.length;y+=3){_.x=r[y+0],_.y=r[y+1],_.z=r[y+2];const b=v(_)/2/Math.PI+.5,E=g(_)/Math.PI+.5;o.push(b,1-E)}m(),d()}function d(){for(let _=0;_<o.length;_+=6){const y=o[_+0],b=o[_+2],E=o[_+4],M=Math.max(y,b,E),T=Math.min(y,b,E);M>.9&&T<.1&&(y<.2&&(o[_+0]+=1),b<.2&&(o[_+2]+=1),E<.2&&(o[_+4]+=1))}}function f(_){r.push(_.x,_.y,_.z)}function p(_,y){const b=_*3;y.x=e[b+0],y.y=e[b+1],y.z=e[b+2]}function m(){const _=new w,y=new w,b=new w,E=new w,M=new te,T=new te,C=new te;for(let B=0,S=0;B<r.length;B+=9,S+=6){_.set(r[B+0],r[B+1],r[B+2]),y.set(r[B+3],r[B+4],r[B+5]),b.set(r[B+6],r[B+7],r[B+8]),M.set(o[S+0],o[S+1]),T.set(o[S+2],o[S+3]),C.set(o[S+4],o[S+5]),E.copy(_).add(y).add(b).divideScalar(3);const R=v(E);A(M,S+0,_,R),A(T,S+2,y,R),A(C,S+4,b,R)}}function A(_,y,b,E){E<0&&_.x===1&&(o[y]=_.x-1),b.x===0&&b.z===0&&(o[y]=E/2/Math.PI+.5)}function v(_){return Math.atan2(_.z,-_.x)}function g(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fh(e.vertices,e.indices,e.radius,e.details)}}class vx extends Fh{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,n=1/i,r=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],o=[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];super(r,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new vx(e.radius,e.detail)}}const qy=new w,Xy=new w,OS=new w,Yy=new _r;class TT extends wt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const n=Math.pow(10,4),r=Math.cos(Hu*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],u=["a","b","c"],d=new Array(3),f={},p=[];for(let m=0;m<l;m+=3){o?(c[0]=o.getX(m),c[1]=o.getX(m+1),c[2]=o.getX(m+2)):(c[0]=m,c[1]=m+1,c[2]=m+2);const{a:A,b:v,c:g}=Yy;if(A.fromBufferAttribute(a,c[0]),v.fromBufferAttribute(a,c[1]),g.fromBufferAttribute(a,c[2]),Yy.getNormal(OS),d[0]=`${Math.round(A.x*n)},${Math.round(A.y*n)},${Math.round(A.z*n)}`,d[1]=`${Math.round(v.x*n)},${Math.round(v.y*n)},${Math.round(v.z*n)}`,d[2]=`${Math.round(g.x*n)},${Math.round(g.y*n)},${Math.round(g.z*n)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let _=0;_<3;_++){const y=(_+1)%3,b=d[_],E=d[y],M=Yy[u[_]],T=Yy[u[y]],C=`${b}_${E}`,B=`${E}_${b}`;B in f&&f[B]?(OS.dot(f[B].normal)<=r&&(p.push(M.x,M.y,M.z),p.push(T.x,T.y,T.z)),f[B]=null):C in f||(f[C]={index0:c[_],index1:c[y],normal:OS.clone()})}}for(const m in f)if(f[m]){const{index0:A,index1:v}=f[m];qy.fromBufferAttribute(a,A),Xy.fromBufferAttribute(a,v),p.push(qy.x,qy.y,qy.z),p.push(Xy.x,Xy.y,Xy.z)}this.setAttribute("position",new ut(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Qu extends av{constructor(e){super(e),this.uuid=uo(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,n=this.holes.length;i<n;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const n=e.holes[t];this.holes.push(new av().fromJSON(n))}return this}}const xj={triangulate:function(s,e,t=2){const i=e&&e.length,n=i?e[0]*t:s.length;let r=HF(s,0,n,t,!0);const o=[];if(!r||r.next===r.prev)return o;let a,l,c,u,d,f,p;if(i&&(r=Mj(s,e,r,t)),s.length>80*t){a=c=s[0],l=u=s[1];for(let m=t;m<n;m+=t)d=s[m],f=s[m+1],d<a&&(a=d),f<l&&(l=f),d>c&&(c=d),f>u&&(u=f);p=Math.max(c-a,u-l),p=p!==0?32767/p:0}return lv(r,o,t,a,l,p,0),o}};function HF(s,e,t,i,n){let r,o;if(n===Uj(s,e,t,i)>0)for(r=e;r<t;r+=i)o=zB(r,s[r],s[r+1],o);else for(r=t-i;r>=e;r-=i)o=zB(r,s[r],s[r+1],o);return o&&Ax(o,o.next)&&(hv(o),o=o.next),o}function nd(s,e){if(!s)return s;e||(e=s);let t=s,i;do if(i=!1,!t.steiner&&(Ax(t,t.next)||ln(t.prev,t,t.next)===0)){if(hv(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function lv(s,e,t,i,n,r,o){if(!s)return;!o&&r&&Bj(s,i,n,r);let a=s,l,c;for(;s.prev!==s.next;){if(l=s.prev,c=s.next,r?Sj(s,i,n,r):wj(s)){e.push(l.i/t|0),e.push(s.i/t|0),e.push(c.i/t|0),hv(s),s=c.next,a=c.next;continue}if(s=c,s===a){o?o===1?(s=Cj(nd(s),e,t),lv(s,e,t,i,n,r,2)):o===2&&Ej(s,e,t,i,n,r):lv(nd(s),e,t,i,n,r,1);break}}}function wj(s){const e=s.prev,t=s,i=s.next;if(ln(e,t,i)>=0)return!1;const n=e.x,r=t.x,o=i.x,a=e.y,l=t.y,c=i.y,u=n<r?n<o?n:o:r<o?r:o,d=a<l?a<c?a:c:l<c?l:c,f=n>r?n>o?n:o:r>o?r:o,p=a>l?a>c?a:c:l>c?l:c;let m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&Uf(n,a,r,l,o,c,m.x,m.y)&&ln(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Sj(s,e,t,i){const n=s.prev,r=s,o=s.next;if(ln(n,r,o)>=0)return!1;const a=n.x,l=r.x,c=o.x,u=n.y,d=r.y,f=o.y,p=a<l?a<c?a:c:l<c?l:c,m=u<d?u<f?u:f:d<f?d:f,A=a>l?a>c?a:c:l>c?l:c,v=u>d?u>f?u:f:d>f?d:f,g=l1(p,m,e,t,i),_=l1(A,v,e,t,i);let y=s.prevZ,b=s.nextZ;for(;y&&y.z>=g&&b&&b.z<=_;){if(y.x>=p&&y.x<=A&&y.y>=m&&y.y<=v&&y!==n&&y!==o&&Uf(a,u,l,d,c,f,y.x,y.y)&&ln(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=A&&b.y>=m&&b.y<=v&&b!==n&&b!==o&&Uf(a,u,l,d,c,f,b.x,b.y)&&ln(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=g;){if(y.x>=p&&y.x<=A&&y.y>=m&&y.y<=v&&y!==n&&y!==o&&Uf(a,u,l,d,c,f,y.x,y.y)&&ln(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=_;){if(b.x>=p&&b.x<=A&&b.y>=m&&b.y<=v&&b!==n&&b!==o&&Uf(a,u,l,d,c,f,b.x,b.y)&&ln(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Cj(s,e,t){let i=s;do{const n=i.prev,r=i.next.next;!Ax(n,r)&&QF(n,i,i.next,r)&&cv(n,r)&&cv(r,n)&&(e.push(n.i/t|0),e.push(i.i/t|0),e.push(r.i/t|0),hv(i),hv(i.next),i=s=r),i=i.next}while(i!==s);return nd(i)}function Ej(s,e,t,i,n,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Lj(o,a)){let l=VF(o,a);o=nd(o,o.next),l=nd(l,l.next),lv(o,e,t,i,n,r,0),lv(l,e,t,i,n,r,0);return}a=a.next}o=o.next}while(o!==s)}function Mj(s,e,t,i){const n=[];let r,o,a,l,c;for(r=0,o=e.length;r<o;r++)a=e[r]*i,l=r<o-1?e[r+1]*i:s.length,c=HF(s,a,l,i,!1),c===c.next&&(c.steiner=!0),n.push(Oj(c));for(n.sort(Tj),r=0;r<n.length;r++)t=Ij(n[r],t);return t}function Tj(s,e){return s.x-e.x}function Ij(s,e){const t=Rj(s,e);if(!t)return e;const i=VF(t,s);return nd(i,i.next),nd(t,t.next)}function Rj(s,e){let t=e,i=-1/0,n;const r=s.x,o=s.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){const f=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=r&&f>i&&(i=f,n=t.x<t.next.x?t:t.next,f===r))return n}t=t.next}while(t!==e);if(!n)return null;const a=n,l=n.x,c=n.y;let u=1/0,d;t=n;do r>=t.x&&t.x>=l&&r!==t.x&&Uf(o<c?r:i,o,l,c,o<c?i:r,o,t.x,t.y)&&(d=Math.abs(o-t.y)/(r-t.x),cv(t,s)&&(d<u||d===u&&(t.x>n.x||t.x===n.x&&Pj(n,t)))&&(n=t,u=d)),t=t.next;while(t!==a);return n}function Pj(s,e){return ln(s.prev,s,e.prev)<0&&ln(e.next,s,s.next)<0}function Bj(s,e,t,i){let n=s;do n.z===0&&(n.z=l1(n.x,n.y,e,t,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==s);n.prevZ.nextZ=null,n.prevZ=null,Dj(n)}function Dj(s){let e,t,i,n,r,o,a,l,c=1;do{for(t=s,s=null,r=null,o=0;t;){for(o++,i=t,a=0,e=0;e<c&&(a++,i=i.nextZ,!!i);e++);for(l=c;a>0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(n=t,t=t.nextZ,a--):(n=i,i=i.nextZ,l--),r?r.nextZ=n:s=n,n.prevZ=r,r=n;t=i}r.nextZ=null,c*=2}while(o>1);return s}function l1(s,e,t,i,n){return s=(s-t)*n|0,e=(e-i)*n|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function Oj(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function Uf(s,e,t,i,n,r,o,a){return(n-o)*(e-a)>=(s-o)*(r-a)&&(s-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(r-a)>=(n-o)*(i-a)}function Lj(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!kj(s,e)&&(cv(s,e)&&cv(e,s)&&Fj(s,e)&&(ln(s.prev,s,e.prev)||ln(s,e.prev,e))||Ax(s,e)&&ln(s.prev,s,s.next)>0&&ln(e.prev,e,e.next)>0)}function ln(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function Ax(s,e){return s.x===e.x&&s.y===e.y}function QF(s,e,t,i){const n=Ky(ln(s,e,t)),r=Ky(ln(s,e,i)),o=Ky(ln(t,i,s)),a=Ky(ln(t,i,e));return!!(n!==r&&o!==a||n===0&&Jy(s,t,e)||r===0&&Jy(s,i,e)||o===0&&Jy(t,s,i)||a===0&&Jy(t,e,i))}function Jy(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function Ky(s){return s>0?1:s<0?-1:0}function kj(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&QF(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function cv(s,e){return ln(s.prev,s,s.next)<0?ln(s,e,s.next)>=0&&ln(s,s.prev,e)>=0:ln(s,e,s.prev)<0||ln(s,s.next,e)<0}function Fj(s,e){let t=s,i=!1;const n=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&n<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==s);return i}function VF(s,e){const t=new c1(s.i,s.x,s.y),i=new c1(e.i,e.x,e.y),n=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=n,n.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function zB(s,e,t,i){const n=new c1(s,e,t);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function hv(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function c1(s,e,t){this.i=s,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Uj(s,e,t,i){let n=0;for(let r=e,o=t-i;r<t;r+=i)n+=(s[o]-s[r])*(s[r+1]+s[o+1]),o=r;return n}class ol{static area(e){const t=e.length;let i=0;for(let n=t-1,r=0;r<t;n=r++)i+=e[n].x*e[r].y-e[r].x*e[n].y;return i*.5}static isClockWise(e){return ol.area(e)<0}static triangulateShape(e,t){const i=[],n=[],r=[];GB(e),HB(i,e);let o=e.length;t.forEach(GB);for(let l=0;l<t.length;l++)n.push(o),o+=t[l].length,HB(i,t[l]);const a=xj.triangulate(i,n);for(let l=0;l<a.length;l+=3)r.push(a.slice(l,l+3));return r}}function GB(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function HB(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class yx extends wt{constructor(e=new Qu([new te(.5,.5),new te(-.5,.5),new te(-.5,-.5),new te(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,n=[],r=[];for(let a=0,l=e.length;a<l;a++){const c=e[a];o(c)}this.setAttribute("position",new ut(n,3)),this.setAttribute("uv",new ut(r,2)),this.computeVertexNormals();function o(a){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,A=t.bevelOffset!==void 0?t.bevelOffset:0,v=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,_=t.UVGenerator!==void 0?t.UVGenerator:Nj;let y,b=!1,E,M,T,C;g&&(y=g.getSpacedPoints(u),b=!0,f=!1,E=g.computeFrenetFrames(u,!1),M=new w,T=new w,C=new w),f||(v=0,p=0,m=0,A=0);const B=a.extractPoints(c);let S=B.shape;const R=B.holes;if(!ol.isClockWise(S)){S=S.reverse();for(let W=0,Ne=R.length;W<Ne;W++){const ye=R[W];ol.isClockWise(ye)&&(R[W]=ye.reverse())}}const z=ol.triangulateShape(S,R),O=S;for(let W=0,Ne=R.length;W<Ne;W++){const ye=R[W];S=S.concat(ye)}function V(W,Ne,ye){return Ne||console.error("THREE.ExtrudeGeometry: vec does not exist"),W.clone().addScaledVector(Ne,ye)}const L=S.length,k=z.length;function G(W,Ne,ye){let ke,Se,$e;const Je=W.x-Ne.x,st=W.y-Ne.y,Bt=ye.x-W.x,N=ye.y-W.y,D=Je*Je+st*st,fe=Je*N-st*Bt;if(Math.abs(fe)>Number.EPSILON){const ve=Math.sqrt(D),Ie=Math.sqrt(Bt*Bt+N*N),Ee=Ne.x-st/ve,vt=Ne.y+Je/ve,at=ye.x-N/Ie,Oe=ye.y+Bt/Ie,He=((at-Ee)*N-(Oe-vt)*Bt)/(Je*N-st*Bt);ke=Ee+Je*He-W.x,Se=vt+st*He-W.y;const yt=ke*ke+Se*Se;if(yt<=2)return new te(ke,Se);$e=Math.sqrt(yt/2)}else{let ve=!1;Je>Number.EPSILON?Bt>Number.EPSILON&&(ve=!0):Je<-Number.EPSILON?Bt<-Number.EPSILON&&(ve=!0):Math.sign(st)===Math.sign(N)&&(ve=!0),ve?(ke=-st,Se=Je,$e=Math.sqrt(D)):(ke=Je,Se=st,$e=Math.sqrt(D/2))}return new te(ke/$e,Se/$e)}const Y=[];for(let W=0,Ne=O.length,ye=Ne-1,ke=W+1;W<Ne;W++,ye++,ke++)ye===Ne&&(ye=0),ke===Ne&&(ke=0),Y[W]=G(O[W],O[ye],O[ke]);const $=[];let re,ce=Y.concat();for(let W=0,Ne=R.length;W<Ne;W++){const ye=R[W];re=[];for(let ke=0,Se=ye.length,$e=Se-1,Je=ke+1;ke<Se;ke++,$e++,Je++)$e===Se&&($e=0),Je===Se&&(Je=0),re[ke]=G(ye[ke],ye[$e],ye[Je]);$.push(re),ce=ce.concat(re)}for(let W=0;W<v;W++){const Ne=W/v,ye=p*Math.cos(Ne*Math.PI/2),ke=m*Math.sin(Ne*Math.PI/2)+A;for(let Se=0,$e=O.length;Se<$e;Se++){const Je=V(O[Se],Y[Se],ke);Ve(Je.x,Je.y,-ye)}for(let Se=0,$e=R.length;Se<$e;Se++){const Je=R[Se];re=$[Se];for(let st=0,Bt=Je.length;st<Bt;st++){const N=V(Je[st],re[st],ke);Ve(N.x,N.y,-ye)}}}const Re=m+A;for(let W=0;W<L;W++){const Ne=f?V(S[W],ce[W],Re):S[W];b?(T.copy(E.normals[0]).multiplyScalar(Ne.x),M.copy(E.binormals[0]).multiplyScalar(Ne.y),C.copy(y[0]).add(T).add(M),Ve(C.x,C.y,C.z)):Ve(Ne.x,Ne.y,0)}for(let W=1;W<=u;W++)for(let Ne=0;Ne<L;Ne++){const ye=f?V(S[Ne],ce[Ne],Re):S[Ne];b?(T.copy(E.normals[W]).multiplyScalar(ye.x),M.copy(E.binormals[W]).multiplyScalar(ye.y),C.copy(y[W]).add(T).add(M),Ve(C.x,C.y,C.z)):Ve(ye.x,ye.y,d/u*W)}for(let W=v-1;W>=0;W--){const Ne=W/v,ye=p*Math.cos(Ne*Math.PI/2),ke=m*Math.sin(Ne*Math.PI/2)+A;for(let Se=0,$e=O.length;Se<$e;Se++){const Je=V(O[Se],Y[Se],ke);Ve(Je.x,Je.y,d+ye)}for(let Se=0,$e=R.length;Se<$e;Se++){const Je=R[Se];re=$[Se];for(let st=0,Bt=Je.length;st<Bt;st++){const N=V(Je[st],re[st],ke);b?Ve(N.x,N.y+y[u-1].y,y[u-1].x+ye):Ve(N.x,N.y,d+ye)}}}ie(),me();function ie(){const W=n.length/3;if(f){let Ne=0,ye=L*Ne;for(let ke=0;ke<k;ke++){const Se=z[ke];je(Se[2]+ye,Se[1]+ye,Se[0]+ye)}Ne=u+v*2,ye=L*Ne;for(let ke=0;ke<k;ke++){const Se=z[ke];je(Se[0]+ye,Se[1]+ye,Se[2]+ye)}}else{for(let Ne=0;Ne<k;Ne++){const ye=z[Ne];je(ye[2],ye[1],ye[0])}for(let Ne=0;Ne<k;Ne++){const ye=z[Ne];je(ye[0]+L*u,ye[1]+L*u,ye[2]+L*u)}}i.addGroup(W,n.length/3-W,0)}function me(){const W=n.length/3;let Ne=0;be(O,Ne),Ne+=O.length;for(let ye=0,ke=R.length;ye<ke;ye++){const Se=R[ye];be(Se,Ne),Ne+=Se.length}i.addGroup(W,n.length/3-W,1)}function be(W,Ne){let ye=W.length;for(;--ye>=0;){const ke=ye;let Se=ye-1;Se<0&&(Se=W.length-1);for(let $e=0,Je=u+v*2;$e<Je;$e++){const st=L*$e,Bt=L*($e+1),N=Ne+ke+st,D=Ne+Se+st,fe=Ne+Se+Bt,ve=Ne+ke+Bt;Ge(N,D,fe,ve)}}}function Ve(W,Ne,ye){l.push(W),l.push(Ne),l.push(ye)}function je(W,Ne,ye){dt(W),dt(Ne),dt(ye);const ke=n.length/3,Se=_.generateTopUV(i,n,ke-3,ke-2,ke-1);tt(Se[0]),tt(Se[1]),tt(Se[2])}function Ge(W,Ne,ye,ke){dt(W),dt(Ne),dt(ke),dt(Ne),dt(ye),dt(ke);const Se=n.length/3,$e=_.generateSideWallUV(i,n,Se-6,Se-3,Se-2,Se-1);tt($e[0]),tt($e[1]),tt($e[3]),tt($e[1]),tt($e[2]),tt($e[3])}function dt(W){n.push(l[W*3+0]),n.push(l[W*3+1]),n.push(l[W*3+2])}function tt(W){r.push(W.x),r.push(W.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return zj(t,i,e)}static fromJSON(e,t){const i=[];for(let r=0,o=e.shapes.length;r<o;r++){const a=t[e.shapes[r]];i.push(a)}const n=e.options.extrudePath;return n!==void 0&&(e.options.extrudePath=new tb[n.type]().fromJSON(n)),new yx(i,e.options)}}const Nj={generateTopUV:function(s,e,t,i,n){const r=e[t*3],o=e[t*3+1],a=e[i*3],l=e[i*3+1],c=e[n*3],u=e[n*3+1];return[new te(r,o),new te(a,l),new te(c,u)]},generateSideWallUV:function(s,e,t,i,n,r){const o=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],d=e[i*3+2],f=e[n*3],p=e[n*3+1],m=e[n*3+2],A=e[r*3],v=e[r*3+1],g=e[r*3+2];return Math.abs(a-u)<Math.abs(o-c)?[new te(o,1-l),new te(c,1-d),new te(f,1-m),new te(A,1-g)]:[new te(a,1-l),new te(u,1-d),new te(p,1-m),new te(v,1-g)]}};function zj(s,e,t){if(t.shapes=[],Array.isArray(s))for(let i=0,n=s.length;i<n;i++){const r=s[i];t.shapes.push(r.uuid)}else t.shapes.push(s.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class _x extends Fh{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,n=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],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];super(n,r,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new _x(e.radius,e.detail)}}class nc extends Fh{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],n=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,n,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new nc(e.radius,e.detail)}}class sd extends wt{constructor(e=.5,t=1,i=32,n=1,r=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:n,thetaStart:r,thetaLength:o},i=Math.max(3,i),n=Math.max(1,n);const a=[],l=[],c=[],u=[];let d=e;const f=(t-e)/n,p=new w,m=new te;for(let A=0;A<=n;A++){for(let v=0;v<=i;v++){const g=r+v/i*o;p.x=d*Math.cos(g),p.y=d*Math.sin(g),l.push(p.x,p.y,p.z),c.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,u.push(m.x,m.y)}d+=f}for(let A=0;A<n;A++){const v=A*(i+1);for(let g=0;g<i;g++){const _=g+v,y=_,b=_+i+1,E=_+i+2,M=_+1;a.push(y,b,M),a.push(b,E,M)}}this.setIndex(a),this.setAttribute("position",new ut(l,3)),this.setAttribute("normal",new ut(c,3)),this.setAttribute("uv",new ut(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new sd(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class bx extends wt{constructor(e=new Qu([new te(0,.5),new te(-.5,-.5),new te(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],n=[],r=[],o=[];let a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(a,l,u),a+=l,l=0;this.setIndex(i),this.setAttribute("position",new ut(n,3)),this.setAttribute("normal",new ut(r,3)),this.setAttribute("uv",new ut(o,2));function c(u){const d=n.length/3,f=u.extractPoints(t);let p=f.shape;const m=f.holes;ol.isClockWise(p)===!1&&(p=p.reverse());for(let v=0,g=m.length;v<g;v++){const _=m[v];ol.isClockWise(_)===!0&&(m[v]=_.reverse())}const A=ol.triangulateShape(p,m);for(let v=0,g=m.length;v<g;v++){const _=m[v];p=p.concat(_)}for(let v=0,g=p.length;v<g;v++){const _=p[v];n.push(_.x,_.y,0),r.push(0,0,1),o.push(_.x,_.y)}for(let v=0,g=A.length;v<g;v++){const _=A[v],y=_[0]+d,b=_[1]+d,E=_[2]+d;i.push(y,b,E),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return Gj(t,e)}static fromJSON(e,t){const i=[];for(let n=0,r=e.shapes.length;n<r;n++){const o=t[e.shapes[n]];i.push(o)}return new bx(i,e.curveSegments)}}function Gj(s,e){if(e.shapes=[],Array.isArray(s))for(let t=0,i=s.length;t<i;t++){const n=s[t];e.shapes.push(n.uuid)}else e.shapes.push(s.uuid);return e}class Sa extends wt{constructor(e=1,t=32,i=16,n=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:r,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(o+a,Math.PI);let c=0;const u=[],d=new w,f=new w,p=[],m=[],A=[],v=[];for(let g=0;g<=i;g++){const _=[],y=g/i;let b=0;g===0&&o===0?b=.5/t:g===i&&l===Math.PI&&(b=-.5/t);for(let E=0;E<=t;E++){const M=E/t;d.x=-e*Math.cos(n+M*r)*Math.sin(o+y*a),d.y=e*Math.cos(o+y*a),d.z=e*Math.sin(n+M*r)*Math.sin(o+y*a),m.push(d.x,d.y,d.z),f.copy(d).normalize(),A.push(f.x,f.y,f.z),v.push(M+b,1-y),_.push(c++)}u.push(_)}for(let g=0;g<i;g++)for(let _=0;_<t;_++){const y=u[g][_+1],b=u[g][_],E=u[g+1][_],M=u[g+1][_+1];(g!==0||o>0)&&p.push(y,b,M),(g!==i-1||l<Math.PI)&&p.push(b,E,M)}this.setIndex(p),this.setAttribute("position",new ut(m,3)),this.setAttribute("normal",new ut(A,3)),this.setAttribute("uv",new ut(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Sa(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class xx extends Fh{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],n=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,n,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new xx(e.radius,e.detail)}}class Jl extends wt{constructor(e=1,t=.4,i=12,n=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:n,arc:r},i=Math.floor(i),n=Math.floor(n);const o=[],a=[],l=[],c=[],u=new w,d=new w,f=new w;for(let p=0;p<=i;p++)for(let m=0;m<=n;m++){const A=m/n*r,v=p/i*Math.PI*2;d.x=(e+t*Math.cos(v))*Math.cos(A),d.y=(e+t*Math.cos(v))*Math.sin(A),d.z=t*Math.sin(v),a.push(d.x,d.y,d.z),u.x=e*Math.cos(A),u.y=e*Math.sin(A),f.subVectors(d,u).normalize(),l.push(f.x,f.y,f.z),c.push(m/n),c.push(p/i)}for(let p=1;p<=i;p++)for(let m=1;m<=n;m++){const A=(n+1)*p+m-1,v=(n+1)*(p-1)+m-1,g=(n+1)*(p-1)+m,_=(n+1)*p+m;o.push(A,v,_),o.push(v,g,_)}this.setIndex(o),this.setAttribute("position",new ut(a,3)),this.setAttribute("normal",new ut(l,3)),this.setAttribute("uv",new ut(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jl(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class wx extends wt{constructor(e=1,t=.4,i=64,n=8,r=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:n,p:r,q:o},i=Math.floor(i),n=Math.floor(n);const a=[],l=[],c=[],u=[],d=new w,f=new w,p=new w,m=new w,A=new w,v=new w,g=new w;for(let y=0;y<=i;++y){const b=y/i*r*Math.PI*2;_(b,r,o,e,p),_(b+.01,r,o,e,m),v.subVectors(m,p),g.addVectors(m,p),A.crossVectors(v,g),g.crossVectors(A,v),A.normalize(),g.normalize();for(let E=0;E<=n;++E){const M=E/n*Math.PI*2,T=-t*Math.cos(M),C=t*Math.sin(M);d.x=p.x+(T*g.x+C*A.x),d.y=p.y+(T*g.y+C*A.y),d.z=p.z+(T*g.z+C*A.z),l.push(d.x,d.y,d.z),f.subVectors(d,p).normalize(),c.push(f.x,f.y,f.z),u.push(y/i),u.push(E/n)}}for(let y=1;y<=i;y++)for(let b=1;b<=n;b++){const E=(n+1)*(y-1)+(b-1),M=(n+1)*y+(b-1),T=(n+1)*y+b,C=(n+1)*(y-1)+b;a.push(E,M,C),a.push(M,T,C)}this.setIndex(a),this.setAttribute("position",new ut(l,3)),this.setAttribute("normal",new ut(c,3)),this.setAttribute("uv",new ut(u,2));function _(y,b,E,M,T){const C=Math.cos(y),B=Math.sin(y),S=E/b*y,R=Math.cos(S);T.x=M*(2+R)*.5*C,T.y=M*(2+R)*B*.5,T.z=M*Math.sin(S)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wx(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Sx extends wt{constructor(e=new ET(new w(-1,-1,0),new w(-1,1,0),new w(1,1,0)),t=64,i=1,n=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:n,closed:r};const o=e.computeFrenetFrames(t,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new w,l=new w,c=new te;let u=new w;const d=[],f=[],p=[],m=[];A(),this.setIndex(m),this.setAttribute("position",new ut(d,3)),this.setAttribute("normal",new ut(f,3)),this.setAttribute("uv",new ut(p,2));function A(){for(let y=0;y<t;y++)v(y);v(r===!1?t:0),_(),g()}function v(y){u=e.getPointAt(y/t,u);const b=o.normals[y],E=o.binormals[y];for(let M=0;M<=n;M++){const T=M/n*Math.PI*2,C=Math.sin(T),B=-Math.cos(T);l.x=B*b.x+C*E.x,l.y=B*b.y+C*E.y,l.z=B*b.z+C*E.z,l.normalize(),f.push(l.x,l.y,l.z),a.x=u.x+i*l.x,a.y=u.y+i*l.y,a.z=u.z+i*l.z,d.push(a.x,a.y,a.z)}}function g(){for(let y=1;y<=t;y++)for(let b=1;b<=n;b++){const E=(n+1)*(y-1)+(b-1),M=(n+1)*y+(b-1),T=(n+1)*y+b,C=(n+1)*(y-1)+b;m.push(E,M,C),m.push(M,T,C)}}function _(){for(let y=0;y<=t;y++)for(let b=0;b<=n;b++)c.x=y/t,c.y=b/n,p.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new Sx(new tb[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class IT extends wt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,n=new w,r=new w;if(e.index!==null){const o=e.attributes.position,a=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:a.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const d=l[c],f=d.start,p=d.count;for(let m=f,A=f+p;m<A;m+=3)for(let v=0;v<3;v++){const g=a.getX(m+v),_=a.getX(m+(v+1)%3);n.fromBufferAttribute(o,g),r.fromBufferAttribute(o,_),QB(n,r,i)===!0&&(t.push(n.x,n.y,n.z),t.push(r.x,r.y,r.z))}}}else{const o=e.attributes.position;for(let a=0,l=o.count/3;a<l;a++)for(let c=0;c<3;c++){const u=3*a+c,d=3*a+(c+1)%3;n.fromBufferAttribute(o,u),r.fromBufferAttribute(o,d),QB(n,r,i)===!0&&(t.push(n.x,n.y,n.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new ut(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function QB(s,e,t){const i=`${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`,n=`${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`;return t.has(i)===!0||t.has(n)===!0?!1:(t.add(i),t.add(n),!0)}var VB=Object.freeze({__proto__:null,BoxGeometry:Li,CapsuleGeometry:px,CircleGeometry:mx,ConeGeometry:gx,CylinderGeometry:Sn,DodecahedronGeometry:vx,EdgesGeometry:TT,ExtrudeGeometry:yx,IcosahedronGeometry:_x,LatheGeometry:Kv,OctahedronGeometry:nc,PlaneGeometry:zn,PolyhedronGeometry:Fh,RingGeometry:sd,ShapeGeometry:bx,SphereGeometry:Sa,TetrahedronGeometry:xx,TorusGeometry:Jl,TorusKnotGeometry:wx,TubeGeometry:Sx,WireframeGeometry:IT});class Cx extends Nt{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new xe(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Zv extends Pt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class zr extends Nt{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new xe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kh,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Gi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(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.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class mo extends zr{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new te(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return An(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new xe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new xe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new xe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class jF extends Nt{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new xe(16777215),this.specular=new xe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kh,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Gi,this.combine=Qv,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(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.envMapRotation.copy(e.envMapRotation),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.flatShading=e.flatShading,this.fog=e.fog,this}}class WF extends Nt{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new xe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kh,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,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.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Ex extends Nt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kh,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(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.flatShading=e.flatShading,this}}class qF extends Nt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kh,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Gi,this.combine=Qv,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(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.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.envMapRotation.copy(e.envMapRotation),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.flatShading=e.flatShading,this.fog=e.fog,this}}class XF extends Nt{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new xe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kh,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(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.flatShading=e.flatShading,this.fog=e.fog,this}}class YF extends Rn{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function ku(s,e,t){return!s||!t&&s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function JF(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function KF(s){function e(n,r){return s[n]-s[r]}const t=s.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i}function h1(s,e,t){const i=s.length,n=new s.constructor(i);for(let r=0,o=0;o!==i;++r){const a=t[r]*e;for(let l=0;l!==e;++l)n[o++]=s[a+l]}return n}function RT(s,e,t,i){let n=1,r=s[0];for(;r!==void 0&&r[i]===void 0;)r=s[n++];if(r===void 0)return;let o=r[i];if(o!==void 0)if(Array.isArray(o))do o=r[i],o!==void 0&&(e.push(r.time),t.push.apply(t,o)),r=s[n++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[i],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=s[n++];while(r!==void 0);else do o=r[i],o!==void 0&&(e.push(r.time),t.push(o)),r=s[n++];while(r!==void 0)}function Hj(s,e,t,i,n=30){const r=s.clone();r.name=e;const o=[];for(let l=0;l<r.tracks.length;++l){const c=r.tracks[l],u=c.getValueSize(),d=[],f=[];for(let p=0;p<c.times.length;++p){const m=c.times[p]*n;if(!(m<t||m>=i)){d.push(c.times[p]);for(let A=0;A<u;++A)f.push(c.values[p*u+A])}}d.length!==0&&(c.times=ku(d,c.times.constructor),c.values=ku(f,c.values.constructor),o.push(c))}r.tracks=o;let a=1/0;for(let l=0;l<r.tracks.length;++l)a>r.tracks[l].times[0]&&(a=r.tracks[l].times[0]);for(let l=0;l<r.tracks.length;++l)r.tracks[l].shift(-1*a);return r.resetDuration(),r}function Qj(s,e=0,t=s,i=30){i<=0&&(i=30);const n=t.tracks.length,r=e/i;for(let o=0;o<n;++o){const a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;const c=s.tracks.find(function(g){return g.name===a.name&&g.ValueTypeName===l});if(c===void 0)continue;let u=0;const d=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=d/3);let f=0;const p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=p/3);const m=a.times.length-1;let A;if(r<=a.times[0]){const g=u,_=d-u;A=a.values.slice(g,_)}else if(r>=a.times[m]){const g=m*d+u,_=g+d-u;A=a.values.slice(g,_)}else{const g=a.createInterpolant(),_=u,y=d-u;g.evaluate(r),A=g.resultBuffer.slice(_,y)}l==="quaternion"&&new Ce().fromArray(A).normalize().conjugate().toArray(A);const v=c.times.length;for(let g=0;g<v;++g){const _=g*p+f;if(l==="quaternion")Ce.multiplyQuaternionsFlat(c.values,_,A,0,c.values,_);else{const y=p-f*2;for(let b=0;b<y;++b)c.values[_+b]-=A[b]}}}return s.blendMode=rT,s}const Vj={convertArray:ku,isTypedArray:JF,getKeyframeOrder:KF,sortedArray:h1,flattenJSON:RT,subclip:Hj,makeClipAdditive:Qj};class Bp{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],r=t[i-1];e:{t:{let o;i:{n:if(!(e<n)){for(let a=i+2;;){if(n===void 0){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(r=n,n=t[++i],e<n)break t}o=t.length;break i}if(!(e>=r)){const a=t[1];e<a&&(i=2,r=a);for(let l=i-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(n=r,r=t[--i-1],e>=r)break t}o=i,i=0;break i}break e}for(;i<o;){const a=i+o>>>1;e<t[a]?o=a:i=a+1}if(n=t[i],r=t[i-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let o=0;o!==n;++o)t[o]=i[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class ZF extends Bp{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Du,endingEnd:Du}}intervalChanged_(e,t,i){const n=this.parameterPositions;let r=e-2,o=e+1,a=n[r],l=n[o];if(a===void 0)switch(this.getSettings_().endingStart){case Ou:r=e,a=2*t-i;break;case ev:r=n.length-2,a=t+n[r]-n[r+1];break;default:r=e,a=i}if(l===void 0)switch(this.getSettings_().endingEnd){case Ou:o=e,l=2*i-t;break;case ev:o=1,l=i+n[1]-n[0];break;default:o=e-1,l=t}const c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-i),this._offsetPrev=r*u,this._offsetNext=o*u}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this._offsetPrev,d=this._offsetNext,f=this._weightPrev,p=this._weightNext,m=(i-t)/(n-t),A=m*m,v=A*m,g=-f*v+2*f*A-f*m,_=(1+f)*v+(-1.5-2*f)*A+(-.5+f)*m+1,y=(-1-p)*v+(1.5+p)*A+.5*m,b=p*v-p*A;for(let E=0;E!==a;++E)r[E]=g*o[u+E]+_*o[c+E]+y*o[l+E]+b*o[d+E];return r}}class PT extends Bp{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=(i-t)/(n-t),d=1-u;for(let f=0;f!==a;++f)r[f]=o[c+f]*d+o[l+f]*u;return r}}class $F extends Bp{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class Ca{constructor(e,t,i,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=ku(t,this.TimeBufferType),this.values=ku(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:ku(e.times,Array),values:ku(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new $F(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new PT(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ZF(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Th:t=this.InterpolantFactoryMethodDiscrete;break;case dl:t=this.InterpolantFactoryMethodLinear;break;case l_:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Th;case this.InterpolantFactoryMethodLinear:return dl;case this.InterpolantFactoryMethodSmooth:return l_}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let r=0,o=n-1;for(;r!==n&&i[r]<e;)++r;for(;o!==-1&&i[o]>t;)--o;if(++o,r!==0||o!==n){r>=o&&(o=Math.max(o,1),r=o-1);const a=this.getValueSize();this.times=i.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){const l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(n!==void 0&&JF(n))for(let a=0,l=n.length;a!==l;++a){const c=n[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===l_,r=e.length-1;let o=1;for(let a=1;a<r;++a){let l=!1;const c=e[a],u=e[a+1];if(c!==u&&(a!==1||c!==e[0]))if(n)l=!0;else{const d=a*i,f=d-i,p=d+i;for(let m=0;m!==i;++m){const A=t[d+m];if(A!==t[f+m]||A!==t[p+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];const d=a*i,f=o*i;for(let p=0;p!==i;++p)t[f+p]=t[d+p]}++o}}if(r>0){e[o]=e[r];for(let a=r*i,l=o*i,c=0;c!==i;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Ca.prototype.TimeBufferType=Float32Array;Ca.prototype.ValueBufferType=Float32Array;Ca.prototype.DefaultInterpolation=dl;class dd extends Ca{}dd.prototype.ValueTypeName="bool";dd.prototype.ValueBufferType=Array;dd.prototype.DefaultInterpolation=Th;dd.prototype.InterpolantFactoryMethodLinear=void 0;dd.prototype.InterpolantFactoryMethodSmooth=void 0;class Mx extends Ca{}Mx.prototype.ValueTypeName="color";class Ih extends Ca{}Ih.prototype.ValueTypeName="number";class eU extends Bp{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(i-t)/(n-t);let c=e*a;for(let u=c+a;c!==u;c+=4)Ce.slerpFlat(r,0,o,c-a,o,c,l);return r}}class fl extends Ca{InterpolantFactoryMethodLinear(e){return new eU(this.times,this.values,this.getValueSize(),e)}}fl.prototype.ValueTypeName="quaternion";fl.prototype.DefaultInterpolation=dl;fl.prototype.InterpolantFactoryMethodSmooth=void 0;class fd extends Ca{}fd.prototype.ValueTypeName="string";fd.prototype.ValueBufferType=Array;fd.prototype.DefaultInterpolation=Th;fd.prototype.InterpolantFactoryMethodLinear=void 0;fd.prototype.InterpolantFactoryMethodSmooth=void 0;class mc extends Ca{}mc.prototype.ValueTypeName="vector";class Sr{constructor(e,t=-1,i,n=sx){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=uo(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(Wj(i[o]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=i.length;r!==o;++r)t.push(Ca.toJSON(i[r]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,o=[];for(let a=0;a<r;a++){let l=[],c=[];l.push((a+r-1)%r,a,(a+1)%r),c.push(0,1,0);const u=KF(l);l=h1(l,1,u),c=h1(c,1,u),!n&&l[0]===0&&(l.push(r),c.push(c[0])),o.push(new Ih(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const n=e;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===t)return i[n];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){const c=e[a],u=c.name.match(r);if(u&&u.length>1){const d=u[1];let f=n[d];f||(n[d]=f=[]),f.push(c)}}const o=[];for(const a in n)o.push(this.CreateFromMorphTargetSequence(a,n[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(d,f,p,m,A){if(p.length!==0){const v=[],g=[];RT(p,v,g,m),v.length!==0&&A.push(new d(f,v,g))}},n=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let d=0;d<c.length;d++){const f=c[d].keys;if(!(!f||f.length===0))if(f[0].morphTargets){const p={};let m;for(m=0;m<f.length;m++)if(f[m].morphTargets)for(let A=0;A<f[m].morphTargets.length;A++)p[f[m].morphTargets[A]]=-1;for(const A in p){const v=[],g=[];for(let _=0;_!==f[m].morphTargets.length;++_){const y=f[m];v.push(y.time),g.push(y.morphTarget===A?1:0)}n.push(new Ih(".morphTargetInfluence["+A+"]",v,g))}l=p.length*o}else{const p=".bones["+t[d].name+"]";i(mc,p+".position",f,"pos",n),i(fl,p+".quaternion",f,"rot",n),i(mc,p+".scale",f,"scl",n)}}return n.length===0?null:new this(r,l,n,a)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,n=e.length;i!==n;++i){const r=this.tracks[i];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function jj(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ih;case"vector":case"vector2":case"vector3":case"vector4":return mc;case"color":return Mx;case"quaternion":return fl;case"bool":case"boolean":return dd;case"string":return fd}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function Wj(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=jj(s.type);if(s.times===void 0){const t=[],i=[];RT(s.keys,t,i,"value"),s.times=t,s.values=i}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const sc={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(this.files[s]=e)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};class Tx{constructor(e,t,i){const n=this;let r=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,r===!1&&n.onStart!==void 0&&n.onStart(u,o,a),r=!0},this.itemEnd=function(u){o++,n.onProgress!==void 0&&n.onProgress(u,o,a),o===a&&(r=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(u){n.onError!==void 0&&n.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,d){return c.push(u,d),this},this.removeHandler=function(u){const d=c.indexOf(u);return d!==-1&&c.splice(d,2),this},this.getHandler=function(u){for(let d=0,f=c.length;d<f;d+=2){const p=c[d],m=c[d+1];if(p.global&&(p.lastIndex=0),p.test(u))return m}return null}}}const tU=new Tx;class ks{constructor(e){this.manager=e!==void 0?e:tU,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(n,r){i.load(e,n,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}ks.DEFAULT_MATERIAL_NAME="__DEFAULT";const Rl={};class qj extends Error{constructor(e,t){super(e),this.response=t}}class Kn extends ks{constructor(e){super(e)}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=sc.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(Rl[e]!==void 0){Rl[e].push({onLoad:t,onProgress:i,onError:n});return}Rl[e]=[],Rl[e].push({onLoad:t,onProgress:i,onError:n});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=Rl[e],d=c.body.getReader(),f=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),p=f?parseInt(f):0,m=p!==0;let A=0;const v=new ReadableStream({start(g){_();function _(){d.read().then(({done:y,value:b})=>{if(y)g.close();else{A+=b.byteLength;const E=new ProgressEvent("progress",{lengthComputable:m,loaded:A,total:p});for(let M=0,T=u.length;M<T;M++){const C=u[M];C.onProgress&&C.onProgress(E)}g.enqueue(b),_()}})}}});return new Response(v)}else throw new qj(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(a),f=d&&d[1]?d[1].toLowerCase():void 0,p=new TextDecoder(f);return c.arrayBuffer().then(m=>p.decode(m))}}}).then(c=>{sc.add(e,c);const u=Rl[e];delete Rl[e];for(let d=0,f=u.length;d<f;d++){const p=u[d];p.onLoad&&p.onLoad(c)}}).catch(c=>{const u=Rl[e];if(u===void 0)throw this.manager.itemError(e),c;delete Rl[e];for(let d=0,f=u.length;d<f;d++){const p=u[d];p.onError&&p.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Xj extends ks{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Kn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(l){n?n(l):console.error(l),r.manager.itemError(e)}},i,n)}parse(e){const t=[];for(let i=0;i<e.length;i++){const n=Sr.parse(e[i]);t.push(n)}return t}}class Yj extends ks{constructor(e){super(e)}load(e,t,i,n){const r=this,o=[],a=new rl,l=new Kn(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(r.withCredentials);let c=0;function u(d){l.load(e[d],function(f){const p=r.parse(f,!0);o[d]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},c+=1,c===6&&(p.mipmapCount===1&&(a.minFilter=Mt),a.image=o,a.format=p.format,a.needsUpdate=!0,t&&t(a))},i,n)}if(Array.isArray(e))for(let d=0,f=e.length;d<f;++d)u(d);else l.load(e,function(d){const f=r.parse(d,!0);if(f.isCubemap){const p=f.mipmaps.length/f.mipmapCount;for(let m=0;m<p;m++){o[m]={mipmaps:[]};for(let A=0;A<f.mipmapCount;A++)o[m].mipmaps.push(f.mipmaps[m*f.mipmapCount+A]),o[m].format=f.format,o[m].width=f.width,o[m].height=f.height}a.image=o}else a.image.width=f.width,a.image.height=f.height,a.mipmaps=f.mipmaps;f.mipmapCount===1&&(a.minFilter=Mt),a.format=f.format,a.needsUpdate=!0,t&&t(a)},i,n);return a}}class uv extends ks{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=sc.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const a=ov("img");function l(){u(),sc.add(e,this),t&&t(this),r.manager.itemEnd(e)}function c(d){u(),n&&n(d),r.manager.itemError(e),r.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class Jj extends ks{constructor(e){super(e)}load(e,t,i,n){const r=new Wv;r.colorSpace=gt;const o=new uv(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(e[c],function(u){r.images[c]=u,a++,a===6&&(r.needsUpdate=!0,t&&t(r))},void 0,n)}for(let c=0;c<e.length;++c)l(c);return r}}class BT extends ks{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Nr,a=new Kn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(e,function(l){let c;try{c=r.parse(l)}catch(u){if(n!==void 0)n(u);else{console.error(u);return}}c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:us,o.wrapT=c.wrapT!==void 0?c.wrapT:us,o.magFilter=c.magFilter!==void 0?c.magFilter:Mt,o.minFilter=c.minFilter!==void 0?c.minFilter:Mt,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(o.colorSpace=c.colorSpace),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=br),c.mipmapCount===1&&(o.minFilter=Mt),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c)},i,n),o}}class al extends ks{constructor(e){super(e)}load(e,t,i,n){const r=new Dt,o=new uv(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},i,n),r}}let Uh=class extends ge{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new xe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}};class DT extends Uh{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ge.DEFAULT_UP),this.updateMatrix(),this.groundColor=new xe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const LS=new we,jB=new w,WB=new w;class OT{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new te(512,512),this.map=null,this.mapPass=null,this.matrix=new we,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new qv,this._frameExtents=new te(1,1),this._viewportCount=1,this._viewports=[new Ze(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;jB.setFromMatrixPosition(e.matrixWorld),t.position.copy(jB),WB.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(WB),t.updateMatrixWorld(),LS.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(LS),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(LS)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Kj extends OT{constructor(){super(new Qt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=fp*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(i!==t.fov||n!==t.aspect||r!==t.far)&&(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Ix extends Uh{constructor(e,t,i=0,n=Math.PI/3,r=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ge.DEFAULT_UP),this.updateMatrix(),this.target=new ge,this.distance=i,this.angle=n,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new Kj}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const qB=new we,wm=new w,kS=new w;class Zj extends OT{constructor(){super(new Qt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new te(4,2),this._viewportCount=6,this._viewports=[new Ze(2,1,1,1),new Ze(0,1,1,1),new Ze(3,1,1,1),new Ze(1,1,1,1),new Ze(3,0,1,1),new Ze(1,0,1,1)],this._cubeDirections=[new w(1,0,0),new w(-1,0,0),new w(0,0,1),new w(0,0,-1),new w(0,1,0),new w(0,-1,0)],this._cubeUps=[new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,0,1),new w(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,n=this.matrix,r=e.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),wm.setFromMatrixPosition(e.matrixWorld),i.position.copy(wm),kS.copy(i.position),kS.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(kS),i.updateMatrixWorld(),n.makeTranslation(-wm.x,-wm.y,-wm.z),qB.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(qB)}}class $v extends Uh{constructor(e,t,i=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new Zj}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class $j extends OT{constructor(){super(new yc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class mp extends Uh{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ge.DEFAULT_UP),this.updateMatrix(),this.target=new ge,this.shadow=new $j}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class LT extends Uh{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class iU extends Uh{constructor(e,t,i=10,n=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=n}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class nU{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new w)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,n=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*n),t.addScaledVector(o[2],.488603*r),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*n)),t.addScaledVector(o[5],1.092548*(n*r)),t.addScaledVector(o[6],.315392*(3*r*r-1)),t.addScaledVector(o[7],1.092548*(i*r)),t.addScaledVector(o[8],.546274*(i*i-n*n)),t}getIrradianceAt(e,t){const i=e.x,n=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*n),t.addScaledVector(o[2],2*.511664*r),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*n),t.addScaledVector(o[5],2*.429043*n*r),t.addScaledVector(o[6],.743125*r*r-.247708),t.addScaledVector(o[7],2*.429043*i*r),t.addScaledVector(o[8],.429043*(i*i-n*n)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(e,t+n*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(e,t+n*3);return e}static getBasisAt(e,t){const i=e.x,n=e.y,r=e.z;t[0]=.282095,t[1]=.488603*n,t[2]=.488603*r,t[3]=.488603*i,t[4]=1.092548*i*n,t[5]=1.092548*n*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*i*r,t[8]=.546274*(i*i-n*n)}}class sU extends Uh{constructor(e=new nU,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Rx extends ks{constructor(e){super(e),this.textures={}}load(e,t,i,n){const r=this,o=new Kn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(l){n?n(l):console.error(l),r.manager.itemError(e)}},i,n)}parse(e){const t=this.textures;function i(r){return t[r]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",r),t[r]}const n=Rx.createMaterialFromType(e.type);if(e.uuid!==void 0&&(n.uuid=e.uuid),e.name!==void 0&&(n.name=e.name),e.color!==void 0&&n.color!==void 0&&n.color.setHex(e.color),e.roughness!==void 0&&(n.roughness=e.roughness),e.metalness!==void 0&&(n.metalness=e.metalness),e.sheen!==void 0&&(n.sheen=e.sheen),e.sheenColor!==void 0&&(n.sheenColor=new xe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(n.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&n.emissive!==void 0&&n.emissive.setHex(e.emissive),e.specular!==void 0&&n.specular!==void 0&&n.specular.setHex(e.specular),e.specularIntensity!==void 0&&(n.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&n.specularColor!==void 0&&n.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(n.shininess=e.shininess),e.clearcoat!==void 0&&(n.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=e.clearcoatRoughness),e.iridescence!==void 0&&(n.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(n.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(n.transmission=e.transmission),e.thickness!==void 0&&(n.thickness=e.thickness),e.attenuationDistance!==void 0&&(n.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&n.attenuationColor!==void 0&&n.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(n.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(n.fog=e.fog),e.flatShading!==void 0&&(n.flatShading=e.flatShading),e.blending!==void 0&&(n.blending=e.blending),e.combine!==void 0&&(n.combine=e.combine),e.side!==void 0&&(n.side=e.side),e.shadowSide!==void 0&&(n.shadowSide=e.shadowSide),e.opacity!==void 0&&(n.opacity=e.opacity),e.transparent!==void 0&&(n.transparent=e.transparent),e.alphaTest!==void 0&&(n.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(n.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(n.depthFunc=e.depthFunc),e.depthTest!==void 0&&(n.depthTest=e.depthTest),e.depthWrite!==void 0&&(n.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(n.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(n.blendSrc=e.blendSrc),e.blendDst!==void 0&&(n.blendDst=e.blendDst),e.blendEquation!==void 0&&(n.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(n.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(n.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(n.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&n.blendColor!==void 0&&n.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(n.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(n.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(n.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(n.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(n.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(n.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(n.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(n.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(n.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(n.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(n.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(n.rotation=e.rotation),e.linewidth!==void 0&&(n.linewidth=e.linewidth),e.dashSize!==void 0&&(n.dashSize=e.dashSize),e.gapSize!==void 0&&(n.gapSize=e.gapSize),e.scale!==void 0&&(n.scale=e.scale),e.polygonOffset!==void 0&&(n.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(n.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(n.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(n.dithering=e.dithering),e.alphaToCoverage!==void 0&&(n.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(n.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(n.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(n.visible=e.visible),e.toneMapped!==void 0&&(n.toneMapped=e.toneMapped),e.userData!==void 0&&(n.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?n.vertexColors=e.vertexColors>0:n.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const r in e.uniforms){const o=e.uniforms[r];switch(n.uniforms[r]={},o.type){case"t":n.uniforms[r].value=i(o.value);break;case"c":n.uniforms[r].value=new xe().setHex(o.value);break;case"v2":n.uniforms[r].value=new te().fromArray(o.value);break;case"v3":n.uniforms[r].value=new w().fromArray(o.value);break;case"v4":n.uniforms[r].value=new Ze().fromArray(o.value);break;case"m3":n.uniforms[r].value=new Lt().fromArray(o.value);break;case"m4":n.uniforms[r].value=new we().fromArray(o.value);break;default:n.uniforms[r].value=o.value}}if(e.defines!==void 0&&(n.defines=e.defines),e.vertexShader!==void 0&&(n.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(n.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(n.glslVersion=e.glslVersion),e.extensions!==void 0)for(const r in e.extensions)n.extensions[r]=e.extensions[r];if(e.lights!==void 0&&(n.lights=e.lights),e.clipping!==void 0&&(n.clipping=e.clipping),e.size!==void 0&&(n.size=e.size),e.sizeAttenuation!==void 0&&(n.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(n.map=i(e.map)),e.matcap!==void 0&&(n.matcap=i(e.matcap)),e.alphaMap!==void 0&&(n.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(n.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(n.bumpScale=e.bumpScale),e.normalMap!==void 0&&(n.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(n.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),n.normalScale=new te().fromArray(r)}return e.displacementMap!==void 0&&(n.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(n.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(n.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(n.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(n.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(n.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(n.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(n.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(n.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(n.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(n.envMap=i(e.envMap)),e.envMapRotation!==void 0&&n.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(n.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(n.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(n.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(n.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(n.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(n.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(n.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(n.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(n.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(n.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(n.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(n.clearcoatNormalScale=new te().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(n.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(n.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(n.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(n.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(n.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(n.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(n.sheenRoughnessMap=i(e.sheenRoughnessMap)),n}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:Cx,SpriteMaterial:vT,RawShaderMaterial:Zv,ShaderMaterial:Pt,PointsMaterial:dx,MeshPhysicalMaterial:mo,MeshStandardMaterial:zr,MeshPhongMaterial:jF,MeshToonMaterial:WF,MeshNormalMaterial:Ex,MeshLambertMaterial:qF,MeshDepthMaterial:Xv,MeshDistanceMaterial:mT,MeshBasicMaterial:ai,MeshMatcapMaterial:XF,LineDashedMaterial:YF,LineBasicMaterial:Rn,Material:Nt};return new t[e]}}class Ah{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,n=e.length;i<n;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Px extends wt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class rU extends ks{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Kn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(l){n?n(l):console.error(l),r.manager.itemError(e)}},i,n)}parse(e){const t={},i={};function n(p,m){if(t[m]!==void 0)return t[m];const v=p.interleavedBuffers[m],g=r(p,v.buffer),_=Lf(v.type,g),y=new Yv(_,v.stride);return y.uuid=v.uuid,t[m]=y,y}function r(p,m){if(i[m]!==void 0)return i[m];const v=p.arrayBuffers[m],g=new Uint32Array(v).buffer;return i[m]=g,g}const o=e.isInstancedBufferGeometry?new Px:new wt,a=e.data.index;if(a!==void 0){const p=Lf(a.type,a.array);o.setIndex(new it(p,1))}const l=e.data.attributes;for(const p in l){const m=l[p];let A;if(m.isInterleavedBufferAttribute){const v=n(e.data,m.data);A=new xr(v,m.itemSize,m.offset,m.normalized)}else{const v=Lf(m.type,m.array),g=m.isInstancedBufferAttribute?Lr:it;A=new g(v,m.itemSize,m.normalized)}m.name!==void 0&&(A.name=m.name),m.usage!==void 0&&A.setUsage(m.usage),o.setAttribute(p,A)}const c=e.data.morphAttributes;if(c)for(const p in c){const m=c[p],A=[];for(let v=0,g=m.length;v<g;v++){const _=m[v];let y;if(_.isInterleavedBufferAttribute){const b=n(e.data,_.data);y=new xr(b,_.itemSize,_.offset,_.normalized)}else{const b=Lf(_.type,_.array);y=new it(b,_.itemSize,_.normalized)}_.name!==void 0&&(y.name=_.name),A.push(y)}o.morphAttributes[p]=A}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let p=0,m=d.length;p!==m;++p){const A=d[p];o.addGroup(A.start,A.count,A.materialIndex)}const f=e.data.boundingSphere;if(f!==void 0){const p=new w;f.center!==void 0&&p.fromArray(f.center),o.boundingSphere=new In(p,f.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}class eW extends ks{constructor(e){super(e)}load(e,t,i,n){const r=this,o=this.path===""?Ah.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new Kn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(d){n!==void 0&&n(d),console.error("THREE:ObjectLoader: Can't parse "+e+".",d.message);return}const u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){n!==void 0&&n(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}r.parse(c,t)},i,n)}async loadAsync(e,t){const i=this,n=this.path===""?Ah.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;const r=new Kn(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const o=await r.loadAsync(e,t),a=JSON.parse(o),l=a.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(a)}parse(e,t){const i=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),o=this.parseImages(e.images,function(){t!==void 0&&t(c)}),a=this.parseTextures(e.textures,o),l=this.parseMaterials(e.materials,a),c=this.parseObject(e.object,r,l,a,i),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),t!==void 0){let d=!1;for(const f in o)if(o[f].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),n=this.parseGeometries(e.geometries,i),r=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,r),a=this.parseMaterials(e.materials,o),l=this.parseObject(e.object,n,a,o,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,n=e.length;i<n;i++){const r=new Qu().fromJSON(e[i]);t[r.uuid]=r}return t}parseSkeletons(e,t){const i={},n={};if(t.traverse(function(r){r.isBone&&(n[r.uuid]=r)}),e!==void 0)for(let r=0,o=e.length;r<o;r++){const a=new Pp().fromJSON(e[r],n);i[a.uuid]=a}return i}parseGeometries(e,t){const i={};if(e!==void 0){const n=new rU;for(let r=0,o=e.length;r<o;r++){let a;const l=e[r];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":a=n.parse(l);break;default:l.type in VB?a=VB[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}a.uuid=l.uuid,l.name!==void 0&&(a.name=l.name),l.userData!==void 0&&(a.userData=l.userData),i[l.uuid]=a}}return i}parseMaterials(e,t){const i={},n={};if(e!==void 0){const r=new Rx;r.setTextures(t);for(let o=0,a=e.length;o<a;o++){const l=e[o];i[l.uuid]===void 0&&(i[l.uuid]=r.parse(l)),n[l.uuid]=i[l.uuid]}}return n}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const n=e[i],r=Sr.parse(n);t[r.uuid]=r}return t}parseImages(e,t){const i=this,n={};let r;function o(l){return i.manager.itemStart(l),r.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function a(l){if(typeof l=="string"){const c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return o(u)}else return l.data?{data:Lf(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new Tx(t);r=new uv(l),r.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){const d=e[c],f=d.url;if(Array.isArray(f)){const p=[];for(let m=0,A=f.length;m<A;m++){const v=f[m],g=a(v);g!==null&&(g instanceof HTMLImageElement?p.push(g):p.push(new Nr(g.data,g.width,g.height)))}n[d.uuid]=new ic(p)}else{const p=a(d.url);n[d.uuid]=new ic(p)}}}return n}async parseImagesAsync(e){const t=this,i={};let n;async function r(o){if(typeof o=="string"){const a=o,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await n.loadAsync(l)}else return o.data?{data:Lf(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){n=new uv(this.manager),n.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){const l=e[o],c=l.url;if(Array.isArray(c)){const u=[];for(let d=0,f=c.length;d<f;d++){const p=c[d],m=await r(p);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new Nr(m.data,m.width,m.height)))}i[l.uuid]=new ic(u)}else{const u=await r(l.url);i[l.uuid]=new ic(u)}}}return i}parseTextures(e,t){function i(r,o){return typeof r=="number"?r:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",r),o[r])}const n={};if(e!==void 0)for(let r=0,o=e.length;r<o;r++){const a=e[r];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);const l=t[a.image],c=l.data;let u;Array.isArray(c)?(u=new Wv,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new Nr:u=new Dt,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=i(a.mapping,tW)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=i(a.wrap[0],XB),u.wrapT=i(a.wrap[1],XB)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=i(a.minFilter,YB)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,YB)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),n[a.uuid]=u}return n}parseObject(e,t,i,n,r){let o;function a(f){return t[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",f),t[f]}function l(f){if(f!==void 0){if(Array.isArray(f)){const p=[];for(let m=0,A=f.length;m<A;m++){const v=f[m];i[v]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",v),p.push(i[v])}return p}return i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),i[f]}}function c(f){return n[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",f),n[f]}let u,d;switch(e.type){case"Scene":o=new ir,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new xe(e.background):o.background=c(e.background)),e.environment!==void 0&&(o.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new hx(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new cx(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new Qt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new yc(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new LT(e.color,e.intensity);break;case"DirectionalLight":o=new mp(e.color,e.intensity);break;case"PointLight":o=new $v(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new iU(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new Ix(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new DT(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new sU().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),d=l(e.material),o=new ga(u,d),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),d=l(e.material),o=new pe(u,d);break;case"InstancedMesh":u=a(e.geometry),d=l(e.material);const f=e.count,p=e.instanceMatrix,m=e.instanceColor;o=new ux(u,d,f),o.instanceMatrix=new Lr(new Float32Array(p.array),16),m!==void 0&&(o.instanceColor=new Lr(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=a(e.geometry),d=l(e.material),o=new DF(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,d),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(A=>{const v=new Ti;v.min.fromArray(A.boxMin),v.max.fromArray(A.boxMax);const g=new In;return g.radius=A.sphereRadius,g.center.fromArray(A.sphereCenter),{boxInitialized:A.boxInitialized,box:v,sphereInitialized:A.sphereInitialized,sphere:g}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=c(e.matricesTexture.uuid);break;case"LOD":o=new AT;break;case"Line":o=new Mn(a(e.geometry),l(e.material));break;case"LineLoop":o=new yT(a(e.geometry),l(e.material));break;case"LineSegments":o=new Ao(a(e.geometry),l(e.material));break;case"PointCloud":case"Points":o=new _T(a(e.geometry),l(e.material));break;case"Sprite":o=new BF(l(e.material));break;case"Group":o=new kr;break;case"Bone":o=new Jv;break;default:o=new ge}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const f=e.children;for(let p=0;p<f.length;p++)o.add(this.parseObject(f[p],t,i,n,r))}if(e.animations!==void 0){const f=e.animations;for(let p=0;p<f.length;p++){const m=f[p];o.animations.push(r[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);const f=e.levels;for(let p=0;p<f.length;p++){const m=f[p],A=o.getObjectByProperty("uuid",m.object);A!==void 0&&o.addLevel(A,m.distance,m.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const n=t[i.skeleton];n===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(n,i.bindMatrix)}})}}const tW={UVMapping:ex,CubeReflectionMapping:pc,CubeRefractionMapping:Eh,EquirectangularReflectionMapping:zo,EquirectangularRefractionMapping:up,CubeUVReflectionMapping:Ep},XB={RepeatWrapping:Go,ClampToEdgeWrapping:us,MirroredRepeatWrapping:id},YB={NearestFilter:Ht,NearestMipmapNearestFilter:dp,NearestMipmapLinearFilter:Xl,LinearFilter:Mt,LinearMipmapNearestFilter:Gu,LinearMipmapLinearFilter:br};class oU extends ks{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=sc.get(e);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(c=>{t&&t(c),r.manager.itemEnd(e)}).catch(c=>{n&&n(c)});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return sc.add(e,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){n&&n(c),sc.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});sc.add(e,l),r.manager.itemStart(e)}}let Zy;class Bx{static getContext(){return Zy===void 0&&(Zy=new(window.AudioContext||window.webkitAudioContext)),Zy}static setContext(e){Zy=e}}class ib extends ks{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Kn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{const c=l.slice(0);Bx.getContext().decodeAudioData(c,function(d){t(d)}).catch(a)}catch(c){a(c)}},i,n);function a(l){n?n(l):console.error(l),r.manager.itemError(e)}}}const JB=new we,KB=new we,ou=new we;class iW{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Qt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Qt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,ou.copy(e.projectionMatrix);const n=t.eyeSep/2,r=n*t.near/t.focus,o=t.near*Math.tan(Hu*t.fov*.5)/t.zoom;let a,l;KB.elements[12]=-n,JB.elements[12]=n,a=-o*t.aspect+r,l=o*t.aspect+r,ou.elements[0]=2*t.near/(l-a),ou.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(ou),a=-o*t.aspect-r,l=o*t.aspect-r,ou.elements[0]=2*t.near/(l-a),ou.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(ou)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(KB),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(JB)}}class kT{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ZB(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=ZB();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function ZB(){return(typeof performance>"u"?Date:performance).now()}const Ia=new w,$B=new Ce,nW=new w,au=new w;let aU=class extends ge{constructor(){super(),this.type="AudioListener",this.context=Bx.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new kT}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Ia,$B,nW),!(!Number.isFinite(Ia.x)||!Number.isFinite(Ia.y)||!Number.isFinite(Ia.z)))if(au.set(0,0,-1).applyQuaternion($B),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Ia.x,n),t.positionY.linearRampToValueAtTime(Ia.y,n),t.positionZ.linearRampToValueAtTime(Ia.z,n),t.forwardX.linearRampToValueAtTime(au.x,n),t.forwardY.linearRampToValueAtTime(au.y,n),t.forwardZ.linearRampToValueAtTime(au.z,n),t.upX.linearRampToValueAtTime(i.x,n),t.upY.linearRampToValueAtTime(i.y,n),t.upZ.linearRampToValueAtTime(i.z,n)}else t.setPosition(Ia.x,Ia.y,Ia.z),t.setOrientation(au.x,au.y,au.z,i.x,i.y,i.z)}},FT=class extends ge{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}};const lu=new w,e2=new Ce,sW=new w,cu=new w;class lU extends FT{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(lu,e2,sW),cu.set(0,0,1).applyQuaternion(e2);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(lu.x,i),t.positionY.linearRampToValueAtTime(lu.y,i),t.positionZ.linearRampToValueAtTime(lu.z,i),t.orientationX.linearRampToValueAtTime(cu.x,i),t.orientationY.linearRampToValueAtTime(cu.y,i),t.orientationZ.linearRampToValueAtTime(cu.z,i)}else t.setPosition(lu.x,lu.y,lu.z),t.setOrientation(cu.x,cu.y,cu.z)}}class rW{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class cU{constructor(e,t,i){this.binding=e,this.valueSize=i;let n,r,o;switch(t){case"quaternion":n=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:n=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,n=this.valueSize,r=e*n+n;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==n;++a)i[r+a]=i[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(i,r,0,a,n)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,n=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,n=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const l=t*this._origIndex;this._mixBufferRegion(i,n,l,1-r,t)}o>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){a.setValue(i,n);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let r=i,o=n;r!==o;++r)t[r]=t[n+r%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,n,r){if(n>=.5)for(let o=0;o!==r;++o)e[t+o]=e[i+o]}_slerp(e,t,i,n){Ce.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){const o=this._workIndex*r;Ce.multiplyQuaternionsFlat(e,o,e,t,e,i),Ce.slerpFlat(e,t,e,t,e,o,n)}_lerp(e,t,i,n,r){const o=1-n;for(let a=0;a!==r;++a){const l=t+a;e[l]=e[l]*o+e[i+a]*n}}_lerpAdditive(e,t,i,n,r){for(let o=0;o!==r;++o){const a=t+o;e[a]=e[a]+e[i+o]*n}}}const UT="\\[\\]\\.:\\/",oW=new RegExp("["+UT+"]","g"),NT="[^"+UT+"]",aW="[^"+UT.replace("\\.","")+"]",lW=/((?:WC+[\/:])*)/.source.replace("WC",NT),cW=/(WCOD+)?/.source.replace("WCOD",aW),hW=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",NT),uW=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",NT),dW=new RegExp("^"+lW+cW+hW+uW+"$"),fW=["material","materials","bones","map"];class pW{constructor(e,t,i){const n=i||Xt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class Xt{constructor(e,t,i){this.path=t,this.parsedPath=i||Xt.parseTrackName(t),this.node=Xt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Xt.Composite(e,t,i):new Xt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(oW,"")}static parseTrackName(e){const t=dW.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const r=i.nodeName.substring(n+1);fW.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=r)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(r){for(let o=0;o<r.length;o++){const a=r[o];if(a.name===t||a.uuid===t)return a;const l=i(a.children);if(l)return l}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let r=t.propertyIndex;if(e||(e=Xt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const o=e[n];if(o===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+n+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Xt.Composite=pW;Xt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Xt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Xt.prototype.GetterByBindingType=[Xt.prototype._getValue_direct,Xt.prototype._getValue_array,Xt.prototype._getValue_arrayElement,Xt.prototype._getValue_toArray];Xt.prototype.SetterByBindingTypeAndVersioning=[[Xt.prototype._setValue_direct,Xt.prototype._setValue_direct_setNeedsUpdate,Xt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Xt.prototype._setValue_array,Xt.prototype._setValue_array_setNeedsUpdate,Xt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Xt.prototype._setValue_arrayElement,Xt.prototype._setValue_arrayElement_setNeedsUpdate,Xt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Xt.prototype._setValue_fromArray,Xt.prototype._setValue_fromArray_setNeedsUpdate,Xt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class mW{constructor(){this.isAnimationObjectGroup=!0,this.uuid=uo(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,n=arguments.length;i!==n;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,o=r.length;let a,l=e.length,c=this.nCachedObjects_;for(let u=0,d=arguments.length;u!==d;++u){const f=arguments[u],p=f.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(f);for(let A=0,v=o;A!==v;++A)r[A].push(new Xt(f,i[A],n[A]))}else if(m<c){a=e[m];const A=--c,v=e[A];t[v.uuid]=m,e[m]=v,t[p]=A,e[A]=f;for(let g=0,_=o;g!==_;++g){const y=r[g],b=y[A];let E=y[m];y[m]=b,E===void 0&&(E=new Xt(f,i[g],n[g])),y[A]=E}}else e[m]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const l=arguments[o],c=l.uuid,u=t[c];if(u!==void 0&&u>=r){const d=r++,f=e[d];t[f.uuid]=u,e[u]=f,t[c]=d,e[d]=l;for(let p=0,m=n;p!==m;++p){const A=i[p],v=A[d],g=A[u];A[u]=v,A[d]=g}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){const c=arguments[a],u=c.uuid,d=t[u];if(d!==void 0)if(delete t[u],d<r){const f=--r,p=e[f],m=--o,A=e[m];t[p.uuid]=d,e[d]=p,t[A.uuid]=f,e[f]=A,e.pop();for(let v=0,g=n;v!==g;++v){const _=i[v],y=_[f],b=_[m];_[d]=y,_[f]=b,_.pop()}}else{const f=--o,p=e[f];f>0&&(t[p.uuid]=d),e[d]=p,e.pop();for(let m=0,A=n;m!==A;++m){const v=i[m];v[d]=v[f],v.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const i=this._bindingsIndicesByPath;let n=i[e];const r=this._bindings;if(n!==void 0)return r[n];const o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,d=new Array(c);n=r.length,i[e]=n,o.push(e),a.push(t),r.push(d);for(let f=u,p=l.length;f!==p;++f){const m=l[f];d[f]=new Xt(m,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const n=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=i,o[i]=l,o.pop(),r[i]=r[a],r.pop(),n[i]=n[a],n.pop()}}}class hU{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;const r=t.tracks,o=r.length,a=new Array(o),l={endingStart:Du,endingEnd:Du};for(let c=0;c!==o;++c){const u=r[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=sT,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}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const n=this._clip.duration,r=e._clip.duration,o=r/n,a=n/r;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const n=this._mixer,r=n.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=r,l[1]=r+i,c[0]=e/o,c[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,n){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const l=(e-r)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case rT:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case sx:default:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(o),c[u].accumulate(n,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let n=this.time+e,r=this._loopCount;const o=i===Wk;if(e===0)return r===-1?n:o&&(r&1)===1?t-n:n;if(i===$g){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=t||n<0){const a=Math.floor(n/t);n-=t*a,r+=Math.abs(a);const l=this.repetitions-r;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(r&1)===1)return t-n}return n}_setEndings(e,t,i){const n=this._interpolantSettings;i?(n.endingStart=Ou,n.endingEnd=Ou):(e?n.endingStart=this.zeroSlopeAtStart?Ou:Du:n.endingStart=ev,t?n.endingEnd=this.zeroSlopeAtEnd?Ou:Du:n.endingEnd=ev)}_scheduleFading(e,t,i){const n=this._mixer,r=n.time;let o=this._weightInterpolant;o===null&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=r,l[0]=t,a[1]=r+e,l[1]=i,this}}const gW=new Float32Array(1);class Dx extends ps{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,o=e._propertyBindings,a=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let d=0;d!==r;++d){const f=n[d],p=f.name;let m=u[p];if(m!==void 0)++m.referenceCount,o[d]=m;else{if(m=o[d],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const A=t&&t._propertyBindings[d].binding.parsedPath;m=new cU(Xt.create(i,p,A),f.ValueTypeName,f.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),o[d]=m}a[d].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,i)}const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const n=this._actions,r=this._actionsByClip;let o=r[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=o;else{const a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=n.length,n.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],n=e._cacheIndex;i._cacheIndex=n,t[n]=i,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,o=this._actionsByClip,a=o[r],l=a.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;const d=a.actionByRoot,f=(e._localRoot||this._root).uuid;delete d[f],l.length===0&&delete o[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,n=this._nActiveActions++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,n=--this._nActiveActions,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_addInactiveBinding(e,t,i){const n=this._bindingsByRootAndName,r=this._bindings;let o=n[t];o===void 0&&(o={},n[t]=o),o[i]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,n=i.rootNode.uuid,r=i.path,o=this._bindingsByRootAndName,a=o[n],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete a[r],Object.keys(a).length===0&&delete o[n]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,n=this._nActiveBindings++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,n=--this._nActiveBindings,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new PT(new Float32Array(2),new Float32Array(2),1,gW),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=t[n];e.__cacheIndex=n,t[n]=e,r.__cacheIndex=i,t[i]=r}clipAction(e,t,i){const n=t||this._root,r=n.uuid;let o=typeof e=="string"?Sr.findByName(n,e):e;const a=o!==null?o.uuid:e,l=this._actionsByClip[a];let c=null;if(i===void 0&&(o!==null?i=o.blendMode:i=sx),l!==void 0){const d=l.actionByRoot[r];if(d!==void 0&&d.blendMode===i)return d;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;const u=new hU(this,o,t,i);return this._bindAction(u,c),this._addInactiveAction(u,a,r),u}existingAction(e,t){const i=t||this._root,n=i.uuid,r=typeof e=="string"?Sr.findByName(i,e):e,o=r?r.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[n]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,n=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(n,e,r,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,n=this._actionsByClip,r=n[i];if(r!==void 0){const o=r.knownActions;for(let a=0,l=o.length;a!==l;++a){const c=o[a];this._deactivateAction(c);const u=c._cacheIndex,d=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,d._cacheIndex=u,t[u]=d,t.pop(),this._removeInactiveBindingsForAction(c)}delete n[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const o in i){const a=i[o].actionByRoot,l=a[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const n=this._bindingsByRootAndName,r=n[t];if(r!==void 0)for(const o in r){const a=r[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class _e{constructor(e){this.value=e}clone(){return new _e(this.value.clone===void 0?this.value:this.value.clone())}}let vW=0;class AW extends ps{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:vW++}),this.name="",this.usage=sv,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let i=0,n=t.length;i<n;i++){const r=Array.isArray(t[i])?t[i]:[t[i]];for(let o=0;o<r.length;o++)this.uniforms.push(r[o].clone())}return this}clone(){return new this.constructor().copy(this)}}class nb extends Yv{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class yW{constructor(e,t,i,n,r){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=n,this.count=r,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const t2=new we;let pd=class{constructor(e,t,i=0,n=1/0){this.ray=new Hr(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new er,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return t2.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(t2),this}intersectObject(e,t=!0,i=[]){return u1(e,this,i,t),i.sort(i2),i}intersectObjects(e,t=!0,i=[]){for(let n=0,r=e.length;n<r;n++)u1(e[n],this,i,t);return i.sort(i2),i}};function i2(s,e){return s.distance-e.distance}function u1(s,e,t,i){if(s.layers.test(e.layers)&&s.raycast(e,t),i===!0){const n=s.children;for(let r=0,o=n.length;r<o;r++)u1(n[r],e,t,!0)}}class d1{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(An(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class _W{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}const n2=new te;class bW{constructor(e=new te(1/0,1/0),t=new te(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=n2.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(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(e,t){return 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(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,n2).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const s2=new w,$y=new w;class zT{constructor(e=new w,t=new w){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){s2.subVectors(e,this.start),$y.subVectors(this.end,this.start);const i=$y.dot($y);let r=$y.dot(s2)/i;return t&&(r=An(r,0,1)),r}closestPointToPoint(e,t,i){const n=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(n).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const r2=new w;class xW extends ge{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new wt,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){const c=o/l*Math.PI*2,u=a/l*Math.PI*2;n.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new ut(n,3));const r=new Rn({fog:!1,toneMapped:!1});this.cone=new Ao(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),r2.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(r2),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Hc=new w,e0=new we,FS=new we;class wW extends Ao{constructor(e){const t=uU(e),i=new wt,n=[],r=[],o=new xe(0,0,1),a=new xe(0,1,0);for(let c=0;c<t.length;c++){const u=t[c];u.parent&&u.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(o.r,o.g,o.b),r.push(a.r,a.g,a.b))}i.setAttribute("position",new ut(n,3)),i.setAttribute("color",new ut(r,3));const l=new Rn({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,n=i.getAttribute("position");FS.copy(this.root.matrixWorld).invert();for(let r=0,o=0;r<t.length;r++){const a=t[r];a.parent&&a.parent.isBone&&(e0.multiplyMatrices(FS,a.matrixWorld),Hc.setFromMatrixPosition(e0),n.setXYZ(o,Hc.x,Hc.y,Hc.z),e0.multiplyMatrices(FS,a.parent.matrixWorld),Hc.setFromMatrixPosition(e0),n.setXYZ(o+1,Hc.x,Hc.y,Hc.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function uU(s){const e=[];s.isBone===!0&&e.push(s);for(let t=0;t<s.children.length;t++)e.push.apply(e,uU(s.children[t]));return e}class SW extends pe{constructor(e,t,i){const n=new Sa(t,4,2),r=new ai({wireframe:!0,fog:!1,toneMapped:!1});super(n,r),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const CW=new w,o2=new xe,a2=new xe;class EW extends ge{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new nc(t);n.rotateY(Math.PI*.5),this.material=new ai({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),o=new Float32Array(r.count*3);n.setAttribute("color",new it(o,3)),this.add(new pe(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");o2.copy(this.light.color),a2.copy(this.light.groundColor);for(let i=0,n=t.count;i<n;i++){const r=i<n/2?o2:a2;t.setXYZ(i,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(CW.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Ox=class extends Ao{constructor(e=10,t=10,i=4473924,n=8947848){i=new xe(i),n=new xe(n);const r=t/2,o=e/t,a=e/2,l=[],c=[];for(let f=0,p=0,m=-a;f<=t;f++,m+=o){l.push(-a,0,m,a,0,m),l.push(m,0,-a,m,0,a);const A=f===r?i:n;A.toArray(c,p),p+=3,A.toArray(c,p),p+=3,A.toArray(c,p),p+=3,A.toArray(c,p),p+=3}const u=new wt;u.setAttribute("position",new ut(l,3)),u.setAttribute("color",new ut(c,3));const d=new Rn({vertexColors:!0,toneMapped:!1});super(u,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class MW extends Ao{constructor(e=10,t=16,i=8,n=64,r=4473924,o=8947848){r=new xe(r),o=new xe(o);const a=[],l=[];if(t>1)for(let d=0;d<t;d++){const f=d/t*(Math.PI*2),p=Math.sin(f)*e,m=Math.cos(f)*e;a.push(0,0,0),a.push(p,0,m);const A=d&1?r:o;l.push(A.r,A.g,A.b),l.push(A.r,A.g,A.b)}for(let d=0;d<i;d++){const f=d&1?r:o,p=e-e/i*d;for(let m=0;m<n;m++){let A=m/n*(Math.PI*2),v=Math.sin(A)*p,g=Math.cos(A)*p;a.push(v,0,g),l.push(f.r,f.g,f.b),A=(m+1)/n*(Math.PI*2),v=Math.sin(A)*p,g=Math.cos(A)*p,a.push(v,0,g),l.push(f.r,f.g,f.b)}}const c=new wt;c.setAttribute("position",new ut(a,3)),c.setAttribute("color",new ut(l,3));const u=new Rn({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const l2=new w,t0=new w,c2=new w;class dU extends ge{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let n=new wt;n.setAttribute("position",new ut([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Rn({fog:!1,toneMapped:!1});this.lightPlane=new Mn(n,r),this.add(this.lightPlane),n=new wt,n.setAttribute("position",new ut([0,0,0,0,0,1],3)),this.targetLine=new Mn(n,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),l2.setFromMatrixPosition(this.light.matrixWorld),t0.setFromMatrixPosition(this.light.target.matrixWorld),c2.subVectors(t0,l2),this.lightPlane.lookAt(t0),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(t0),this.targetLine.scale.z=c2.length()}}const i0=new w,gn=new jv;class fU extends Ao{constructor(e){const t=new wt,i=new Rn({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,A){l(m),l(A)}function l(m){n.push(0,0,0),r.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(n.length/3-1)}t.setAttribute("position",new ut(n,3)),t.setAttribute("color",new ut(r,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const c=new xe(16755200),u=new xe(16711680),d=new xe(43775),f=new xe(16777215),p=new xe(3355443);this.setColors(c,u,d,f,p)}setColors(e,t,i,n,r){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,n.r,n.g,n.b),a.setXYZ(39,n.r,n.g,n.b),a.setXYZ(40,r.r,r.g,r.b),a.setXYZ(41,r.r,r.g,r.b),a.setXYZ(42,r.r,r.g,r.b),a.setXYZ(43,r.r,r.g,r.b),a.setXYZ(44,r.r,r.g,r.b),a.setXYZ(45,r.r,r.g,r.b),a.setXYZ(46,r.r,r.g,r.b),a.setXYZ(47,r.r,r.g,r.b),a.setXYZ(48,r.r,r.g,r.b),a.setXYZ(49,r.r,r.g,r.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,i=1,n=1;gn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),xn("c",t,e,gn,0,0,-1),xn("t",t,e,gn,0,0,1),xn("n1",t,e,gn,-i,-n,-1),xn("n2",t,e,gn,i,-n,-1),xn("n3",t,e,gn,-i,n,-1),xn("n4",t,e,gn,i,n,-1),xn("f1",t,e,gn,-i,-n,1),xn("f2",t,e,gn,i,-n,1),xn("f3",t,e,gn,-i,n,1),xn("f4",t,e,gn,i,n,1),xn("u1",t,e,gn,i*.7,n*1.1,-1),xn("u2",t,e,gn,-i*.7,n*1.1,-1),xn("u3",t,e,gn,0,n*2,-1),xn("cf1",t,e,gn,-i,0,1),xn("cf2",t,e,gn,i,0,1),xn("cf3",t,e,gn,0,-n,1),xn("cf4",t,e,gn,0,n,1),xn("cn1",t,e,gn,-i,0,-1),xn("cn2",t,e,gn,i,0,-1),xn("cn3",t,e,gn,0,-n,-1),xn("cn4",t,e,gn,0,n,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function xn(s,e,t,i,n,r,o){i0.set(n,r,o).unproject(i);const a=e[s];if(a!==void 0){const l=t.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],i0.x,i0.y,i0.z)}}const n0=new Ti;class GT extends Ao{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(8*3),r=new wt;r.setIndex(new it(i,1)),r.setAttribute("position",new it(n,3)),super(r,new Rn({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&n0.setFromObject(this.object),n0.isEmpty())return;const t=n0.min,i=n0.max,n=this.geometry.attributes.position,r=n.array;r[0]=i.x,r[1]=i.y,r[2]=i.z,r[3]=t.x,r[4]=i.y,r[5]=i.z,r[6]=t.x,r[7]=t.y,r[8]=i.z,r[9]=i.x,r[10]=t.y,r[11]=i.z,r[12]=i.x,r[13]=i.y,r[14]=t.z,r[15]=t.x,r[16]=i.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=i.x,r[22]=t.y,r[23]=t.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class f1 extends Ao{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],r=new wt;r.setIndex(new it(i,1)),r.setAttribute("position",new ut(n,3)),super(r,new Rn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class TW extends Mn{constructor(e,t=1,i=16776960){const n=i,r=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new wt;o.setAttribute("position",new ut(r,3)),o.computeBoundingSphere(),super(o,new Rn({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new wt;l.setAttribute("position",new ut(a,3)),l.computeBoundingSphere(),this.add(new pe(l,new ai({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const h2=new w;let s0,US;class IW extends ge{constructor(e=new w(0,0,1),t=new w(0,0,0),i=1,n=16776960,r=i*.2,o=r*.2){super(),this.type="ArrowHelper",s0===void 0&&(s0=new wt,s0.setAttribute("position",new ut([0,0,0,0,1,0],3)),US=new Sn(0,.5,1,5,1),US.translate(0,-.5,0)),this.position.copy(t),this.line=new Mn(s0,new Rn({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new pe(US,new ai({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,r,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{h2.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(h2,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}let Ho=class extends Ao{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],n=new wt;n.setAttribute("position",new ut(t,3)),n.setAttribute("color",new ut(i,3));const r=new Rn({vertexColors:!0,toneMapped:!1});super(n,r),this.type="AxesHelper"}setColors(e,t,i){const n=new xe,r=this.geometry.attributes.color.array;return n.set(e),n.toArray(r,0),n.toArray(r,3),n.set(t),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};class RW{constructor(){this.type="ShapePath",this.color=new xe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new av,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,n){return this.currentPath.quadraticCurveTo(e,t,i,n),this}bezierCurveTo(e,t,i,n,r,o){return this.currentPath.bezierCurveTo(e,t,i,n,r,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const _=[];for(let y=0,b=g.length;y<b;y++){const E=g[y],M=new Qu;M.curves=E.curves,_.push(M)}return _}function i(g,_){const y=_.length;let b=!1;for(let E=y-1,M=0;M<y;E=M++){let T=_[E],C=_[M],B=C.x-T.x,S=C.y-T.y;if(Math.abs(S)>Number.EPSILON){if(S<0&&(T=_[M],B=-B,C=_[E],S=-S),g.y<T.y||g.y>C.y)continue;if(g.y===T.y){if(g.x===T.x)return!0}else{const R=S*(g.x-T.x)-B*(g.y-T.y);if(R===0)return!0;if(R<0)continue;b=!b}}else{if(g.y!==T.y)continue;if(C.x<=g.x&&g.x<=T.x||T.x<=g.x&&g.x<=C.x)return!0}}return b}const n=ol.isClockWise,r=this.subPaths;if(r.length===0)return[];let o,a,l;const c=[];if(r.length===1)return a=r[0],l=new Qu,l.curves=a.curves,c.push(l),c;let u=!n(r[0].getPoints());u=e?!u:u;const d=[],f=[];let p=[],m=0,A;f[m]=void 0,p[m]=[];for(let g=0,_=r.length;g<_;g++)a=r[g],A=a.getPoints(),o=n(A),o=e?!o:o,o?(!u&&f[m]&&m++,f[m]={s:new Qu,p:A},f[m].s.curves=a.curves,u&&m++,p[m]=[]):p[m].push({h:a,p:A[0]});if(!f[0])return t(r);if(f.length>1){let g=!1,_=0;for(let y=0,b=f.length;y<b;y++)d[y]=[];for(let y=0,b=f.length;y<b;y++){const E=p[y];for(let M=0;M<E.length;M++){const T=E[M];let C=!0;for(let B=0;B<f.length;B++)i(T.p,f[B].p)&&(y!==B&&_++,C?(C=!1,d[B].push(T)):g=!0);C&&d[y].push(T)}}_>0&&g===!1&&(p=d)}let v;for(let g=0,_=f.length;g<_;g++){l=f[g].s,c.push(l),v=p[g];for(let y=0,b=v.length;y<b;y++)l.holes.push(v[y].h)}return c}}class pU extends Yt{constructor(e=1,t=1,i=1,n={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...n,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:fc}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+fc):window.__THREE__=fc);const PW=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Zb,AddEquation:ah,AddOperation:kk,AdditiveAnimationBlendMode:rT,AdditiveBlending:ed,AgXToneMapping:KM,AlphaFormat:Qk,AlwaysCompare:mF,AlwaysDepth:Yb,AlwaysStencilFunc:K_,AmbientLight:LT,AnimationAction:hU,AnimationClip:Sr,AnimationLoader:Xj,AnimationMixer:Dx,AnimationObjectGroup:mW,AnimationUtils:Vj,ArcCurve:FF,ArrayCamera:gT,ArrowHelper:IW,AttachedBindMode:kE,Audio:FT,AudioAnalyser:rW,AudioContext:Bx,AudioListener:aU,AudioLoader:ib,AxesHelper:Ho,BackSide:_n,BasicDepthPacking:Ds,BasicShadowMap:wH,BatchedMesh:DF,Bone:Jv,BooleanKeyframeTrack:dd,Box2:bW,Box3:Ti,Box3Helper:f1,BoxGeometry:Li,BoxHelper:GT,BufferAttribute:it,BufferGeometry:wt,BufferGeometryLoader:rU,ByteType:Gk,Cache:sc,Camera:jv,CameraHelper:fU,CanvasTexture:bT,CapsuleGeometry:px,CatmullRomCurve3:UF,CineonToneMapping:Uk,CircleGeometry:mx,ClampToEdgeWrapping:us,Clock:kT,Color:xe,ColorKeyframeTrack:Mx,ColorManagement:vi,CompressedArrayTexture:LF,CompressedCubeTexture:kF,CompressedTexture:rl,CompressedTextureLoader:Yj,ConeGeometry:gx,ConstantAlphaFactor:Dk,ConstantColorFactor:Pk,CubeCamera:dT,CubeReflectionMapping:pc,CubeRefractionMapping:Eh,CubeTexture:Wv,CubeTextureLoader:Jj,CubeUVReflectionMapping:Ep,CubicBezierCurve:wT,CubicBezierCurve3:NF,CubicInterpolant:ZF,CullFaceBack:BE,CullFaceFront:yk,CullFaceFrontBack:xH,CullFaceNone:Ak,Curve:wa,CurvePath:GF,CustomBlending:YM,CustomToneMapping:Nk,CylinderGeometry:Sn,Cylindrical:_W,Data3DTexture:ax,DataArrayTexture:ox,DataTexture:Nr,DataTextureLoader:BT,DataUtils:Lu,DecrementStencilOp:$k,DecrementWrapStencilOp:tF,DefaultLoadingManager:tU,DepthFormat:vh,DepthStencilFormat:Mh,DepthTexture:Ip,DetachedBindMode:zk,DirectionalLight:mp,DirectionalLightHelper:dU,DiscreteInterpolant:$F,DisplayP3ColorSpace:Vv,DodecahedronGeometry:vx,DoubleSide:mi,DstAlphaFactor:Ek,DstColorFactor:Tk,DynamicCopyUsage:DH,DynamicDrawUsage:Ks,DynamicReadUsage:RH,EdgesGeometry:TT,EllipseCurve:fx,EqualCompare:uF,EqualDepth:cp,EqualStencilFunc:sF,EquirectangularReflectionMapping:zo,EquirectangularRefractionMapping:up,Euler:Gi,EventDispatcher:ps,ExtrudeGeometry:yx,FileLoader:Kn,Float16BufferAttribute:vQ,Float32BufferAttribute:ut,FloatType:Ni,Fog:hx,FogExp2:cx,FramebufferTexture:pj,FrontSide:Bs,Frustum:qv,GLBufferAttribute:yW,GLSL1:LH,GLSL3:Z_,GreaterCompare:dF,GreaterDepth:Kb,GreaterEqualCompare:pF,GreaterEqualDepth:Jb,GreaterEqualStencilFunc:lF,GreaterStencilFunc:oF,GridHelper:Ox,Group:kr,HalfFloatType:cn,HemisphereLight:DT,HemisphereLightHelper:EW,IcosahedronGeometry:_x,ImageBitmapLoader:oU,ImageLoader:uv,ImageUtils:cT,IncrementStencilOp:Zk,IncrementWrapStencilOp:eF,InstancedBufferAttribute:Lr,InstancedBufferGeometry:Px,InstancedInterleavedBuffer:nb,InstancedMesh:ux,Int16BufferAttribute:mQ,Int32BufferAttribute:gQ,Int8BufferAttribute:dQ,IntType:ZM,InterleavedBuffer:Yv,InterleavedBufferAttribute:xr,Interpolant:Bp,InterpolateDiscrete:Th,InterpolateLinear:dl,InterpolateSmooth:l_,InvertStencilOp:iF,KeepStencilOp:ih,KeyframeTrack:Ca,LOD:AT,LatheGeometry:Kv,Layers:er,LessCompare:hF,LessDepth:Kg,LessEqualCompare:aT,LessEqualDepth:td,LessEqualStencilFunc:rF,LessStencilFunc:nF,Light:Uh,LightProbe:sU,Line:Mn,Line3:zT,LineBasicMaterial:Rn,LineCurve:ST,LineCurve3:zF,LineDashedMaterial:YF,LineLoop:yT,LineSegments:Ao,LinearDisplayP3ColorSpace:Mp,LinearEncoding:Xk,LinearFilter:Mt,LinearInterpolant:PT,LinearMipMapLinearFilter:MH,LinearMipMapNearestFilter:EH,LinearMipmapLinearFilter:br,LinearMipmapNearestFilter:Gu,LinearSRGBColorSpace:yi,LinearToneMapping:hp,LinearTransfer:tv,Loader:ks,LoaderUtils:Ah,LoadingManager:Tx,LoopOnce:$g,LoopPingPong:Wk,LoopRepeat:sT,LuminanceAlphaFormat:Vk,LuminanceFormat:ix,MOUSE:wu,Material:Nt,MaterialLoader:Rx,MathUtils:Jn,Matrix3:Lt,Matrix4:we,MaxEquation:H_,Mesh:pe,MeshBasicMaterial:ai,MeshDepthMaterial:Xv,MeshDistanceMaterial:mT,MeshLambertMaterial:qF,MeshMatcapMaterial:XF,MeshNormalMaterial:Ex,MeshPhongMaterial:jF,MeshPhysicalMaterial:mo,MeshStandardMaterial:zr,MeshToonMaterial:WF,MinEquation:LE,MirroredRepeatWrapping:id,MixOperation:Lk,MultiplyBlending:OE,MultiplyOperation:Qv,NearestFilter:Ht,NearestMipMapLinearFilter:CH,NearestMipMapNearestFilter:SH,NearestMipmapLinearFilter:Xl,NearestMipmapNearestFilter:dp,NeutralToneMapping:$b,NeverCompare:cF,NeverDepth:JM,NeverStencilFunc:n1,NoBlending:Zi,NoColorSpace:$s,NoToneMapping:ho,NormalAnimationBlendMode:sx,NormalBlending:gh,NotEqualCompare:fF,NotEqualDepth:Hv,NotEqualStencilFunc:aF,NumberKeyframeTrack:Ih,Object3D:ge,ObjectLoader:eW,ObjectSpaceNormalMap:Yk,OctahedronGeometry:nc,OneFactor:wk,OneMinusConstantAlphaFactor:Ok,OneMinusConstantColorFactor:Bk,OneMinusDstAlphaFactor:Mk,OneMinusDstColorFactor:Ik,OneMinusSrcAlphaFactor:V_,OneMinusSrcColorFactor:Ck,OrthographicCamera:yc,P3Primaries:nv,PCFShadowMap:qM,PCFSoftShadowMap:XM,PMREMGenerator:r1,Path:av,PerspectiveCamera:Qt,Plane:Ar,PlaneGeometry:zn,PlaneHelper:TW,PointLight:$v,PointLightHelper:SW,Points:_T,PointsMaterial:dx,PolarGridHelper:MW,PolyhedronGeometry:Fh,PositionalAudio:lU,PropertyBinding:Xt,PropertyMixer:cU,QuadraticBezierCurve:CT,QuadraticBezierCurve3:ET,Quaternion:Ce,QuaternionKeyframeTrack:fl,QuaternionLinearInterpolant:eU,RED_GREEN_RGTC2_Format:e1,RED_RGTC1_Format:jk,REVISION:fc,RGBADepthPacking:rx,RGBAFormat:Ai,RGBAIntegerFormat:nT,RGBA_ASTC_10x10_Format:XE,RGBA_ASTC_10x5_Format:jE,RGBA_ASTC_10x6_Format:WE,RGBA_ASTC_10x8_Format:qE,RGBA_ASTC_12x10_Format:YE,RGBA_ASTC_12x12_Format:JE,RGBA_ASTC_4x4_Format:Y_,RGBA_ASTC_5x4_Format:NE,RGBA_ASTC_5x5_Format:zE,RGBA_ASTC_6x5_Format:GE,RGBA_ASTC_6x6_Format:Zg,RGBA_ASTC_8x5_Format:HE,RGBA_ASTC_8x6_Format:QE,RGBA_ASTC_8x8_Format:VE,RGBA_BPTC_Format:_g,RGBA_ETC2_EAC_Format:X_,RGBA_PVRTC_2BPPV1_Format:UE,RGBA_PVRTC_4BPPV1_Format:W_,RGBA_S3TC_DXT1_Format:o_,RGBA_S3TC_DXT3_Format:a_,RGBA_S3TC_DXT5_Format:yg,RGB_BPTC_SIGNED_Format:KE,RGB_BPTC_UNSIGNED_Format:ZE,RGB_ETC1_Format:nx,RGB_ETC2_Format:q_,RGB_PVRTC_2BPPV1_Format:FE,RGB_PVRTC_4BPPV1_Format:j_,RGB_S3TC_DXT1_Format:Ag,RGFormat:hh,RGIntegerFormat:iT,RawShaderMaterial:Zv,Ray:Hr,Raycaster:pd,Rec709Primaries:iv,RectAreaLight:iU,RedFormat:pa,RedIntegerFormat:tT,ReinhardToneMapping:Fk,RenderTarget:yF,RepeatWrapping:Go,ReplaceStencilOp:Kk,ReverseSubtractEquation:bk,RingGeometry:sd,SIGNED_RED_GREEN_RGTC2_Format:t1,SIGNED_RED_RGTC1_Format:$E,SRGBColorSpace:gt,SRGBTransfer:Oi,Scene:ir,ShaderChunk:zt,ShaderLib:Ts,ShaderMaterial:Pt,ShadowMaterial:Cx,Shape:Qu,ShapeGeometry:bx,ShapePath:RW,ShapeUtils:ol,ShortType:Hk,Skeleton:Pp,SkeletonHelper:wW,SkinnedMesh:ga,Source:ic,Sphere:In,SphereGeometry:Sa,Spherical:d1,SphericalHarmonics3:nU,SplineCurve:MT,SpotLight:Ix,SpotLightHelper:xW,Sprite:BF,SpriteMaterial:vT,SrcAlphaFactor:Q_,SrcAlphaSaturateFactor:Rk,SrcColorFactor:Sk,StaticCopyUsage:BH,StaticDrawUsage:sv,StaticReadUsage:IH,StereoCamera:iW,StreamCopyUsage:OH,StreamDrawUsage:TH,StreamReadUsage:PH,StringKeyframeTrack:fd,SubtractEquation:_k,SubtractiveBlending:DE,TOUCH:Su,TangentSpaceNormalMap:kh,TetrahedronGeometry:xx,Texture:Dt,TextureLoader:al,TorusGeometry:Jl,TorusKnotGeometry:wx,Triangle:_r,TriangleFanDrawMode:J_,TriangleStripDrawMode:oT,TrianglesDrawMode:qk,TubeGeometry:Sx,UVMapping:ex,Uint16BufferAttribute:hT,Uint32BufferAttribute:uT,Uint8BufferAttribute:fQ,Uint8ClampedBufferAttribute:pQ,Uniform:_e,UniformsGroup:AW,UniformsLib:Fe,UniformsUtils:Tp,UnsignedByteType:di,UnsignedInt248Type:ac,UnsignedIntType:fa,UnsignedShort4444Type:$M,UnsignedShort5551Type:eT,UnsignedShortType:tx,VSMShadowMap:Ua,Vector2:te,Vector3:w,Vector4:Ze,VectorKeyframeTrack:mc,VideoTexture:OF,WebGL1Renderer:IF,WebGL3DRenderTarget:tQ,WebGLArrayRenderTarget:eQ,WebGLCoordinateSystem:Za,WebGLCubeRenderTarget:fT,WebGLMultipleRenderTargets:pU,WebGLRenderTarget:Yt,WebGLRenderer:_c,WebGLUtils:TF,WebGPUCoordinateSystem:rv,WireframeGeometry:IT,WrapAroundEnding:ev,ZeroCurvatureEnding:Du,ZeroFactor:xk,ZeroSlopeEnding:Ou,ZeroStencilOp:Jk,_SRGBAFormat:$_,createCanvasElement:vF,sRGBEncoding:i1},Symbol.toStringTag,{value:"Module"})),NS=new Map;function Gr(s=(e=>(e=globalThis.location)==null?void 0:e.hostname)()){if(NS.has(s))return NS.get(s);const t=/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|localhost/.test(s);return NS.set(s,t),t===!0}function mU(){return window.location.hostname.includes("glitch.me")}var kn=(s=>(s.ContextRegistered="ContextRegistered",s.ContextCreationStart="ContextCreationStart",s.ContextCreated="ContextCreated",s.ContextFirstFrameRendered="ContextFirstFrameRendered",s.ContextDestroyed="ContextDestroyed",s.MissingCamera="MissingCamera",s.ContextClearing="ContextClearing",s.ContextCleared="ContextCleared",s))(kn||{});class hi{static get Current(){return globalThis["NeedleEngine.Context.Current"]}static set Current(e){globalThis["NeedleEngine.Context.Current"]=e}static get All(){return this.Registered}static register(e){this.Registered.push(e),this.dispatchCallback("ContextRegistered",e)}static unregister(e){const t=this.Registered.indexOf(e);t!==-1&&this.Registered.splice(t,1)}static registerCallback(e,t){this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(t)}static unregisterCallback(e,t){if(!this._callbacks[e])return;const i=this._callbacks[e].indexOf(t);i!==-1&&this._callbacks[e].splice(i,1)}static dispatchCallback(e,t,i){if(!this._callbacks[e])return!0;const n={event:e,context:t};if(i)for(const o in i)n[o]=i[o];const r=new Array;return this._callbacks[e].forEach(o=>{const a=o(n);a instanceof Promise&&r.push(a)}),Promise.all(r)}static addContextCreatedCallback(e){this.registerCallback("ContextCreated",e)}static addContextDestroyedCallback(e){this.registerCallback("ContextDestroyed",e)}}h(hi,"Registered",[]),h(hi,"_callbacks",{});const gU=()=>s=>s;function BW(s){return gU()(s)}function DW(){return!!ne("debug")}class Qo{constructor(e,t){h(this,"_factory");h(this,"_cache",[]);h(this,"_maxSize");h(this,"_index",0);this._factory=e,this._maxSize=t}get(){const e=this._index%this._maxSize;return this._index++,this._cache.length<=e&&(this._cache[e]=this._factory()),this._cache[e]}}let HT=!1;const p1=[];setTimeout(()=>{HT&&console.log(p1.sort())},100);function eA(){var s;return new URLSearchParams((s=globalThis.location)==null?void 0:s.search)}function ne(s){HT&&!p1.includes(s)&&p1.push(s);const e=eA();if(e.has(s)){const t=e.get(s);if(t){const i=Number(t);return isNaN(i)?t:i}else return!0}return!1}HT=ne("help")===!0;function OW(s,e){const t=eA();t.has(s)?t.set(s,e):t.append(s,e),document.location.search=t.toString()}function sb(s,e,t=!0){const i=eA();i.has(s)?e===null?i.delete(s):i.set(s,e):e!==null&&i.append(s,e),t?vU(s,i):QT(s,i)}function m1(s,e,t){s.has(e)?s.set(e,t.toString()):s.append(e,t.toString())}function vU(s,e,t){window.history.pushState(t,s,"?"+e.toString())}function QT(s,e,t){window.history.replaceState(t,s,"?"+e.toString())}function LW(s){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=t.length,n=0;n<s;n++)e+=t.charAt(Math.floor(Math.random()*i));return e}function kW(s,e){return Math.floor(Math.random()*(e-s+1))+s}const u2=["smol","tiny","giant","interesting","smart","bright","dull","extreme","beautiful","pretty","dark","epic","salty","silly","funny","lame","lazy","loud","lucky","mad","mean","mighty","mysterious","nasty","odd","old","powerful","quiet","rapid","scary","shiny","shy","silly","smooth","sour","spicy","stupid","sweet","tasty","terrible","ugly","unusual","vast","wet","wild","witty","wrong","zany","zealous","zippy","zombie","zorro"],d2=["cat","dog","mouse","pig","cow","horse","sheep","chicken","duck","goat","panda","tiger","lion","elephant","monkey","bird","fish","snake","frog","turtle","hamster","penguin","kangaroo","whale","dolphin","crocodile","snail","ant","bee","beetle","butterfly","dragon","eagle","fish","giraffe","lizard","panda","penguin","rabbit","snake","spider","tiger","zebra"];function AU(){const s=u2[Math.floor(Math.random()*u2.length)],e=d2[Math.floor(Math.random()*d2.length)];return s+"_"+e}function yU(s){return s=s.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,""),s.trim()}function gp(s,e,t=!0,i=!1){var n;if(e==null)return null;if(e.userData&&e.userData.guid===s)return e;if(e.guid==s)return e;if(i&&(n=e.userData)!=null&&n.components){for(const r of e.userData.components)if(r.guid===s)return r}if(t){if(e.scenes)for(const r in e.scenes){const o=e.scenes[r],a=gp(s,o,t,i);if(a)return a}if(e.children)for(const r in e.children){const o=e.children[r],a=gp(s,o,t,i);if(a)return a}}}function tA(s,e){if(s!=null&&typeof s=="object"){let t;Array.isArray(s)?t=[]:(t=Object.create(s),Object.assign(t,s));for(const i of Object.keys(s)){const n=s[i];e&&!e(s,i,n)?t[i]=n:(n==null?void 0:n.clone)!==void 0&&typeof n.clone=="function"?t[i]=n.clone():t[i]=tA(n,e)}return t}return s}function _a(s){return new Promise((e,t)=>{setTimeout(e,s)})}function _U(s,e){if(s<=0)return Promise.resolve();if(e||(e=hi.Current),!e)return Promise.reject("No context");const t=e.time.frameCount+s;return new Promise((i,n)=>{if(!e)return n("No context");const r=()=>{e.time.frameCount>=t&&(e.pre_update_callbacks.splice(e.pre_update_callbacks.indexOf(r),1),i())};e.pre_update_callbacks.push(r)})}const r0=ne("debugresolveurl"),bU="rel:";function FW(s,e){return bc(s,e)}function bc(s,e){if(e===void 0)return r0&&console.warn("getPath: uri is undefined, returning uri",e),e;if(e.startsWith("./"))return e;if(e.startsWith("http"))return r0&&console.warn("getPath: uri is absolute, returning uri",e),e;if(s===void 0)return r0&&console.warn("getPath: source is undefined, returning uri",e),e;e.startsWith(bU)&&(e=e.substring(4));const t=s.lastIndexOf("/");if(t>=0){const i=s.substring(0,t+1),n=i+e;return r0&&console.log("source:",s,`- changed uri
3812
3812
  from`,e,`
3813
3813
  → `,n,`
3814
3814
  `+i),n}return e}class UW{constructor(e,t){h(this,"writeCallbacks",[]);h(this,"_applied",!1);h(this,"_object");h(this,"_prop");h(this,"_wrapperProp");this._object=e,this._prop=t,this._wrapperProp=Symbol("$"+t),this.apply()}subscribeWrite(e){this.writeCallbacks.push(e)}unsubscribeWrite(e){const t=this.writeCallbacks.indexOf(e);t!==-1&&this.writeCallbacks.splice(t,1)}apply(){if(this._applied||!this._object)return;const e=this._object,t=this._prop;if(e[t]===void 0)return;this._applied=!0,e[this._wrapperProp]!==void 0&&console.warn("Watcher is being applied to an object that already has a wrapper property. This is not (yet) supported");const i=e[t];e[this._wrapperProp]=i,Object.defineProperty(e,t,{get:()=>e[this._wrapperProp],set:o=>{e[this._wrapperProp]=o;for(const a of this.writeCallbacks)a(o,this._prop)}})}revoke(){if(!this._applied||!this._object)return;this._applied=!1;const e=this._object,t=this._prop;Reflect.deleteProperty(e,t);const i=e[this._wrapperProp];e[t]=i,Reflect.deleteProperty(e,this._wrapperProp)}dispose(){this.revoke(),this.writeCallbacks.length=0,this._object=null}}class lc{constructor(e,t){h(this,"_watches",[]);if(Array.isArray(t))for(const i of t)this._watches.push(new lc(e,i));else this._watches.push(new UW(e,t))}subscribeWrite(e){for(const t of this._watches)t.subscribeWrite(e)}unsubscribeWrite(e){for(const t of this._watches)t.unsubscribeWrite(e)}apply(){for(const e of this._watches)e.apply()}revoke(){for(const e of this._watches)e.revoke()}dispose(){for(const e of this._watches)e.dispose();this._watches.length=0}}const Cf=Symbol("needle:watches");function Lx(s,e){if(!s[Cf])if(s instanceof te)s[Cf]=new lc(s,["x","y"]);else if(s instanceof w)s[Cf]=new lc(s,["x","y","z"]);else if(s instanceof Ze||s instanceof Ce)s[Cf]=new lc(s,["x","y","z","w"]);else return!1;return s[Cf].subscribeWrite(e),!0}function VT(s,e){if(!s)return;const t=s[Cf];t&&t.unsubscribeWrite(e)}function rd(){const s=window.navigator.userAgent,e=/Windows|MacOS|Mac OS/.test(s),t=/Windows NT/.test(s)&&/Edg/.test(s)&&!/Win64/.test(s);return e&&!t&&!Dp()}function ml(){return typeof window.orientation<"u"||navigator.userAgent.indexOf("IEMobile")!==-1}function Vu(){return/WebXRViewer\//i.test(navigator.userAgent)}const NW=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"];function Dp(){return NW.includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function $f(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function kx(){return navigator.userAgent.includes("OculusBrowser")}async function g1(){try{return(await navigator.permissions.query({name:"microphone"})).state!=="denied"}catch(s){return console.error("Error querying `microphone` permissions.",s),!1}}const zW=/ip=(?<ip>.+?)\n/s;async function GW(){const e=await(await fetch("https://www.cloudflare.com/cdn-cgi/trace")).text(),t=zW.exec(e);return t?t[1]:null}async function HW(){return(await(await fetch("https://api.db-ip.com/v2/free/self")).json()).ipAddress}async function QW(){return await(await fetch("https://api.db-ip.com/v2/free/self").catch(()=>null)).json()}const uh=new WeakMap;function xU(s,e,t){if(!uh.get(s)){const n=new MutationObserver(r=>{VW(s,r)});uh.set(s,{observer:n,attributeChangedListeners:new Map}),n.observe(s,{attributes:!0})}const i=uh.get(s).attributeChangedListeners;i.has(e)||i.set(e,[]),i.get(e).push(t)}function wU(s,e,t){if(!uh.get(s))return;const i=uh.get(s).attributeChangedListeners;if(!i.has(e))return;const n=i.get(e),r=n.indexOf(t);if(r!==-1&&(n.splice(r,1),n.length<=0)){i.delete(e);const o=uh.get(s);o==null||o.observer.disconnect(),uh.delete(s)}}function VW(s,e){const t=uh.get(s).attributeChangedListeners;for(const i of e)if(i.type==="attributes"){const n=i.attributeName,r=s.getAttribute(n);if(t.has(n))for(const o of t.get(n))o(r)}}class v1{constructor(e){h(this,"reason");this.reason=e}}async function iA(s){const e=await Promise.allSettled(s).catch(n=>[new v1(n.message)]);let t=!1;const i=e.map(n=>"value"in n?n.value:(t=!0,new v1(n.reason)));return{anyFailed:t,results:i}}async function SU(s){if(!globalThis.QRCode){const i="https://cdn.rawgit.com/davidshimjs/qrcodejs/gh-pages/qrcode.min.js";let n=document.head.querySelector(`script[src="${i}"]`);n||(n=document.createElement("script"),n.src=i,document.head.appendChild(n)),await new Promise((r,o)=>{n.addEventListener("load",()=>{r(!0)})})}const e=globalThis.QRCode,t=s.domElement??document.createElement("div");return new e(t,{width:s.width??256,height:s.height??256,colorDark:"#000000",colorLight:"#ffffff",correctLevel:e.CorrectLevel.M,...s}),t}const jW=ne("debugdebug");let dv=!1;(ne("noerrors")||ne("nooverlaymessages"))&&(dv=!0);const zS="needle_engine_global_error_container";var ao=(s=>(s[s.Log=0]="Log",s[s.Warn=1]="Warn",s[s.Error=2]="Error",s))(ao||{});function jT(){return MU}const A1=new Array;function WW(s){A1.push(s)}let GS=!1;function qW(...s){if(!GS){GS=!0;try{for(let e=0;e<A1.length;e++)A1[e](...s)}catch(e){console.error(e)}GS=!1}}const CU=console.error,EU=function(...s){CU.apply(console,s),JW(s),$a(2,s),y1(...s)};function XW(s){dv=!s,s?console.error=EU:console.error=CU}function YW(){dv||(jW&&console.warn("Patch console",window.location.hostname),console.error=EU,window.addEventListener("error",s=>{if(!s)return;const e=s.error;if(e===void 0){Gr()&&console.warn("Received unknown error",s,s.target);return}$a(2,e,s.filename,s.lineno),y1(s)},!0),window.addEventListener("unhandledrejection",s=>{dv||s&&(s.reason?$a(2,s.reason.message,s.reason.stack):$a(2,"unhandled rejection"),y1(s))}))}let MU=0;function y1(...s){MU+=1,qW(...s)}function JW(s){if(Array.isArray(s))for(let e=0;e<s.length;e++){const t=s[e];typeof t=="string"&&t.startsWith("THREE.PropertyBinding: Trying to update node for track:")&&(s[e]="Some animated objects couldn't be found: see console for details")}}function $a(s,e,t,i){if(dv)return;const n=hi.Current,r=(n==null?void 0:n.domElement)??document.querySelector("needle-engine");if(r){if(Array.isArray(e)){let o="";for(let a=0;a<e.length;a++){let l=e[a];l instanceof Error&&(l=l.message),typeof l!="object"&&(a>0&&(o+=" "),o+=l)}e=o}!e||e.length<=0||KW(s,r,e)}}const HS=new Set;function KW(s,e,t){if(t==null)return;const i=$W(e);if(i.childElementCount>=20){const o=i.lastElementChild;f2(o)}if(t.length>400&&(t=t.substring(0,400)+"..."),HS.has(t))return;HS.add(t);const n=e9(s,t);i.prepend(n);const r=t;setTimeout(()=>{HS.delete(r),f2(n)},1e4)}const ZW=`
@@ -4341,7 +4341,7 @@ void main() {
4341
4341
  `;a+=n(o);const l=Object.keys(r);let c="";for(let u=0;u<l.length;u++){const d=l[u],f=r[d];if(Sm.has(f)){c+="";continue}Sm.set(f,!0),c+=d+":"+i(f,o+1),u<l.length-1&&(c+=", "),c.length>=60&&(c+=`
4342
4342
  `,c+=n(o),a+=c,c="")}return a+=c,a+=`
4343
4343
  }`,a}return r}function n(r){let o="";for(let a=0;a<r;a++)o+=" ";return o}}const iY=ne("nodevlogs");function yn(s,e=ao.Log){$a(e,s)}function $i(s){yn(s,ao.Warn)}function SN(s){yn(s,ao.Error)}let S1;function At(){return iY?!1:S1!==void 0?S1:Gr()}function nY(s){S1=s}const hu=new pd,Ys=new w,Qc=new w,Yi=new Ce,P2={X:new w(1,0,0),Y:new w(0,1,0),Z:new w(0,0,1)},JS={type:"change"},B2={type:"mouseDown"},D2={type:"mouseUp",mode:null},O2={type:"objectChange"};class sY extends ge{constructor(e,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const i=new SI;this._gizmo=i,this.add(i);const n=new hY;this._plane=n,this.add(n);const r=this;function o(_,y){let b=y;Object.defineProperty(r,_,{get:function(){return b!==void 0?b:y},set:function(E){b!==E&&(b=E,n[_]=E,i[_]=E,r.dispatchEvent({type:_+"-changed",value:E}),r.dispatchEvent(JS))}}),r[_]=y,n[_]=y,i[_]=y}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0);const a=new w,l=new w,c=new Ce,u=new Ce,d=new w,f=new Ce,p=new w,m=new w,A=new w,v=0,g=new w;o("worldPosition",a),o("worldPositionStart",l),o("worldQuaternion",c),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",f),o("pointStart",p),o("pointEnd",m),o("rotationAxis",A),o("rotationAngle",v),o("eye",g),this._offset=new w,this._startNorm=new w,this._endNorm=new w,this._cameraScale=new w,this._parentPosition=new w,this._parentQuaternion=new Ce,this._parentQuaternionInv=new Ce,this._parentScale=new w,this._worldScaleStart=new w,this._worldQuaternionInv=new Ce,this._worldScale=new w,this._positionStart=new w,this._quaternionStart=new Ce,this._scaleStart=new w,this._getPointer=rY.bind(this),this._onPointerDown=aY.bind(this),this._onPointerHover=oY.bind(this),this._onPointerMove=lY.bind(this),this._onPointerUp=cY.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&hu.setFromCamera(e,this.camera);const t=KS(this._gizmo.picker[this.mode],hu);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&hu.setFromCamera(e,this.camera);const t=KS(this._plane,hu,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,B2.mode=this.mode,this.dispatchEvent(B2)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let r=this.space;if(i==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&hu.setFromCamera(e,this.camera);const o=KS(this._plane,hu,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(n.position.applyQuaternion(Yi.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),r==="world"&&(n.parent&&n.position.add(Ys.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(Ys.setFromMatrixPosition(n.parent.matrixWorld))));else if(i==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),Qc.set(a,a,a)}else Ys.copy(this.pointStart),Qc.copy(this.pointEnd),Ys.applyQuaternion(this._worldQuaternionInv),Qc.applyQuaternion(this._worldQuaternionInv),Qc.divide(Ys),t.search("X")===-1&&(Qc.x=1),t.search("Y")===-1&&(Qc.y=1),t.search("Z")===-1&&(Qc.z=1);n.scale.copy(this._scaleStart).multiply(Qc),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(Ys.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Ys.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(P2[t]),Ys.copy(P2[t]),r==="local"&&Ys.applyQuaternion(this.worldQuaternion),Ys.cross(this.eye),Ys.length()===0?l=!0:this.rotationAngle=this._offset.dot(Ys.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(Yi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(Yi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(JS),this.dispatchEvent(O2)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(D2.mode=this.mode,this.dispatchEvent(D2)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(JS),this.dispatchEvent(O2),this.pointStart.copy(this.pointEnd))}getRaycaster(){return hu}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function rY(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function oY(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function aY(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function lY(s){this.enabled&&this.pointerMove(this._getPointer(s))}function cY(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function KS(s,e,t){const i=e.intersectObject(s,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const u0=new Gi,Pi=new w(0,1,0),L2=new w(0,0,0),k2=new we,d0=new Ce,f_=new Ce,Ra=new w,F2=new we,tg=new w(1,0,0),Eu=new w(0,1,0),ig=new w(0,0,1),f0=new w,Cm=new w,Em=new w;class SI extends ge{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new ai({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new Rn({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const r=e.clone();r.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const d=e.clone();d.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);const m=e.clone();m.color.setHex(7895160);const A=new Sn(0,.04,.1,12);A.translate(0,.05,0);const v=new Li(.08,.08,.08);v.translate(0,.04,0);const g=new wt;g.setAttribute("position",new ut([0,0,0,1,0,0],3));const _=new Sn(.0075,.0075,.5,3);_.translate(0,.25,0);function y(V,L){const k=new Jl(V,.0075,3,64,L*Math.PI*2);return k.rotateY(Math.PI/2),k.rotateX(Math.PI/2),k}function b(){const V=new wt;return V.setAttribute("position",new ut([0,0,0,1,1,1],3)),V}const E={X:[[new pe(A,r),[.5,0,0],[0,0,-Math.PI/2]],[new pe(A,r),[-.5,0,0],[0,0,Math.PI/2]],[new pe(_,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new pe(A,o),[0,.5,0]],[new pe(A,o),[0,-.5,0],[Math.PI,0,0]],[new pe(_,o)]],Z:[[new pe(A,a),[0,0,.5],[Math.PI/2,0,0]],[new pe(A,a),[0,0,-.5],[-Math.PI/2,0,0]],[new pe(_,a),null,[Math.PI/2,0,0]]],XYZ:[[new pe(new nc(.1,0),d.clone()),[0,0,0]]],XY:[[new pe(new Li(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new pe(new Li(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new pe(new Li(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new pe(new Sn(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new pe(new Sn(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new pe(new Sn(.2,0,.6,4),i),[0,.3,0]],[new pe(new Sn(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new pe(new Sn(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new pe(new Sn(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new pe(new nc(.2,0),i)]],XY:[[new pe(new Li(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new pe(new Li(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new pe(new Li(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},T={START:[[new pe(new nc(.01,2),n),null,null,null,"helper"]],END:[[new pe(new nc(.01,2),n),null,null,null,"helper"]],DELTA:[[new Mn(b(),n),null,null,null,"helper"]],X:[[new Mn(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Mn(g,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Mn(g,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},C={XYZE:[[new pe(y(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new pe(y(.5,.5),r)]],Y:[[new pe(y(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new pe(y(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new pe(y(.75,1),f),null,[0,Math.PI/2,0]]]},B={AXIS:[[new Mn(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},S={XYZE:[[new pe(new Sa(.25,10,8),i)]],X:[[new pe(new Jl(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new pe(new Jl(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new pe(new Jl(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new pe(new Jl(.75,.1,2,24),i)]]},R={X:[[new pe(v,r),[.5,0,0],[0,0,-Math.PI/2]],[new pe(_,r),[0,0,0],[0,0,-Math.PI/2]],[new pe(v,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new pe(v,o),[0,.5,0]],[new pe(_,o)],[new pe(v,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new pe(v,a),[0,0,.5],[Math.PI/2,0,0]],[new pe(_,a),[0,0,0],[Math.PI/2,0,0]],[new pe(v,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new pe(new Li(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new pe(new Li(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new pe(new Li(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new pe(new Li(.1,.1,.1),d.clone())]]},Q={X:[[new pe(new Sn(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new pe(new Sn(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new pe(new Sn(.2,0,.6,4),i),[0,.3,0]],[new pe(new Sn(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new pe(new Sn(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new pe(new Sn(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new pe(new Li(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new pe(new Li(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new pe(new Li(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new pe(new Li(.2,.2,.2),i),[0,0,0]]]},z={X:[[new Mn(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Mn(g,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Mn(g,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function O(V){const L=new ge;for(const k in V)for(let G=V[k].length;G--;){const Y=V[k][G][0].clone(),$=V[k][G][1],re=V[k][G][2],ce=V[k][G][3],Re=V[k][G][4];Y.name=k,Y.tag=Re,$&&Y.position.set($[0],$[1],$[2]),re&&Y.rotation.set(re[0],re[1],re[2]),ce&&Y.scale.set(ce[0],ce[1],ce[2]),Y.updateMatrix();const ie=Y.geometry.clone();ie.applyMatrix4(Y.matrix),Y.geometry=ie,Y.renderOrder=1/0,Y.position.set(0,0,0),Y.rotation.set(0,0,0),Y.scale.set(1,1,1),L.add(Y)}return L}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=O(E)),this.add(this.gizmo.rotate=O(C)),this.add(this.gizmo.scale=O(R)),this.add(this.picker.translate=O(M)),this.add(this.picker.rotate=O(S)),this.add(this.picker.scale=O(Q)),this.add(this.helper.translate=O(T)),this.add(this.helper.rotate=O(B)),this.add(this.helper.scale=O(z)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:f_;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let r=0;r<n.length;r++){const o=n[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(Yi.setFromEuler(u0.set(0,0,0)),o.quaternion.copy(i).multiply(Yi),Math.abs(Pi.copy(tg).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(Yi.setFromEuler(u0.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(Yi),Math.abs(Pi.copy(Eu).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(Yi.setFromEuler(u0.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(Yi),Math.abs(Pi.copy(ig).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(Yi.setFromEuler(u0.set(0,Math.PI/2,0)),Pi.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(k2.lookAt(L2,Pi,Eu)),o.quaternion.multiply(Yi),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),Ys.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Ys.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(Ys),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(Pi.copy(tg).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(Pi.copy(Eu).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(Pi.copy(ig).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(Pi.copy(ig).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(Pi.copy(tg).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(Pi.copy(Eu).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(d0.copy(i),Pi.copy(this.eye).applyQuaternion(Yi.copy(i).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(k2.lookAt(this.eye,L2,Eu)),o.name==="X"&&(Yi.setFromAxisAngle(tg,Math.atan2(-Pi.y,Pi.z)),Yi.multiplyQuaternions(d0,Yi),o.quaternion.copy(Yi)),o.name==="Y"&&(Yi.setFromAxisAngle(Eu,Math.atan2(Pi.x,Pi.z)),Yi.multiplyQuaternions(d0,Yi),o.quaternion.copy(Yi)),o.name==="Z"&&(Yi.setFromAxisAngle(ig,Math.atan2(Pi.y,Pi.x)),Yi.multiplyQuaternions(d0,Yi),o.quaternion.copy(Yi))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis||this.axis.split("").some(function(l){return o.name===l}))&&(o.material.color.setHex(16776960),o.material.opacity=1)}super.updateMatrixWorld(e)}}class hY extends pe{constructor(){super(new zn(1e5,1e5,2,2),new ai({visible:!1,wireframe:!0,side:mi,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),f0.copy(tg).applyQuaternion(t==="local"?this.worldQuaternion:f_),Cm.copy(Eu).applyQuaternion(t==="local"?this.worldQuaternion:f_),Em.copy(ig).applyQuaternion(t==="local"?this.worldQuaternion:f_),Pi.copy(Cm),this.mode){case"translate":case"scale":switch(this.axis){case"X":Pi.copy(this.eye).cross(f0),Ra.copy(f0).cross(Pi);break;case"Y":Pi.copy(this.eye).cross(Cm),Ra.copy(Cm).cross(Pi);break;case"Z":Pi.copy(this.eye).cross(Em),Ra.copy(Em).cross(Pi);break;case"XY":Ra.copy(Em);break;case"YZ":Ra.copy(f0);break;case"XZ":Pi.copy(Em),Ra.copy(Cm);break;case"XYZ":case"E":Ra.set(0,0,0);break}break;case"rotate":default:Ra.set(0,0,0)}Ra.length()===0?this.quaternion.copy(this.cameraQuaternion):(F2.lookAt(Ys.set(0,0,0),Ra,Pi),this.quaternion.setFromRotationMatrix(F2)),super.updateMatrixWorld(e)}}const uY=ne("debugpatch");function Gx(s,e,t,i){const n=uY===e;if(!t&&!i)return;const r=e+"___needle";fY(s,e,t,i);const o=Object.getOwnPropertyDescriptor(s,e),a=s[e];n&&console.log("Patch",s.constructor.name,e,o,a),o?(n&&console.log("Apply patch with existing descriptor",s.constructor.name,e,o),typeof o.value=="function"&&(s[e]=N2(o.value,s,e))):(n&&console.log("Create patch with new property",s.constructor.name,e,o),Object.defineProperty(s,e,{set:function(l){if(typeof l=="function")this[r]=N2(l,s,e);else{const c=this[r];CN(s,e,this,c,l),this[r]=l,EN(s,e,this,c,l)}},get:function(){const l=this[r];return typeof l=="function"&&l[r]?l[r]:l}}))}function dY(s,e,t){const i=CI(s,e);if(i)for(let n=i.length-1;n>=0;n--){const r=i[n];r.prefix===t&&(r.prefix=null),r.postfix===t&&(r.postfix=null),!r.prefix&&!r.postfix&&i.splice(n,1)}}const U2=Symbol("Needle:Patches:WrappedFunction");function N2(s,e,t){if(s[U2])return s;const i=function(...n){CN(e,t,this,...n);const r=s.apply(this,n);return EN(e,t,this,r,...n),r};return i[U2]=!0,i}const p_="Needle:Patches";function C1(){return globalThis[p_]||(globalThis[p_]=new WeakMap),globalThis[p_]}function CI(s,e){const t=C1().get(s);return t?t.get(e):null}function fY(s,e,t,i){let n=C1().get(s);n||(n=new Map,C1().set(s,n));let r=n.get(e);r||(r=[],n.set(e,r)),r.push({prefix:t,postfix:i})}function CN(s,e,t,...i){var r;if(!t)return;const n=CI(s,e);if(n)for(const o of n)(r=o.prefix)==null||r.call(t,...i)}function EN(s,e,t,i,...n){var o;if(!t)return;const r=CI(s,e);if(r)for(const a of r)(o=a.postfix)==null||o.call(t,i,...n)}const z2=Symbol("gltf-loader-internal-usage-tracker"),pY=ne("debugusers"),jg=class{constructor(e){h(this,"parser");h(this,"_getDependency");h(this,"_loadingId");h(this,"_loadedObjects",new Set);this.parser=e,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(e){return jg._loadingProcesses>0}beforeRoot(){jg._loadingProcesses++;const e=this,t=this._getDependency;return this.parser.getDependency=function(i,n){const r=t.call(this,i,n);return r.then(o=>(o&&(e._loadedObjects.add(o),o[z2]=e._loadingId),o)),r},null}afterRoot(e){jg._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const t of this._loadedObjects)delete t[z2],t instanceof ge&&(t.parent||t instanceof pe&&(pY&&console.warn("> GLTF LOADER: Mesh not used in scene!",t),t.material=null,t.geometry=null));return null}};let Cg=jg;h(Cg,"_loadingProcesses",0);class MN{constructor(){window.addEventListener("unhandledrejection",e=>{var i;if(e.defaultPrevented)return;const t=(i=e==null?void 0:e.reason)==null?void 0:i.path;if(t){const n=t[0];n&&n.tagName==="IMG"&&(console.warn(`Could not load image:
4344
- `+n.src),e.preventDefault())}})}}const Hx=ne("trackresources");function TN(){return Hx==="dispose"}let gd=!0;Hx===0&&(gd=!1);function mY(s){gd=s}function IN(){return gd}const RN=Symbol("disposable");function EI(s,e){s&&(s[RN]=e,Wu&&console.warn("Set disposable",e,s))}const PN=Symbol("disposed");function gY(s){return s[PN]===!0}function Di(s){var e;if(s){if(s[RN]===!1){Wu&&console.warn("Object is marked as not disposable",s);return}if(s[PN]=!0,s instanceof ir)Di(s.environment),Di(s.background),Di(s.customDepthMaterial),Di(s.customDistanceMaterial);else if(s instanceof ga)Di(s.geometry),Di(s.material),Di(s.skeleton),Di(s.bindMatrix),Di(s.bindMatrixInverse),Di(s.customDepthMaterial),Di(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof pe)Di(s.geometry),Di(s.material),Di(s.customDepthMaterial),Di(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof wt){df(s);for(const t of Object.keys(s.attributes)){const i=s.attributes[t];Di(i)}}else if(s instanceof it||s instanceof xr)Wu&&console.warn("BufferAttribute dispose not supported",s.count);else if(s instanceof Array)for(const t of s)t instanceof Nt&&Di(t);else if(s instanceof Nt){df(s);for(const i of Object.keys(s)){const n=s[i];n instanceof Dt&&(Di(n),s[i]=null)}const t=s.uniforms;if(t)for(const i of Object.keys(t)){const n=t[i];n instanceof Dt?(Di(n),t[i]=null):n instanceof _e&&(Di(n.value),n.value=null)}}else s instanceof Dt?(df(s),df(s.source),((e=s.source)==null?void 0:e.data)instanceof ImageBitmap&&df(s.source.data)):s instanceof Pp?(df(s.boneTexture),s.boneTexture=null):s instanceof Jv||!(s instanceof ge)&&Wu&&console.warn("Unknown object type",s)}}function df(s){s&&((Wu||TN()||Hx)&&console.warn("🧨 FREE",s),s instanceof ImageBitmap?s.close():s instanceof ic?s.data=null:s.dispose())}function BN(s){(s instanceof pe||s instanceof ga)&&(s.material=null,s.geometry=null)}const vY=new Set;function MI(s,e,t=null,i){if(i||(i=vY,i.clear()),!s)return i;const n=s[yv];if(n)for(const r of n)i.has(r)||(t==null?void 0:t.call(null,r))!==!1&&(i.add(r),e&&MI(r,!0,t,i));return i}function AY(s){return s[ng]}const Wu=ne("debugresourceusers")||ne("debugmemory"),yv=Symbol("needle-resource-users"),ng=Symbol("needle-resource-users-count");function cr(s,e){Gx(s,e,function(t,i){gd&&(db(yv,this,t,!1),db(yv,this,i,!0))})}gd&&(cr(pe.prototype,"material"),cr(pe.prototype,"geometry"),cr(Nt.prototype,"map"),cr(Nt.prototype,"bumpMap"),cr(Nt.prototype,"alphaMap"),cr(Nt.prototype,"normalMap"),cr(Nt.prototype,"displacementMap"),cr(Nt.prototype,"roughnessMap"),cr(Nt.prototype,"metalnessMap"),cr(Nt.prototype,"emissiveMap"),cr(Nt.prototype,"specularMap"),cr(Nt.prototype,"envMap"),cr(Nt.prototype,"lightMap"),cr(Nt.prototype,"aoMap"),cr(Nt.prototype,"gradientMap"));function yY(s){if(gd===!1)return;const e=s[yv];if(e)for(const t of e)db(yv,t,s,!1)}gd&&Gx(Nt.prototype,"dispose",function(){yY(this)});let E1=0;function db(s,e,t,i){if(E1>0)return;if(Array.isArray(t)){for(const r of t)db(s,e,r,i);return}if(!t)return;let n=t[s];if(n||(n=new Set),i){if(e&&!n.has(e)){n.add(e);let r=t[ng]||0;r+=1,t[ng]=r,Wu&&console.warn(`🟢 Added user of "${t.type}"`,e,t,r,"users:",n)}}else if(e&&n.has(e)){n.delete(e);let r=t[ng]||0;r>0&&(r-=1,t[ng]=r),Wu&&console.warn(`🔴 Removed user of "${t.type}"`,e,t,r,"users:",n),r<=0&&(Cg.isLoading(t)||(Hx&&console.warn(`🔴 Removed all user of "${t.type}"`,t),TN()&&Di(t)))}t[s]=n}try{Gx(_c.prototype,"render",function(){E1++},function(){E1--})}catch(s){console.warn("Could not wrap WebGLRenderer.render",s)}var lA=(s=>(s.Added="component-added",s.Removing="removing-component",s))(lA||{});const G2=ne("debugcomponentevents");class cA{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let i=this.eventListeners.get(e);i||(i=[]),i.push(t),this.eventListeners.set(e,i),G2&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const i=this.eventListeners.get(e);if(!i)return;const n=i.indexOf(t);n<0||i.splice(n,1)}static dispatchComponentLifecycleEvent(e,t){const i=this.eventListeners.get(e);if(G2&&console.log("Dispatching event "+e,i),!!i)for(const n of i)n(t)}}h(cA,"eventListeners",new Map);const DN=ne("debugdefines");Op('if(!globalThis[""3.35.0-beta""]) globalThis[""3.35.0-beta""] = "0.0.0";');Op('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');Op('if(!globalThis[""Mon Mar 25 2024 15:03:15 GMT+0100 (Central European Standard Time)""]) globalThis[""Mon Mar 25 2024 15:03:15 GMT+0100 (Central European Standard Time)""] = "unknown";');Op('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.35.0-beta";');Op('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');Op('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Mar 25 2024 15:03:15 GMT+0100 (Central European Standard Time)";');const tl="3.35.0-beta",Qx="undefined",TI="Mon Mar 25 2024 15:03:15 GMT+0100 (Central European Standard Time)";DN&&console.log(`Engine version: ${tl} (generator: ${Qx})
4344
+ `+n.src),e.preventDefault())}})}}const Hx=ne("trackresources");function TN(){return Hx==="dispose"}let gd=!0;Hx===0&&(gd=!1);function mY(s){gd=s}function IN(){return gd}const RN=Symbol("disposable");function EI(s,e){s&&(s[RN]=e,Wu&&console.warn("Set disposable",e,s))}const PN=Symbol("disposed");function gY(s){return s[PN]===!0}function Di(s){var e;if(s){if(s[RN]===!1){Wu&&console.warn("Object is marked as not disposable",s);return}if(s[PN]=!0,s instanceof ir)Di(s.environment),Di(s.background),Di(s.customDepthMaterial),Di(s.customDistanceMaterial);else if(s instanceof ga)Di(s.geometry),Di(s.material),Di(s.skeleton),Di(s.bindMatrix),Di(s.bindMatrixInverse),Di(s.customDepthMaterial),Di(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof pe)Di(s.geometry),Di(s.material),Di(s.customDepthMaterial),Di(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof wt){df(s);for(const t of Object.keys(s.attributes)){const i=s.attributes[t];Di(i)}}else if(s instanceof it||s instanceof xr)Wu&&console.warn("BufferAttribute dispose not supported",s.count);else if(s instanceof Array)for(const t of s)t instanceof Nt&&Di(t);else if(s instanceof Nt){df(s);for(const i of Object.keys(s)){const n=s[i];n instanceof Dt&&(Di(n),s[i]=null)}const t=s.uniforms;if(t)for(const i of Object.keys(t)){const n=t[i];n instanceof Dt?(Di(n),t[i]=null):n instanceof _e&&(Di(n.value),n.value=null)}}else s instanceof Dt?(df(s),df(s.source),((e=s.source)==null?void 0:e.data)instanceof ImageBitmap&&df(s.source.data)):s instanceof Pp?(df(s.boneTexture),s.boneTexture=null):s instanceof Jv||!(s instanceof ge)&&Wu&&console.warn("Unknown object type",s)}}function df(s){s&&((Wu||TN()||Hx)&&console.warn("🧨 FREE",s),s instanceof ImageBitmap?s.close():s instanceof ic?s.data=null:s.dispose())}function BN(s){(s instanceof pe||s instanceof ga)&&(s.material=null,s.geometry=null)}const vY=new Set;function MI(s,e,t=null,i){if(i||(i=vY,i.clear()),!s)return i;const n=s[yv];if(n)for(const r of n)i.has(r)||(t==null?void 0:t.call(null,r))!==!1&&(i.add(r),e&&MI(r,!0,t,i));return i}function AY(s){return s[ng]}const Wu=ne("debugresourceusers")||ne("debugmemory"),yv=Symbol("needle-resource-users"),ng=Symbol("needle-resource-users-count");function cr(s,e){Gx(s,e,function(t,i){gd&&(db(yv,this,t,!1),db(yv,this,i,!0))})}gd&&(cr(pe.prototype,"material"),cr(pe.prototype,"geometry"),cr(Nt.prototype,"map"),cr(Nt.prototype,"bumpMap"),cr(Nt.prototype,"alphaMap"),cr(Nt.prototype,"normalMap"),cr(Nt.prototype,"displacementMap"),cr(Nt.prototype,"roughnessMap"),cr(Nt.prototype,"metalnessMap"),cr(Nt.prototype,"emissiveMap"),cr(Nt.prototype,"specularMap"),cr(Nt.prototype,"envMap"),cr(Nt.prototype,"lightMap"),cr(Nt.prototype,"aoMap"),cr(Nt.prototype,"gradientMap"));function yY(s){if(gd===!1)return;const e=s[yv];if(e)for(const t of e)db(yv,t,s,!1)}gd&&Gx(Nt.prototype,"dispose",function(){yY(this)});let E1=0;function db(s,e,t,i){if(E1>0)return;if(Array.isArray(t)){for(const r of t)db(s,e,r,i);return}if(!t)return;let n=t[s];if(n||(n=new Set),i){if(e&&!n.has(e)){n.add(e);let r=t[ng]||0;r+=1,t[ng]=r,Wu&&console.warn(`🟢 Added user of "${t.type}"`,e,t,r,"users:",n)}}else if(e&&n.has(e)){n.delete(e);let r=t[ng]||0;r>0&&(r-=1,t[ng]=r),Wu&&console.warn(`🔴 Removed user of "${t.type}"`,e,t,r,"users:",n),r<=0&&(Cg.isLoading(t)||(Hx&&console.warn(`🔴 Removed all user of "${t.type}"`,t),TN()&&Di(t)))}t[s]=n}try{Gx(_c.prototype,"render",function(){E1++},function(){E1--})}catch(s){console.warn("Could not wrap WebGLRenderer.render",s)}var lA=(s=>(s.Added="component-added",s.Removing="removing-component",s))(lA||{});const G2=ne("debugcomponentevents");class cA{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let i=this.eventListeners.get(e);i||(i=[]),i.push(t),this.eventListeners.set(e,i),G2&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const i=this.eventListeners.get(e);if(!i)return;const n=i.indexOf(t);n<0||i.splice(n,1)}static dispatchComponentLifecycleEvent(e,t){const i=this.eventListeners.get(e);if(G2&&console.log("Dispatching event "+e,i),!!i)for(const n of i)n(t)}}h(cA,"eventListeners",new Map);const DN=ne("debugdefines");Op('if(!globalThis[""3.35.0-beta.1""]) globalThis[""3.35.0-beta.1""] = "0.0.0";');Op('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');Op('if(!globalThis[""Tue Mar 26 2024 10:41:24 GMT+0100 (Central European Standard Time)""]) globalThis[""Tue Mar 26 2024 10:41:24 GMT+0100 (Central European Standard Time)""] = "unknown";');Op('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.35.0-beta.1";');Op('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');Op('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Tue Mar 26 2024 10:41:24 GMT+0100 (Central European Standard Time)";');const tl="3.35.0-beta.1",Qx="undefined",TI="Tue Mar 26 2024 10:41:24 GMT+0100 (Central European Standard Time)";DN&&console.log(`Engine version: ${tl} (generator: ${Qx})
4345
4345
  Project built at ${TI}`);const cc="needle_isActiveInHierarchy",Iu="builtin_components",Eg="needle_editor_guid";function Op(s){try{(0,eval)(s)}catch(e){DN&&console.error(e)}}const _v=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),ON=Symbol("isUsingInstancing"),LN=Symbol("instancingRenderer"),M1=Symbol("instancingAutoUpdateBounds");class Aa{static isUsingInstancing(e){return e[ON]===!0}static getRenderer(e){return e[LN]||null}setAutoUpdateBounds(e,t){const i=Aa.getRenderer(e);i&&(i[M1]=t)}static markDirty(e,t=!0){if(e&&(this.isUsingInstancing(e)&&(e[_v]=!0,e.matrixWorldNeedsUpdate=!0),t))for(const i of e.children)Aa.markDirty(i,!0)}}function qu(s,e){try{e?s(e):s()}catch(t){return console.error(t),!1}return!0}const T1=ne("debugnewscripts"),_Y=ne("debughierarchy"),qi=[];function bY(){return qi.length>0}function fb(s){if(!(s.new_scripts.length<=0)){if(T1&&console.log("Register new components",s.new_scripts.length,[...s.new_scripts],s.alias?"element: "+s.alias:s.hash,s),s.new_scripts_pre_setup_callbacks.length>0){for(const e of s.new_scripts_pre_setup_callbacks)e&&e();s.new_scripts_pre_setup_callbacks.length=0}qi.length=0,s.new_scripts.length>0&&qi.push(...s.new_scripts),s.new_scripts.length=0;for(let e=0;e<qi.length;e++)try{const t=qi[e];if(t.isComponent!==!0){(At()||T1)&&console.error(`Registered script is not a Needle Engine component.
4346
4346
  The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
4347
4347
  `,t),qi.splice(e,1),e--;continue}if(t.destroyed)continue;if(!t.gameObject){console.error("MISSING GAMEOBJECT - will ignore",t),qi.splice(e,1),e--;continue}t.context=s,Mg(t.gameObject),II(t,s)}catch(t){console.error(t),Kl(qi[e],s),qi.splice(e,1),e--}for(let e=0;e<qi.length;e++)try{const t=qi[e];if(t.destroyed){Kl(qi[e],s),qi.splice(e,1),e--;continue}if(t.registering)try{t.registering()}catch(i){console.error(i)}t.__internalAwake!==void 0&&(t.gameObject||console.error("MISSING GAMEOBJECT",t,t.gameObject),Mg(t.gameObject),t.activeAndEnabled&&qu(t.__internalAwake.bind(t)))}catch(t){console.error(t),Kl(qi[e],s),qi.splice(e,1),e--}for(let e=0;e<qi.length;e++)try{const t=qi[e];if(t.destroyed||t.enabled===!1||(Mg(t.gameObject),t.activeAndEnabled===!1))continue;t.__internalEnable!==void 0&&(t.enabled=!0,qu(t.__internalEnable.bind(t)))}catch(t){console.error(t),Kl(qi[e],s),qi.splice(e,1),e--}for(let e=0;e<qi.length;e++)try{const t=qi[e];if(t.destroyed||!t.gameObject)continue;s.new_script_start.push(t)}catch(t){console.error(t),Kl(qi[e],s),qi.splice(e,1),e--}qi.length=0;for(const e of s.new_scripts_post_setup_callbacks)e&&e();s.new_scripts_post_setup_callbacks.length=0}}function xY(s){s&&(s.__internalDisable(!0),Kl(s,s.context))}function kN(s,e){for(let t=0;t<s.new_script_start.length;t++)try{const i=s.new_script_start[t];if(e!==void 0&&i.gameObject!==e||i.destroyed||i.activeAndEnabled===!1)continue;qu(i.__internalAwake.bind(i)),i.enabled&&(qu(i.__internalEnable.bind(i)),qu(i.__internalStart.bind(i)),s.new_script_start.splice(t,1),t--)}catch(i){console.error(i),Kl(s.new_script_start[t],s),s.new_script_start.splice(t,1),t--}}function II(s,e){e.scripts.indexOf(s)===-1&&(e.scripts.push(s),s.earlyUpdate&&e.scripts_earlyUpdate.push(s),s.update&&e.scripts_update.push(s),s.lateUpdate&&e.scripts_lateUpdate.push(s),s.onBeforeRender&&e.scripts_onBeforeRender.push(s),s.onAfterRender&&e.scripts_onAfterRender.push(s),s.onPausedChanged&&e.scripts_pausedChanged.push(s),ZS(s,null)&&e.new_scripts_xr.push(s),ZS(s,"immersive-vr")&&e.scripts_immersive_vr.push(s),ZS(s,"immersive-ar")&&e.scripts_immersive_ar.push(s))}function Kl(s,e){Eo(s,e.new_scripts),Eo(s,e.new_script_start),Eo(s,e.scripts),Eo(s,e.scripts_earlyUpdate),Eo(s,e.scripts_update),Eo(s,e.scripts_lateUpdate),Eo(s,e.scripts_onBeforeRender),Eo(s,e.scripts_onAfterRender),Eo(s,e.scripts_pausedChanged),Eo(s,e.new_scripts_xr),Eo(s,e.scripts_immersive_vr),Eo(s,e.scripts_immersive_ar),e.stopAllCoroutinesFrom(s)}function Eo(s,e){const t=e.indexOf(s);t>=0&&e.splice(t,1)}function ZS(s,e){var t;if(s){const i=s;if(i.onBeforeXR||i.onEnterXR||i.onUpdateXR||i.onLeaveXR||i.onXRControllerAdded||i.onXRControllerRemoved)return!(e!=null&&((t=i.supportsXR)==null?void 0:t.call(i,e))===!1)}return!1}function m_(s){if(s||(s=hi.Current.scene),!s){console.trace("Invalid call - no current context.");return}const e=Up(s);FN(s,e,!0)||(T1||At()?console.error(`Error updating hierarchy
@@ -5254,12 +5254,12 @@ Coroutine functions must be generators: "*myCoroutine() {...}"
5254
5254
  Start a coroutine from a component by calling "this.startCoroutine(myCoroutine())"`),t):(this.coroutines[i]||(this.coroutines[i]=[]),this.coroutines[i].push({comp:e,main:t}),t)}unregisterCoroutineUpdate(e,t){if(!this.coroutines[t])return;const i=this.coroutines[t].findIndex(n=>n.main===e);i>=0&&this.coroutines[t].splice(i,1)}stopAllCoroutinesFrom(e){for(const t in this.coroutines){const i=this.coroutines[t];for(let n=i.length-1;n>=0;n--)i[n].comp===e&&i.splice(n,1)}}setCurrentCamera(e){var n;if(!e)return;if(e.cam||e.buildCamera(),!e.cam){console.warn("Camera component is missing camera",e);return}const t=this._cameraStack.indexOf(e);t>=0&&this._cameraStack.splice(t,1),this._cameraStack.push(e),this.mainCameraComponent=e;const i=e.cam;i.isPerspectiveCamera&&this.updateAspect(i),(n=this.mainCameraComponent)==null||n.applyClearFlagsIfIsActiveCamera()}removeCamera(e){if(!e)return;const t=this._cameraStack.indexOf(e);if(t>=0&&this._cameraStack.splice(t,1),this.mainCameraComponent===e&&(this.mainCameraComponent=void 0,this._cameraStack.length>0)){const i=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(i)}}addBeforeRenderListener(e,t){this._onBeforeRenderListeners.has(e.uuid)||(this._onBeforeRenderListeners.set(e.uuid,[]),e.onBeforeRender=this._createRenderCallbackWrapper(e,this._onBeforeRenderListeners)),this._onBeforeRenderListeners.get(e.uuid).push(t)}removeBeforeRenderListener(e,t){if(this._onBeforeRenderListeners.has(e.uuid)){const i=this._onBeforeRenderListeners.get(e.uuid),n=i.indexOf(t);n>=0&&i.splice(n,1)}}addAfterRenderListener(e,t){var i;this._onAfterRenderListeners.has(e.uuid)||(this._onAfterRenderListeners.set(e.uuid,[]),e.onAfterRender=this._createRenderCallbackWrapper(e,this._onAfterRenderListeners)),(i=this._onAfterRenderListeners.get(e.uuid))==null||i.push(t)}removeAfterRenderListener(e,t){if(this._onAfterRenderListeners.has(e.uuid)){const i=this._onAfterRenderListeners.get(e.uuid),n=i.indexOf(t);n>=0&&i.splice(n,1)}}_createRenderCallbackWrapper(e,t){return(i,n,r,o,a,l)=>{const c=t.get(e.uuid);if(c)for(let u=0;u<c.length;u++){const d=c[u];d(i,n,r,o,a,l)}}}get isRendering(){return this._isRendering}setRequireDepth(e){this._requireDepthTexture=e}setRequireColor(e){this._requireColorTexture=e}get depthTexture(){var e;return((e=this._renderTarget)==null?void 0:e.depthTexture)||null}get opaqueColorTexture(){var e;return((e=this._renderTarget)==null?void 0:e.texture)||null}get isVisibleToUser(){if(this.isInXR)return!0;if(!this._isVisible)return!1;const e=getComputedStyle(this.domElement);return e.visibility!=="hidden"&&e.display!=="none"&&e.opacity!=="0"}async internalOnCreate(e){var a,l,c,u,d;const t=++this._createId;xs&&console.log("Creating context",this.name,e);const i=globalThis["needle:dependencies:ready"];i instanceof Promise&&(xs&&console.log("Waiting for dependencies to be ready"),await i.catch(f=>{(xs||At())&&console.error("Needle Engine dependencies failed to load",f)}).then(()=>{xs&&console.log("Needle Engine dependencies are ready")})),this.clear(),this.isManagedExternally===!1&&(this.createNewRenderer(),(a=this.renderer)==null||a.setAnimationLoop(null)),await _a(1),Ui.Current=this,await hi.dispatchCallback(kn.ContextCreationStart,this);let n=!0,r;try{Ui.Current=this,e?r=await this.internalLoadInitialContent(t,e):r=[]}catch(f){console.error(f),n=!1}if(!n||t!==this._createId)return!1;if(this.internalOnUpdateVisible(),!this.renderer)return xs&&console.warn("Context has no renderer (perhaps it was disconnected?",this.domElement.isConnected),!1;!this.isManagedExternally&&!this.domElement.shadowRoot&&this.domElement.prepend(this.renderer.domElement),Ui.Current=this,Ui.Current=this;for(let f=0;f<this.new_scripts.length;f++){const p=this.new_scripts[f];if(p.gameObject!==void 0&&p.gameObject!==null){p.gameObject.userData===void 0&&(p.gameObject.userData={}),p.gameObject.userData.components===void 0&&(p.gameObject.userData.components=[]);const m=p.gameObject.userData.components;m.includes(p)||m.push(p)}}if(this.post_setup_callbacks)for(let f=0;f<this.post_setup_callbacks.length;f++)Ui.Current=this,await this.post_setup_callbacks[f](this);if(!this.mainCamera){Ui.Current=this;let f=null;hd(this.scene,p=>{const m=p;if(m!=null&&m.isCamera){if(Mg(m.gameObject),!m.activeAndEnabled)return;if(m.tag==="MainCamera")return f=m,!0;f=m}}),f?this.setCurrentCamera(f):!hi.dispatchCallback(kn.MissingCamera,this,{files:r})&&!this.mainCamera&&!this.isManagedExternally&&console.warn("Missing camera in main scene",this)}if(this.input.bindEvents(),Ui.Current=this,fb(this),this.physics.engine&&((l=this.physics.engine)==null||l.step(0),(c=this.physics.engine)==null||c.postStep()),!this.isManagedExternally&&this.composer&&this.mainCamera){const f=new jx(this.scene,this.mainCamera);this.renderer.setSize(this.domWidth,this.domHeight),this.composer.addPass(f),this.composer.setSize(this.domWidth,this.domHeight)}this._sizeChanged=!0,this._stats&&(this._stats.showPanel(0),(u=this.domElement.shadowRoot)==null||u.appendChild(this._stats.dom)),xs&&ub(this.scene,!0),this.targetFrameRate===void 0?(xs&&console.warn("No target framerate set, using default",Ui.DefaultTargetFrameRate),this.targetFrameRate=Ui._defaultTargetFramerate):xs&&console.log("Target framerate set to",this.targetFrameRate),this._dispatchReadyAfterFrame=!0;const o=hi.dispatchCallback(kn.ContextCreated,this,{files:r});return o&&("internalSetLoadingMessage"in this.domElement&&typeof this.domElement.internalSetLoadingMessage=="function"&&((d=this.domElement)==null||d.internalSetLoadingMessage("finish loading")),await o),uu(this,kn.ContextCreated),xs&&console.log("Context Created...",this.renderer,this.renderer.domElement),this._isCreating=!1,this.isManagedExternally||this.restartRenderLoop(),o}async internalLoadInitialContent(e,t){var l,c;const i=new Array;if(t.files.length===0)return i;const n=[...t.files],r={name:"",progress:null,index:0,count:n.length},o=ya(),a=0;for(let u=0;u<n.length;u++){if(e!==this._createId){xs&&console.log("Aborting loading because create id changed",e,this._createId);break}const d=n[u];if(!d.includes(".glb")&&!d.includes(".gltf")){const p=`Needle Engine: found suspicious src "${d}"`;console.warn(p),Gr()&&$i(p)}(l=t==null?void 0:t.onLoadingStart)==null||l.call(this,u,d),xs&&console.log("Context Load "+d);const f=await o.loadSync(this,d,d,a,p=>{var m;r.name=d,r.progress=p,r.index=u,r.count=n.length,(m=t.onLoadingProgress)==null||m.call(this,r)});(c=t==null?void 0:t.onLoadingFinished)==null||c.call(this,u,d,f??null),f?i.push({src:d,file:f}):console.warn("Could not load file: "+d)}if(e!==this._createId){for(const u of i)if(u&&u.file)for(const d of u.file.scenes)ba(d,!0,!0)}else for(const u of i)u&&u.file&&this.scene.add(u.file.scene);return i}restartRenderLoop(){return this.renderer?this._isCreating?(console.warn("Can not start render loop while creating context"),!1):(this.renderer.setAnimationLoop((e,t)=>{this.isManagedExternally||this.update(e,t)}),!0):(console.error("Can not start render loop without renderer"),!1)}update(e,t){if(t===void 0&&(t=null),At()||xs||bY())try{this.internalStep(e,t),this._renderlooperrors=0}catch(i){this._renderlooperrors+=1,(At()||xs)&&(i instanceof Error||i instanceof TypeError)&&yn("Caught unhandled exception during render-loop - see console for details.",ao.Error),console.error("Frame #"+this.time.frame+`
5255
5255
  `,i),this._renderlooperrors>=3&&(console.warn("Stopping render loop due to error"),this.renderer.setAnimationLoop(null)),this.domElement.dispatchEvent(new CustomEvent("error",{detail:i}))}else this.internalStep(e,t)}updatePhysics(e){this.internalUpdatePhysics(e)}internalStep(e,t){this.internalOnBeforeRender(e,t)!==!1&&(this.internalOnRender(),this.internalOnAfterRender())}internalOnBeforeRender(e,t){var n;const i=t!==null&&this._xrFrame===null;if(this._xrFrame=t,i&&this.domElement.dispatchEvent(new CustomEvent("xr-session-started",{detail:{context:this,session:this.xrSession,frame:t}})),this._currentFrameEvent=-1,this.isManagedExternally===!1&&this.isInXR===!1&&this.targetFrameRate!==void 0){this._lastTimestamp===0&&(this._lastTimestamp=e),this._accumulatedTime+=(e-this._lastTimestamp)/1e3,this._lastTimestamp=e;let r=this.targetFrameRate;if(typeof r=="object"&&(r=r.value),this._accumulatedTime<1/(r+1))return!1;this._accumulatedTime=0}if((n=this._stats)==null||n.begin(),Ui.Current=this,this.onHandlePaused())return!1;for(Ui.Current=this,this.time.update(),uee&&console.log("FPS",this.time.smoothedFps.toFixed(0)),fb(this),m_(this.scene),kN(this),uu(this,-1);this._cameraStack.length>0&&(!this.mainCameraComponent||this.mainCameraComponent.destroyed);){this._cameraStack.splice(this._cameraStack.length-1,1);const r=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(r)}if(this.pre_update_oneshot_callbacks){for(const r in this.pre_update_oneshot_callbacks)this.pre_update_oneshot_callbacks[r]();this.pre_update_oneshot_callbacks.length=0}if(this.pre_update_callbacks)for(const r in this.pre_update_callbacks)this.pre_update_callbacks[r]();this._currentFrameEvent=0;for(let r=0;r<this.scripts_earlyUpdate.length;r++){const o=this.scripts_earlyUpdate[r];o.activeAndEnabled&&o.earlyUpdate!==void 0&&(Ui.Current=this,o.earlyUpdate())}if(this.executeCoroutines(0),uu(this,0),this.onHandlePaused())return!1;this._currentFrameEvent=1;for(let r=0;r<this.scripts_update.length;r++){const o=this.scripts_update[r];o.activeAndEnabled&&o.update!==void 0&&(Ui.Current=this,o.update())}if(this.executeCoroutines(1),uu(this,1),this.onHandlePaused())return!1;this._currentFrameEvent=2;for(let r=0;r<this.scripts_lateUpdate.length;r++){const o=this.scripts_lateUpdate[r];o.activeAndEnabled&&o.lateUpdate!==void 0&&(Ui.Current=this,o.lateUpdate())}if(this.executeCoroutines(2),uu(this,2),this.onHandlePaused()||(this.physicsSteps===void 0&&(this.physicsSteps=1),this.physics.engine&&this.physicsSteps>0&&this.internalUpdatePhysics(this.physicsSteps),this.onHandlePaused()))return!1;if(this.isVisibleToUser||this.runInBackground){this._currentFrameEvent=3;for(let r=0;r<this.scripts_onBeforeRender.length;r++){const o=this.scripts_onBeforeRender[r];o.activeAndEnabled&&o.onBeforeRender!==void 0&&(Ui.Current=this,o.onBeforeRender(t))}if(this.executeCoroutines(3),uu(this,3),this._sizeChanged&&this.updateSize(),this.pre_render_callbacks)for(const r in this.pre_render_callbacks)this.pre_render_callbacks[r](t)}return!0}internalUpdatePhysics(e){if(!this.physics.engine)return!1;const t=e,i=this.time.deltaTime/t;for(let n=0;n<t;n++)this._currentFrameEvent=9,this.executeCoroutines(9),this.physics.engine.step(i),this._currentFrameEvent=10,this.executeCoroutines(10);return this.physics.engine.postStep(),!0}internalOnRender(){this.isManagedExternally||(SY(this),this._currentFrameEvent=-1,this.renderNow(),this._currentFrameEvent=4)}internalOnAfterRender(){if(this.isVisibleToUser||this.runInBackground){for(let e=0;e<this.scripts_onAfterRender.length;e++){const t=this.scripts_onAfterRender[e];t.activeAndEnabled&&t.onAfterRender!==void 0&&(Ui.Current=this,t.onAfterRender())}if(this.executeCoroutines(4),uu(this,4),this.post_render_callbacks)for(const e in this.post_render_callbacks)this.post_render_callbacks[e]()}this._currentFrameEvent=-1,this.connection.sendBufferedMessagesNow(),this._stats&&(this._stats.end(),this.time.frameCount%150===0&&console.log(this.renderer.info.render.calls+" DrawCalls",`
5256
5256
  Render:`,{...this.renderer.info.render},`
5257
- Memory:`,{...this.renderer.info.memory})),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")),hi.dispatchCallback(kn.ContextFirstFrameRendered,this))}renderNow(e){return!e&&(e=this.mainCamera,!e)?!1:(this._isRendering=!0,this.renderRequiredTextures(),this.composer&&!this.isInXR?this.composer.render(this.time.deltaTime):e&&this.renderer.render(this.scene,e),this._isRendering=!1,!0)}onHandlePaused(){const e=this.evaluatePaused();if(this._wasPaused!==e){hee&&console.log("Paused?",e,"context:"+this.alias);for(let t=0;t<this.scripts_pausedChanged.length;t++){const i=this.scripts_pausedChanged[t];i.activeAndEnabled&&i.onPausedChanged!==void 0&&(Ui.Current=this,i.onPausedChanged(e,this._wasPaused))}}return this._wasPaused=e,e}evaluatePaused(){return this.isInXR?!1:this.isPaused?!0:this.runInBackground?!1:!this.isVisibleToUser}renderRequiredTextures(){if(!this.mainCamera||!this._requireDepthTexture&&!this._requireColorTexture)return;if(!this._renderTarget){if(this._renderTarget=new Yt(this.domWidth,this.domHeight),this._requireDepthTexture){const i=new Ip(this.domWidth,this.domHeight);this._renderTarget.depthTexture=i}this._requireColorTexture&&(this._renderTarget.texture=new Dt,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Ht,this._renderTarget.texture.magFilter=Ht,this._renderTarget.texture.format=Ai)}const e=this._renderTarget;e.texture&&(e.texture.colorSpace=this.renderer.outputColorSpace);const t=this.renderer.getRenderTarget();this.renderer.setRenderTarget(e),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(t)}executeCoroutines(e){var i;if(this.coroutines[e]){const n=this.coroutines[e];for(let r=0;r<n.length;r++)try{const o=n[r];if(!o.comp||o.comp.destroyed||!o.main||o.comp.enabled===!1){dee&&console.log("Removing coroutine",o.comp,o.comp.enabled),n.splice(r,1),--r;continue}const l=o.chained;if(l&&l.length>0){const f=l[l.length-1].next();if(f.done&&l.pop(),t(f)&&(o.chained||(o.chained=[]),o.chained.push(f.value)),!f.done)continue}const c=o.main.next();if(c.done===!0){n.splice(r,1),--r;continue}const u=c.value;if(t(u)){if(u.next().done)continue;o.chained||(o.chained=[]),o.chained.push(u)}else if(u instanceof Promise){const d=u;o.chained||(o.chained=[]);const f=gz(d);(i=o.chained)==null||i.push(f);continue}}catch(o){console.error(o)}}function t(n){return!!(n&&n.next&&n.return)}}};let Ft=Ui;h(Ft,"_defaultTargetFramerate",{value:60}),h(Ft,"_defaultWebglRendererParameters",{antialias:!0,alpha:!1,powerPreference:"high-performance"});hi.registerCallback(kn.ContextCreated,s=>{const e=s.context;Nz(e),Fz(e)});const Rb=ne("debugcomponents"),JD="eff8ba80-635d-11ec-90d6-0242ac120003";class ds{constructor(e){h(this,"_originalSeed");h(this,"_seed");typeof e=="string"&&(e=ds.hash(e)),this._originalSeed=e,this._seed=e}get seed(){return this._seed}set seed(e){this._seed=e}reset(){this._seed=this._originalSeed}generateUUID(e){if(typeof e=="string")return V2(e,JD);const t=this._seed;return this._seed-=1,V2(t.toString(),JD)}initialize(e){typeof e=="string"?this._seed=ds.hash(e):this._seed=e}static createFromString(e){return new ds(this.hash(e))}static hash(e){let t=0;for(let i=0;i<e.length;i++)t=e.charCodeAt(i)+((t<<5)-t);return t}}var Oz=(s=>(s.NewInstanceCreated="new-instance-created",s.InstanceDestroyed="instance-destroyed",s))(Oz||{});class Lz{constructor(e){h(this,"guid");this.guid=e}}function $x(s,e,t=!0){if(!s)return;const i=s;if(ba(s,t),!e){console.warn("Can not send destroy: No networking connection provided",s.guid);return}if(!e.isConnected){console.warn("Can not send destroy: not connected",s.guid);return}let n=s.guid;if(!n&&i.uuid&&(n=i.uuid),!n){console.warn("Can not send destroy: failed to find guid",s);return}const r=new Lz(n);e.send("instance-destroyed",r,ha.Queued)}function kz(s,e){const t=new Lz(s);e.send("instance-destroyed",t,ha.Queued)}function Fz(s){s.connection.beginListen("instance-destroyed",e=>{Rb&&console.log("[Remote] Destroyed",s.scene,e);const t=gA(e.guid,s.scene);t&&ba(t)})}class mee{constructor(e,t,i){h(this,"filename");h(this,"hash");h(this,"size");this.filename=e,this.hash=t,this.size=i}}class Uz{constructor(e,t){h(this,"guid");h(this,"originalGuid");h(this,"seed");h(this,"visible");h(this,"hostData");h(this,"dontSave");h(this,"parent");h(this,"position");h(this,"rotation");h(this,"scale");h(this,"preventCreation");this.originalGuid=e,this.guid=t}}function tR(s,e,t,i){var l;const n=s;if(!n.guid)return console.warn("Can not instantiate: No guid",n),null;if(e.context||(e.context=Ft.Current),!e.context)return console.error("Missing network instantiate options / reference to network connection in sync instantiate"),null;const r=e?{...e}:null,{instance:o,seed:a}=gee(n,e);if(o){const c=o;if(c.guid){Rb&&console.log("[Local] new instance","gameobject:",o==null?void 0:o.guid);const u=new Uz(n.guid,c.guid);u.seed=a,r&&(r.position&&(u.position={x:r.position.x,y:r.position.y,z:r.position.z}),r.rotation&&(u.rotation={x:r.rotation.x,y:r.rotation.y,z:r.rotation.z,w:r.rotation.w}),r.scale&&(u.scale={x:r.scale.x,y:r.scale.y,z:r.scale.z})),u.position||(u.position={x:c.position.x,y:c.position.y,z:c.position.z}),u.rotation||(u.rotation={x:c.quaternion.x,y:c.quaternion.y,z:c.quaternion.z,w:c.quaternion.w}),u.scale||(u.scale={x:c.scale.x,y:c.scale.y,z:c.scale.z}),u.visible=n.visible,r!=null&&r.parent&&(typeof r.parent=="string"?u.parent=r.parent:u.parent=r.parent.guid),u.hostData=t,i===!1&&(u.dontSave=!0),(l=e==null?void 0:e.context)==null||l.connection.send("new-instance-created",u)}else console.warn("Missing guid, can not send new instance event",c)}return o}function ew(){return Math.random()*9999999}function Nz(s){s.connection.beginListen("new-instance-created",async e=>{const t=await vee(e.originalGuid,s.scene);if(e.preventCreation===!0)return;if(!t){console.warn("could not find object that was instantiated: "+e.guid);return}const i=new Ea;e.position&&(i.position=new w(e.position.x,e.position.y,e.position.z)),e.rotation&&(i.rotation=new Ce(e.rotation.x,e.rotation.y,e.rotation.z,e.rotation.w)),e.scale&&(i.scale=new w(e.scale.x,e.scale.y,e.scale.z)),i.parent=e.parent,e.seed&&(i.idProvider=new ds(e.seed)),i.visible=e.visible,i.context=s,Rb&&s.alias&&console.log("[Remote] instantiate in: "+s.alias);const n=Np(t,i);n&&(e.parent==="scene"&&s.scene.add(n),Rb&&console.log("[Remote] new instance","gameobject:",n==null?void 0:n.guid,t))})}function gee(s,e){const t=ew(),i=e??new Ea;i.idProvider=new ds(t);const n=Np(s,i);return{seed:t,instance:n}}const zz={};function Gz(s,e){zz[s]=e}async function vee(s,e){const t=zz[s];if(t!=null){const i=await t(s);if(i)return i}return Hz(s,e)}function Hz(s,e){if(e===null||!s)return null;if(e.guid===s)return e;if(e.children)for(const t of e.children){const i=Hz(s,t);if(i)return i}return null}const w_=ne("debuggetcomponent"),S_=ne("debuginstantiate");var Qz=(s=>(s[s.None=0]="None",s[s.HideInHierarchy=1]="HideInHierarchy",s[s.HideInInspector=2]="HideInInspector",s[s.DontSaveInEditor=4]="DontSaveInEditor",s[s.NotEditable=8]="NotEditable",s[s.DontSaveInBuild=16]="DontSaveInBuild",s[s.DontUnloadUnusedAsset=32]="DontUnloadUnusedAsset",s[s.DontSave=52]="DontSave",s[s.HideAndDontSave=61]="HideAndDontSave",s))(Qz||{});class Ea{constructor(){h(this,"idProvider");h(this,"parent");h(this,"keepWorldPosition");h(this,"position");h(this,"rotation");h(this,"scale");h(this,"visible");h(this,"context")}clone(){var t,i,n;const e=new Ea;return e.idProvider=this.idProvider,e.parent=this.parent,e.keepWorldPosition=this.keepWorldPosition,e.position=(t=this.position)==null?void 0:t.clone(),e.rotation=(i=this.rotation)==null?void 0:i.clone(),e.scale=(n=this.scale)==null?void 0:n.clone(),e}cloneAssign(e){var t,i,n;this.idProvider=e.idProvider,this.parent=e.parent,this.keepWorldPosition=e.keepWorldPosition,this.position=(t=e.position)==null?void 0:t.clone(),this.rotation=(i=e.rotation)==null?void 0:i.clone(),this.scale=(n=e.scale)==null?void 0:n.clone()}}function Up(s){return s.visible}function Og(s,e){return typeof e=="number"&&(e=e>.5),s.visible=e,s.visible}function Vz(s){return s[cc]||tw(s)}function jz(s,e){s[ON]=e}function tw(s){return Aa.isUsingInstancing(s)}function gA(s,e){return gp(s,e,!0,!0)}const Wz=Symbol("isDestroyed");function cd(s){return s[Wz]}function qz(s,e){s[Wz]=e}const sM=Symbol("isDontDestroy");function rM(s,e=!0){s[sM]=e}const C_=[],E_=[];function ba(s,e=!0,t=!1){C_.length=0,E_.length=0,oM(s,e,t,!0);for(const i of C_)i.gameObject=null,i.context=null;for(const i of E_)qz(i,!0),t&&Di(i),BN(i);E_.length=0,C_.length=0}function oM(s,e=!0,t=!1,i=!0){var a;if(s==null)return;const n=s;if(n.isComponent){if(n[sM])return;C_.push(n);const l=n.gameObject;n.__internalDisable(),n.__internalDestroy(),n.gameObject=l;return}if(s[sM])return;const r=s;w_&&console.log(r),E_.push(r);const o=(a=r.userData)==null?void 0:a.components;if(o!=null&&Array.isArray(o)){let l=o.length;for(let c=0;c<o.length;c++){const u=o[c];oM(u,e,t,!1),o.length<l&&(l=o.length,c--)}}if(e&&r.children)for(const l of r.children)oM(l,e,t,!1);i&&r.removeFromParent()}function hd(s,e,t=!0){return Xz(s,e,t)}function*iR(s,e,t=!1,i=999,n=0){if(s!=null&&s.userData.components&&!(n>i)){for(const r of s.userData.components)e&&(r==null?void 0:r.isComponent)===!0&&r instanceof e?yield r:yield r;if(t===!0)for(const r of s.children)yield*iR(r,e,!0,i,n+1)}}function Xz(s,e,t,i=0){var n;if(s){if(s.isObject3D,i>1e3){console.warn("Failed to iterate components: too many levels");return}if((n=s.userData)!=null&&n.components)for(let r=0;r<s.userData.components.length;r++){const o=s.userData.components[r];if((o==null?void 0:o.isComponent)===!0){const a=e(o);if(a!==void 0)return a}}if(t&&s.children){const r=i+1;for(let o=0;o<s.children.length;o++){const a=s.children[o];if(!a)continue;const l=Xz(a,e,t,r);if(l!==void 0)return l}}}}function Np(s,e=null){let t=null;e!==null&&(e.x!==void 0?(t=new Ea,t.position=e):t=e);let i=Ft.Current;t!=null&&t.context&&(i=t.context),w_&&i.alias&&console.log("context",i.alias),t&&!t.idProvider&&(t.idProvider=new ds(Date.now()));const n=[],r={},o={},a=Yz(i,s,t,n,r,o);a&&(yee(r),Aee(o,r)),w_&&(ub(s,!0),ub(a,!0));const l={};for(const c in n){const u=n[c],d=u.guid;t&&t.idProvider&&(u.guid=t.idProvider.generateUUID(),l[d]=u.guid,w_&&console.log(u.name,u.guid)),Zx(u,i),u.__internalNewInstanceCreated&&u.__internalNewInstanceCreated()}for(const c in n){const u=n[c];u.resolveGuids&&u.resolveGuids(l),u.enabled!==!1&&(u.enabled=!0)}return fb(i),a}function Yz(s,e,t,i,n,r){var u;if(!e)return null;const o=e.userData;e.userData={};const a=e.children;e.children=[];const l=e.clone(!1);if(iw(l),e.userData=o,e.children=a,n[e.uuid]={original:e,clone:l},S_&&console.log("ADD",e,l),e.type==="SkinnedMesh"&&(r[e.uuid]={original:e,clone:l}),(t==null?void 0:t.visible)!==void 0&&(l.visible=t.visible),t!=null&&t.idProvider){l.uuid=t.idProvider.generateUUID();const d=l;d&&(d.guid=l.uuid)}e.animations&&e.animations.length>0&&(l.animations=[...e.animations]);const c=e.parent;if(c&&c.add(l),t!=null&&t.position?tr(l,t.position):l.position.copy(e.position),t!=null&&t.rotation?Vo(l,t.rotation):l.quaternion.copy(e.quaternion),t!=null&&t.scale?l.scale.copy(t.scale):l.scale.copy(e.scale),t!=null&&t.parent&&t.parent!=="scene"){let d=null;if(typeof t.parent=="string"?d=gp(t.parent,s.scene,!0):d=t.parent,d){const f=t.keepWorldPosition===!0?d.attach:d.add;f?f.call(d,l):console.error("Invalid parent object",d,"received when instantiating:",e)}else console.warn("could not find parent:",t.parent)}for(const[d,f]of Object.entries(e.userData))d!=="components"&&(l.userData[d]=f);if((u=e.userData)!=null&&u.components){const d=e.userData.components,f=[];l.userData.components=f;for(let p=0;p<d.length;p++){const m=d[p],A=new m.constructor;_p(A,m),m[Eg]!==void 0&&(A[Eg]=m[Eg]),f.push(A),A.gameObject=l,i.push(A),cA.dispatchComponentLifecycleEvent(lA.Added,A)}}t&&(t.position=void 0,t.rotation=void 0,t.scale=void 0,t.parent=void 0);for(const d in e.children){const f=e.children[d],p=Yz(s,f,t,i,n,r);p&&l.add(p)}return l}function Aee(s,e){for(const t in s){const i=s[t],n=i.original,r=n.skeleton,o=i.clone;if(!r){console.warn("Skinned mesh has no skeleton?",i);continue}const a=r.bones,l=o.skeleton.clone();o.skeleton=l,o.bindMatrix.clone().copy(n.bindMatrix),o.bindMatrixInverse.copy(n.bindMatrixInverse);const c=[];l.bones=c;for(let u=0;u<a.length;u++){const d=a[u],p=e[d.uuid].clone;c.push(p)}}for(const t in s){const i=s[t].clone;i.skeleton.update(),i.bind(i.skeleton,i.bindMatrix),i.updateMatrixWorld(!0)}}function yee(s){var e;for(const t in s){const n=s[t].clone;if((e=n.userData)!=null&&e.components)for(let r=0;r<n.userData.components.length;r++){const o=n.userData.components[r],a=Object.entries(o);for(const[l,c]of a)if(Array.isArray(c)){const u=[];o[l]=u;for(let d=0;d<c.length;d++){const f=c[d];if(typeof f!="object"){u.push(f);continue}const p=KD(o,l,f,s);p!==void 0?u.push(p):u.push(f)}}else if(typeof c=="object"){const u=KD(o,l,c,s);u!==void 0&&(o[l]=u)}}}}function KD(s,e,t,i){var n,r;if(t!=null)if(t.isComponent===!0){const o=t.gameObject;if(o){const a=o.uuid,l=(n=i[a])==null?void 0:n.clone;if(!l){S_&&console.log("reference did not change",e,s,t);return}const c=o.userData.components.indexOf(t);if(c>=0)return S_&&console.log(e,a),l.userData.components[c];console.warn("could not find component",e,t)}}else if(t.isObject3D===!0){if(e==="gameObject")return;const o=t;if(o){const a=o.uuid,l=(r=i[a])==null?void 0:r.clone;if(l)return S_&&console.log(e,"old",t,"new",l),l}}else{if(t.isVector4||t.isVector3||t.isVector2||t.isQuaternion||t.isEuler)return t.clone();if(t.isColor===!0)return t.clone();if(t.isEventList===!0)return new t.constructor}}const Jz=new Map;function _ee(s,e){if(!s)return;if(!e){console.warn("No prototype found",s,s.prototype,s.constructor);return}const t=Jz.get(e);t&&t.apply(s)}function bee(s){const e=xee(s.prototype);Jz.set(s,e)}function xee(s){return new wee(s)}class wee{constructor(e){h(this,"$symbol");h(this,"extensions");h(this,"descriptors");this.$symbol=Symbol("prototype-extension"),this.extensions=Object.keys(e),this.descriptors=new Array;for(let t=0;t<this.extensions.length;t++){const i=this.extensions[t],n=Object.getOwnPropertyDescriptor(e,i);n&&this.descriptors.push(n)}}apply(e){if(!e[this.$symbol]){e[this.$symbol]=!0;for(let t=0;t<this.extensions.length;t++){const i=this.extensions[t],n=this.descriptors[t];n&&Object.defineProperty(e,i,n)}}}}function iw(s){s&&s.isObject3D===!0&&_ee(s,ge)}ge.prototype.SetActive=function(s){this.visible=s};ge.prototype.setActive=function(s){this.visible=s};ge.prototype.destroy=function(){ba(this)};ge.prototype.addComponent=function(s,e){return Yu(this,s,e)};ge.prototype.addNewComponent=function(s,e){return Yu(this,s,e)};ge.prototype.removeComponent=function(s){return nR(this,s)};ge.prototype.getOrAddComponent=function(s,e){return nw(this,s,e)};ge.prototype.getComponent=function(s){return zp(this,s)};ge.prototype.getComponents=function(s,e){return vA(this,s,e)};ge.prototype.getComponentInChildren=function(s){return AA(this,s)};ge.prototype.getComponentsInChildren=function(s,e){return yA(this,s,e)};ge.prototype.getComponentInParent=function(s){return Cv(this,s)};ge.prototype.getComponentsInParent=function(s,e){return sw(this,s,e)};Object.getOwnPropertyDescriptor(ge.prototype,"activeSelf")||Object.defineProperty(ge.prototype,"activeSelf",{get:function(){return Up(this)},set:function(s){Og(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"transform")||Object.defineProperty(ge.prototype,"transform",{get:function(){return this}});Object.getOwnPropertyDescriptor(ge.prototype,"worldPosition")||Object.defineProperty(ge.prototype,"worldPosition",{get:function(){return this instanceof SI?kt(this.object):kt(this)},set:function(s){tr(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldQuaternion")||Object.defineProperty(ge.prototype,"worldQuaternion",{get:function(){return this instanceof SI?Mi(this.object):Mi(this)},set:function(s){Vo(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldRotation")||Object.defineProperty(ge.prototype,"worldRotation",{get:function(){return oA(this)},set:function(s){wI(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldScale")||Object.defineProperty(ge.prototype,"worldScale",{get:function(){return an(this)},set:function(s){Av(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldForward")||Object.defineProperty(ge.prototype,"worldForward",{get:function(){return En().set(0,0,1).applyQuaternion(Mi(this))}});Object.getOwnPropertyDescriptor(ge.prototype,"worldRight")||Object.defineProperty(ge.prototype,"worldRight",{get:function(){return En().set(1,0,0).applyQuaternion(Mi(this))}});Object.getOwnPropertyDescriptor(ge.prototype,"worldUp")||Object.defineProperty(ge.prototype,"worldUp",{get:function(){return En().set(0,1,0).applyQuaternion(Mi(this))}});bee(ge);const See=ne("debuggetcomponent"),ZD=()=>See||globalThis.NEEDLE_DEBUG_GETCOMPONENT===!0;function Cee(s){return s==null||s.isObject3D?s:s.object&&s.object.isObject3D?s.object:s}function nR(s,e){if(!s||!s.userData.components)return e;const t=s.userData.components.indexOf(e);return t<0||(cA.dispatchComponentLifecycleEvent(lA.Removing,e),e.gameObject=null,s.userData.components.splice(t,1)),e}function nw(s,e,t){const i=zp(s,e);return i||Yu(s,e,t)}const Kz=new ds("addComponentIdProvider");function bh(s,e,t=!0){s.userData||(s.userData={}),s.userData.components||(s.userData.components=[]),s.userData.components.push(e),e.gameObject=s,(e.guid===void 0||e.guid==="invalid")&&(e.guid=Kz.generateUUID()),iw(s),Zx(e);try{t&&e.__internalAwake&&(Mg(s),e.activeAndEnabled&&e.__internalAwake()),cA.dispatchComponentLifecycleEvent(lA.Added,e)}catch(i){console.error(i)}return e}function Yu(s,e,t,i){if(typeof e=="function"){const n=new e;t&&n.__internalNewInstanceCreated(t);let r=!0;return(i==null?void 0:i.callAwake)!=null&&(r=i.callAwake),bh(s,n,r)}if(e.destroyed)return console.warn("Can not move/add a destroyed component",e),e;if(e.gameObject===s)return e;if(e.gameObject&&e.gameObject.userData.components){const n=e.gameObject.userData.components.indexOf(e);e.gameObject.userData.components.splice(n,1)}if(!s.userData.components)s.userData.components=[];else if(s.userData.components.includes(e))return e;return s.userData.components.push(e),e.gameObject=s,(e.guid===void 0||e.guid==="invalid")&&(e.guid=Kz.generateUUID()),t&&e._internalInit(t),Zx(e),e}function Zz(s){if(s.gameObject&&s.gameObject.userData.components){const e=s.gameObject.userData.components.indexOf(s);s.gameObject.userData.components.splice(e,1)}s.__internalDisable&&s.__internalDisable(),Kl(s,s.context??Ft.Current),s.destroy(),s.gameObject=null}let $D=!1;function $z(s,e,t){var i;if(s==null)return null;if(!s.isObject3D)return console.error("Object is not object3D"),null;if(!((i=s==null?void 0:s.userData)!=null&&i.components)||(typeof e=="string"&&($D||($D=!0,console.warn(`Accessing components by name is not supported.
5257
+ Memory:`,{...this.renderer.info.memory})),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")),hi.dispatchCallback(kn.ContextFirstFrameRendered,this))}renderNow(e){return!e&&(e=this.mainCamera,!e)?!1:(this._isRendering=!0,this.renderRequiredTextures(),this.composer&&!this.isInXR?this.composer.render(this.time.deltaTime):e&&this.renderer.render(this.scene,e),this._isRendering=!1,!0)}onHandlePaused(){const e=this.evaluatePaused();if(this._wasPaused!==e){hee&&console.log("Paused?",e,"context:"+this.alias);for(let t=0;t<this.scripts_pausedChanged.length;t++){const i=this.scripts_pausedChanged[t];i.activeAndEnabled&&i.onPausedChanged!==void 0&&(Ui.Current=this,i.onPausedChanged(e,this._wasPaused))}}return this._wasPaused=e,e}evaluatePaused(){return this.isInXR?!1:this.isPaused?!0:this.runInBackground?!1:!this.isVisibleToUser}renderRequiredTextures(){if(!this.mainCamera||!this._requireDepthTexture&&!this._requireColorTexture)return;if(!this._renderTarget){if(this._renderTarget=new Yt(this.domWidth,this.domHeight),this._requireDepthTexture){const i=new Ip(this.domWidth,this.domHeight);this._renderTarget.depthTexture=i}this._requireColorTexture&&(this._renderTarget.texture=new Dt,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Ht,this._renderTarget.texture.magFilter=Ht,this._renderTarget.texture.format=Ai)}const e=this._renderTarget;e.texture&&(e.texture.colorSpace=this.renderer.outputColorSpace);const t=this.renderer.getRenderTarget();this.renderer.setRenderTarget(e),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(t)}executeCoroutines(e){var i;if(this.coroutines[e]){const n=this.coroutines[e];for(let r=0;r<n.length;r++)try{const o=n[r];if(!o.comp||o.comp.destroyed||!o.main||o.comp.enabled===!1){dee&&console.log("Removing coroutine",o.comp,o.comp.enabled),n.splice(r,1),--r;continue}const l=o.chained;if(l&&l.length>0){const f=l[l.length-1].next();if(f.done&&l.pop(),t(f)&&(o.chained||(o.chained=[]),o.chained.push(f.value)),!f.done)continue}const c=o.main.next();if(c.done===!0){n.splice(r,1),--r;continue}const u=c.value;if(t(u)){if(u.next().done)continue;o.chained||(o.chained=[]),o.chained.push(u)}else if(u instanceof Promise){const d=u;o.chained||(o.chained=[]);const f=gz(d);(i=o.chained)==null||i.push(f);continue}}catch(o){console.error(o)}}function t(n){return!!(n&&n.next&&n.return)}}};let Ft=Ui;h(Ft,"_defaultTargetFramerate",{value:60}),h(Ft,"_defaultWebglRendererParameters",{antialias:!0,alpha:!1,powerPreference:"high-performance"});hi.registerCallback(kn.ContextCreated,s=>{const e=s.context;Nz(e),Fz(e)});const Rb=ne("debugcomponents"),JD="eff8ba80-635d-11ec-90d6-0242ac120003";class ds{constructor(e){h(this,"_originalSeed");h(this,"_seed");typeof e=="string"&&(e=ds.hash(e)),this._originalSeed=e,this._seed=e}get seed(){return this._seed}set seed(e){this._seed=e}reset(){this._seed=this._originalSeed}generateUUID(e){if(typeof e=="string")return V2(e,JD);const t=this._seed;return this._seed-=1,V2(t.toString(),JD)}initialize(e){typeof e=="string"?this._seed=ds.hash(e):this._seed=e}static createFromString(e){return new ds(this.hash(e))}static hash(e){let t=0;for(let i=0;i<e.length;i++)t=e.charCodeAt(i)+((t<<5)-t);return t}}var Oz=(s=>(s.NewInstanceCreated="new-instance-created",s.InstanceDestroyed="instance-destroyed",s))(Oz||{});class Lz{constructor(e){h(this,"guid");this.guid=e}}function $x(s,e,t=!0){if(!s)return;const i=s;if(ba(s,t),!e){console.warn("Can not send destroy: No networking connection provided",s.guid);return}if(!e.isConnected){console.warn("Can not send destroy: not connected",s.guid);return}let n=s.guid;if(!n&&i.uuid&&(n=i.uuid),!n){console.warn("Can not send destroy: failed to find guid",s);return}const r=new Lz(n);e.send("instance-destroyed",r,ha.Queued)}function kz(s,e){const t=new Lz(s);e.send("instance-destroyed",t,ha.Queued)}function Fz(s){s.connection.beginListen("instance-destroyed",e=>{Rb&&console.log("[Remote] Destroyed",s.scene,e);const t=gA(e.guid,s.scene);t&&ba(t)})}class mee{constructor(e,t,i){h(this,"filename");h(this,"hash");h(this,"size");this.filename=e,this.hash=t,this.size=i}}class Uz{constructor(e,t){h(this,"guid");h(this,"originalGuid");h(this,"seed");h(this,"visible");h(this,"hostData");h(this,"dontSave");h(this,"parent");h(this,"position");h(this,"rotation");h(this,"scale");h(this,"preventCreation");this.originalGuid=e,this.guid=t}}function tR(s,e,t,i){var l;const n=s;if(!n.guid)return console.warn("Can not instantiate: No guid",n),null;if(e.context||(e.context=Ft.Current),!e.context)return console.error("Missing network instantiate options / reference to network connection in sync instantiate"),null;const r=e?{...e}:null,{instance:o,seed:a}=gee(n,e);if(o){const c=o;if(c.guid){Rb&&console.log("[Local] new instance","gameobject:",o==null?void 0:o.guid);const u=new Uz(n.guid,c.guid);u.seed=a,r&&(r.position&&(u.position={x:r.position.x,y:r.position.y,z:r.position.z}),r.rotation&&(u.rotation={x:r.rotation.x,y:r.rotation.y,z:r.rotation.z,w:r.rotation.w}),r.scale&&(u.scale={x:r.scale.x,y:r.scale.y,z:r.scale.z})),u.position||(u.position={x:c.position.x,y:c.position.y,z:c.position.z}),u.rotation||(u.rotation={x:c.quaternion.x,y:c.quaternion.y,z:c.quaternion.z,w:c.quaternion.w}),u.scale||(u.scale={x:c.scale.x,y:c.scale.y,z:c.scale.z}),u.visible=n.visible,r!=null&&r.parent&&(typeof r.parent=="string"?u.parent=r.parent:u.parent=r.parent.guid),u.hostData=t,i===!1&&(u.dontSave=!0),(l=e==null?void 0:e.context)==null||l.connection.send("new-instance-created",u)}else console.warn("Missing guid, can not send new instance event",c)}return o}function ew(){return Math.random()*9999999}function Nz(s){s.connection.beginListen("new-instance-created",async e=>{const t=await vee(e.originalGuid,s.scene);if(e.preventCreation===!0)return;if(!t){console.warn("could not find object that was instantiated: "+e.guid);return}const i=new Ea;e.position&&(i.position=new w(e.position.x,e.position.y,e.position.z)),e.rotation&&(i.rotation=new Ce(e.rotation.x,e.rotation.y,e.rotation.z,e.rotation.w)),e.scale&&(i.scale=new w(e.scale.x,e.scale.y,e.scale.z)),i.parent=e.parent,e.seed&&(i.idProvider=new ds(e.seed)),i.visible=e.visible,i.context=s,Rb&&s.alias&&console.log("[Remote] instantiate in: "+s.alias);const n=Np(t,i);n&&(e.parent==="scene"&&s.scene.add(n),Rb&&console.log("[Remote] new instance","gameobject:",n==null?void 0:n.guid,t))})}function gee(s,e){const t=ew(),i=e??new Ea;i.idProvider=new ds(t);const n=Np(s,i);return{seed:t,instance:n}}const zz={};function Gz(s,e){zz[s]=e}async function vee(s,e){const t=zz[s];if(t!=null){const i=await t(s);if(i)return i}return Hz(s,e)}function Hz(s,e){if(e===null||!s)return null;if(e.guid===s)return e;if(e.children)for(const t of e.children){const i=Hz(s,t);if(i)return i}return null}const w_=ne("debuggetcomponent"),S_=ne("debuginstantiate");var Qz=(s=>(s[s.None=0]="None",s[s.HideInHierarchy=1]="HideInHierarchy",s[s.HideInInspector=2]="HideInInspector",s[s.DontSaveInEditor=4]="DontSaveInEditor",s[s.NotEditable=8]="NotEditable",s[s.DontSaveInBuild=16]="DontSaveInBuild",s[s.DontUnloadUnusedAsset=32]="DontUnloadUnusedAsset",s[s.DontSave=52]="DontSave",s[s.HideAndDontSave=61]="HideAndDontSave",s))(Qz||{});class Ea{constructor(){h(this,"idProvider");h(this,"parent");h(this,"keepWorldPosition");h(this,"position");h(this,"rotation");h(this,"scale");h(this,"visible");h(this,"context")}clone(){var t,i,n;const e=new Ea;return e.idProvider=this.idProvider,e.parent=this.parent,e.keepWorldPosition=this.keepWorldPosition,e.position=(t=this.position)==null?void 0:t.clone(),e.rotation=(i=this.rotation)==null?void 0:i.clone(),e.scale=(n=this.scale)==null?void 0:n.clone(),e}cloneAssign(e){var t,i,n;this.idProvider=e.idProvider,this.parent=e.parent,this.keepWorldPosition=e.keepWorldPosition,this.position=(t=e.position)==null?void 0:t.clone(),this.rotation=(i=e.rotation)==null?void 0:i.clone(),this.scale=(n=e.scale)==null?void 0:n.clone()}}function Up(s){return s.visible}function Og(s,e){return typeof e=="number"&&(e=e>.5),s.visible=e,s.visible}function Vz(s){return s[cc]||tw(s)}function jz(s,e){s[ON]=e}function tw(s){return Aa.isUsingInstancing(s)}function gA(s,e){return gp(s,e,!0,!0)}const Wz=Symbol("isDestroyed");function cd(s){return s[Wz]}function qz(s,e){s[Wz]=e}const sM=Symbol("isDontDestroy");function rM(s,e=!0){s[sM]=e}const C_=[],E_=[];function ba(s,e=!0,t=!1){C_.length=0,E_.length=0,oM(s,e,!0);for(const i of C_)i.gameObject=null,i.context=null;for(const i of E_)qz(i,!0),t&&Di(i),BN(i);E_.length=0,C_.length=0}function oM(s,e=!0,t=!0){var o;if(s==null)return;const i=s;if(i.isComponent){if(i[sM])return;C_.push(i);const a=i.gameObject;i.__internalDisable(),i.__internalDestroy(),i.gameObject=a;return}if(s[sM])return;const n=s;w_&&console.log(n),E_.push(n);const r=(o=n.userData)==null?void 0:o.components;if(r!=null&&Array.isArray(r)){let a=r.length;for(let l=0;l<r.length;l++){const c=r[l];oM(c,e,!1),r.length<a&&(a=r.length,l--)}}if(e&&n.children)for(const a of n.children)oM(a,e,!1);t&&n.removeFromParent()}function hd(s,e,t=!0){return Xz(s,e,t)}function*iR(s,e,t=!1,i=999,n=0){if(s!=null&&s.userData.components&&!(n>i)){for(const r of s.userData.components)e&&(r==null?void 0:r.isComponent)===!0&&r instanceof e?yield r:yield r;if(t===!0)for(const r of s.children)yield*iR(r,e,!0,i,n+1)}}function Xz(s,e,t,i=0){var n;if(s){if(s.isObject3D,i>1e3){console.warn("Failed to iterate components: too many levels");return}if((n=s.userData)!=null&&n.components)for(let r=0;r<s.userData.components.length;r++){const o=s.userData.components[r];if((o==null?void 0:o.isComponent)===!0){const a=e(o);if(a!==void 0)return a}}if(t&&s.children){const r=i+1;for(let o=0;o<s.children.length;o++){const a=s.children[o];if(!a)continue;const l=Xz(a,e,t,r);if(l!==void 0)return l}}}}function Np(s,e=null){let t=null;e!==null&&(e.x!==void 0?(t=new Ea,t.position=e):t=e);let i=Ft.Current;t!=null&&t.context&&(i=t.context),w_&&i.alias&&console.log("context",i.alias),t&&!t.idProvider&&(t.idProvider=new ds(Date.now()));const n=[],r={},o={},a=Yz(i,s,t,n,r,o);a&&(yee(r),Aee(o,r)),w_&&(ub(s,!0),ub(a,!0));const l={};for(const c in n){const u=n[c],d=u.guid;t&&t.idProvider&&(u.guid=t.idProvider.generateUUID(),l[d]=u.guid,w_&&console.log(u.name,u.guid)),Zx(u,i),u.__internalNewInstanceCreated&&u.__internalNewInstanceCreated()}for(const c in n){const u=n[c];u.resolveGuids&&u.resolveGuids(l),u.enabled!==!1&&(u.enabled=!0)}return fb(i),a}function Yz(s,e,t,i,n,r){var u;if(!e)return null;const o=e.userData;e.userData={};const a=e.children;e.children=[];const l=e.clone(!1);if(iw(l),e.userData=o,e.children=a,n[e.uuid]={original:e,clone:l},S_&&console.log("ADD",e,l),e.type==="SkinnedMesh"&&(r[e.uuid]={original:e,clone:l}),(t==null?void 0:t.visible)!==void 0&&(l.visible=t.visible),t!=null&&t.idProvider){l.uuid=t.idProvider.generateUUID();const d=l;d&&(d.guid=l.uuid)}e.animations&&e.animations.length>0&&(l.animations=[...e.animations]);const c=e.parent;if(c&&c.add(l),t!=null&&t.position?tr(l,t.position):l.position.copy(e.position),t!=null&&t.rotation?Vo(l,t.rotation):l.quaternion.copy(e.quaternion),t!=null&&t.scale?l.scale.copy(t.scale):l.scale.copy(e.scale),t!=null&&t.parent&&t.parent!=="scene"){let d=null;if(typeof t.parent=="string"?d=gp(t.parent,s.scene,!0):d=t.parent,d){const f=t.keepWorldPosition===!0?d.attach:d.add;f?f.call(d,l):console.error("Invalid parent object",d,"received when instantiating:",e)}else console.warn("could not find parent:",t.parent)}for(const[d,f]of Object.entries(e.userData))d!=="components"&&(l.userData[d]=f);if((u=e.userData)!=null&&u.components){const d=e.userData.components,f=[];l.userData.components=f;for(let p=0;p<d.length;p++){const m=d[p],A=new m.constructor;_p(A,m),m[Eg]!==void 0&&(A[Eg]=m[Eg]),f.push(A),A.gameObject=l,i.push(A),cA.dispatchComponentLifecycleEvent(lA.Added,A)}}t&&(t.position=void 0,t.rotation=void 0,t.scale=void 0,t.parent=void 0);for(const d in e.children){const f=e.children[d],p=Yz(s,f,t,i,n,r);p&&l.add(p)}return l}function Aee(s,e){for(const t in s){const i=s[t],n=i.original,r=n.skeleton,o=i.clone;if(!r){console.warn("Skinned mesh has no skeleton?",i);continue}const a=r.bones,l=o.skeleton.clone();o.skeleton=l,o.bindMatrix.clone().copy(n.bindMatrix),o.bindMatrixInverse.copy(n.bindMatrixInverse);const c=[];l.bones=c;for(let u=0;u<a.length;u++){const d=a[u],p=e[d.uuid].clone;c.push(p)}}for(const t in s){const i=s[t].clone;i.skeleton.update(),i.bind(i.skeleton,i.bindMatrix),i.updateMatrixWorld(!0)}}function yee(s){var e;for(const t in s){const n=s[t].clone;if((e=n.userData)!=null&&e.components)for(let r=0;r<n.userData.components.length;r++){const o=n.userData.components[r],a=Object.entries(o);for(const[l,c]of a)if(Array.isArray(c)){const u=[];o[l]=u;for(let d=0;d<c.length;d++){const f=c[d];if(typeof f!="object"){u.push(f);continue}const p=KD(o,l,f,s);p!==void 0?u.push(p):u.push(f)}}else if(typeof c=="object"){const u=KD(o,l,c,s);u!==void 0&&(o[l]=u)}}}}function KD(s,e,t,i){var n,r;if(t!=null)if(t.isComponent===!0){const o=t.gameObject;if(o){const a=o.uuid,l=(n=i[a])==null?void 0:n.clone;if(!l){S_&&console.log("reference did not change",e,s,t);return}const c=o.userData.components.indexOf(t);if(c>=0)return S_&&console.log(e,a),l.userData.components[c];console.warn("could not find component",e,t)}}else if(t.isObject3D===!0){if(e==="gameObject")return;const o=t;if(o){const a=o.uuid,l=(r=i[a])==null?void 0:r.clone;if(l)return S_&&console.log(e,"old",t,"new",l),l}}else{if(t.isVector4||t.isVector3||t.isVector2||t.isQuaternion||t.isEuler)return t.clone();if(t.isColor===!0)return t.clone();if(t.isEventList===!0)return new t.constructor}}const Jz=new Map;function _ee(s,e){if(!s)return;if(!e){console.warn("No prototype found",s,s.prototype,s.constructor);return}const t=Jz.get(e);t&&t.apply(s)}function bee(s){const e=xee(s.prototype);Jz.set(s,e)}function xee(s){return new wee(s)}class wee{constructor(e){h(this,"$symbol");h(this,"extensions");h(this,"descriptors");this.$symbol=Symbol("prototype-extension"),this.extensions=Object.keys(e),this.descriptors=new Array;for(let t=0;t<this.extensions.length;t++){const i=this.extensions[t],n=Object.getOwnPropertyDescriptor(e,i);n&&this.descriptors.push(n)}}apply(e){if(!e[this.$symbol]){e[this.$symbol]=!0;for(let t=0;t<this.extensions.length;t++){const i=this.extensions[t],n=this.descriptors[t];n&&Object.defineProperty(e,i,n)}}}}function iw(s){s&&s.isObject3D===!0&&_ee(s,ge)}ge.prototype.SetActive=function(s){this.visible=s};ge.prototype.setActive=function(s){this.visible=s};ge.prototype.destroy=function(){ba(this)};ge.prototype.addComponent=function(s,e){return Yu(this,s,e)};ge.prototype.addNewComponent=function(s,e){return Yu(this,s,e)};ge.prototype.removeComponent=function(s){return nR(this,s)};ge.prototype.getOrAddComponent=function(s,e){return nw(this,s,e)};ge.prototype.getComponent=function(s){return zp(this,s)};ge.prototype.getComponents=function(s,e){return vA(this,s,e)};ge.prototype.getComponentInChildren=function(s){return AA(this,s)};ge.prototype.getComponentsInChildren=function(s,e){return yA(this,s,e)};ge.prototype.getComponentInParent=function(s){return Cv(this,s)};ge.prototype.getComponentsInParent=function(s,e){return sw(this,s,e)};Object.getOwnPropertyDescriptor(ge.prototype,"activeSelf")||Object.defineProperty(ge.prototype,"activeSelf",{get:function(){return Up(this)},set:function(s){Og(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"transform")||Object.defineProperty(ge.prototype,"transform",{get:function(){return this}});Object.getOwnPropertyDescriptor(ge.prototype,"worldPosition")||Object.defineProperty(ge.prototype,"worldPosition",{get:function(){return this instanceof SI?kt(this.object):kt(this)},set:function(s){tr(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldQuaternion")||Object.defineProperty(ge.prototype,"worldQuaternion",{get:function(){return this instanceof SI?Mi(this.object):Mi(this)},set:function(s){Vo(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldRotation")||Object.defineProperty(ge.prototype,"worldRotation",{get:function(){return oA(this)},set:function(s){wI(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldScale")||Object.defineProperty(ge.prototype,"worldScale",{get:function(){return an(this)},set:function(s){Av(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldForward")||Object.defineProperty(ge.prototype,"worldForward",{get:function(){return En().set(0,0,1).applyQuaternion(Mi(this))}});Object.getOwnPropertyDescriptor(ge.prototype,"worldRight")||Object.defineProperty(ge.prototype,"worldRight",{get:function(){return En().set(1,0,0).applyQuaternion(Mi(this))}});Object.getOwnPropertyDescriptor(ge.prototype,"worldUp")||Object.defineProperty(ge.prototype,"worldUp",{get:function(){return En().set(0,1,0).applyQuaternion(Mi(this))}});bee(ge);const See=ne("debuggetcomponent"),ZD=()=>See||globalThis.NEEDLE_DEBUG_GETCOMPONENT===!0;function Cee(s){return s==null||s.isObject3D?s:s.object&&s.object.isObject3D?s.object:s}function nR(s,e){if(!s||!s.userData.components)return e;const t=s.userData.components.indexOf(e);return t<0||(cA.dispatchComponentLifecycleEvent(lA.Removing,e),e.gameObject=null,s.userData.components.splice(t,1)),e}function nw(s,e,t){const i=zp(s,e);return i||Yu(s,e,t)}const Kz=new ds("addComponentIdProvider");function bh(s,e,t=!0){s.userData||(s.userData={}),s.userData.components||(s.userData.components=[]),s.userData.components.push(e),e.gameObject=s,(e.guid===void 0||e.guid==="invalid")&&(e.guid=Kz.generateUUID()),iw(s),Zx(e);try{t&&e.__internalAwake&&(Mg(s),e.activeAndEnabled&&e.__internalAwake()),cA.dispatchComponentLifecycleEvent(lA.Added,e)}catch(i){console.error(i)}return e}function Yu(s,e,t,i){if(typeof e=="function"){const n=new e;t&&n.__internalNewInstanceCreated(t);let r=!0;return(i==null?void 0:i.callAwake)!=null&&(r=i.callAwake),bh(s,n,r)}if(e.destroyed)return console.warn("Can not move/add a destroyed component",e),e;if(e.gameObject===s)return e;if(e.gameObject&&e.gameObject.userData.components){const n=e.gameObject.userData.components.indexOf(e);e.gameObject.userData.components.splice(n,1)}if(!s.userData.components)s.userData.components=[];else if(s.userData.components.includes(e))return e;return s.userData.components.push(e),e.gameObject=s,(e.guid===void 0||e.guid==="invalid")&&(e.guid=Kz.generateUUID()),t&&e._internalInit(t),Zx(e),e}function Zz(s){if(s.gameObject&&s.gameObject.userData.components){const e=s.gameObject.userData.components.indexOf(s);s.gameObject.userData.components.splice(e,1)}s.__internalDisable&&s.__internalDisable(),Kl(s,s.context??Ft.Current),s.destroy(),s.gameObject=null}let $D=!1;function $z(s,e,t){var i;if(s==null)return null;if(!s.isObject3D)return console.error("Object is not object3D"),null;if(!((i=s==null?void 0:s.userData)!=null&&i.components)||(typeof e=="string"&&($D||($D=!0,console.warn(`Accessing components by name is not supported.
5258
5258
  Please use the component type instead. This may keep working in local development but it will fail when bundling your application.
5259
5259
 
5260
5260
  You can import other modules your main module to get access to types
5261
5261
  or if you use npmdefs you can make types available globally using globalThis:
5262
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis`,e))),ZD()&&console.log("[onGetComponent] FIND",e),e==null))return null;for(let n=0;n<s.userData.components.length;n++){const r=s.userData.components[n];let o=Object.getPrototypeOf(r);for(;o;){if(o===e.prototype)if(ZD()&&console.log("[onGetComponent] MATCH BY PROTOYPE",o),t)t.push(r);else return r;o=Object.getPrototypeOf(o)}}return t||null}function zp(s,e){const t=$z(s,e);return t?Array.isArray(t)?t[0]:t:null}function vA(s,e,t,i=!0){return t||(t=[]),i&&(t.length=0),$z(s,e,t),t}function AA(s,e,t){var n;const i=zp(s,e);if(t===!1&&(i==null?void 0:i.enabled)===!1)return null;if(i)return i;for(let r=0;r<((n=s==null?void 0:s.children)==null?void 0:n.length);r++){const o=AA(s.children[r],e);if(o)return o}return null}function yA(s,e,t,i=!0){var n;t||(t=[]),i&&(t.length=0),vA(s,e,t,!1);for(let r=0;r<((n=s==null?void 0:s.children)==null?void 0:n.length);r++)yA(s.children[r],e,t,!1);return t}function Cv(s,e){if(!s)return null;if(Array.isArray(s)){for(let i=0;i<s.length;i++){const n=Cee(s[i]),r=Cv(n,e);if(r)return r}return null}const t=zp(s,e);return t||(s.parent?Cv(s.parent,e):null)}function sw(s,e,t,i=!0){return t||(t=[]),i&&(t.length=0),s?(vA(s,e,t,!1),s.parent?sw(s.parent,e,t,!1):t):t}function e4(s,e,t){if(!s)return null;if(!e&&(e=Ft.Current,!e))return console.error("Can not search object without any needle context or scene!!!"),null;let i=e;if(i.isScene||(i=e==null?void 0:e.scene),!i)return null;for(const n in i.children){const r=i.children[n];if(t===!1&&r[cc]===!1)continue;const o=AA(r,s);if(o)return o}return null}function t4(s,e,t){if(!s)return e;if(e||(e=[]),e.length=0,!t&&(t=Ft.Current,!t))return console.error("Can not search object without any needle context or scene!!!"),e;const i=t.isScene===!0||t.isObject3D===!0?t:t==null?void 0:t.scene;if(!i)return e;for(const n in i.children){const r=i.children[n];if(r.constructor==s)return r;yA(r,s,e,!1)}return e}class oe extends ge{constructor(){super(...arguments);h(this,"guid")}static isDestroyed(t){return cd(t)}static setActive(t,i,n=!0){t&&(Og(t,i),m_(t),i&&n&&kN(Ft.Current,t))}static isActiveSelf(t){return Up(t)}static isActiveInHierarchy(t){return Vz(t)}static markAsInstancedRendered(t,i){jz(t,i)}static isUsingInstancing(t){return tw(t)}static foreachComponent(t,i,n=!0){return hd(t,i,n)}static instantiateSynced(t,i){return t?tR(t,i):null}static instantiate(t,i=null){return Np(t,i)}static destroySynced(t,i,n=!0){if(!t)return;const r=t;i=i??Ft.Current,$x(r,i.connection,n)}static destroy(t,i=!0,n=!0){return ba(t,i,n)}static add(t,i,n){if(!(!t||!i)){if(t===i){console.warn("Can not add object to self",t);return}n||(n=Ft.Current),i.add(t),Og(t,!0),m_(t),n?oe.foreachComponent(t,r=>{II(r,n),!r.__internalDidAwakeAndStart&&n.new_script_start.includes(r)===!1&&n.new_script_start.push(r)},!0):console.warn("Missing context")}}static remove(t){var i;t&&((i=t.parent)==null||i.remove(t),Og(t,!1),m_(t),oe.foreachComponent(t,n=>{xY(n)},!0))}static invokeOnChildren(t,i,...n){this.invoke(t,i,!0,n)}static invoke(t,i,n=!1,...r){t&&this.foreachComponent(t,o=>{const a=o[i];a&&typeof a=="function"&&(a==null||a.call(o,...r))},n)}static addNewComponent(t,i,n,r=!0){return Yu(t,i,n,{callAwake:r})}static addComponent(t,i,n,r){return Yu(t,i,n,r)}static moveComponent(t,i){return Yu(t,i)}static removeComponent(t){return nR(t.gameObject,t),t}static getOrAddComponent(t,i){return nw(t,i)}static getComponent(t,i){return t===null?null:zp(t,i)}static getComponents(t,i,n=null){return t===null?n??[]:vA(t,i,n)}static findByGuid(t,i){return gA(t,i)}static findObjectOfType(t,i,n=!0){return e4(t,i??Ft.Current,n)}static findObjectsOfType(t,i){const n=[];return t4(t,n,i),n}static getComponentInChildren(t,i){return AA(t,i)}static getComponentsInChildren(t,i,n=null){return yA(t,i,n??void 0)}static getComponentInParent(t,i){return Cv(t,i)}static getComponentsInParent(t,i,n=null){return sw(t,i,n)}static getAllComponents(t){var r;return[...(r=t.userData)==null?void 0:r.components]}static*iterateComponents(t){var n;const i=(n=t==null?void 0:t.userData)==null?void 0:n.components;if(i&&Array.isArray(i))for(let r=0;r<i.length;r++)yield i[r]}}var Ka;let Me=(Ka=class{constructor(e){h(this,"__context");h(this,"__name");h(this,"gameObject");h(this,"guid","invalid");h(this,"sourceId");h(this,"__didAwake",!1);h(this,"__didStart",!1);h(this,"__didEnable",!1);h(this,"__isEnabled");h(this,"__destroyed",!1);h(this,"_eventListeners",new Map);this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(e)}get isComponent(){return!0}get context(){return this.__context??Ft.Current}set context(e){this.__context=e}get scene(){return this.context.scene}get layer(){var e,t;return(t=(e=this.gameObject)==null?void 0:e.userData)==null?void 0:t.layer}get name(){var e,t;return(e=this.gameObject)!=null&&e.name?this.gameObject.name:(t=this.gameObject)==null?void 0:t.userData.name}set name(e){this.gameObject?(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.name=e,this.__name=e):this.__name=e}get tag(){var e;return(e=this.gameObject)==null?void 0:e.userData.tag}set tag(e){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.tag=e)}get static(){var e;return(e=this.gameObject)==null?void 0:e.userData.static}get hideFlags(){var e;return(e=this.gameObject)==null?void 0:e.userData.hideFlags}get activeAndEnabled(){return!(this.destroyed||this.__isEnabled===!1||!this.__isActiveInHierarchy)}get __isActive(){return this.gameObject.visible}get __isActiveInHierarchy(){if(!this.gameObject)return!1;const e=this.gameObject[cc];return e===void 0?!0:e}set __isActiveInHierarchy(e){this.gameObject&&(this.gameObject[cc]=e)}awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(e,t=Un.Update){return this.context.registerCoroutineUpdate(this,e,t)}stopCoroutine(e,t=Un.Update){this.context.unregisterCoroutineUpdate(e,t)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}__internalNewInstanceCreated(e){return this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(e),this}_internalInit(e){if(typeof e=="object")for(const t of Object.keys(e)){const i=e[t];typeof i!="function"&&(this[t]=i)}}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(e){return this.__destroyed?(At()&&console.warn("[Needle Engine Dev] Trying to enable destroyed component"),!1):this.__didAwake?this.__didEnable?(e!==!0&&(this.__isEnabled=!0),!1):(this.__didEnable=!0,this.__isEnabled=!0,this.onEnable(),!0):!1}__internalDisable(e){if(this.__didAwake){if(!this.__didEnable){e!==!0&&(this.__isEnabled=!1);return}this.__didEnable=!1,this.__isEnabled=!1,this.onDisable()}}__internalDestroy(){var e;this.__destroyed||(this.__destroyed=!0,this.__didAwake&&((e=this.onDestroy)==null||e.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this}))),Zz(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(e){if(this.__destroyed){At()&&console.warn(`[Needle Engine Dev] Trying to ${e?"enable":"disable"} destroyed component`);return}if(typeof e=="number"&&(e>=.5?e=!0:e=!1),!this.__didAwake){this.__isEnabled=e;return}e?this.__internalEnable():this.__internalDisable()}get worldPosition(){return kt(this.gameObject)}set worldPosition(e){tr(this.gameObject,e)}setWorldPosition(e,t,i){ad(this.gameObject,e,t,i)}get worldQuaternion(){return Mi(this.gameObject)}set worldQuaternion(e){Vo(this.gameObject,e)}setWorldQuaternion(e,t,i,n){yI(this.gameObject,e,t,i,n)}get worldEuler(){return bI(this.gameObject)}set worldEuler(e){xI(this.gameObject,e)}get worldRotation(){return this.gameObject.worldRotation}set worldRotation(e){this.setWorldRotation(e.x,e.y,e.z,!0)}setWorldRotation(e,t,i,n=!0){aA(this.gameObject,e,t,i,n)}get forward(){return Ka._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}get right(){return Ka._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}get up(){return Ka._up.set(0,1,0).applyQuaternion(this.worldQuaternion)}addEventListener(e,t){this._eventListeners[e]=this._eventListeners[e]||[],this._eventListeners[e].push(t)}removeEventListener(e,t){if(!this._eventListeners[e])return;const i=this._eventListeners[e].indexOf(t);i>=0&&this._eventListeners[e].splice(i,1)}dispatchEvent(e){if(!e||!this._eventListeners[e.type])return!1;const t=this._eventListeners[e.type];for(let i=0;i<t.length;i++)t[i](e);return!1}},h(Ka,"_forward",new w),h(Ka,"_right",new w),h(Ka,"_up",new w),Ka);const Eee=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:Me,Component:Me,GameObject:oe},Symbol.toStringTag,{value:"Module"})),Ru=ne("debugloading"),Dm=ne("debugloadingrendering"),eO=ne("debuglicense");class Mee{constructor(){h(this,"className");h(this,"additionalClasses")}}let Om=0,tO;function sR(s){Ru&&console.log(s.progress.loaded.toFixed(0)+"/"+s.progress.total.toFixed(0),s);const e=s.count,t=s.progress.total;t===0||t===void 0?(tO!==s.name&&(Om=0),tO=s.name,Om+=(1-Om)*.001,Ru&&$i("Loading "+s.name+" did not report total size")):Om=s.progress.loaded/t;const i=s.index/e+Om/e;return et.clamp01(i)}const Vb=class{constructor(e,t){h(this,"loadingProgress",0);h(this,"_element");h(this,"_progress",0);h(this,"_allowCustomLoadingElement",!0);h(this,"_loadingElement");h(this,"_loadingTextContainer",null);h(this,"_loadingBar",null);h(this,"_messageContainer",null);h(this,"_loadingElementOptions");h(this,"_progressLoop");this._element=e,this._loadingElementOptions=t}async onLoadingBegin(e){const t=this._element.shadowRoot||this._element;if(Ru&&console.warn("Begin Loading"),!this._loadingElement){for(let i=0;i<t.children.length;i++){const n=t.children[i];if(n.classList.contains(Vb.LoadingContainerClassName)){if(!this._allowCustomLoadingElement){Ru&&console.warn("Remove custom loading container"),t.removeChild(n);continue}this._loadingElement=this.createLoadingElement(n)}}this._loadingElement||(this._loadingElement=this.createLoadingElement())}this._progress=0,this.loadingProgress=0,this._loadingElement.style.display="flex",t.appendChild(this._loadingElement),this.smoothProgressLoop(),this.setMessage(e??"")}onLoadingUpdate(e,t){var n;if(!((n=this._loadingElement)!=null&&n.parentNode))return;let i=0;typeof e=="number"?i=e:("index"in e&&(i=sR(e)),!t&&"name"in e&&this.setMessage("loading "+e.name)),this.loadingProgress=i,t&&this.setMessage(t),this.updateDisplay()}onLoadingFinished(){Ru&&console.warn("Finished Loading"),Dm||(this.loadingProgress=1,this.onDoneLoading())}setMessage(e){this._messageContainer&&(this._messageContainer.innerText=e)}smoothProgressLoop(){if(this._progressLoop)return;let e=1/12;Dm&&(e=1/500,typeof Dm=="number"&&(e*=Dm)),this._progressLoop=setInterval(()=>{this.loadingProgress>=.95&&!Dm&&(e=.9),this._progress=et.lerp(this._progress,this.loadingProgress,e*this.loadingProgress),this.updateDisplay()},e)}onDoneLoading(){this._loadingElement&&(Ru&&console.log("Hiding loading element"),this._loadingElement.style.display="none",this._loadingElement.remove()),this._progressLoop&&clearInterval(this._progressLoop),this._progressLoop=null}updateDisplay(){const e=this._progress,t=(e*100).toFixed(0)+"%";this._loadingBar&&(this._loadingBar.style.width=e*100+"%"),this._loadingTextContainer&&(this._loadingTextContainer.textContent=t)}createLoadingElement(e){var m,A;Ru&&!e&&console.log("Creating loading element"),this._loadingElement=e||document.createElement("div");let t=this._element.getAttribute("loading-style");(!t||t==="auto")&&(window.matchMedia("(prefers-color-scheme: dark)").matches?t="dark":t="light");const i=cl();if(!e&&(this._loadingElement.style.position="absolute",this._loadingElement.style.width="100%",this._loadingElement.style.height="100%",this._loadingElement.style.left="0",this._loadingElement.style.top="0",t==="light"?this._loadingElement.style.backgroundColor="#ddd":this._loadingElement.style.backgroundColor="#222",this._loadingElement.style.display="flex",this._loadingElement.style.alignItems="center",this._loadingElement.style.justifyContent="center",this._loadingElement.style.zIndex=Number.MAX_SAFE_INTEGER.toString(),this._loadingElement.style.flexDirection="column",this._loadingElement.style.pointerEvents="none",this._loadingElement.style.color="white",this._loadingElement.style.fontFamily="Roboto, sans-serif, Arial",t==="light"?this._loadingElement.style.color="rgba(0,0,0,.6)":this._loadingElement.style.color="rgba(255,255,255,.3)",i&&this._element)){const v=this._element.getAttribute("loading-background-color");v&&(this._loadingElement.style.backgroundColor=v);const g=this._element.getAttribute("loading-text-color");g&&(this._loadingElement.style.color=g)}const n=((m=this._loadingElementOptions)==null?void 0:m.className)??Vb.LoadingContainerClassName;if(this._loadingElement.classList.add(n),(A=this._loadingElementOptions)!=null&&A.additionalClasses)for(const v of this._loadingElementOptions.additionalClasses)this._loadingElement.classList.add(v);const r=document.createElement("div");this._loadingElement.appendChild(r);const o=document.createElement("img"),a=120;o.style.width=`${a}px`,o.style.height=`${a}px`,o.style.borderRadius="80px",o.style.padding="20px",o.style.margin="-20px",o.style.marginBottom="-10px",o.style.userSelect="none",o.style.objectFit="contain",o.style.transition="transform 2s ease-out, opacity 1s ease-in-out",o.style.transform="translateY(10px)",setTimeout(()=>{o.style.transform="translateY(0px)"},1),o.src=$$;let l=!1;if(i&&this._element){const v=this._element.getAttribute("loading-logo-src");v&&(l=!0,o.src=v)}l||(o.style.cursor="pointer",o.style.pointerEvents="all",o.addEventListener("click",()=>window.open("https://needle.tools","_blank"))),r.appendChild(o);const c=document.createElement("div");c.style.cssText=`
5262
+ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis`,e))),ZD()&&console.log("[onGetComponent] FIND",e),e==null))return null;for(let n=0;n<s.userData.components.length;n++){const r=s.userData.components[n];let o=Object.getPrototypeOf(r);for(;o;){if(o===e.prototype)if(ZD()&&console.log("[onGetComponent] MATCH BY PROTOYPE",o),t)t.push(r);else return r;o=Object.getPrototypeOf(o)}}return t||null}function zp(s,e){const t=$z(s,e);return t?Array.isArray(t)?t[0]:t:null}function vA(s,e,t,i=!0){return t||(t=[]),i&&(t.length=0),$z(s,e,t),t}function AA(s,e,t){var n;const i=zp(s,e);if(t===!1&&(i==null?void 0:i.enabled)===!1)return null;if(i)return i;for(let r=0;r<((n=s==null?void 0:s.children)==null?void 0:n.length);r++){const o=AA(s.children[r],e);if(o)return o}return null}function yA(s,e,t,i=!0){var n;t||(t=[]),i&&(t.length=0),vA(s,e,t,!1);for(let r=0;r<((n=s==null?void 0:s.children)==null?void 0:n.length);r++)yA(s.children[r],e,t,!1);return t}function Cv(s,e){if(!s)return null;if(Array.isArray(s)){for(let i=0;i<s.length;i++){const n=Cee(s[i]),r=Cv(n,e);if(r)return r}return null}const t=zp(s,e);return t||(s.parent?Cv(s.parent,e):null)}function sw(s,e,t,i=!0){return t||(t=[]),i&&(t.length=0),s?(vA(s,e,t,!1),s.parent?sw(s.parent,e,t,!1):t):t}function e4(s,e,t){if(!s)return null;if(!e&&(e=Ft.Current,!e))return console.error("Can not search object without any needle context or scene!!!"),null;let i=e;if(i.isScene||(i=e==null?void 0:e.scene),!i)return null;for(const n in i.children){const r=i.children[n];if(t===!1&&r[cc]===!1)continue;const o=AA(r,s);if(o)return o}return null}function t4(s,e,t){if(!s)return e;if(e||(e=[]),e.length=0,!t&&(t=Ft.Current,!t))return console.error("Can not search object without any needle context or scene!!!"),e;const i=t.isScene===!0||t.isObject3D===!0?t:t==null?void 0:t.scene;if(!i)return e;for(const n in i.children){const r=i.children[n];if(r.constructor==s)return r;yA(r,s,e,!1)}return e}class oe extends ge{constructor(){super(...arguments);h(this,"guid")}static isDestroyed(t){return cd(t)}static setActive(t,i,n=!0){t&&(Og(t,i),m_(t),i&&n&&kN(Ft.Current,t))}static isActiveSelf(t){return Up(t)}static isActiveInHierarchy(t){return Vz(t)}static markAsInstancedRendered(t,i){jz(t,i)}static isUsingInstancing(t){return tw(t)}static foreachComponent(t,i,n=!0){return hd(t,i,n)}static instantiateSynced(t,i){return t?tR(t,i):null}static instantiate(t,i=null){return Np(t,i)}static destroySynced(t,i,n=!0){if(!t)return;const r=t;i=i??Ft.Current,$x(r,i.connection,n)}static destroy(t,i=!0){return ba(t,i)}static add(t,i,n){if(!(!t||!i)){if(t===i){console.warn("Can not add object to self",t);return}n||(n=Ft.Current),i.add(t),Og(t,!0),m_(t),n?oe.foreachComponent(t,r=>{II(r,n),!r.__internalDidAwakeAndStart&&n.new_script_start.includes(r)===!1&&n.new_script_start.push(r)},!0):console.warn("Missing context")}}static remove(t){var i;t&&((i=t.parent)==null||i.remove(t),Og(t,!1),m_(t),oe.foreachComponent(t,n=>{xY(n)},!0))}static invokeOnChildren(t,i,...n){this.invoke(t,i,!0,n)}static invoke(t,i,n=!1,...r){t&&this.foreachComponent(t,o=>{const a=o[i];a&&typeof a=="function"&&(a==null||a.call(o,...r))},n)}static addNewComponent(t,i,n,r=!0){return Yu(t,i,n,{callAwake:r})}static addComponent(t,i,n,r){return Yu(t,i,n,r)}static moveComponent(t,i){return Yu(t,i)}static removeComponent(t){return nR(t.gameObject,t),t}static getOrAddComponent(t,i){return nw(t,i)}static getComponent(t,i){return t===null?null:zp(t,i)}static getComponents(t,i,n=null){return t===null?n??[]:vA(t,i,n)}static findByGuid(t,i){return gA(t,i)}static findObjectOfType(t,i,n=!0){return e4(t,i??Ft.Current,n)}static findObjectsOfType(t,i){const n=[];return t4(t,n,i),n}static getComponentInChildren(t,i){return AA(t,i)}static getComponentsInChildren(t,i,n=null){return yA(t,i,n??void 0)}static getComponentInParent(t,i){return Cv(t,i)}static getComponentsInParent(t,i,n=null){return sw(t,i,n)}static getAllComponents(t){var r;return[...(r=t.userData)==null?void 0:r.components]}static*iterateComponents(t){var n;const i=(n=t==null?void 0:t.userData)==null?void 0:n.components;if(i&&Array.isArray(i))for(let r=0;r<i.length;r++)yield i[r]}}var Ka;let Me=(Ka=class{constructor(e){h(this,"__context");h(this,"__name");h(this,"gameObject");h(this,"guid","invalid");h(this,"sourceId");h(this,"__didAwake",!1);h(this,"__didStart",!1);h(this,"__didEnable",!1);h(this,"__isEnabled");h(this,"__destroyed",!1);h(this,"_eventListeners",new Map);this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(e)}get isComponent(){return!0}get context(){return this.__context??Ft.Current}set context(e){this.__context=e}get scene(){return this.context.scene}get layer(){var e,t;return(t=(e=this.gameObject)==null?void 0:e.userData)==null?void 0:t.layer}get name(){var e,t;return(e=this.gameObject)!=null&&e.name?this.gameObject.name:(t=this.gameObject)==null?void 0:t.userData.name}set name(e){this.gameObject?(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.name=e,this.__name=e):this.__name=e}get tag(){var e;return(e=this.gameObject)==null?void 0:e.userData.tag}set tag(e){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.tag=e)}get static(){var e;return(e=this.gameObject)==null?void 0:e.userData.static}get hideFlags(){var e;return(e=this.gameObject)==null?void 0:e.userData.hideFlags}get activeAndEnabled(){return!(this.destroyed||this.__isEnabled===!1||!this.__isActiveInHierarchy)}get __isActive(){return this.gameObject.visible}get __isActiveInHierarchy(){if(!this.gameObject)return!1;const e=this.gameObject[cc];return e===void 0?!0:e}set __isActiveInHierarchy(e){this.gameObject&&(this.gameObject[cc]=e)}awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(e,t=Un.Update){return this.context.registerCoroutineUpdate(this,e,t)}stopCoroutine(e,t=Un.Update){this.context.unregisterCoroutineUpdate(e,t)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}__internalNewInstanceCreated(e){return this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(e),this}_internalInit(e){if(typeof e=="object")for(const t of Object.keys(e)){const i=e[t];typeof i!="function"&&(this[t]=i)}}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(e){return this.__destroyed?(At()&&console.warn("[Needle Engine Dev] Trying to enable destroyed component"),!1):this.__didAwake?this.__didEnable?(e!==!0&&(this.__isEnabled=!0),!1):(this.__didEnable=!0,this.__isEnabled=!0,this.onEnable(),!0):!1}__internalDisable(e){if(this.__didAwake){if(!this.__didEnable){e!==!0&&(this.__isEnabled=!1);return}this.__didEnable=!1,this.__isEnabled=!1,this.onDisable()}}__internalDestroy(){var e;this.__destroyed||(this.__destroyed=!0,this.__didAwake&&((e=this.onDestroy)==null||e.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this}))),Zz(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(e){if(this.__destroyed){At()&&console.warn(`[Needle Engine Dev] Trying to ${e?"enable":"disable"} destroyed component`);return}if(typeof e=="number"&&(e>=.5?e=!0:e=!1),!this.__didAwake){this.__isEnabled=e;return}e?this.__internalEnable():this.__internalDisable()}get worldPosition(){return kt(this.gameObject)}set worldPosition(e){tr(this.gameObject,e)}setWorldPosition(e,t,i){ad(this.gameObject,e,t,i)}get worldQuaternion(){return Mi(this.gameObject)}set worldQuaternion(e){Vo(this.gameObject,e)}setWorldQuaternion(e,t,i,n){yI(this.gameObject,e,t,i,n)}get worldEuler(){return bI(this.gameObject)}set worldEuler(e){xI(this.gameObject,e)}get worldRotation(){return this.gameObject.worldRotation}set worldRotation(e){this.setWorldRotation(e.x,e.y,e.z,!0)}setWorldRotation(e,t,i,n=!0){aA(this.gameObject,e,t,i,n)}get forward(){return Ka._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}get right(){return Ka._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}get up(){return Ka._up.set(0,1,0).applyQuaternion(this.worldQuaternion)}addEventListener(e,t){this._eventListeners[e]=this._eventListeners[e]||[],this._eventListeners[e].push(t)}removeEventListener(e,t){if(!this._eventListeners[e])return;const i=this._eventListeners[e].indexOf(t);i>=0&&this._eventListeners[e].splice(i,1)}dispatchEvent(e){if(!e||!this._eventListeners[e.type])return!1;const t=this._eventListeners[e.type];for(let i=0;i<t.length;i++)t[i](e);return!1}},h(Ka,"_forward",new w),h(Ka,"_right",new w),h(Ka,"_up",new w),Ka);const Eee=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:Me,Component:Me,GameObject:oe},Symbol.toStringTag,{value:"Module"})),Ru=ne("debugloading"),Dm=ne("debugloadingrendering"),eO=ne("debuglicense");class Mee{constructor(){h(this,"className");h(this,"additionalClasses")}}let Om=0,tO;function sR(s){Ru&&console.log(s.progress.loaded.toFixed(0)+"/"+s.progress.total.toFixed(0),s);const e=s.count,t=s.progress.total;t===0||t===void 0?(tO!==s.name&&(Om=0),tO=s.name,Om+=(1-Om)*.001,Ru&&$i("Loading "+s.name+" did not report total size")):Om=s.progress.loaded/t;const i=s.index/e+Om/e;return et.clamp01(i)}const Vb=class{constructor(e,t){h(this,"loadingProgress",0);h(this,"_element");h(this,"_progress",0);h(this,"_allowCustomLoadingElement",!0);h(this,"_loadingElement");h(this,"_loadingTextContainer",null);h(this,"_loadingBar",null);h(this,"_messageContainer",null);h(this,"_loadingElementOptions");h(this,"_progressLoop");this._element=e,this._loadingElementOptions=t}async onLoadingBegin(e){const t=this._element.shadowRoot||this._element;if(Ru&&console.warn("Begin Loading"),!this._loadingElement){for(let i=0;i<t.children.length;i++){const n=t.children[i];if(n.classList.contains(Vb.LoadingContainerClassName)){if(!this._allowCustomLoadingElement){Ru&&console.warn("Remove custom loading container"),t.removeChild(n);continue}this._loadingElement=this.createLoadingElement(n)}}this._loadingElement||(this._loadingElement=this.createLoadingElement())}this._progress=0,this.loadingProgress=0,this._loadingElement.style.display="flex",t.appendChild(this._loadingElement),this.smoothProgressLoop(),this.setMessage(e??"")}onLoadingUpdate(e,t){var n;if(!((n=this._loadingElement)!=null&&n.parentNode))return;let i=0;typeof e=="number"?i=e:("index"in e&&(i=sR(e)),!t&&"name"in e&&this.setMessage("loading "+e.name)),this.loadingProgress=i,t&&this.setMessage(t),this.updateDisplay()}onLoadingFinished(){Ru&&console.warn("Finished Loading"),Dm||(this.loadingProgress=1,this.onDoneLoading())}setMessage(e){this._messageContainer&&(this._messageContainer.innerText=e)}smoothProgressLoop(){if(this._progressLoop)return;let e=1/12;Dm&&(e=1/500,typeof Dm=="number"&&(e*=Dm)),this._progressLoop=setInterval(()=>{this.loadingProgress>=.95&&!Dm&&(e=.9),this._progress=et.lerp(this._progress,this.loadingProgress,e*this.loadingProgress),this.updateDisplay()},e)}onDoneLoading(){this._loadingElement&&(Ru&&console.log("Hiding loading element"),this._loadingElement.style.display="none",this._loadingElement.remove()),this._progressLoop&&clearInterval(this._progressLoop),this._progressLoop=null}updateDisplay(){const e=this._progress,t=(e*100).toFixed(0)+"%";this._loadingBar&&(this._loadingBar.style.width=e*100+"%"),this._loadingTextContainer&&(this._loadingTextContainer.textContent=t)}createLoadingElement(e){var m,A;Ru&&!e&&console.log("Creating loading element"),this._loadingElement=e||document.createElement("div");let t=this._element.getAttribute("loading-style");(!t||t==="auto")&&(window.matchMedia("(prefers-color-scheme: dark)").matches?t="dark":t="light");const i=cl();if(!e&&(this._loadingElement.style.position="absolute",this._loadingElement.style.width="100%",this._loadingElement.style.height="100%",this._loadingElement.style.left="0",this._loadingElement.style.top="0",t==="light"?this._loadingElement.style.backgroundColor="#ddd":this._loadingElement.style.backgroundColor="#222",this._loadingElement.style.display="flex",this._loadingElement.style.alignItems="center",this._loadingElement.style.justifyContent="center",this._loadingElement.style.zIndex=Number.MAX_SAFE_INTEGER.toString(),this._loadingElement.style.flexDirection="column",this._loadingElement.style.pointerEvents="none",this._loadingElement.style.color="white",this._loadingElement.style.fontFamily="Roboto, sans-serif, Arial",t==="light"?this._loadingElement.style.color="rgba(0,0,0,.6)":this._loadingElement.style.color="rgba(255,255,255,.3)",i&&this._element)){const v=this._element.getAttribute("loading-background-color");v&&(this._loadingElement.style.backgroundColor=v);const g=this._element.getAttribute("loading-text-color");g&&(this._loadingElement.style.color=g)}const n=((m=this._loadingElementOptions)==null?void 0:m.className)??Vb.LoadingContainerClassName;if(this._loadingElement.classList.add(n),(A=this._loadingElementOptions)!=null&&A.additionalClasses)for(const v of this._loadingElementOptions.additionalClasses)this._loadingElement.classList.add(v);const r=document.createElement("div");this._loadingElement.appendChild(r);const o=document.createElement("img"),a=120;o.style.width=`${a}px`,o.style.height=`${a}px`,o.style.borderRadius="80px",o.style.padding="20px",o.style.margin="-20px",o.style.marginBottom="-10px",o.style.userSelect="none",o.style.objectFit="contain",o.style.transition="transform 2s ease-out, opacity 1s ease-in-out",o.style.transform="translateY(10px)",setTimeout(()=>{o.style.transform="translateY(0px)"},1),o.src=$$;let l=!1;if(i&&this._element){const v=this._element.getAttribute("loading-logo-src");v&&(l=!0,o.src=v)}l||(o.style.cursor="pointer",o.style.pointerEvents="all",o.addEventListener("click",()=>window.open("https://needle.tools","_blank"))),r.appendChild(o);const c=document.createElement("div");c.style.cssText=`
5263
5263
  display: flex;
5264
5264
  flex-direction: column;
5265
5265
  align-items: center;