@needle-tools/engine 3.37.5-alpha → 3.37.6-alpha

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.
@@ -107,7 +107,7 @@
107
107
  #endif`,$Q=`#ifdef USE_AOMAP
108
108
  uniform sampler2D aoMap;
109
109
  uniform float aoMapIntensity;
110
- #endif`,e8=`#ifdef USE_BATCHING
110
+ #endif`,eV=`#ifdef USE_BATCHING
111
111
  attribute float batchId;
112
112
  uniform highp sampler2D batchingTexture;
113
113
  mat4 getBatchingMatrix( const in float i ) {
@@ -121,15 +121,15 @@
121
121
  vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
122
122
  return mat4( v1, v2, v3, v4 );
123
123
  }
124
- #endif`,t8=`#ifdef USE_BATCHING
124
+ #endif`,tV=`#ifdef USE_BATCHING
125
125
  mat4 batchingMatrix = getBatchingMatrix( batchId );
126
- #endif`,i8=`vec3 transformed = vec3( position );
126
+ #endif`,iV=`vec3 transformed = vec3( position );
127
127
  #ifdef USE_ALPHAHASH
128
128
  vPosition = vec3( position );
129
- #endif`,n8=`vec3 objectNormal = vec3( normal );
129
+ #endif`,nV=`vec3 objectNormal = vec3( normal );
130
130
  #ifdef USE_TANGENT
131
131
  vec3 objectTangent = vec3( tangent.xyz );
132
- #endif`,s8=`float G_BlinnPhong_Implicit( ) {
132
+ #endif`,sV=`float G_BlinnPhong_Implicit( ) {
133
133
  return 0.25;
134
134
  }
135
135
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -143,7 +143,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
143
143
  float G = G_BlinnPhong_Implicit( );
144
144
  float D = D_BlinnPhong( shininess, dotNH );
145
145
  return F * ( G * D );
146
- } // validated`,r8=`#ifdef USE_IRIDESCENCE
146
+ } // validated`,rV=`#ifdef USE_IRIDESCENCE
147
147
  const mat3 XYZ_TO_REC709 = mat3(
148
148
  3.2404542, -0.9692660, 0.0556434,
149
149
  -1.5371385, 1.8760108, -0.2040259,
@@ -206,7 +206,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
206
206
  }
207
207
  return max( I, vec3( 0.0 ) );
208
208
  }
209
- #endif`,o8=`#ifdef USE_BUMPMAP
209
+ #endif`,oV=`#ifdef USE_BUMPMAP
210
210
  uniform sampler2D bumpMap;
211
211
  uniform float bumpScale;
212
212
  vec2 dHdxy_fwd() {
@@ -227,7 +227,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
227
227
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
228
228
  return normalize( abs( fDet ) * surf_norm - vGrad );
229
229
  }
230
- #endif`,a8=`#if NUM_CLIPPING_PLANES > 0
230
+ #endif`,aV=`#if NUM_CLIPPING_PLANES > 0
231
231
  vec4 plane;
232
232
  #ifdef ALPHA_TO_COVERAGE
233
233
  float distanceToPlane, distanceGradient;
@@ -273,26 +273,26 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
273
273
  if ( clipped ) discard;
274
274
  #endif
275
275
  #endif
276
- #endif`,l8=`#if NUM_CLIPPING_PLANES > 0
276
+ #endif`,lV=`#if NUM_CLIPPING_PLANES > 0
277
277
  varying vec3 vClipPosition;
278
278
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
279
- #endif`,c8=`#if NUM_CLIPPING_PLANES > 0
279
+ #endif`,cV=`#if NUM_CLIPPING_PLANES > 0
280
280
  varying vec3 vClipPosition;
281
- #endif`,h8=`#if NUM_CLIPPING_PLANES > 0
281
+ #endif`,hV=`#if NUM_CLIPPING_PLANES > 0
282
282
  vClipPosition = - mvPosition.xyz;
283
- #endif`,u8=`#if defined( USE_COLOR_ALPHA )
283
+ #endif`,uV=`#if defined( USE_COLOR_ALPHA )
284
284
  diffuseColor *= vColor;
285
285
  #elif defined( USE_COLOR )
286
286
  diffuseColor.rgb *= vColor;
287
- #endif`,d8=`#if defined( USE_COLOR_ALPHA )
287
+ #endif`,dV=`#if defined( USE_COLOR_ALPHA )
288
288
  varying vec4 vColor;
289
289
  #elif defined( USE_COLOR )
290
290
  varying vec3 vColor;
291
- #endif`,f8=`#if defined( USE_COLOR_ALPHA )
291
+ #endif`,fV=`#if defined( USE_COLOR_ALPHA )
292
292
  varying vec4 vColor;
293
293
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
294
294
  varying vec3 vColor;
295
- #endif`,p8=`#if defined( USE_COLOR_ALPHA )
295
+ #endif`,pV=`#if defined( USE_COLOR_ALPHA )
296
296
  vColor = vec4( 1.0 );
297
297
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
298
298
  vColor = vec3( 1.0 );
@@ -302,7 +302,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
302
302
  #endif
303
303
  #ifdef USE_INSTANCING_COLOR
304
304
  vColor.xyz *= instanceColor.xyz;
305
- #endif`,m8=`#define PI 3.141592653589793
305
+ #endif`,mV=`#define PI 3.141592653589793
306
306
  #define PI2 6.283185307179586
307
307
  #define PI_HALF 1.5707963267948966
308
308
  #define RECIPROCAL_PI 0.3183098861837907
@@ -380,7 +380,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
380
380
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
381
381
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
382
382
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
383
- } // validated`,g8=`#ifdef ENVMAP_TYPE_CUBE_UV
383
+ } // validated`,gV=`#ifdef ENVMAP_TYPE_CUBE_UV
384
384
  #define cubeUV_minMipLevel 4.0
385
385
  #define cubeUV_minTileSize 16.0
386
386
  float getFace( vec3 direction ) {
@@ -473,7 +473,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
473
473
  return vec4( mix( color0, color1, mipF ), 1.0 );
474
474
  }
475
475
  }
476
- #endif`,v8=`vec3 transformedNormal = objectNormal;
476
+ #endif`,vV=`vec3 transformedNormal = objectNormal;
477
477
  #ifdef USE_TANGENT
478
478
  vec3 transformedTangent = objectTangent;
479
479
  #endif
@@ -502,18 +502,18 @@ transformedNormal = normalMatrix * transformedNormal;
502
502
  #ifdef FLIP_SIDED
503
503
  transformedTangent = - transformedTangent;
504
504
  #endif
505
- #endif`,A8=`#ifdef USE_DISPLACEMENTMAP
505
+ #endif`,AV=`#ifdef USE_DISPLACEMENTMAP
506
506
  uniform sampler2D displacementMap;
507
507
  uniform float displacementScale;
508
508
  uniform float displacementBias;
509
- #endif`,y8=`#ifdef USE_DISPLACEMENTMAP
509
+ #endif`,yV=`#ifdef USE_DISPLACEMENTMAP
510
510
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
511
- #endif`,_8=`#ifdef USE_EMISSIVEMAP
511
+ #endif`,_V=`#ifdef USE_EMISSIVEMAP
512
512
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
513
513
  totalEmissiveRadiance *= emissiveColor.rgb;
514
- #endif`,b8=`#ifdef USE_EMISSIVEMAP
514
+ #endif`,bV=`#ifdef USE_EMISSIVEMAP
515
515
  uniform sampler2D emissiveMap;
516
- #endif`,x8="gl_FragColor = linearToOutputTexel( gl_FragColor );",w8=`
516
+ #endif`,xV="gl_FragColor = linearToOutputTexel( gl_FragColor );",wV=`
517
517
  const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
518
518
  vec3( 0.8224621, 0.177538, 0.0 ),
519
519
  vec3( 0.0331941, 0.9668058, 0.0 ),
@@ -541,7 +541,7 @@ vec4 LinearToLinear( in vec4 value ) {
541
541
  }
542
542
  vec4 LinearTosRGB( in vec4 value ) {
543
543
  return sRGBTransferOETF( value );
544
- }`,S8=`#ifdef USE_ENVMAP
544
+ }`,SV=`#ifdef USE_ENVMAP
545
545
  #ifdef ENV_WORLDPOS
546
546
  vec3 cameraToFrag;
547
547
  if ( isOrthographic ) {
@@ -570,7 +570,7 @@ vec4 LinearTosRGB( in vec4 value ) {
570
570
  #elif defined( ENVMAP_BLENDING_ADD )
571
571
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
572
572
  #endif
573
- #endif`,C8=`#ifdef USE_ENVMAP
573
+ #endif`,CV=`#ifdef USE_ENVMAP
574
574
  uniform float envMapIntensity;
575
575
  uniform float flipEnvMap;
576
576
  uniform mat3 envMapRotation;
@@ -580,7 +580,7 @@ vec4 LinearTosRGB( in vec4 value ) {
580
580
  uniform sampler2D envMap;
581
581
  #endif
582
582
 
583
- #endif`,E8=`#ifdef USE_ENVMAP
583
+ #endif`,EV=`#ifdef USE_ENVMAP
584
584
  uniform float reflectivity;
585
585
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
586
586
  #define ENV_WORLDPOS
@@ -591,7 +591,7 @@ vec4 LinearTosRGB( in vec4 value ) {
591
591
  #else
592
592
  varying vec3 vReflect;
593
593
  #endif
594
- #endif`,M8=`#ifdef USE_ENVMAP
594
+ #endif`,MV=`#ifdef USE_ENVMAP
595
595
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
596
596
  #define ENV_WORLDPOS
597
597
  #endif
@@ -602,7 +602,7 @@ vec4 LinearTosRGB( in vec4 value ) {
602
602
  varying vec3 vReflect;
603
603
  uniform float refractionRatio;
604
604
  #endif
605
- #endif`,T8=`#ifdef USE_ENVMAP
605
+ #endif`,TV=`#ifdef USE_ENVMAP
606
606
  #ifdef ENV_WORLDPOS
607
607
  vWorldPosition = worldPosition.xyz;
608
608
  #else
@@ -619,18 +619,18 @@ vec4 LinearTosRGB( in vec4 value ) {
619
619
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
620
620
  #endif
621
621
  #endif
622
- #endif`,I8=`#ifdef USE_FOG
622
+ #endif`,IV=`#ifdef USE_FOG
623
623
  vFogDepth = - mvPosition.z;
624
- #endif`,R8=`#ifdef USE_FOG
624
+ #endif`,RV=`#ifdef USE_FOG
625
625
  varying float vFogDepth;
626
- #endif`,P8=`#ifdef USE_FOG
626
+ #endif`,PV=`#ifdef USE_FOG
627
627
  #ifdef FOG_EXP2
628
628
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
629
629
  #else
630
630
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
631
631
  #endif
632
632
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
633
- #endif`,B8=`#ifdef USE_FOG
633
+ #endif`,BV=`#ifdef USE_FOG
634
634
  uniform vec3 fogColor;
635
635
  varying float vFogDepth;
636
636
  #ifdef FOG_EXP2
@@ -639,7 +639,7 @@ vec4 LinearTosRGB( in vec4 value ) {
639
639
  uniform float fogNear;
640
640
  uniform float fogFar;
641
641
  #endif
642
- #endif`,D8=`#ifdef USE_GRADIENTMAP
642
+ #endif`,DV=`#ifdef USE_GRADIENTMAP
643
643
  uniform sampler2D gradientMap;
644
644
  #endif
645
645
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -651,16 +651,16 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
651
651
  vec2 fw = fwidth( coord ) * 0.5;
652
652
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
653
653
  #endif
654
- }`,O8=`#ifdef USE_LIGHTMAP
654
+ }`,OV=`#ifdef USE_LIGHTMAP
655
655
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
656
656
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
657
657
  reflectedLight.indirectDiffuse += lightMapIrradiance;
658
- #endif`,L8=`#ifdef USE_LIGHTMAP
658
+ #endif`,LV=`#ifdef USE_LIGHTMAP
659
659
  uniform sampler2D lightMap;
660
660
  uniform float lightMapIntensity;
661
- #endif`,k8=`LambertMaterial material;
661
+ #endif`,kV=`LambertMaterial material;
662
662
  material.diffuseColor = diffuseColor.rgb;
663
- material.specularStrength = specularStrength;`,F8=`varying vec3 vViewPosition;
663
+ material.specularStrength = specularStrength;`,FV=`varying vec3 vViewPosition;
664
664
  struct LambertMaterial {
665
665
  vec3 diffuseColor;
666
666
  float specularStrength;
@@ -674,7 +674,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
674
674
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
675
675
  }
676
676
  #define RE_Direct RE_Direct_Lambert
677
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,U8=`uniform bool receiveShadow;
677
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,UV=`uniform bool receiveShadow;
678
678
  uniform vec3 ambientLightColor;
679
679
  #if defined( USE_LIGHT_PROBES )
680
680
  uniform vec3 lightProbe[ 9 ];
@@ -797,7 +797,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
797
797
  vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
798
798
  return irradiance;
799
799
  }
800
- #endif`,N8=`#ifdef USE_ENVMAP
800
+ #endif`,NV=`#ifdef USE_ENVMAP
801
801
  vec3 getIBLIrradiance( const in vec3 normal ) {
802
802
  #ifdef ENVMAP_TYPE_CUBE_UV
803
803
  vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
@@ -830,8 +830,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
830
830
  #endif
831
831
  }
832
832
  #endif
833
- #endif`,z8=`ToonMaterial material;
834
- material.diffuseColor = diffuseColor.rgb;`,G8=`varying vec3 vViewPosition;
833
+ #endif`,zV=`ToonMaterial material;
834
+ material.diffuseColor = diffuseColor.rgb;`,GV=`varying vec3 vViewPosition;
835
835
  struct ToonMaterial {
836
836
  vec3 diffuseColor;
837
837
  };
@@ -843,11 +843,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
843
843
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
844
844
  }
845
845
  #define RE_Direct RE_Direct_Toon
846
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,H8=`BlinnPhongMaterial material;
846
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,HV=`BlinnPhongMaterial material;
847
847
  material.diffuseColor = diffuseColor.rgb;
848
848
  material.specularColor = specular;
849
849
  material.specularShininess = shininess;
850
- material.specularStrength = specularStrength;`,Q8=`varying vec3 vViewPosition;
850
+ material.specularStrength = specularStrength;`,QV=`varying vec3 vViewPosition;
851
851
  struct BlinnPhongMaterial {
852
852
  vec3 diffuseColor;
853
853
  vec3 specularColor;
@@ -864,7 +864,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
864
864
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
865
865
  }
866
866
  #define RE_Direct RE_Direct_BlinnPhong
867
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,V8=`PhysicalMaterial material;
867
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,VV=`PhysicalMaterial material;
868
868
  material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
869
869
  vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
870
870
  float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
@@ -947,7 +947,7 @@ material.roughness = min( material.roughness, 1.0 );
947
947
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
948
948
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
949
949
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
950
- #endif`,W8=`struct PhysicalMaterial {
950
+ #endif`,WV=`struct PhysicalMaterial {
951
951
  vec3 diffuseColor;
952
952
  float roughness;
953
953
  vec3 specularColor;
@@ -1247,7 +1247,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1247
1247
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1248
1248
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1249
1249
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1250
- }`,j8=`
1250
+ }`,jV=`
1251
1251
  vec3 geometryPosition = - vViewPosition;
1252
1252
  vec3 geometryNormal = normal;
1253
1253
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1362,7 +1362,7 @@ IncidentLight directLight;
1362
1362
  #if defined( RE_IndirectSpecular )
1363
1363
  vec3 radiance = vec3( 0.0 );
1364
1364
  vec3 clearcoatRadiance = vec3( 0.0 );
1365
- #endif`,q8=`#if defined( RE_IndirectDiffuse )
1365
+ #endif`,qV=`#if defined( RE_IndirectDiffuse )
1366
1366
  #ifdef USE_LIGHTMAP
1367
1367
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1368
1368
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1381,25 +1381,25 @@ IncidentLight directLight;
1381
1381
  #ifdef USE_CLEARCOAT
1382
1382
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1383
1383
  #endif
1384
- #endif`,X8=`#if defined( RE_IndirectDiffuse )
1384
+ #endif`,XV=`#if defined( RE_IndirectDiffuse )
1385
1385
  RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1386
1386
  #endif
1387
1387
  #if defined( RE_IndirectSpecular )
1388
1388
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1389
- #endif`,Y8=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
1389
+ #endif`,YV=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
1390
1390
  gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1391
- #endif`,J8=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
1391
+ #endif`,JV=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
1392
1392
  uniform float logDepthBufFC;
1393
1393
  varying float vFragDepth;
1394
1394
  varying float vIsPerspective;
1395
- #endif`,K8=`#ifdef USE_LOGDEPTHBUF
1395
+ #endif`,KV=`#ifdef USE_LOGDEPTHBUF
1396
1396
  #ifdef USE_LOGDEPTHBUF_EXT
1397
1397
  varying float vFragDepth;
1398
1398
  varying float vIsPerspective;
1399
1399
  #else
1400
1400
  uniform float logDepthBufFC;
1401
1401
  #endif
1402
- #endif`,Z8=`#ifdef USE_LOGDEPTHBUF
1402
+ #endif`,ZV=`#ifdef USE_LOGDEPTHBUF
1403
1403
  #ifdef USE_LOGDEPTHBUF_EXT
1404
1404
  vFragDepth = 1.0 + gl_Position.w;
1405
1405
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
@@ -1409,7 +1409,7 @@ IncidentLight directLight;
1409
1409
  gl_Position.z *= gl_Position.w;
1410
1410
  }
1411
1411
  #endif
1412
- #endif`,$8=`#ifdef USE_MAP
1412
+ #endif`,$V=`#ifdef USE_MAP
1413
1413
  #ifdef USE_MIPMAP_BIAS
1414
1414
  vec4 sampledDiffuseColor = texture2D( map, vMapUv, mipmapBias );
1415
1415
  #else
@@ -1420,13 +1420,13 @@ IncidentLight directLight;
1420
1420
 
1421
1421
  #endif
1422
1422
  diffuseColor *= sampledDiffuseColor;
1423
- #endif`,eV=`#ifdef USE_MAP
1423
+ #endif`,e8=`#ifdef USE_MAP
1424
1424
  uniform sampler2D map;
1425
1425
 
1426
1426
  #ifdef USE_MIPMAP_BIAS
1427
1427
  uniform float mipmapBias;
1428
1428
  #endif
1429
- #endif`,tV=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1429
+ #endif`,t8=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1430
1430
  #if defined( USE_POINTS_UV )
1431
1431
  vec2 uv = vUv;
1432
1432
  #else
@@ -1438,7 +1438,7 @@ IncidentLight directLight;
1438
1438
  #endif
1439
1439
  #ifdef USE_ALPHAMAP
1440
1440
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1441
- #endif`,iV=`#if defined( USE_POINTS_UV )
1441
+ #endif`,i8=`#if defined( USE_POINTS_UV )
1442
1442
  varying vec2 vUv;
1443
1443
  #else
1444
1444
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1450,19 +1450,19 @@ IncidentLight directLight;
1450
1450
  #endif
1451
1451
  #ifdef USE_ALPHAMAP
1452
1452
  uniform sampler2D alphaMap;
1453
- #endif`,nV=`float metalnessFactor = metalness;
1453
+ #endif`,n8=`float metalnessFactor = metalness;
1454
1454
  #ifdef USE_METALNESSMAP
1455
1455
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1456
1456
  metalnessFactor *= texelMetalness.b;
1457
- #endif`,sV=`#ifdef USE_METALNESSMAP
1457
+ #endif`,s8=`#ifdef USE_METALNESSMAP
1458
1458
  uniform sampler2D metalnessMap;
1459
- #endif`,rV=`#ifdef USE_INSTANCING_MORPH
1459
+ #endif`,r8=`#ifdef USE_INSTANCING_MORPH
1460
1460
  float morphTargetInfluences[MORPHTARGETS_COUNT];
1461
1461
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1462
1462
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1463
1463
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1464
1464
  }
1465
- #endif`,oV=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
1465
+ #endif`,o8=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
1466
1466
  vColor *= morphTargetBaseInfluence;
1467
1467
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1468
1468
  #if defined( USE_COLOR_ALPHA )
@@ -1471,7 +1471,7 @@ IncidentLight directLight;
1471
1471
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1472
1472
  #endif
1473
1473
  }
1474
- #endif`,aV=`#ifdef USE_MORPHNORMALS
1474
+ #endif`,a8=`#ifdef USE_MORPHNORMALS
1475
1475
  objectNormal *= morphTargetBaseInfluence;
1476
1476
  #ifdef MORPHTARGETS_TEXTURE
1477
1477
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
@@ -1483,7 +1483,7 @@ IncidentLight directLight;
1483
1483
  objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
1484
1484
  objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
1485
1485
  #endif
1486
- #endif`,lV=`#ifdef USE_MORPHTARGETS
1486
+ #endif`,l8=`#ifdef USE_MORPHTARGETS
1487
1487
  #ifndef USE_INSTANCING_MORPH
1488
1488
  uniform float morphTargetBaseInfluence;
1489
1489
  #endif
@@ -1507,7 +1507,7 @@ IncidentLight directLight;
1507
1507
  uniform float morphTargetInfluences[ 4 ];
1508
1508
  #endif
1509
1509
  #endif
1510
- #endif`,cV=`#ifdef USE_MORPHTARGETS
1510
+ #endif`,c8=`#ifdef USE_MORPHTARGETS
1511
1511
  transformed *= morphTargetBaseInfluence;
1512
1512
  #ifdef MORPHTARGETS_TEXTURE
1513
1513
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
@@ -1525,7 +1525,7 @@ IncidentLight directLight;
1525
1525
  transformed += morphTarget7 * morphTargetInfluences[ 7 ];
1526
1526
  #endif
1527
1527
  #endif
1528
- #endif`,hV=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1528
+ #endif`,h8=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1529
1529
  #ifdef FLAT_SHADED
1530
1530
  vec3 fdx = dFdx( vViewPosition );
1531
1531
  vec3 fdy = dFdy( vViewPosition );
@@ -1566,7 +1566,7 @@ IncidentLight directLight;
1566
1566
  tbn2[1] *= faceDirection;
1567
1567
  #endif
1568
1568
  #endif
1569
- vec3 nonPerturbedNormal = normal;`,uV=`#ifdef USE_NORMALMAP_OBJECTSPACE
1569
+ vec3 nonPerturbedNormal = normal;`,u8=`#ifdef USE_NORMALMAP_OBJECTSPACE
1570
1570
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1571
1571
  #ifdef FLIP_SIDED
1572
1572
  normal = - normal;
@@ -1581,25 +1581,25 @@ vec3 nonPerturbedNormal = normal;`,uV=`#ifdef USE_NORMALMAP_OBJECTSPACE
1581
1581
  normal = normalize( tbn * mapN );
1582
1582
  #elif defined( USE_BUMPMAP )
1583
1583
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1584
- #endif`,dV=`#ifndef FLAT_SHADED
1584
+ #endif`,d8=`#ifndef FLAT_SHADED
1585
1585
  varying vec3 vNormal;
1586
1586
  #ifdef USE_TANGENT
1587
1587
  varying vec3 vTangent;
1588
1588
  varying vec3 vBitangent;
1589
1589
  #endif
1590
- #endif`,fV=`#ifndef FLAT_SHADED
1590
+ #endif`,f8=`#ifndef FLAT_SHADED
1591
1591
  varying vec3 vNormal;
1592
1592
  #ifdef USE_TANGENT
1593
1593
  varying vec3 vTangent;
1594
1594
  varying vec3 vBitangent;
1595
1595
  #endif
1596
- #endif`,pV=`#ifndef FLAT_SHADED
1596
+ #endif`,p8=`#ifndef FLAT_SHADED
1597
1597
  vNormal = normalize( transformedNormal );
1598
1598
  #ifdef USE_TANGENT
1599
1599
  vTangent = normalize( transformedTangent );
1600
1600
  vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1601
1601
  #endif
1602
- #endif`,mV=`#ifdef USE_NORMALMAP
1602
+ #endif`,m8=`#ifdef USE_NORMALMAP
1603
1603
  uniform sampler2D normalMap;
1604
1604
  uniform vec2 normalScale;
1605
1605
  #endif
@@ -1621,13 +1621,13 @@ vec3 nonPerturbedNormal = normal;`,uV=`#ifdef USE_NORMALMAP_OBJECTSPACE
1621
1621
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1622
1622
  return mat3( T * scale, B * scale, N );
1623
1623
  }
1624
- #endif`,gV=`#ifdef USE_CLEARCOAT
1624
+ #endif`,g8=`#ifdef USE_CLEARCOAT
1625
1625
  vec3 clearcoatNormal = nonPerturbedNormal;
1626
- #endif`,vV=`#ifdef USE_CLEARCOAT_NORMALMAP
1626
+ #endif`,v8=`#ifdef USE_CLEARCOAT_NORMALMAP
1627
1627
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1628
1628
  clearcoatMapN.xy *= clearcoatNormalScale;
1629
1629
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1630
- #endif`,AV=`#ifdef USE_CLEARCOATMAP
1630
+ #endif`,A8=`#ifdef USE_CLEARCOATMAP
1631
1631
  uniform sampler2D clearcoatMap;
1632
1632
  #endif
1633
1633
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1636,18 +1636,18 @@ vec3 nonPerturbedNormal = normal;`,uV=`#ifdef USE_NORMALMAP_OBJECTSPACE
1636
1636
  #endif
1637
1637
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1638
1638
  uniform sampler2D clearcoatRoughnessMap;
1639
- #endif`,yV=`#ifdef USE_IRIDESCENCEMAP
1639
+ #endif`,y8=`#ifdef USE_IRIDESCENCEMAP
1640
1640
  uniform sampler2D iridescenceMap;
1641
1641
  #endif
1642
1642
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1643
1643
  uniform sampler2D iridescenceThicknessMap;
1644
- #endif`,_V=`#ifdef OPAQUE
1644
+ #endif`,_8=`#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 );`,bV=`vec3 packNormalToRGB( const in vec3 normal ) {
1650
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,b8=`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
- }`,xV=`#ifdef PREMULTIPLIED_ALPHA
1691
+ }`,x8=`#ifdef PREMULTIPLIED_ALPHA
1692
1692
  gl_FragColor.rgb *= gl_FragColor.a;
1693
- #endif`,wV=`vec4 mvPosition = vec4( transformed, 1.0 );
1693
+ #endif`,w8=`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;`,SV=`#ifdef DITHERING
1701
+ gl_Position = projectionMatrix * mvPosition;`,S8=`#ifdef DITHERING
1702
1702
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1703
- #endif`,CV=`#ifdef DITHERING
1703
+ #endif`,C8=`#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`,EV=`float roughnessFactor = roughness;
1710
+ #endif`,E8=`float roughnessFactor = roughness;
1711
1711
  #ifdef USE_ROUGHNESSMAP
1712
1712
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1713
1713
  roughnessFactor *= texelRoughness.g;
1714
- #endif`,MV=`#ifdef USE_ROUGHNESSMAP
1714
+ #endif`,M8=`#ifdef USE_ROUGHNESSMAP
1715
1715
  uniform sampler2D roughnessMap;
1716
- #endif`,TV=`#if NUM_SPOT_LIGHT_COORDS > 0
1716
+ #endif`,T8=`#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;`,SV=`#ifdef DITHERING
1890
1890
  return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1891
1891
  #endif
1892
1892
  }
1893
- #endif`,IV=`#if NUM_SPOT_LIGHT_COORDS > 0
1893
+ #endif`,I8=`#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;`,SV=`#ifdef DITHERING
1928
1928
  };
1929
1929
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1930
1930
  #endif
1931
- #endif`,RV=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1931
+ #endif`,R8=`#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;`,SV=`#ifdef DITHERING
1960
1960
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1961
1961
  }
1962
1962
  #pragma unroll_loop_end
1963
- #endif`,PV=`float getShadowMask() {
1963
+ #endif`,P8=`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;`,SV=`#ifdef DITHERING
1992
1992
  #endif
1993
1993
  #endif
1994
1994
  return shadow;
1995
- }`,BV=`#ifdef USE_SKINNING
1995
+ }`,B8=`#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`,DV=`#ifdef USE_SKINNING
2000
+ #endif`,D8=`#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;`,SV=`#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`,OV=`#ifdef USE_SKINNING
2015
+ #endif`,O8=`#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;`,SV=`#ifdef DITHERING
2020
2020
  skinned += boneMatZ * skinVertex * skinWeight.z;
2021
2021
  skinned += boneMatW * skinVertex * skinWeight.w;
2022
2022
  transformed = ( bindMatrixInverse * skinned ).xyz;
2023
- #endif`,LV=`#ifdef USE_SKINNING
2023
+ #endif`,L8=`#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;`,SV=`#ifdef DITHERING
2031
2031
  #ifdef USE_TANGENT
2032
2032
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2033
2033
  #endif
2034
- #endif`,kV=`float specularStrength;
2034
+ #endif`,k8=`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`,FV=`#ifdef USE_SPECULARMAP
2040
+ #endif`,F8=`#ifdef USE_SPECULARMAP
2041
2041
  uniform sampler2D specularMap;
2042
- #endif`,UV=`#if defined( TONE_MAPPING )
2042
+ #endif`,U8=`#if defined( TONE_MAPPING )
2043
2043
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2044
- #endif`,NV=`#ifndef saturate
2044
+ #endif`,N8=`#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; }`,zV=`#ifdef USE_TRANSMISSION
2141
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,z8=`#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; }`,zV=`#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`,GV=`#ifdef USE_TRANSMISSION
2162
+ #endif`,G8=`#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; }`,zV=`#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`,HV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2268
+ #endif`,H8=`#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; }`,zV=`#ifdef USE_TRANSMISS
2335
2335
  #ifdef USE_THICKNESSMAP
2336
2336
  uniform mat3 thicknessMapTransform;
2337
2337
  varying vec2 vThicknessMapUv;
2338
- #endif`,QV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2338
+ #endif`,Q8=`#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; }`,zV=`#ifdef USE_TRANSMISS
2429
2429
  #ifdef USE_THICKNESSMAP
2430
2430
  uniform mat3 thicknessMapTransform;
2431
2431
  varying vec2 vThicknessMapUv;
2432
- #endif`,VV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2432
+ #endif`,V8=`#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; }`,zV=`#ifdef USE_TRANSMISS
2500
2500
  #endif
2501
2501
  #ifdef USE_THICKNESSMAP
2502
2502
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2503
- #endif`,WV=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2503
+ #endif`,W8=`#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; }`,zV=`#ifdef USE_TRANSMISS
2509
2509
  worldPosition = instanceMatrix * worldPosition;
2510
2510
  #endif
2511
2511
  worldPosition = modelMatrix * worldPosition;
2512
- #endif`;const jV=`varying vec2 vUv;
2512
+ #endif`;const j8=`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
- }`,qV=`uniform sampler2D t2D;
2517
+ }`,q8=`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
- }`,XV=`varying vec3 vWorldDirection;
2529
+ }`,X8=`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
- }`,YV=`#ifdef ENVMAP_TYPE_CUBE
2536
+ }`,Y8=`#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
- }`,JV=`varying vec3 vWorldDirection;
2559
+ }`,J8=`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
- }`,KV=`uniform samplerCube tCube;
2566
+ }`,K8=`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
- }`,ZV=`#include <common>
2576
+ }`,Z8=`#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
- }`,$V=`#if DEPTH_PACKING == 3200
2603
+ }`,$8=`#if DEPTH_PACKING == 3200
2604
2604
  uniform float opacity;
2605
2605
  #endif
2606
2606
  #include <common>
@@ -3556,7 +3556,7 @@ void main() {
3556
3556
  #include <tonemapping_fragment>
3557
3557
  #include <colorspace_fragment>
3558
3558
  #include <fog_fragment>
3559
- }`,Ht={alphahash_fragment:jQ,alphahash_pars_fragment:qQ,alphamap_fragment:XQ,alphamap_pars_fragment:YQ,alphatest_fragment:JQ,alphatest_pars_fragment:KQ,aomap_fragment:ZQ,aomap_pars_fragment:$Q,batching_pars_vertex:e8,batching_vertex:t8,begin_vertex:i8,beginnormal_vertex:n8,bsdfs:s8,iridescence_fragment:r8,bumpmap_pars_fragment:o8,clipping_planes_fragment:a8,clipping_planes_pars_fragment:l8,clipping_planes_pars_vertex:c8,clipping_planes_vertex:h8,color_fragment:u8,color_pars_fragment:d8,color_pars_vertex:f8,color_vertex:p8,common:m8,cube_uv_reflection_fragment:g8,defaultnormal_vertex:v8,displacementmap_pars_vertex:A8,displacementmap_vertex:y8,emissivemap_fragment:_8,emissivemap_pars_fragment:b8,colorspace_fragment:x8,colorspace_pars_fragment:w8,envmap_fragment:S8,envmap_common_pars_fragment:C8,envmap_pars_fragment:E8,envmap_pars_vertex:M8,envmap_physical_pars_fragment:N8,envmap_vertex:T8,fog_vertex:I8,fog_pars_vertex:R8,fog_fragment:P8,fog_pars_fragment:B8,gradientmap_pars_fragment:D8,lightmap_fragment:O8,lightmap_pars_fragment:L8,lights_lambert_fragment:k8,lights_lambert_pars_fragment:F8,lights_pars_begin:U8,lights_toon_fragment:z8,lights_toon_pars_fragment:G8,lights_phong_fragment:H8,lights_phong_pars_fragment:Q8,lights_physical_fragment:V8,lights_physical_pars_fragment:W8,lights_fragment_begin:j8,lights_fragment_maps:q8,lights_fragment_end:X8,logdepthbuf_fragment:Y8,logdepthbuf_pars_fragment:J8,logdepthbuf_pars_vertex:K8,logdepthbuf_vertex:Z8,map_fragment:$8,map_pars_fragment:eV,map_particle_fragment:tV,map_particle_pars_fragment:iV,metalnessmap_fragment:nV,metalnessmap_pars_fragment:sV,morphinstance_vertex:rV,morphcolor_vertex:oV,morphnormal_vertex:aV,morphtarget_pars_vertex:lV,morphtarget_vertex:cV,normal_fragment_begin:hV,normal_fragment_maps:uV,normal_pars_fragment:dV,normal_pars_vertex:fV,normal_vertex:pV,normalmap_pars_fragment:mV,clearcoat_normal_fragment_begin:gV,clearcoat_normal_fragment_maps:vV,clearcoat_pars_fragment:AV,iridescence_pars_fragment:yV,opaque_fragment:_V,packing:bV,premultiplied_alpha_fragment:xV,project_vertex:wV,dithering_fragment:SV,dithering_pars_fragment:CV,roughnessmap_fragment:EV,roughnessmap_pars_fragment:MV,shadowmap_pars_fragment:TV,shadowmap_pars_vertex:IV,shadowmap_vertex:RV,shadowmask_pars_fragment:PV,skinbase_vertex:BV,skinning_pars_vertex:DV,skinning_vertex:OV,skinnormal_vertex:LV,specularmap_fragment:kV,specularmap_pars_fragment:FV,tonemapping_fragment:UV,tonemapping_pars_fragment:NV,transmission_fragment:zV,transmission_pars_fragment:GV,uv_pars_fragment:HV,uv_pars_vertex:QV,uv_vertex:VV,worldpos_vertex:WV,background_vert:jV,background_frag:qV,backgroundCube_vert:XV,backgroundCube_frag:YV,cube_vert:JV,cube_frag:KV,depth_vert:ZV,depth_frag:$V,distanceRGBA_vert:e5,distanceRGBA_frag:t5,equirect_vert:i5,equirect_frag:n5,linedashed_vert:s5,linedashed_frag:r5,meshbasic_vert:o5,meshbasic_frag:a5,meshlambert_vert:l5,meshlambert_frag:c5,meshmatcap_vert:h5,meshmatcap_frag:u5,meshnormal_vert:d5,meshnormal_frag:f5,meshphong_vert:p5,meshphong_frag:m5,meshphysical_vert:g5,meshphysical_frag:v5,meshtoon_vert:A5,meshtoon_frag:y5,points_vert:_5,points_frag:b5,shadow_vert:x5,shadow_frag:w5,sprite_vert:S5,sprite_frag:C5},Ue={common:{diffuse:{value:new xe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ut},alphaMap:{value:null},alphaMapTransform:{value:new Ut},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ut}},envmap:{envMap:{value:null},envMapRotation:{value:new Ut},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ut}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ut}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ut},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ut},normalScale:{value:new te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ut},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ut}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ut}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ut}},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 Ut},alphaTest:{value:0},uvTransform:{value:new Ut}},sprite:{diffuse:{value:new xe(16777215)},opacity:{value:1},center:{value:new te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ut},alphaMap:{value:null},alphaMapTransform:{value:new Ut},alphaTest:{value:0}}},Rs={basic:{uniforms:yr([Ue.common,Ue.specularmap,Ue.envmap,Ue.aomap,Ue.lightmap,Ue.fog]),vertexShader:Ht.meshbasic_vert,fragmentShader:Ht.meshbasic_frag},lambert:{uniforms:yr([Ue.common,Ue.specularmap,Ue.envmap,Ue.aomap,Ue.lightmap,Ue.emissivemap,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.fog,Ue.lights,{emissive:{value:new xe(0)}}]),vertexShader:Ht.meshlambert_vert,fragmentShader:Ht.meshlambert_frag},phong:{uniforms:yr([Ue.common,Ue.specularmap,Ue.envmap,Ue.aomap,Ue.lightmap,Ue.emissivemap,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.fog,Ue.lights,{emissive:{value:new xe(0)},specular:{value:new xe(1118481)},shininess:{value:30}}]),vertexShader:Ht.meshphong_vert,fragmentShader:Ht.meshphong_frag},standard:{uniforms:yr([Ue.common,Ue.envmap,Ue.aomap,Ue.lightmap,Ue.emissivemap,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.roughnessmap,Ue.metalnessmap,Ue.fog,Ue.lights,{emissive:{value:new xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ht.meshphysical_vert,fragmentShader:Ht.meshphysical_frag},toon:{uniforms:yr([Ue.common,Ue.aomap,Ue.lightmap,Ue.emissivemap,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.gradientmap,Ue.fog,Ue.lights,{emissive:{value:new xe(0)}}]),vertexShader:Ht.meshtoon_vert,fragmentShader:Ht.meshtoon_frag},matcap:{uniforms:yr([Ue.common,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.fog,{matcap:{value:null}}]),vertexShader:Ht.meshmatcap_vert,fragmentShader:Ht.meshmatcap_frag},points:{uniforms:yr([Ue.points,Ue.fog]),vertexShader:Ht.points_vert,fragmentShader:Ht.points_frag},dashed:{uniforms:yr([Ue.common,Ue.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ht.linedashed_vert,fragmentShader:Ht.linedashed_frag},depth:{uniforms:yr([Ue.common,Ue.displacementmap]),vertexShader:Ht.depth_vert,fragmentShader:Ht.depth_frag},normal:{uniforms:yr([Ue.common,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,{opacity:{value:1}}]),vertexShader:Ht.meshnormal_vert,fragmentShader:Ht.meshnormal_frag},sprite:{uniforms:yr([Ue.sprite,Ue.fog]),vertexShader:Ht.sprite_vert,fragmentShader:Ht.sprite_frag},background:{uniforms:{uvTransform:{value:new Ut},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ht.background_vert,fragmentShader:Ht.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ut}},vertexShader:Ht.backgroundCube_vert,fragmentShader:Ht.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ht.cube_vert,fragmentShader:Ht.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ht.equirect_vert,fragmentShader:Ht.equirect_frag},distanceRGBA:{uniforms:yr([Ue.common,Ue.displacementmap,{referencePosition:{value:new w},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ht.distanceRGBA_vert,fragmentShader:Ht.distanceRGBA_frag},shadow:{uniforms:yr([Ue.lights,Ue.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:Ht.shadow_vert,fragmentShader:Ht.shadow_frag}};Rs.physical={uniforms:yr([Rs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ut},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ut},clearcoatNormalScale:{value:new te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ut},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ut},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ut},sheen:{value:0},sheenColor:{value:new xe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ut},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ut},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ut},transmissionSamplerSize:{value:new te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ut},attenuationDistance:{value:0},attenuationColor:{value:new xe(0)},specularColor:{value:new xe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ut},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ut},anisotropyVector:{value:new te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ut}}]),vertexShader:Ht.meshphysical_vert,fragmentShader:Ht.meshphysical_frag};const Ky={r:0,b:0,g:0},hu=new Wi,E5=new we;function M5(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(g,v){let _=!1,y=v.isScene===!0?v.background:null;y&&y.isTexture&&(y=(v.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===Wp)?(u===void 0&&(u=new de(new Fi(1,1,1),new Bt({name:"BackgroundCubeMaterial",uniforms:Pp(Rs.backgroundCube.uniforms),vertexShader:Rs.backgroundCube.vertexShader,fragmentShader:Rs.backgroundCube.fragmentShader,side:wn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(M,E,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(u)),hu.copy(v.backgroundRotation),hu.x*=-1,hu.y*=-1,hu.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(hu.y*=-1,hu.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=v.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(E5.makeRotationFromEuler(hu)),u.material.toneMapped=gi.getTransfer(y.colorSpace)!==ki,(d!==y||f!==y.version||p!==s.toneMapping)&&(u.material.needsUpdate=!0,d=y,f=y.version,p=s.toneMapping),u.layers.enableAll(),g.unshift(u,u.geometry,u.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new de(new Gn(2,2),new Bt({name:"BackgroundMaterial",uniforms:Pp(Rs.background.uniforms),vertexShader:Rs.background.vertexShader,fragmentShader:Rs.background.fragmentShader,side:Os,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=v.backgroundIntensity,c.material.toneMapped=gi.getTransfer(y.colorSpace)!==ki,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(),g.unshift(c,c.geometry,c.material,0,0,null))}function A(g,v){g.getRGB(Ky,GF(s)),i.buffers.color.setClear(Ky.r,Ky.g,Ky.b,v,o)}return{getClearColor:function(){return a},setClearColor:function(g,v=1){a.set(g),l=v,A(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(g){l=g,A(a,l)},render:m}}function T5(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=g(null);let c=l,u=!1;function d(D,V,L,k,G){let Y=!1;if(o){const K=A(k,L,V);c!==K&&(c=K,p(c.object)),Y=v(D,k,L,G),Y&&_(D,k,L,G)}else{const K=V.wireframe===!0;(c.geometry!==k.id||c.program!==L.id||c.wireframe!==K)&&(c.geometry=k.id,c.program=L.id,c.wireframe=K,Y=!0)}G!==null&&t.update(G,s.ELEMENT_ARRAY_BUFFER),(Y||u)&&(u=!1,C(D,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(D){return i.isWebGL2?s.bindVertexArray(D):r.bindVertexArrayOES(D)}function m(D){return i.isWebGL2?s.deleteVertexArray(D):r.deleteVertexArrayOES(D)}function A(D,V,L){const k=L.wireframe===!0;let G=a[D.id];G===void 0&&(G={},a[D.id]=G);let Y=G[V.id];Y===void 0&&(Y={},G[V.id]=Y);let K=Y[k];return K===void 0&&(K=g(f()),Y[k]=K),K}function g(D){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:D,attributes:{},index:null}}function v(D,V,L,k){const G=c.attributes,Y=V.attributes;let K=0;const re=L.getAttributes();for(const ce in re)if(re[ce].location>=0){const ie=G[ce];let ge=Y[ce];if(ge===void 0&&(ce==="instanceMatrix"&&D.instanceMatrix&&(ge=D.instanceMatrix),ce==="instanceColor"&&D.instanceColor&&(ge=D.instanceColor)),ie===void 0||ie.attribute!==ge||ge&&ie.data!==ge.data)return!0;K++}return c.attributesNum!==K||c.index!==k}function _(D,V,L,k){const G={},Y=V.attributes;let K=0;const re=L.getAttributes();for(const ce in re)if(re[ce].location>=0){let ie=Y[ce];ie===void 0&&(ce==="instanceMatrix"&&D.instanceMatrix&&(ie=D.instanceMatrix),ce==="instanceColor"&&D.instanceColor&&(ie=D.instanceColor));const ge={};ge.attribute=ie,ie&&ie.data&&(ge.data=ie.data),G[ce]=ge,K++}c.attributes=G,c.attributesNum=K,c.index=k}function y(){const D=c.newAttributes;for(let V=0,L=D.length;V<L;V++)D[V]=0}function b(D){M(D,0)}function M(D,V){const L=c.newAttributes,k=c.enabledAttributes,G=c.attributeDivisors;L[D]=1,k[D]===0&&(s.enableVertexAttribArray(D),k[D]=1),G[D]!==V&&((i.isWebGL2?s:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,V),G[D]=V)}function E(){const D=c.newAttributes,V=c.enabledAttributes;for(let L=0,k=V.length;L<k;L++)V[L]!==D[L]&&(s.disableVertexAttribArray(L),V[L]=0)}function T(D,V,L,k,G,Y,K){K===!0?s.vertexAttribIPointer(D,V,L,G,Y):s.vertexAttribPointer(D,V,L,k,G,Y)}function C(D,V,L,k){if(i.isWebGL2===!1&&(D.isInstancedMesh||k.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;y();const G=k.attributes,Y=L.getAttributes(),K=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"&&D.instanceMatrix&&(Re=D.instanceMatrix),re==="instanceColor"&&D.instanceColor&&(Re=D.instanceColor)),Re!==void 0){const ie=Re.normalized,ge=Re.itemSize,be=t.get(Re);if(be===void 0)continue;const Ve=be.buffer,We=be.type,Ge=be.bytesPerElement,ft=i.isWebGL2===!0&&(We===s.INT||We===s.UNSIGNED_INT||Re.gpuType===fT);if(Re.isInterleavedBufferAttribute){const it=Re.data,j=it.stride,Ne=Re.offset;if(it.isInstancedInterleavedBuffer){for(let ye=0;ye<ce.locationSize;ye++)M(ce.location+ye,it.meshPerAttribute);D.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=it.meshPerAttribute*it.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,ge/ce.locationSize,We,ie,j*Ge,(Ne+ge/ce.locationSize*ye)*Ge,ft)}else{if(Re.isInstancedBufferAttribute){for(let it=0;it<ce.locationSize;it++)M(ce.location+it,Re.meshPerAttribute);D.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=Re.meshPerAttribute*Re.count)}else for(let it=0;it<ce.locationSize;it++)b(ce.location+it);s.bindBuffer(s.ARRAY_BUFFER,Ve);for(let it=0;it<ce.locationSize;it++)T(ce.location+it,ge/ce.locationSize,We,ie,ge*Ge,ge/ce.locationSize*it*Ge,ft)}}else if(K!==void 0){const ie=K[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)}}}}E()}function P(){H();for(const D in a){const V=a[D];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[D]}}function S(D){if(a[D.id]===void 0)return;const V=a[D.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[D.id]}function I(D){for(const V in a){const L=a[V];if(L[D.id]===void 0)continue;const k=L[D.id];for(const G in k)m(k[G].object),delete k[G];delete L[D.id]}}function H(){U(),u=!0,c!==l&&(c=l,p(c.object))}function U(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:d,reset:H,resetDefaultState:U,dispose:P,releaseStatesOfGeometry:S,releaseStatesOfProgram:I,initAttributes:y,enableAttribute:b,disableUnusedAttributes:E}}function I5(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 R5(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),g=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),v=s.getParameter(s.MAX_VARYING_VECTORS),_=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),y=f>0,b=o||e.has("OES_texture_float"),M=y&&b,E=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:g,maxVaryings:v,maxFragmentUniforms:_,vertexTextures:y,floatFragmentTextures:b,floatVertexTextures:M,maxSamples:E}}function P5(s){const e=this;let t=null,i=0,n=!1,r=!1;const o=new xr,a=new Ut,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,g=d.clipShadows,v=s.get(d);if(!n||m===null||m.length===0||r&&!g)r?u(null):c();else{const _=r?0:i,y=_*4;let b=v.clippingState||null;l.value=b,b=u(m,f,y,p);for(let M=0;M!==y;++M)b[M]=t[M];v.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 g=null;if(A!==0){if(g=l.value,m!==!0||g===null){const v=p+A*4,_=f.matrixWorldInverse;a.getNormalMatrix(_),(g===null||g.length<v)&&(g=new Float32Array(v));for(let y=0,b=p;y!==A;++y,b+=4)o.copy(d[y]).applyMatrix4(_,a),o.normal.toArray(g,b),g[b+3]=o.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=A,e.numIntersection=0,g}}function B5(s){let e=new WeakMap;function t(o,a){return a===Jo?o.mapping=_c:a===Tp&&(o.mapping=Lh),o}function i(o){if(o&&o.isTexture){const a=o.mapping;if(a===Jo||a===Tp)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 TT(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 Cc extends fA{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 ep=4,vB=[.125,.215,.35,.446,.526,.582],ku=20,NS=new Cc,AB=new xe;let zS=null,GS=0,HS=0;const Du=(1+Math.sqrt(5))/2,xf=1/Du,yB=[new w(1,1,1),new w(-1,1,1),new w(1,1,-1),new w(-1,1,-1),new w(0,Du,xf),new w(0,Du,-xf),new w(xf,0,Du),new w(-xf,0,Du),new w(Du,xf,0),new w(-Du,xf,0)];class _1{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){zS=this._renderer.getRenderTarget(),GS=this._renderer.getActiveCubeFace(),HS=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=wB(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=xB(),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(zS,GS,HS),e.scissorTest=!1,Zy(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===_c||e.mapping===Lh?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),zS=this._renderer.getRenderTarget(),GS=this._renderer.getActiveCubeFace(),HS=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:It,minFilter:It,generateMipmaps:!1,type:un,format:vi,colorSpace:yi,depthBuffer:!1},n=bB(e,t,i),{_lodMax:r}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=_B(r),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=bB(e,t,i);const{_lodMax:o}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=_B(o)),this._blurMaterial=D5(o,e,t)}return n}_compileMaterial(e){const t=new de(this._lodPlanes[0],e);this._renderer.compile(t,NS)}_sceneToCubeUV(e,t,i,n){const a=new Gt(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(AB),u.toneMapping=Wr,u.autoClear=!1;const p=new ai({name:"PMREM.Background",side:wn,depthWrite:!1,depthTest:!1}),m=new de(new Fi,p);let A=!1;const g=e.background;g?g.isColor&&(p.color.copy(g),e.background=null,A=!0):(p.color.copy(AB),A=!0);for(let v=0;v<6;v++){const _=v%3;_===0?(a.up.set(0,l[v],0),a.lookAt(c[v],0,0)):_===1?(a.up.set(0,0,l[v]),a.lookAt(0,c[v],0)):(a.up.set(0,l[v],0),a.lookAt(0,0,c[v]));const y=this._cubeSize;Zy(n,_*y,v>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=g}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===_c||e.mapping===Lh;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=wB()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=xB());const r=n?this._cubemapMaterial:this._equirectMaterial,o=new de(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const l=this._cubeSize;Zy(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,NS)}_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=yB[(n-1)%yB.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 de(this._lodPlanes[n],c),f=c.uniforms,p=this._sizeLods[i]-1,m=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*ku-1),A=r/m,g=isFinite(r)?1+Math.floor(u*A):ku;g>ku&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${ku}`);const v=[];let _=0;for(let T=0;T<ku;++T){const C=T/A,P=Math.exp(-C*C/2);v.push(P),T===0?_+=P:T<g&&(_+=2*P)}for(let T=0;T<v.length;T++)v[T]=v[T]/_;f.envMap.value=e.texture,f.samples.value=g,f.weights.value=v,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],M=3*b*(n>y-ep?n-y+ep:0),E=4*(this._cubeSize-b);Zy(t,M,E,3*b,2*b),l.setRenderTarget(t),l.render(d,NS)}}function _B(s){const e=[],t=[],i=[];let n=s;const r=s-ep+1+vB.length;for(let o=0;o<r;o++){const a=Math.pow(2,n);t.push(a);let l=1/a;o>s-ep?l=vB[o-s+ep-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,g=2,v=1,_=new Float32Array(A*m*p),y=new Float32Array(g*m*p),b=new Float32Array(v*m*p);for(let E=0;E<p;E++){const T=E%3*2/3-1,C=E>2?0:-1,P=[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(P,A*m*E),y.set(f,g*m*E);const S=[E,E,E,E,E,E];b.set(S,v*m*E)}const M=new At;M.setAttribute("position",new tt(_,A)),M.setAttribute("uv",new tt(y,g)),M.setAttribute("faceIndex",new tt(b,v)),e.push(M),n>ep&&n--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function bB(s,e,t){const i=new Yt(s,e,t);return i.texture.mapping=Wp,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Zy(s,e,t,i,n){s.viewport.set(e,t,i,n),s.scissor.set(e,t,i,n)}function D5(s,e,t){const i=new Float32Array(ku),n=new w(0,1,0);return new Bt({name:"SphericalGaussianBlur",defines:{n:ku,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:IT(),fragmentShader:`
3559
+ }`,Ht={alphahash_fragment:jQ,alphahash_pars_fragment:qQ,alphamap_fragment:XQ,alphamap_pars_fragment:YQ,alphatest_fragment:JQ,alphatest_pars_fragment:KQ,aomap_fragment:ZQ,aomap_pars_fragment:$Q,batching_pars_vertex:eV,batching_vertex:tV,begin_vertex:iV,beginnormal_vertex:nV,bsdfs:sV,iridescence_fragment:rV,bumpmap_pars_fragment:oV,clipping_planes_fragment:aV,clipping_planes_pars_fragment:lV,clipping_planes_pars_vertex:cV,clipping_planes_vertex:hV,color_fragment:uV,color_pars_fragment:dV,color_pars_vertex:fV,color_vertex:pV,common:mV,cube_uv_reflection_fragment:gV,defaultnormal_vertex:vV,displacementmap_pars_vertex:AV,displacementmap_vertex:yV,emissivemap_fragment:_V,emissivemap_pars_fragment:bV,colorspace_fragment:xV,colorspace_pars_fragment:wV,envmap_fragment:SV,envmap_common_pars_fragment:CV,envmap_pars_fragment:EV,envmap_pars_vertex:MV,envmap_physical_pars_fragment:NV,envmap_vertex:TV,fog_vertex:IV,fog_pars_vertex:RV,fog_fragment:PV,fog_pars_fragment:BV,gradientmap_pars_fragment:DV,lightmap_fragment:OV,lightmap_pars_fragment:LV,lights_lambert_fragment:kV,lights_lambert_pars_fragment:FV,lights_pars_begin:UV,lights_toon_fragment:zV,lights_toon_pars_fragment:GV,lights_phong_fragment:HV,lights_phong_pars_fragment:QV,lights_physical_fragment:VV,lights_physical_pars_fragment:WV,lights_fragment_begin:jV,lights_fragment_maps:qV,lights_fragment_end:XV,logdepthbuf_fragment:YV,logdepthbuf_pars_fragment:JV,logdepthbuf_pars_vertex:KV,logdepthbuf_vertex:ZV,map_fragment:$V,map_pars_fragment:e8,map_particle_fragment:t8,map_particle_pars_fragment:i8,metalnessmap_fragment:n8,metalnessmap_pars_fragment:s8,morphinstance_vertex:r8,morphcolor_vertex:o8,morphnormal_vertex:a8,morphtarget_pars_vertex:l8,morphtarget_vertex:c8,normal_fragment_begin:h8,normal_fragment_maps:u8,normal_pars_fragment:d8,normal_pars_vertex:f8,normal_vertex:p8,normalmap_pars_fragment:m8,clearcoat_normal_fragment_begin:g8,clearcoat_normal_fragment_maps:v8,clearcoat_pars_fragment:A8,iridescence_pars_fragment:y8,opaque_fragment:_8,packing:b8,premultiplied_alpha_fragment:x8,project_vertex:w8,dithering_fragment:S8,dithering_pars_fragment:C8,roughnessmap_fragment:E8,roughnessmap_pars_fragment:M8,shadowmap_pars_fragment:T8,shadowmap_pars_vertex:I8,shadowmap_vertex:R8,shadowmask_pars_fragment:P8,skinbase_vertex:B8,skinning_pars_vertex:D8,skinning_vertex:O8,skinnormal_vertex:L8,specularmap_fragment:k8,specularmap_pars_fragment:F8,tonemapping_fragment:U8,tonemapping_pars_fragment:N8,transmission_fragment:z8,transmission_pars_fragment:G8,uv_pars_fragment:H8,uv_pars_vertex:Q8,uv_vertex:V8,worldpos_vertex:W8,background_vert:j8,background_frag:q8,backgroundCube_vert:X8,backgroundCube_frag:Y8,cube_vert:J8,cube_frag:K8,depth_vert:Z8,depth_frag:$8,distanceRGBA_vert:e5,distanceRGBA_frag:t5,equirect_vert:i5,equirect_frag:n5,linedashed_vert:s5,linedashed_frag:r5,meshbasic_vert:o5,meshbasic_frag:a5,meshlambert_vert:l5,meshlambert_frag:c5,meshmatcap_vert:h5,meshmatcap_frag:u5,meshnormal_vert:d5,meshnormal_frag:f5,meshphong_vert:p5,meshphong_frag:m5,meshphysical_vert:g5,meshphysical_frag:v5,meshtoon_vert:A5,meshtoon_frag:y5,points_vert:_5,points_frag:b5,shadow_vert:x5,shadow_frag:w5,sprite_vert:S5,sprite_frag:C5},Ue={common:{diffuse:{value:new xe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ut},alphaMap:{value:null},alphaMapTransform:{value:new Ut},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ut}},envmap:{envMap:{value:null},envMapRotation:{value:new Ut},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ut}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ut}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ut},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ut},normalScale:{value:new te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ut},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ut}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ut}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ut}},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 Ut},alphaTest:{value:0},uvTransform:{value:new Ut}},sprite:{diffuse:{value:new xe(16777215)},opacity:{value:1},center:{value:new te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ut},alphaMap:{value:null},alphaMapTransform:{value:new Ut},alphaTest:{value:0}}},Rs={basic:{uniforms:yr([Ue.common,Ue.specularmap,Ue.envmap,Ue.aomap,Ue.lightmap,Ue.fog]),vertexShader:Ht.meshbasic_vert,fragmentShader:Ht.meshbasic_frag},lambert:{uniforms:yr([Ue.common,Ue.specularmap,Ue.envmap,Ue.aomap,Ue.lightmap,Ue.emissivemap,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.fog,Ue.lights,{emissive:{value:new xe(0)}}]),vertexShader:Ht.meshlambert_vert,fragmentShader:Ht.meshlambert_frag},phong:{uniforms:yr([Ue.common,Ue.specularmap,Ue.envmap,Ue.aomap,Ue.lightmap,Ue.emissivemap,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.fog,Ue.lights,{emissive:{value:new xe(0)},specular:{value:new xe(1118481)},shininess:{value:30}}]),vertexShader:Ht.meshphong_vert,fragmentShader:Ht.meshphong_frag},standard:{uniforms:yr([Ue.common,Ue.envmap,Ue.aomap,Ue.lightmap,Ue.emissivemap,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.roughnessmap,Ue.metalnessmap,Ue.fog,Ue.lights,{emissive:{value:new xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ht.meshphysical_vert,fragmentShader:Ht.meshphysical_frag},toon:{uniforms:yr([Ue.common,Ue.aomap,Ue.lightmap,Ue.emissivemap,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.gradientmap,Ue.fog,Ue.lights,{emissive:{value:new xe(0)}}]),vertexShader:Ht.meshtoon_vert,fragmentShader:Ht.meshtoon_frag},matcap:{uniforms:yr([Ue.common,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.fog,{matcap:{value:null}}]),vertexShader:Ht.meshmatcap_vert,fragmentShader:Ht.meshmatcap_frag},points:{uniforms:yr([Ue.points,Ue.fog]),vertexShader:Ht.points_vert,fragmentShader:Ht.points_frag},dashed:{uniforms:yr([Ue.common,Ue.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ht.linedashed_vert,fragmentShader:Ht.linedashed_frag},depth:{uniforms:yr([Ue.common,Ue.displacementmap]),vertexShader:Ht.depth_vert,fragmentShader:Ht.depth_frag},normal:{uniforms:yr([Ue.common,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,{opacity:{value:1}}]),vertexShader:Ht.meshnormal_vert,fragmentShader:Ht.meshnormal_frag},sprite:{uniforms:yr([Ue.sprite,Ue.fog]),vertexShader:Ht.sprite_vert,fragmentShader:Ht.sprite_frag},background:{uniforms:{uvTransform:{value:new Ut},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ht.background_vert,fragmentShader:Ht.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ut}},vertexShader:Ht.backgroundCube_vert,fragmentShader:Ht.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ht.cube_vert,fragmentShader:Ht.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ht.equirect_vert,fragmentShader:Ht.equirect_frag},distanceRGBA:{uniforms:yr([Ue.common,Ue.displacementmap,{referencePosition:{value:new w},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ht.distanceRGBA_vert,fragmentShader:Ht.distanceRGBA_frag},shadow:{uniforms:yr([Ue.lights,Ue.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:Ht.shadow_vert,fragmentShader:Ht.shadow_frag}};Rs.physical={uniforms:yr([Rs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ut},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ut},clearcoatNormalScale:{value:new te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ut},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ut},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ut},sheen:{value:0},sheenColor:{value:new xe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ut},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ut},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ut},transmissionSamplerSize:{value:new te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ut},attenuationDistance:{value:0},attenuationColor:{value:new xe(0)},specularColor:{value:new xe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ut},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ut},anisotropyVector:{value:new te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ut}}]),vertexShader:Ht.meshphysical_vert,fragmentShader:Ht.meshphysical_frag};const Ky={r:0,b:0,g:0},hu=new Wi,E5=new we;function M5(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(g,v){let _=!1,y=v.isScene===!0?v.background:null;y&&y.isTexture&&(y=(v.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===Wp)?(u===void 0&&(u=new de(new Fi(1,1,1),new Bt({name:"BackgroundCubeMaterial",uniforms:Pp(Rs.backgroundCube.uniforms),vertexShader:Rs.backgroundCube.vertexShader,fragmentShader:Rs.backgroundCube.fragmentShader,side:wn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(M,E,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(u)),hu.copy(v.backgroundRotation),hu.x*=-1,hu.y*=-1,hu.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(hu.y*=-1,hu.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=v.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(E5.makeRotationFromEuler(hu)),u.material.toneMapped=gi.getTransfer(y.colorSpace)!==ki,(d!==y||f!==y.version||p!==s.toneMapping)&&(u.material.needsUpdate=!0,d=y,f=y.version,p=s.toneMapping),u.layers.enableAll(),g.unshift(u,u.geometry,u.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new de(new Gn(2,2),new Bt({name:"BackgroundMaterial",uniforms:Pp(Rs.background.uniforms),vertexShader:Rs.background.vertexShader,fragmentShader:Rs.background.fragmentShader,side:Os,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=v.backgroundIntensity,c.material.toneMapped=gi.getTransfer(y.colorSpace)!==ki,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(),g.unshift(c,c.geometry,c.material,0,0,null))}function A(g,v){g.getRGB(Ky,GF(s)),i.buffers.color.setClear(Ky.r,Ky.g,Ky.b,v,o)}return{getClearColor:function(){return a},setClearColor:function(g,v=1){a.set(g),l=v,A(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(g){l=g,A(a,l)},render:m}}function T5(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=g(null);let c=l,u=!1;function d(D,V,L,k,G){let Y=!1;if(o){const K=A(k,L,V);c!==K&&(c=K,p(c.object)),Y=v(D,k,L,G),Y&&_(D,k,L,G)}else{const K=V.wireframe===!0;(c.geometry!==k.id||c.program!==L.id||c.wireframe!==K)&&(c.geometry=k.id,c.program=L.id,c.wireframe=K,Y=!0)}G!==null&&t.update(G,s.ELEMENT_ARRAY_BUFFER),(Y||u)&&(u=!1,C(D,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(D){return i.isWebGL2?s.bindVertexArray(D):r.bindVertexArrayOES(D)}function m(D){return i.isWebGL2?s.deleteVertexArray(D):r.deleteVertexArrayOES(D)}function A(D,V,L){const k=L.wireframe===!0;let G=a[D.id];G===void 0&&(G={},a[D.id]=G);let Y=G[V.id];Y===void 0&&(Y={},G[V.id]=Y);let K=Y[k];return K===void 0&&(K=g(f()),Y[k]=K),K}function g(D){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:D,attributes:{},index:null}}function v(D,V,L,k){const G=c.attributes,Y=V.attributes;let K=0;const re=L.getAttributes();for(const ce in re)if(re[ce].location>=0){const ie=G[ce];let ge=Y[ce];if(ge===void 0&&(ce==="instanceMatrix"&&D.instanceMatrix&&(ge=D.instanceMatrix),ce==="instanceColor"&&D.instanceColor&&(ge=D.instanceColor)),ie===void 0||ie.attribute!==ge||ge&&ie.data!==ge.data)return!0;K++}return c.attributesNum!==K||c.index!==k}function _(D,V,L,k){const G={},Y=V.attributes;let K=0;const re=L.getAttributes();for(const ce in re)if(re[ce].location>=0){let ie=Y[ce];ie===void 0&&(ce==="instanceMatrix"&&D.instanceMatrix&&(ie=D.instanceMatrix),ce==="instanceColor"&&D.instanceColor&&(ie=D.instanceColor));const ge={};ge.attribute=ie,ie&&ie.data&&(ge.data=ie.data),G[ce]=ge,K++}c.attributes=G,c.attributesNum=K,c.index=k}function y(){const D=c.newAttributes;for(let V=0,L=D.length;V<L;V++)D[V]=0}function b(D){M(D,0)}function M(D,V){const L=c.newAttributes,k=c.enabledAttributes,G=c.attributeDivisors;L[D]=1,k[D]===0&&(s.enableVertexAttribArray(D),k[D]=1),G[D]!==V&&((i.isWebGL2?s:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,V),G[D]=V)}function E(){const D=c.newAttributes,V=c.enabledAttributes;for(let L=0,k=V.length;L<k;L++)V[L]!==D[L]&&(s.disableVertexAttribArray(L),V[L]=0)}function T(D,V,L,k,G,Y,K){K===!0?s.vertexAttribIPointer(D,V,L,G,Y):s.vertexAttribPointer(D,V,L,k,G,Y)}function C(D,V,L,k){if(i.isWebGL2===!1&&(D.isInstancedMesh||k.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;y();const G=k.attributes,Y=L.getAttributes(),K=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"&&D.instanceMatrix&&(Re=D.instanceMatrix),re==="instanceColor"&&D.instanceColor&&(Re=D.instanceColor)),Re!==void 0){const ie=Re.normalized,ge=Re.itemSize,be=t.get(Re);if(be===void 0)continue;const Ve=be.buffer,We=be.type,Ge=be.bytesPerElement,ft=i.isWebGL2===!0&&(We===s.INT||We===s.UNSIGNED_INT||Re.gpuType===fT);if(Re.isInterleavedBufferAttribute){const it=Re.data,j=it.stride,Ne=Re.offset;if(it.isInstancedInterleavedBuffer){for(let ye=0;ye<ce.locationSize;ye++)M(ce.location+ye,it.meshPerAttribute);D.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=it.meshPerAttribute*it.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,ge/ce.locationSize,We,ie,j*Ge,(Ne+ge/ce.locationSize*ye)*Ge,ft)}else{if(Re.isInstancedBufferAttribute){for(let it=0;it<ce.locationSize;it++)M(ce.location+it,Re.meshPerAttribute);D.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=Re.meshPerAttribute*Re.count)}else for(let it=0;it<ce.locationSize;it++)b(ce.location+it);s.bindBuffer(s.ARRAY_BUFFER,Ve);for(let it=0;it<ce.locationSize;it++)T(ce.location+it,ge/ce.locationSize,We,ie,ge*Ge,ge/ce.locationSize*it*Ge,ft)}}else if(K!==void 0){const ie=K[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)}}}}E()}function P(){H();for(const D in a){const V=a[D];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[D]}}function S(D){if(a[D.id]===void 0)return;const V=a[D.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[D.id]}function I(D){for(const V in a){const L=a[V];if(L[D.id]===void 0)continue;const k=L[D.id];for(const G in k)m(k[G].object),delete k[G];delete L[D.id]}}function H(){U(),u=!0,c!==l&&(c=l,p(c.object))}function U(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:d,reset:H,resetDefaultState:U,dispose:P,releaseStatesOfGeometry:S,releaseStatesOfProgram:I,initAttributes:y,enableAttribute:b,disableUnusedAttributes:E}}function I5(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 R5(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),g=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),v=s.getParameter(s.MAX_VARYING_VECTORS),_=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),y=f>0,b=o||e.has("OES_texture_float"),M=y&&b,E=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:g,maxVaryings:v,maxFragmentUniforms:_,vertexTextures:y,floatFragmentTextures:b,floatVertexTextures:M,maxSamples:E}}function P5(s){const e=this;let t=null,i=0,n=!1,r=!1;const o=new xr,a=new Ut,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,g=d.clipShadows,v=s.get(d);if(!n||m===null||m.length===0||r&&!g)r?u(null):c();else{const _=r?0:i,y=_*4;let b=v.clippingState||null;l.value=b,b=u(m,f,y,p);for(let M=0;M!==y;++M)b[M]=t[M];v.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 g=null;if(A!==0){if(g=l.value,m!==!0||g===null){const v=p+A*4,_=f.matrixWorldInverse;a.getNormalMatrix(_),(g===null||g.length<v)&&(g=new Float32Array(v));for(let y=0,b=p;y!==A;++y,b+=4)o.copy(d[y]).applyMatrix4(_,a),o.normal.toArray(g,b),g[b+3]=o.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=A,e.numIntersection=0,g}}function B5(s){let e=new WeakMap;function t(o,a){return a===Jo?o.mapping=_c:a===Tp&&(o.mapping=Lh),o}function i(o){if(o&&o.isTexture){const a=o.mapping;if(a===Jo||a===Tp)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 TT(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 Cc extends fA{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 ep=4,vB=[.125,.215,.35,.446,.526,.582],ku=20,NS=new Cc,AB=new xe;let zS=null,GS=0,HS=0;const Du=(1+Math.sqrt(5))/2,xf=1/Du,yB=[new w(1,1,1),new w(-1,1,1),new w(1,1,-1),new w(-1,1,-1),new w(0,Du,xf),new w(0,Du,-xf),new w(xf,0,Du),new w(-xf,0,Du),new w(Du,xf,0),new w(-Du,xf,0)];class _1{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){zS=this._renderer.getRenderTarget(),GS=this._renderer.getActiveCubeFace(),HS=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=wB(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=xB(),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(zS,GS,HS),e.scissorTest=!1,Zy(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===_c||e.mapping===Lh?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),zS=this._renderer.getRenderTarget(),GS=this._renderer.getActiveCubeFace(),HS=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:It,minFilter:It,generateMipmaps:!1,type:un,format:vi,colorSpace:yi,depthBuffer:!1},n=bB(e,t,i),{_lodMax:r}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=_B(r),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=bB(e,t,i);const{_lodMax:o}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=_B(o)),this._blurMaterial=D5(o,e,t)}return n}_compileMaterial(e){const t=new de(this._lodPlanes[0],e);this._renderer.compile(t,NS)}_sceneToCubeUV(e,t,i,n){const a=new Gt(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(AB),u.toneMapping=Wr,u.autoClear=!1;const p=new ai({name:"PMREM.Background",side:wn,depthWrite:!1,depthTest:!1}),m=new de(new Fi,p);let A=!1;const g=e.background;g?g.isColor&&(p.color.copy(g),e.background=null,A=!0):(p.color.copy(AB),A=!0);for(let v=0;v<6;v++){const _=v%3;_===0?(a.up.set(0,l[v],0),a.lookAt(c[v],0,0)):_===1?(a.up.set(0,0,l[v]),a.lookAt(0,c[v],0)):(a.up.set(0,l[v],0),a.lookAt(0,0,c[v]));const y=this._cubeSize;Zy(n,_*y,v>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=g}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===_c||e.mapping===Lh;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=wB()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=xB());const r=n?this._cubemapMaterial:this._equirectMaterial,o=new de(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const l=this._cubeSize;Zy(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,NS)}_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=yB[(n-1)%yB.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 de(this._lodPlanes[n],c),f=c.uniforms,p=this._sizeLods[i]-1,m=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*ku-1),A=r/m,g=isFinite(r)?1+Math.floor(u*A):ku;g>ku&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${ku}`);const v=[];let _=0;for(let T=0;T<ku;++T){const C=T/A,P=Math.exp(-C*C/2);v.push(P),T===0?_+=P:T<g&&(_+=2*P)}for(let T=0;T<v.length;T++)v[T]=v[T]/_;f.envMap.value=e.texture,f.samples.value=g,f.weights.value=v,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],M=3*b*(n>y-ep?n-y+ep:0),E=4*(this._cubeSize-b);Zy(t,M,E,3*b,2*b),l.setRenderTarget(t),l.render(d,NS)}}function _B(s){const e=[],t=[],i=[];let n=s;const r=s-ep+1+vB.length;for(let o=0;o<r;o++){const a=Math.pow(2,n);t.push(a);let l=1/a;o>s-ep?l=vB[o-s+ep-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,g=2,v=1,_=new Float32Array(A*m*p),y=new Float32Array(g*m*p),b=new Float32Array(v*m*p);for(let E=0;E<p;E++){const T=E%3*2/3-1,C=E>2?0:-1,P=[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(P,A*m*E),y.set(f,g*m*E);const S=[E,E,E,E,E,E];b.set(S,v*m*E)}const M=new At;M.setAttribute("position",new tt(_,A)),M.setAttribute("uv",new tt(y,g)),M.setAttribute("faceIndex",new tt(b,v)),e.push(M),n>ep&&n--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function bB(s,e,t){const i=new Yt(s,e,t);return i.texture.mapping=Wp,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Zy(s,e,t,i,n){s.viewport.set(e,t,i,n),s.scissor.set(e,t,i,n)}function D5(s,e,t){const i=new Float32Array(ku),n=new w(0,1,0);return new Bt({name:"SphericalGaussianBlur",defines:{n:ku,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:IT(),fragmentShader:`
3560
3560
 
3561
3561
  precision mediump float;
3562
3562
  precision mediump int;
@@ -4340,7 +4340,7 @@ void main() {
4340
4340
  }`),h(_a,"blipMaterial"),h(_a,"mesh");function NN(s){return _a.copyTexture(s)}function vY(s,e=!1){return _a.textureToCanvas(s,e)}function AY(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&s instanceof ImageBitmap}let T0=!1;d9((...s)=>{var e;gt()&&((e=ri.Current)!=null&&e.isInXR)&&(kp(!0),zN("error",...s))});function kp(s){if(s){if(T0)return;T0=!0,_Y()}else{if(!T0)return;T0=!1,bY()}}const jg={log:void 0,warn:void 0,error:void 0};class yY{constructor(){h(this,"familyName","needle-xr");h(this,"root",null);h(this,"context",null);h(this,"defaultFontSize",.06);h(this,"targetObject",new me);h(this,"userForwardViewPoint",new w);h(this,"oneEuroFilter",new OI(90,.8));h(this,"_lastElementRemoveTime",0);h(this,"onBeforeRender",()=>{var t,i;const e=(t=this.context)==null?void 0:t.mainCamera;if(this.context&&e instanceof Gt){const n=this.getRoot();Number.isNaN(n.position.x)&&n.position.set(0,0,0),Number.isNaN(n.quaternion.x)&&n.quaternion.set(0,0,0,1),this.context.scene.add(this.targetObject);const r=((i=this.context.xr)==null?void 0:i.rigScale)??1,o=3.5*r,a=e.worldForward;a.y=0,a.normalize().multiplyScalar(o),this.userForwardViewPoint.copy(e.worldPosition).sub(a),this.targetObject.position.distanceTo(this.userForwardViewPoint)>2*r&&(this.targetObject.position.copy(this.userForwardViewPoint),EA(this.targetObject,e,!0,!0),this.targetObject.rotateY(Math.PI)),this.oneEuroFilter.filter(this.targetObject.position,n.position,this.context.time.time);const c=this.context.time.deltaTime;if(n.quaternion.slerp(this.targetObject.quaternion,c*5),n.scale.setScalar(r),this.targetObject.removeFromParent(),this.context.scene.add(n),this.context.time.time-this._lastElementRemoveTime>.1){this._lastElementRemoveTime=this.context.time.time;const u=Date.now();for(let d=0;d<this._activeTexts.length;d++){const f=this._activeTexts[d];if(f instanceof Oi.Text&&u-f._activatedTime>2e4){f.removeFromParent(),this._textBuffer.push(f),this._activeTexts.splice(d,1);break}}}}});h(this,"textOptions",{fontSize:this.defaultFontSize,fontFamily:this.familyName,padding:.03,margin:.005,color:0,backgroundColor:16777215,backgroundOpacity:.4,borderRadius:.03,offset:.025});h(this,"_textBuffer",[]);h(this,"_activeTexts",[]);this.ensureFont()}onEnable(){this.context=ri.Current||ri.All[0],this.context.pre_render_callbacks.push(this.onBeforeRender)}onDisable(){var e,t,i;(t=this.context)==null||t.pre_render_callbacks.splice((e=this.context)==null?void 0:e.pre_render_callbacks.indexOf(this.onBeforeRender),1),(i=this.root)==null||i.removeFromParent()}addLog(e,t){const i=this.getRoot(),n=this.getText();let r=16777215,o=0;switch(e){case"log":r=16777215,o=0;break;case"warn":r=16772761,o=4465152;break;case"error":r=16755370,o=7798784;break}t.length>1e3&&(t=t.substring(0,1e3)+"...");const a=new Date().toISOString().split("T")[1].split(".")[0];n.textContent="["+a+"] "+t,n.visible=!0,n._activatedTime=Date.now(),i.add(n),this._activeTexts.push(n),this.context&&this.context.scene.add(i),n.set({backgroundColor:r,color:o}),Oi.update()}ensureFont(){let e=Oi.FontLibrary.getFontFamily(this.familyName);if(!e){e=Oi.FontLibrary.addFontFamily(this.familyName);const t=e.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");t==null||t.addEventListener("ready",()=>{Oi.update()})}}getText(){const e=this.getRoot();if(this._textBuffer.length>0){const i=this._textBuffer.pop();return i.visible=!0,setTimeout(()=>this.disableDepthTestRecursive(i),100),i}if(e.children.length>20&&this._activeTexts.length>0)return this._activeTexts.shift();const t=new Oi.Text(this.textOptions);return setTimeout(()=>this.disableDepthTestRecursive(t),500),setTimeout(()=>this.disableDepthTestRecursive(t),1500),t}disableDepthTestRecursive(e,t=0){for(let n=0;n<e.children.length;n++){const r=e.children[n];r instanceof me&&this.disableDepthTestRecursive(r,t+1)}e.renderOrder=10*t,e.layers.set(2);const i=e.material;i&&(i.depthWrite=!1,i.depthTest=!1,i.transparent=!0),t===0&&Oi.update()}getRoot(){if(this.root)return this.root;const e=this.defaultFontSize,t={boxSizing:"border-box",fontFamily:this.familyName,width:"2.6",fontSize:e,color:0,lineHeight:1,backgroundColor:16777215,backgroundOpacity:0,whiteSpace:"pre-wrap",flexDirection:"column-reverse"};return this.root=new Oi.Block(t),this.root}}let br=null;function _Y(){br||(br=new yY),br.onEnable();for(const s in jg){jg[s]=console[s];let e=!1;console[s]=function(){var t;if((t=jg[s])==null||t.apply(console,arguments),!e)try{e=!0,zN(s,...arguments)}finally{e=!1}}}}function bY(){br==null||br.onDisable();for(const s in jg)console[s]=jg[s]}const Vm=new Map;function zN(s,...e){try{switch(Vm.clear(),s){case"log":br==null||br.addLog("log",t());break;case"warn":br==null||br.addLog("warn",t());break;case"error":br==null||br.addLog("error",t());break}}catch(r){console.error("Error in spatial console",r)}finally{Vm.clear()}function t(){let r="";for(let o=0;o<e.length;o++){const a=e[o];r+=i(a),o<e.length-1&&(r+=", ")}return r}function i(r,o=0){if(typeof r=="string")return'"'+r+'"';if(typeof r=="number"){if(r%1!==0){const l=r.toFixed(5),c=l.indexOf(".");let u=l.length-1;for(;u>c&&l[u]==="0";)u--;return l.substring(0,u+1)}return r.toString()}else if(Array.isArray(r)){let a="[";for(let l=0;l<r.length;l++){const c=r[l];a+=i(c,o+1),l<r.length-1&&(a+=", ")}return a+="]",a}else{if(r===null)return"null";if(r===void 0)return"undefined";if(typeof r=="function")return r.name+"()"}if(r instanceof te)return`(${i(r.x)}, ${i(r.y)})`;if(r instanceof w)return`(${i(r.x)}, ${i(r.y)}, ${i(r.z)})`;if(r instanceof Ze)return`(${i(r.x)}, ${i(r.y)}, ${i(r.z)}, ${i(r.w)})`;if(r instanceof Ce)return`(${i(r.x)}, ${i(r.y)}, ${i(r.z)}, ${i(r.w)})`;if(r instanceof Ot||r instanceof _t)return r.name;if(r instanceof Ut)return`[${r.elements.join(", ")}]`;if(r instanceof we)return`[${r.elements.join(", ")}]`;if(r instanceof sr)return r.mask.toString();if(typeof r=="object"){if(Vm.has(r))return"*";let a=`{
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(Vm.has(f)){c+="";continue}Vm.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
- }`,a}return r}function n(r){let o="";for(let a=0;a<r;a++)o+=" ";return o}}const xY=ne("nodevlogs");function tn(s,e=mo.Log){al(e,s)}function dn(s){tn(s,mo.Warn)}function GI(s){tn(s,mo.Error)}let N1;function gt(){return xY?!1:N1!==void 0?N1:xo()}function wY(s){N1=s}const GN=ne("debugdefines");$p('if(!globalThis[""3.37.5-alpha""]) globalThis[""3.37.5-alpha""] = "0.0.0";');$p('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');$p('if(!globalThis[""Tue Apr 23 2024 09:16:13 GMT+0200 (Central European Summer Time)""]) globalThis[""Tue Apr 23 2024 09:16:13 GMT+0200 (Central European Summer Time)""] = "unknown";');$p('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.37.5-alpha";');$p('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');$p('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Tue Apr 23 2024 09:16:13 GMT+0200 (Central European Summer Time)";');const cl="3.37.5-alpha",rw="undefined",HI="Tue Apr 23 2024 09:16:13 GMT+0200 (Central European Summer Time)";GN&&console.log(`Engine version: ${cl} (generator: ${rw})
4343
+ }`,a}return r}function n(r){let o="";for(let a=0;a<r;a++)o+=" ";return o}}const xY=ne("nodevlogs");function tn(s,e=mo.Log){al(e,s)}function dn(s){tn(s,mo.Warn)}function GI(s){tn(s,mo.Error)}let N1;function gt(){return xY?!1:N1!==void 0?N1:xo()}function wY(s){N1=s}const GN=ne("debugdefines");$p('if(!globalThis[""3.37.6-alpha""]) globalThis[""3.37.6-alpha""] = "0.0.0";');$p('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');$p('if(!globalThis[""Wed Apr 24 2024 17:26:48 GMT+0200 (Central European Summer Time)""]) globalThis[""Wed Apr 24 2024 17:26:48 GMT+0200 (Central European Summer Time)""] = "unknown";');$p('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.37.6-alpha";');$p('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');$p('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Apr 24 2024 17:26:48 GMT+0200 (Central European Summer Time)";');const cl="3.37.6-alpha",rw="undefined",HI="Wed Apr 24 2024 17:26:48 GMT+0200 (Central European Summer Time)";GN&&console.log(`Engine version: ${cl} (generator: ${rw})
4344
4344
  Project built at ${HI}`);const gc="needle_isActiveInHierarchy",Fu="builtin_components",qg="needle_editor_guid";function $p(s){try{(0,eval)(s)}catch(e){GN&&console.error(e)}}const SY='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98z"/><path style="fill:url(#c)" d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z"/><path style="fill:url(#d)" d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04z"/><path style="fill:#9c3" d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5z"/><path style="fill:url(#e)" d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59z"/><path style="fill:url(#f)" d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z"/><path style="fill:#ffe113" d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1z"/><path style="fill:#f3e600" d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75z"/></symbol></defs><use width="160" height="187.74" xlink:href="#g"/></svg>',CY=btoa(SY),EY="data:image/svg+xml;base64,"+CY,MY=EY,TY=`<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> <svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" version="1.1" viewBox="0 0 1014 282" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m665.95 132.73v44.88l-10.56-8.4c-0.8-0.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18 0.4-6.06 1.2s-3.54 1.8-4.98 3-2.56 2.5-3.36 3.9-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c0.32 0.24 0.56 0.44 0.72 0.6s0.36 0.32 0.6 0.48c0.96-1.2 2.14-2.28 3.54-3.24s2.92-1.76 4.56-2.4 3.34-1.14 5.1-1.5 3.44-0.54 5.04-0.54c1.44 0 2.92 0.04 4.44 0.12s2.84 0.28 3.96 0.6c4.56 1.12 7.8 3.12 9.72 6s2.88 6.56 2.88 11.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m732.38 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m795.93 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m858.57 97.21c0.64 0.48 0.96 1.16 0.96 2.04v74.88c-0.08 1.04-0.12 2.12-0.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18s-2.06-1.66-2.46-1.98c-1.76 2.48-4.26 4.44-7.5 5.88s-7.02 2.16-11.34 2.16c-3.84 0-7.4-0.7-10.68-2.1s-6.14-3.44-8.58-6.12-4.34-5.94-5.7-9.78-2.04-8.16-2.04-12.96c0-4.32 0.78-8.34 2.34-12.06s3.6-6.92 6.12-9.6 5.38-4.78 8.58-6.3 6.48-2.28 9.84-2.28c2.56 0 4.82 0.22 6.78 0.66s3.68 1.06 5.16 1.86 2.78 1.74 3.9 2.82 2.16 2.22 3.12 3.42v-35.04l10.68 8.64zm-27.96 67.92c3.6 0 6.52-0.68 8.76-2.04s3.98-3.06 5.22-5.1 2.1-4.22 2.58-6.54 0.72-4.44 0.72-6.36v-1.2c0-1.12-0.22-2.7-0.66-4.74s-1.28-4.06-2.52-6.06-3-3.7-5.28-5.1-5.22-2.02-8.82-1.86c-3.44 0-6.26 0.74-8.46 2.22s-3.96 3.26-5.28 5.34-2.24 4.2-2.76 6.36-0.78 3.92-0.78 5.28c0 1.84 0.24 3.92 0.72 6.24s1.36 4.48 2.64 6.48 3.04 3.68 5.28 5.04 5.12 2.04 8.64 2.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m882.81 97.09c0.64 0.48 0.96 1.12 0.96 1.92l-0.12 41.04v37.08l-10.56-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-77.88l10.8 8.64z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m950.36 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.8559 0 0 .7642 45.348 36.475)"> <g transform="translate(2.7114)"> <path d="m3.935 173.02c-0.331 0-0.497-0.402-0.497-1.207v-51.002c0-0.738 0.138-1.107 0.414-1.107h1.781c0.277 0 0.415 0.335 0.415 1.006v5.935c0 0.336 0.027 0.553 0.083 0.654 0.055 0.101 0.151-0.017 0.289-0.352 0.912-1.744 1.754-3.236 2.527-4.477 0.773-1.24 1.554-2.179 2.341-2.816s1.65-0.956 2.588-0.956c1.685 0 3.011 0.922 3.977 2.766 0.967 1.845 1.602 3.84 1.905 5.986 0.056 0.268 0.139 0.369 0.249 0.302s0.221-0.235 0.331-0.503c0.939-1.811 1.802-3.353 2.589-4.628 0.787-1.274 1.581-2.246 2.382-2.917s1.671-1.006 2.61-1.006c2.016 0 3.569 1.392 4.66 4.175 1.09 2.783 1.636 6.421 1.636 10.915v37.925c0 0.871-0.18 1.307-0.539 1.307h-1.739c-0.138 0-0.249-0.1-0.332-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.338-6.321-1.015-8.3-0.676-1.978-1.76-2.967-3.251-2.967-0.884 0-1.726 0.386-2.527 1.157s-1.519 1.727-2.154 2.867-1.201 2.213-1.699 3.219c-0.248 0.469-0.421 0.905-0.517 1.308-0.097 0.402-0.145 0.972-0.145 1.71v37.221c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.166 0-0.29-0.1-0.373-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.332-6.321-0.994-8.3-0.663-1.978-1.754-2.967-3.273-2.967-1.242 0-2.375 0.704-3.396 2.112-1.022 1.409-2.223 3.555-3.604 6.439v39.031c0 0.805-0.18 1.207-0.539 1.207h-1.698z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m53.642 166.28c-1.077 2.549-2.237 4.477-3.479 5.785-1.243 1.307-2.61 1.961-4.101 1.961-2.154 0-3.853-1.324-5.095-3.973-1.243-2.649-1.864-6.187-1.864-10.613 0-3.488 0.4-6.489 1.201-9.004s1.988-4.51 3.562-5.985c1.574-1.476 3.521-2.414 5.841-2.817l3.686-0.704c0.221-0.067 0.394-0.218 0.518-0.453 0.124-0.234 0.187-0.587 0.187-1.056v-2.917c0-3.89-0.504-6.975-1.512-9.255s-2.354-3.42-4.039-3.42c-1.298 0-2.472 0.72-3.521 2.162s-2.002 3.572-2.858 6.388c-0.083 0.268-0.159 0.453-0.228 0.554-0.069 0.1-0.172 0.083-0.311-0.051l-1.698-1.71c-0.083-0.134-0.138-0.285-0.166-0.453-0.027-0.167 0.014-0.452 0.125-0.855 0.856-3.353 2.009-6.052 3.459-8.098 1.449-2.045 3.224-3.068 5.322-3.068 1.74 0 3.211 0.687 4.412 2.062s2.112 3.37 2.734 5.986c0.621 2.615 0.932 5.7 0.932 9.255v35.712c0 0.536-0.035 0.888-0.104 1.056s-0.2 0.251-0.393 0.251h-1.533c-0.166 0-0.29-0.117-0.373-0.352-0.083-0.234-0.124-0.553-0.124-0.955l-0.083-5.231c-0.055-0.939-0.221-1.006-0.497-0.202zm0.456-19.314c0-1.14-0.194-1.643-0.58-1.509l-3.107 0.603c-1.436 0.202-2.686 0.638-3.749 1.308-1.063 0.671-1.953 1.543-2.671 2.616s-1.257 2.33-1.616 3.772-0.538 3.102-0.538 4.98c0 3.152 0.455 5.616 1.367 7.393 0.911 1.778 2.14 2.666 3.686 2.666 0.939 0 1.85-0.419 2.734-1.257s1.671-1.895 2.361-3.169c0.663-1.408 1.181-2.85 1.553-4.326 0.373-1.475 0.56-2.883 0.56-4.225v-8.852z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m79.034 173.02c-0.166 0-0.297-0.117-0.394-0.352-0.096-0.234-0.145-0.553-0.145-0.955v-4.628c0-0.536-0.041-0.838-0.124-0.905s-0.207 0.1-0.373 0.503c-0.276 0.67-0.69 1.593-1.242 2.766-0.553 1.174-1.271 2.23-2.154 3.169-0.884 0.939-1.961 1.408-3.231 1.408-1.74 0-3.314-0.989-4.722-2.967-1.409-1.979-2.534-4.963-3.376-8.953-0.843-3.991-1.264-8.937-1.264-14.838 0-5.701 0.415-10.68 1.243-14.939s1.988-7.595 3.479-10.009c1.492-2.415 3.204-3.622 5.137-3.622 1.436 0 2.616 0.57 3.541 1.71 0.926 1.14 1.719 2.381 2.382 3.722 0.249 0.47 0.414 0.637 0.497 0.503s0.125-0.536 0.125-1.207v-23.841c0-0.805 0.151-1.208 0.455-1.208h1.864c0.276 0 0.414 0.369 0.414 1.107v72.128c0 0.537-0.041 0.905-0.124 1.107-0.083 0.201-0.235 0.301-0.455 0.301h-1.533zm-0.621-42.049c-0.939-2.213-1.885-3.94-2.838-5.181s-2.009-1.861-3.169-1.861c-1.463 0-2.768 0.889-3.914 2.666s-2.044 4.376-2.693 7.796-0.973 7.578-0.973 12.474c0 5.097 0.338 9.272 1.015 12.524 0.676 3.253 1.567 5.651 2.672 7.193 1.104 1.543 2.305 2.314 3.603 2.314 1.188 0 2.258-0.704 3.211-2.113 0.952-1.408 1.705-3.118 2.257-5.13s0.829-3.957 0.829-5.835v-24.847z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m89.514 149.38c0 3.42 0.345 6.606 1.035 9.557 0.691 2.951 1.609 5.315 2.755 7.092s2.437 2.666 3.873 2.666c1.519 0 2.837-0.738 3.956-2.213 1.118-1.476 2.064-3.655 2.837-6.539 0.083-0.336 0.166-0.52 0.249-0.554 0.083-0.033 0.179 0.017 0.29 0.151l1.408 1.912c0.221 0.268 0.235 0.67 0.041 1.207-0.69 2.548-1.47 4.661-2.34 6.337-0.87 1.677-1.857 2.935-2.962 3.773-1.104 0.838-2.319 1.257-3.645 1.257-2.043 0-3.838-1.14-5.385-3.42-1.546-2.28-2.761-5.482-3.645-9.607-0.884-4.124-1.325-8.836-1.325-14.134 0-5.901 0.455-10.931 1.367-15.089 0.911-4.158 2.14-7.377 3.686-9.658 1.547-2.28 3.3-3.42 5.261-3.42 1.988 0 3.714 1.073 5.178 3.219 1.463 2.146 2.595 5.231 3.396 9.255s1.201 8.886 1.201 14.587c0 0.469-0.02 0.939-0.062 1.408-0.041 0.469-0.214 0.704-0.517 0.704h-16.362c-0.083 0-0.152 0.151-0.207 0.453-0.056 0.302-0.083 0.654-0.083 1.056zm13.752-6.237c0.304 0 0.497-0.1 0.58-0.302 0.083-0.201 0.124-0.57 0.124-1.106 0-3.219-0.283-6.187-0.849-8.903s-1.367-4.896-2.402-6.539c-1.036-1.643-2.272-2.464-3.708-2.464-1.629 0-2.996 0.955-4.101 2.867-1.104 1.911-1.94 4.342-2.506 7.293s-0.849 6.002-0.849 9.154h13.711z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m148.54 119.7c0.165 0 0.283 0.117 0.352 0.352s0.076 0.52 0.02 0.855l-6.254 50.902c-0.028 0.47-0.104 0.788-0.228 0.956s-0.297 0.251-0.518 0.251h-1.615c-0.442 0-0.718-0.402-0.829-1.207l-5.26-40.138c-0.111-0.604-0.201-0.905-0.27-0.905s-0.131 0.301-0.186 0.905l-5.012 40.138c-0.028 0.47-0.097 0.788-0.207 0.956-0.111 0.168-0.277 0.251-0.497 0.251h-1.74c-0.442 0-0.718-0.402-0.829-1.207l-6.503-50.801c-0.055-0.403-0.048-0.721 0.021-0.956s0.2-0.352 0.393-0.352h1.823c0.166 0 0.297 0.067 0.393 0.201 0.097 0.134 0.159 0.403 0.187 0.805l5.302 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.219-41.949c0.055-0.268 0.124-0.47 0.207-0.604s0.193-0.201 0.331-0.201h1.533c0.138 0 0.262 0.067 0.373 0.201 0.11 0.134 0.179 0.403 0.207 0.805l5.468 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.053-41.849c0.055-0.335 0.138-0.57 0.249-0.704 0.11-0.134 0.234-0.201 0.373-0.201h1.284z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m156.49 171.51c0 0.604-0.042 1.006-0.125 1.208-0.082 0.201-0.262 0.301-0.538 0.301h-1.533c-0.221 0-0.366-0.083-0.435-0.251s-0.103-0.486-0.103-0.956v-50.902c0-0.805 0.152-1.207 0.456-1.207h1.822c0.304 0 0.456 0.402 0.456 1.207v50.6zm0.165-63.979c0 1.207-0.207 1.811-0.621 1.811h-1.905c-0.221 0-0.366-0.135-0.435-0.403s-0.104-0.67-0.104-1.207v-7.847c0-1.006 0.18-1.509 0.539-1.509h1.988c0.359 0 0.538 0.47 0.538 1.409v7.746z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m168.3 124.83c-0.221 0-0.331 0.269-0.331 0.805v33.801c0 3.42 0.221 5.667 0.663 6.74 0.441 1.073 1.09 1.609 1.946 1.609h3.024c0.138 0 0.242 0.084 0.311 0.252 0.069 0.167 0.103 0.419 0.103 0.754v2.716c0 0.537-0.138 0.906-0.414 1.107-0.248 0.067-0.614 0.134-1.098 0.201-0.483 0.067-0.959 0.118-1.429 0.151-0.469 0.034-0.828 0.05-1.077 0.05-1.712 0-2.934-0.955-3.665-2.867-0.732-1.911-1.098-5.013-1.098-9.305v-35.108c0-0.604-0.124-0.906-0.373-0.906h-3.521c-0.248 0-0.373-0.268-0.373-0.804v-3.521c0-0.537 0.111-0.805 0.332-0.805h3.686c0.166 0 0.263-0.268 0.29-0.805l0.415-16.095c0-0.805 0.124-1.207 0.372-1.207h1.492c0.303 0 0.455 0.436 0.455 1.307v15.995c0 0.537 0.097 0.805 0.29 0.805h5.468c0.221 0 0.331 0.268 0.331 0.805v3.521c0 0.536-0.124 0.804-0.373 0.804h-5.426z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m179.4 173.02c-0.331 0-0.497-0.402-0.497-1.207v-72.329c0-0.738 0.138-1.107 0.414-1.107h1.782c0.276 0 0.414 0.336 0.414 1.006v27.162c0 0.335 0.034 0.536 0.103 0.603s0.159-0.033 0.27-0.302c0.994-1.81 1.898-3.319 2.713-4.526 0.814-1.208 1.629-2.113 2.444-2.717 0.814-0.603 1.691-0.905 2.63-0.905 2.182 0 3.839 1.375 4.971 4.125 1.132 2.749 1.698 6.404 1.698 10.965v37.925c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.165 0-0.29-0.1-0.373-0.301-0.082-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.366-6.321-1.097-8.3-0.732-1.978-1.899-2.967-3.501-2.967-0.883 0-1.705 0.318-2.464 0.956-0.76 0.637-1.526 1.576-2.299 2.816-0.773 1.241-1.643 2.834-2.61 4.779v39.031c0 0.805-0.179 1.207-0.538 1.207h-1.699z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> </g> <g transform="matrix(.80638 0 0 .80638 452.53 65.421)" fill-rule="nonzero"> <path d="m79.32 36.98v150.76l15.68-13.2 6.59-156.31-22.27 18.75z" fill="url(#f)"/> <path d="m79.32 36.98-22.27-18.75 6.59 156.31 15.68 13.2v-150.76z" fill="url(#e)"/> <path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z" fill="url(#d)"/> <path d="m25.19 104.83-25.19-14.59 16.97 53.86 16.85 9.77-8.63-49.04z" fill="url(#c)"/> <path d="M43.86,82.5L18.69,67.98L0,90.24L25.18,104.83L43.86,82.5Z" fill="#9c3"/> <path d="m134.82 78.69-9.97 56.5 15.58-9.04 19.57-62.05-25.18 14.59z" fill="url(#b)"/> <path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z" fill="url(#a)"/> <path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33 25.19-14.59z" fill="#ffe113"/> <path d="M101.59,18.23L79.32,0L57.05,18.23L79.32,36.98L101.59,18.23Z" fill="#f3e600"/> </g> <defs> <linearGradient id="f" x2="1" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)" gradientUnits="userSpaceOnUse"><stop stop-color="#62d399" offset="0"/><stop stop-color="#acd842" offset=".51"/><stop stop-color="#d7db0a" offset=".9"/><stop stop-color="#d7db0a" offset="1"/></linearGradient> <linearGradient id="e" x2="1" gradientTransform="matrix(-1.6,-162.13,162.13,-1.6,69.68,178.9)" gradientUnits="userSpaceOnUse"><stop stop-color="#0ba398" offset="0"/><stop stop-color="#4ca352" offset=".5"/><stop stop-color="#76a30a" offset="1"/></linearGradient> <linearGradient id="d" x2="1" gradientTransform="matrix(-1.9,-67.98,67.98,-1.9,36.6,152.17)" gradientUnits="userSpaceOnUse"><stop stop-color="#36a382" offset="0"/><stop stop-color="#36a382" offset=".19"/><stop stop-color="#49a459" offset=".54"/><stop stop-color="#76a30b" offset="1"/></linearGradient> <linearGradient id="c" x2="1" gradientTransform="matrix(2.18,-62.38,62.38,2.18,15.82,153.24)" gradientUnits="userSpaceOnUse"><stop stop-color="#267880" offset="0"/><stop stop-color="#457a5c" offset=".51"/><stop stop-color="#717516" offset="1"/></linearGradient> <linearGradient id="b" x2="1" gradientTransform="matrix(13.85,-71.96,71.96,13.85,135.08,135.43)" gradientUnits="userSpaceOnUse"><stop stop-color="#b0d939" offset="0"/><stop stop-color="#eadb04" offset="1"/></linearGradient> <linearGradient id="a" x2="1" gradientTransform="matrix(26.159 -64.737 64.737 26.159 107.42 128.14)" gradientUnits="userSpaceOnUse"><stop stop-color="#74af52" offset="0"/><stop stop-color="#74af52" offset=".17"/><stop stop-color="#99be32" offset=".48"/><stop stop-color="#c0c40a" offset="1"/></linearGradient> </defs> </svg>`;btoa(TY);const IY='<svg viewBox="0 0 509 154" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M665.95 132.73v44.88l-10.56-8.4c-.8-.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18.4-6.06 1.2-1.88.8-3.54 1.8-4.98 3-1.44 1.2-2.56 2.5-3.36 3.9-.8 1.4-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-.72-.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c.32.24.56.44.72.6.16.16.36.32.6.48.96-1.2 2.14-2.28 3.54-3.24 1.4-.96 2.92-1.76 4.56-2.4 1.64-.64 3.34-1.14 5.1-1.5 1.76-.36 3.44-.54 5.04-.54 1.44 0 2.92.04 4.44.12 1.52.08 2.84.28 3.96.6 4.56 1.12 7.8 3.12 9.72 6 1.92 2.88 2.88 6.56 2.88 11.04ZM732.38 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM795.93 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM858.57 97.21c.64.48.96 1.16.96 2.04v74.88c-.08 1.04-.12 2.12-.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18-1.24-1-2.06-1.66-2.46-1.98-1.76 2.48-4.26 4.44-7.5 5.88-3.24 1.44-7.02 2.16-11.34 2.16-3.84 0-7.4-.7-10.68-2.1-3.28-1.4-6.14-3.44-8.58-6.12-2.44-2.68-4.34-5.94-5.7-9.78-1.36-3.84-2.04-8.16-2.04-12.96 0-4.32.78-8.34 2.34-12.06 1.56-3.72 3.6-6.92 6.12-9.6 2.52-2.68 5.38-4.78 8.58-6.3 3.2-1.52 6.48-2.28 9.84-2.28 2.56 0 4.82.22 6.78.66 1.96.44 3.68 1.06 5.16 1.86s2.78 1.74 3.9 2.82a35.92 35.92 0 0 1 3.12 3.42V88.57l10.68 8.64Zm-27.96 67.92c3.6 0 6.52-.68 8.76-2.04 2.24-1.36 3.98-3.06 5.22-5.1a20.5 20.5 0 0 0 2.58-6.54c.48-2.32.72-4.44.72-6.36v-1.2c0-1.12-.22-2.7-.66-4.74-.44-2.04-1.28-4.06-2.52-6.06s-3-3.7-5.28-5.1c-2.28-1.4-5.22-2.02-8.82-1.86-3.44 0-6.26.74-8.46 2.22-2.2 1.48-3.96 3.26-5.28 5.34-1.32 2.08-2.24 4.2-2.76 6.36-.52 2.16-.78 3.92-.78 5.28 0 1.84.24 3.92.72 6.24.48 2.32 1.36 4.48 2.64 6.48s3.04 3.68 5.28 5.04c2.24 1.36 5.12 2.04 8.64 2.04ZM882.81 97.09c.64.48.96 1.12.96 1.92l-.12 41.04v37.08l-10.56-8.4c-.72-.64-1.08-1.44-1.08-2.4V88.45l10.8 8.64ZM950.36 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14Z" style="fill-rule:nonzero" transform="translate(-452.406 -63.709) scale(1.00797)"/><path d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75Z" style="fill:url(#a);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98Z" style="fill:url(#b);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33Z" style="fill:url(#c);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04Z" style="fill:url(#d);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5Z" style="fill:#9c3;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59Z" style="fill:url(#e);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5Z" style="fill:url(#f);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1Z" style="fill:#ffe113;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75Z" style="fill:#f3e600;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><defs><linearGradient id="a" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)"><stop offset="0" style="stop-color:#62d399;stop-opacity:1"/><stop offset=".51" style="stop-color:#acd842;stop-opacity:1"/><stop offset=".9" style="stop-color:#d7db0a;stop-opacity:1"/><stop offset="1" style="stop-color:#d7db0a;stop-opacity:1"/></linearGradient><linearGradient id="b" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-90.565 123.412 54.953) scale(162.14)"><stop offset="0" style="stop-color:#0ba398;stop-opacity:1"/><stop offset=".5" style="stop-color:#4ca352;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30a;stop-opacity:1"/></linearGradient><linearGradient id="c" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="scale(-68) rotate(88.4 .881 -1.396)"><stop offset="0" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".19" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".54" style="stop-color:#49a459;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30b;stop-opacity:1"/></linearGradient><linearGradient id="d" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-88 87.255 68.431) scale(62.42)"><stop offset="0" style="stop-color:#267880;stop-opacity:1"/><stop offset=".51" style="stop-color:#457a5c;stop-opacity:1"/><stop offset="1" style="stop-color:#717516;stop-opacity:1"/></linearGradient><linearGradient id="e" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-79.1 149.53 -14.065) scale(73.28)"><stop offset="0" style="stop-color:#b0d939;stop-opacity:1"/><stop offset="1" style="stop-color:#eadb04;stop-opacity:1"/></linearGradient><linearGradient id="f" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-67.997 148.705 -15.558) scale(69.8226)"><stop offset="0" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".17" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".48" style="stop-color:#99be32;stop-opacity:1"/><stop offset="1" style="stop-color:#c0c40a;stop-opacity:1"/></linearGradient></defs></svg>',RY=btoa(IY),PY="data:image/svg+xml;charset=utf-8;base64,"+RY,BY=PY,jo=ne("debuglicense");let td="basic";jo&&console.log("License Type: "+td);function Ia(){switch(td){case"pro":case"enterprise":return!0}return!1}function QI(){switch(td){case"indie":return!0}return!1}function Fp(){return Ia()||QI()}const HN=[];function DY(s){if(Ia()||QI())return s(!0);HN.push(s)}function OY(s){for(const e of HN)try{e(s)}catch{}}ri.registerCallback(bn.ContextRegistered,s=>{FY(s.context),NY(),kY(s.context)});let Eh,z1=!1,bg="";async function LY(){if(Eh)return Eh;if(td==="basic")try{const s="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+cl+"&generator="+encodeURIComponent(rw),e=await fetch(s,{method:"GET"}).catch(t=>{jo&&console.error("License check failed",t)});(e==null?void 0:e.status)===200?(z1=!1,jo&&console.log("License check succeeded"),td="pro",OY(!0)):(e==null?void 0:e.status)===403?(z1=!0,bg=await e.text()):jo&&console.log("License check failed with status "+(e==null?void 0:e.status))}catch(s){jo&&console.error("License check failed",s)}else jo&&console.log('Runtime license check is skipped because license is already applied as "'+td+'"')}Eh=LY();async function kY(s){function e(){const n=document.createElement("div");n.className="needle-forbidden",n.style.cssText=`
4345
4345
  position: fixed;
4346
4346
  top: 0;
@@ -5506,8 +5506,8 @@ Could not find method ${u.method} on object ${f.name}. Please rename ${u.method}
5506
5506
  Could not find method ${u.method} on object ${f.name}`,f,typeof f[u.method])};if(typeof f[u.method]!="function"){let y=!1,b=f;for(;b;){const M=Object.getOwnPropertyDescriptor(b,u.method);if(M&&(M.writable===!0||M.set)){y=!0;break}b=Object.getPrototypeOf(b)}!y&&(gt()||Ds)&&v()}}let m=u.argument;m!==void 0?m=d(m):u.arguments!==void 0&&(m=u.arguments.map(d));const A=p?this.createEventMethod(f,u.method,m):void 0,g=new Hp(A,u.enabled);if(g.method||(g[Bie]=(o=t.object)==null?void 0:o.name),!f||!g.method){const v=t.object?"Current object: "+t.object.name+", "+t.object.guid:null;f?console.warn('EventList method not found: "'+u.method+'" on',f):console.warn("EventList is missing target - will be ignored",u.target,v,e)}else a.push(g)}const l=new $n(a);Ds&&console.log(l);const c=t.target;return c!==void 0&&t.path!==void 0&&l.setEventTarget(t.path,c),l}}createEventMethod(e,t,i){return(...n)=>{const r=e[t];typeof r=="function"?i!==void 0?Array.isArray(i)?r==null||r.call(e,...i):r==null||r.call(e,i):r==null||r.call(e,...n):e[t]=i}}}const Oie=new Die;class nG extends wl{constructor(){super([Rh,Yt])}onSerialize(e,t){}onDeserialize(e,t){if(e instanceof _t&&t.type===Rh){const i=e,n=new Rh(i.image.width,i.image.height,{colorSpace:yi});return n.texture=i,i.isRenderTargetTexture=!0,i.flipY=!0,i.offset.y=1,i.repeat.y=-1,i.needsUpdate=!0,i.mipmaps=[],i instanceof fl&&(i.isCompressedTexture=!1,i.format=RGBAFormat),n}}}new nG;class sG extends wl{constructor(){super([URL])}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"&&e.length>0)return Mc(t.gltfId,e)}}new sG;var Lie=Object.defineProperty,kie=Object.getOwnPropertyDescriptor,Fie=(s,e,t,i)=>{for(var n=i>1?void 0:i?kie(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Lie(e,t,n),n};class VA extends Me{awake(){Vr.createIfNoneExists(this.context)}onEnable(){var e;(e=Vr.get(this.context))==null||e.register(this)}onDisable(){var e;(e=Vr.get(this.context))==null||e.unregister(this)}}class So extends VA{constructor(){super(...arguments);h(this,"targets",null);h(this,"raycastHits",[]);h(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(t=null){if(!this.targets)return null;t??(t=new ia),t.targets=this.targets,t.results=this.raycastHits;const i=t.testObject;this.ignoreSkinnedMeshes&&(t.testObject=r=>r instanceof yo?"continue in children":i?i(r):!0);const n=this.context.physics.raycast(t);return t.testObject=i,n}}Fie([x()],So.prototype,"ignoreSkinnedMeshes",2);class Ew extends So{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class Yv extends VA{performRaycast(e){if(!St.active||!(e!=null&&e.ray))return null;const t=e.ray.origin,i=.01;return this.context.physics.sphereOverlap(t,i)}}class Mw{static getObject(e){const t=e[qo];return t&&(t.isComponent===!0?e=t.gameObject:e=t),e}static isInteractable(e,t){if(t&&(t.canvasGroup=void 0,t.graphic=void 0),e==null||!e.visible||(e=this.getObject(e),!e.visible))return!1;const i=this.tryFindCanvasGroup(e);if((i==null?void 0:i.isCanvasGroup)===!0&&(t&&(t.canvasGroup=i),i.blocksRaycasts===!1||i.interactable===!1))return!1;const n=wd(e,r=>{if(r.isGraphic===!0)return r},!1);return t&&(n==null?void 0:n.isGraphic)===!0&&(t.graphic=n),!((n==null?void 0:n.raycastTarget)===!1||(n==null?void 0:n.layer)===2)}static tryFindCanvasGroup(e){if(!e)return null;const t=wd(e,i=>{const n=i;if(n.blocksRaycasts!==void 0&&n.interactable!==void 0)return n},!1);return t!==void 0?t:this.tryFindCanvasGroup(e.parent)}}function TR(s){const e=s[qo];return e||(s.parent?TR(s.parent):null)}function Uie(s){return s.isUI===!0||typeof s[qo]=="object"}function Jb(s,e){if(!s)return;const t=s.material;if((t==null?void 0:t.isMaterial)===!0){const i=s.parent;i&&i.isText,t.side=e.doubleSided??!0?di:Os,t.shadowSide=e.doubleSided?di:Os,s.castShadow=e.castShadows?e.castShadows:!1,s.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const i of s.children)Jb(i,e)}function Vf(s,e,t){s[e]===void 0&&console.warn("Field",e,"is undefined on",s);const i=Proxy.revocable(s[e],{set(o,a,l,c){const u=o[a],d=Reflect.set(o,a,l,c);return t(l,u),d}}),n=i.revoke,r=s[e];return i.revoke=()=>{s[e]=r,n()},s[e]=i.proxy,i}const WO=Symbol("Scheduled action");function Nie(s,e,t=ji.OnBeforeRender){let i=s[WO];i||(i=s[WO]={});const n=e.name;i[t]||(i[t]={});const r=i[t];if(r[n])return;function*a(){e==null||e.call(s),r[n]=null}const l=s.startCoroutine(a(),t);r[n]=l}const Vl=ne("debugeventsystem");var OM=(s=>(s.BeforeHandleInput="BeforeHandleInput",s.AfterHandleInput="AfterHandleInput",s))(OM||{});const Ka=class extends Me{constructor(){super();h(this,"raycaster",[]);h(this,"_handleInputFn");h(this,"pressedByID",new Map);h(this,"hoveredByID",new Map);h(this,"_sortedHits",[]);h(this,"_testObjectsCache",new Map);h(this,"_currentlyActiveRaycaster",null);h(this,"_currentPointerEventName",null);h(this,"shouldRaycastObject",t=>{var r;let i=null;if(Uie(t)&&(i=(r=t[qo])==null?void 0:r.gameObject),this._testObjectsCache.has(t)||i&&this._testObjectsCache.has(i))return this._testObjectsCache.get(t)===!1?"continue in children":!0;{let o=DM(t,this._currentPointerEventName);if(!o&&i&&(o=DM(i,this._currentPointerEventName)),o){this._testObjectsCache.set(t,!0);for(const a of t.children)this.shouldRaycastObject_AddToYesCache(a);return!0}return this._testObjectsCache.set(t,!1),"continue in children"}});h(this,"_sortingBuffer",[]);h(this,"_noDepthTestingResults",[]);h(this,"out",{});h(this,"_capturedPointer",{});h(this,"pointerEnterSymbol",Symbol("pointerEnter"));h(this,"pointerExitSymbol",Symbol("pointerExit"));h(this,"currentActiveMeshUIComponents",[]);Ka.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Ka.systems.length<=0&&Ka.systems.push(...oe.findObjectsOfType(Ka,t)));for(const n of Ka.systems)if(n.context===t)return;const i=new me;oe.addNewComponent(i,Ka),t.scene.add(i)}static get systems(){const t=Lt.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const i=this._eventSystemMap.get(t);return i&&i.length>0?i[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,i,n=!1){gh.update(t,i,n)}static markUIDirty(t){gh.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Ka.systems.splice(Ka.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!oe.findObjectOfType(VA,this.context)){const i=oe.addNewComponent(this.context.scene,So);this.raycaster.push(i),(gt()||Vl)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(t){var i;t&&this.raycaster&&!this.raycaster.includes(t)&&((i=this.raycaster)==null||i.push(t))}unregister(t){var n,r;const i=(n=this.raycaster)==null?void 0:n.indexOf(t);i!==void 0&&i!==-1&&((r=this.raycaster)==null||r.splice(i,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(en.PointerDown,this._handleInputFn),this.context.input.addEventListener(en.PointerUp,this._handleInputFn),this.context.input.addEventListener(en.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(en.PointerDown,this._handleInputFn),this.context.input.removeEventListener(en.PointerUp,this._handleInputFn),this.context.input.removeEventListener(en.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(t){if(t===void 0||t.propagationStopped)return;const i=new lm(this.context.input,t);this._currentPointerEventName=t.type,i.inputSource=this.context.input,i.isClick=t.isClick,i.isDoubleClick=t.isDoubleClick,i.isDown=t.type==en.PointerDown,i.isUp=t.type==en.PointerUp,i.isPressed=this.context.input.getPointerPressed(t.pointerId),Vl&&(i.isDown?console.log("DOWN",i.pointerId):i.isUp&&console.log("UP",i.pointerId),i.isClick&&console.log("CLICK",i.pointerId));const n=new ia;t.hasRay?n.ray=t.ray:n.screenPoint=this.context.input.getPointerPositionRC(t.pointerId);const r=this.performRaycast(n);if(r)for(const a of r)a.event=t,t.intersections.push(a);Vl&&i.isClick&&tn("EventSystem: "+i.pointerId+" - "+this.context.time.frame+" - Up:"+i.isUp+", Down:"+i.isDown);const o={sender:this,args:i,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(r,i),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))}shouldRaycastObject_AddToYesCache(t){this._testObjectsCache.set(t,!0);for(const i of t.children)this.shouldRaycastObject_AddToYesCache(i)}performRaycast(t){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,t||(t=new ia),t.testObject=this.shouldRaycastObject;for(const i of this.raycaster){if(!i.activeAndEnabled)continue;this._currentlyActiveRaycaster=i;const n=i.performRaycast(t);this._currentlyActiveRaycaster=null,n&&n.length>0&&this._sortedHits.push(...n)}return this._sortedHits.sort((i,n)=>i.distance-n.distance),this._sortedHits}assignHitInformation(t,i){i?(t.intersection=i,t.point=i.point,t.normal=i.normal,t.face=i.face,t.distance=i.distance,t.instanceId=i.instanceId):(t.intersection=void 0,t.point=void 0,t.normal=void 0,t.face=void 0,t.distance=void 0,t.instanceId=void 0)}handleIntersections(t,i){var r;if(t!=null&&t.length){t=this.sortCandidates(t);for(const o of t){if(i.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(i,o),this.handleEventOnObject(o.object,i))return!0}}this.assignHitInformation(i,t==null?void 0:t[0]),this.invokePointerCapture(i);const n=this.hoveredByID.get(i.pointerId);return n&&this.propagatePointerExit(n.obj,n.data,null),this.hoveredByID.delete(i.pointerId),i.isUp&&((r=this.pressedByID.get(i.pointerId))==null||r.handlers.forEach(o=>this.invokeOnPointerUp(i,o)),this.pressedByID.delete(i.pointerId)),!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let i=0;i<t.length;i++){const n=t[i],r=n.object;if(r.material&&r.material.depthTest===!1){this._noDepthTestingResults.push(n);continue}this._sortingBuffer.push(n)}for(const i of this._sortingBuffer)this._noDepthTestingResults.push(i);return this._noDepthTestingResults}handleEventOnObject(t,i){if(!this.testIsVisible(t))return i.isClick&&Vl&&console.log("not allowed",t),!1;if(i.pointerId===void 0)return Vl&&console.error("Event without pointer can't be handled",i),!1;i.object=t;const n=t.parent,r=i.isClick??!1;let o=null;if(n&&n.isUI){const d=(i.isPressed||i.isClick)??!1;if(n[qo]){const f=n[qo].gameObject;if(f){if(!Mw.isInteractable(f,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,d),t=f}}}r&&Vl&&console.log(this.context.time.frame,t);const a=this.hoveredByID.get(i.pointerId),l=a==null?void 0:a.obj;l!==t&&l&&this.propagatePointerExit(l,a.data,t);const u=this.hoveredByID.get(i.pointerId);if(u?(u.obj=t,u.data=i):this.hoveredByID.set(i.pointerId,{obj:t,data:i}),i.isDown){const d=this.pressedByID.get(i.pointerId);d?(d.obj=t,d.data=i):this.pressedByID.set(i.pointerId,{obj:t,data:i,handlers:new Set})}return(o===null||o.interactable)&&this.handleMainInteraction(t,i,l??null),!0}propagate(t,i){for(;t;)oe.foreachComponent(t,n=>{i(n)},!1),t=t.parent}handleMainInteraction(t,i,n){const r=this.pressedByID.get(i.pointerId),o=n!==t;let a=!0;switch(i.event.pointerType){case"mouse":case"touch":const l=this.context.input.getPointerPositionLastFrame(i.pointerId),c=this.context.input.getPointerPosition(i.pointerId);a=l&&!et.approximately(l,c);break}this.propagate(t,l=>{var u;const c=l;c.interactable!==!1&&(!c.activeAndEnabled||!c.enabled||(c.onPointerEnter&&o&&this.handlePointerEnter(c,i),i.isDown&&c.onPointerDown&&(c.onPointerDown(i),r==null||r.handlers.add(c),this.handlePointerCapture(i,c)),c.onPointerMove&&(a&&c.onPointerMove(i),this.handlePointerCapture(i,c)),i.isUp&&(c.onPointerUp&&(this.invokeOnPointerUp(i,c),r==null||r.handlers.delete(c)),c.onPointerExit&&((u=i.event)==null?void 0:u.pointerType)===mw.Touch&&(this.handlePointerExit(c,i),this.hoveredByID.delete(i.pointerId))),i.isClick&&c.onPointerClick&&c.onPointerClick(i)))}),i.isUp&&(r==null||r.handlers.forEach(l=>{this.invokeOnPointerUp(i,l)}),this.pressedByID.delete(i.pointerId))}propagatePointerExit(t,i,n){this.propagate(t,r=>{if(!r.gameObject||r.destroyed)return;const o=r;if(o.onPointerExit){if(n&&this.isChild(n,r.gameObject))return;this.handlePointerExit(o,i)}})}invokeOnPointerUp(t,i){var n;(n=i.onPointerUp)==null||n.call(i,t),this.releasePointerCapture(t,i)}handlePointerEnter(t,i){t.onPointerEnter&&this.updatePointerState(t,i.pointerId,this.pointerEnterSymbol,!0)&&t.onPointerEnter(i),this.updatePointerState(t,i.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(t,i){t.onPointerExit&&this.updatePointerState(t,i.pointerId,this.pointerExitSymbol,!0)&&t.onPointerExit(i),this.updatePointerState(t,i.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(t,i,n,r){let o=t[n];if(r)return o&&o.includes(i)?!1:(o=o||[],o.push(i),t[n]=o,!0);{if(!o||!o.includes(i))return!1;const a=o.indexOf(i);return a!==-1&&o.splice(a,1),!0}}handlePointerCapture(t,i){if(t.z__pointer_ctured){t.z__pointer_ctured=!1;const n=t.pointerId;if(i.onPointerMove){const r=this._capturedPointer[n]||[];r.push(i),this._capturedPointer[n]=r}else gt()&&!i.z__warned_no_pointermove&&(i.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else t.z__pointer_cture_rleased&&(t.z__pointer_cture_rleased=!1,this.releasePointerCapture(t,i))}releasePointerCapture(t,i){const n=t.pointerId;if(this._capturedPointer[n]){const r=this._capturedPointer[n].indexOf(i);r!==-1&&(this._capturedPointer[n].splice(r,1),Vl&&console.log("released pointer capture",n,i,this._capturedPointer))}}invokePointerCapture(t){var i;if(t.event.type===en.PointerMove){const n=t.pointerId,r=this._capturedPointer[n];if(r){Vl&&console.log("Captured",n,r);for(let o=0;o<r.length;o++){const a=r[o];if(a.destroyed){r.splice(o,1),o--;continue}(i=a.onPointerMove)==null||i.call(a,t)}}}}isChild(t,i){return!t||!i?!1:t===i?!0:t.parent?this.isChild(t.parent,i):!1}handleMeshUiObjectWithoutShadowDom(t,i){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,i)}handleMeshUIIntersection(t,i){const n=gh.updateState(t,i);return n&&this.currentActiveMeshUIComponents.push(n),n!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&gh.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const i=this.currentActiveMeshUIComponents[t];gh.resetState(i)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?oe.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let Vr=Ka;h(Vr,"_eventSystemMap",new Map),h(Vr,"didSearchEventSystem",!1);class gh{static markDirty(){this.needsUpdate=!0}static update(e,t,i=!1){if(i){e.update();return}const n=t.time.frameCount;for(const r of this.lastUpdateFrame)if(r.context===t){if(n===r.frame)return;r.frame=n;let o=this.needsUpdate||n<1;r.nextUpdate===t.time.frameCount&&(o=!0),o&&(Vl&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:n,nextUpdate:n}],e.update()}static updateState(e,t){let i=null;if(e&&(i=this.findBlockInParent(e),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}h(gh,"lastSelected",null),h(gh,"lastUpdateFrame",[]),h(gh,"needsUpdate",!1);var zie=Object.defineProperty,Gie=Object.getOwnPropertyDescriptor,Cn=(s,e,t,i)=>{for(var n=i>1?void 0:i?Gie(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&zie(e,t,n),n};const Hie=ne("debugorbit"),W0=ne("freecam"),sg=ne("debugcamerafit"),j0=ne("smoothcam"),Qie={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let KC;class Jv extends CustomEvent{constructor(e,t){super("target-reached",{detail:{controls:e,type:t}})}}class Ci extends Me{constructor(){super(...arguments);h(this,"autoTarget",!0);h(this,"autoFit",!1);h(this,"enableRotate",!0);h(this,"autoRotate",!1);h(this,"autoRotateSpeed",1);h(this,"minAzimuthAngle",1/0);h(this,"maxAzimuthAngle",1/0);h(this,"minPolarAngle",0);h(this,"maxPolarAngle",Math.PI);h(this,"enableKeys",!0);h(this,"enableDamping",!0);h(this,"dampingFactor",.1);h(this,"enableZoom",!0);h(this,"minZoom",0);h(this,"maxZoom",1/0);h(this,"enablePan",!0);h(this,"lookAtConstraint",null);h(this,"lookAtConstraint01",1);h(this,"allowInterrupt",!0);h(this,"middleClickToFocus",!0);h(this,"doubleClickToFocus",!0);h(this,"useSlerp",!0);h(this,"debugLog",!1);h(this,"targetLerpDuration",1);h(this,"_controls",null);h(this,"_cameraObject",null);h(this,"_lookTargetLerpActive",!1);h(this,"_lookTargetStartPosition",new w);h(this,"_lookTargetEndPosition",new w);h(this,"_lookTargetLerp01",0);h(this,"_lookTargetLerpDuration",0);h(this,"_cameraLerpActive",!1);h(this,"_cameraStartPosition",new w);h(this,"_cameraEndPosition",new w);h(this,"_cameraLerp01",0);h(this,"_cameraLerpDuration",0);h(this,"_inputs",0);h(this,"_enableTime",0);h(this,"_startedListeningToKeyEvents",!1);h(this,"_eventSystem");h(this,"_afterHandleInputFn");h(this,"_camera",null);h(this,"_syncedTransform");h(this,"_didStart",!1);h(this,"_didSetTarget",!1);h(this,"targetElement",null);h(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});h(this,"_shouldDisable",!1);h(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(t){var i;(i=this.controls)==null||i.addEventListener("start",t)}get targetLerpSpeed(){return 5}set targetLerpSpeed(t){this.targetLerpDuration=1/t}awake(){this._didStart=!1,this._didSetTarget=!1,this._startedListeningToKeyEvents=!1}start(){this._didStart=!0,this._eventSystem=Vr.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(OM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var t,i;(t=this._controls)==null||t.dispose(),(i=this._eventSystem)==null||i.removeEventListener(OM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const t=oe.getComponent(this.gameObject,zi);this._camera=t;let i=t==null?void 0:t.cam;if(!i&&this.gameObject instanceof Gt&&(i=this.gameObject),i&&IM(i,this,!0),!this._controls&&i instanceof Gt){this._cameraObject=i;const n=this.targetElement??this.context.renderer.domElement,r=i==null?void 0:i.quaternion.clone();this._controls=new pie(i,n),i==null||i.quaternion.copy(r),KC===void 0&&(KC={...this._controls.keys})}this._controls&&(W0&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,Mo()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(i==null?void 0:i.type)==="PerspectiveCamera"?W0||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):W0||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=oe.getComponent(this.gameObject,zh)??void 0}onDisable(){var t;(t=this._camera)!=null&&t.cam&&IM(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(t){t.detail.args.pointerId===0&&(t.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!t.detail.args.isPressed||t.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var i,n;if(!this._controls)return;if(this._cameraObject!==this.context.mainCamera){this._controls.enabled=!1;return}this._controls.enabled=!0,this.__handleSetTargetWhenBecomingActiveTheFirstTime(),(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&((i=this.context.input.getPointerPositionDelta(0))!=null&&i.length())||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0;let t=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(t||(t=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),t&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new Jv(this,"camera"));else{const r=et.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,r)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new Jv(this,"lookat"));else{const r=et.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,r)}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?KC:Qie,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,this._controls.minAzimuthAngle=this.minAzimuthAngle,this._controls.maxAzimuthAngle=this.maxAzimuthAngle,this._controls.minPolarAngle=this.minPolarAngle,this._controls.maxPolarAngle=this.maxPolarAngle,typeof j0=="number"||j0===!0){this._controls.enableDamping=!0;const r=typeof j0=="number"?j0:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,r))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!W0&&((n=this.lookAtConstraint)!=null&&n.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),Hie&&bt.DrawWireSphere(this._controls.target,.1,65280))}}__handleSetTargetWhenBecomingActiveTheFirstTime(){if(!this._didSetTarget&&(this._didSetTarget=!0,this.autoTarget)){const t=oe.getComponent(this.gameObject,zi);if(t&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const n=Nt(t.cam).length(),r=new w(0,0,-n).applyMatrix4(t.cam.matrixWorld);this.setLookTargetPosition(r,!0)}if(!this.autoFit&&!this.setLookTargetFromConstraint()){const i=new ia;i.screenPoint=new te(0,0),i.lineThreshold=.1;const n=this.context.physics.raycast(i);n.length>0&&this.setLookTargetPosition(n[0].point,!0),sg&&console.log("OrbitControls hits",...n)}this.autoFit&&this.fitCamera()}}setCameraAndLookTarget(t){if(!t||!(t instanceof me))return;const i=Nt(t),n=FI(t);this.setTargetFromRaycast(new qr(i,n)),this.setCameraTargetPosition(i)}setCameraTargetPosition(t,i=!1){var n,r;t&&(t instanceof me&&(t=Nt(t)),this._cameraEndPosition||(this._cameraEndPosition=new w),this._cameraEndPosition.copy(t),i===!0?(this._cameraLerpActive=!1,(n=this.controllerObject)==null||n.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((r=this._cameraObject)==null?void 0:r.position),typeof i=="number"?this._cameraLerpDuration=i:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(t=null,i=!1){this._controls&&t&&(t instanceof me&&(t=Nt(t)),this._lookTargetEndPosition.copy(t),i===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof i=="number"?this._lookTargetLerpDuration=i:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(t=0,i=1){var r;if(!this._controls)return!1;const n=(r=this.lookAtConstraint)==null?void 0:r.sources;if(n&&n.length>0){const o=n[t];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,i),!0}return!1}lerpTarget(t,i){return this.lerpLookTarget(t,i)}lerpLookTarget(t,i){this._controls&&(i>=1?this._controls.target.copy(t):this._controls.target.lerp(t,i))}setTargetFromRaycast(t){if(!this.controls)return;const i=t?this.context.physics.raycastFromRay(t):this.context.physics.raycast();for(const n of i)if(n.distance>0&&oe.isActiveInHierarchy(n.object)){const r=TR(n.object);if(r){const o=r.canvas;if(o!=null&&o.screenspace)break}this.setLookTargetPosition(n.point);break}}fitCamera(t,i=void 0,n=!0){if(this.context.isInXR)return;i==null&&(i=1.1);const r=this._cameraObject,o=this._controls;if(t!=null&&t.length||(t=this.context.scene.children),t.length<=0){console.warn("No objects to fit camera to...");return}if(!r||!o){console.warn("No camera or controls found to fit camera to objects...");return}const a=new w,l=new w,c=new Ai;c.makeEmpty();const u=[];function d(E){let T=!0;if(E.visible&&K4(E)!==!1&&!(E.type==="TransformControlsGizmo"||E.type==="TransformControlsPlane")&&(E instanceof T1&&(T=!1),E instanceof Zx&&(T=!1),E instanceof Y4&&(T=!1),E.material instanceof Qx&&(T=!1),E instanceof de||(T=!1),E!==r&&E.isUI!==!0)){if(T){sg&&console.log(E.name,E.type,E);const C=E.children;E.children=u;const P=E.position,S=E.scale;if(Number.isNaN(P.x)||Number.isNaN(P.y)||Number.isNaN(P.z)){console.warn(`Object "${E.name}" has NaN values in position or scale.... will ignore it`,P,S);return}c.expandByObject(E,!0),E.children=C}for(const C of E.children)d(C)}}let f=!1;for(const E of t)E&&(f=!0,E.updateMatrixWorld(),d(E));if(!f){console.warn("No objects to fit camera to...");return}if(r.updateMatrixWorld(),r.updateProjectionMatrix(),c.getCenter(l),c.applyMatrix4(r.matrixWorldInverse),c.getSize(a),c.setFromCenterAndSize(l,a),Number.isNaN(a.x)||Number.isNaN(a.y)||Number.isNaN(a.z)){console.warn("Camera fit size resultet in NaN",r,c,[...t]);return}if(a.length()<=1e-10){sg&&console.warn("Camera fit size is zero",c,[...t]);return}const p=r.fov,m=2*Math.atan(Math.tan(p*Math.PI/360/2)*r.aspect)/Math.PI*360,A=a.y/(2*Math.atan(Math.PI*p/360)),g=a.x/(2*Math.atan(Math.PI*m/360)),v=i*Math.max(A,g)+a.z/2;sg&&console.log("Fit camera to objects",A,g,"distance",v),o.maxDistance=v*10,o.minDistance=v*.01;const _=.05,y=l.clone();y.y-=a.y*_,this.setLookTargetPosition(y,n),this.autoTarget=!1,r.near=v/1e3,r.far=v*100,r.updateMatrixWorld(),r.updateProjectionMatrix();const b=Nt(r),M=l.clone();if(M.sub(b),M.y=0,M.normalize(),M.multiplyScalar(v),M.y+=-_*4*a.y,r.parent){const E=r.parent.worldToLocal(l.clone().sub(M));this.setCameraTargetPosition(E,n)}else console.error(`Can not fit camera ${r.name} because it has no parent`);if(sg){const E=new T1(c);this.context.scene.add(E),zI(E,MA(r)),setTimeout(()=>{this.context.scene.remove(E)},1e4),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",T=>{T.code==="KeyF"&&this.fitCamera(t,i,n)}))}o.update()}}Cn([x()],Ci.prototype,"autoTarget",2);Cn([x()],Ci.prototype,"autoFit",2);Cn([x()],Ci.prototype,"enableRotate",2);Cn([x()],Ci.prototype,"autoRotate",2);Cn([x()],Ci.prototype,"autoRotateSpeed",2);Cn([x()],Ci.prototype,"minAzimuthAngle",2);Cn([x()],Ci.prototype,"maxAzimuthAngle",2);Cn([x()],Ci.prototype,"minPolarAngle",2);Cn([x()],Ci.prototype,"maxPolarAngle",2);Cn([x()],Ci.prototype,"enableKeys",2);Cn([x()],Ci.prototype,"enableDamping",2);Cn([x()],Ci.prototype,"dampingFactor",2);Cn([x()],Ci.prototype,"enableZoom",2);Cn([x()],Ci.prototype,"minZoom",2);Cn([x()],Ci.prototype,"maxZoom",2);Cn([x()],Ci.prototype,"enablePan",2);Cn([x(Ld)],Ci.prototype,"lookAtConstraint",2);Cn([x()],Ci.prototype,"lookAtConstraint01",2);Cn([x()],Ci.prototype,"allowInterrupt",2);Cn([x()],Ci.prototype,"middleClickToFocus",2);Cn([x()],Ci.prototype,"doubleClickToFocus",2);Cn([x()],Ci.prototype,"targetLerpDuration",2);var Vie=Object.defineProperty,Wie=Object.getOwnPropertyDescriptor,Xr=(s,e,t,i)=>{for(var n=i>1?void 0:i?Wie(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Vie(e,t,n),n},Sd=(s=>(s[s.Skybox=1]="Skybox",s[s.SolidColor=2]="SolidColor",s[s.Uninitialized=4]="Uninitialized",s))(Sd||{});const Kl=ne("debugcam"),jO=ne("debugscreenpointtoray");var __;const Bg=(__=class extends Me{constructor(){super(...arguments);h(this,"_nearClipPlane",.1);h(this,"_farClipPlane",1e3);h(this,"orthographic",!1);h(this,"orthographicSize",5);h(this,"ARBackgroundAlpha",0);h(this,"_cullingMask",4294967295);h(this,"_backgroundBlurriness",0);h(this,"_backgroundIntensity",1);h(this,"_environmentIntensity");h(this,"_targetTexture",null);h(this,"_backgroundColor");h(this,"_fov");h(this,"_cam",null);h(this,"_clearFlags",2);h(this,"_skybox");h(this,"_frustum");h(this,"_projScreenMatrix",new we)}get isCamera(){return!0}get aspect(){return this._cam instanceof Gt?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(e){this._cam instanceof Gt&&this._cam.aspect!==e&&(this._cam.aspect=e,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof Gt?this._cam.fov:this._fov}set fieldOfView(e){const t=this.fieldOfView!=e;if(this._fov=e,t&&this._cam&&this._cam instanceof Gt){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(e){const t=this._nearClipPlane!=e;this._nearClipPlane=e,this._cam&&t&&(this._cam.near=e,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(e){const t=this._farClipPlane!=e;this._farClipPlane=e,this._cam&&t&&(this._cam.far=e,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(e){e!==this._clearFlags&&(this._clearFlags=e,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(e){this._cullingMask=e,this._cam&&(this._cam.layers.mask=e)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(e){this.cullingMask=(1<<e|0)>>>0}set backgroundBlurriness(e){e!==this._backgroundBlurriness&&(e===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(e,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(e){e!==this._backgroundIntensity&&(e===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(e,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(e){this._environmentIntensity=e}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(e){if(e){if(this._backgroundColor)this._backgroundColor.copy(e);else{if(!e.clone)return;this._backgroundColor=e.clone()}e.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(e){this._targetTexture=e}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(e,t,i){const n=this.cam,r=Bg._origin;r.set(e,t,-1),this.context.input.convertScreenspaceToRaycastSpace(r),jO&&console.log("screenPointToRay",e.toFixed(2),t.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(n);const o=Bg._direction.set(r.x,r.y,r.z),a=Nt(n);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new qr(a.clone(),o.clone())}getFrustum(){return this._frustum||(this._frustum=new md,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new md),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(e,t){return t&&this._projScreenMatrix.multiplyMatrices(this.cam.projectionMatrix,this.cam.matrixWorldInverse),e===this._projScreenMatrix?e:e.copy(this._projScreenMatrix)}awake(){jO&&window.addEventListener("pointerdown",e=>{const t=e.clientX,i=e.clientY;console.log("touch",t.toFixed(2),i.toFixed(2));const n=this.screenPointToRay(t,i),r="#"+Math.floor(Math.random()*16777215).toString(16);bt.DrawRay(n.origin,n.direction,r,10)})}onEnable(){Kl&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Sd[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),qie(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._frustum&&this.updateFrustum(),this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const e=this.context.renderer;if(e){const t=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,e),t==null||t.applyClearFlags()}}}buildCamera(){if(this._cam)return;const e=this.gameObject.isCamera;let t=null;if(e?(t=this.gameObject,t==null||t.layers.enableAll(),t instanceof Gt&&(this._fov=t.fov)):t=this.gameObject.children[0],t&&t.isCamera)t instanceof Gt&&(this._fov&&(t.fov=this._fov),t.near=this._nearClipPlane,t.far=this._farClipPlane,t.updateProjectionMatrix());else if(!this.orthographic)t=new Gt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(t.fov=this.fieldOfView),this.gameObject.add(t);else{const i=this.orthographicSize*100;t=new Cc(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(t)}this._cam=t,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){Kl&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,Kl){const e=`Camera "${this.name}" clear flags: ${Sd[this._clearFlags]}`;console.debug(e)}switch(this._clearFlags){case 1:if(Bg.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:Kl&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0?this.context.scene.backgroundIntensity=this._backgroundIntensity:Kl&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let e=this._backgroundColor.alpha;Bg.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}else Kl&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new jie(this)),this._skybox.enable()}static backgroundShouldBeTransparent(e){var r,o,a,l;const t=(r=e.renderer.xr)==null?void 0:r.getSession();if(!t)return!1;if(typeof t._transparent=="boolean")return t._transparent;const i=t.environmentBlendMode;Kl&&tn("Environment blend mode: "+i+" on "+navigator.userAgent);let n=i==="additive"||i==="alpha-blend";return e.isInAR&&i==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(a=navigator.userAgent)!=null&&a.includes("Mozilla")&&((l=navigator.userAgent)!=null&&l.includes("Mobile WebXRViewer/v2")))&&(n=!0),t._transparent=n,n}},h(__,"_origin",new w),h(__,"_direction",new w),__);let zi=Bg;Xr([x()],zi.prototype,"aspect",1);Xr([x()],zi.prototype,"fieldOfView",1);Xr([x()],zi.prototype,"nearClipPlane",1);Xr([x()],zi.prototype,"farClipPlane",1);Xr([x()],zi.prototype,"clearFlags",1);Xr([x()],zi.prototype,"orthographic",2);Xr([x()],zi.prototype,"orthographicSize",2);Xr([x()],zi.prototype,"ARBackgroundAlpha",2);Xr([x()],zi.prototype,"cullingMask",1);Xr([x()],zi.prototype,"backgroundBlurriness",1);Xr([x()],zi.prototype,"backgroundIntensity",1);Xr([x()],zi.prototype,"environmentIntensity",1);Xr([x(wi)],zi.prototype,"backgroundColor",1);Xr([x(Rh)],zi.prototype,"targetTexture",1);class jie{constructor(e){h(this,"_camera");h(this,"_skybox");this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(Kl&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=Jo,this.context.scene.background=this._skybox):(this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background)),(Kl||gt())&&dn(`Camera "${this._camera.name}" has no skybox texture`))}}function qie(s){ne("freecam")&&s.context.mainCameraComponent===s&&oe.getOrAddComponent(s.gameObject,Ci)}class Ph extends Me{constructor(){super(...arguments);h(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new CU),this._listener}awake(){fn.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const t=this.listener;if(t==null||t.parent)return;const i=this.context.mainCameraComponent||oe.getComponentInParent(this.gameObject,zi);i!=null&&i.cam?i.cam.add(t):this.gameObject.add(t)})}}var Xie=Object.defineProperty,Yie=Object.getOwnPropertyDescriptor,Tw=(s,e,t,i)=>{for(var n=i>1?void 0:i?Yie(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Xie(e,t,n),n};const Jie=ne("debugsignals");class WA{constructor(){h(this,"guid")}}Tw([x()],WA.prototype,"guid",2);class cm{constructor(){h(this,"signal");h(this,"reaction")}}Tw([x(WA)],cm.prototype,"signal",2);Tw([x($n)],cm.prototype,"reaction",2);var kE;const Wl=(kE=class extends Me{constructor(){super(...arguments);h(this,"events")}static invoke(e){if(Wl.receivers[e]){const t=Wl.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}awake(){Jie&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)Wl.receivers[e.signal.guid]||(Wl.receivers[e.signal.guid]=[]),Wl.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(Wl.receivers[e.signal.guid]){const t=Wl.receivers[e.signal.guid].indexOf(this);t>=0&&Wl.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;const t=typeof e=="object"?e.guid:e;for(const i of this.events)if(i.signal.guid===t)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(n){console.error(n)}}},h(kE,"receivers",{}),kE);let hm=Wl;Tw([x(cm)],hm.prototype,"events",2);var so=(s=>(s.Activation="ActivationTrack",s.Animation="AnimationTrack",s.Audio="AudioTrack",s.Control="ControlTrack",s.Marker="MarkerTrack",s.Signal="SignalTrack",s))(so||{}),Ja=(s=>(s[s.None=0]="None",s[s.Hold=1]="Hold",s[s.Loop=2]="Loop",s[s.PingPong=3]="PingPong",s[s.Continue=4]="Continue",s))(Ja||{}),IR=(s=>(s.Signal="SignalEmitter",s))(IR||{});const hl=ne("debugtimeline");class jA{constructor(){h(this,"director");h(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,i,n=!0){if(t<0||t>=i.length)return 0;const r=i[t];if(n||e>=r.start&&e<=r.end){let o=1;const a=!1;if(r.easeInDuration>0){const l=Math.min((e-r.start)/r.easeInDuration,1);o*=l}if(r.easeOutDuration>0&&!a){const l=Math.min((r.end-e)/r.easeOutDuration,1);o*=l}return o}return 0}}class Kie{constructor(e){h(this,"clip");h(this,"rootPositionOffset");h(this,"rootQuaternionOffset");h(this,"rootStartPosition");h(this,"rootEndPosition");h(this,"rootStartQuaternion");h(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const i=e.getRoot(),n=i.name+".position",r=i.name+".quaternion";hl&&console.log(t.name,t.tracks,n);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(n))this.rootStartPosition=new w().fromArray(o.values,0),this.rootEndPosition=new w().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),hl&&console.log(this.rootPositionOffset);else if(o.name.endsWith(r)&&(this.rootStartQuaternion=new Ce().fromArray(o.values,0),this.rootEndQuaternion=new Ce().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),hl)){const a=new Wi().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Iw extends jA{constructor(){super(...arguments);h(this,"models",[]);h(this,"trackOffset");h(this,"target");h(this,"mixer");h(this,"clips",[]);h(this,"actions",[]);h(this,"_actionOffsets",[]);h(this,"_didBind",!1);h(this,"_animator",null);h(this,"_useclipOffsets",!0);h(this,"_totalOffsetPosition",new w);h(this,"_totalOffsetRotation",new Ce);h(this,"_totalOffsetPosition2",new w);h(this,"_totalOffsetRotation2",new Ce);h(this,"_summedPos",new w);h(this,"_tempPos",new w);h(this,"_summedRot",new Ce);h(this,"_tempRot",new Ce);h(this,"_clipRotQuat",new Ce)}onStateChanged(){this._animator&&qO(this._animator.gameObject,this,this.director.isPlaying)}createHooks(t,i){var u,d;if(((u=i.tracks)==null?void 0:u.length)<=0){console.warn("No tracks in AnimationClip",i);return}const n=i.tracks[0].name.split("."),r=n[n.length-2],o=r+".position",a=r+".quaternion";let l=!1,c=!1;for(const f of i.tracks)f.name.endsWith(o)?(l=!0,this.createPositionInterpolant(i,t,f)):f.name.endsWith(a)&&(c=!0,this.createRotationInterpolant(i,t,f));if(!l||!c){const f=(d=this.mixer)==null?void 0:d.getRoot(),p=i.tracks[0],m=p.name.lastIndexOf("."),A=p.name.substring(0,m),g=A.substring(A.lastIndexOf(".")+1),v=f.getObjectByName(g);if(v)if(l){if(!c){const _=i.tracks[0].name.substring(0,m)+".quaternion";hl&&console.warn("Create quaternion track",g,v);const y=v.quaternion,b=new _l(_,[0,i.duration],[y.x,y.y,y.z,y.w,y.x,y.y,y.z,y.w]);i.tracks.push(b),this.createRotationInterpolant(i,t,b)}}else{const _=A+".position";hl&&console.warn("Create position track",g,v);const y=v.position,b=new bc(_,[0,i.duration],[y.x,y.y,y.z,y.x,y.y,y.z]);i.tracks.push(b),this.createPositionInterpolant(i,t,b)}}}bind(){if(!this._didBind){this._didBind=!0,hl&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const t of this.actions){const i=new Kie(t);this._actionOffsets.push(i)}this.target&&(this._animator=oe.getComponent(this.target,ks)??null,this._animator&&qO(this._animator.gameObject,this,!0));for(const t of this.models){const i=t.asset,n=i.position,r=i.rotation;n&&n.x!==void 0&&(n.isVector3||(i.position=new w(n.x,n.y,n.z)),r.isQuaternion||(i.rotation=new Ce(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const t=this.trackOffset.position;t&&(t.isVector3||(this.trackOffset.position=new w(t.x,t.y,t.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new Ce(i.x,i.y,i.z,i.w)))}}evaluate(t){var l,c,u,d,f,p,m;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let i=0,n=0,r=!1,o=!1,a=0;for(let A=0;A<this.clips.length;A++){const g=this.models[A],v=this.actions[A],_=g.asset;v.weight=0;const y=t>=g.start&&t<=g.end,b=g.preExtrapolationMode,M=g.postExtrapolationMode,E=A<this.clips.length-1?this.models[A+1]:null;let T=y,C=!1;if(!T&&!r&&g.end<t&&M!==Ja.None?(!E||E.start>t)&&(T=!0,r=!0):A==0&&!T&&!o&&g.start>t&&b!==Ja.None&&(!E||E.start<t)&&(T=!0,C=!0,o=!0),T){let P=1;P*=this.evaluateWeight(t,A,this.models,T),P*=this.director.weight;let S=y;if(C)switch(b){case Ja.Hold:break;case Ja.Loop:t+=g.start,S=!0;break;default:t+=g.start,S=!0;break}let I=this.getClipTime(t,g),H=0;const U=_.duration;if(C&&b===Ja.Hold&&(I=0),S){if(_.loop)for(H+=Math.floor(I/(U+1e-6));I>U;)I-=U}else if(!y&&r)switch(M){case Ja.Hold:I=this.getClipTime(g.end,g);break;case Ja.Loop:I%=U;break;case Ja.PingPong:const L=Math.floor(I/U)%2!==0;I%=U,L&&(I=U-I);break}g.reversed===!0?v.time=v.getClip().duration-I:v.time=I,v.timeScale=0;const D=Math.max(0,P);if(v.weight=D,a+=D,v.clampWhenFinished=!1,v.isRunning()||v.play(),this._useclipOffsets){const V=i==0?this._totalOffsetPosition:this._totalOffsetPosition2,L=i==0?this._totalOffsetRotation:this._totalOffsetRotation2;i<1&&(n=1-P),i+=1;const k=this._summedPos.set(0,0,0),G=this._tempPos.set(0,0,0),Y=this._summedRot.identity(),K=this._tempRot.identity(),re=_.rotation;re&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(re,P));const ce=this._actionOffsets[A];if(ce.hasOffsets)for(let Re=0;Re<H;Re++)ce.rootPositionOffset?G.copy(ce.rootPositionOffset):G.set(0,0,0),G.applyQuaternion(Y),this._clipRotQuat&&G.applyQuaternion(this._clipRotQuat),ce.rootQuaternionOffset&&(K.copy(ce.rootQuaternionOffset),Y.multiply(K)),k.add(G);this._clipRotQuat&&L.multiply(this._clipRotQuat),L.multiply(Y),_.position&&k.add(_.position),V.add(k)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,n),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,n)),this.__mixerError===void 0&&(hl||gt())&&((c=(l=this._animator)==null?void 0:l.runtimeAnimatorController)!=null&&c.mixer)&&this.mixer!==((d=(u=this._animator)==null?void 0:u.runtimeAnimatorController)==null?void 0:d.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(f=this._animator)!=null&&f.runtimeAnimatorController){const A=Math.max(0,1-a);(m=(p=this._animator)==null?void 0:p.runtimeAnimatorController)==null||m.update(A)}else this.mixer.update(t)}createRotationInterpolant(t,i,n){var l;const r=n.createInterpolant.bind(n),o=new Ce;this.ensureTrackOffsets();const a=(l=this.trackOffset)==null?void 0:l.rotation;n.createInterpolant=()=>{const c=r(),u=c.evaluate.bind(c);return c.evaluate=d=>{var p;const f=u(d);if(o.set(f[0],f[1],f[2],f[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const m of this.director.animationCallbackReceivers)(p=m==null?void 0:m.onTimelineRotation)==null||p.call(m,this.director,this.target,d,o);return f[0]=o.x,f[1]=o.y,f[2]=o.z,f[3]=o.w,f},c}}createPositionInterpolant(t,i,n){var u,d;const r=n.createInterpolant.bind(n),o=new w;this.ensureTrackOffsets();const a=(u=this.trackOffset)==null?void 0:u.rotation,l=(d=this.trackOffset)==null?void 0:d.position;let c;n.createInterpolant=()=>{const f=r(),p=f.evaluate.bind(f);return f.evaluate=m=>{var g,v,_;const A=p(m);if(o.set(A[0],A[1],A[2]),i.removeStartOffset&&(c===void 0?(c=null,c=(v=(g=this._actionOffsets.find(y=>y.clip===t))==null?void 0:g.rootStartPosition)==null?void 0:v.clone()):c!=null&&c.isVector3&&o.sub(c)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),a&&o.applyQuaternion(a),l&&(o.x-=l.x,o.y+=l.y,o.z+=l.z),this.director.animationCallbackReceivers)for(const y of this.director.animationCallbackReceivers)(_=y==null?void 0:y.onTimelinePosition)==null||_.call(y,this.director,this.target,m,o);return A[0]=o.x,A[1]=o.y,A[2]=o.z,A},f}}}const Zie=ne("mutetimeline"),dp=class extends jA{constructor(){super(...arguments);h(this,"models",[]);h(this,"listener");h(this,"audio",[]);h(this,"audioContextTimeOffset",[]);h(this,"lastTime",0);h(this,"audioSource");h(this,"_audioLoader",null);h(this,"_playableDirectorResumed",!1)}getAudioFilePath(t){const i=this.director.sourceId;return Mc(i,t)}onAllowAudioChanged(t){for(let i=0;i<this.models.length;i++){const n=this.models[i];this.audio[i].setVolume(t?n.asset.volume:0)}}addModel(t){const i=new $T(this.listener);this.audio.push(i);const n=t;n._didTriggerPlay=!1,this.models.push(n)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop();for(const t of this.models)t._didTriggerPlay=!1}onDestroy(){for(const t of this.audio)t.source&&(t==null||t.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}for(const t of this.models)t._didTriggerPlay=!1}onPauseChanged(){for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(t){if(Zie||this.track.muted||this.director.speed<0)return;const i=this.director.context.application.muted,n=this._playableDirectorResumed;this._playableDirectorResumed=!1;const r=i?.1:0;for(let o=0;o<this.models.length;o++){const a=this.models[o],l=this.audio[o],c=a.asset;if((!l||!l.buffer)&&this.isInTimeRange(a,t-1,t+1)&&this.handleAudioLoading(a,l),fn.userInteractionRegistered!==!1&&!(l===null||!l.buffer))if(l.playbackRate=this.director.context.time.timeScale*this.director.speed,l.loop=c.loop,t>=a.start&&t<=a.end&&t<this.director.duration){if(!l.isPlaying||!this.director.isPlaying)(n||!a._didTriggerPlay&&this.lastTime<t)&&(a.duration*a.timeScale>.3?l.offset=a.clipIn+(t-a.start)*a.timeScale:l.offset=0,hl&&console.log("Timeline Audio ("+this.track.name+") play with offset "+l.offset+" - "+a.asset.clip),l.play(r),a._didTriggerPlay=!0);else{const d=a.clipIn+(t-a.start)*a.timeScale,f=l.context.currentTime-l._startedAt+l.offset;Math.abs(d-f)>.3&&(l.offset=d,l.stop(),l.play(r))}let u=c.volume;if(this.track.volume!==void 0&&(u*=this.track.volume),i&&(u=0),a.easeInDuration>0){const d=Math.min((t-a.start)/a.easeInDuration,1);u*=d}if(a.easeOutDuration>0){const d=Math.min((a.end-t)/a.easeOutDuration,1);u*=d}l.setVolume(u*this.director.weight)}else a._didTriggerPlay=!1,this.director.isPlaying&&l.isPlaying&&l.stop()}this.lastTime=t}loadAudio(t,i=0,n=0){let r=null;const o=t-n,a=t+i;for(const l of this.models)if(this.isInTimeRange(l,o,a)){const c=this.audio[this.models.indexOf(l)],u=this.handleAudioLoading(l,c);u!==null&&(r===null&&(r=[]),r.push(u))}return r!==null?Promise.all(r):null}isInTimeRange(t,i,n){return i<=t.start&&n>=t.end||i>=t.start&&i<=t.end||n>=t.start&&n<=t.end}static dispose(){dp._audioBuffers.clear()}handleAudioLoading(t,i){this._audioLoader||(this._audioLoader=new xb);const n=this.getAudioFilePath(t.asset.clip);if(dp._audioBuffers.get(n)){const o=dp._audioBuffers.get(n);return o.then(a=>{a&&i.setBuffer(a)}),o}hl&&console.warn("LOAD audio track",n,this.director.sourceId);const r=new Promise((o,a)=>{this._audioLoader.load(n,l=>{i.setBuffer(l),o(l)},void 0,l=>{console.error("Error loading audio",l),o(null)})});return dp._audioBuffers.set(n,r),r}};let od=dp;h(od,"_audioBuffers",new Map);class Kv extends jA{constructor(){super(...arguments);h(this,"models",[]);h(this,"didTrigger",[]);h(this,"receivers",[])}evaluate(t){var n;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.didTrigger[r],l=o.time-t;let c=!1;if(o.retroActive)c=l<=1e-6;else{const u=Math.abs(l);(u===0||u>=1e-5&&u<i)&&(c=!0)}if(c){if(!a)if(hl&&console.log("Trigger signal",t,o.time,o),this.didTrigger[r]=!0,((n=this.receivers)==null?void 0:n.length)<=0)hm.invoke(o.asset);else for(const u of this.receivers)u&&u.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class Rw extends jA{constructor(){super(...arguments);h(this,"models",[]);h(this,"timelines",[]);h(this,"_previousActiveModel",null)}resolveSourceObjects(t){for(let i=this.models.length-1;i>=0;i--){const r=this.models[i].asset;if(!r.sourceObject||typeof r.sourceObject!="object"){console.log("no source object, removing model",i,r),this.models.splice(i,1);continue}else{const o=oe.getComponent(r.sourceObject,yc);this.timelines.push(o),o&&r.updateDirector&&(o.playOnAwake=!1)}}}evaluate(t){var i;this._previousActiveModel=null;for(let n=0;n<this.models.length;n++){const r=this.models[n],o=r.asset;if(t>=r.start&&t<=r.end){this._previousActiveModel=r;const a=this.getClipTime(t,r);if(o.controlActivation){const l=o.sourceObject;l.visible=!0}if(o.updateDirector){const l=this.timelines[n];l&&(l.isPlaying&&l.pause(),l.time=a,l.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const l=o.sourceObject;(a==null?void 0:a.sourceObject)!==l&&(l.visible=!1)}}}}}const Df=ne("debugtimeline"),hx=class extends Me{constructor(){super(...arguments);h(this,"playableAsset");h(this,"playOnAwake");h(this,"extrapolationMode",1);h(this,"waitForAudio",!0);h(this,"_visibilityChangeEvt");h(this,"_clonedPlayableAsset",!1);h(this,"_speed",1);h(this,"_guidsMap");h(this,"_isPlaying",!1);h(this,"_internalUpdateRoutine");h(this,"_isPaused",!1);h(this,"_isStopping",!1);h(this,"_time",0);h(this,"_duration",0);h(this,"_weight",1);h(this,"_animationTracks",[]);h(this,"_audioTracks",[]);h(this,"_signalTracks",[]);h(this,"_controlTracks",[]);h(this,"_customTracks",[]);h(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);h(this,"animationCallbackReceivers",[])}static registerCreateTrack(t,i){this.createTrackFunctions[t]=i}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(Df||xo())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,i,n;Df&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(i=this.playableAsset)==null?void 0:i.tracks,Array.isArray((n=this.playableAsset)==null?void 0:n.tracks),this)}onEnable(){var t,i,n;for(const r of this._audioTracks)(t=r.onEnable)==null||t.call(r);for(const r of this._customTracks)(i=r.onEnable)==null||i.call(r);for(const r of this._animationTracks)(n=r.onEnable)==null||n.call(r);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,i,n;this.stop();for(const r of this._audioTracks)(t=r.onDisable)==null||t.call(r);for(const r of this._customTracks)(i=r.onDisable)==null||i.call(r);for(const r of this._animationTracks)(n=r.onDisable)==null||n.call(r);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const i of this._allTracks)for(const n of i)(t=n.onDestroy)==null||t.call(n)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,t&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const i=[];for(const n of this._audioTracks){const r=n.loadAudio(this._time,1,0);r&&i.push(r)}if(i.length>0&&(await Promise.all(i),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!fn.userInteractionRegistered&&this.waitForAudio;)await Pa(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),ji.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const n of this._audioTracks)n.stop();const t=this._isPaused==!0,i=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!i&&this.invokePauseChangedMethodsOnTracks(),i&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const i of t)yield i}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onPauseChanged)==null||t.call(i)}invokeStateChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onStateChanged)==null||t.call(i,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(t=!1){if(!this.isValid())return;let i=this._time;switch(this.extrapolationMode){case 0:this._speed>0?i=Math.min(i,this._duration):this._speed<0&&(i=Math.max(i,0)),this._time=i;break;case 1:i%=this._duration,this._time=i;break;case 2:if(i>this._duration){this.stop();return}break}const n=this._time;for(const r of this.playableAsset.tracks)if(!r.muted)switch(r.type){case so.Activation:if(!t&&!this._isPlaying)continue;for(let o=0;o<r.outputs.length;o++){const a=r.outputs[o];if(typeof a=="object"){let l=!1;if(r.clips)for(const u of r.clips)u.start<=n&&n<=u.end&&(l=!0);const c=a;c.visible!==void 0&&c.visible!==l&&(c.visible=l,Df&&console.warn(this.name,"set ActivationTrack-"+o,c.name,l,n))}}break}if(!this._isStopping)for(const r of this._animationTracks)r.evaluate(n);for(const r of this._audioTracks)r.evaluate(n);for(const r of this._signalTracks)r.evaluate(n);for(const r of this._controlTracks)r.evaluate(n);for(const r of this._customTracks)r.evaluate(n)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=xA(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const i of this.playableAsset.tracks){for(let n=i.outputs.length-1;n>=0;n--){let r=i.outputs[n];if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const o=oe.findByGuid(r,t);o===null||typeof o!="object"?(i.outputs.splice(n,1),console.warn("Failed to resolve binding",r,i.name,i.type)):(Df&&console.log("Resolved binding",r,"to",o),i.outputs[n]=o)}else if(r===null){if(i.outputs.splice(n,1),hx.createTrackFunctions[i.type])continue;i.type!==so.Audio&&i.type!==so.Control&&i.type!==so.Marker&&i.type!==so.Signal&&console.warn("Missing binding",r,i.name,i.type,this.name,this.playableAsset.name)}}if(i.type===so.Control&&i.clips)for(let n=0;n<i.clips.length;n++){const r=i.clips[n];let o=r.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const a=oe.findByGuid(o,t);a===null||typeof a!="object"?console.warn("Failed to resolve sourceObject binding",o,i.name,r):(Df&&console.log("Resolved binding",o,"to",a),r.asset.sourceObject=a)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){if(t.clips)for(const i of t.clips)i.end>this._duration&&(this._duration=i.end);if(t.markers)for(const i of t.markers)i.time>this._duration&&(this._duration=i.time+.001)}}}setupAndCreateTrackHandlers(){var i,n,r;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let t=oe.findObjectOfType(Ph,this.context);for(const o of this.playableAsset.tracks){const a=o.type,l=hx.createTrackFunctions[a];if(l!=null){const c=l(this,o);if(typeof c.evaluate=="function"){c.director=this,c.track=o,this._customTracks.push(c);continue}}if(o.type===so.Animation){if(!o.clips||o.clips.length<=0){Df&&console.warn("Animation track has no clips",o);continue}for(let c=o.outputs.length-1;c>=0;c--){let u=o.outputs[c];if(u instanceof me){const f=oe.getOrAddComponent(u,ks);f&&(u=f)}const d=(i=u==null?void 0:u.gameObject)==null?void 0:i.animations;if(d){const f=new Iw;f.trackOffset=o.trackOffset,f.director=this,f.track=o;for(let p=0;p<o.clips.length;p++){const m=o.clips[p],A=m.asset;if(!A){console.error(`Timeline ${this.name}: clip #${p} on track "${o.name}" has no animation data`);continue}const g=A.clip;let v=g;if((typeof v=="string"||typeof v=="number")&&(v=d.find(y=>y.name===g)),!v){console.warn("Could not find animationClip for model",m,o.name,this.name,(n=this.playableAsset)==null?void 0:n.name);continue}u instanceof ks&&u.runtimeAnimatorController&&(u.__internalDidAwakeAndStart||u.initializeRuntimeAnimatorController(),u.runtimeAnimatorController.mixer||u.runtimeAnimatorController.bind(u),f.mixer=u.runtimeAnimatorController.mixer),f.mixer||(f.mixer=new Kx(u.gameObject)),f.clips.push(v),f.mixer.uncacheAction(v),f.createHooks(m.asset,v);const _=f.mixer.clipAction(v);f.actions.push(_),f.models.push(m)}this._animationTracks.push(f)}}}else if(o.type===so.Audio){if(!o.clips||o.clips.length<=0)continue;const c=new od;c.director=this,c.track=o,c.audioSource=o.outputs.find(u=>u instanceof fn),this._audioTracks.push(c),t||(t=(r=this.context.mainCameraComponent)==null?void 0:r.gameObject.addNewComponent(Ph)),c.listener=t.listener;for(let u=0;u<o.clips.length;u++){const d=o.clips[u];c.addModel(d)}}else if(o.type===so.Marker){const c=new Kv;if(c.director=this,c.track=o,o.markers)for(const u of o.markers)switch(u.type){case IR.Signal:c.models.push(u),c.didTrigger.push(!1);break}if(c!==null&&c.models.length>0){const u=oe.getComponent(this.gameObject,hm);u&&(c.receivers.push(u),this._signalTracks.push(c))}}else if(o.type===so.Signal){const c=new Kv;if(c.director=this,c.track=o,o.markers)for(const u of o.markers)c.models.push(u),c.didTrigger.push(!1);for(const u of o.outputs)c.receivers.push(u);this._signalTracks.push(c)}else if(o.type===so.Control){const c=new Rw;if(c.director=this,c.track=o,o.clips)for(const u of o.clips)c.models.push(u);c.resolveSourceObjects(this.context),this._controlTracks.push(c)}}}setAudioTracksAllowPlaying(t){for(const i of this._audioTracks)i.onAllowAudioChanged(t)}registerAnimationCallback(t){this.animationCallbackReceivers.push(t)}unregisterAnimationCallback(t){const i=this.animationCallbackReceivers.indexOf(t);i!==-1&&this.animationCallbackReceivers.splice(i,1)}};let yc=hx;h(yc,"createTrackFunctions",{});const Z_=Symbol("objectIsAnimatedData");function qO(s,e,t){if(!s)return;if(s[Z_]===void 0){if(!t)return;s[Z_]=new Set}const i=s[Z_];t?i.add(e):i.has(e)&&i.delete(e)}function $ie(s){if(!s)return!1;const e=s[Z_];return e!==void 0&&e.size>0}ri.registerCallback(bn.ContextCreated,s=>{const e=s.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true")&&s.files)for(const t of s.files)oe.foreachComponent(t.file.scene,n=>{if(n.enabled!==!1){if(n instanceof Br&&n.playAutomatically||n instanceof ks||n instanceof yc&&n.playOnAwake===!0)return!0;if(n instanceof Br)return n.playAutomatically=!0,!0;if(n instanceof yc)return n.playOnAwake=!0,!0}},!0)!==!0&&ene(t.file)});function ene(s){if(!s||!s.animations)return;for(let t=0;t<s.animations.length;t++){const i=s.animations[t];if(!(!i.tracks||i.tracks.length<=0))for(const n in i.tracks){const r=i.tracks[n],o=r.__objectName??r.name.substring(0,r.name.indexOf("."));let a=s.scene.getObjectByName(o);if(!a&&(a=s.scene.getObjectByProperty("uuid",o),!a))continue;let l=e(a);l||(l=Ih(s.scene,new Br));const c=l.animations=l.animations||[];i.name_animator=l.name,c.indexOf(i)<0&&c.push(i)}}function e(t){var n;if(!t)return;const i=(n=t.userData)==null?void 0:n.components;if(i&&i.length>0)for(let r=0;r<i.length;r++){const o=i[r];if(o instanceof ks||o instanceof Br)return t}return e(t.parent)}}class tne{constructor(){h(this,"_context")}get context(){return this._context??Lt.Current}get isStateMachineBehaviour(){return!0}}class Dg{constructor(e,t,i,n){h(this,"name");h(this,"nameHash");h(this,"normalizedTime");h(this,"length");h(this,"speed");h(this,"action");this.name=e.name,this.nameHash=e.hash,this.normalizedTime=t,this.length=i,this.speed=n,this.action=e.motion.action||null}}function rG(s,e){return{name:"",isLooping:!1,guid:(e==null?void 0:e.generateUUID())??Kn.generateUUID(),index:-1,clip:new Rr(s,1,[])}}var dh=(s=>(s[s.If=1]="If",s[s.IfNot=2]="IfNot",s[s.Greater=3]="Greater",s[s.Less=4]="Less",s[s.Equals=6]="Equals",s[s.NotEqual=7]="NotEqual",s))(dh||{}),RR=(s=>(s[s.Float=1]="Float",s[s.Int=3]="Int",s[s.Bool=4]="Bool",s[s.Trigger=9]="Trigger",s))(RR||{});const vr=ne("debuganimatorcontroller"),q0=ne("debugrootmotion");class bo{constructor(e){h(this,"_speed",1);h(this,"normalizedStartOffset",0);h(this,"animator");h(this,"model");h(this,"_mixer");h(this,"_activeState");h(this,"_activeStates",[]);h(this,"rootMotionHandler");this.model=e,vr&&console.log(this)}static createFromClips(e,t={looping:!1,autoTransition:!0,transitionDuration:0}){const i=[];for(let o=0;o<e.length;o++){const a=e[o],l=[];if(t.autoTransition!==!1){const u=t.transitionDuration??0,d=u/a.duration;let f=o;(t.autoTransition===void 0||t.autoTransition===!0)&&(f=(o+1)%e.length),l.push({exitTime:1-d,offset:0,duration:u,hasExitTime:!0,destinationState:f,conditions:[]})}const c={name:a.name,hash:o,motion:{name:a.name,clip:a,isLooping:(t==null?void 0:t.looping)??!1},transitions:l,behaviours:[]};i.push(c)}const n={name:"AnimatorController",guid:new fs(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:i}}]};return new bo(n)}play(e,t=-1,i=Number.NEGATIVE_INFINITY,n=0){if(t<0)t=0;else if(t>=this.model.layers.length){console.warn("invalid layer");return}const o=this.model.layers[t].stateMachine;for(const a of o.states)if(a.name===e||a.hash===e){vr&&console.log("transition to ",a),this.transitionTo(a,n,i);return}console.warn("Could not find "+e+" to play")}reset(){this.setStartTransition()}setBool(e,t){var n,r;const i=typeof e=="string"?"name":"hash";return(r=(n=this.model)==null?void 0:n.parameters)==null?void 0:r.filter(o=>o[i]===e).forEach(o=>o.value=t)}getBool(e){var i,n,r;const t=typeof e=="string"?"name":"hash";return((r=(n=(i=this.model)==null?void 0:i.parameters)==null?void 0:n.find(o=>o[t]===e))==null?void 0:r.value)??!1}setFloat(e,t){var r,o;const i=typeof e=="string"?"name":"hash",n=(o=(r=this.model)==null?void 0:r.parameters)==null?void 0:o.filter(a=>a[i]===e);return n.forEach(a=>a.value=t),(n==null?void 0:n.length)>0}getFloat(e){var i,n,r;const t=typeof e=="string"?"name":"hash";return((r=(n=(i=this.model)==null?void 0:i.parameters)==null?void 0:n.find(o=>o[t]===e))==null?void 0:r.value)??0}setInteger(e,t){var n,r;const i=typeof e=="string"?"name":"hash";return(r=(n=this.model)==null?void 0:n.parameters)==null?void 0:r.filter(o=>o[i]===e).forEach(o=>o.value=t)}getInteger(e){var i,n,r;const t=typeof e=="string"?"name":"hash";return((r=(n=(i=this.model)==null?void 0:i.parameters)==null?void 0:n.find(o=>o[t]===e))==null?void 0:r.value)??0}setTrigger(e){var i,n;vr&&console.log("SET TRIGGER",e);const t=typeof e=="string"?"name":"hash";return(n=(i=this.model)==null?void 0:i.parameters)==null?void 0:n.filter(r=>r[t]===e).forEach(r=>r.value=!0)}resetTrigger(e){var i,n;const t=typeof e=="string"?"name":"hash";return(n=(i=this.model)==null?void 0:i.parameters)==null?void 0:n.filter(r=>r[t]===e).forEach(r=>r.value=!1)}getTrigger(e){var i,n,r;const t=typeof e=="string"?"name":"hash";return((r=(n=(i=this.model)==null?void 0:i.parameters)==null?void 0:n.find(o=>o[t]===e))==null?void 0:r.value)??!1}isInTransition(){return this._activeStates.length>1}setSpeed(e){this._speed=e}FindState(e){return this.findState(e)}findState(e){if(!e)return null;if(Array.isArray(this.model.layers)){for(const t of this.model.layers)for(const i of t.stateMachine.states)if(i.name===e||i.hash==e)return i}return null}getCurrentStateInfo(){if(!this._activeState)return null;const e=this._activeState.motion.action;if(!e)return null;const t=this._activeState.motion.clip.duration,i=t<=0?0:Math.abs(e.time/t);return new Dg(this._activeState,i,t,this._speed)}get currentAction(){if(!this._activeState)return null;const e=this._activeState.motion.action;return e||null}get context(){var e;return(e=this.animator)==null?void 0:e.context}get mixer(){return this._mixer}bind(e){e?this.animator!==e&&(this.animator=e,this._mixer=new Kx(this.animator.gameObject),this.createActions(this.animator)):console.error("AnimatorController.bind: animator is null")}clone(){if(typeof this.model=="string")return console.warn("AnimatorController has not been resolved, can not create model from string",this.model),null;vr&&console.warn("AnimatorController clone()",this.model);const e=xA(this.model,(i,n,r)=>r==null?!0:!(r.type==="Object3D"||r.isObject3D===!0||UN(r)||r.tracks!==void 0||r instanceof bo));return console.assert(e!==this.model),new bo(e)}update(e){var i,n;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(e);const t=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((i=this.rootMotionHandler)==null||i.onBeforeUpdate(e)),this._mixer.update(t),this.animator.applyRootMotion&&((n=this.rootMotionHandler)==null||n.onAfterUpdate(e))}get activeState(){return this._activeState}updateActiveStates(e){for(let t=0;t<this._activeStates.length;t++){const i=this._activeStates[t],n=i.motion;if(!n.action)this._activeStates.splice(t,1),t--;else{const r=n.action;r.weight=e,r.getEffectiveWeight()<=0&&!r.isRunning()&&(vr&&console.debug("REMOVE",i.name,r.getEffectiveWeight(),r.isRunning(),r.isScheduled()),this._activeStates.splice(t,1),t--)}}}setStartTransition(){for(const e of this.model.layers){const t=e.stateMachine;t.defaultState===void 0&&(vr&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",e),t.defaultState=0);const i=t.states[t.defaultState];this.transitionTo(i,0,this.normalizedStartOffset)}}evaluateTransitions(){var r;let e=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;e=!0}const t=this._activeState,i=t.motion.action;for(const o of t.transitions){if(!o.hasExitTime&&o.conditions.length<=0)continue;let a=!0;for(const l of o.conditions)if(!this.evaluateCondition(l)){a=!1;break}if(a)if(i){const l=t.motion.clip.duration,c=l<=0?1:Math.abs(i.time/l);let u=!1;if(o.hasExitTime?i.timeScale>0?u=c>=o.exitTime:i.timeScale<0&&(u=1-c>=o.exitTime):u=!0,u){for(const d of o.conditions){const f=this.model.parameters.find(p=>p.name===d.parameter);(f==null?void 0:f.type)===RR.Trigger&&f.value&&(f.value=!1)}i.clampWhenFinished=!0,vr&&console.log("transition to "+o.destinationState,o,c,o.exitTime,o.hasExitTime),this.transitionTo(o.destinationState,o.duration,o.offset);return}}else{this.transitionTo(o.destinationState,o.duration,o.offset);return}}if(i){let o=t.speed??1;t.speedParameter&&(o*=this.getFloat(t.speedParameter)),o!==void 0&&(i.timeScale=o*this._speed)}let n=!1;if(t.motion.isLooping&&i&&(i.time>=i.getClip().duration?(n=!0,i.reset(),i.time=0,i.play()):i.time<=0&&i.timeScale<0&&(n=!0,i.reset(),i.time=i.getClip().duration,i.play())),!n&&t&&!e&&i&&this.animator&&t.behaviours){const o=i==null?void 0:i.getClip().duration,a=i.time/o,l=new Dg(this._activeState,a,o,this._speed);for(const c of t.behaviours)c.instance&&((r=c.instance.onStateUpdate)==null||r.call(c.instance,this.animator,l,0))}}getState(e,t){return typeof e=="number"&&(e==-1&&(e=this.model.layers[t].stateMachine.defaultState,e===void 0&&(vr&&console.warn("AnimatorController default state is undefined: ",this.model,"Layer: "+t),e=0)),e=this.model.layers[t].stateMachine.states[e]),e}transitionTo(e,t,i){var c,u,d,f,p,m,A,g;if(!this.animator)return;const n=0;if(e=this.getState(e,n),!(e!=null&&e.motion)||!e.motion.clip||!(e.motion.clip instanceof Rr))return;const r=this._activeState===e;if(r){const v=e.motion;if(!v.action_loopback&&v.clip){const _=this.rootMotionHandler?this.animator.gameObject.matrix.clone():null;this._mixer.uncacheAction(v.clip,this.animator.gameObject),_&&_.decompose(this.animator.gameObject.position,this.animator.gameObject.quaternion,this.animator.gameObject.scale),v.action_loopback=this.createAction(v.clip)}}if((c=this._activeState)!=null&&c.behaviours&&this._activeState.motion.action){const v=(u=this._activeState)==null?void 0:u.motion.clip.duration,_=this._activeState.motion.action.time/v,y=new Dg(this._activeState,_,v,this._speed);for(const b of this._activeState.behaviours)(f=(d=b.instance)==null?void 0:d.onStateExit)==null||f.call(b.instance,this.animator,y,n)}const o=(p=this._activeState)==null?void 0:p.motion.action;o&&o.fadeOut(t),r&&(e.motion.action=e.motion.action_loopback,e.motion.action_loopback=o);const a=this._activeState;this._activeState=e;const l=(m=e.motion)==null?void 0:m.action;if(l){if(i=Math.max(0,Math.min(1,i)),e.cycleOffsetParameter){let _=this.getFloat(e.cycleOffsetParameter);typeof _=="number"?(_<0&&(_+=1),i+=_,i%=1):vr&&console.warn("AnimatorController cycle offset parameter is not a number",e.cycleOffsetParameter)}else typeof e.cycleOffset=="number"&&(i+=e.cycleOffset,i%=1);l.isRunning()&&l.stop(),l.reset(),l.enabled=!0;const v=e.motion.clip.duration;if(l.time=r?0:i*v,l.timeScale<0&&(l.time=v-l.time),l.clampWhenFinished=!0,l.setLoop(bv,0),t>0?l.fadeIn(t):l.weight=1,l.play(),this.rootMotionHandler&&this.rootMotionHandler.onStart(l),this._activeStates.includes(e)||this._activeStates.push(e),this._activeState.behaviours){const _=new Dg(e,i,v,this._speed);for(const y of this._activeState.behaviours)(g=(A=y.instance)==null?void 0:A.onStateEnter)==null||g.call(y.instance,this.animator,_,n)}}else vr&&(e.__warned_no_motion||(e.__warned_no_motion=!0,console.warn("No action",e.motion,this)));vr&&console.log("TRANSITION FROM "+(a==null?void 0:a.name)+" TO "+e.name,t,o,l,l==null?void 0:l.getEffectiveTimeScale(),l==null?void 0:l.getEffectiveWeight(),l==null?void 0:l.isRunning(),l==null?void 0:l.isScheduled(),l==null?void 0:l.paused)}createAction(e){var i,n;if(this._mixer.existingAction(e)&&this._mixer.uncacheAction(e,(i=this.animator)==null?void 0:i.gameObject),(n=this.animator)!=null&&n.applyRootMotion){this.rootMotionHandler||(this.rootMotionHandler=new ine(this));const r=this.animator.gameObject;return this.rootMotionHandler.createClip(this._mixer,r,e)}else return this._mixer.clipAction(e)}evaluateCondition(e){const t=this.model.parameters.find(i=>i.name===e.parameter);if(!t)return!1;switch(e.mode){case dh.If:return t.value===!0;case dh.IfNot:return t.value===!1;case dh.Greater:return t.value>e.threshold;case dh.Less:return t.value<e.threshold;case dh.Equals:return t.value===e.threshold;case dh.NotEqual:return t.value!==e.threshold}return!1}createActions(e){var t,i,n,r;vr&&console.log("AnimatorController createActions",this.model);for(const o of this.model.layers){const a=o.stateMachine;for(let l=0;l<a.states.length;l++){const c=a.states[l];c.transitions||(c.transitions=[]);for(const u of c.transitions)u.conditions||(u.conditions=[]);if(c.motion||(c.motion=rG(c.name)),this.animator&&c.motion.clips){const u=(t=c.motion.clips)==null?void 0:t.find(d=>{var f,p;return d.node.name===((p=(f=this.animator)==null?void 0:f.gameObject)==null?void 0:p.name)});u?c.motion.clip=u.clip:(vr||gt())&&console.warn('Could not find clip for animator "'+((n=(i=this.animator)==null?void 0:i.gameObject)==null?void 0:n.name)+'"',c.motion.clips.map(d=>d.node.name))}if(!c.motion.clip){const u=new Rr(void 0,void 0,[]);c.motion.clip=u}if((r=c.motion)!=null&&r.clip){const u=c.motion.clip;if(u instanceof Rr){const d=this.createAction(u);c.motion.action=d}else(vr||gt())&&console.warn("No valid animationclip assigned",c)}if(c.behaviours&&Array.isArray(c.behaviours))for(const u of c.behaviours){if(!(u!=null&&u.typeName))continue;const d=J.get(u.typeName),f=new d;f.isStateMachineBehaviour&&(f._context=this.context??void 0,Np(f,u.properties),u.instance=f),vr&&console.log("Created animator controller behaviour",c.name,u.typeName,u.properties,f)}}}}*enumerateActions(){if(this.model.layers)for(const e of this.model.layers){const t=e.stateMachine;for(let i=0;i<t.states.length;i++){const n=t.states[i];n!=null&&n.motion&&(n.motion.action&&(yield n.motion.action),n.motion.action_loopback&&(yield n.motion.action_loopback))}}}}class XO{constructor(e,t){h(this,"track");h(this,"createdInterpolant");h(this,"originalEvaluate");h(this,"customEvaluate");this.track=e;const i=e,n=i.createInterpolant.bind(e);i.createInterpolant=()=>(i.createInterpolant=n,this.createdInterpolant=n(),this.originalEvaluate=this.createdInterpolant.evaluate.bind(this.createdInterpolant),this.customEvaluate=r=>{if(!this.originalEvaluate)return;const o=this.originalEvaluate(r);return t(r,o)},this.createdInterpolant.evaluate=this.customEvaluate,this.createdInterpolant)}dispose(){this.createdInterpolant&&this.originalEvaluate&&(this.createdInterpolant.evaluate=this.originalEvaluate),this.track=void 0,this.createdInterpolant=null,this.originalEvaluate=void 0,this.customEvaluate=void 0}}const qn=class{constructor(e,t,i,n,r){h(this,"_action");h(this,"root");h(this,"clip");h(this,"positionWrapper",null);h(this,"rotationWrapper",null);h(this,"context");h(this,"positionChange",new w);h(this,"rotationChange",new Ce);h(this,"_prevTime",0);if(this.context=e,this.root=t,this.clip=i,qn.firstKeyframeRotation[this.cacheId]||(qn.firstKeyframeRotation[this.cacheId]=new Ce),r){const o=r.values;qn.firstKeyframeRotation[this.cacheId].set(o[0],o[1],o[2],o[3])}qn.spaceRotation[this.cacheId]||(qn.spaceRotation[this.cacheId]=new Ce),qn.effectiveSpaceRotation[this.cacheId]||(qn.effectiveSpaceRotation[this.cacheId]=new Ce),qn.clipOffsetRotation[this.cacheId]=new Ce,r&&qn.clipOffsetRotation[this.cacheId].set(r.values[0],r.values[1],r.values[2],r.values[3]).invert(),this.handlePosition(i,n),this.handleRotation(i,r)}set action(e){this._action=e}get action(){return this._action}get cacheId(){return this.root.uuid}onStart(e){if(e.getClip()!==this.clip)return;qn.lastObjRotation[this.cacheId]||(qn.lastObjRotation[this.cacheId]=this.root.quaternion.clone());const t=qn.lastObjRotation[this.cacheId];if(qn.spaceRotation[this.cacheId].copy(t),q0){const i=new Wi().setFromQuaternion(t);console.log("START",this.clip.name,et.toDegrees(i.y),this.root.position.z)}}getClipRotationOffset(){return qn.clipOffsetRotation[this.cacheId]}handlePosition(e,t){if(t){const i=this.root;q0&&i.add(new $o),qn.lastObjPosition[this.cacheId]||(qn.lastObjPosition[this.cacheId]=this.root.position.clone());const n=new w,r=new w;this.positionWrapper=new XO(t,(o,a)=>{const l=this.action.getEffectiveWeight();return q0&&i.position.length()>8&&i.position.set(0,i.position.y,0),o>this._prevTime&&(n.set(a[0],a[1],a[2]),n.sub(r),n.multiplyScalar(l),n.applyQuaternion(this.getClipRotationOffset()),n.applyQuaternion(i.quaternion),this.positionChange.copy(n)),r.fromArray(a),this._prevTime=o,a[0]=0,a[1]=0,a[2]=0,a})}}handleRotation(e,t){if(t){if(q0){const o=t.values,a=new Wi().setFromQuaternion(new Ce(o[0],o[1],o[2],o[3]));console.log(e.name,t.name,"FIRST ROTATION IN TRACK",et.toDegrees(a.y));const l=t.values.length-4,c=new Ce().set(o[l],o[l+1],o[l+2],o[l+3]),u=new Wi().setFromQuaternion(c);console.log(e.name,t.name,"LAST ROTATION IN TRACK",et.toDegrees(u.y))}let i=0;const n=new Ce,r=new Ce;this.rotationWrapper=new XO(t,(o,a)=>(o>i&&(r.set(a[0],a[1],a[2],a[3]),n.invert(),r.multiply(n),this.rotationChange.copy(r)),n.fromArray(a),i=o,a[0]=0,a[1]=0,a[2]=0,a[3]=1,a))}}onBeforeUpdate(e){this.positionChange.set(0,0,0),this.rotationChange.set(0,0,0,1)}onAfterUpdate(e){return!this.action||(e*=this.action.getEffectiveWeight(),e<=0)?!1:(this.positionChange.multiplyScalar(e),this.rotationChange.slerp(qn.identityQuaternion,1-e),!0)}};let qa=qn;h(qa,"lastObjPosition",{}),h(qa,"lastObjRotation",{}),h(qa,"firstKeyframeRotation",{}),h(qa,"spaceRotation",{}),h(qa,"effectiveSpaceRotation",{}),h(qa,"clipOffsetRotation",{}),h(qa,"identityQuaternion",new Ce);class ine{constructor(e){h(this,"controller");h(this,"handler",[]);h(this,"root");h(this,"basePosition",new w);h(this,"baseQuaternion",new Ce);h(this,"baseRotation",new Wi);h(this,"summedPosition",new w);h(this,"summedRotation",new Ce);this.controller=e}createClip(e,t,i){this.root=t,t&&"name"in t&&t.name;const n=this.findRootTrack(i,".position"),r=this.findRootTrack(i,".quaternion"),o=new qa(this.controller.context,t,i,n,r);this.handler.push(o);const a=e.clipAction(i);return o.action=a,a}onStart(e){for(const t of this.handler)t.onStart(e)}onBeforeUpdate(e){this.basePosition.copy(this.root.position),this.baseQuaternion.copy(this.root.quaternion);for(const t of this.handler)t.onBeforeUpdate(e)}onAfterUpdate(e){if(!(e<=0)){this.root.position.copy(this.basePosition),this.root.quaternion.copy(this.baseQuaternion),this.summedPosition.set(0,0,0),this.summedRotation.set(0,0,0,1);for(const t of this.handler)t.onAfterUpdate(e)&&(this.summedPosition.add(t.positionChange),this.summedRotation.multiply(t.rotationChange));this.root.position.add(this.summedPosition),this.root.quaternion.multiply(this.summedRotation)}}findRootTrack(e,t){const i=e.tracks;if(!i)return null;for(const n of i)if(n.name.endsWith(t))return n;return null}}class nne extends wl{onSerialize(e,t){}onDeserialize(e,t){if(t.type===bo&&(e==null?void 0:e.__type)==="AnimatorController")return new bo(e)}}new nne(bo);var sne=Object.defineProperty,rne=Object.getOwnPropertyDescriptor,Pw=(s,e,t,i)=>{for(var n=i>1?void 0:i?rne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&sne(e,t,n),n};const Fo=ne("debuganimator");class ks extends Me{constructor(){super(...arguments);h(this,"applyRootMotion",!1);h(this,"hasRootMotion",!1);h(this,"keepAnimatorControllerStateOnDisable",!1);h(this,"_parametersAreDirty",!1);h(this,"_isDirty",!1);h(this,"_speed",1);h(this,"_normalizedStartOffset",0);h(this,"_animatorController",null);h(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(t){var i;this._animatorController&&this._animatorController.model===t||(t?t instanceof bo?(t.animator&&t.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(i=t.model)==null?void 0:i.name),t.model||console.error("AnimatorController has no model"),t=new bo(t.model)),this._animatorController=t,this._animatorController.bind(this)):(Fo&&console.log("Assign animator controller",t,this),this._animatorController=new bo(t),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}getCurrentStateInfo(){var t;return(t=this.runtimeAnimatorController)==null?void 0:t.getCurrentStateInfo()}get currentAction(){var t;return((t=this.runtimeAnimatorController)==null?void 0:t.currentAction)||null}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(t,i=-1,n=Number.NEGATIVE_INFINITY,r=0){this.play(t,i,n,r)}play(t,i=-1,n=Number.NEGATIVE_INFINITY,r=0){var o;(o=this.runtimeAnimatorController)==null||o.play(t,i,n,r),this._isDirty=!0}Reset(){this.reset()}reset(){var t;(t=this._animatorController)==null||t.reset(),this._isDirty=!0}SetBool(t,i){this.setBool(t,i)}setBool(t,i){var n,r;Fo&&console.log("setBool",t,i),((n=this.runtimeAnimatorController)==null?void 0:n.getBool(t))!==i&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.setBool(t,i)}GetBool(t){return this.getBool(t)}getBool(t){var n;const i=((n=this.runtimeAnimatorController)==null?void 0:n.getBool(t))??!1;return Fo&&console.log("getBool",t,i),i}toggleBool(t){this.setBool(t,!this.getBool(t))}SetFloat(t,i){this.setFloat(t,i)}setFloat(t,i){var n,r;((n=this.runtimeAnimatorController)==null?void 0:n.getFloat(t))!==i&&(this._parametersAreDirty=!0),Fo&&console.log("setFloat",t,i),(r=this.runtimeAnimatorController)==null||r.setFloat(t,i)}GetFloat(t){return this.getFloat(t)}getFloat(t){var n;const i=((n=this.runtimeAnimatorController)==null?void 0:n.getFloat(t))??-1;return Fo&&console.log("getFloat",t,i),i}SetInteger(t,i){this.setInteger(t,i)}setInteger(t,i){var n,r;((n=this.runtimeAnimatorController)==null?void 0:n.getInteger(t))!==i&&(this._parametersAreDirty=!0),Fo&&console.log("setInteger",t,i),(r=this.runtimeAnimatorController)==null||r.setInteger(t,i)}GetInteger(t){return this.getInteger(t)}getInteger(t){var n;const i=((n=this.runtimeAnimatorController)==null?void 0:n.getInteger(t))??-1;return Fo&&console.log("getInteger",t,i),i}SetTrigger(t){this.setTrigger(t)}setTrigger(t){var i;this._parametersAreDirty=!0,Fo&&console.log("setTrigger",t),(i=this.runtimeAnimatorController)==null||i.setTrigger(t)}ResetTrigger(t){this.resetTrigger(t)}resetTrigger(t){var i;this._parametersAreDirty=!0,Fo&&console.log("resetTrigger",t),(i=this.runtimeAnimatorController)==null||i.resetTrigger(t)}GetTrigger(t){this.getTrigger(t)}getTrigger(t){var n;const i=(n=this.runtimeAnimatorController)==null?void 0:n.getTrigger(t);return Fo&&console.log("getTrigger",t,i),i}IsInTransition(){return this.isInTransition()}isInTransition(){var t;return((t=this.runtimeAnimatorController)==null?void 0:t.isInTransition())??!1}SetSpeed(t){return this.setSpeed(t)}setSpeed(t){var i;t!==this._speed&&(Fo&&console.log("setSpeed",t),this._speed=t,((i=this._animatorController)==null?void 0:i.animator)==this&&this._animatorController.setSpeed(t))}set minMaxSpeed(t){var i;this._speed=et.lerp(t.x,t.y,Math.random()),((i=this._animatorController)==null?void 0:i.animator)==this&&this._animatorController.setSpeed(this._speed)}set minMaxOffsetNormalized(t){var i;this._normalizedStartOffset=et.lerp(t.x,t.y,Math.random()),((i=this.runtimeAnimatorController)==null?void 0:i.animator)==this&&(this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset)}awake(){Fo&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(t=!1){const i=t||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&i){const n=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=n,n?(console.assert(this.runtimeAnimatorController!==n),this.runtimeAnimatorController=n,console.assert(this.runtimeAnimatorController===n),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this._speed),this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){var t;this.keepAnimatorControllerStateOnDisable||(t=this._animatorController)==null||t.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!$ie(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}Pw([x()],ks.prototype,"applyRootMotion",2);Pw([x()],ks.prototype,"hasRootMotion",2);Pw([x()],ks.prototype,"keepAnimatorControllerStateOnDisable",2);Pw([x()],ks.prototype,"runtimeAnimatorController",1);const Xu=ne("debugusdzanimation"),LM=ne("debugusdzanimationserialization");class Bw{constructor(e,t,i){h(this,"_start");h(this,"ext");h(this,"root");h(this,"clip");this.ext=e,this.root=t,this.clip=i}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){return this.clip.duration}}const VP=class{constructor(e,t,i){h(this,"clip");h(this,"pos");h(this,"rot");h(this,"scale");h(this,"root");h(this,"target");h(this,"duration",0);h(this,"useRootMotion",!1);this.root=e,this.target=t,this.clip=i,i?this.duration=i.duration:this.duration=VP.restPoseClipDuration;const n=oe.getComponent(e,ks);n&&(this.useRootMotion=n.applyRootMotion)}get frameRate(){return 60}addTrack(e){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it – this is likely a bug");return}e.name.endsWith("position")&&(this.pos=e),e.name.endsWith("quaternion")&&(this.rot=e),e.name.endsWith("scale")&&(this.scale=e)}getFrames(){var e,t,i,n,r,o;return this.clip?Math.max(((t=(e=this.pos)==null?void 0:e.times)==null?void 0:t.length)??0,((n=(i=this.rot)==null?void 0:i.times)==null?void 0:n.length)??0,((o=(r=this.scale)==null?void 0:r.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(e=!0,t=!0,i=!0){var l,c,u;if(!this.clip)return[0,this.duration];const n=(l=this.pos)==null?void 0:l.times,r=(c=this.rot)==null?void 0:c.times,o=(u=this.scale)==null?void 0:u.times,a=[];if(e&&n)for(const d of n)a.push(d);if(t&&r)for(const d of r)a.push(d);if(i&&o)for(const d of o)a.push(d);return a.includes(0)||a.push(0),a.sort((d,f)=>d-f),[...new Set(a)]}*getValues(e,t=!0,i=!0,n=!0){var f,p,m;const r=new w,o=new Ce,a=new w(1,1,1),l=this.target,c=t?(f=this.pos)==null?void 0:f.createInterpolant():void 0,u=i?(p=this.rot)==null?void 0:p.createInterpolant():void 0,d=n?(m=this.scale)==null?void 0:m.createInterpolant():void 0;c||r.set(l.position.x,l.position.y,l.position.z),u||o.set(l.quaternion.x,l.quaternion.y,l.quaternion.z,l.quaternion.w),d||a.set(l.scale.x,l.scale.y,l.scale.z);for(let A=0;A<e.length;A++){const g=e[A];if(c){const v=c.evaluate(g);r.set(v[0],v[1],v[2])}if(u){const v=u.evaluate(g);o.set(v[0],v[1],v[2],v[3])}if(d){const v=d.evaluate(g);a.set(v[0],v[1],v[2])}if(this.useRootMotion&&l===this.root){const v=new we;v.compose(r,o,a),v.multiply(l.matrix),v.decompose(r,o,a)}yield{time:g,translation:r,rotation:o,scale:a,index:A}}}};let us=VP;h(us,"animationDurationPadding",1/60),h(us,"restPoseClipDuration",1/60);class qA{constructor(e){h(this,"dict",new Map);h(this,"rootTargetMap",new Map);h(this,"rootAndClipToRegisteredAnimationMap",new Map);h(this,"rootToRegisteredClipCount",new Map);h(this,"serializers",[]);h(this,"injectRestPoses",!1);h(this,"injectImplicitBehaviours",!1);this.injectRestPoses=e,this.injectImplicitBehaviours=e}get extensionName(){return"animation"}getStartTimeCode(){return!this.injectRestPoses||this.rootAndClipToRegisteredAnimationMap.size===0?0:(us.restPoseClipDuration+us.animationDurationPadding)*60}getEndTimeCode(){let e=0;for(const[t,i]of this.rootAndClipToRegisteredAnimationMap){const n=i.start+i.duration;n>e&&(e=n)}return e*60}getClipCount(e){let t=this.rootToRegisteredClipCount.get(e);return this.injectRestPoses&&(t=t?t-1:0),t??0}getStartTime01(e,t){const i=this.rootTargetMap.get(e);if(!i)return 0;const n=this.dict.get(i[0]);if(!n)return console.error("Trying to get start time for root that has no animation data",e,t,...this.dict),0;let r=0;for(let o=0;o<n.length&&n[o].clip!==t;o++)r+=n[o].getDuration()+us.animationDurationPadding;return r}registerAnimation(e,t){if(!t||!e)return null;this.rootTargetMap.has(e)||this.rootTargetMap.set(e,[]);const i=e.uuid+t.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(i))return this.rootAndClipToRegisteredAnimationMap.get(i);Xu&&console.log("registerAnimation",e,t);const n=this.injectRestPoses?1:0,r=this.rootToRegisteredClipCount.get(e)??n,o=this.rootTargetMap.get(e),a=new Set(o);if(t.tracks)for(const c of t.tracks){const u=Xt.parseTrackName(c.name),d=Xt.findNode(e,u.nodeName);if(!d){console.warn("no object found for track",c.name,"using "+e.name+" instead");continue}this.dict.has(d)||this.dict.set(d,[]);const f=this.dict.get(d);if(!f){console.warn("no transform data found for target ",d,"at slot "+r+", this is likely a bug");continue}if(a.delete(d),this.injectRestPoses&&!f[0]){const m=new us(null,d,void 0);f[0]=m}let p=f[r];p||(p=new us(e,d,t),f[r]=p),p.addTrack(c),o!=null&&o.includes(d)||o==null||o.push(d)}for(const c of a){const u=this.dict.get(c);if(!u)continue;if(this.injectRestPoses&&!u[0]){const f=new us(null,c,void 0);u[0]=f}let d=u[r];d||(Xu&&console.log("Adding padding clip for ",c,t,"at slot",r),d=new us(e,c,t),u[r]=d)}const l=new Bw(this,e,t);return this.rootAndClipToRegisteredAnimationMap.set(i,l),this.rootToRegisteredClipCount.set(e,r+1),l}onAfterHierarchy(e){Xu&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(e){var t,i;for(const n of this.serializers){const r=(t=n.model)==null?void 0:t.parent,o=(r==null?void 0:r.isDynamic)===!0;LM&&console.log(o,(i=n.model)==null?void 0:i.parent),o&&n.registerCallback(r)}}onExportObject(e,t,i){oe.foreachComponent(e,r=>{const o=r;typeof o.createAnimation=="function"&&o.createAnimation(this,t,i)},!1);const n=new one(e,this.dict);this.serializers.push(n),n.registerCallback(t)}}class one{constructor(e,t){h(this,"object");h(this,"dict");h(this,"model");h(this,"callback");this.object=e,this.dict=t}registerCallback(e){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),LM&&console.log("REPARENT",e),this.model=e,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(e,t){var r;const i=this.model,n=this.dict;if(i&&i.skinnedMesh){let o=function(C){const P=[];for(const[S,I]of C){let H=`${S} : [`;const U=[];for(const D of I)U.push(`(${cs(D.x)}, ${cs(D.y)}, ${cs(D.z)})`);H=H.concat(U.join(", ")),H=H.concat("],"),P.push(H)}return P},a=function(C){const P=[];for(const[S,I]of C){let H=`${S} : [`;const U=[];for(const D of I)U.push(`(${cs(D.w)}, ${cs(D.x)}, ${cs(D.y)}, ${cs(D.z)})`);H=H.concat(U.join(", ")),H=H.concat("],"),P.push(H)}return P},l=function(C){let P,S=!0;const I=new Map;for(const[U,D]of C){P===void 0&&(P=D.length),P!==D.length&&(S=!1);let V=0;for(const L of D)V++,L||(I.has(U)||I.set(U,[]),I.get(U).push(V))}Xu&&console.log("Bone count: ",C.size,"TransformData entries per bone: ",P,"Undefined bone entries: ",I),console.assert(S,"All bones should have the same number of TransformData entries",C),console.assert(I.size===0,"All TransformData entries should be set",I);const H=[];for(const[U,D]of C){const V=new Array;let L=0;for(let k=0;k<D.length;k++)V.push(L),L+=D[k].getDuration()+us.animationDurationPadding;for(let k=0;k<D.length;k++){const G=D[k],Y=V[k];H.length<=k&&H.push({pos:[],rot:[],scale:[],timeOffset:Y});const K=H[k];K.pos.push(...G.getSortedTimesArray(!0,!1,!1)),K.rot.push(...G.getSortedTimesArray(!1,!0,!1)),K.scale.push(...G.getSortedTimesArray(!1,!1,!0))}}for(const U of H)U.pos.sort((D,V)=>D-V),U.rot.sort((D,V)=>D-V),U.scale.sort((D,V)=>D-V),U.pos=[...new Set(U.pos)],U.rot=[...new Set(U.rot)],U.scale=[...new Set(U.scale)];return H},c=function(C,P,S){const I=new Map,H=new Map,U=new Map,D=P.length;for(const V of S){const L=C.get(V);let k;L?console.assert(L.length===D,"We should have the same number of TransformData entries for each bone",L,P):k=new us(null,V,void 0);for(let G=0;G<D;G++){const Y=L?L[G]:k,K=P[G];for(const{time:re,translation:ce}of Y.getValues(K.pos,!0,!1,!1)){const ie=(re+K.timeOffset)*60;I.has(ie)||I.set(ie,new Array),I.get(ie).push(ce.clone())}for(const{time:re,rotation:ce}of Y.getValues(K.rot,!1,!0,!1)){const ie=(re+K.timeOffset)*60;H.has(ie)||H.set(ie,new Array),H.get(ie).push(ce.clone())}for(const{time:re,scale:ce}of Y.getValues(K.scale,!1,!1,!0)){const ie=(re+K.timeOffset)*60;U.has(ie)||U.set(ie,new Array),U.get(ie).push(ce.clone())}}}return{position:I.size==0?void 0:I,quaternion:H.size==0?void 0:H,scale:U.size==0?void 0:U}},u=function(C){const P=[];for(const S of C)P.push(`(${cs(S.x)}, ${cs(S.y)}, ${cs(S.z)})`);return P.join(", ")},d=function(C){const P=[];for(const S of C)P.push(`(${cs(S.w)}, ${cs(S.x)}, ${cs(S.y)}, ${cs(S.z)})`);return P.join(", ")},f=function(C){const P=new Map;if(Xu){const S=new Array;for(const[I,H]of n)S.push(I.uuid+": "+H.length+" "+H.map(U=>{var D;return(D=U.clip)==null?void 0:D.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
5507
5507
  `+S.join(`
5508
5508
  `))}for(const S of C){const I=n.get(S);I&&P.set(S,I)}return P},p=function(C){const P=f(C),S=l(P);return c(P,S,C)};const m=i.skinnedMesh.skeleton,A=new Array;for(const C in m.bones){const P=m.bones[C],S=m.boneInverses[C];A.push({bone:P,inverse:S})}for(const C of m3(m.bones))A.push({bone:C,inverse:C.matrixWorld.clone().invert()});const g=A[0].bone.parent;g||console.error("No bone parent found for skinned mesh during USDZ export",i.skinnedMesh),A.sort((C,P)=>Ap(C.bone,g)>Ap(P.bone,g)?1:-1);const v=[],_=[],y=[],b=[];for(const{bone:C}of A)v.push(C.matrix.clone()),_.push(C.position),y.push(C.quaternion),b.push(C.scale);const M=A.map(C=>'"'+Ap(C.bone,g)+'"').join(", "),E=A.map(C=>np(C.inverse.clone().invert())).join(", ");e.beginBlock('def Skeleton "Rig"'),e.appendLine(`uniform matrix4d[] bindTransforms = [${E}]`),e.appendLine(`uniform token[] joints = [${M}]`),e.appendLine('uniform token purpose = "guide"'),e.appendLine(`uniform matrix4d[] restTransforms = [${v.map(C=>np(C)).join(", ")}]`),e.appendLine(`matrix4d xformOp:transform = ${np(new we)}`),e.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const T=p(A.map(C=>C.bone));if(Xu){let C=1e7,P=0;for(const S of((r=T.position)==null?void 0:r.keys())??[])C=Math.min(C,S),P=Math.max(P,S);console.log("Time samples",C,P,T)}if(e.beginBlock('def SkelAnimation "_anim"'),e.appendLine(`uniform token[] joints = [${M}]`),e.appendLine(`quatf[] rotations = [${d(y)}]`),T&&T.quaternion){e.beginBlock("quatf[] rotations.timeSamples = {","");const C=a(T.quaternion);for(const P of C)e.appendLine(P);e.closeBlock()}if(e.appendLine(`half3[] scales = [${u(b)}]`),T&&T.scale){e.beginBlock("half3[] scales.timeSamples = {","");const C=o(T.scale);for(const P of C)e.appendLine(P);e.closeBlock()}if(e.appendLine(`float3[] translations = [${u(_)}]`),T&&T.position){e.beginBlock("float3[] translations.timeSamples = {","");const C=o(T.position);for(const P of C)e.appendLine(P);e.closeBlock()}e.closeBlock(),e.closeBlock()}}onSerialize(e,t){var c;if(!this.model)return;const i=this.dict.get(this.object);if(i)for(let u=0;u<i.length;u++)i[u]===void 0&&(i[u]=new us(null,this.object,void 0));this.skinnedMeshExport(e,t);const n=this.object,r=this.dict.get(n);if(!r||n.isSkinnedMesh)return;LM&&console.log("SERIALIZE",this.model.name,this.object.type,r);const o=new we;e.appendLine("matrix4d xformOp:transform.timeSamples = {"),e.indent++;const a=new Array;let l=0;for(let u=0;u<r.length;u++){if(a.push(l),r[u]===void 0){console.error("Got an undefined transform data, this is likely a bug.",n,r);continue}l+=r[u].getDuration()+us.animationDurationPadding}for(let u=0;u<r.length;u++){const d=r[u];if(!d)continue;const f=a[u];{const p=d.getSortedTimesArray();if(!p||p.length===0){console.error("got an animated object but no time values?",n,d);continue}if(Xu){const m=((c=d.clip)==null?void 0:c.name)??"rest",A=d.getDuration();console.log("Write .timeSamples:",m,f,A,r),e.appendLine("# "+m+": start="+(f*d.frameRate).toFixed(3)+", length="+(A*d.frameRate).toFixed(3)+", frames="+d.getFrames())}for(const{time:m,translation:A,rotation:g,scale:v}of d.getValues(p)){o.compose(A,g,v);const _=`${(f+m)*d.frameRate}: ${np(o)},`;e.appendLine(_)}}}e.indent--,e.appendLine("}")}}var ane=Object.defineProperty,lne=Object.getOwnPropertyDescriptor,oG=(s,e,t,i)=>{for(var n=i>1?void 0:i?lne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&ane(e,t,n),n};const YO=ne("debugpost");class kt{constructor(e){h(this,"_active",!0);h(this,"_value");h(this,"_valueRaw");h(this,"_defaultValue");h(this,"valueProcessor");h(this,"onValueChanged");this._value=e,this._defaultValue=e,this._valueRaw=e}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}get value(){return this._valueRaw}set value(e){this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;const i=this._value;if(YO){let n=!0;if(typeof i=="number"&&typeof e=="number"){const r=i==null?void 0:i.toFixed(4),o=e==null?void 0:e.toFixed(4);r!=o?n=!0:n=!1}n&&console.log("VolumeParameter: value changed from",i,"to",e)}!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged?this.onValueChanged(e,i,this):YO&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(e){return this._valueRaw!==e}}oG([x()],kt.prototype,"overrideState",1);oG([x()],kt.prototype,"value",1);var cne=Object.defineProperty,hne=Object.getOwnPropertyDescriptor,une=(s,e,t,i)=>{for(var n=i>1?void 0:i?hne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&cne(e,t,n),n};const dne=ne("debugpost");class lr extends Me{constructor(t=void 0){super();h(this,"active",!0);h(this,"_result");h(this,"_didCreateVolumeParameters",!1);if(t){this.ensureVolumeParameters();for(const i of Object.keys(t)){const n=t[i],r=this[i];r instanceof kt&&(r.value=n)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var t;return this.ensureVolumeParameters(),this._result||(this._result=(t=this.onCreateEffect)==null?void 0:t.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){dne&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(t=>t.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const t=Object.keys(this);for(const i of t){const n=this[i];n instanceof kt&&n.__init()}}onAfterDeserialize(t,i){if(typeof t=="object"){const n=this.$serializedTypes;if(n){for(const r of Object.keys(n))if(n[r]===kt){const a=t[r];if(a!==void 0){const l=this[r];l.value=a}}}}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof kt){const n=t.value;return this[i].value=n,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const t=this.$serializedTypes;if(t)for(const i of Object.keys(t))t[i]===kt&&(this[i]||(this[i]=new kt))}}une([x()],lr.prototype,"active",2);var fne=Object.defineProperty,pne=Object.getOwnPropertyDescriptor,mne=(s,e,t,i)=>{for(var n=i>1?void 0:i?pne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&fne(e,t,n),n};const gne=ne("debugpost"),kM={};function aa(s,e){kM[s]=e}function vne(s){return s.__type in kM?kM[s.__type]:(gne&&s.__type&&console.warn("Unknown postprocessing type",s.__type,s),lr)}class XA{constructor(){h(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}mne([tm([s=>vne(s),lr])],XA.prototype,"components",2);var Ane=Object.defineProperty,yne=Object.getOwnPropertyDescriptor,_ne=(s,e,t,i)=>{for(var n=i>1?void 0:i?yne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ane(e,t,n),n};class YA extends lr{constructor(){super(...arguments);h(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new Y3({preset:Qf.HIGH,edgeDetectionMode:iR.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}_ne([x(kt)],YA.prototype,"preset",2);aa("Antialiasing",YA);const bne=ne("debugusdz");class Gh{constructor(){h(this,"files",new Array)}static getName(e){var r;const t=e.split(".").pop();let n=(r=e.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:r.replace(".","_");return n||(n="Audio_"+Math.random().toString(36).substring(2,15)),xc(n)+"."+t}get extensionName(){return"Audio"}onExportObject(e,t,i){const n=oe.getComponents(e,fn);if(n.length)for(const r of n){if(!r.clip||typeof r.clip!="string"||!r.playOnAwake)continue;const o=r.clip.split("/").pop()||"Audio",a=Gh.getName(r.clip),l=xc(a);this.files.some(c=>c.path===r.clip)||this.files.push({path:r.clip,name:a}),i.quickLookCompatible||t.addEventListener("serialize",(c,u)=>{c.appendLine(),c.beginBlock(`def SpatialAudio "${l}"`,"(",!1),c.appendLine(`displayName = "${o}"`),c.closeBlock(")"),c.beginBlock(),c.appendLine(`uniform asset filePath = @audio/${a}@`),c.appendLine(`uniform token auralMode = "${r.spatialBlend>0?"spatial":"nonSpatial"}"`),c.appendLine(`uniform token playbackMode = "${r.loop?"loopFromStage":"onceFromStart"}"`),c.appendLine(`uniform float gain = ${r.volume}`),c.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const i="audio/"+t.name;if(e.files[i]){bne&&console.warn("Audio file with name "+i+" already exists in the context. Skipping.");continue}const o=await(await(await fetch(t.path)).blob()).arrayBuffer(),a=new Uint8Array(o);e.files[i]=a}}}const Yu=ne("debugautosync"),ZC=Symbol("syncerId");class xne{constructor(){h(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const t=new wne(e);return t[ZC]=e.guid,this._syncers[t[ZC]]=t,t}removeSyncer(e){delete this._syncers[e[ZC]]}}const PR=new xne;class wne{constructor(e){h(this,"comp");h(this,"hasChanges",!1);h(this,"changedProperties",{});h(this,"data",{});h(this,"_boundEvent");h(this,"_handleReceivingMethod");h(this,"_isReceiving",!1);h(this,"_isInit",!1);this.comp=e}get networkingKey(){return this.comp.guid}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,this._boundEvent=this.onHandleSending.bind(this),this.comp.context.post_render_callbacks.push(this._boundEvent),this._handleReceivingMethod=this.onHandleReceiving.bind(this),this.comp.context.connection.beginListen(this.networkingKey,this._handleReceivingMethod);const t=this.comp.context.connection.tryGetState(this.comp.guid);t&&this.onHandleReceiving(t)}destroy(){this._isInit&&(this._boundEvent&&this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this._boundEvent),1),this._handleReceivingMethod&&this.comp.context.connection.stopListen(this.networkingKey,this._handleReceivingMethod),this.comp=null,this._isInit=!1)}notifyChanged(e,t){this._isReceiving||(Yu&&console.log("Property changed: "+e,t),this.hasChanges=!0,this.changedProperties[e]=t)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const e=this.comp.context.connection;if(!e||!e.isConnected){for(const t in this.changedProperties)delete this.changedProperties[t];return}for(const t in this.data)delete this.data[t];this.data.guid=this.comp.guid;for(const t in this.changedProperties){const i=this.changedProperties[t];delete this.changedProperties[t],this.data[t]=i}e.send(this.networkingKey,this.data)}onHandleReceiving(e){if(Yu&&console.log("RECEIVE",this.comp.name,this.comp.guid,e),!this._isInit||!this.comp)return;const t=e.guid;if(!(t&&t!==this.comp.guid)){Yu&&console.log("RECEIVED",this.comp.name,this.comp.guid,e);try{this._isReceiving=!0;for(const i in e){if(i==="guid")continue;const n=e[i];this.comp[i]=n,Yu&&console.log("SET",i,n)}}catch(i){console.error(i)}finally{this._isReceiving=!1}}}}function Sne(s,e){let t=e!==s;return!t&&s&&e&&(Array.isArray(s)&&Array.isArray(e)||typeof s=="object"&&typeof e=="object")&&(t=!0),t}const ov=Symbol("AutoSyncHandler");function Cne(s){if(s[ov])return s[ov];const e=PR.getOrCreateSyncer(s);return e==null||e.init(s),s[ov]=e,e}function Ene(s){const e=s[ov];e&&(PR.removeSyncer(e),e.destroy(),delete s[ov])}const BR=function(s){return function(e,t){var u;let i="";typeof t=="string"?i=t:i=t.name;let n=null,r;typeof s=="string"?r=e[s]:typeof s=="function"&&(r=s);const o=e,a=o.__internalAwake;if(typeof a!="function"){(Yu||gt())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((u=e==null?void 0:e.constructor)==null?void 0:u.name)+'" is not supported',e);return}Yu&&console.log(i);const l=Symbol(i);o.__internalAwake=function(){if(this[l]!==void 0)return;this[l]=this[i],n=PR.getOrCreateSyncer(this);const d=Object.getOwnPropertyDescriptor(this,i);if((d==null?void 0:d.set)===void 0){let f=!1;Object.defineProperty(this,i,{set:function(p){var A;const m=this[l];if(this[l]=p,f){gt()&&console.warn("Recursive call detected",i);return}f=!0;try{const g=Sne(p,m);Yu&&console.log("SyncField assignment",i,"changed?",g,p),g&&(r==null?void 0:r.call(this,p,m))!==!1&&((A=Cne(this))==null||A.notifyChanged(i,p))}finally{f=!1}},get:function(){return this[l]},configurable:!0,enumerable:!0})}n==null||n.init(this),a.call(this)};const c=o.__internalDestroy;o.__internalDestroy=function(){Ene(this),c.call(this)}}};var Mne=Object.defineProperty,Tne=Object.getOwnPropertyDescriptor,Dw=(s,e,t,i)=>{for(var n=i>1?void 0:i?Tne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Mne(e,t,n),n};const ao=ne("debugplayersync");class um extends Me{constructor(){super(...arguments);h(this,"autoSync",!0);h(this,"asset");h(this,"onPlayerSpawned");h(this,"_localInstance");h(this,"onJoinedRoom",()=>{ao&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new $n)}onEnable(){this.context.connection.beginListen(ii.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(ii.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(ii.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(ii.JoinedRoom,this.onJoinedRoom)}async getInstance(){var i,n,r,o,a,l;if(this._localInstance)return this._localInstance;if(ao&&console.log("PlayerSync.createInstance",(i=this.asset)==null?void 0:i.uri),!((n=this.asset)!=null&&n.asset)&&!((r=this.asset)!=null&&r.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(o=this.asset)==null?void 0:o.instantiateSynced({parent:this.gameObject},!0);const t=await this._localInstance;if(t){const c=oe.getComponent(t,Yo);c?(c.owner=this.context.connection.connectionId,(a=this.onPlayerSpawned)==null||a.invoke(t)):(this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((l=this.asset)==null?void 0:l.uri)+"</strong>: please make sure the asset has a PlayerState component!"),oe.destroySynced(t))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var t;(t=this._localInstance)==null||t.then(i=>(ao&&console.log("PlayerSync.destroyInstance",i),oe.destroySynced(i))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",t=>{if(document.visibilityState==="visible")for(let i=Yo.all.length-1;i>=0;i--){const n=Yo.all[i];(!n.owner||!this.context.connection.userIsInRoom(n.owner))&&n.doDestroy()}})}}Dw([x()],um.prototype,"autoSync",2);Dw([x($t)],um.prototype,"asset",2);Dw([x($n)],um.prototype,"onPlayerSpawned",2);var aG=(s=>(s.OwnerChanged="ownerChanged",s))(aG||{}),gg;const Ss=(gg=class extends Me{constructor(){super(...arguments);h(this,"onOwnerChangeEvent",new $n);h(this,"onFirstOwnerChangeEvent",new $n);h(this,"hasOwner",!1);h(this,"owner");h(this,"dontDestroy",!1);h(this,"onUserLeftRoom",e=>{if(e.userId===this.owner){ao&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return Ss._all}static get local(){return Ss._local}static getFor(e){if(e instanceof me)return oe.getComponentInParent(e,Ss);if(e instanceof Me)return oe.getComponentInParent(e.gameObject,Ss)}static isLocalPlayer(e){const t=Ss.getFor(e);return(t==null?void 0:t.isLocalPlayer)??!1}static addEventListener(e,t){return this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(t),t}static removeEventListener(e,t){if(!this._callbacks[e])return;const i=this._callbacks[e].indexOf(t);i>=0&&this._callbacks[e].splice(i,1)}static dispatchEvent(e,t){if(this._callbacks[e])for(const i of this._callbacks[e])i(t)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(e,t){var o,a;ao&&console.log("PlayerSync.onOwnerChange",this,"newOwner",e,"oldOwner",t);const i=Ss._local.indexOf(this);i>=0&&Ss._local.splice(i,1);const n={playerState:this,oldValue:t,newValue:e};if(this.hasOwner||(this.hasOwner=!0,(o=this.onFirstOwnerChangeEvent)==null||o.invoke(n)),(a=this.onOwnerChangeEvent)==null||a.invoke(n),this.owner===this.context.connection.connectionId){Ss._local.push(this);const l=new CustomEvent("local-owner-changed",{detail:n});this.dispatchEvent(l)}const r=new CustomEvent("owner-changed",{detail:n});this.dispatchEvent(r),Ss.dispatchEvent("ownerChanged",r)}awake(){Ss.all.push(this),ao&&console.log("Registered new PlayerState",this.guid,Ss.all.length-1,Ss.all),this.context.connection.beginListen(ii.UserLeftRoom,this.onUserLeftRoom)}async start(){ao&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await Pa(300),this.context.connection.userIsInRoom(this.owner)==!1&&(ao&&console.log(`PlayerSync.start → doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(ao&&console.warn("PlayerState.start → owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?ao&&console.warn("PlayerState.start → owner is still undefined but dontDestroy is set to true",this.name):(ao&&console.warn(`PlayerState.start → owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):ao&&console.log("PlayerState.start → owner is assigned",this.owner)},2e3))}doDestroy(){ao&&console.log("PlayerSync.doDestroy → syncDestroy",this.name),yw(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(ii.UserLeftRoom,this.onUserLeftRoom),Ss.all.splice(Ss.all.indexOf(this),1),this.isLocalPlayer){const e=Ss._local.indexOf(this);e>=0&&Ss._local.splice(e,1)}}},h(gg,"_all",[]),h(gg,"_local",[]),h(gg,"_callbacks",{}),gg);let Yo=Ss;Dw([BR(Yo.prototype.onOwnerChange)],Yo.prototype,"owner",2);const Ine=ne("debugavatar"),ya=class extends Me{constructor(){super(...arguments);h(this,"connectionId");h(this,"avatar")}static getAvatar(t){return t>=0&&t<ya.instances.length?ya.instances[t]:null}static onAvatarMarkerCreated(t){return ya._onNewAvatarMarkerAdded.push(t),t}static onAvatarMarkerDestroyed(t){return ya._onAvatarMarkerDestroyed.push(t),t}awake(){ya.instances.push(this),Ine&&console.log(this);for(const t of ya._onNewAvatarMarkerAdded)t({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){ya.instances.splice(ya.instances.indexOf(this),1);for(const t of ya._onAvatarMarkerDestroyed)t({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let Yn=ya;h(Yn,"instances",[]),h(Yn,"_onNewAvatarMarkerAdded",[]),h(Yn,"_onAvatarMarkerDestroyed",[]);var Rne=Object.defineProperty,Pne=Object.getOwnPropertyDescriptor,Bne=(s,e,t,i)=>{for(var n=i>1?void 0:i?Pne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Rne(e,t,n),n};const Wf=ne("debugxrflags"),lG=ne("disablexrflags");lG&&console.warn("XRFlags are disabled");var nl=(s=>(s[s.Never=0]="Never",s[s.Browser=1]="Browser",s[s.AR=2]="AR",s[s.VR=4]="VR",s[s.FirstPerson=8]="FirstPerson",s[s.ThirdPerson=16]="ThirdPerson",s[s.All=4294967295]="All",s))(nl||{});const WP=class{constructor(){h(this,"Mask",17)}Has(e){return(this.Mask&e)!==0}Set(e){Wf&&console.warn("Set XR flag state to",e),this.Mask=e,uo.Apply()}Enable(e){this.Mask|=e,uo.Apply()}Disable(e){this.Mask&=~e,uo.Apply()}Toggle(e){this.Mask^=e,uo.Apply()}EnableAll(){this.Mask=-1,uo.Apply()}DisableAll(){this.Mask=0,uo.Apply()}};let Ps=WP;h(Ps,"Global",new WP);var vg;const jl=(vg=class extends Me{constructor(){super(...arguments);h(this,"visibleIn")}static Apply(){for(const e of this.registry)e.UpdateVisible(Ps.Global)}awake(){jl.registry.push(this)}onEnable(){jl.firstApply?this.UpdateVisible(Ps.Global):(jl.firstApply=!0,jl.Apply())}onDestroy(){const e=jl.registry.indexOf(this);e>=0&&jl.registry.splice(e,1)}get isOn(){return this.gameObject.visible}UpdateVisible(e=null){if(lG)return;let t;const i=e;if(i&&typeof i=="number"&&(console.assert(typeof i=="number","XRFlag.UpdateVisible: state must be a number",i),Wf&&console.log(i),jl.buffer.Mask=i,e=jl.buffer),e instanceof Ps?(Wf&&console.warn(this.name,"use passed in mask",e.Mask,this.visibleIn),t=e.Has(this.visibleIn)):(Wf&&console.log(this.name,"use global mask"),Ps.Global.Has(this.visibleIn)),t!==void 0)if(t)Wf&&console.log(this.name,"is visible",this.gameObject.uuid),oe.setActive(this.gameObject,!0);else{if(Wf&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},h(vg,"registry",[]),h(vg,"firstApply"),h(vg,"buffer",new Ps),vg);let uo=jl;Bne([x()],uo.prototype,"visibleIn",2);var Dne=Object.defineProperty,One=Object.getOwnPropertyDescriptor,DR=(s,e,t,i)=>{for(var n=i>1?void 0:i?One(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Dne(e,t,n),n};const rg=ne("debugwebxr"),JO=new Ce().setFromAxisAngle(new w(0,1,0),Math.PI);class kd extends Me{constructor(){super(...arguments);h(this,"head");h(this,"leftHand");h(this,"rightHand");h(this,"_syncTransforms")}async onEnterXR(t){if(!this.activeAndEnabled)return;rg&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const i=Yo.getFor(this);if(i!=null&&i.owner){const n=this.gameObject.addNewComponent(Yn);n.avatar=this.gameObject,n.connectionId=i.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):i&&!this.context.connection.isConnected&&(i.dontDestroy=!0)}onLeaveXR(t){const i=this.gameObject.getComponent(Yn);i&&i.destroy()}onUpdateXR(t){var l,c;if(!this.activeAndEnabled)return;const i=Yo.isLocalPlayer(this);if(!i)return;const n=t.xr;if(n.rig&&n.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),n.rig.gameObject.add(this.gameObject)),this._syncTransforms&&i)for(const u of this._syncTransforms)u.fastMode=!0,u.isOwned()||u.requestOwnership();if(this.head&&this.context.mainCamera){const u=this.head.asset;if(u.position.copy(this.context.mainCamera.position),u.quaternion.copy(this.context.mainCamera.quaternion),u.quaternion.x*=-1,this.context.time.frameCount%10===0){const d=oe.getComponentsInChildren(this.head.asset,uo);for(const f of d)f.enabled=!1,f.gameObject.visible=!1}}const r=t.xr.leftController,o=(l=this.leftHand)==null?void 0:l.asset;r&&o&&(o.position.copy(r.gripPosition),o.quaternion.copy(r.gripQuaternion),o.quaternion.multiply(JO),o.visible=r.isTracking);const a=t.xr.rightController;if(a&&((c=this.rightHand)!=null&&c.asset)){const u=this.rightHand.asset;u.position.copy(a.gripPosition),u.quaternion.copy(a.gripQuaternion),u.quaternion.multiply(JO),u.visible=a.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var t,i,n;if(this.context.connection.isConnected){const r=Yo.getFor(this);if(r&&r.isLocalPlayer==!1){const o=St.getXRSync(this.context);if(o&&o.hasState(r.owner)){this.tryFindAvatarObjectsIfMissing();const a=(t=this.leftHand)==null?void 0:t.asset;a&&(a.visible=(o==null?void 0:o.isTracking(r.owner,"left"))??!1);const l=(i=this.rightHand)==null?void 0:i.asset;l&&(l.visible=(o==null?void 0:o.isTracking(r.owner,"right"))??!1)}if((n=this.head)!=null&&n.asset){const a=oe.getComponentsInChildren(this.head.asset,uo);for(const l of a)l.enabled=!1,l.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const t={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};u4.tryFindAvatarObjects(this.gameObject,this.sourceId||"",t),t.head&&(this.head=t.head),t.leftHand&&(this.leftHand=t.leftHand),t.rightHand&&(this.rightHand=t.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof me&&(this.head=new $t("",this.sourceId,this.head));else{const t=new me;t.name="Head";const i=LA.createPrimitive(bd.Cube);t.add(i),this.gameObject.add(t),this.head=new $t("",this.sourceId,t),rg&&console.log("Create head",t)}if(this.rightHand)this.rightHand instanceof me&&(this.rightHand=new $t("",this.sourceId,this.rightHand));else{const t=new me;t.name="Right Hand",this.gameObject.add(t),this.rightHand=new $t("",this.sourceId,t),rg&&console.log("Create right hand",t)}if(this.leftHand)this.leftHand instanceof me&&(this.leftHand=new $t("",this.sourceId,this.leftHand));else{const t=new me;t.name="Left Hand",this.gameObject.add(t),this.leftHand=new $t("",this.sourceId,t),rg&&console.log("Create left hand",t)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),Yo.isLocalPlayer(this.gameObject)&&(this._syncTransforms=oe.getComponentsInChildren(this.gameObject,zh))}async loadAvatarObjects(t,i,n){const r=t.loadAssetAsync(),o=i.loadAssetAsync(),a=n.loadAssetAsync(),l=new Array;r&&l.push(r),o&&l.push(o),a&&l.push(a);const c=await wA(l);rg&&console.log("Avatar loaded results:",c)}}DR([x($t)],kd.prototype,"head",2);DR([x($t)],kd.prototype,"leftHand",2);DR([x($t)],kd.prototype,"rightHand",2);class vl{static Add(e,t,i=null){if(t){for(const n of this.Pois)if(n.obj===t)return;this.Pois.push({obj:t,avatar:i}),this.LastChangeTime=e.time.time}}static Remove(e,t){var i;if(t){for(const n of this.Pois)if(n.obj===t){this.Pois.splice(this.Pois.indexOf(n),1),this.LastChangeTime=(e==null?void 0:e.time.time)??((i=Lt.Current)==null?void 0:i.time.time);return}}}}h(vl,"Pois",[]),h(vl,"LastChangeTime",0);class Lne{constructor(){h(this,"guid");h(this,"position",new w)}}class Zv extends Me{constructor(){super(...arguments);h(this,"target",null);h(this,"avatar",null);h(this,"_model",null);h(this,"_targetModel",new Lne);h(this,"_currentTargetObject",null);h(this,"_lastUpdateTime",0);h(this,"_lookDuration",0);h(this,"_lastPoiChangedTime",0)}set controlledTarget(t){this.target=t;const i=J.get("MoveRandom");if(i&&this.target){const n=oe.getComponent(this.target,i);n&&n.destroy()}}awake(){if(this.avatar=oe.getComponentInParent(this.gameObject,Yn),this.avatar){const t=oe.getComponentInParent(this.gameObject,Yn);this._model=new xR(this.context.connection,this.guid),t!=null&&t.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",t=>{var i;this.target&&t&&t.guid===((i=this.avatar)==null?void 0:i.guid)&&rr(this.target,t.position)})}update(){var i;if((!this.context.connection.isConnected||(i=this._model)!=null&&i.hasOwnership)&&(vl.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=vl.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const n=Nt(this._currentTargetObject);rr(this.target,n),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(n))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const i=vl.Pois;if(i.length>0){const n=i[Math.floor(Math.random()*i.length)];if(n&&n.obj){if(n.avatar&&n.avatar===this.avatar)return;this._currentTargetObject=n.obj}}}}}const lp=ne("debugnetworkingstreams");var ul=(s=>(s.Connected="peer-user-connected",s.StreamReceived="receive-stream",s.StreamEnded="call-ended",s.Disconnected="peer-user-disconnected",s.UserJoined="user-joined",s))(ul||{});class cG{constructor(e,t){h(this,"type","call-ended");h(this,"userId");h(this,"direction");this.userId=e,this.direction=t}}class hG{constructor(e,t){h(this,"type","receive-stream");h(this,"stream");h(this,"target");this.stream=e,this.target=t}}class kne{constructor(e,t){h(this,"guid");h(this,"peerId");h(this,"dontSave",!0);this.guid=e.id,this.peerId=t}}var uG=(s=>(s.Incoming="incoming",s.Outgoing="outgoing",s))(uG||{});class Fne extends ps{constructor(t,i,n){super();h(this,"userId");h(this,"direction");h(this,"call");h(this,"_stream",null);h(this,"_isDisposed",!1);this.userId=t,this.call=i,this.direction=n,this._stream=null,i.on("stream",r=>{if(lp&&console.log("Receive video",r.getAudioTracks(),r.getVideoTracks()),this._stream=r,n==="incoming"){const o=new hG(r,this);this.dispatchEvent(o)}}),i.on("close",()=>{this.dispatchEvent(new cG(t,n))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),fc(this._stream))}get isOpen(){var t;return((t=this.call.peerConnection)==null?void 0:t.connectionState)==="connected"}get isOpening(){var t;return((t=this.call.peerConnection)==null?void 0:t.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const fp=class extends ps{constructor(t,i){super();h(this,"id");h(this,"context");h(this,"_peer");h(this,"_incomingCalls",[]);h(this,"_outgoingCalls",[]);h(this,"_enabled",!1);h(this,"_enabledPeer",!1);h(this,"onConnectRoomFn",this.onConnectRoom.bind(this));h(this,"onPeerConnectFn",this.onPeerConnect.bind(this));h(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this));this.context=t,this.id=i,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(t,i){if(fp.instances.has(i))return fp.instances.get(i);const n=new fp(t,i);return fp.instances.set(i,n),n}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(t){return this.id+"-"+t}getUserIdFromPeerId(t){return t.substring(this.id.length+1)}makeCall(t,i){var o;const n={metadata:{userId:this.context.connection.connectionId}},r=(o=this._peer)==null?void 0:o.call(t,i,n);if(r)return this.registerCall(r,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(ii.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(ii.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const t=this.getMyPeerId();t?this._peer=s4(t):console.error("Failed to setup peerjs because we dont have a connection id",this.context.connection.connectionId)}this._enabled&&this.subscribePeerEvents()}}subscribePeerEvents(){this._peer&&(this._peer.on("open",this.onPeerConnectFn),this._peer.on("call",this.onPeerReceiveCallFn))}unsubscribePeerEvents(){this._peer&&(this._peer.off("open",this.onPeerConnectFn),this._peer.off("call",this.onPeerReceiveCallFn))}onPeerConnect(t){lp&&console.log("Peer connected as",t),this.context.connection.send("peer-user-connected",new kne(this,t))}onPeerReceivingCall(t){t.answer(),this.registerCall(t,"incoming")}registerCall(t,i){const n=t.metadata;(!n||!n.userId)&&console.error("Missing call metadata",t);const r=n.userId;i==="incoming"&&lp?console.log("Receive call from",t.metadata):lp&&console.log("Make call to",t.metadata);const o=i==="incoming"?this._incomingCalls:this._outgoingCalls,a=new Fne(r,t,i);return o.push(a),t.on("error",l=>{console.error("Call error",l)}),t.on("close",()=>{lp&&console.log("Call ended",t.metadata),t.close();const l=o.indexOf(a);l!==-1&&o.splice(l,1)}),a.addEventListener("call-ended",l=>{this.dispatchEvent(l)}),i==="incoming"&&(a.addEventListener("receive-stream",l=>{this.dispatchEvent(l)}),t.on("stream",()=>{let l=0;const c=setInterval(()=>{const u=l===0;!a.isOpen&&u&&(l+=1,clearInterval(c),a.close())},2e3)})),a}};let xp=fp;h(xp,"instances",new Map);class JA extends ps{constructor(t,i){super();h(this,"context");h(this,"peer");h(this,"_sendingStreams",new Map);h(this,"debug",!1);h(this,"onJoinedRoom",t=>{this.debug&&console.log(`${t.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()});h(this,"onReceiveStream",t=>{this.debug&&console.log("RECEIVE STREAM",t),this.dispatchEvent({type:"receive-stream",target:this,stream:t.stream,userId:t.userId})});h(this,"onCallEnded",t=>{this.dispatchEvent(t)});h(this,"onUserConnected",t=>{if(this.peer.id===t.guid){this.debug&&console.log("USER CONNECTED",t.guid,t);const i=this._sendingStreams.keys().next().value;this.peer.makeCall(t.peerId,i)}});h(this,"onUserLeft",t=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()});this.context=t,this.peer=i,lp&&(this.debug=!0)}static create(t){const i=xp.getOrCreate(t.context,t.context.connection.connectionId);return new JA(t.context,i)}startSendingStream(t){this._sendingStreams.has(t)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(t,[]),this.updateSendingCalls())}stopSendingStream(t){if(t){const i=this._sendingStreams.get(t);if(i){this.debug&&console.log("Closing calls",i);for(const n of i)n.close()}this._sendingStreams.delete(t),i&&this.debug&&console.log("Currently sending",this._sendingStreams)}}enable(){this.peer.enable(),this.peer.addEventListener("receive-stream",this.onReceiveStream),this.peer.addEventListener("call-ended",this.onCallEnded),this.context.connection.beginListen("peer-user-connected",this.onUserConnected),this.context.connection.beginListen(ii.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(ii.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(ii.UserLeftRoom,this.onUserLeft)}disable(){this.peer.disable(),this.peer.removeEventListener("receive-stream",this.onReceiveStream),this.peer.removeEventListener("call-ended",this.onCallEnded),this.context.connection.stopListen("peer-user-connected",this.onUserConnected),this.context.connection.stopListen(ii.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(ii.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(ii.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var n;let t=!1;const i=this.context.connection.connectionId;for(const r of this._sendingStreams.keys()){const o=this._sendingStreams.get(r)||[];for(const a of this.context.connection.usersInRoom()){if(a===i)continue;const l=o.find(c=>c.userId===a);if(!l||((n=l.stream)==null?void 0:n.active)===!1){this.debug&&console.log("Starting call to",a,i);const c=this.peer.makeCall(this.peer.getPeerIdFromUserId(a),r);c&&(t=!0,o.push(c))}}this._sendingStreams.set(r,o)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),t&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const t of this._sendingStreams.keys()){const i=this._sendingStreams.get(t);if(i)for(let n=i.length-1;n>=0;n--){const r=i[n];this.context.connection.userIsInRoom(r.userId)||(r.close(),i.splice(n,1))}}}}function fc(s){if(s&&s instanceof MediaStream)for(const e of s.getTracks())e.stop()}var Une=Object.defineProperty,Nne=Object.getOwnPropertyDescriptor,dG=(s,e,t,i)=>{for(var n=i>1?void 0:i?Nne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Une(e,t,n),n};const zne="noVoip",Gne=ne("debugvoip");class Fd extends Me{constructor(){super(...arguments);h(this,"autoConnect",!1);h(this,"runInBackground",!0);h(this,"debug",!1);h(this,"_net");h(this,"_outputStream",null);h(this,"onJoinedRoom",async()=>{await Pa(300),this.autoConnect&&!this.isSending&&this.connect()});h(this,"_incomingStreams",new Map);h(this,"onReceiveStream",t=>{const i=t.target.userId,n=t.stream,r=this._incomingStreams.get(i);if(r)r.srcObject=n,r.setAttribute("autoplay","true");else{const o=new Audio;this._incomingStreams.set(i,o),o.setAttribute("autoplay","true"),o.srcObject=n}});h(this,"onStreamEnded",t=>{const i=this._incomingStreams.get(t.userId);fc(i==null?void 0:i.srcObject),this._incomingStreams.delete(t.userId)});h(this,"onEnabledChanged",()=>{for(const t of this._incomingStreams){const i=t[1];i.muted=!this.enabled}});h(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const i=!(document.visibilityState==="visible");this.setMuted(i);for(const n of this._incomingStreams){const r=n[1];r.muted=i}})}awake(){Gne&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async t=>{t.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=JA.create(this)),this._net.addEventListener(ul.StreamReceived,this.onReceiveStream),this._net.addEventListener(ul.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(ii.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var t;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(ul.StreamReceived,this.onReceiveStream),this._net.removeEventListener(ul.StreamEnded,this.onStreamEnded),(t=this._net)==null||t.disable(),this.context.connection.stopListen(ii.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(t){if(this.context.connection.isConnected){if(!await P1())return console.error("Cannot connect to voice chat - microphone permissions not granted"),!1}else return console.error("Cannot connect to voice chat - not connected to server"),!1;return this._net.stopSendingStream(this._outputStream),fc(this._outputStream),this._outputStream=await this.getAudioStream(t),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await P1()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):GI("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),fc(this._outputStream),this._outputStream=null}setMuted(t){var n;const i=(n=this._outputStream)==null?void 0:n.getAudioTracks();if(i)for(const r of i)r.enabled=!t}get isMuted(){var i;if(this._outputStream===null)return!1;const t=(i=this._outputStream)==null?void 0:i.getAudioTracks();if(t){for(const n of t)if(!n.enabled)return!0}return!1}getFrequency(t){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,gt()&&dn("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(t){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:t??!0,video:!1}).catch(n=>(console.warn("VOIP failed getting audio stream",n),null)):(console.error("No getDisplayMedia support"),null)}}dG([x()],Fd.prototype,"autoConnect",2);dG([x()],Fd.prototype,"runInBackground",2);var Hne=Object.defineProperty,Qne=Object.getOwnPropertyDescriptor,fG=(s,e,t,i)=>{for(var n=i>1?void 0:i?Qne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Hne(e,t,n),n};const Vne=ne("debugmouth");class KA extends Me{constructor(){super(...arguments);h(this,"idle",[]);h(this,"talking",[]);h(this,"marker",null);h(this,"voip",null);h(this,"lastMouthChangeTime",0);h(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=oe.findObjectOfType(Fd,this.context),this.marker||(this.marker=oe.getComponentInParent(this.gameObject,Yn))},3e3)}update(){var n;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((n=this.marker)==null?void 0:n.connectionId)??null;if(!t){Vne&&(t=null);return}const i=this.voip.getFrequency(t)??0;this.updateLips(i)}updateLips(t){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&t>30){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,i)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,i)}}}setMouthShapeActive(t,i){if(t){t!=this.idle?this.idle.map(n=>n.visible=!1):this.talking.map(n=>n.visible=!1);for(let n=0;n<t.length;n++){const r=t[n];r&&(r.visible=n===i)}}}}fG([x(me)],KA.prototype,"idle",2);fG([x(me)],KA.prototype,"talking",2);class OR extends Me{constructor(){super(...arguments);h(this,"voip",null);h(this,"marker",null);h(this,"_startPosition",null)}awake(){this.voip=oe.findObjectOfType(Fd,this.context),this.marker=oe.getComponentInParent(this.gameObject,Yn)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const t=this.marker.connectionId,i=this.voip.getFrequency(t);if(i==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const n=i/100;this.gameObject.position.y=this._startPosition.y+n*.07}}var Wne=Object.defineProperty,jne=Object.getOwnPropertyDescriptor,Ow=(s,e,t,i)=>{for(var n=i>1?void 0:i?jne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Wne(e,t,n),n};class Ud extends Me{constructor(){super(...arguments);h(this,"eyes",[]);h(this,"lastBlinkTime",0);h(this,"blinkLength",0);h(this,"eyesOpen",!0);h(this,"state",null)}awake(){this.state=oe.getComponentInParent(this.gameObject,uo)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const i of this.eyes)i&&(i.visible=this.eyesOpen)}}}Ow([x(me)],Ud.prototype,"eyes",2);Ow([x()],Ud.prototype,"lastBlinkTime",2);Ow([x()],Ud.prototype,"blinkLength",2);Ow([x()],Ud.prototype,"eyesOpen",2);var qne=Object.defineProperty,Xne=Object.getOwnPropertyDescriptor,LR=(s,e,t,i)=>{for(var n=i>1?void 0:i?Xne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&qne(e,t,n),n},FE;const pG=(FE=class extends Me{constructor(){super(...arguments);h(this,"head",null);h(this,"eyes",null);h(this,"target",null);h(this,"brain",null);h(this,"vec",new w);h(this,"currentTargetPoint",new w)}awake(){this.brain||(this.brain=oe.getComponentInParent(this.gameObject,Zv)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=oe.addNewComponent(this.gameObject,Zv)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const e=this.target;if(e&&this.head){const t=this.eyes;if(t){const i=Nt(e);this.currentTargetPoint.lerp(i,this.context.time.deltaTime/.1);const n=Nt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(n).normalize();if(r.length()<.1)return;const o=pG.forward;if(o.set(0,0,1),o.applyQuaternion(Ii(this.head)),o.dot(r)>.45)for(let l=0;l<t.length;l++)t[l].lookAt(this.currentTargetPoint)}}}},h(FE,"forward",new w(0,0,1)),FE);let dm=pG;LR([x(me)],dm.prototype,"head",2);LR([x(me)],dm.prototype,"eyes",2);LR([x(me)],dm.prototype,"target",2);const og=ne("debugavatar");class Lw{constructor(e,t,i,n){h(this,"root");h(this,"head");h(this,"leftHand");h(this,"rigthHand");var r;this.root=e,this.head=t,this.leftHand=i,this.rigthHand=n,(r=this.root)==null||r.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class kR{constructor(){h(this,"avatarRegistryUrl",null)}async getOrCreateNewAvatarInstance(e,t){if(!t)return console.error("Can not create avatar: failed to provide id or root object"),null;let i=null;if(typeof t=="string"){if(i=await this.loadAvatar(e,t),!i){const r=new Fa;i=oe.instantiate(Dp(t,e.scene),r)}}else i=t;if(!i)return null;const n=this.findAvatar(i);return n.isValid?(og&&console.log("[Custom Avatar] valid config",t,og?n:""),n):(console.warn("[Custom Avatar] config isn't valid",t,og?n:""),null)}async loadAvatar(e,t){if(console.assert(t!=null&&typeof t=="string","Avatar id must not be null"),t.length<=0||!t)return null;if(og&&console.log("[Custom Avatar] "+t+", loading..."),t.endsWith(".glb")||(t+=".glb"),this.avatarRegistryUrl===null){const n=await fetch("./"+t);let r=null;if(n.ok){const a=await n.blob();a&&(r=await a.arrayBuffer())}if(!r&&(r=await hR(t,t,0,"no url here go away",!0),!r))return null;const o=await Ra().parseSync(e,r,null,0);return(o==null?void 0:o.scene)??null}const i=new em;return IA(i,e),new Promise((n,r)=>{const o=this.avatarRegistryUrl+"/"+t;i.load(o,async a=>{await Ra().createBuiltinComponents(e,o,a,null,void 0),n(a.scene)},a=>{og&&console.log("[Custom Avatar] "+a.loaded/a.total*100+"% loaded of "+a.total/1024+"kB")},a=>{console.error("[Custom Avatar] Error when loading: "+a),n(null)})})}cacheModel(e,t){}findAvatar(e){const t=e;let i=t;i.children.length==1&&(i=e.children[0]);let n=this.findAvatarPart(i,["head"]);const r=this.findAvatarPart(i,["left","hand"]),o=this.findAvatarPart(i,["right","hand"]);if(!n){n=t;const l=new w;new Ai().setFromObject(n).getSize(l);const c=Math.max(l.x,l.y,l.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+c+" meters! Should be < 0.3m"),c>.3&&n.scale.multiplyScalar(1/c*.3)}return new Lw(t,n,r,o)}findAvatarPart(e,t){const i=e.name.toLowerCase();let n=!0;for(const r of t){if(!n)break;i.indexOf(r)===-1&&(n=!1)}if(n)return e;if(e.children)for(const r of e.children){const o=this.findAvatarPart(r,t);if(o)return o}return null}handleCustomAvatarErrors(e){if(!e.ok)throw Error(e.statusText);return e}}var Yne=Object.defineProperty,Jne=Object.getOwnPropertyDescriptor,FR=(s,e,t,i)=>{for(var n=i>1?void 0:i?Jne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Yne(e,t,n),n};class fm extends Me{constructor(){super(...arguments);h(this,"length",1);h(this,"depthTest",!0);h(this,"isGizmo",!0);h(this,"_axes",null)}onEnable(){if(this.isGizmo&&!BA)return;this._axes||(this._axes=new $o(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const t=this._axes.material;t&&t.depthTest!==void 0&&(t.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}FR([x()],fm.prototype,"length",2);FR([x()],fm.prototype,"depthTest",2);FR([x()],fm.prototype,"isGizmo",2);class UR extends Me{constructor(){super(...arguments);h(this,"from");h(this,"to");h(this,"hint");h(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const t=Nt(this.to).clone(),i=Nt(this.from).clone(),n=t.distanceTo(i),r=t.clone();r.sub(i);const o=i.clone();o.add(t),o.multiplyScalar(.5);const a=Nt(this.hint).clone();a.sub(o);const l=new w;l.crossVectors(a,r),l.crossVectors(r,l),l.normalize();const c=n*.5,u=Math.max(this.desiredDistance,c),d=Math.sqrt(u*u-c*c),f=l.clone();f.multiplyScalar(d),f.add(o),rr(this.gameObject,f);const p=o.clone();p.sub(l),this.gameObject.lookAt(p)}}const Kne=ne("debugusdzbehaviours");class kw{constructor(){h(this,"behaviours",[]);h(this,"behaviourComponents",[]);h(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(e){this.behaviours.push(e)}onBeforeBuildDocument(e){const t=[];return e.root.traverse(i=>{oe.foreachComponent(i,n=>{var o;const r=n;if(typeof r.createBehaviours=="function"||typeof r.beforeCreateDocument=="function"||typeof r.afterCreateDocument=="function"||typeof r.afterSerialize=="function"){this.behaviourComponents.push(r);const a=(o=r.beforeCreateDocument)==null?void 0:o.call(r,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,i){var n;for(const r of this.behaviourComponents)(n=r.createBehaviours)==null||n.call(r,this,t,i)}onAfterBuildDocument(e){for(const t of this.behaviourComponents)typeof t.afterCreateDocument=="function"&&t.afterCreateDocument(this,e);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(e,t){var i;if((i=this.behaviours)!=null&&i.length){t.beginBlock('def Scope "Behaviors"');for(const n of this.behaviours)n.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){Kne&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const t of this.behaviourComponentsCopy)typeof t.afterSerialize=="function"&&(t.afterSerialize.constructor.name==="AsyncFunction"?await t.afterSerialize(this,e):t.afterSerialize(this,e));this.behaviours.length=0}}var Zne=Object.defineProperty,$ne=Object.getOwnPropertyDescriptor,NR=(s,e,t,i)=>{for(var n=i>1?void 0:i?$ne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Zne(e,t,n),n},UE;const mG=(UE=class extends lr{constructor(){super(...arguments);h(this,"threshold");h(this,"intensity");h(this,"scatter");h(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>1*Math.PI*(1-e)):(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>100*(1-e))}onCreateEffect(){let e;if(this.selectiveBloom==null&&(this.selectiveBloom=mG.useSelectiveBloom),this.selectiveBloom){const t=e=new X3(this.context.scene,this.context.mainCamera,{blendFunction:Vt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new oR({blendFunction:Vt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});return this.intensity.onValueChanged=t=>{e.intensity=t},this.threshold.onValueChanged=t=>{e.luminanceMaterial.threshold=t},this.scatter.onValueChanged=t=>{e.luminancePass.enabled=!0,e.luminanceMaterial.smoothing=t},e}},h(UE,"useSelectiveBloom",!1),UE);let Nd=mG;NR([x(kt)],Nd.prototype,"threshold",2);NR([x(kt)],Nd.prototype,"intensity",2);NR([x(kt)],Nd.prototype,"scatter",2);aa("Bloom",Nd);const jf="NEEDLE_progressive",Ks=ne("debugprogressive"),$C=Symbol("needle-progressive-texture"),wp=new Map;if(Ks){let s=function(){e+=1,tn(`Toggle LOD level: ${e}<br/>Registered objects: ${wp.size}`),console.log("Toggle LOD level",e,wp);const i=ri.Current;wp.forEach((n,r)=>{for(const o of n.keys){const a=r[o];if(a instanceof At){const l=Ti.getMeshLODInformation(a),c=l?Math.min(e,l.lods.length):0;r["DEBUG:LOD"]=c,Ti.assignMeshLOD(i,n.sourceId,r,c),l&&(t=Math.max(t,l.lods.length-1))}else if(r instanceof Ot){Ti.assignTextureLOD(i,n.sourceId,r,e);break}}}),e>=t&&(e=-1)},e=-1,t=2;window.addEventListener("keyup",i=>{i.key==="p"&&s()}),ri.registerCallback(bn.ContextCreated,i=>{const n=document.createElement("button");n.innerText="Toggle Progressive",n.onclick=s,i.context.menu.appendChild(n)})}function KO(s,e,t){var n;if(!Ks)return;wp.has(s)||wp.set(s,{keys:[],sourceId:t});const i=wp.get(s);((n=i==null?void 0:i.keys)==null?void 0:n.includes(e))==!1&&i.keys.push(e)}const zr=class{constructor(e,t,i){h(this,"parser");h(this,"sourceId");h(this,"context");this.parser=e,this.sourceId=t,this.context=i}get name(){return jf}static getMeshLODInformation(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static hasLODLevelAvailable(e,t){var r;if(e instanceof Ot){for(const o of Object.keys(e)){const a=e[o];if(a instanceof _t&&this.hasLODLevelAvailable(a,t))return!0}return!1}else if(e instanceof Er){for(const o of e.children)if(o instanceof de&&this.hasLODLevelAvailable(o,t))return!0}let i,n;if(e instanceof de?i=e.geometry:e instanceof _t&&(i=e),i&&(r=i==null?void 0:i.userData)!=null&&r.LODS){const o=i.userData.LODS;if(n=this.lodInfos.get(o.key),t===void 0)return n!=null;if(n)return Array.isArray(n.lods)?t<n.lods.length:t===0}return!1}static assignMeshLOD(e,t,i,n){if(!i)return Promise.resolve(null);if(i instanceof de){const r=i.geometry,o=this.getAssignedLODInformation(r);if(!o)return Promise.resolve(null);jv(i)||W_(i,i.geometry);const a=this.onProgressiveLoadStart(e,t,i,null);return i["LOD:requested level"]=n,zr.getOrLoadLOD(e,t,r,n).then(l=>{if(i["LOD:requested level"]===n){if(delete i["LOD:requested level"],Array.isArray(l)){const c=o.index||0;l=l[c]}l&&r!=l&&(Ks=="verbose"&&console.log("Progressive Mesh "+i.name+" loaded",r,"→",l,`
5509
- `,i),l instanceof At&&(i.geometry=l,Ks&&KO(i,"geometry",t)))}return this.onProgressiveLoadEnd(a),l}).catch(l=>(this.onProgressiveLoadEnd(a),console.error("Error loading mesh LOD",i,l),null))}else Ks&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",i);return Promise.resolve(null)}static assignTextureLOD(e,t,i,n=0){if(!i)return Promise.resolve(null);if(i instanceof Ot){const r=i,o=[],a=new Array;if(r instanceof yA)for(const l of Object.keys(r.uniforms)){const c=r.uniforms[l].value;if(c instanceof _t){const u=this.assignTextureLODForSlot(e,t,c,n,r,l);o.push(u),a.push(l)}}else for(const l of Object.keys(r)){const c=r[l];if(c instanceof _t){const u=this.assignTextureLODForSlot(e,t,c,n,r,l);o.push(u),a.push(l)}}return wA(o).then(l=>{const c=new Array;for(let u=0;u<l.results.length;u++){const d=l.results[u],f=a[u];d instanceof _t?c.push({material:r,slot:f,texture:d,level:n}):c.push({material:r,slot:f,texture:null,level:n})}return c})}if(i instanceof _t){const r=i;return this.assignTextureLODForSlot(e,t,r,n,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,i,n,r,o){if((i==null?void 0:i.isTexture)!==!0)return Promise.resolve(null);const a=this.onProgressiveLoadStart(e,t,r,o);return zr.getOrLoadLOD(e,t,i,n).then(l=>Array.isArray(l)?null:(l==null?void 0:l.isTexture)===!0?(l!=i&&(r&&o&&(r[o]=l),Ks&&o&&r&&KO(r,o,t)),this.onProgressiveLoadEnd(a),l):(Ks=="verbose"&&console.warn("No LOD found for",i,n),this.onProgressiveLoadEnd(a),null)).catch(l=>(this.onProgressiveLoadEnd(a),console.error("Error loading LOD",i,l),null))}afterRoot(e){var i,n;Ks&&console.log("AFTER",this.sourceId,e),(i=this.parser.json.textures)==null||i.forEach((r,o)=>{if(r!=null&&r.extensions){const a=r==null?void 0:r.extensions[jf];if(a){for(const l of this.parser.associations.keys())if(l instanceof _t&&this.parser.associations.get(l).textures===o){const u=l;Ks&&console.log("> Progressive: register texture",o,u.name,u.uuid,u,a),u.source&&(u.source[$C]=a);const d=u.uuid;zr.assignLODInformation(u,d,0,0,void 0),zr.lodInfos.set(d,a),zr.lowresCache.set(d,u)}}}});const t=(r,o,a,l,c)=>{const u=o.geometry;u["needle:raycast-mesh"]=!0,u&&!jv(o)&&(Ks&&console.log("Set raycast mesh",o.name,o.uuid,u),W_(o,u),hw(u,!0).forEach(d=>{d instanceof de&&W_(d,u)})),u.userData||(u.userData={}),zr.assignLODInformation(u,r,a,l,c.density),zr.lodInfos.set(r,c)};return(n=this.parser.json.meshes)==null||n.forEach((r,o)=>{if(r!=null&&r.extensions){const a=r==null?void 0:r.extensions[jf];if(a&&a.lods){for(const l of this.parser.associations.keys())if(l instanceof de){const c=this.parser.associations.get(l);if(c.meshes===o){const u=l;Ks&&console.log("> Progressive: register mesh",o,u.name,a,u.uuid,u);const d=u.uuid,f=a.lods.length;if(u instanceof de){t(d,u,f,c.primitives,a);let p=zr.lowresCache.get(d);p?p.push(u.geometry):p=[u.geometry],zr.lowresCache.set(d,p)}}}}}}),null}static async getOrLoadLOD(e,t,i,n){var c,u,d;const r=Ks=="verbose",o=i.userData.LODS;if(!o)return null;const a=o==null?void 0:o.key;let l;if(i instanceof _t&&i.source&&i.source[$C]&&(l=i.source[$C]),l||(l=zr.lodInfos.get(a)),l){if(n>0){let m=!1;const A=Array.isArray(l.lods);if(A&&n>=l.lods.length?m=!0:A||(m=!0),m)return this.lowresCache.get(a)}const f=Array.isArray(l.lods)?l.lods[n].path:l.lods;if(!f)return Ks&&!l["missing:uri"]&&(l["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+n,l)),null;const p=Mc(t,f);if(p.endsWith(".glb")||p.endsWith(".gltf")){if(!l.guid)return console.warn("missing pointer for glb/gltf texture",l),null;const m=p+"_"+l.guid,A=this.previouslyLoaded.get(m);if(A!==void 0){r&&console.log(`LOD ${n} was already loading/loaded: ${m}`);let y=await A.catch(M=>(console.error(`Error loading LOD ${n} from ${p}
5510
- `,M),null)),b=!1;if(y==null||(y instanceof _t&&i instanceof _t?(c=y.image)!=null&&c.data||(u=y.source)!=null&&u.data?y=this.copySettings(i,y):(b=!0,this.previouslyLoaded.delete(m)):y instanceof At&&i instanceof At&&((d=y.attributes.position)!=null&&d.array||(b=!0,this.previouslyLoaded.delete(m)))),!b)return y}const g=l,v=new Promise(async(y,b)=>{const M=new em;IA(M,e),Ks&&(await Pa(Math.random()*1e3),r&&console.warn("Start loading (delayed) "+p,g.guid));const E=await M.loadAsync(p).catch(P=>(console.error(`Error loading LOD ${n} from ${p}
5509
+ `,i),l instanceof At&&(i.geometry=l,Ks&&KO(i,"geometry",t)))}return this.onProgressiveLoadEnd(a),l}).catch(l=>(this.onProgressiveLoadEnd(a),console.error("Error loading mesh LOD",i,l),null))}else Ks&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",i);return Promise.resolve(null)}static assignTextureLOD(e,t,i,n=0){if(!i)return Promise.resolve(null);if(i instanceof Ot){const r=i,o=[],a=new Array;if(r instanceof yA)for(const l of Object.keys(r.uniforms)){const c=r.uniforms[l].value;if(c instanceof _t){const u=this.assignTextureLODForSlot(e,t,c,n,r,l);o.push(u),a.push(l)}}else for(const l of Object.keys(r)){const c=r[l];if(c instanceof _t){const u=this.assignTextureLODForSlot(e,t,c,n,r,l);o.push(u),a.push(l)}}return wA(o).then(l=>{const c=new Array;for(let u=0;u<l.results.length;u++){const d=l.results[u],f=a[u];d instanceof _t?c.push({material:r,slot:f,texture:d,level:n}):c.push({material:r,slot:f,texture:null,level:n})}return c})}if(i instanceof _t){const r=i;return this.assignTextureLODForSlot(e,t,r,n,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,i,n,r,o){if((i==null?void 0:i.isTexture)!==!0)return Promise.resolve(null);const a=this.onProgressiveLoadStart(e,t,r,o);return zr.getOrLoadLOD(e,t,i,n).then(l=>Array.isArray(l)?null:(l==null?void 0:l.isTexture)===!0?(l!=i&&(r&&o&&(r[o]=l),Ks&&o&&r&&KO(r,o,t)),this.onProgressiveLoadEnd(a),l):(Ks=="verbose"&&console.warn("No LOD found for",i,n),this.onProgressiveLoadEnd(a),null)).catch(l=>(this.onProgressiveLoadEnd(a),console.error("Error loading LOD",i,l),null))}afterRoot(e){var i,n;Ks&&console.log("AFTER",this.sourceId,e),(i=this.parser.json.textures)==null||i.forEach((r,o)=>{if(r!=null&&r.extensions){const a=r==null?void 0:r.extensions[jf];if(a){for(const l of this.parser.associations.keys())if(l instanceof _t&&this.parser.associations.get(l).textures===o){const u=l;Ks&&console.log("> Progressive: register texture",o,u.name,u.uuid,u,a),u.source&&(u.source[$C]=a);const d=u.uuid;zr.assignLODInformation(u,d,0,0,void 0),zr.lodInfos.set(d,a),zr.lowresCache.set(d,u)}}}});const t=(r,o,a,l,c)=>{const u=o.geometry;u["needle:raycast-mesh"]=!0,u&&!jv(o)&&(Ks&&console.log("Set raycast mesh",o.name,o.uuid,u),W_(o,u),hw(u,!0).forEach(d=>{d instanceof de&&W_(d,u)})),u.userData||(u.userData={}),zr.assignLODInformation(u,r,a,l,c.density),zr.lodInfos.set(r,c)};return(n=this.parser.json.meshes)==null||n.forEach((r,o)=>{if(r!=null&&r.extensions){const a=r==null?void 0:r.extensions[jf];if(a&&a.lods){for(const l of this.parser.associations.keys())if(l instanceof de){const c=this.parser.associations.get(l);if(c.meshes===o){const u=l;Ks&&console.log("> Progressive: register mesh",o,u.name,a,u.uuid,u);const d=u.uuid,f=a.lods.length;if(u instanceof de){t(d,u,f,c.primitives,a);let p=zr.lowresCache.get(d);p?p.push(u.geometry):p=[u.geometry],zr.lowresCache.set(d,p)}}}}}}),null}static async getOrLoadLOD(e,t,i,n){var c,u,d;const r=Ks=="verbose",o=i.userData.LODS;if(!o)return null;const a=o==null?void 0:o.key;let l;if(i instanceof _t&&i.source&&i.source[$C]&&(l=i.source[$C]),l||(l=zr.lodInfos.get(a)),l){if(n>0){let m=!1;const A=Array.isArray(l.lods);if(A&&n>=l.lods.length?m=!0:A||(m=!0),m)return this.lowresCache.get(a)}const f=Array.isArray(l.lods)?l.lods[n].path:l.lods;if(!f)return Ks&&!l["missing:uri"]&&(l["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+n,l)),null;let p=Mc(t,f);if(p.endsWith(".glb")||p.endsWith(".gltf")){if(!l.guid)return console.warn("missing pointer for glb/gltf texture",l),null;const m=p+"_"+l.guid,A=this.previouslyLoaded.get(m);if(A!==void 0){r&&console.log(`LOD ${n} was already loading/loaded: ${m}`);let y=await A.catch(M=>(console.error(`Error loading LOD ${n} from ${p}
5510
+ `,M),null)),b=!1;if(y==null||(y instanceof _t&&i instanceof _t?(c=y.image)!=null&&c.data||(u=y.source)!=null&&u.data?y=this.copySettings(i,y):(b=!0,this.previouslyLoaded.delete(m)):y instanceof At&&i instanceof At&&((d=y.attributes.position)!=null&&d.array||(b=!0,this.previouslyLoaded.delete(m)))),!b)return y}const g=l,v=new Promise(async(y,b)=>{const M=new em;if(IA(M,e),l&&Array.isArray(l.lods)){const P=l.lods[n];P.hash&&(p+="?v="+P.hash)}Ks&&(await Pa(Math.random()*1e3),r&&console.warn("Start loading (delayed) "+p,g.guid));const E=await M.loadAsync(p).catch(P=>(console.error(`Error loading LOD ${n} from ${p}
5511
5511
  `,P),null));if(!E)return null;const T=E.parser;r&&console.log("Loading finished "+p,g.guid);let C=0;if(E.parser.json.textures){let P=!1;for(const S of E.parser.json.textures){if(S!=null&&S.extensions){const I=S==null?void 0:S.extensions[jf];if(I!=null&&I.guid&&I.guid===g.guid){P=!0;break}}C++}if(P){let S=await T.getDependency("texture",C);return r&&console.log('change "'+i.name+'" → "'+S.name+'"',p,C,S,m),i instanceof _t&&(S=this.copySettings(i,S)),S&&(S.guid=g.guid),y(S)}}if(C=0,E.parser.json.meshes){let P=!1;for(const S of E.parser.json.meshes){if(S!=null&&S.extensions){const I=S==null?void 0:S.extensions[jf];if(I!=null&&I.guid&&I.guid===g.guid){P=!0;break}}C++}if(P){const S=await T.getDependency("mesh",C),I=g;if(r&&console.log(`Loaded Mesh "${S.name}"`,p,C,S,m),S instanceof de){const H=S.geometry;return zr.assignLODInformation(H,a,n,void 0,I.density),y(H)}else{const H=new Array;for(let U=0;U<S.children.length;U++){const D=S.children[U];if(D instanceof de){const V=D.geometry;zr.assignLODInformation(V,a,n,U,I.density),H.push(V)}}return y(H)}}}return y(null)});return this.previouslyLoaded.set(m,v),await v}else if(i instanceof _t){r&&console.log("Load texture from uri: "+p);const A=await new ml().loadAsync(p);return A?(A.guid=l.guid,A.flipY=!1,A.needsUpdate=!0,A.colorSpace=i.colorSpace,r&&console.log(l,A)):Ks&&console.warn("failed loading",p),A}}else Ks&&console.warn(`Can not load LOD ${n}: no LOD info found for "${a}" ${i.name}`,i.type);return null}static assignLODInformation(e,t,i,n,r){if(!e)return;e.userData||(e.userData={});const o=new ese(t,i,n,r);e.userData.LODS=o,e.userData.LOD=i}static getAssignedLODInformation(e){var t;return((t=e==null?void 0:e.userData)==null?void 0:t.LODS)||null}static copySettings(e,t){const i=this._copiedTextures.get(e);return i||(t=t.clone(),this._copiedTextures.set(e,t),t.offset=e.offset,t.repeat=e.repeat,t.colorSpace=e.colorSpace,t)}static beginListenStart(e,t){this._progressiveEventListeners.has(e)||this._progressiveEventListeners.set(e,new ZO),this._progressiveEventListeners.get(e).start.push(t)}static stopListenStart(e,t){if(!this._progressiveEventListeners.has(e))return;const i=this._progressiveEventListeners.get(e).start,n=i.indexOf(t);n>=0&&i.splice(n,1)}static beginListenEnd(e,t){this._progressiveEventListeners.has(e)||this._progressiveEventListeners.set(e,new ZO),this._progressiveEventListeners.get(e).end.push(t)}static stopListenEnd(e,t){if(!this._progressiveEventListeners.has(e))return;const i=this._progressiveEventListeners.get(e).end,n=i.indexOf(t);n>=0&&i.splice(n,1)}static onProgressiveLoadStart(e,t,i,n){this._currentProgressiveLoadingInfo.has(e)||this._currentProgressiveLoadingInfo.set(e,[]);const r=new gG(e,t,i,n),o=this._currentProgressiveLoadingInfo.get(e),a=this._progressiveEventListeners.get(e);return a&&a.onStart(r),o.push(r),r}static onProgressiveLoadEnd(e){if(!e)return;const t=e.context;if(!this._currentProgressiveLoadingInfo.has(t))return;const i=this._currentProgressiveLoadingInfo.get(t),n=i.indexOf(e);if(n<0)return;i.splice(n,1);const r=this._progressiveEventListeners.get(t);r&&r.onEnd(e)}};let Ti=zr;h(Ti,"lodInfos",new Map),h(Ti,"previouslyLoaded",new Map),h(Ti,"lowresCache",new Map),h(Ti,"_copiedTextures",new Map),h(Ti,"_progressiveEventListeners",new Map),h(Ti,"_currentProgressiveLoadingInfo",new Map);class ese{constructor(e,t,i,n){h(this,"key");h(this,"level");h(this,"index");h(this,"density");this.key=e,this.level=t,i!=null&&(this.index=i),n!=null&&(this.density=n)}}class gG{constructor(e,t,i,n){h(this,"context");h(this,"source");h(this,"material");h(this,"slot");h(this,"mesh");this.context=e,this.source=t,i instanceof de?this.mesh=i:this.material=i,this.slot=n}}class ZO{constructor(){h(this,"start",[]);h(this,"end",[])}onStart(e){for(const t of this.start)t(e)}onEnd(e){for(const t of this.end)t(e)}}var tse=Object.defineProperty,ise=Object.getOwnPropertyDescriptor,Yr=(s,e,t,i)=>{for(var n=i>1?void 0:i?ise(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&tse(e,t,n),n};class Io extends Me{constructor(){super(...arguments);h(this,"attachedRigidbody",null);h(this,"isTrigger",!1);h(this,"sharedMaterial");h(this,"membership",[0]);h(this,"filter");h(this,"updateProperties",()=>{var t;(t=this.context.physics.engine)==null||t.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Pi))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Pi))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Pi))}onDisable(){var t;(t=this.context.physics.engine)==null||t.removeBody(this)}get body(){var t;return(t=this.context.physics.engine)==null?void 0:t.getBody(this)}updatePhysicsMaterial(){var t;(t=this.context.physics.engine)==null||t.updatePhysicsMaterial(this)}}Yr([x(Pi)],Io.prototype,"attachedRigidbody",2);Yr([x()],Io.prototype,"isTrigger",2);Yr([x()],Io.prototype,"sharedMaterial",2);Yr([x()],Io.prototype,"membership",2);Yr([x()],Io.prototype,"filter",2);class pm extends Io{constructor(){super(...arguments);h(this,"radius",.5);h(this,"center",new w(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addSphereCollider(this),$x(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),aI(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Yr([Hs(),x()],pm.prototype,"radius",2);Yr([x(w)],pm.prototype,"center",2);class mm extends Io{constructor(){super(...arguments);h(this,"size",new w(1,1,1));h(this,"center",new w(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addBoxCollider(this,this.size),$x(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),aI(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Yr([Hs(),x(w)],mm.prototype,"size",2);Yr([x(w)],mm.prototype,"center",2);class zd extends Io{constructor(){super(...arguments);h(this,"sharedMesh");h(this,"convex",!1)}onEnable(){var i,n,r;if(super.onEnable(),!this.context.physics.engine)return;(i=this.sharedMesh)!=null&&i.isMesh||this.gameObject instanceof de&&(this.sharedMesh=this.gameObject);const t=0;if((n=this.sharedMesh)!=null&&n.isMesh)this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Hi(this.gameObject)),Ti.assignMeshLOD(this.context,this.sourceId,this.sharedMesh,t).then(o=>{o&&this.activeAndEnabled&&this.context.physics.engine&&this.sharedMesh&&(this.context.physics.engine.removeBody(this),this.sharedMesh.geometry=o,this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Hi(this.gameObject)))});else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${((r=this.sharedMesh)==null?void 0:r.name)||this.gameObject.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);const a=new Array;for(const l in o.children){const c=o.children[l];c.isMesh&&(this.context.physics.engine.addMeshCollider(this,c,this.convex,Hi(this.gameObject)),a.push(Ti.assignMeshLOD(this.context,this.sourceId,c,t)))}Promise.all(a).then(l=>{var u,d;if(l.some(f=>f)==!1)return;(u=this.context.physics.engine)==null||u.removeBody(this);const c=new de;for(const f of l)f&&this.activeAndEnabled&&(c.geometry=f,(d=this.context.physics.engine)==null||d.addMeshCollider(this,c,this.convex,Hi(this.gameObject)))})}}}}Yr([x(de)],zd.prototype,"sharedMesh",2);Yr([x()],zd.prototype,"convex",2);class Sc extends Io{constructor(){super(...arguments);h(this,"center",new w(0,0,0));h(this,"radius",.5);h(this,"height",2)}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addCapsuleCollider(this,this.height,this.radius)}}Yr([x(w)],Sc.prototype,"center",2);Yr([x()],Sc.prototype,"radius",2);Yr([x()],Sc.prototype,"height",2);var nse=Object.defineProperty,sse=Object.getOwnPropertyDescriptor,zR=(s,e,t,i)=>{for(var n=i>1?void 0:i?sse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&nse(e,t,n),n};class Gd extends Me{constructor(){super(...arguments);h(this,"objectBounds",!1);h(this,"color");h(this,"isGizmo",!0);h(this,"_gizmoObject",null);h(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!BA||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new nI(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=dR(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),ji.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){var t;for(;this._boxHelper;)(t=this._boxHelper)==null||t.update(),yield}}zR([x()],Gd.prototype,"objectBounds",2);zR([x(xe)],Gd.prototype,"color",2);zR([x()],Gd.prototype,"isGizmo",2);const rse=ne("gizmos"),ose=ne("debugboxhelper"),zo=class extends Me{constructor(){super(...arguments);h(this,"box",null);h(this,"_lastMatrixUpdateFrame",-1);h(this,"_helper",null);h(this,"_color",null)}isInBox(t,i){var r;if(!t)return;if(this.box||(this.box=new Ai),t.type==="Mesh")zo.testBox.setFromObject(t);else if(t.type==="Group"){if(zo.testBox.makeEmpty(),t.children.length>0)for(let o=0;o<t.children.length;o++)t.children[o].type==="Mesh"&&zo.testBox.expandByObject(t)}else{const o=Nt(t,zo._position),a=Hi(t,zo._size);i!==void 0&&a.multiplyScalar(i),zo.testBox.setFromCenterAndSize(o,a)}this.updateBox();const n=(r=this.box)==null?void 0:r.intersectsBox(zo.testBox);return n&&ose&&bt.DrawWireBox3(zo.testBox,16711680,5),n}intersects(t){return t?this.updateBox(!1).intersectsBox(t):!1}updateBox(t=!1){if(this.box||(this.box=new Ai),t||this.context.time.frameCount!=this._lastMatrixUpdateFrame){const i=this._lastMatrixUpdateFrame<0;this._lastMatrixUpdateFrame=this.context.time.frameCount;const n=i,r=Nt(this.gameObject,zo._position,n),o=Hi(this.gameObject,zo._size);this.box.setFromCenterAndSize(r,o)}return this.box}awake(){this._helper=null,this._color=null,this.box=null}showHelper(t=null,i=!1){var n;if(!(!rse&&!i)){if(this._helper){t&&((n=this._color)==null||n.set(t)),this.gameObject.add(this._helper);return}this._helper=dR(t),this.gameObject.add(this._helper)}}};let Xo=zo;h(Xo,"testBox",new Ai),h(Xo,"_position",new w),h(Xo,"_size",new w(.01,.01,.01));class ase extends kN{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const i in t)for(const n in t[i])e._simpleState__statesProperties[n]||(e._simpleState__statesProperties[n]=[]),e._simpleState__statesProperties[n].push(i);for(const i of e._components)e._simpleState__statesProperties[i.id]&&(e._simpleState__normalStyles[i.id]=i.inline?i.inline:i._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;const i=[];for(const n in t)this._simpleState__statesProperties[n]||(this._simpleState__statesProperties[n]=[],i.push(n)),this._simpleState__statesProperties[n].push(e);for(const n of this._components)i.indexOf(n.id)>-1&&(this._simpleState__normalStyles[n.id]=n.inline?n.inline:n._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const i in e)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=e[i]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var lse=Object.defineProperty,cse=Object.getOwnPropertyDescriptor,vG=(s,e,t,i)=>{for(var n=i>1?void 0:i?cse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&lse(e,t,n),n};class gm extends Me{constructor(){super(...arguments);h(this,"effectColor");h(this,"effectDistance")}}vG([x(wi)],gm.prototype,"effectColor",2);vG([x(te)],gm.prototype,"effectDistance",2);var hse=Object.defineProperty,use=Object.getOwnPropertyDescriptor,ZA=(s,e,t,i)=>{for(var n=i>1?void 0:i?use(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&hse(e,t,n),n};const eE=ne("debugui"),tE=ne("debuguilayout");class GR{constructor(){h(this,"width");h(this,"height")}}class HR{constructor(){h(this,"x");h(this,"y");h(this,"width");h(this,"height")}}const ma=new w,ag=new we,X0=new Ce,AG=class extends Da{constructor(){super(...arguments);h(this,"_anchoredPosition");h(this,"sizeDelta",new te(100,100));h(this,"pivot",new te(.5,.5));h(this,"anchorMin",new te(0,0));h(this,"anchorMax",new te(1,1));h(this,"minWidth");h(this,"minHeight");h(this,"lastMatrix");h(this,"rectBlock");h(this,"_transformNeedsUpdate",!1);h(this,"_initialPosition");h(this,"_parentRectTransform");h(this,"_lastUpdateFrame",-1);h(this,"_lastAnchoring");h(this,"_createdBlocks",[]);h(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new te),this._anchoredPosition}set anchoredPosition(e){this._anchoredPosition=e}get width(){let e=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const t=this._parentRectTransform.width,i=this.anchorMax.x-this.anchorMin.x;e=t*i,e+=this.sizeDelta.x}return this.minWidth!==void 0&&e<this.minWidth?this.minWidth:e}get height(){let e=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const t=this._parentRectTransform.height,i=this.anchorMax.y-this.anchorMin.y;e=t*i,e+=this.sizeDelta.y}return this.minHeight!==void 0&&e<this.minHeight?this.minHeight:e}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new te),this.lastMatrix=new we,this.rectBlock=new me,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Vf(this,"_anchoredPosition",()=>{this.markDirty()}),Vf(this,"sizeDelta",()=>{this.markDirty()}),Vf(this,"pivot",()=>{this.markDirty()}),Vf(this,"anchorMin",()=>{this.markDirty()}),Vf(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var e;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(e=this.Canvas)==null||e.registerTransform(this)}onDisable(){var e;super.onDisable(),this.removeShadowComponent(),(e=this.Canvas)==null||e.unregisterTransform(this)}onParentRectTransformChanged(e){this._transformNeedsUpdate||this.onApplyTransform(tE?`${e.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(tE&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(e){var n;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const t=this.shadowComponent;if(!t)return;this.gameObject.parent?this._parentRectTransform=oe.getComponentInParent(this.gameObject.parent,AG):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,tE&&console.warn("RectTransform → ApplyTransform",this.name+" because "+e),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,ma.set(0,0,0),this.applyPivot(ma),t.matrix.setPosition(ma.x,ma.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(X0.copy(this.gameObject.quaternion),X0.x*=-1,X0.z*=-1,ag.makeRotationFromQuaternion(X0),t.matrix.premultiply(ag)),ma.set(0,0,0),this.applyAnchoring(ma),(n=this.Canvas)!=null&&n.screenspace?ma.z+=.1:ma.z+=.01,ag.identity(),ag.setPosition(ma.x,ma.y,ma.z),t.matrix.premultiply(ag),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const r of CR(this.gameObject,Da,i,1)){if(r===this||!r.activeAndEnabled)continue;const o=r;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(e){this._lastAnchoring||(this._lastAnchoring=new te);const t=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=t.x,this.gameObject.position.y+=t.y,this._lastAnchoring.copy(this._anchoredPosition),e.x+=this._initialPosition.x-this.gameObject.position.x,e.y+=this._initialPosition.y-this.gameObject.position.y,e.z+=this._initialPosition.z-this.gameObject.position.z;const i=this._parentRectTransform;if(i){let n=0;const r=1-this.anchorMax.y-this.anchorMin.y;n-=i.height*.5*r,e.y+=n;let o=0;const a=1-this.anchorMax.x-this.anchorMin.x;o-=i.width*.5*a,e.x+=o}}applyPivot(e){if(this.pivot&&!this.isRoot()){const t=this.pivot.x-.5;e.x-=t*this.sizeDelta.x*this.gameObject.scale.x;const i=this.pivot.y-.5;e.y-=i*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const e={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(e),e}ensureValidSize(e,t=1e-4){return e.width<=0&&(e.width=t),e.height<=0&&(e.height=1e-4),e}createNewBlock(e){e={...this.getBasicOptions(),...e},eE&&console.log(this.name,e);const t=new BI(e);return this._createdBlocks.push(t),t}createNewText(e){eE&&console.log(e),e={...this.getBasicOptions(),...e},eE&&console.log(this.name,e);const t=new DI(e);return this._createdTextBlocks.push(t),t}};let Dr=AG;ZA([x(te)],Dr.prototype,"anchoredPosition",1);ZA([x(te)],Dr.prototype,"sizeDelta",2);ZA([x(te)],Dr.prototype,"pivot",2);ZA([x(te)],Dr.prototype,"anchorMin",2);ZA([x(te)],Dr.prototype,"anchorMax",2);var dse=Object.defineProperty,fse=Object.getOwnPropertyDescriptor,yG=(s,e,t,i)=>{for(var n=i>1?void 0:i?fse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&dse(e,t,n),n};const Y0={backgroundColor:new xe(1,1,1),backgroundOpacity:1,borderColor:new xe(1,1,1),borderOpacity:1};var NE;const $_=(NE=class extends Da{constructor(){super(...arguments);h(this,"_alphaFactor",1);h(this,"sRGBColor",new xe(1,0,1));h(this,"raycastTarget",!0);h(this,"uiObject",null);h(this,"_color",null);h(this,"_rect",null);h(this,"_stateManager",null);h(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new wi(1,1,1,1)),this._color}set color(e){(!this._color||this._color.r!==e.r||this._color.g!==e.g||this._color.b!==e.b||this._color.alpha!==e.alpha)&&(this._color||(this._color=new wi(1,1,1,1)),this._color.copy(e),this.onColorChanged())}setAlphaFactor(e){this._alphaFactor=e,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),Y0.backgroundColor=this.sRGBColor,Y0.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(Y0,this._alphaFactor),this.uiObject.set(Y0),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=oe.getComponent(this.gameObject,Dr)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var e;(e=this.uiObject)==null||e.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(e){return super.__internalNewInstanceCreated(e),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone()),this}setState(e){this.makePanel(),this.uiObject&&(this.uiObject.setState(e),this==null||this.markDirty())}setupState(e){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new ase(this.uiObject)),this.uiObject.setupState(e.state,e.attributes))}setOptions(e){this.makePanel(),this.uiObject&&this.uiObject.set(e)}awake(){super.awake(),this.makePanel(),Vf(this,"_color",()=>Nie(this,this.onColorChanged))}onEnable(){var e;super.onEnable(),this.uiObject&&((e=this.rectTransform.shadowComponent)==null||e.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const e=.015,t={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:e};this.onBeforeCreate(t),this.applyEffects(t),this.onCreate(t),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(e){}onCreate(e){this.uiObject=this.rectTransform.createNewBlock(e),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(e,t=1){var n;const i=(n=this.gameObject)==null?void 0:n.getComponent(gm);i&&(i.effectDistance&&(e.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(e.borderColor=i.effectColor,e.borderOpacity=i.effectColor.alpha*t))}async setTexture(e){if(this.setOptions({backgroundOpacity:0}),e){if($_.textureCache.has(e))e=$_.textureCache.get(e);else if(!e.isRenderTargetTexture){const t=e.clone();t.colorSpace=yi,$_.textureCache.set(e,t),e=t}this.setOptions({backgroundImage:e,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"}),Ti.assignTextureLOD(this.context,this.sourceId,e,0).then(t=>{t instanceof _t&&this.setOptions({backgroundImage:t})})}else this.setOptions({backgroundImage:void 0,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},h(NE,"textureCache",new Map),NE);let Hd=$_;yG([x(wi)],Hd.prototype,"color",1);yG([x()],Hd.prototype,"raycastTarget",2);class $A extends Hd{constructor(){super(...arguments);h(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var pse=Object.defineProperty,mse=Object.getOwnPropertyDescriptor,Fw=(s,e,t,i)=>{for(var n=i>1?void 0:i?mse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&pse(e,t,n),n};let QR=class{constructor(){h(this,"texture",null);h(this,"rect")}};Fw([x(_t)],QR.prototype,"texture",2);let vm=class extends $A{constructor(){super(...arguments);h(this,"_sprite");h(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new QR),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var i,n,r,o,a,l,c;const t=this.sprite;switch((i=t==null?void 0:t.texture)==null?void 0:i.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!((r=(n=t==null?void 0:t.texture)==null?void 0:n.name)!=null&&r.length)&&((a=(o=t==null?void 0:t.texture)==null?void 0:o.image)==null?void 0:a.width)===32&&((c=(l=t==null?void 0:t.texture)==null?void 0:l.image)==null?void 0:c.height)===32}onBeforeCreate(t){var i,n;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((n=(i=this.sprite)==null?void 0:i.texture)==null?void 0:n.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};Fw([x(QR)],vm.prototype,"sprite",1);Fw([x()],vm.prototype,"pixelsPerUnitMultiplier",2);class Uw extends $A{constructor(){super(...arguments);h(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(t){this._mainTexture!==t&&(this._mainTexture=t,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Fw([x(_t)],Uw.prototype,"mainTexture",1);var gse=Object.defineProperty,vse=Object.getOwnPropertyDescriptor,Ro=(s,e,t,i)=>{for(var n=i>1?void 0:i?vse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&gse(e,t,n),n};const xu=ne("debugbutton");class Xh{constructor(){h(this,"colorMultiplier");h(this,"disabledColor");h(this,"fadeDuration");h(this,"highlightedColor");h(this,"normalColor");h(this,"pressedColor");h(this,"selectedColor")}}Ro([x()],Xh.prototype,"colorMultiplier",2);Ro([x(wi)],Xh.prototype,"disabledColor",2);Ro([x()],Xh.prototype,"fadeDuration",2);Ro([x(wi)],Xh.prototype,"highlightedColor",2);Ro([x(wi)],Xh.prototype,"normalColor",2);Ro([x(wi)],Xh.prototype,"pressedColor",2);Ro([x(wi)],Xh.prototype,"selectedColor",2);class Ase{constructor(){h(this,"disabledTrigger");h(this,"highlightedTrigger");h(this,"normalTrigger");h(this,"pressedTrigger");h(this,"selectedTrigger")}}class Tc extends Me{constructor(){super(...arguments);h(this,"onClick");h(this,"_isHovered",0);h(this,"colors");h(this,"transition");h(this,"animationTriggers");h(this,"animator");h(this,"_interactable",!0);h(this,"_requestedAnimatorTrigger");h(this,"_isInit",!1);h(this,"_image")}onPointerEnter(t){var n,r;const i=t.event.pointerType==="mouse"&&t.button===0;i&&(this._isHovered+=1),xu&&console.warn("Button Enter",i,this._isHovered,(n=this.animationTriggers)==null?void 0:n.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((r=this._image)==null||r.setState("hovered")),i&&this.context.input.setCursorPointer())}onPointerExit(){var t,i;this._isHovered-=1,this._isHovered<0&&(this._isHovered=0),xu&&console.log("Button Exit",this._isHovered,(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this._isHovered>0||(this._isHovered=0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("normal")),this.context.input.setCursorNormal()))}onPointerDown(t){var i,n;xu&&console.log("Button Down",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((n=this._image)==null||n.setState("pressed")))}onPointerUp(t){var i,n;xu&&console.warn("Button Up",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((n=this._image)==null||n.setState(this._isHovered?"hovered":"normal")))}onPointerClick(t){if(this.interactable&&!(t.button!==0&&t.event.pointerType===mw.Mouse)&&(xu&&(console.warn("Button Click",this.onClick),tn("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),t.use(),xu))){const i=this.gameObject.worldPosition;i.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),bt.DrawLabel(i,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}set interactable(t){this._interactable=t,this._image&&(this._image.setInteractable(t),t?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(t){this.interactable=t}awake(){super.awake(),xu&&console.log(this),this._isInit=!1,this.init()}start(){var t;(t=this._image)==null||t.setInteractable(this.interactable),this.gameObject.getComponentInParent(VA)||this.gameObject.addComponent(Ew)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*setAnimatorTriggerAtEndOfFrame(t){var i;this._requestedAnimatorTrigger=t,yield,yield,this._requestedAnimatorTrigger==t&&((i=this.animator)==null||i.SetTrigger(t))}init(){this._isInit||(this._isInit=!0,this._image=oe.getComponent(this.gameObject,vm),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(t){var p,m,A,g,v;t.setInteractable(this.interactable);const i=this.getFinalColor(t.color,(p=this.colors)==null?void 0:p.normalColor),n={state:"normal",attributes:{backgroundColor:i,backgroundOpacity:i.alpha}};t.setupState(n);const r=this.getFinalColor(t.color,(m=this.colors)==null?void 0:m.highlightedColor),o={state:"hovered",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};t.setupState(o);const a=this.getFinalColor(t.color,(A=this.colors)==null?void 0:A.pressedColor),l={state:"pressed",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};t.setupState(l);const c=this.getFinalColor(t.color,(g=this.colors)==null?void 0:g.selectedColor),u={state:"selected",attributes:{backgroundColor:c,backgroundOpacity:c.alpha}};t.setupState(u);const d=this.getFinalColor(t.color,(v=this.colors)==null?void 0:v.disabledColor),f={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};t.setupState(f)}getFinalColor(t,i){return i?t.clone().multiply(i).convertLinearToSRGB():t.clone().convertLinearToSRGB()}}Ro([x($n)],Tc.prototype,"onClick",2);Ro([x(Xh)],Tc.prototype,"colors",2);Ro([x()],Tc.prototype,"transition",2);Ro([x(Ase)],Tc.prototype,"animationTriggers",2);Ro([x(ks)],Tc.prototype,"animator",2);Ro([x()],Tc.prototype,"interactable",1);var yse=Object.defineProperty,_se=Object.getOwnPropertyDescriptor,Qn=(s,e,t,i)=>{for(var n=i>1?void 0:i?_se(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&yse(e,t,n),n};const $O=ne("debuguilayout");class Yh{constructor(){h(this,"left",0);h(this,"right",0);h(this,"top",0);h(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}Qn([x()],Yh.prototype,"left",2);Qn([x()],Yh.prototype,"right",2);Qn([x()],Yh.prototype,"top",2);Qn([x()],Yh.prototype,"bottom",2);class Po extends Me{constructor(){super(...arguments);h(this,"_rectTransform",null);h(this,"_needsUpdate",!1);h(this,"childAlignment",0);h(this,"reverseArrangement",!1);h(this,"spacing",0);h(this,"padding");h(this,"minWidth",0);h(this,"minHeight",0);h(this,"flexibleHeight",0);h(this,"flexibleWidth",0);h(this,"preferredHeight",0);h(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(t){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&($O&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){$O&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(Dr);const t=this.gameObject.getComponentInParent(Fs);t&&t.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const t=this.gameObject.getComponentInParent(Fs);t&&t.unregisterLayoutGroup(this)}set m_Spacing(t){t!==this.spacing&&(this._needsUpdate=!0,this.spacing=t)}get m_Spacing(){return this.spacing}}Qn([x()],Po.prototype,"childAlignment",2);Qn([x()],Po.prototype,"reverseArrangement",2);Qn([x()],Po.prototype,"spacing",2);Qn([x(Yh)],Po.prototype,"padding",2);Qn([x()],Po.prototype,"minWidth",2);Qn([x()],Po.prototype,"minHeight",2);Qn([x()],Po.prototype,"flexibleHeight",2);Qn([x()],Po.prototype,"flexibleWidth",2);Qn([x()],Po.prototype,"preferredHeight",2);Qn([x()],Po.prototype,"preferredWidth",2);class Jh extends Po{constructor(){super(...arguments);h(this,"childControlHeight",!0);h(this,"childControlWidth",!0);h(this,"childForceExpandHeight",!1);h(this,"childForceExpandWidth",!1);h(this,"childScaleHeight",!1);h(this,"childScaleWidth",!1)}onCalculateLayout(t){var C;const i=this.primaryAxis,n=t.width;let r=n;const o=t.height;let a=o;r-=this.padding.horizontal,a-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const l=i==="x",c=l?"y":"x",u=l?this.childControlWidth:this.childControlHeight,d=l?this.childControlHeight:this.childControlWidth,f=l?this.childForceExpandWidth:this.childForceExpandHeight,p=l?this.childForceExpandHeight:this.childForceExpandWidth,m=l?a:r,A=l?n:o,g=.5*(l?this.childAlignment%3:Math.floor(this.childAlignment/3));let v=0;l?v+=this.padding.left:v+=this.padding.top;let _=0,y=0;for(let P=0;P<this.gameObject.children.length;P++){const S=this.gameObject.children[P],I=oe.getComponent(S,Dr);I!=null&&I.activeAndEnabled&&(y+=1,l?_+=I.width:_+=I.height)}let b=0;const M=this.spacing*(y-1);if(f||u){let P=0;l?P=r-=M:P=a-=M,y>0&&(b=P/y)}let E=0;E+=this.padding.left,E-=this.padding.right,g!==0&&(v=A-_,v*=g,v-=M*g,l?(v-=this.padding.right*g,v+=this.padding.left*(1-g),v<this.padding.left&&(v=this.padding.left)):(v-=this.padding.bottom*g,v+=this.padding.top*(1-g),v<this.padding.top&&(v=this.padding.top)));let T=1;for(let P=0;P<this.gameObject.children.length;P++){const S=this.gameObject.children[P],I=oe.getComponent(S,Dr);if(I!=null&&I.activeAndEnabled){(C=I.pivot)==null||C.set(.5,.5),I.anchorMin.set(0,1),I.anchorMax.set(0,1);const H=n*.5+E*.5;I.anchoredPosition.x!==H&&(I.anchoredPosition.x=H);const U=o*-.5;I.anchoredPosition.y!==U&&(I.anchoredPosition.y=U),p&&d&&I.sizeDelta[c]!==m&&(I.sizeDelta[c]=m),f&&u&&I.sizeDelta[i]!==b&&(I.sizeDelta[i]=b);const D=l?I.width:I.height,V=D*.5;if(v+=V,f){const k=b*T-b*.5;k>v&&(v=k-b*.5+D+this.padding.left,v-=V)}let L=v;i==="y"&&(L=-L),I.anchoredPosition[i]!==L&&(I.anchoredPosition[i]=L),v+=V,v+=this.spacing,T+=1}}}}Qn([x()],Jh.prototype,"childControlHeight",2);Qn([x()],Jh.prototype,"childControlWidth",2);Qn([x()],Jh.prototype,"childForceExpandHeight",2);Qn([x()],Jh.prototype,"childForceExpandWidth",2);Qn([x()],Jh.prototype,"childScaleHeight",2);Qn([x()],Jh.prototype,"childScaleWidth",2);class VR extends Jh{get primaryAxis(){return"y"}}class WR extends Jh{get primaryAxis(){return"x"}}class jR extends Po{onCalculateLayout(){}}var bse=Object.defineProperty,xse=Object.getOwnPropertyDescriptor,El=(s,e,t,i)=>{for(var n=i>1?void 0:i?xse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&bse(e,t,n),n},_G=(s=>(s[s.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",s[s.ScreenSpaceCamera=1]="ScreenSpaceCamera",s[s.WorldSpace=2]="WorldSpace",s[s.Undefined=-1]="Undefined",s))(_G||{});const iE=ne("debuguilayout"),bG=class extends QA{constructor(){super(...arguments);h(this,"_renderOnTop");h(this,"_depthWrite",!1);h(this,"_doubleSided",!0);h(this,"_castShadows",!1);h(this,"_receiveShadows",!1);h(this,"_renderMode",-1);h(this,"_rootCanvas");h(this,"_scaleFactor",1);h(this,"worldCamera");h(this,"planeDistance",-1);h(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this));h(this,"previousParent",null);h(this,"_lastMatrixWorld",null);h(this,"_rectTransforms",[]);h(this,"_layoutGroups",new Map);h(this,"_receivers",[]);h(this,"onBeforeRenderRoutine",()=>{var e,t,i,n;if(this.previousParent=this.gameObject.parent,((e=this.context.xr)!=null&&e.isVR||(t=this.context.xr)!=null&&t.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(n=this.shadowComponent)==null||n.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),Vr.ensureUpdateMeshUI(V2,this.context))});h(this,"onAfterRenderRoutine",()=>{var e,t,i,n,r;if(((e=this.context.xr)!=null&&e.isVR||(t=this.context.xr)!=null&&t.isPassThrough)&&this.screenspace){(i=this.previousParent)==null||i.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const l=this.context.mainCamera;l==null||l.add(this.gameObject)}else this.previousParent.add(this.gameObject);const o=this.context.renderer.autoClear,a=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(n=this.shadowComponent)==null||n.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),Vr.ensureUpdateMeshUI(V2,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=o,this.context.renderer.autoClearColor=a,this.previousParent.add(this.gameObject)}(r=this._lastMatrixWorld)==null||r.copy(this.gameObject.matrixWorld)});h(this,"_updateRenderSettingsRoutine");h(this,"_activeRenderMode",-1);h(this,"_lastWidth",-1);h(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(e){e!==this._renderOnTop&&(this._renderOnTop=e,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(e){this._depthWrite!==e&&(this._depthWrite=e,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(e){this._doubleSided!==e&&(this._doubleSided=e,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(e){this._castShadows!==e&&(this._castShadows=e,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(e){this._receiveShadows!==e&&(this._receiveShadows=e,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(e){this._renderMode!==e&&(this._renderMode=e,this.onRenderSettingsChanged())}set rootCanvas(e){this._rootCanvas instanceof bG||(this._rootCanvas=e)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(e){this._scaleFactor=e}awake(){var e;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,iE&&console.log("Canvas.Awake()",((e=this.previousParent)==null?void 0:e.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new we,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const e=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);e!==-1&&this.context.pre_render_callbacks.splice(e,1);const t=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);t!==-1&&this.context.post_render_callbacks.splice(t,1)}registerTransform(e){this._rectTransforms.push(e)}unregisterTransform(e){const t=this._rectTransforms.indexOf(e);t!==-1&&this._rectTransforms.splice(t,1)}registerLayoutGroup(e){const t=e.gameObject;this._layoutGroups.set(t,e)}unregisterLayoutGroup(e){const t=e.gameObject;this._layoutGroups.delete(t)}registerEventReceiver(e){this._receivers.push(e)}unregisterEventReceiver(e){const t=this._receivers.indexOf(e);t!==-1&&this._receivers.splice(t,1)}async onEnterXR(e){this.screenspace?(e.xr.isVR||e.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await kU(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(e){this.screenspace&&(e.xr.isVR||e.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var e;for(const t of this._receivers)(e=t.onBeforeCanvasRender)==null||e.call(t,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new we);const e=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);iE&&e&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const t=!1;for(const i of this._rectTransforms){e&&i.markDirty();let n=this._layoutGroups.get(i.gameObject);i.isDirty&&!n&&(n=i.gameObject.getComponentInParent(Po)),(i.isDirty||n!=null&&n.isDirty)&&(iE&&!t&&console.log("CANVAS UPDATE ### "+i.name+" ##################################### "+this.context.time.frame),n==null||n.updateLayout(),i.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),ji.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Jb(this.shadowComponent,this);for(const e of oe.getComponentsInChildren(this.gameObject,Da))Jb(e.shadowComponent,this)}}onUpdateRenderMode(e=!1){if(!e&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let t=this.context.mainCameraComponent,i=10;switch(t&&t.nearClipPlane>0&&t.farClipPlane>0&&(i=et.lerp(t.nearClipPlane,t.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(t=this.worldCamera),this.planeDistance>0&&(i=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!t)return;const n=i+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-n,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(Dr);let o=!1;r.sizeDelta.x!==this.context.domWidth&&(o=!0),r.sizeDelta.y!==this.context.domHeight&&(o=!0);const a=t.fieldOfView*Math.PI/180,l=2*Math.tan(a/2)*Math.abs(n);this.gameObject.scale.x=l/this.context.domHeight,this.gameObject.scale.y=l/this.context.domHeight,this.gameObject.scale.z=.01,o&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r==null||r.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let Fs=bG;El([x()],Fs.prototype,"renderOnTop",1);El([x()],Fs.prototype,"depthWrite",1);El([x()],Fs.prototype,"doubleSided",1);El([x()],Fs.prototype,"castShadows",1);El([x()],Fs.prototype,"receiveShadows",1);El([x()],Fs.prototype,"renderMode",1);El([x(Fs)],Fs.prototype,"rootCanvas",1);El([x()],Fs.prototype,"scaleFactor",1);El([x(zi)],Fs.prototype,"worldCamera",2);El([x()],Fs.prototype,"planeDistance",2);var wse=Object.defineProperty,Sse=Object.getOwnPropertyDescriptor,qR=(s,e,t,i)=>{for(var n=i>1?void 0:i?Sse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&wse(e,t,n),n};class Hh extends Me{constructor(){super(...arguments);h(this,"_alpha",1);h(this,"interactable",!0);h(this,"blocksRaycasts",!0);h(this,"_isDirty",!1);h(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(t){t!==this._alpha&&(this._alpha=t,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),ji.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){this._buffer.length=0;for(const t of oe.getComponentsInChildren(this.gameObject,Da,this._buffer)){const i=t;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}qR([x()],Hh.prototype,"alpha",1);qR([x()],Hh.prototype,"interactable",2);qR([x()],Hh.prototype,"blocksRaycasts",2);var Cse=Object.defineProperty,Ese=Object.getOwnPropertyDescriptor,pn=(s,e,t,i)=>{for(var n=i>1?void 0:i?Ese(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Cse(e,t,n),n};const eL=ne("debugusdzbehaviours");function ey(s){s&&(s.getComponentInParent(VA)||(gt()&&console.warn("Create Raycaster on "+s.name+" because no raycaster was found in the hierarchy"),s.addNewComponent(So)))}class Qd extends Me{constructor(){super(...arguments);h(this,"object");h(this,"target");h(this,"duration",1);h(this,"relativeMotion",!1);h(this,"coroutine",null);h(this,"targetPos",new w);h(this,"targetRot",new Ce);h(this,"targetScale",new w)}start(){ey(this.gameObject)}onPointerClick(t){t.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const t=Nt(this.object).clone(),i=Nt(this.target).clone(),n=Ii(this.object).clone(),r=Ii(this.target).clone(),o=Hi(this.object).clone(),a=Hi(this.target).clone(),l=t.distanceTo(i),c=n.angleTo(r),u=o.distanceTo(a);if(l<.01&&c<.01&&u<.01){rr(this.object,i),ta(this.object,r),zv(this.object,a),this.coroutine=null;return}let d=0,f=0;for(;d<1;)d+=this.context.time.deltaTime/this.duration,d>1&&(d=1),f=d<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2,this.targetPos.lerpVectors(t,i,f),this.targetRot.slerpQuaternions(n,r,f),this.targetScale.lerpVectors(o,a,f),rr(this.object,this.targetPos),ta(this.object,this.targetRot),zv(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const t=this.object.position.clone(),i=this.object.quaternion.clone(),n=this.object.scale.clone(),r=this.target.position.clone(),o=this.target.quaternion.clone(),a=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(a);let l=0,c=0;for(;l<1;)l+=this.context.time.deltaTime/this.duration,l>1&&(l=1),c=l<.5?4*l*l*l:1-Math.pow(-2*l+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,c),this.object.quaternion.slerpQuaternions(i,this.targetRot,c),this.object.scale.lerpVectors(n,this.targetScale,c),yield;this.coroutine=null}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const n=new Jn("Move to "+((i=this.target)==null?void 0:i.name),Bs.tapTrigger(this.gameObject),li.transformAction(this.object,this.target,this.duration,this.relativeMotion?"relative":"absolute"));t.addBehavior(n)}}}pn([x(me)],Qd.prototype,"object",2);pn([x(me)],Qd.prototype,"target",2);pn([x()],Qd.prototype,"duration",2);pn([x()],Qd.prototype,"relativeMotion",2);var b_;const ql=(b_=class extends Me{constructor(){super(...arguments);h(this,"materialToSwitch");h(this,"variantMaterial");h(this,"fadeDuration",0);h(this,"_objectsWithThisMaterial",null);h(this,"selfModel");h(this,"targetModels")}start(){this._objectsWithThisMaterial=this.objectsWithThisMaterial,ey(this.gameObject)}onPointerClick(e){if(e.use(),!!this.variantMaterial)for(let t=0;t<this.objectsWithThisMaterial.length;t++){const i=this.objectsWithThisMaterial[t];i.material=this.variantMaterial}}get objectsWithThisMaterial(){return this._objectsWithThisMaterial!=null?this._objectsWithThisMaterial:(this._objectsWithThisMaterial=[],this.variantMaterial&&this.materialToSwitch&&this.context.scene.traverse(e=>{if(e instanceof de)if(Array.isArray(e.material)){for(const t of e.material)if(t===this.materialToSwitch){this.objectsWithThisMaterial.push(e);break}}else e.material===this.materialToSwitch&&this.objectsWithThisMaterial.push(e)}),this._objectsWithThisMaterial)}async beforeCreateDocument(e,t){this.targetModels=[],ql._materialTriggersPerId={},ql.variantSwitchIndex=0,this.materialToSwitch&&await Ti.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Ti.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(e,t,i){this.objectsWithThisMaterial.find(r=>r.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(ql._materialTriggersPerId[this.materialToSwitch.uuid]||(ql._materialTriggersPerId[this.materialToSwitch.uuid]=[]),ql._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(e,t){if(!this.materialToSwitch)return;const i=ql._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const n={};for(const r of i){const o=r.createVariants();o&&o.length>0&&(n[r.selfModel.uuid]=o)}for(const r of i){const o=[];for(const a in n)a!==r.selfModel.uuid&&o.push(...n[a]);r.createAndAttachBehaviors(e,n[r.selfModel.uuid],o)}}delete ql._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(e,t,i){const n=[],r=[],o=Math.max(0,this.fadeDuration);r.push(li.fadeAction([...this.targetModels,...i],o,!1)),n.push(li.fadeAction(t,o,!1)),r.push(li.fadeAction(t,o,!0)),e.addBehavior(new Jn("Select_"+this.selfModel.name,Bs.tapTrigger(this.selfModel),li.parallel(...r))),e.addBehavior(new Jn("StartHidden_"+this.selfModel.name,Bs.sceneStartTrigger(),li.parallel(...n)))}createVariants(){if(!this.variantMaterial)return null;const e=[];for(const t of this.targetModels){const i=t.clone();i.name+=" variant_"+this.variantMaterial.name+"_"+ql.variantSwitchIndex++,i.name=i.name.replace(/\s/g,"_"),i.material=this.variantMaterial,i.geometry=t.geometry,i.matrix=t.matrix,(!t.parent||!t.parent.isEmpty())&&Qr.createEmptyParent(t),t.parent&&t.parent.add(i),e.push(i)}return e}},h(b_,"_materialTriggersPerId",{}),h(b_,"variantSwitchIndex",0),b_);let Am=ql;pn([x(Ot)],Am.prototype,"materialToSwitch",2);pn([x(Ot)],Am.prototype,"variantMaterial",2);pn([x()],Am.prototype,"fadeDuration",2);var zf;const ln=(zf=class extends Me{constructor(){super(...arguments);h(this,"target");h(this,"toggleOnClick",!1);h(this,"targetState",!0);h(this,"hideSelf",!0);h(this,"selfModel");h(this,"selfModelClone");h(this,"targetModel");h(this,"toggleModel");h(this,"stateBeforeCreatingDocument",!1);h(this,"targetStateBeforeCreatingDocument",!1)}start(){ey(this.gameObject)}onPointerClick(e){e.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t,this.selfModelClone=t.clone())}beforeCreateDocument(){this.target&&(this.gameObject[ln.wasVisible]===void 0&&(this.gameObject[ln.wasVisible]=this.gameObject.activeSelf),this.target[ln.wasVisible]===void 0&&(this.target[ln.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[ln.wasVisible],this.targetStateBeforeCreatingDocument=this.target[ln.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(e,t){if(!this.target)return;this.targetModel=t.document.findById(this.target.uuid);const i=this.selfModel;if(this.selfModel&&this.targetModel){let n=this.selfModel,r=this.targetState;if(this.toggleOnClick)if(r=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&g3.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[ln.toggleClone]){const l=this.selfModelClone.clone();l.matrix.identity(),l.name+="_toggle"+ln.clonedToggleIndex++,i.add(l),this.gameObject[ln.toggleClone]=l,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const a=this.gameObject[ln.toggleClone];if(!this.gameObject[ln.reverseToggleClone]){const l=this.selfModelClone.clone();l.matrix.identity(),l.name+="_toggleReverse"+ln.clonedToggleIndex++,i.add(l),this.gameObject[ln.reverseToggleClone]=l}this.toggleModel=this.gameObject[ln.reverseToggleClone],(!this.toggleModel.geometry||!a.geometry)&&console.error("triggers without childs and without geometry won't work!",this,i.geometry),n=a,i.geometry=null,i.material=null}if(this.toggleModel){if(this.toggleOnClick){const a=[];a.push(li.fadeAction(n,0,!1)),a.push(li.fadeAction(this.toggleModel,0,!0)),a.push(li.fadeAction(this.targetModel,0,r)),e.addBehavior(new Jn("Toggle_"+n.name+"_toggleTo"+(r?"On":"Off"),Bs.tapTrigger(n),li.parallel(...a)));const l=[];l.push(li.fadeAction(this.toggleModel,0,!1)),l.push(li.fadeAction(n,0,!0)),l.push(li.fadeAction(this.targetModel,0,!r)),e.addBehavior(new Jn("Toggle_"+n.name+"_toggleTo"+(r?"Off":"On"),Bs.tapTrigger(this.toggleModel),li.parallel(...l)))}}else{const a=[];this.hideSelf&&a.push(li.fadeAction(n,0,!1)),a.push(li.fadeAction(this.targetModel,0,r)),e.addBehavior(new Jn("Toggle_"+n.name+"_toggleTo"+(r?"On":"Off"),Bs.tapTrigger(n),li.parallel(...a)))}const o=new Array;this.targetStateBeforeCreatingDocument||o.push(this.targetModel),this.stateBeforeCreatingDocument||o.push(i),this.toggleModel&&o.push(this.toggleModel),e.addBehavior(new Jn("HideOnStart_"+this.gameObject.name,Bs.sceneStartTrigger(),li.fadeAction(o,0,!1)))}}afterSerialize(e,t){this.gameObject[ln.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[ln.wasVisible],delete this.gameObject[ln.wasVisible]),this.target&&this.target[ln.wasVisible]!==void 0&&(this.target.visible=this.target[ln.wasVisible],delete this.target[ln.wasVisible]),delete this.gameObject[ln.toggleClone],delete this.gameObject[ln.reverseToggleClone]}},h(zf,"clonedToggleIndex",0),h(zf,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),h(zf,"toggleClone",Symbol("clone for toggling")),h(zf,"reverseToggleClone",Symbol("clone for reverse toggling")),zf);let Vd=ln;pn([x(me)],Vd.prototype,"target",2);pn([x()],Vd.prototype,"toggleOnClick",2);pn([x()],Vd.prototype,"targetState",2);pn([x()],Vd.prototype,"hideSelf",2);class XR extends Me{start(){this.gameObject.visible=!1}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&e.addBehavior(new Jn("HideOnStart_"+this.gameObject.name,Bs.sceneStartTrigger(),li.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class ym extends Me{constructor(){super(...arguments);h(this,"target");h(this,"duration",.5);h(this,"motionType","bounce")}beforeCreateDocument(){}createBehaviours(t,i,n){if(this.target&&i.uuid===this.gameObject.uuid){const r=new Jn("emphasize "+this.name,Bs.tapTrigger(this.gameObject),li.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(r)}}afterCreateDocument(t,i){}}pn([x()],ym.prototype,"target",2);pn([x()],ym.prototype,"duration",2);pn([x()],ym.prototype,"motionType",2);class Qh extends Me{constructor(){super(...arguments);h(this,"target");h(this,"clip","");h(this,"toggleOnClick",!1)}start(){ey(this.gameObject)}ensureAudioSource(){if(!this.target){const t=this.gameObject.addNewComponent(fn);t&&(this.target=t,t.spatialBlend=1,t.volume=1,t.loop=!1)}}onPointerClick(t){var i;t.use(),!(!((i=this.target)!=null&&i.clip)&&!this.clip)&&(this.ensureAudioSource(),this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play())))}createBehaviours(t,i,n){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r||typeof r!="string")return;const o=this.target?this.target.gameObject:this.gameObject,a=Gh.getName(r),l=this.target?this.target.volume:1,c=this.target&&this.target.spatialBlend==0?"nonSpatial":"spatial";let u=!1;if(this.gameObject.traverse(d=>{d instanceof de&&d.visible&&(u=!0)}),u=!0,u){let d=li.playAudioAction(o,"audio/"+a,"play",l,c);this.toggleOnClick&&(d.multiplePerformOperation="stop"),this.target&&this.target.loop&&(d=li.sequence(d).makeLooping());const f=new Jn("playAudio "+this.name,Bs.tapTrigger(this.gameObject),d);t.addBehavior(f)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let d=li.playAudioAction(o,"audio/"+a,"play",l,c);this.target.loop&&(d=li.sequence(d).makeLooping());const f=new Jn("playAudioOnStart"+(this.name?"_"+this.name:""),Bs.sceneStartTrigger(),d);t.addBehavior(f)}}}async afterSerialize(t,i){if(!this.target&&!this.clip)return;const n=this.clip?this.clip:this.target?this.target.clip:void 0;if(!n||typeof n!="string")return;const o="audio/"+Gh.getName(n);if(i.files[o])return;const c=await(await(await fetch(n)).blob()).arrayBuffer(),u=new Uint8Array(c);i.files[o]=u}}pn([x(fn)],Qh.prototype,"target",2);pn([x(URL)],Qh.prototype,"clip",2);pn([x()],Qh.prototype,"toggleOnClick",2);var x_;const lh=(x_=class extends Me{constructor(){super(...arguments);h(this,"animator");h(this,"stateName");h(this,"trigger","tap");h(this,"animation");h(this,"selfModel");h(this,"stateAnimationModel");h(this,"animationSequence",new Array);h(this,"animationLoopAfterSequence",new Array)}get target(){var e,t;return((e=this.animator)==null?void 0:e.gameObject)||((t=this.animation)==null?void 0:t.gameObject)}start(){ey(this.gameObject)}onPointerClick(e){var t;e.use(),this.target&&this.stateName&&((t=this.animator)==null||t.play(this.stateName,0,0,.1))}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}afterSerialize(){if(lh.rootsWithExclusivePlayback.size>1){const e='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';gt()&&dn(e),console.warn(e,...lh.rootsWithExclusivePlayback)}lh.animationActions=[],lh.rootsWithExclusivePlayback=new Set}afterCreateDocument(e,t){if(this.animationSequence===void 0&&this.animationLoopAfterSequence===void 0||!this.stateAnimationModel||!this.target)return;const i=t.document,n=t.extensions.find(a=>a instanceof qA);if(!n)return;const r=n.getClipCount(this.target)>1;r&&(gt()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+n.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),lh.rootsWithExclusivePlayback.add(this.target));const o=(a,l)=>{let c=lh.animationActions.find(u=>u.affectedObjects==a&&u.start==l.start&&u.duration==l.duration);return c||(c=li.startAnimationAction(a,l.start,l.duration),lh.animationActions.push(c)),c};i.traverse(a=>{var l,c;if(a.uuid===((l=this.target)==null?void 0:l.uuid)){const u=li.sequence();if(this.animationSequence!==void 0)for(const f of this.animationSequence)u.addAction(o(a,f));if(this.animationLoopAfterSequence!==void 0){const f=u.actions.length==0?u:li.sequence();for(const p of this.animationLoopAfterSequence)f.addAction(o(a,p));f.makeLooping(),u!==f&&u.addAction(f)}const d=new Jn("tap "+this.name+" for "+this.stateName+" on "+((c=this.target)==null?void 0:c.name),this.trigger=="tap"?Bs.tapTrigger(this.selfModel):Bs.sceneStartTrigger(),u);r&&d.makeExclusive(!0),e.addBehavior(d)}})}createAnimation(e,t,i){var c,u,d,f;if(!this.target||!this.animator&&!this.animation)return;if(this.stateAnimationModel=t,this.animation&&this.animation.clip){this.animationSequence=new Array,this.animationLoopAfterSequence=new Array;const p=e.registerAnimation(this.target,this.animation.clip);p&&this.animationLoopAfterSequence.push(p);return}const n=(c=this.animator)==null?void 0:c.runtimeAnimatorController;let r=n==null?void 0:n.findState(this.stateName),o=[],a=[];if(n&&r){const p=new Array;p.push(r);let m=!1;for(;p.length<100;){if(!r||r===null||!r.transitions||r.transitions.length===0){(u=r.motion)!=null&&u.isLooping&&(m=!0);break}const A=r.transitions.find(v=>v.conditions.length===0),g=A?n.getState(A.destinationState,0):null;if(g&&p.includes(g)){r=g,m=!0;break}else if(A){if(r=g,!r)break;p.push(r)}else{m=((d=r.motion)==null?void 0:d.isLooping)??!1;break}}if(m&&r){const A=p.indexOf(r);o=p.slice(0,A),a=p.slice(A),eL&&console.log("found loop from "+this.stateName,"states until loop",o,"states looping",a)}else o=p,a=[],eL&&console.log("found no loop from "+this.stateName,"states",o)}if(o=o.filter(p=>{var m,A,g;return((m=p.motion)==null?void 0:m.clip)&&((g=(A=p.motion)==null?void 0:A.clip.tracks)==null?void 0:g.length)>0}),a=a.filter(p=>{var m,A,g;return((m=p.motion)==null?void 0:m.clip)&&((g=(A=p.motion)==null?void 0:A.clip.tracks)==null?void 0:g.length)>0}),o.length===0&&a.length===0){console.warn("No clips found for state "+this.stateName+" on "+((f=this.animator)==null?void 0:f.name)+", can't export animation data");return}const l=(p,m)=>{var g,v,_;if(!this.target)return;if(!((g=p.motion)!=null&&g.clip)){console.warn("No clip found for state "+p.name+" on "+((v=this.animator)==null?void 0:v.name)+", can't export animation data");return}const A=e.registerAnimation(this.target,p.motion.clip);A?m.push(A):console.warn("Couldn't register animation for state "+p.name+" on "+((_=this.animator)==null?void 0:_.name))};if(o.length>0){this.animationSequence=new Array;for(const p of o)l(p,this.animationSequence)}if(a.length>0){this.animationLoopAfterSequence=new Array;for(const p of a)l(p,this.animationLoopAfterSequence)}}},h(x_,"animationActions",[]),h(x_,"rootsWithExclusivePlayback",new Set),x_);let Cd=lh;pn([x(ks)],Cd.prototype,"animator",2);pn([x()],Cd.prototype,"stateName",2);class _m extends Me{constructor(){super(...arguments);h(this,"target")}getType(){}getDuration(){}}pn([x(me)],_m.prototype,"target",2);class ty extends Me{constructor(){super(...arguments);h(this,"target")}}pn([x(_m)],ty.prototype,"target",2);class iy extends _m{constructor(){super(...arguments);h(this,"type",1);h(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}pn([x()],iy.prototype,"type",2);pn([x()],iy.prototype,"duration",2);class YR extends ty{}var Mse=Object.defineProperty,Tse=Object.getOwnPropertyDescriptor,Ic=(s,e,t,i)=>{for(var n=i>1?void 0:i?Tse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Mse(e,t,n),n};const tL=ne("debugcharactercontroller");class Wd extends Me{constructor(){super(...arguments);h(this,"center",new w(0,0,0));h(this,"radius",.5);h(this,"height",2);h(this,"_rigidbody",null);h(this,"_activeGroundCollisions");h(this,"_contactVelocity",new w)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Pi),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Pi)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const t=this.rigidbody;let i=this.gameObject.getComponent(Sc);i||(i=this.gameObject.addNewComponent(Sc)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height;const n=new w(0,0,1),r=new w(1,0,0),o=new w(0,1,0),a=this.gameObject.getWorldDirection(new w);a.y=0;const l=r.dot(a)<0?-1:1,c=n.angleTo(a)*l;this.gameObject.setRotationFromAxisAngle(o,c),t.lockRotationX=!0,t.lockRotationY=!0,t.lockRotationZ=!0}move(t){this.gameObject.position.add(t)}onCollisionEnter(t){(t.contacts.length==0||t.contacts.some(i=>i.normal.y>.2))&&(this._activeGroundCollisions.add(t),tL&&console.log(`Collision(${this._activeGroundCollisions.size}): ${t.contacts.map(i=>i.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(t){this._activeGroundCollisions.delete(t),tL&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var t;this._contactVelocity.set(0,0,0);for(const i of this._activeGroundCollisions){const n=(t=this.context.physics.engine)==null?void 0:t.getLinearVelocity(i.collider);n&&(this._contactVelocity.x+=n.x,this._contactVelocity.y+=n.y,this._contactVelocity.z+=n.z)}return this._contactVelocity}}Ic([x(w)],Wd.prototype,"center",2);Ic([x()],Wd.prototype,"radius",2);Ic([x()],Wd.prototype,"height",2);class Rc extends Me{constructor(){super(...arguments);h(this,"controller");h(this,"movementSpeed",2);h(this,"rotationSpeed",2);h(this,"jumpForce",1);h(this,"doubleJumpForce",2);h(this,"animator");h(this,"lookForward",!0);h(this,"lookInput",new te(0,0));h(this,"moveInput",new te(0,0));h(this,"jumpInput",!1);h(this,"_currentSpeed",new w(0,0,0));h(this,"_currentAngularSpeed",new w(0,0,0));h(this,"_temp",new w(0,0,0));h(this,"_jumpCount",0);h(this,"_currentRotation");h(this,"_raycastOptions",new ia)}awake(){this._currentRotation=new Ce}update(){const t=this.context.input;t.isKeyPressed("KeyW")?this.moveInput.y+=1:t.isKeyPressed("KeyS")&&(this.moveInput.y-=1),t.isKeyPressed("KeyD")?this.lookInput.x+=1:t.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=t.isKeyDown("Space"))}move(t){this.moveInput.add(t)}look(t){this.lookInput.add(t)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(t,i,n){var r,o,a,l,c,u,d,f,p,m,A;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=t.y*this.movementSpeed*this.context.time.deltaTime,(a=this.animator)==null||a.setBool("running",t.length()>.01),(c=this.animator)==null||c.setBool("jumping",((l=this.controller)==null?void 0:l.isGrounded)===!0&&n),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=et.toRadians(-i.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const g=this.context.mainCameraComponent.forward;g.y=0,g.normalize(),this._currentRotation.setFromUnitVectors(new w(0,0,1),g),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&n&&this.jumpForce>0){let g=(u=this.controller)==null?void 0:u.isGrounded;if(this.doubleJumpForce>0&&!((d=this.controller)!=null&&d.isGrounded)&&this._jumpCount===1&&(g=!0,(f=this.animator)==null||f.setBool("doubleJump",!0)),g){this._jumpCount+=1;const v=this.controller.rigidbody,_=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;v.applyImpulse(new w(0,1,0).multiplyScalar(_))}}if(this.controller){const g=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(g<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new qr),this._raycastOptions.ray.origin.copy(Nt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const v=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const _=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(v),(_.length&&_[0].distance>2||g<-10)&&((m=this.animator)==null||m.setBool("falling",!0))}else(A=this.animator)==null||A.setBool("falling",!1)}}}Ic([x(Wd)],Rc.prototype,"controller",2);Ic([x()],Rc.prototype,"movementSpeed",2);Ic([x()],Rc.prototype,"rotationSpeed",2);Ic([x()],Rc.prototype,"jumpForce",2);Ic([x()],Rc.prototype,"doubleJumpForce",2);Ic([x(ks)],Rc.prototype,"animator",2);var Ise=Object.defineProperty,Rse=Object.getOwnPropertyDescriptor,Pse=(s,e,t,i)=>{for(var n=i>1?void 0:i?Rse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ise(e,t,n),n};class ny extends lr{constructor(){super(...arguments);h(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const t=new V3;return t.offset=new te(0,0),t.radialModulation=!0,t.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{t.offset.x=-i,t.offset.y=i},t}}Pse([x(kt)],ny.prototype,"intensity",2);aa("ChromaticAberration",ny);const sy=new At;sy.setAttribute("position",new tt(new Float32Array([-1,-1,3,-1,-1,3]),2));sy.setAttribute("uv",new tt(new Float32Array([0,0,2,0,0,2]),2));sy.boundingSphere=new Sn;sy.computeBoundingSphere=function(){};const Bse=new Cc;class wu{constructor(e){this._mesh=new de(sy,e),this._mesh.frustumCulled=!1}render(e){e.render(this._mesh,Bse)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const Dse={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new we},viewMat:{value:new we},projViewMat:{value:new we},projectionMatrixInv:{value:new we},viewMatrixInv:{value:new we},cameraPos:{value:new w},resolution:{value:new te},time:{value:0},samples:{value:[]},bluenoise:{value:null},distanceFalloff:{value:1},radius:{value:5},near:{value:.1},far:{value:1e3},logDepth:{value:!1},ortho:{value:!1},screenSpaceRadius:{value:!1},frame:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:`
5512
5512
  varying vec2 vUv;
5513
5513
  void main() {
@@ -6951,7 +6951,7 @@ void main() {
6951
6951
  vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
6952
6952
 
6953
6953
  #include <fog_vertex>
6954
- }`);new w(0,0,1);var Xae=function(s){Em(t,s);var e=Mm(t);function t(i){var n;return Et(this,t),n=e.call(this,i),ee(ni(n),"positionBuffer",void 0),ee(ni(n),"previousBuffer",void 0),ee(ni(n),"nextBuffer",void 0),ee(ni(n),"uvBuffer",void 0),ee(ni(n),"sideBuffer",void 0),ee(ni(n),"widthBuffer",void 0),ee(ni(n),"colorBuffer",void 0),ee(ni(n),"indexBuffer",void 0),ee(ni(n),"vector_",new w),ee(ni(n),"vector2_",new w),ee(ni(n),"vector3_",new w),ee(ni(n),"quaternion_",new Ce),n.maxParticles=1e4,n.setupBuffers(),n.rebuildMaterial(),n}return Mt(t,[{key:"setupBuffers",value:function(){this.geometry&&this.geometry.dispose(),this.geometry=new At,this.indexBuffer=new tt(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(tr),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new tt(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(tr),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new tt(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(tr),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new tt(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(tr),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new tt(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(tr),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new tt(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(tr),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new tt(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(tr),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new tt(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(tr),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function(n){for(;n>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function(){this.layers.mask=this.settings.layers.mask;var n={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new te(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0},repeat:{value:new te(1,1)}},r={};if(r.USE_UV="",r.USE_COLOR_ALPHA="",this.settings.material.map&&(r.USE_MAP="",r.MAP_UV=XM(this.settings.material.map.channel),n.map=new _e(this.settings.material.map),n.mapTransform=new _e(new Ut().copy(this.settings.material.map.matrix))),this.settings.renderMode===at.Trail)this.material=new Bt({uniforms:n,defines:r,vertexShader:qae,fragmentShader:jae,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||dd});else throw new Error("render mode unavailable")}},{key:"update",value:function(){var n=this,r=0,o=0,a=0;this.systems.forEach(function(l){for(var c=0;c<l.particleNum;c++)a+=l.particles[c].previous.length*2}),a>this.maxParticles&&this.expandBuffers(a),this.systems.forEach(function(l){var c=n.quaternion_,u=n.vector2_,d=n.vector3_;l.emitter.matrixWorld.decompose(u,c,d);for(var f=l.particles,p=l.particleNum,m=n.settings.uTileCount,A=n.settings.vTileCount,g=1/m,v=1/A,_=0;_<p;_++){var y=f[_],b=y.uvTile%A,M=Math.floor(y.uvTile/A),E=y.previous.values(),T=E.next(),C=T.value,P=C;T.done||(T=E.next());var S=void 0;T.value!==void 0?S=T.value:S=P;for(var I=0;I<y.previous.length;I++,r+=2){if(n.positionBuffer.setXYZ(r,P.position.x,P.position.y,P.position.z),n.positionBuffer.setXYZ(r+1,P.position.x,P.position.y,P.position.z),l.worldSpace?(n.positionBuffer.setXYZ(r,P.position.x,P.position.y,P.position.z),n.positionBuffer.setXYZ(r+1,P.position.x,P.position.y,P.position.z)):(y.parentMatrix?n.vector_.copy(P.position).applyMatrix4(y.parentMatrix):n.vector_.copy(P.position).applyMatrix4(l.emitter.matrixWorld),n.positionBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.positionBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),l.worldSpace?(n.previousBuffer.setXYZ(r,C.position.x,C.position.y,C.position.z),n.previousBuffer.setXYZ(r+1,C.position.x,C.position.y,C.position.z)):(y.parentMatrix?n.vector_.copy(C.position).applyMatrix4(y.parentMatrix):n.vector_.copy(C.position).applyMatrix4(l.emitter.matrixWorld),n.previousBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.previousBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),l.worldSpace?(n.nextBuffer.setXYZ(r,S.position.x,S.position.y,S.position.z),n.nextBuffer.setXYZ(r+1,S.position.x,S.position.y,S.position.z)):(y.parentMatrix?n.vector_.copy(S.position).applyMatrix4(y.parentMatrix):n.vector_.copy(S.position).applyMatrix4(l.emitter.matrixWorld),n.nextBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.nextBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),n.sideBuffer.setX(r,-1),n.sideBuffer.setX(r+1,1),l.worldSpace)n.widthBuffer.setX(r,P.size),n.widthBuffer.setX(r+1,P.size);else if(y.parentMatrix)n.widthBuffer.setX(r,P.size),n.widthBuffer.setX(r+1,P.size);else{var H=(Math.abs(d.x)+Math.abs(d.y)+Math.abs(d.z))/3;n.widthBuffer.setX(r,P.size*H),n.widthBuffer.setX(r+1,P.size*H)}n.uvBuffer.setXY(r,(I/y.previous.length+b)*g,(A-M-1)*v),n.uvBuffer.setXY(r+1,(I/y.previous.length+b)*g,(A-M)*v),n.colorBuffer.setXYZW(r,P.color.x,P.color.y,P.color.z,P.color.w),n.colorBuffer.setXYZW(r+1,P.color.x,P.color.y,P.color.z,P.color.w),I+1<y.previous.length&&(n.indexBuffer.setX(o*3,r),n.indexBuffer.setX(o*3+1,r+1),n.indexBuffer.setX(o*3+2,r+2),o++,n.indexBuffer.setX(o*3,r+2),n.indexBuffer.setX(o*3+1,r+1),n.indexBuffer.setX(o*3+2,r+3),o++),C=P,P=S,T.done||(T=E.next(),T.value!==void 0&&(S=T.value))}}}),this.positionBuffer.updateRange.count=r*3,this.positionBuffer.needsUpdate=!0,this.previousBuffer.updateRange.count=r*3,this.previousBuffer.needsUpdate=!0,this.nextBuffer.updateRange.count=r*3,this.nextBuffer.needsUpdate=!0,this.sideBuffer.updateRange.count=r,this.sideBuffer.needsUpdate=!0,this.widthBuffer.updateRange.count=r,this.widthBuffer.needsUpdate=!0,this.uvBuffer.updateRange.count=r*2,this.uvBuffer.needsUpdate=!0,this.colorBuffer.updateRange.count=r*4,this.colorBuffer.needsUpdate=!0,this.indexBuffer.updateRange.count=o*3,this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,o*3)}},{key:"dispose",value:function(){this.geometry.dispose()}}]),t}(YG),Yae=function(s){Em(t,s);var e=Mm(t);function t(){var i;return Et(this,t),i=e.call(this),ee(ni(i),"batches",[]),ee(ni(i),"systemToBatchIndex",new Map),ee(ni(i),"type","BatchedRenderer"),i}return Mt(t,[{key:"addSystem",value:function(n){n._renderer=this;for(var r=n.getRendererSettings(),o=0;o<this.batches.length;o++)if(t.equals(this.batches[o].settings,r)){this.batches[o].addSystem(n),this.systemToBatchIndex.set(n,o);return}var a;switch(r.renderMode){case at.Trail:a=new Xae(r);break;case at.Mesh:case at.BillBoard:case at.VerticalBillBoard:case at.HorizontalBillBoard:case at.StretchedBillBoard:a=new Wae(r);break}a.addSystem(n),this.batches.push(a),this.systemToBatchIndex.set(n,this.batches.length-1),this.add(a)}},{key:"deleteSystem",value:function(n){var r=this.systemToBatchIndex.get(n);r!=null&&(this.batches[r].removeSystem(n),this.systemToBatchIndex.delete(n))}},{key:"updateSystem",value:function(n){this.deleteSystem(n),this.addSystem(n)}},{key:"update",value:function(n){this.systemToBatchIndex.forEach(function(o,a){a.update(n)});for(var r=0;r<this.batches.length;r++)this.batches[r].update()}}],[{key:"equals",value:function(n,r){return n.material.side===r.material.side&&n.material.blending===r.material.blending&&n.material.transparent===r.material.transparent&&n.material.type===r.material.type&&n.material.alphaTest===r.material.alphaTest&&n.material.map===r.material.map&&n.renderMode===r.renderMode&&n.uTileCount===r.uTileCount&&n.vTileCount===r.vTileCount&&n.instancingGeometry===r.instancingGeometry&&n.renderOrder===r.renderOrder&&n.layers.mask===r.layers.mask}}]),t}(me),Jae=Yae,JL=function(){function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new w;Et(this,s),ee(this,"locations",[]),this.scaleX=e,this.scaleY=t,this.position=i}return Mt(s,[{key:"transform",value:function(t,i){t.x=this.locations[i%this.locations.length].x*this.scaleX+this.position.x,t.y=this.locations[i%this.locations.length].y*this.scaleY+this.position.y,t.z=this.position.z}},{key:"clone",value:function(){var t=new s(this.scaleX,this.scaleY,this.position.clone());return t.locations=this.locations.map(function(i){return i.clone()}),t}},{key:"toJSON",value:function(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(function(t){return{x:t.x,y:t.y}})}}},{key:"fromImage",value:function(t,i){var n=document.createElement("canvas");n.width=t.width,n.height=t.height;var r=n.getContext("2d");if(r){r.drawImage(t,0,0);var o=r.getImageData(0,0,n.width,n.height,{colorSpace:"srgb"});n.remove(),this.locations.length=0;for(var a=0;a<o.height;a++)for(var l=0;l<o.width;l++)o.data[(a*o.width+l)*4+3]>i&&this.locations.push(new te(l,o.height-a))}}}],[{key:"fromJSON",value:function(t){var i=new s(t.scaleX,t.scaleY,new w(t.position[0],t.position[1],t.position[2]));return i.locations=t.locations.map(function(n){return new te(n.x,n.y)}),i}}]),s}();function Kae(s){switch(s.type){case"TextureSequencer":return JL.fromJSON(s);default:return new JL}}var Zae=function(){function s(e){Et(this,s),ee(this,"type","ApplySequences"),ee(this,"sequencers",[]),ee(this,"time",0),ee(this,"index",0),ee(this,"pCount",0),ee(this,"delay",void 0),ee(this,"tempV",new w),this.delay=e}return Mt(s,[{key:"initialize",value:function(t){t.id=this.pCount,t.dst=new w,t.begin=new w,t.inMotion=!1,this.pCount++}},{key:"reset",value:function(){this.time=0,this.index=0,this.pCount=0}},{key:"update",value:function(t,i){var n=this.sequencers[this.index],r=t.id*this.delay;this.time>=n[0].a+r&&this.time<=n[0].b+r?(t.inMotion||(t.inMotion=!0,t.begin.copy(t.position),n[1].transform(t.dst,t.id)),t.position.lerpVectors(t.begin,t.dst,s.BEZIER.genValue((this.time-n[0].a-r)/(n[0].b-n[0].a)))):this.time>n[0].b+r&&(t.inMotion=!1)}},{key:"frameUpdate",value:function(t){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=t}},{key:"appendSequencer",value:function(t,i){this.sequencers.push([t,i])}},{key:"toJSON",value:function(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(function(t){var i=Sp(t,2),n=i[0],r=i[1];return{range:n.toJSON(),sequencer:r.toJSON()}})}}},{key:"clone",value:function(){var t=new s(this.delay);return t.sequencers=this.sequencers.map(function(i){return[i[0].clone(),i[1].clone()]}),t}}],[{key:"fromJSON",value:function(t){var i=new s(t.delay);return t.sequencers.forEach(function(n){i.sequencers.push([Ni(n.range),Kae(n.sequencer)])}),i}}]),s}();ee(Zae,"BEZIER",new VM(0,0,1,1));var ue=function(s){return s[s.Number=0]="Number",s[s.Vec2=1]="Vec2",s[s.Vec3=2]="Vec3",s[s.Vec4=3]="Vec4",s[s.Boolean=4]="Boolean",s[s.AnyType=5]="AnyType",s}({}),KL=Mt(function s(e,t,i,n){Et(this,s),ee(this,"input",void 0),ee(this,"inputIndex",void 0),ee(this,"output",void 0),ee(this,"outputIndex",void 0),this.input=e,this.inputIndex=t,this.input.outputs[t].push(this),this.output=i,this.outputIndex=n,this.output.inputs[n]=this}),$ae=function(){function s(){Et(this,s),ee(this,"visited",new Set),ee(this,"graph_",void 0),ee(this,"context_",void 0),s.Instance=this}return Mt(s,[{key:"traverse",value:function(t){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");this.visited.add(t.id);for(var i=[],n=0;n<t.inputs.length;n++)if(t.inputs[n]instanceof KL){var r=t.inputs[n].input;this.visited.has(r.id)||this.traverse(r),i.push(r.outputValues[t.inputs[n].inputIndex])}else i.push(t.inputs[n].getValue(this.context_));t.func(this.context_,i,t.outputValues),this.graph_.nodesInOrder.push(t)}},{key:"executeCompiledGraph",value:function(){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");for(var t=this.graph_.nodesInOrder,i=0;i<t.length;i++){for(var n=[],r=t[i],o=0;o<r.inputs.length;o++)if(r.inputs[o]instanceof KL)n.push(r.inputs[o].input.outputValues[r.inputs[o].inputIndex]);else if(r.inputs[o]!==void 0)n.push(r.inputs[o].getValue(this.context_));else throw new Error("miss input for node ".concat(r.id));r.func(this.context_,n,r.outputValues)}}},{key:"run",value:function(t,i){if(this.graph_=t,this.context_=i,t.compiled)this.executeCompiledGraph();else{t.nodesInOrder.length=0,this.visited.clear();for(var n=0;n<t.outputNodes.length;n++){var r=t.outputNodes[n];this.traverse(r)}t.compiled=!0}}}]),s}();ee($ae,"Instance",void 0);var ci=function(){function s(e){Et(this,s),ee(this,"name",void 0),ee(this,"nodeTypeSignatures",[]),this.name=e}return Mt(s,[{key:"addSignature",value:function(t,i,n){this.nodeTypeSignatures.push({inputTypes:t,outputTypes:i,func:n})}}]),s}(),eS=new ci("add");eS.addSignature([ue.Number,ue.Number],[ue.Number],function(s,e,t,i){i[0]=t[0]+t[1]});eS.addSignature([ue.Vec2,ue.Vec2],[ue.Vec2],function(s,e,t,i){i[0].addVectors(t[0],t[1])});eS.addSignature([ue.Vec3,ue.Vec3],[ue.Vec3],function(s,e,t,i){i[0].addVectors(t[0],t[1])});eS.addSignature([ue.Vec4,ue.Vec4],[ue.Vec4],function(s,e,t,i){i[0].addVectors(t[0],t[1])});var tS=new ci("sub");tS.addSignature([ue.Number,ue.Number],[ue.Number],function(s,e,t,i){i[0]=t[0]-t[1]});tS.addSignature([ue.Vec2,ue.Vec2],[ue.Vec2],function(s,e,t,i){i[0].subVectors(t[0],t[1])});tS.addSignature([ue.Vec3,ue.Vec3],[ue.Vec3],function(s,e,t,i){i[0].subVectors(t[0],t[1])});tS.addSignature([ue.Vec4,ue.Vec4],[ue.Vec4],function(s,e,t,i){i[0].subVectors(t[0],t[1])});var iS=new ci("mul");iS.addSignature([ue.Number,ue.Number],[ue.Number],function(s,e,t,i){i[0]=t[0]*t[1]});iS.addSignature([ue.Vec2,ue.Number],[ue.Vec2],function(s,e,t,i){i[0].copy(t[0]).multiplyScalar(t[1])});iS.addSignature([ue.Vec3,ue.Number],[ue.Vec3],function(s,e,t,i){i[0].copy(t[0]).multiplyScalar(t[1])});iS.addSignature([ue.Vec4,ue.Number],[ue.Vec4],function(s,e,t,i){i[0].copy(t[0]).multiplyScalar(t[1])});var nS=new ci("div");nS.addSignature([ue.Number,ue.Number],[ue.Number],function(s,e,t,i){i[0]=t[0]/t[1]});nS.addSignature([ue.Vec2,ue.Number],[ue.Vec2],function(s,e,t,i){i[0].copy(t[0]).divideScalar(t[1])});nS.addSignature([ue.Vec3,ue.Number],[ue.Vec3],function(s,e,t,i){i[0].copy(t[0]).divideScalar(t[1])});nS.addSignature([ue.Vec4,ue.Number],[ue.Vec4],function(s,e,t,i){i[0].copy(t[0]).divideScalar(t[1])});var ele=new ci("sin");ele.addSignature([ue.Number],[ue.Number],function(s,e,t,i){i[0]=Math.sin(t[0])});var tle=new ci("cos");tle.addSignature([ue.Number],[ue.Number],function(s,e,t,i){i[0]=Math.cos(t[0])});var ile=new ci("tan");ile.addSignature([ue.Number],[ue.Number],function(s,e,t,i){i[0]=Math.tan(t[0])});var nle=new ci("abs");nle.addSignature([ue.Number],[ue.Number],function(s,e,t,i){i[0]=Math.abs(t[0])});var sle=new ci("min");sle.addSignature([ue.Number,ue.Number],[ue.Number],function(s,e,t,i){i[0]=Math.min(t[0],t[1])});var rle=new ci("max");rle.addSignature([ue.Number,ue.Number],[ue.Number],function(s,e,t,i){i[0]=Math.max(t[0],t[1])});var AP=new ci("dot");AP.addSignature([ue.Vec2,ue.Vec2],[ue.Number],function(s,e,t,i){i[0]=t[0].dot(t[1])});AP.addSignature([ue.Vec3,ue.Vec3],[ue.Number],function(s,e,t,i){i[0]=t[0].dot(t[1])});AP.addSignature([ue.Vec4,ue.Vec4],[ue.Number],function(s,e,t,i){i[0]=t[0].dot(t[1])});var ole=new ci("cross");ole.addSignature([ue.Vec3,ue.Vec3],[ue.Vec3],function(s,e,t,i){i[0].crossVectors(t[0],t[1])});var yP=new ci("length");yP.addSignature([ue.Vec2],[ue.Number],function(s,e,t,i){i[0]=t[0].length()});yP.addSignature([ue.Vec3],[ue.Number],function(s,e,t,i){i[0]=t[0].length()});yP.addSignature([ue.Vec4],[ue.Number],function(s,e,t,i){i[0]=t[0].length()});var _P=new ci("lengthSq");_P.addSignature([ue.Vec2],[ue.Number],function(s,e,t,i){i[0]=t[0].lengthSq()});_P.addSignature([ue.Vec3],[ue.Number],function(s,e,t,i){i[0]=t[0].lengthSq()});_P.addSignature([ue.Vec4],[ue.Number],function(s,e,t,i){i[0]=t[0].lengthSq()});var bP=new ci("normalize");bP.addSignature([ue.Vec2],[ue.Vec2],function(s,e,t,i){i[0].copy(t[0]).normalize()});bP.addSignature([ue.Vec3],[ue.Vec3],function(s,e,t,i){i[0].copy(t[0]).normalize()});bP.addSignature([ue.Vec4],[ue.Vec4],function(s,e,t,i){i[0].copy(t[0]).normalize()});var JG=new ci("distance");JG.addSignature([ue.Vec2,ue.Vec2],[ue.Number],function(s,e,t,i){i[0]=t[0].distanceTo(t[1])});JG.addSignature([ue.Vec3,ue.Vec3],[ue.Number],function(s,e,t,i){i[0]=t[0].distanceTo(t[1])});var ale=new ci("and");ale.addSignature([ue.Boolean,ue.Boolean],[ue.Boolean],function(s,e,t,i){i[0]=t[0]&&t[1]});var lle=new ci("or");lle.addSignature([ue.Boolean,ue.Boolean],[ue.Boolean],function(s,e,t,i){i[0]=t[0]||t[1]});var cle=new ci("not");cle.addSignature([ue.Boolean],[ue.Boolean],function(s,e,t,i){i[0]=!t[0]});var sS=new ci("equal");sS.addSignature([ue.Number,ue.Number],[ue.Boolean],function(s,e,t,i){i[0]=t[0]===t[1]});sS.addSignature([ue.Vec2,ue.Vec2],[ue.Boolean],function(s,e,t,i){i[0]=t[0].equals(t[1])});sS.addSignature([ue.Vec3,ue.Vec3],[ue.Boolean],function(s,e,t,i){i[0]=t[0].equals(t[1])});sS.addSignature([ue.Vec4,ue.Vec4],[ue.Boolean],function(s,e,t,i){i[0]=t[0].equals(t[1])});var hle=new ci("lessThan");hle.addSignature([ue.Number,ue.Number],[ue.Boolean],function(s,e,t,i){i[0]=t[0]<t[1]});var ule=new ci("greaterThan");ule.addSignature([ue.Number,ue.Number],[ue.Boolean],function(s,e,t,i){i[0]=t[0]>t[1]});var dle=new ci("lessThanOrEqual");dle.addSignature([ue.Number,ue.Number],[ue.Boolean],function(s,e,t,i){i[0]=t[0]<=t[1]});var fle=new ci("greaterThanOrEqual");fle.addSignature([ue.Number,ue.Number],[ue.Boolean],function(s,e,t,i){i[0]=t[0]>=t[1]});var ple=new ci("if");ple.addSignature([ue.Boolean,ue.AnyType,ue.AnyType],[ue.AnyType],function(s,e,t,i){i[0]=t[0]?t[1]:t[2]});var mle=new ci("number");mle.addSignature([],[ue.Number],function(s,e,t,i){i[0]=e.value});var gle=new ci("vec2");gle.addSignature([],[ue.Vec2],function(s,e,t,i){i[0]=e.value});var vle=new ci("vec3");vle.addSignature([],[ue.Vec3],function(s,e,t,i){i[0]=e.value});var Ale=new ci("vec4");Ale.addSignature([],[ue.Vec4],function(s,e,t,i){i[0]=e.value});var yle=new ci("bool");yle.addSignature([],[ue.Boolean],function(s,e,t,i){i[0]=e.value});var _le=new ci("particlePosition");_le.addSignature([],[ue.Vec3],function(s,e,t,i){i[0]=s.particle[e.property]});var ble=new ci("particleVelocity");ble.addSignature([],[ue.Vec3],function(s,e,t,i){i[0]=s.particle[e.property]});var xle=new ci("particleRotation");xle.addSignature([],[ue.Number],function(s,e,t,i){i[0]=s.particle[e.property]});var wle=new ci("particleAge");wle.addSignature([],[ue.Number],function(s,e,t,i){i[0]=s.particle[e.property]});var Ay=new ci("output");Ay.addSignature([ue.Number],[ue.Number],function(s,e,t,i){i[0]=t[0]});Ay.addSignature([ue.Vec2],[ue.Vec2],function(s,e,t,i){i[0]=t[0]});Ay.addSignature([ue.Vec3],[ue.Vec3],function(s,e,t,i){i[0]=t[0]});Ay.addSignature([ue.Vec4],[ue.Vec4],function(s,e,t,i){i[0]=t[0]});Ay.addSignature([ue.Boolean],[ue.Boolean],function(s,e,t,i){i[0]=t[0]});console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 16px; font-weight: bold;");var Sle=Object.defineProperty,Cle=Object.getOwnPropertyDescriptor,vn=(s,e,t,i)=>{for(var n=i>1?void 0:i?Cle(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Sle(e,t,n),n};const Ug=ne("debugparticles"),Ele=ne("noprogressive"),Mle=ne("debugprogressive");var YM=(s=>(s[s.Birth=0]="Birth",s[s.Collision=1]="Collision",s[s.Death=2]="Death",s[s.Trigger=3]="Trigger",s[s.Manual=4]="Manual",s))(YM||{});class ca extends Me{constructor(){super(...arguments);h(this,"renderMode");h(this,"particleMaterial");h(this,"trailMaterial");h(this,"particleMesh");h(this,"maxParticleSize");h(this,"minParticleSize");h(this,"velocityScale");h(this,"cameraVelocityScale");h(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&gt()){const t=`ParticleSystem "${this.name}" has non-default min/max particle size. This may not render correctly. Please set min size to 0 and the max size to 0.5 and use the "StartSize" setting instead`;console.warn(t)}}get transparent(){var i;return((i=this.particleMaterial)==null?void 0:i.transparent)??!1}getMaterial(t=!1){let i=t===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;return i&&t&&i.side===Os&&(i=i.clone(),i.side=wn,t?this.trailMaterial=i:this.particleMaterial=i),i&&!Ele&&i._didRequestTextureLOD===void 0&&(i._didRequestTextureLOD=0,Mle&&console.log("Load material LOD",i.name),Ti.assignTextureLOD(this.context,this.sourceId,i)),i}getMesh(t){let i=null;if(!i&&(this.particleMesh instanceof de&&(i=this.particleMesh.geometry),i===null)){i=new Gn(1,1);const r=i.attributes.uv;for(let o=0;o<r.count;o++)r.setX(o,1-r.getX(o))}return new de(i,this.getMaterial())}}vn([x()],ca.prototype,"renderMode",2);vn([x(Ot)],ca.prototype,"particleMaterial",2);vn([x(Ot)],ca.prototype,"trailMaterial",2);vn([x()],ca.prototype,"maxParticleSize",2);vn([x()],ca.prototype,"minParticleSize",2);vn([x()],ca.prototype,"velocityScale",2);vn([x()],ca.prototype,"cameraVelocityScale",2);vn([x()],ca.prototype,"lengthScale",2);class l_{constructor(e,t=1){h(this,"_curve");h(this,"_factor");h(this,"type","function");this._curve=e,this._factor=t}genValue(e){return this._curve.evaluate(e,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class xP{constructor(e){h(this,"type","value");h(this,"system");this.system=e}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class Tle extends xP{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class Ile extends xP{constructor(){super(...arguments);h(this,"_lastPosition",new w);h(this,"_lastDistance",0)}update(){const t=Nt(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(t),this._lastPosition.copy(t)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let t=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const r=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let a=this._lastDistance/this.system.deltaTime*r;Number.isFinite(a)||(a=0),t+=a}const i=this.system.emission.getBurst();i>0&&(t+=i/this.system.deltaTime);const n=this.system.maxParticles-this.system.currentParticles;return et.clamp(t,0,n/this.system.deltaTime)}}class Rle extends xP{genValue(){return this.system.isPlaying,0}}class nu{constructor(e){h(this,"system");h(this,"type");this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",e&&(this.system=e)}get context(){return this.system.context}initialize(e){}update(e,t){}frameUpdate(e){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class Ple extends nu{constructor(){super(...arguments);h(this,"type","NeedleTextureSheet")}update(t,i){const n=this.system.textureSheetAnimation;if(n.enabled){const r=t.age/t.life,o=n.evaluate(r);o!==void 0&&(t.uvTile=o)}}}const ZL=Symbol("particleRotation");class Ble extends nu{constructor(){super(...arguments);h(this,"type","NeedleRotation")}initialize(t){t[ZL]=Math.random()}update(t,i){if(t.rotation===void 0)return;const n=t.age/t.life;if(typeof t.rotation=="number"&&(this.system.rotationOverLifetime.enabled?t.rotation+=this.system.rotationOverLifetime.evaluate(n,t[ZL])*i:this.system.renderer.renderMode===ec.Billboard&&(t.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const r=t.velocity.length();t.rotation+=this.system.rotationBySpeed.evaluate(n,r)*i}}}const $L=Symbol("sizeLerpFactor"),Dle=new w;class Ole extends nu{constructor(){super(...arguments);h(this,"type","NeedleSize");h(this,"_minSize",0);h(this,"_maxSize",1)}initialize(t){t[$L]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(t,i){const n=t.age/t.life;let r=1;this.system.sizeOverLifetime.enabled&&(r*=this.system.sizeOverLifetime.evaluate(n,void 0,t[$L]).x);let o=1;if(this.system.renderer.renderMode!==ec.Mesh&&(o=this.system.worldScale.x/this.system.cameraScale),t.size=t.startSize*r*o,this.system.localspace){const a=KG(this.system,Dle);t.size*=a.x}}}const cp=Symbol("particleLife"),bE=Symbol("trailLifetime"),ek=Symbol("trailStartLength"),xE=Symbol("trailWidthRandom");class Lle extends nu{constructor(){super(...arguments);h(this,"type","NeedleTrail")}initialize(t){t instanceof nA&&(t[cp]=t.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(t[bE]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),t.life+=t[bE]),t[ek]=t.length,t[xE]=Math.random())}update(t){var i;if((i=this.system.trails)!=null&&i.enabled&&t instanceof nA){const n=t,r=t.age/t[cp],o=t.previous.values(),a=t.previous.length;for(let l=0;l<a;l++){const u=o.next().value,d=1-l/(a-1);let f=t.size;f<=0&&!this.system.trails.sizeAffectsWidth&&(f=20*this.system.trails.widthOverTrail.evaluate(.5,n[xE])),u.size=this.system.trails.getWidth(f,r,d,n[xE]),u.color.copy(t.color),this.system.trails.getColor(u.color,r,d)}if(t.age>t[cp]){t.velocity.set(0,0,0);const l=(t.age-t[cp])/t[bE];n.length=et.lerp(t[ek],0,l)}}}}const c_=Symbol("startVelocity"),tk=Symbol("gravityModifier"),wE=Symbol("gravitySpeed"),h_=Symbol("velocity lerp factor"),JM=new w;class kle extends nu{constructor(){super(...arguments);h(this,"type","NeedleVelocity");h(this,"_gravityDirection",new w)}initialize(t){var r,o;const i=this.system.main.simulationSpeed;t.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random()),t.velocity.copy(this.system.shape.getDirection(t,t.position)).multiplyScalar(t.startSpeed),(r=this.system.inheritVelocity)!=null&&r.enabled&&this.system.inheritVelocity.applyInitial(t.velocity),t[c_]?t[c_].copy(t.velocity):t[c_]=t.velocity.clone();const n=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());t[tk]=n*i,t[wE]=n*i*.5,t[h_]=Math.random(),(o=this.system.velocityOverLifetime)==null||o.init(t),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===eA.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(t,i){var f;const n=t[c_],r=t[tk];if(r!==0){const p=r*t[wE];JM.copy(this._gravityDirection).multiplyScalar(p),t[wE]+=i*.05,n.add(JM)}t.velocity.copy(n);const o=t.age/t.life;(f=this.system.inheritVelocity)!=null&&f.enabled&&this.system.inheritVelocity.applyCurrent(t.velocity,o,t[h_]);const a=this.system.noise;a.enabled&&a.apply(0,t.position,t.velocity,i,t.age,t.life);const l=this.system.sizeBySpeed;l!=null&&l.enabled&&(t.size=l.evaluate(t.velocity,o,t[h_],t.size));const c=this.system.colorBySpeed;c!=null&&c.enabled&&c.evaluate(t.velocity,t[h_],t.color);const u=this.system.velocityOverLifetime;u.enabled&&u.apply(t,0,t.position,t.velocity,i,t.age,t.life);const d=this.system.limitVelocityOverLifetime;d.enabled&&d.apply(t.position,n,t.velocity,t.size,o,i,1),this.system.worldspace&&t.velocity.multiply(this.system.worldScale)}}const ik=Symbol("colorLerpFactor"),nk=new wi(1,1,1,1),Eu=new wi(1,1,1,1);class Fle extends nu{constructor(){super(...arguments);h(this,"type","NeedleColor")}initialize(t){}_init(t){const i=this.system.renderer.particleMaterial;Eu.copy(this.system.main.startColor.evaluate(Math.random())),i!=null&&i.color&&(nk.copy(i.color),Eu.multiply(nk)),Eu.convertLinearToSRGB(),t.startColor.set(Eu.r,Eu.g,Eu.b,Eu.alpha),t.color.copy(t.startColor),t[ik]=Math.random()}update(t,i){if(t.age===0&&this._init(t),this.system.colorOverLifetime.enabled){const n=t.age/t.life,r=this.system.colorOverLifetime.color.evaluate(n,t[ik]);t.color.set(r.r,r.g,r.b,r.alpha).multiply(t.startColor)}else t.color.copy(t.startColor)}}class Ule{constructor(e){h(this,"system");h(this,"emission");h(this,"autoDestroy");h(this,"startLength");h(this,"emissionBursts");h(this,"onlyUsedByOther");h(this,"behaviors",[]);h(this,"rendererEmitterSettings",{startLength:new er(220),followLocalOrigin:!1});h(this,"flatWhiteTexture");h(this,"clonedTexture",{original:void 0,clone:void 0});this.system=e,this.emission=new Ile(this.system)}get anim(){return this.system.textureSheetAnimation}get prewarm(){return!1}get material(){return this.system.renderer.getMaterial(this.system.trails.enabled)}get layers(){return this.system.gameObject.layers}update(){this.emission.update()}get looping(){return this.system.main.loop}get duration(){return this.system.duration}get shape(){return this.system.shape}get startLife(){return new l_(this.system.main.startLifetime)}get startSpeed(){return new l_(this.system.main.startSpeed)}get startRotation(){return new l_(this.system.main.startRotation)}get startSize(){return new l_(this.system.main.startSize)}get startColor(){return new tx(new Ze(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new Rle(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return at.Trail;switch(this.system.renderer.renderMode){case ec.Billboard:return at.BillBoard;case ec.Stretch:return at.StretchedBillBoard;case ec.HorizontalBillboard:return at.HorizontalBillBoard;case ec.VerticalBillboard:return at.VerticalBillBoard;case ec.Mesh:return at.Mesh}return at.BillBoard}get speedFactor(){var t;let e=this.system.main.simulationSpeed;return((t=this.system.renderer)==null?void 0:t.renderMode)===ec.Stretch&&(e*=this.system.renderer.velocityScale??1),e}get texture(){const e=this.material;if(e&&e.map){const t=e.map;if(this.clonedTexture.original!==t||!this.clonedTexture.clone){const i=t.clone();i.premultiplyAlpha=!1,i.colorSpace=yi,this.clonedTexture.original=t,this.clonedTexture.clone=i}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=A4(new wi(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new Tle(this.system)}get uTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesX:void 0}get vTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesY:void 0}get renderOrder(){return 1}get blending(){var e;return((e=this.system.renderer.particleMaterial)==null?void 0:e.blending)??wh}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===eA.World}}class Nle{constructor(){h(this,"burstIndex",0);h(this,"burstWaveIndex",0);h(this,"time",0);h(this,"waitEmiting",0)}}const tb=class extends Me{constructor(){super(...arguments);h(this,"_state");h(this,"colorOverLifetime");h(this,"main");h(this,"emission");h(this,"sizeOverLifetime");h(this,"shape");h(this,"noise");h(this,"trails");h(this,"velocityOverLifetime");h(this,"limitVelocityOverLifetime");h(this,"inheritVelocity");h(this,"colorBySpeed");h(this,"textureSheetAnimation");h(this,"rotationOverLifetime");h(this,"rotationBySpeed");h(this,"sizeBySpeed");h(this,"_cameraScale",1);h(this,"__worldQuaternion",new Ce);h(this,"_worldQuaternionInverted",new Ce);h(this,"_worldScale",new w);h(this,"_worldPositionFrame",-1);h(this,"_worldPos",new w);h(this,"_renderer");h(this,"_batchSystem");h(this,"_particleSystem");h(this,"_interface");h(this,"_container");h(this,"_time",0);h(this,"_isPlaying",!0);h(this,"_isUsedAsSubsystem",!1);h(this,"_didPreWarm",!1);h(this,"_bursts");h(this,"_subEmitterSystems");h(this,"_lastBatchesCount",-1);h(this,"lastMaterialVersion",-1)}play(e=!1){var t;e&&oe.foreachComponent(this.gameObject,i=>{i instanceof tb&&i!==this&&i.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(t=this.emission)==null||t.reset()}pause(e=!0){e&&oe.foreachComponent(this.gameObject,t=>{t instanceof tb&&t!==this&&t.pause(!1)},!0),this._isPlaying=!1}stop(e=!0,t=!1){e&&oe.foreachComponent(this.gameObject,i=>{i instanceof tb&&i!==this&&i.stop(!1,t)},!0),this._isPlaying=!1,this._time=0,t&&this.reset()}reset(){var e;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(e=this.emission)==null||e.reset())}emit(e){if(this._particleSystem){this.onUpdate(),e=Math.min(e,this.maxParticles-this.currentParticles),this._state||(this._state=new Nle),this._state.waitEmiting=e,this._state.time=0;const t=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=t}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(e){this.main.playOnAwake=e}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var e;return((e=this._particleSystem)==null?void 0:e.particleNum)??0}get maxParticles(){return this.main.maxParticles}get time(){return this._time}get duration(){return this.main.duration}get deltaTime(){return this.context.time.deltaTime*this.main.simulationSpeed}get scale(){return this.gameObject.scale.x}get cameraScale(){return this._cameraScale}get container(){return this._container}get worldspace(){return this.main.simulationSpace===eA.World}get localspace(){return this.main.simulationSpace===eA.Local}get worldQuaternion(){return this.__worldQuaternion}get worldQuaternionInverted(){return this._worldQuaternionInverted}get worldScale(){return this._worldScale}get worldPos(){return this._worldPositionFrame!==this.context.time.frame&&(this._worldPositionFrame=this.context.time.frame,Nt(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(e){return this._particleSystem?(e instanceof nu&&(e.system=this),gt()&&console.log("add behaviour",e),this._particleSystem.addBehavior(e),!0):!1}removeBehaviour(e){if(!this._particleSystem)return!1;const t=this._particleSystem.behaviors,i=t.indexOf(e);return i!==-1&&t.splice(i,1),!0}removeAllBehaviours(){return this._particleSystem?(this._particleSystem.behaviors.length=0,!0):!1}get behaviours(){return this._particleSystem?this._particleSystem.behaviors:null}get particleSystem(){return this._particleSystem??null}set bursts(e){for(let t=0;t<e.length;t++){const i=e[t];if(!(i instanceof tA)){const n=new tA;Np(n,i),e[t]=n}}this._bursts=e}set subEmitterSystems(e){for(let t=0;t<e.length;t++){const i=e[t];if(!(i instanceof oA)){const n=new oA;Np(n,i),e[t]=n}}Ug&&e.length>0&&console.log("SubEmitters: ",e,this),this._subEmitterSystems=e}onAfterDeserialize(e){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const t of this._subEmitterSystems)t._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(ca),!this.main)throw new Error("Not Supported: ParticleSystem needs a serialized MainModule. Creating new particle systems at runtime is currently not supported.");this._container=new me,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new Jae,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new Ule(this),this._particleSystem=new Nae(this._interface),this._particleSystem.addBehavior(new Ole(this)),this._particleSystem.addBehavior(new Fle(this)),this._particleSystem.addBehavior(new Ple(this)),this._particleSystem.addBehavior(new Ble(this)),this._particleSystem.addBehavior(new kle(this)),this._particleSystem.addBehavior(new Lle(this)),this._batchSystem.addSystem(this._particleSystem);const e=this._particleSystem.emitter;this.context.scene.add(e),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),Ug&&(console.log(this),this.gameObject.add(new $o(1)))}start(){this.addSubParticleSystems(),this.updateLayers()}onDestroy(){var e,t,i,n;(e=this._container)==null||e.removeFromParent(),(t=this._batchSystem)==null||t.removeFromParent(),(i=this._particleSystem)==null||i.emitter.removeFromParent(),(n=this._particleSystem)==null||n.dispose()}onEnable(){this.main&&(this.inheritVelocity&&(this.inheritVelocity.system=this),this._batchSystem&&(this._batchSystem.visible=!0),this.playOnAwake&&this.play(),this._isPlaying=this.playOnAwake)}onDisable(){this._batchSystem&&(this._batchSystem.visible=!1)}onBeforeRender(){var e;this.main&&(this._didPreWarm===!1&&((e=this.main)==null?void 0:e.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var c;if(!((c=this.emission)!=null&&c.enabled)||this.emission.rateOverTime.getMax()<=0)return;const t=1/60,i=this.main.duration,n=this.main.startLifetime.getMax(),r=1e3,o=Math.min(Math.max(i,n)/Math.max(.01,this.main.simulationSpeed),r),a=Math.ceil(o/t),l=Date.now();Ug&&console.log(`Particles ${this.name} - Prewarm for ${a} frames (${o} sec). Duration: ${i}, Lifetime: ${n}`);for(let u=0;u<a&&!(this.currentParticles>=this.maxParticles);u++){const d=Date.now()-l;if(d>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${d}`);break}this.onUpdate(),this.onSimulate(t)}}onSimulate(e){if(this._batchSystem){let t=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,t=!0),t&&this.updateLayers(),this._batchSystem.update(e)}this._time+=e,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let e=0;e<this._batchSystem.batches.length;e++){const t=this._batchSystem.batches[e];t.layers.disableAll();const i=this.layer;t.layers.mask=1<<i}}onUpdate(){var r,o;const e=this.renderer.getMaterial(this.trails.enabled);if(e&&e.version!=this.lastMaterialVersion&&this._particleSystem&&(this.lastMaterialVersion=e.version,this._particleSystem.texture=this._interface.texture),this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const t=this.context.mainCamera;if(t){const a=Hi(t);this._cameraScale=a.x}const i=!this.worldspace,n=this.gameObject;if(Ii(n,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),Hi(this.gameObject,this._worldScale),i&&this._container&&((r=this.gameObject)!=null&&r.parent)){const a=KG(this,JM);this._container.matrix.makeScale(a.x,a.y,a.z),this._container.matrix.makeRotationFromQuaternion(this.__worldQuaternion),this._container.matrix.setPosition(this.worldPos),this._container.matrix.scale(this.gameObject.scale)}this.emission.system=this,this._interface.update(),this.shape.update(this,this.context,this.main.simulationSpace,this.gameObject),this.noise.update(this.context),(o=this.inheritVelocity)==null||o.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var e;if(this._subEmitterSystems&&this._particleSystem)for(const t of this._subEmitterSystems){t.particleSystem&&(t.particleSystem.__internalAwake?t.particleSystem.__internalAwake():gt()&&console.warn("SubParticleSystem serialization issue(?)",t.particleSystem,t));const i=(e=t.particleSystem)==null?void 0:e._particleSystem;if(i){t.particleSystem._isUsedAsSubsystem=!0;const n=new rS(this,this._particleSystem,t.particleSystem,i);n.emitterType=t.type,n.emitterProbability=t.emitProbability,this._particleSystem.addBehavior(n)}else Ug&&console.warn("Could not add SubParticleSystem",t,this)}}};let zn=tb;vn([x(ay)],zn.prototype,"colorOverLifetime",2);vn([x(Qs)],zn.prototype,"main",2);vn([x(Ml)],zn.prototype,"emission",2);vn([x($h)],zn.prototype,"sizeOverLifetime",2);vn([x(mn)],zn.prototype,"shape",2);vn([x(Ei)],zn.prototype,"noise",2);vn([x(rn)],zn.prototype,"trails",2);vn([x(gn)],zn.prototype,"velocityOverLifetime",2);vn([x(Vn)],zn.prototype,"limitVelocityOverLifetime",2);vn([x(eu)],zn.prototype,"inheritVelocity",2);vn([x(jd)],zn.prototype,"colorBySpeed",2);vn([x(Vs)],zn.prototype,"textureSheetAnimation",2);vn([x(la)],zn.prototype,"rotationOverLifetime",2);vn([x(Bo)],zn.prototype,"rotationBySpeed",2);vn([x(Or)],zn.prototype,"sizeBySpeed",2);class oA{constructor(){h(this,"particleSystem");h(this,"emitProbability",1);h(this,"properties");h(this,"type")}_deserialize(e,t){const i=this.particleSystem;if(i instanceof zn)return;let n="";i&&typeof i.guid=="string"&&(n=i.guid,this.particleSystem=oe.findByGuid(n,t)),Ug&&!(this.particleSystem instanceof zn)&&console.warn("Could not find particle system for sub emitter",n,t,this)}}function KG(s,e){if(e.set(1,1,1),s.gameObject.parent&&s.localspace)switch(s.main.scalingMode){case UM.Local:e=Hi(s.gameObject.parent,e),e.x=1/e.x,e.y=1/e.y,e.z=1/e.z;break;default:if(!s.unsupported_scaling_mode){s.unsupported_scaling_mode=!0;const t="ParticleSystem scale mode "+UM[s.main.scalingMode]+" is not supported";gt()&&dn(t),console.warn(t,s.name,s)}e=Hi(s.gameObject,e);break}return e}new w(1,1,1);new w(0,0,1);class rS{constructor(e,t,i,n){h(this,"type","NeedleParticleSubEmitter");h(this,"emitterType");h(this,"emitterProbability");h(this,"q_",new Ce);h(this,"v_",new w);h(this,"v2_",new w);h(this,"_emitterMatrix",new we);h(this,"_circularBuffer");this.system=e,this.particleSystem=t,this.subSystem=i,this.subParticleSystem=n,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const r=1e3;this._circularBuffer=new ea(()=>new we,r)}clone(){throw new Error("Method not implemented.")}initialize(e){e.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld),this._emitterMatrix.setPosition(0,0,0),this.emitterType===YM.Birth&&this.run(e)}update(e,t){this.run(e)}frameUpdate(e){}toJSON(){}reset(){}run(e){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!e.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const t=this.system.deltaTime;if(this.emitterType===YM.Death){let n=e.life;if(e[cp]!==void 0&&(n=e[cp]),!(e.age+t*1.2>=n))return;const o=this.subSystem.main.maxParticles-this.subSystem.currentParticles;e.emissionState.waitEmiting=o}const i=new we;i.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1),this.particleSystem.worldSpace||i.multiplyMatrices(this._emitterMatrix,i),this.subParticleSystem.emit(t,e.emissionState,i)}}var zle=Object.defineProperty,Gle=Object.getOwnPropertyDescriptor,Hle=(s,e,t,i)=>{for(var n=i>1?void 0:i?Gle(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&zle(e,t,n),n};class yy extends lr{constructor(){super(...arguments);h(this,"granularity")}get typeName(){return"PixelationEffect"}onCreateEffect(){const t=new q3;return this.granularity.onValueChanged=i=>{t.granularity=i},t}}Hle([x(kt)],yy.prototype,"granularity",2);aa("PixelationEffect",yy);class Vp extends Me{constructor(){super(...arguments);h(this,"_didAssignPlayerColor",!1);h(this,"tryAssignColor",()=>{const t=oe.getComponentInParent(this.gameObject,Yo);if(t&&t.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(t.owner),!0;const i=oe.getComponentInParent(this.gameObject,Yn);return i!=null&&i.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(i.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(ii.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(ii.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield d4(.2),!this.tryAssignColor()););}assignUserColor(t){const i=Vp.hashCode(t),n=Vp.colorFromHashCode(i);if(this.gameObject.type==="Mesh"){const r=this.gameObject;this.assignColor(n,t,r)}else if(this.gameObject.children)for(const r of this.gameObject.children){const o=r;o.material&&o.material.color&&this.assignColor(n,t,o)}}assignColor(t,i,n){let r=n.material;r&&(r._playerMaterial!==i&&(r=r.clone(),r._playerMaterial=i,n.material=r),r.color=t)}static hashCode(t){var i=0,n,r;if(t.length===0)return i;for(n=0;n<t.length;n++)r=t.charCodeAt(n),i=(i<<5)-i+r,i|=0;return i}static colorFromHashCode(t){const i=(t&16711680)>>16,n=(t&65280)>>8,r=t&255;return new xe(i/255,n/255,r/255)}}async function wP(s){const{NeedleEngineHTMLElement:e}=await Promise.resolve().then(()=>eue);e.observedAttributes.includes(s)||e.observedAttributes.push(s)}var Qle=Object.defineProperty,Vle=Object.getOwnPropertyDescriptor,_y=(s,e,t,i)=>{for(var n=i>1?void 0:i?Vle(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Qle(e,t,n),n};const Wo=ne("debugskybox");wP("skybox-image");wP("environment-image");function sk(s,e,t,i,n){const r=new bl;r.allowDrop=!1,r.allowNetworking=!1,r.background=t,r.environment=i,oe.addComponent(s.scene,r);const o=a=>{typeof a=="string"&&(Wo&&console.log(n,"CHANGED TO",a),r.setSkybox(a))};return NU(s.domElement,n,o),r.addEventListener("destroy",()=>{Wo&&console.log("Destroyed attribute remote skybox",n),zU(s.domElement,n,o)}),r.setSkybox(e)}ri.addContextCreatedCallback(s=>{var r;const e=s.context,t=e.domElement.getAttribute("skybox-image"),i=e.domElement.getAttribute("environment-image"),n=new Array;if(t){Wo&&console.log("Creating remote skybox to load "+t),((r=e.mainCameraComponent)==null?void 0:r.clearFlags)!==Sd.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const o=sk(e,t,!0,!1,"skybox-image");n.push(o)}if(i){Wo&&console.log("Creating remote environment to load "+i);const o=sk(e,i,!1,!0,"environment-image");n.push(o)}return n.length>0?wA(n):Promise.resolve()});function ZG(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function rk(s){const t=ZG().find(i=>i.src===s);return t?(Wo&&console.log("Skybox: Found previously loaded texture for "+s),t.texture):null}async function Wle(s){const e=await s;eR(e,!0),Li(e)}function jle(s,e){const t=ZG();for(;t.length>5;){const i=t.shift();i&&Wle(i.texture)}e.then(i=>eR(i,!1)),t.push({src:s,texture:e})}class bl extends Me{constructor(){super(...arguments);h(this,"url");h(this,"allowDrop",!0);h(this,"background",!0);h(this,"environment",!0);h(this,"allowNetworking",!0);h(this,"_loader");h(this,"_prevUrl");h(this,"_prevLoadedEnvironment");h(this,"_prevEnvironment",null);h(this,"_prevBackground",null);h(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]);h(this,"onDragOverEvent",t=>{if(this.allowDrop&&t.dataTransfer)for(const i of t.dataTransfer.types)(i==="text/uri-list"||i==="Files")&&t.preventDefault()});h(this,"onDrop",t=>{var i,n,r,o;if(this.allowDrop&&t.dataTransfer){for(const a of t.dataTransfer.types)if(Wo&&console.log(a),a==="text/uri-list"){const l=t.dataTransfer.getData(a);Wo&&console.log(a,l);let c=(n=(i=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(l))==null?void 0:i.groups)==null?void 0:n.name;if(c||(c=(o=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(l))==null?void 0:r.groups)==null?void 0:o.name),Wo&&console.log(c),c){const u="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+c+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${u}`),t.preventDefault(),this.setSkybox(u);break}else if(this.isValidTextureType(l)){console.log("[Remote Skybox] Setting skybox from url: "+l),t.preventDefault(),this.setSkybox(l);break}else{console.warn(`[RemoteSkybox] Unknown url ${l}. If you want to load a skybox from a url, make sure it is a valid image url. Url must end with${this.validTextureTypes.join(", ")}.`);const u=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:t,url:l,apply:d=>{t.preventDefault(),this.setSkybox(d)}}});this.dispatchEvent(u)}}else if(a=="Files"){const l=t.dataTransfer.files.item(0);if(Wo&&console.log(a,l),!l)continue;if(!this.isValidTextureType(l.name)){console.warn(`[RemoteSkybox]: File "${l.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(rk(l.name)===null){const c=new Blob([l]),u=URL.createObjectURL(c);t.preventDefault(),this.setSkybox(u,l.name)}else t.preventDefault(),this.setSkybox(l.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var t;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,zi.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(t=this.context.mainCameraComponent)==null||t.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(t,i){var o;if(!this.activeAndEnabled||!t)return!1;if(i??(i=t),this.isValidTextureType(i)||console.warn("Potentially invalid skybox url",i,"on",this.name),Wo&&console.log("Remote skybox url?: "+t),this._prevUrl===t&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(o=this._prevLoadedEnvironment)==null||o.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=t;const n=await this.loadTexture(t,i);if(!n||!this.enabled)return!1;this.url=t;const r=t.lastIndexOf("/");return n.name=t.substring(r>=0?r+1:0),this._loader instanceof ml&&(n.colorSpace=vt),this._prevLoadedEnvironment=n,this.applySkybox(),!0}async loadTexture(t,i){var c,u,d,f,p;if(!t)return Promise.resolve(null);i??(i=t);const n=rk(i);if(n){const m=await n;if(((u=(c=m.source)==null?void 0:c.data)==null?void 0:u.length)>0||(p=(f=(d=m.source)==null?void 0:d.data)==null?void 0:f.data)!=null&&p.length)return m}const r=i.endsWith(".exr"),o=i.endsWith(".hdr");r?this._loader instanceof Vb||(this._loader=new Vb):o?this._loader instanceof bM||(this._loader=new bM):this._loader instanceof ml||(this._loader=new ml),Wo&&console.log("Loading skybox: "+t);const a=this._loader.loadAsync(t);return jle(i,a),await a}applySkybox(){var i;const t=this._prevLoadedEnvironment;t&&(t.mapping=Tp,t.needsUpdate=!0,this.context.scene.background!==t&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==t&&(this._prevEnvironment=this.context.scene.environment),Wo&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=t),this.background&&!zi.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((i=this.context.mainCameraComponent)==null?void 0:i.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(t){return t.startsWith("http://")||t.startsWith("https://")}isValidTextureType(t){for(const i of this.validTextureTypes)if(t.endsWith(i))return!0;return!1}registerDropEvents(){this.unregisterDropEvents(),this.context.domElement.addEventListener("dragover",this.onDragOverEvent),this.context.domElement.addEventListener("drop",this.onDrop)}unregisterDropEvents(){this.context.domElement.removeEventListener("dragover",this.onDragOverEvent),this.context.domElement.removeEventListener("drop",this.onDrop)}}_y([BR(bl.prototype.urlChangedSyncField),x(URL)],bl.prototype,"url",2);_y([x()],bl.prototype,"allowDrop",2);_y([x()],bl.prototype,"background",2);_y([x()],bl.prototype,"environment",2);_y([x()],bl.prototype,"allowNetworking",2);var qle=Object.defineProperty,Xle=Object.getOwnPropertyDescriptor,Do=(s,e,t,i)=>{for(var n=i>1?void 0:i?Xle(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&qle(e,t,n),n};const co=ne("debugsceneswitcher"),ib="scene";wP(ib);const sh=Promise.resolve(!1);class hr extends Me{constructor(){super(...arguments);h(this,"autoLoadFirstScene",!0);h(this,"scenes");h(this,"loadingScene");h(this,"queryParameterName","scene");h(this,"useSceneName",!0);h(this,"clamp",!0);h(this,"useHistory",!0);h(this,"useKeyboard",!0);h(this,"useSwipe",!0);h(this,"useSceneLighting",!0);h(this,"preloadNext",1);h(this,"preloadPrevious",1);h(this,"preloadConcurrent",2);h(this,"_currentIndex",-1);h(this,"_currentScene");h(this,"_engineElementOverserver");h(this,"_preloadScheduler");h(this,"onPopState",async t=>{if(!this.useHistory)return;const i=this.useHistory;try{this.useHistory=!1;let n=!1;if(this.queryParameterName&&(n=await this.tryLoadFromQueryParam()),!n){const r=t==null?void 0:t.state;if(r&&r.startsWith(this.guid)){const o=r.substr(this.guid.length+2);co&&console.log("PopState",o),await this.trySelectSceneFromValue(o)}}}finally{this.useHistory=i}});h(this,"normalizedSwipeThresholdX",.1);h(this,"_didSwipe",!1);h(this,"onInputPointerMove",t=>{if(this.useSwipe&&!this._didSwipe&&t.button===0&&t.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const i=this.context.input.getPointerPositionDelta(t.button);if(i){const n=i.x/this.context.domWidth;n>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):n<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}});h(this,"onInputPointerUp",t=>{t.button===0&&(this._didSwipe=!1)});h(this,"onInputKeyDown",t=>{if(!this.useKeyboard||!this.scenes)return;const i=t.key.toLowerCase();if(!i)return;const n=parseInt(i)-1;if(n>=0){this.trySelectSceneFromValue(n);return}switch(i){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}});h(this,"__lastSwitchScene");h(this,"__lastSwitchScenePromise");h(this,"_currentlyLoadingScene");h(this,"_lastLoadingScene");h(this,"_loadingScenePromise");h(this,"_isCurrentlyLoading",!1);h(this,"_currentLoadingProgress")}get currentIndex(){return this._currentIndex}get currentLoadingProgress(){return this._currentLoadingProgress}get currentlyLoadingScene(){return this._currentlyLoadingScene}get currentlyLoadedScene(){return this._currentScene}awake(){this.scenes===void 0&&(this.scenes=[]),co&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(en.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(en.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(en.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(t=>{for(const i of t)if(i.type==="attributes"&&i.attributeName===ib){const n=this.context.domElement.getAttribute(ib);n!==null&&this.trySelectSceneFromValue(n)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new Yle(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin(),this.autoLoadFirstScene&&this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const t=this.context.domElement.getAttribute(ib);try{(t===null||!await this.trySelectSceneFromValue(t))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var t;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(en.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(en.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(en.PointerUp,this.onInputPointerUp),(t=this._preloadScheduler)==null||t.stop()}addScene(t){if(typeof t=="string"){let i=this.context.addressables.findAssetReference(t);return i||(i=new $t(t),this.context.addressables.registerAssetReference(i)),this.scenes.push(i),i}return this.scenes.push(t),t}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(t){var n,r,o;if(co&&console.log("select",t),typeof t=="object"&&console.warn('Switching to "'+t+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof t=="string"){const a=(n=this.scenes)==null?void 0:n.find(l=>l.uri===t);if(!a){const l=$t.getOrCreate(this.sourceId??"",t,this.context);return this.switchScene(l)}if(a)t=(r=this.scenes)==null?void 0:r.indexOf(a);else return sh}if(!((o=this.scenes)!=null&&o.length))return sh;if(t<0){if(this.clamp)return sh;t=this.scenes.length-1}else if(t>=this.scenes.length){if(this.clamp)return sh;t=0}const i=this.scenes[t];return this.switchScene(i)}async switchScene(t){if(!(t instanceof $t)){const n=typeof t;return n==="string"?this.select(t):n==="number"?this.select(t):(console.warn("SceneSwitcher: Can't switch to scene",t,"of type",n),!1)}return t.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===t&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=t,this.__lastSwitchScenePromise=this.__internalSwitchScene(t),await this.__lastSwitchScenePromise)}async __internalSwitchScene(t){var n,r;if(this._currentScene){co&&console.log("UNLOAD",t.uri);const o=this.tryGetSceneEventListener(this._currentScene.asset);if(o!=null&&o.sceneClosing){const a=o.sceneClosing();a instanceof Promise&&await a}this._currentScene.unload()}this._currentScene=void 0;const i=this._currentIndex=((n=this.scenes)==null?void 0:n.indexOf(t))??-1;try{this._currentlyLoadingScene=t,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const o=new CustomEvent("loadscene-start",{detail:{scene:t,switcher:this,index:i}});this.dispatchEvent(o),await this.onStartLoading(),await t.loadAssetAsync((l,c)=>{this._currentLoadingProgress=c,this.dispatchEvent(c)}).catch(console.error),await this.onEndLoading();const a=new CustomEvent("loadscene-finished",{detail:{scene:t,switcher:this,index:i}});if(this.dispatchEvent(a),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,a.defaultPrevented)return co&&console.warn("Adding loaded scene prevented:",t,a),!1;if(!t.asset)return co&&console.warn("Failed loading scene:",t),!1;if(this._currentIndex===i){if(co&&console.log("ADD",t.uri),this._currentScene=t,oe.add(t.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(t),this.useHistory&&i>=0){let u=i.toString();if(this.useSceneName&&(u=ok(t.uri)),(r=this.queryParameterName)!=null&&r.length)Sb(this.queryParameterName,u,this.useHistory);else{const d=history.state,f=this.guid+"::"+i;d!==f&&history.pushState(f,"unused",location.href)}}const l=this.tryGetSceneEventListener(t.asset);if(l!=null&&l.sceneOpened){const u=l.sceneOpened(this);u instanceof Promise&&await u}const c=new CustomEvent("scene-opened",{detail:{scene:t,switcher:this,index:i}});return this.dispatchEvent(c),!0}}catch(o){console.error(o)}return!1}preload(t){if(t>=0&&t<this.scenes.length){const i=this.scenes[t];if(i instanceof $t)return i.preload()}return sh}tryLoadFromQueryParam(){var i;if(!((i=this.queryParameterName)!=null&&i.length))return sh;const t=ne(this.queryParameterName);return typeof t=="boolean"?sh:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(t){if(typeof t=="string"){const i=parseInt(t);if(i>=0&&i<this.scenes.length)return this.select(i);{const n=t.toLowerCase();for(let r=0;r<this.scenes.length;r++){const o=this.scenes[r];if(o&&ok(o.uri).toLowerCase().includes(n))return this.select(r)}}}else if(typeof t=="number"&&t>=0&&t<this.scenes.length)return this.select(t);return xo()&&console.warn('Can not find scene: "'+t+'"',this),sh}async onStartLoading(){var t,i;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(t=this.loadingScene)==null?void 0:t.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&((i=this.loadingScene)!=null&&i.asset))){co&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const n=this.loadingScene.asset;oe.add(n,this.gameObject);const r=this.tryGetSceneEventListener(n);if(r!=null&&r.sceneOpened){const o=r.sceneOpened(this);o instanceof Promise&&await o}}if(this._isCurrentlyLoading){const n=this.tryGetSceneEventListener(this.gameObject);if(n&&n.sceneOpened){const r=n.sceneOpened(this);r instanceof Promise&&await r}}}async onEndLoading(){var t;if(this._isCurrentlyLoading=!1,(t=this.loadingScene)!=null&&t.asset){co&&console.log("Remove loading scene",this.loadingScene.uri);const i=this.loadingScene.asset,n=this.tryGetSceneEventListener(i);if(typeof(n==null?void 0:n.sceneClosing)=="function"){const r=n.sceneClosing();r instanceof Promise&&await r}oe.remove(i)}if(!this._isCurrentlyLoading){const i=this.tryGetSceneEventListener(this.gameObject);if(i&&i.sceneClosing){const n=i.sceneClosing();n instanceof Promise&&await n}}}tryGetSceneEventListener(t,i=0){const n=oe.foreachComponent(t,r=>r.sceneClosing?r:void 0);if(i===0&&!n&&t.children.length)for(const r of t.children){const o=this.tryGetSceneEventListener(r,i+1);if(o)return o}return n||null}}Do([x()],hr.prototype,"autoLoadFirstScene",2);Do([x($t)],hr.prototype,"scenes",2);Do([x($t)],hr.prototype,"loadingScene",2);Do([x()],hr.prototype,"queryParameterName",2);Do([x()],hr.prototype,"useSceneName",2);Do([x()],hr.prototype,"clamp",2);Do([x()],hr.prototype,"useHistory",2);Do([x()],hr.prototype,"useKeyboard",2);Do([x()],hr.prototype,"useSwipe",2);Do([x()],hr.prototype,"useSceneLighting",2);Do([x()],hr.prototype,"preloadNext",2);Do([x()],hr.prototype,"preloadPrevious",2);Do([x()],hr.prototype,"preloadConcurrent",2);function ok(s){const e=s.split("/").pop(),t=e==null?void 0:e.split(".").shift();return t!=null&&t.length?t:s}class Yle{constructor(e,t=1,i=1,n=2){h(this,"maxLoadAhead");h(this,"maxLoadBehind");h(this,"maxConcurrent");h(this,"_isRunning",!1);h(this,"_switcher");h(this,"_loadTasks",[]);h(this,"_maxConcurrentLoads",1);this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=i,this.maxConcurrent=n}begin(){if(this._isRunning)return;co&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,i;const n=this._switcher.scenes,r=setInterval(()=>{if(this.allLoaded()&&(co&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(r);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,i=0,t=0);const o=i%2===0;o&&(t+=1),i+=1;const a=o?this.maxLoadAhead:this.maxLoadBehind;if(t>a)return;const l=o?e+t:e-t;if(l<0||l<0||l>=n.length)return;const c=n[l];new Jle(l,c,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){if(this._switcher.scenes){for(const e of this._switcher.scenes)if((e==null?void 0:e.isLoaded())===!1)return!1}return!0}}class Jle{constructor(e,t,i){h(this,"index");h(this,"asset");h(this,"tasks");this.index=e,this.asset=t,this.tasks=i,i.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(co&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),co&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function Kle(){return new Promise((s,e)=>{const i=()=>{i!=null&&(document.removeEventListener("pointerdown",i),document.removeEventListener("click",i),document.removeEventListener("dragstart",i),document.removeEventListener("touchstart",i),s())};document.addEventListener("pointerdown",i),document.addEventListener("click",i),document.addEventListener("dragstart",i),document.addEventListener("touchstart",i)})}async function Zle(s){await Kle(),s()}var $le=Object.defineProperty,ece=Object.getOwnPropertyDescriptor,Oo=(s,e,t,i)=>{for(var n=i>1?void 0:i?ece(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&$le(e,t,n),n};const as=ne("debugvideo");var $G=(s=>(s[s.None=0]="None",s[s.AdjustHeight=1]="AdjustHeight",s[s.AdjustWidth=2]="AdjustWidth",s))($G||{}),eH=(s=>(s[s.VideoClip=0]="VideoClip",s[s.Url=1]="Url",s))(eH||{}),tH=(s=>(s[s.CameraFarPlane=0]="CameraFarPlane",s[s.CameraNearPlane=1]="CameraNearPlane",s[s.RenderTexture=2]="RenderTexture",s[s.MaterialOverride=3]="MaterialOverride",s))(tH||{});class ns extends Me{constructor(){super();h(this,"playOnAwake",!0);h(this,"aspectMode",0);h(this,"clip",null);h(this,"source",1);h(this,"url",null);h(this,"renderMode");h(this,"targetMaterialProperty");h(this,"targetMaterialRenderer");h(this,"targetTexture");h(this,"time",0);h(this,"_playbackSpeed",1);h(this,"_isLooping",!1);h(this,"_muted",!1);h(this,"_audioOutputMode",2);h(this,"playInBackground",!0);h(this,"_crossOrigin","anonymous");h(this,"_videoElement",null);h(this,"_videoTexture",null);h(this,"_videoMaterial",null);h(this,"_isPlaying",!1);h(this,"wasPlaying",!1);h(this,"visibilityChanged",t=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}});h(this,"_receivedInput",!1);h(this,"_overlay",null);h(this,"_targetObjects");h(this,"_updateAspectRoutineId",-1);h(this,"_hls");h(this,"onHlsAvailable",()=>{var t;as&&console.log("HLS: available",this.clip),!(!this.shouldUseM3U8||!this.url)&&(this._hls||(this._hls=new Hls),this.videoElement.autoplay=!0,this._hls.loadSource(this.url),this._hls.attachMedia(this.videoElement),(t=this._videoElement)==null||t.play(),as&&console.log("HLS: loaded",this.clip))});Zle(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],ne("videoscreenspace")&&window.addEventListener("keydown",t=>{t.key==="f"&&(this.screenspace=!this.screenspace)})}get playbackSpeed(){var t;return((t=this._videoElement)==null?void 0:t.playbackRate)??this._playbackSpeed}set playbackSpeed(t){this._playbackSpeed=t,this._videoElement&&(this._videoElement.playbackRate=t)}get isLooping(){var t;return((t=this._videoElement)==null?void 0:t.loop)??this._isLooping}set isLooping(t){this._isLooping=t,this._videoElement&&(this._videoElement.loop=t)}get currentTime(){var t;return((t=this._videoElement)==null?void 0:t.currentTime)??this.time}set currentTime(t){this._videoElement?this._videoElement.currentTime=t:this.time=t}get isPlaying(){const t=this._videoElement;if(t){if(t.currentTime>0&&!t.paused&&!t.ended&&t.readyState>t.HAVE_CURRENT_DATA)return!0;if(t.srcObject&&t.srcObject.active)return!0}return!1}get crossOrigin(){var t;return((t=this._videoElement)==null?void 0:t.crossOrigin)??this._crossOrigin}set crossOrigin(t){this._crossOrigin=t,this._videoElement&&(t!==null?this._videoElement.setAttribute("crossorigin",t):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return!this._videoMaterial&&!this.create(!1)?null:this._videoMaterial}get videoTexture(){return!this._videoTexture&&!this.create(!1)?null:this._videoTexture}get videoElement(){return!this._videoElement&&!this.create(!1)?null:this._videoElement}get muted(){var t;return((t=this._videoElement)==null?void 0:t.muted)??this._muted}set muted(t){this._muted=t,this._videoElement&&(this._videoElement.muted=t)}get currentVideo(){return this.clip}set audioOutputMode(t){t!==this._audioOutputMode&&(t===1&&gt()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=t,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){as&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(t){this.clip=t,this.source=0,this._videoElement?(this._videoElement.srcObject=t,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(t){this.url!==t&&(this.url=t,this.source=1,as&&console.log("set url",t),this._videoElement?t.endsWith(".m3u8")?this.ensureM3U8CanBePlayed():(this._videoElement.src=t,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var t,i;as&&console.log("VideoPlayer.onEnable",eH[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(t=this._overlay)==null||t.start():(i=this._overlay)==null||i.stop()}onDisable(){var t;window.removeEventListener("visibilitychange",this.visibilityChanged),(t=this._overlay)==null||t.stop(),this.pause()}onDestroy(){var t;this._videoElement&&((t=this.videoElement)==null||t.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var t,i;if(this._videoElement||this.create(!1),!this._videoElement){as&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((t=this._videoElement)!=null&&t.ended)&&!((i=this._videoElement)!=null&&i.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U8){this.ensureM3U8CanBePlayed();return}as&&console.log("Video Play()",this.clip,this._videoElement,this.time),this._videoElement.currentTime=this.time,this._videoElement.play().catch(n=>{var r;console.log(n),as&&console.error("Error playing video",n,"CODE="+n.code,(r=this.videoElement)==null?void 0:r.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),as&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),as&&console.log("STOP",this))}pause(){var t,i;this.time=((t=this._videoElement)==null?void 0:t.currentTime)??0,this._isPlaying=!1,(i=this._videoElement)==null||i.pause(),as&&console.log("PAUSE",this,this.currentTime)}create(t){let i;switch(this.source){case 0:i=this.clip;break;case 1:i=this.url,!(i!=null&&i.length)&&typeof this.clip=="string"&&(i=this.clip);break}return i?(this._videoElement||(as&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof i=="string"?(as&&console.log("Set Video src",i),this._videoElement.src=i):(as&&console.log("Set Video srcObject",i),this._videoElement.srcObject=i),this._videoTexture||(this._videoTexture=new ZF(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=vt,t&&this.handleBeginPlaying(t),as&&console.log("Video: handle playing done...",i,t),!0):(as&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var t;return((t=this._overlay)==null?void 0:t.enabled)??!1}set screenspace(t){var i;if(t){if(!this._videoTexture)return;this._overlay||(this._overlay=new tce(this.context)),this._overlay.add(this._videoTexture)}else(i=this._overlay)==null||i.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=t)}createVideoElement(){const t=document.createElement("video");return this._crossOrigin&&t.setAttribute("crossorigin",this._crossOrigin),as&&console.log("created video element",t),t}handleBeginPlaying(t){var r,o;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let i=this.gameObject;switch(this.renderMode){case 3:i=(r=this.targetMaterialRenderer)==null?void 0:r.gameObject,i||(i=(o=oe.getComponent(this.gameObject,Dn))==null?void 0:o.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!i){console.error("Missing target for video material renderer",this.name,tH[this.renderMode],this);return}const n=i.material;if(n){this._targetObjects.push(i),n!==this._videoMaterial&&(this._videoMaterial=n.clone(),i.material=this._videoMaterial);const a="map",l=this._videoMaterial;if(!this.targetMaterialProperty)l[a]=this._videoTexture;else switch(this.targetMaterialProperty){default:l[a]=this._videoTexture;break}}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),t&&(this.shouldUseM3U8&&this.ensureM3U8CanBePlayed(),this.play())}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let t=!this._receivedInput||this.audioOutputMode===0;!t&&this._muted&&(t=!0),this._videoElement.muted=t,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const t=++this._updateAspectRoutineId,i=void 0,n=this.clip;for(;t===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&n===this.clip&&this._isPlaying;){if(!n||typeof n=="string")return;let r;for(const o of n.getVideoTracks()){const a=o.getSettings();if(a&&a.width&&a.height){r=a.width/a.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let o=0;o<10;o++)yield;if(!this.isPlaying)break;continue}if(i===r){yield;continue}for(const o of this._targetObjects){let a=1;if(o.parent){const l=Hi(o.parent);a=l.x/l.y}switch(this.aspectMode){case 1:o.scale.y=1/r*o.scale.x*a;break;case 2:o.scale.x=r*o.scale.y*a;break}}for(let o=0;o<3;o++)yield}}get shouldUseM3U8(){return this.url!=null&&this.url.endsWith(".m3u8")&&this.source===1}ensureM3U8CanBePlayed(){if(!this.shouldUseM3U8)return;let t=document.head.querySelector("script[data-hls_library]");t?globalThis.Hls?this.onHlsAvailable():t.addEventListener("load",this.onHlsAvailable):(as&&console.log("HLS: load script"),t=document.createElement("script"),t.dataset.hls_library="hls.js",t.src="https://cdn.jsdelivr.net/npm/hls.js@1",t.addEventListener("load",this.onHlsAvailable),document.head.append(t))}}Oo([x()],ns.prototype,"playOnAwake",2);Oo([x()],ns.prototype,"aspectMode",2);Oo([x(URL)],ns.prototype,"clip",2);Oo([x()],ns.prototype,"source",2);Oo([x(URL)],ns.prototype,"url",2);Oo([x()],ns.prototype,"renderMode",2);Oo([x()],ns.prototype,"targetMaterialProperty",2);Oo([x(Dn)],ns.prototype,"targetMaterialRenderer",2);Oo([x(_t)],ns.prototype,"targetTexture",2);Oo([x()],ns.prototype,"time",2);Oo([x()],ns.prototype,"playbackSpeed",1);Oo([x()],ns.prototype,"isLooping",1);Oo([x()],ns.prototype,"audioOutputMode",1);class tce{constructor(e){h(this,"context");h(this,"_videos",[]);h(this,"_screenspaceModeQuad");h(this,"_isInScreenspaceMode",!1);h(this,"_input");this.context=e,this._input=new ice(this)}get enabled(){return this._isInScreenspaceMode}set enabled(e){e?this.start():this.stop()}add(e){this._videos.indexOf(e)===-1&&this._videos.push(e)}remove(e){if(!e)return;const t=this._videos.indexOf(e);t>=0&&this._videos.splice(t,1)}start(){var n;if(this._isInScreenspaceMode||this._videos.length<0)return;const e=this._videos[this._videos.length-1];if(!e)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=LA.createPrimitive(bd.Quad,{material:new nce(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const t=this._screenspaceModeQuad;this.context.scene.add(t),this.updateScreenspaceMaterialUniforms();const i=t.material;i==null||i.reset(),(n=this._input)==null||n.enable(i)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var t;const e=(t=this._screenspaceModeQuad)==null?void 0:t.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class ice{constructor(e){h(this,"_onResizeScreenFn");h(this,"_onKeyUpFn");h(this,"_onMouseWheelFn");h(this,"context");h(this,"overlay");h(this,"_material");h(this,"_isPinching",!1);h(this,"_lastPinch",0);this.overlay=e,this.context=e.context}enable(e){this._material=e,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=n=>{n.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=n=>{this.overlay.enabled&&(e.zoom+=n.deltaY*5e-4,n.preventDefault())},{passive:!1});const t=new te;window.addEventListener("mousemove",n=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const r=new te(n.movementX,n.movementY);r.x/=this.context.domElement.clientWidth,r.y/=this.context.domElement.clientHeight,t.set(r.x,r.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",n=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(n.movementX,n.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let i=0;window.addEventListener("touchstart",n=>{if(n.touches.length<2){this.context.time.time-i<.3&&this.overlay.stop(),i=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",n=>{if(!this._isPinching||!this._material)return;const r=n.touches[0],o=n.touches[1],a=r.clientX-o.clientX,l=r.clientY-o.clientY,c=Math.sqrt(a*a+l*l);if(this._lastPinch!==0){const u=c-this._lastPinch;this._material.zoom-=u*.004}this._lastPinch=c}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class nce extends Bt{constructor(t){super();h(this,"_offset",new te);this.uniforms={map:{value:t},screenAspect:{value:1},offsetScale:{value:new Ze(0,0,1,1)}},this.vertexShader=`
6954
+ }`);new w(0,0,1);var Xae=function(s){Em(t,s);var e=Mm(t);function t(i){var n;return Et(this,t),n=e.call(this,i),ee(ni(n),"positionBuffer",void 0),ee(ni(n),"previousBuffer",void 0),ee(ni(n),"nextBuffer",void 0),ee(ni(n),"uvBuffer",void 0),ee(ni(n),"sideBuffer",void 0),ee(ni(n),"widthBuffer",void 0),ee(ni(n),"colorBuffer",void 0),ee(ni(n),"indexBuffer",void 0),ee(ni(n),"vector_",new w),ee(ni(n),"vector2_",new w),ee(ni(n),"vector3_",new w),ee(ni(n),"quaternion_",new Ce),n.maxParticles=1e4,n.setupBuffers(),n.rebuildMaterial(),n}return Mt(t,[{key:"setupBuffers",value:function(){this.geometry&&this.geometry.dispose(),this.geometry=new At,this.indexBuffer=new tt(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(tr),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new tt(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(tr),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new tt(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(tr),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new tt(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(tr),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new tt(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(tr),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new tt(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(tr),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new tt(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(tr),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new tt(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(tr),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function(n){for(;n>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function(){this.layers.mask=this.settings.layers.mask;var n={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new te(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0},repeat:{value:new te(1,1)}},r={};if(r.USE_UV="",r.USE_COLOR_ALPHA="",this.settings.material.map&&(r.USE_MAP="",r.MAP_UV=XM(this.settings.material.map.channel),n.map=new _e(this.settings.material.map),n.mapTransform=new _e(new Ut().copy(this.settings.material.map.matrix))),this.settings.renderMode===at.Trail)this.material=new Bt({uniforms:n,defines:r,vertexShader:qae,fragmentShader:jae,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||dd});else throw new Error("render mode unavailable")}},{key:"update",value:function(){var n=this,r=0,o=0,a=0;this.systems.forEach(function(l){for(var c=0;c<l.particleNum;c++)a+=l.particles[c].previous.length*2}),a>this.maxParticles&&this.expandBuffers(a),this.systems.forEach(function(l){var c=n.quaternion_,u=n.vector2_,d=n.vector3_;l.emitter.matrixWorld.decompose(u,c,d);for(var f=l.particles,p=l.particleNum,m=n.settings.uTileCount,A=n.settings.vTileCount,g=1/m,v=1/A,_=0;_<p;_++){var y=f[_],b=y.uvTile%A,M=Math.floor(y.uvTile/A),E=y.previous.values(),T=E.next(),C=T.value,P=C;T.done||(T=E.next());var S=void 0;T.value!==void 0?S=T.value:S=P;for(var I=0;I<y.previous.length;I++,r+=2){if(n.positionBuffer.setXYZ(r,P.position.x,P.position.y,P.position.z),n.positionBuffer.setXYZ(r+1,P.position.x,P.position.y,P.position.z),l.worldSpace?(n.positionBuffer.setXYZ(r,P.position.x,P.position.y,P.position.z),n.positionBuffer.setXYZ(r+1,P.position.x,P.position.y,P.position.z)):(y.parentMatrix?n.vector_.copy(P.position).applyMatrix4(y.parentMatrix):n.vector_.copy(P.position).applyMatrix4(l.emitter.matrixWorld),n.positionBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.positionBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),l.worldSpace?(n.previousBuffer.setXYZ(r,C.position.x,C.position.y,C.position.z),n.previousBuffer.setXYZ(r+1,C.position.x,C.position.y,C.position.z)):(y.parentMatrix?n.vector_.copy(C.position).applyMatrix4(y.parentMatrix):n.vector_.copy(C.position).applyMatrix4(l.emitter.matrixWorld),n.previousBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.previousBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),l.worldSpace?(n.nextBuffer.setXYZ(r,S.position.x,S.position.y,S.position.z),n.nextBuffer.setXYZ(r+1,S.position.x,S.position.y,S.position.z)):(y.parentMatrix?n.vector_.copy(S.position).applyMatrix4(y.parentMatrix):n.vector_.copy(S.position).applyMatrix4(l.emitter.matrixWorld),n.nextBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.nextBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),n.sideBuffer.setX(r,-1),n.sideBuffer.setX(r+1,1),l.worldSpace)n.widthBuffer.setX(r,P.size),n.widthBuffer.setX(r+1,P.size);else if(y.parentMatrix)n.widthBuffer.setX(r,P.size),n.widthBuffer.setX(r+1,P.size);else{var H=(Math.abs(d.x)+Math.abs(d.y)+Math.abs(d.z))/3;n.widthBuffer.setX(r,P.size*H),n.widthBuffer.setX(r+1,P.size*H)}n.uvBuffer.setXY(r,(I/y.previous.length+b)*g,(A-M-1)*v),n.uvBuffer.setXY(r+1,(I/y.previous.length+b)*g,(A-M)*v),n.colorBuffer.setXYZW(r,P.color.x,P.color.y,P.color.z,P.color.w),n.colorBuffer.setXYZW(r+1,P.color.x,P.color.y,P.color.z,P.color.w),I+1<y.previous.length&&(n.indexBuffer.setX(o*3,r),n.indexBuffer.setX(o*3+1,r+1),n.indexBuffer.setX(o*3+2,r+2),o++,n.indexBuffer.setX(o*3,r+2),n.indexBuffer.setX(o*3+1,r+1),n.indexBuffer.setX(o*3+2,r+3),o++),C=P,P=S,T.done||(T=E.next(),T.value!==void 0&&(S=T.value))}}}),this.positionBuffer.updateRange.count=r*3,this.positionBuffer.needsUpdate=!0,this.previousBuffer.updateRange.count=r*3,this.previousBuffer.needsUpdate=!0,this.nextBuffer.updateRange.count=r*3,this.nextBuffer.needsUpdate=!0,this.sideBuffer.updateRange.count=r,this.sideBuffer.needsUpdate=!0,this.widthBuffer.updateRange.count=r,this.widthBuffer.needsUpdate=!0,this.uvBuffer.updateRange.count=r*2,this.uvBuffer.needsUpdate=!0,this.colorBuffer.updateRange.count=r*4,this.colorBuffer.needsUpdate=!0,this.indexBuffer.updateRange.count=o*3,this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,o*3)}},{key:"dispose",value:function(){this.geometry.dispose()}}]),t}(YG),Yae=function(s){Em(t,s);var e=Mm(t);function t(){var i;return Et(this,t),i=e.call(this),ee(ni(i),"batches",[]),ee(ni(i),"systemToBatchIndex",new Map),ee(ni(i),"type","BatchedRenderer"),i}return Mt(t,[{key:"addSystem",value:function(n){n._renderer=this;for(var r=n.getRendererSettings(),o=0;o<this.batches.length;o++)if(t.equals(this.batches[o].settings,r)){this.batches[o].addSystem(n),this.systemToBatchIndex.set(n,o);return}var a;switch(r.renderMode){case at.Trail:a=new Xae(r);break;case at.Mesh:case at.BillBoard:case at.VerticalBillBoard:case at.HorizontalBillBoard:case at.StretchedBillBoard:a=new Wae(r);break}a.addSystem(n),this.batches.push(a),this.systemToBatchIndex.set(n,this.batches.length-1),this.add(a)}},{key:"deleteSystem",value:function(n){var r=this.systemToBatchIndex.get(n);r!=null&&(this.batches[r].removeSystem(n),this.systemToBatchIndex.delete(n))}},{key:"updateSystem",value:function(n){this.deleteSystem(n),this.addSystem(n)}},{key:"update",value:function(n){this.systemToBatchIndex.forEach(function(o,a){a.update(n)});for(var r=0;r<this.batches.length;r++)this.batches[r].update()}}],[{key:"equals",value:function(n,r){return n.material.side===r.material.side&&n.material.blending===r.material.blending&&n.material.transparent===r.material.transparent&&n.material.type===r.material.type&&n.material.alphaTest===r.material.alphaTest&&n.material.map===r.material.map&&n.renderMode===r.renderMode&&n.uTileCount===r.uTileCount&&n.vTileCount===r.vTileCount&&n.instancingGeometry===r.instancingGeometry&&n.renderOrder===r.renderOrder&&n.layers.mask===r.layers.mask}}]),t}(me),Jae=Yae,JL=function(){function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new w;Et(this,s),ee(this,"locations",[]),this.scaleX=e,this.scaleY=t,this.position=i}return Mt(s,[{key:"transform",value:function(t,i){t.x=this.locations[i%this.locations.length].x*this.scaleX+this.position.x,t.y=this.locations[i%this.locations.length].y*this.scaleY+this.position.y,t.z=this.position.z}},{key:"clone",value:function(){var t=new s(this.scaleX,this.scaleY,this.position.clone());return t.locations=this.locations.map(function(i){return i.clone()}),t}},{key:"toJSON",value:function(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(function(t){return{x:t.x,y:t.y}})}}},{key:"fromImage",value:function(t,i){var n=document.createElement("canvas");n.width=t.width,n.height=t.height;var r=n.getContext("2d");if(r){r.drawImage(t,0,0);var o=r.getImageData(0,0,n.width,n.height,{colorSpace:"srgb"});n.remove(),this.locations.length=0;for(var a=0;a<o.height;a++)for(var l=0;l<o.width;l++)o.data[(a*o.width+l)*4+3]>i&&this.locations.push(new te(l,o.height-a))}}}],[{key:"fromJSON",value:function(t){var i=new s(t.scaleX,t.scaleY,new w(t.position[0],t.position[1],t.position[2]));return i.locations=t.locations.map(function(n){return new te(n.x,n.y)}),i}}]),s}();function Kae(s){switch(s.type){case"TextureSequencer":return JL.fromJSON(s);default:return new JL}}var Zae=function(){function s(e){Et(this,s),ee(this,"type","ApplySequences"),ee(this,"sequencers",[]),ee(this,"time",0),ee(this,"index",0),ee(this,"pCount",0),ee(this,"delay",void 0),ee(this,"tempV",new w),this.delay=e}return Mt(s,[{key:"initialize",value:function(t){t.id=this.pCount,t.dst=new w,t.begin=new w,t.inMotion=!1,this.pCount++}},{key:"reset",value:function(){this.time=0,this.index=0,this.pCount=0}},{key:"update",value:function(t,i){var n=this.sequencers[this.index],r=t.id*this.delay;this.time>=n[0].a+r&&this.time<=n[0].b+r?(t.inMotion||(t.inMotion=!0,t.begin.copy(t.position),n[1].transform(t.dst,t.id)),t.position.lerpVectors(t.begin,t.dst,s.BEZIER.genValue((this.time-n[0].a-r)/(n[0].b-n[0].a)))):this.time>n[0].b+r&&(t.inMotion=!1)}},{key:"frameUpdate",value:function(t){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=t}},{key:"appendSequencer",value:function(t,i){this.sequencers.push([t,i])}},{key:"toJSON",value:function(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(function(t){var i=Sp(t,2),n=i[0],r=i[1];return{range:n.toJSON(),sequencer:r.toJSON()}})}}},{key:"clone",value:function(){var t=new s(this.delay);return t.sequencers=this.sequencers.map(function(i){return[i[0].clone(),i[1].clone()]}),t}}],[{key:"fromJSON",value:function(t){var i=new s(t.delay);return t.sequencers.forEach(function(n){i.sequencers.push([Ni(n.range),Kae(n.sequencer)])}),i}}]),s}();ee(Zae,"BEZIER",new VM(0,0,1,1));var ue=function(s){return s[s.Number=0]="Number",s[s.Vec2=1]="Vec2",s[s.Vec3=2]="Vec3",s[s.Vec4=3]="Vec4",s[s.Boolean=4]="Boolean",s[s.AnyType=5]="AnyType",s}({}),KL=Mt(function s(e,t,i,n){Et(this,s),ee(this,"input",void 0),ee(this,"inputIndex",void 0),ee(this,"output",void 0),ee(this,"outputIndex",void 0),this.input=e,this.inputIndex=t,this.input.outputs[t].push(this),this.output=i,this.outputIndex=n,this.output.inputs[n]=this}),$ae=function(){function s(){Et(this,s),ee(this,"visited",new Set),ee(this,"graph_",void 0),ee(this,"context_",void 0),s.Instance=this}return Mt(s,[{key:"traverse",value:function(t){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");this.visited.add(t.id);for(var i=[],n=0;n<t.inputs.length;n++)if(t.inputs[n]instanceof KL){var r=t.inputs[n].input;this.visited.has(r.id)||this.traverse(r),i.push(r.outputValues[t.inputs[n].inputIndex])}else i.push(t.inputs[n].getValue(this.context_));t.func(this.context_,i,t.outputValues),this.graph_.nodesInOrder.push(t)}},{key:"executeCompiledGraph",value:function(){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");for(var t=this.graph_.nodesInOrder,i=0;i<t.length;i++){for(var n=[],r=t[i],o=0;o<r.inputs.length;o++)if(r.inputs[o]instanceof KL)n.push(r.inputs[o].input.outputValues[r.inputs[o].inputIndex]);else if(r.inputs[o]!==void 0)n.push(r.inputs[o].getValue(this.context_));else throw new Error("miss input for node ".concat(r.id));r.func(this.context_,n,r.outputValues)}}},{key:"run",value:function(t,i){if(this.graph_=t,this.context_=i,t.compiled)this.executeCompiledGraph();else{t.nodesInOrder.length=0,this.visited.clear();for(var n=0;n<t.outputNodes.length;n++){var r=t.outputNodes[n];this.traverse(r)}t.compiled=!0}}}]),s}();ee($ae,"Instance",void 0);var ci=function(){function s(e){Et(this,s),ee(this,"name",void 0),ee(this,"nodeTypeSignatures",[]),this.name=e}return Mt(s,[{key:"addSignature",value:function(t,i,n){this.nodeTypeSignatures.push({inputTypes:t,outputTypes:i,func:n})}}]),s}(),eS=new ci("add");eS.addSignature([ue.Number,ue.Number],[ue.Number],function(s,e,t,i){i[0]=t[0]+t[1]});eS.addSignature([ue.Vec2,ue.Vec2],[ue.Vec2],function(s,e,t,i){i[0].addVectors(t[0],t[1])});eS.addSignature([ue.Vec3,ue.Vec3],[ue.Vec3],function(s,e,t,i){i[0].addVectors(t[0],t[1])});eS.addSignature([ue.Vec4,ue.Vec4],[ue.Vec4],function(s,e,t,i){i[0].addVectors(t[0],t[1])});var tS=new ci("sub");tS.addSignature([ue.Number,ue.Number],[ue.Number],function(s,e,t,i){i[0]=t[0]-t[1]});tS.addSignature([ue.Vec2,ue.Vec2],[ue.Vec2],function(s,e,t,i){i[0].subVectors(t[0],t[1])});tS.addSignature([ue.Vec3,ue.Vec3],[ue.Vec3],function(s,e,t,i){i[0].subVectors(t[0],t[1])});tS.addSignature([ue.Vec4,ue.Vec4],[ue.Vec4],function(s,e,t,i){i[0].subVectors(t[0],t[1])});var iS=new ci("mul");iS.addSignature([ue.Number,ue.Number],[ue.Number],function(s,e,t,i){i[0]=t[0]*t[1]});iS.addSignature([ue.Vec2,ue.Number],[ue.Vec2],function(s,e,t,i){i[0].copy(t[0]).multiplyScalar(t[1])});iS.addSignature([ue.Vec3,ue.Number],[ue.Vec3],function(s,e,t,i){i[0].copy(t[0]).multiplyScalar(t[1])});iS.addSignature([ue.Vec4,ue.Number],[ue.Vec4],function(s,e,t,i){i[0].copy(t[0]).multiplyScalar(t[1])});var nS=new ci("div");nS.addSignature([ue.Number,ue.Number],[ue.Number],function(s,e,t,i){i[0]=t[0]/t[1]});nS.addSignature([ue.Vec2,ue.Number],[ue.Vec2],function(s,e,t,i){i[0].copy(t[0]).divideScalar(t[1])});nS.addSignature([ue.Vec3,ue.Number],[ue.Vec3],function(s,e,t,i){i[0].copy(t[0]).divideScalar(t[1])});nS.addSignature([ue.Vec4,ue.Number],[ue.Vec4],function(s,e,t,i){i[0].copy(t[0]).divideScalar(t[1])});var ele=new ci("sin");ele.addSignature([ue.Number],[ue.Number],function(s,e,t,i){i[0]=Math.sin(t[0])});var tle=new ci("cos");tle.addSignature([ue.Number],[ue.Number],function(s,e,t,i){i[0]=Math.cos(t[0])});var ile=new ci("tan");ile.addSignature([ue.Number],[ue.Number],function(s,e,t,i){i[0]=Math.tan(t[0])});var nle=new ci("abs");nle.addSignature([ue.Number],[ue.Number],function(s,e,t,i){i[0]=Math.abs(t[0])});var sle=new ci("min");sle.addSignature([ue.Number,ue.Number],[ue.Number],function(s,e,t,i){i[0]=Math.min(t[0],t[1])});var rle=new ci("max");rle.addSignature([ue.Number,ue.Number],[ue.Number],function(s,e,t,i){i[0]=Math.max(t[0],t[1])});var AP=new ci("dot");AP.addSignature([ue.Vec2,ue.Vec2],[ue.Number],function(s,e,t,i){i[0]=t[0].dot(t[1])});AP.addSignature([ue.Vec3,ue.Vec3],[ue.Number],function(s,e,t,i){i[0]=t[0].dot(t[1])});AP.addSignature([ue.Vec4,ue.Vec4],[ue.Number],function(s,e,t,i){i[0]=t[0].dot(t[1])});var ole=new ci("cross");ole.addSignature([ue.Vec3,ue.Vec3],[ue.Vec3],function(s,e,t,i){i[0].crossVectors(t[0],t[1])});var yP=new ci("length");yP.addSignature([ue.Vec2],[ue.Number],function(s,e,t,i){i[0]=t[0].length()});yP.addSignature([ue.Vec3],[ue.Number],function(s,e,t,i){i[0]=t[0].length()});yP.addSignature([ue.Vec4],[ue.Number],function(s,e,t,i){i[0]=t[0].length()});var _P=new ci("lengthSq");_P.addSignature([ue.Vec2],[ue.Number],function(s,e,t,i){i[0]=t[0].lengthSq()});_P.addSignature([ue.Vec3],[ue.Number],function(s,e,t,i){i[0]=t[0].lengthSq()});_P.addSignature([ue.Vec4],[ue.Number],function(s,e,t,i){i[0]=t[0].lengthSq()});var bP=new ci("normalize");bP.addSignature([ue.Vec2],[ue.Vec2],function(s,e,t,i){i[0].copy(t[0]).normalize()});bP.addSignature([ue.Vec3],[ue.Vec3],function(s,e,t,i){i[0].copy(t[0]).normalize()});bP.addSignature([ue.Vec4],[ue.Vec4],function(s,e,t,i){i[0].copy(t[0]).normalize()});var JG=new ci("distance");JG.addSignature([ue.Vec2,ue.Vec2],[ue.Number],function(s,e,t,i){i[0]=t[0].distanceTo(t[1])});JG.addSignature([ue.Vec3,ue.Vec3],[ue.Number],function(s,e,t,i){i[0]=t[0].distanceTo(t[1])});var ale=new ci("and");ale.addSignature([ue.Boolean,ue.Boolean],[ue.Boolean],function(s,e,t,i){i[0]=t[0]&&t[1]});var lle=new ci("or");lle.addSignature([ue.Boolean,ue.Boolean],[ue.Boolean],function(s,e,t,i){i[0]=t[0]||t[1]});var cle=new ci("not");cle.addSignature([ue.Boolean],[ue.Boolean],function(s,e,t,i){i[0]=!t[0]});var sS=new ci("equal");sS.addSignature([ue.Number,ue.Number],[ue.Boolean],function(s,e,t,i){i[0]=t[0]===t[1]});sS.addSignature([ue.Vec2,ue.Vec2],[ue.Boolean],function(s,e,t,i){i[0]=t[0].equals(t[1])});sS.addSignature([ue.Vec3,ue.Vec3],[ue.Boolean],function(s,e,t,i){i[0]=t[0].equals(t[1])});sS.addSignature([ue.Vec4,ue.Vec4],[ue.Boolean],function(s,e,t,i){i[0]=t[0].equals(t[1])});var hle=new ci("lessThan");hle.addSignature([ue.Number,ue.Number],[ue.Boolean],function(s,e,t,i){i[0]=t[0]<t[1]});var ule=new ci("greaterThan");ule.addSignature([ue.Number,ue.Number],[ue.Boolean],function(s,e,t,i){i[0]=t[0]>t[1]});var dle=new ci("lessThanOrEqual");dle.addSignature([ue.Number,ue.Number],[ue.Boolean],function(s,e,t,i){i[0]=t[0]<=t[1]});var fle=new ci("greaterThanOrEqual");fle.addSignature([ue.Number,ue.Number],[ue.Boolean],function(s,e,t,i){i[0]=t[0]>=t[1]});var ple=new ci("if");ple.addSignature([ue.Boolean,ue.AnyType,ue.AnyType],[ue.AnyType],function(s,e,t,i){i[0]=t[0]?t[1]:t[2]});var mle=new ci("number");mle.addSignature([],[ue.Number],function(s,e,t,i){i[0]=e.value});var gle=new ci("vec2");gle.addSignature([],[ue.Vec2],function(s,e,t,i){i[0]=e.value});var vle=new ci("vec3");vle.addSignature([],[ue.Vec3],function(s,e,t,i){i[0]=e.value});var Ale=new ci("vec4");Ale.addSignature([],[ue.Vec4],function(s,e,t,i){i[0]=e.value});var yle=new ci("bool");yle.addSignature([],[ue.Boolean],function(s,e,t,i){i[0]=e.value});var _le=new ci("particlePosition");_le.addSignature([],[ue.Vec3],function(s,e,t,i){i[0]=s.particle[e.property]});var ble=new ci("particleVelocity");ble.addSignature([],[ue.Vec3],function(s,e,t,i){i[0]=s.particle[e.property]});var xle=new ci("particleRotation");xle.addSignature([],[ue.Number],function(s,e,t,i){i[0]=s.particle[e.property]});var wle=new ci("particleAge");wle.addSignature([],[ue.Number],function(s,e,t,i){i[0]=s.particle[e.property]});var Ay=new ci("output");Ay.addSignature([ue.Number],[ue.Number],function(s,e,t,i){i[0]=t[0]});Ay.addSignature([ue.Vec2],[ue.Vec2],function(s,e,t,i){i[0]=t[0]});Ay.addSignature([ue.Vec3],[ue.Vec3],function(s,e,t,i){i[0]=t[0]});Ay.addSignature([ue.Vec4],[ue.Vec4],function(s,e,t,i){i[0]=t[0]});Ay.addSignature([ue.Boolean],[ue.Boolean],function(s,e,t,i){i[0]=t[0]});console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 16px; font-weight: bold;");var Sle=Object.defineProperty,Cle=Object.getOwnPropertyDescriptor,vn=(s,e,t,i)=>{for(var n=i>1?void 0:i?Cle(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Sle(e,t,n),n};const Ug=ne("debugparticles"),Ele=ne("noprogressive"),Mle=ne("debugprogressive");var YM=(s=>(s[s.Birth=0]="Birth",s[s.Collision=1]="Collision",s[s.Death=2]="Death",s[s.Trigger=3]="Trigger",s[s.Manual=4]="Manual",s))(YM||{});class ca extends Me{constructor(){super(...arguments);h(this,"renderMode");h(this,"particleMaterial");h(this,"trailMaterial");h(this,"particleMesh");h(this,"maxParticleSize");h(this,"minParticleSize");h(this,"velocityScale");h(this,"cameraVelocityScale");h(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&gt()){const t=`ParticleSystem "${this.name}" has non-default min/max particle size. This may not render correctly. Please set min size to 0 and the max size to 0.5 and use the "StartSize" setting instead`;console.warn(t)}}get transparent(){var i;return((i=this.particleMaterial)==null?void 0:i.transparent)??!1}getMaterial(t=!1){let i=t===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;return i&&t&&i.side===Os&&(i=i.clone(),i.side=wn,t?this.trailMaterial=i:this.particleMaterial=i),i&&!Ele&&i._didRequestTextureLOD===void 0&&(i._didRequestTextureLOD=0,Mle&&console.log("Load material LOD",i.name),Ti.assignTextureLOD(this.context,this.sourceId,i)),i}getMesh(t){let i=null;if(!i&&(this.particleMesh instanceof de&&(i=this.particleMesh.geometry),i===null)){i=new Gn(1,1);const r=i.attributes.uv;for(let o=0;o<r.count;o++)r.setX(o,1-r.getX(o))}return new de(i,this.getMaterial())}}vn([x()],ca.prototype,"renderMode",2);vn([x(Ot)],ca.prototype,"particleMaterial",2);vn([x(Ot)],ca.prototype,"trailMaterial",2);vn([x()],ca.prototype,"maxParticleSize",2);vn([x()],ca.prototype,"minParticleSize",2);vn([x()],ca.prototype,"velocityScale",2);vn([x()],ca.prototype,"cameraVelocityScale",2);vn([x()],ca.prototype,"lengthScale",2);class l_{constructor(e,t=1){h(this,"_curve");h(this,"_factor");h(this,"type","function");this._curve=e,this._factor=t}genValue(e){return this._curve.evaluate(e,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class xP{constructor(e){h(this,"type","value");h(this,"system");this.system=e}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class Tle extends xP{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class Ile extends xP{constructor(){super(...arguments);h(this,"_lastPosition",new w);h(this,"_lastDistance",0)}update(){const t=Nt(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(t),this._lastPosition.copy(t)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let t=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const r=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let a=this._lastDistance/this.system.deltaTime*r;Number.isFinite(a)||(a=0),t+=a}const i=this.system.emission.getBurst();i>0&&(t+=i/this.system.deltaTime);const n=this.system.maxParticles-this.system.currentParticles;return et.clamp(t,0,n/this.system.deltaTime)}}class Rle extends xP{genValue(){return this.system.isPlaying,0}}class nu{constructor(e){h(this,"system");h(this,"type");this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",e&&(this.system=e)}get context(){return this.system.context}initialize(e){}update(e,t){}frameUpdate(e){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class Ple extends nu{constructor(){super(...arguments);h(this,"type","NeedleTextureSheet")}update(t,i){const n=this.system.textureSheetAnimation;if(n.enabled){const r=t.age/t.life,o=n.evaluate(r);o!==void 0&&(t.uvTile=o)}}}const ZL=Symbol("particleRotation");class Ble extends nu{constructor(){super(...arguments);h(this,"type","NeedleRotation")}initialize(t){t[ZL]=Math.random()}update(t,i){if(t.rotation===void 0)return;const n=t.age/t.life;if(typeof t.rotation=="number"&&(this.system.rotationOverLifetime.enabled?t.rotation+=this.system.rotationOverLifetime.evaluate(n,t[ZL])*i:this.system.renderer.renderMode===ec.Billboard&&(t.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const r=t.velocity.length();t.rotation+=this.system.rotationBySpeed.evaluate(n,r)*i}}}const $L=Symbol("sizeLerpFactor"),Dle=new w;class Ole extends nu{constructor(){super(...arguments);h(this,"type","NeedleSize");h(this,"_minSize",0);h(this,"_maxSize",1)}initialize(t){t[$L]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(t,i){const n=t.age/t.life;let r=1;this.system.sizeOverLifetime.enabled&&(r*=this.system.sizeOverLifetime.evaluate(n,void 0,t[$L]).x);let o=1;if(this.system.renderer.renderMode!==ec.Mesh&&(o=this.system.worldScale.x/this.system.cameraScale),t.size=t.startSize*r*o,this.system.localspace){const a=KG(this.system,Dle);t.size*=a.x}}}const cp=Symbol("particleLife"),bE=Symbol("trailLifetime"),ek=Symbol("trailStartLength"),xE=Symbol("trailWidthRandom");class Lle extends nu{constructor(){super(...arguments);h(this,"type","NeedleTrail")}initialize(t){t instanceof nA&&(t[cp]=t.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(t[bE]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),t.life+=t[bE]),t[ek]=t.length,t[xE]=Math.random())}update(t){var i;if((i=this.system.trails)!=null&&i.enabled&&t instanceof nA){const n=t,r=t.age/t[cp],o=t.previous.values(),a=t.previous.length;for(let l=0;l<a;l++){const u=o.next().value,d=1-l/(a-1);let f=t.size;f<=0&&!this.system.trails.sizeAffectsWidth&&(f=20*this.system.trails.widthOverTrail.evaluate(.5,n[xE])),u.size=this.system.trails.getWidth(f,r,d,n[xE]),u.color.copy(t.color),this.system.trails.getColor(u.color,r,d)}if(t.age>t[cp]){t.velocity.set(0,0,0);const l=(t.age-t[cp])/t[bE];n.length=et.lerp(t[ek],0,l)}}}}const c_=Symbol("startVelocity"),tk=Symbol("gravityModifier"),wE=Symbol("gravitySpeed"),h_=Symbol("velocity lerp factor"),JM=new w;class kle extends nu{constructor(){super(...arguments);h(this,"type","NeedleVelocity");h(this,"_gravityDirection",new w)}initialize(t){var r,o;const i=this.system.main.simulationSpeed;t.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random()),t.velocity.copy(this.system.shape.getDirection(t,t.position)).multiplyScalar(t.startSpeed),(r=this.system.inheritVelocity)!=null&&r.enabled&&this.system.inheritVelocity.applyInitial(t.velocity),t[c_]?t[c_].copy(t.velocity):t[c_]=t.velocity.clone();const n=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());t[tk]=n*i,t[wE]=n*i*.5,t[h_]=Math.random(),(o=this.system.velocityOverLifetime)==null||o.init(t),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===eA.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(t,i){var f;const n=t[c_],r=t[tk];if(r!==0){const p=r*t[wE];JM.copy(this._gravityDirection).multiplyScalar(p),t[wE]+=i*.05,n.add(JM)}t.velocity.copy(n);const o=t.age/t.life;(f=this.system.inheritVelocity)!=null&&f.enabled&&this.system.inheritVelocity.applyCurrent(t.velocity,o,t[h_]);const a=this.system.noise;a.enabled&&a.apply(0,t.position,t.velocity,i,t.age,t.life);const l=this.system.sizeBySpeed;l!=null&&l.enabled&&(t.size=l.evaluate(t.velocity,o,t[h_],t.size));const c=this.system.colorBySpeed;c!=null&&c.enabled&&c.evaluate(t.velocity,t[h_],t.color);const u=this.system.velocityOverLifetime;u.enabled&&u.apply(t,0,t.position,t.velocity,i,t.age,t.life);const d=this.system.limitVelocityOverLifetime;d.enabled&&d.apply(t.position,n,t.velocity,t.size,o,i,1),this.system.worldspace&&t.velocity.multiply(this.system.worldScale)}}const ik=Symbol("colorLerpFactor"),nk=new wi(1,1,1,1),Eu=new wi(1,1,1,1);class Fle extends nu{constructor(){super(...arguments);h(this,"type","NeedleColor")}initialize(t){}_init(t){const i=this.system.renderer.particleMaterial;Eu.copy(this.system.main.startColor.evaluate(Math.random())),i!=null&&i.color&&(nk.copy(i.color),Eu.multiply(nk)),Eu.convertLinearToSRGB(),t.startColor.set(Eu.r,Eu.g,Eu.b,Eu.alpha),t.color.copy(t.startColor),t[ik]=Math.random()}update(t,i){if(t.age===0&&this._init(t),this.system.colorOverLifetime.enabled){const n=t.age/t.life,r=this.system.colorOverLifetime.color.evaluate(n,t[ik]);t.color.set(r.r,r.g,r.b,r.alpha).multiply(t.startColor)}else t.color.copy(t.startColor)}}class Ule{constructor(e){h(this,"system");h(this,"emission");h(this,"autoDestroy");h(this,"startLength");h(this,"emissionBursts");h(this,"onlyUsedByOther");h(this,"behaviors",[]);h(this,"rendererEmitterSettings",{startLength:new er(220),followLocalOrigin:!1});h(this,"flatWhiteTexture");h(this,"clonedTexture",{original:void 0,clone:void 0});this.system=e,this.emission=new Ile(this.system)}get anim(){return this.system.textureSheetAnimation}get prewarm(){return!1}get material(){return this.system.renderer.getMaterial(this.system.trails.enabled)}get layers(){return this.system.gameObject.layers}update(){this.emission.update()}get looping(){return this.system.main.loop}get duration(){return this.system.duration}get shape(){return this.system.shape}get startLife(){return new l_(this.system.main.startLifetime)}get startSpeed(){return new l_(this.system.main.startSpeed)}get startRotation(){return new l_(this.system.main.startRotation)}get startSize(){return new l_(this.system.main.startSize)}get startColor(){return new tx(new Ze(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new Rle(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return at.Trail;switch(this.system.renderer.renderMode){case ec.Billboard:return at.BillBoard;case ec.Stretch:return at.StretchedBillBoard;case ec.HorizontalBillboard:return at.HorizontalBillBoard;case ec.VerticalBillboard:return at.VerticalBillBoard;case ec.Mesh:return at.Mesh}return at.BillBoard}get speedFactor(){var t;let e=this.system.main.simulationSpeed;return((t=this.system.renderer)==null?void 0:t.renderMode)===ec.Stretch&&(e*=this.system.renderer.velocityScale??1),e}get texture(){const e=this.material;if(e&&e.map){const t=e.map;if(this.clonedTexture.original!==t||!this.clonedTexture.clone){const i=t.clone();i.premultiplyAlpha=!1,i.colorSpace=yi,this.clonedTexture.original=t,this.clonedTexture.clone=i}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=A4(new wi(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new Tle(this.system)}get uTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesX:void 0}get vTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesY:void 0}get renderOrder(){return 1}get blending(){var e;return((e=this.system.renderer.particleMaterial)==null?void 0:e.blending)??wh}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===eA.World}}class Nle{constructor(){h(this,"burstIndex",0);h(this,"burstWaveIndex",0);h(this,"time",0);h(this,"waitEmiting",0)}}const tb=class extends Me{constructor(){super(...arguments);h(this,"_state");h(this,"colorOverLifetime");h(this,"main");h(this,"emission");h(this,"sizeOverLifetime");h(this,"shape");h(this,"noise");h(this,"trails");h(this,"velocityOverLifetime");h(this,"limitVelocityOverLifetime");h(this,"inheritVelocity");h(this,"colorBySpeed");h(this,"textureSheetAnimation");h(this,"rotationOverLifetime");h(this,"rotationBySpeed");h(this,"sizeBySpeed");h(this,"_cameraScale",1);h(this,"__worldQuaternion",new Ce);h(this,"_worldQuaternionInverted",new Ce);h(this,"_worldScale",new w);h(this,"_worldPositionFrame",-1);h(this,"_worldPos",new w);h(this,"_renderer");h(this,"_batchSystem");h(this,"_particleSystem");h(this,"_interface");h(this,"_container");h(this,"_time",0);h(this,"_isPlaying",!0);h(this,"_isUsedAsSubsystem",!1);h(this,"_didPreWarm",!1);h(this,"_bursts");h(this,"_subEmitterSystems");h(this,"_lastBatchesCount",-1);h(this,"lastMaterialVersion",-1)}play(e=!1){var t;e&&oe.foreachComponent(this.gameObject,i=>{i instanceof tb&&i!==this&&i.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(t=this.emission)==null||t.reset()}pause(e=!0){e&&oe.foreachComponent(this.gameObject,t=>{t instanceof tb&&t!==this&&t.pause(!1)},!0),this._isPlaying=!1}stop(e=!0,t=!1){e&&oe.foreachComponent(this.gameObject,i=>{i instanceof tb&&i!==this&&i.stop(!1,t)},!0),this._isPlaying=!1,this._time=0,t&&this.reset()}reset(){var e;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(e=this.emission)==null||e.reset())}emit(e){if(this._particleSystem){this.onUpdate(),e=Math.min(e,this.maxParticles-this.currentParticles),this._state||(this._state=new Nle),this._state.waitEmiting=e,this._state.time=0;const t=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=t}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(e){this.main.playOnAwake=e}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var e;return((e=this._particleSystem)==null?void 0:e.particleNum)??0}get maxParticles(){return this.main.maxParticles}get time(){return this._time}get duration(){return this.main.duration}get deltaTime(){return this.context.time.deltaTime*this.main.simulationSpeed}get scale(){return this.gameObject.scale.x}get cameraScale(){return this._cameraScale}get container(){return this._container}get worldspace(){return this.main.simulationSpace===eA.World}get localspace(){return this.main.simulationSpace===eA.Local}get worldQuaternion(){return this.__worldQuaternion}get worldQuaternionInverted(){return this._worldQuaternionInverted}get worldScale(){return this._worldScale}get worldPos(){return this._worldPositionFrame!==this.context.time.frame&&(this._worldPositionFrame=this.context.time.frame,Nt(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(e){return this._particleSystem?(e instanceof nu&&(e.system=this),gt()&&console.log("add behaviour",e),this._particleSystem.addBehavior(e),!0):!1}removeBehaviour(e){if(!this._particleSystem)return!1;const t=this._particleSystem.behaviors,i=t.indexOf(e);return i!==-1&&t.splice(i,1),!0}removeAllBehaviours(){return this._particleSystem?(this._particleSystem.behaviors.length=0,!0):!1}get behaviours(){return this._particleSystem?this._particleSystem.behaviors:null}get particleSystem(){return this._particleSystem??null}set bursts(e){for(let t=0;t<e.length;t++){const i=e[t];if(!(i instanceof tA)){const n=new tA;Np(n,i),e[t]=n}}this._bursts=e}set subEmitterSystems(e){for(let t=0;t<e.length;t++){const i=e[t];if(!(i instanceof oA)){const n=new oA;Np(n,i),e[t]=n}}Ug&&e.length>0&&console.log("SubEmitters: ",e,this),this._subEmitterSystems=e}onAfterDeserialize(e){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const t of this._subEmitterSystems)t._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(ca),!this.main)throw new Error("Not Supported: ParticleSystem needs a serialized MainModule. Creating new particle systems at runtime is currently not supported.");this._container=new me,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new Jae,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new Ule(this),this._particleSystem=new Nae(this._interface),this._particleSystem.addBehavior(new Ole(this)),this._particleSystem.addBehavior(new Fle(this)),this._particleSystem.addBehavior(new Ple(this)),this._particleSystem.addBehavior(new Ble(this)),this._particleSystem.addBehavior(new kle(this)),this._particleSystem.addBehavior(new Lle(this)),this._batchSystem.addSystem(this._particleSystem);const e=this._particleSystem.emitter;this.context.scene.add(e),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),Ug&&(console.log(this),this.gameObject.add(new $o(1)))}start(){this.addSubParticleSystems(),this.updateLayers()}onDestroy(){var e,t,i,n;(e=this._container)==null||e.removeFromParent(),(t=this._batchSystem)==null||t.removeFromParent(),(i=this._particleSystem)==null||i.emitter.removeFromParent(),(n=this._particleSystem)==null||n.dispose()}onEnable(){this.main&&(this.inheritVelocity&&(this.inheritVelocity.system=this),this._batchSystem&&(this._batchSystem.visible=!0),this.playOnAwake&&this.play(),this._isPlaying=this.playOnAwake)}onDisable(){this._batchSystem&&(this._batchSystem.visible=!1)}onBeforeRender(){var e;this.main&&(this._didPreWarm===!1&&((e=this.main)==null?void 0:e.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var c;if(!((c=this.emission)!=null&&c.enabled)||this.emission.rateOverTime.getMax()<=0)return;const t=1/60,i=this.main.duration,n=this.main.startLifetime.getMax(),r=1e3,o=Math.min(Math.max(i,n)/Math.max(.01,this.main.simulationSpeed),r),a=Math.ceil(o/t),l=Date.now();Ug&&console.log(`Particles ${this.name} - Prewarm for ${a} frames (${o} sec). Duration: ${i}, Lifetime: ${n}`);for(let u=0;u<a&&!(this.currentParticles>=this.maxParticles);u++){const d=Date.now()-l;if(d>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${d}`);break}this.onUpdate(),this.onSimulate(t)}}onSimulate(e){if(this._batchSystem){let t=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,t=!0),t&&this.updateLayers(),this._batchSystem.update(e)}this._time+=e,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let e=0;e<this._batchSystem.batches.length;e++){const t=this._batchSystem.batches[e];t.layers.disableAll();const i=this.layer;t.layers.mask=1<<i}}onUpdate(){var r,o;const e=this.renderer.getMaterial(this.trails.enabled);if(e&&e.version!=this.lastMaterialVersion&&this._particleSystem&&(this.lastMaterialVersion=e.version,this._particleSystem.texture=this._interface.texture),this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const t=this.context.mainCamera;if(t){const a=Hi(t);this._cameraScale=a.x}const i=!this.worldspace,n=this.gameObject;if(Ii(n,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),Hi(this.gameObject,this._worldScale),i&&this._container&&((r=this.gameObject)!=null&&r.parent)){const a=KG(this,JM);this._container.matrix.makeScale(a.x,a.y,a.z),this._container.matrix.makeRotationFromQuaternion(this.__worldQuaternion),this._container.matrix.setPosition(this.worldPos),this._container.matrix.scale(this.gameObject.scale)}this.emission.system=this,this._interface.update(),this.shape.update(this,this.context,this.main.simulationSpace,this.gameObject),this.noise.update(this.context),(o=this.inheritVelocity)==null||o.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var e;if(this._subEmitterSystems&&this._particleSystem)for(const t of this._subEmitterSystems){t.particleSystem&&(t.particleSystem.__internalAwake?t.particleSystem.__internalAwake():gt()&&console.warn("SubParticleSystem serialization issue(?)",t.particleSystem,t));const i=(e=t.particleSystem)==null?void 0:e._particleSystem;if(i){t.particleSystem._isUsedAsSubsystem=!0;const n=new rS(this,this._particleSystem,t.particleSystem,i);n.emitterType=t.type,n.emitterProbability=t.emitProbability,this._particleSystem.addBehavior(n)}else Ug&&console.warn("Could not add SubParticleSystem",t,this)}}};let zn=tb;vn([x(ay)],zn.prototype,"colorOverLifetime",2);vn([x(Qs)],zn.prototype,"main",2);vn([x(Ml)],zn.prototype,"emission",2);vn([x($h)],zn.prototype,"sizeOverLifetime",2);vn([x(mn)],zn.prototype,"shape",2);vn([x(Ei)],zn.prototype,"noise",2);vn([x(rn)],zn.prototype,"trails",2);vn([x(gn)],zn.prototype,"velocityOverLifetime",2);vn([x(Vn)],zn.prototype,"limitVelocityOverLifetime",2);vn([x(eu)],zn.prototype,"inheritVelocity",2);vn([x(jd)],zn.prototype,"colorBySpeed",2);vn([x(Vs)],zn.prototype,"textureSheetAnimation",2);vn([x(la)],zn.prototype,"rotationOverLifetime",2);vn([x(Bo)],zn.prototype,"rotationBySpeed",2);vn([x(Or)],zn.prototype,"sizeBySpeed",2);class oA{constructor(){h(this,"particleSystem");h(this,"emitProbability",1);h(this,"properties");h(this,"type")}_deserialize(e,t){const i=this.particleSystem;if(i instanceof zn)return;let n="";i&&typeof i.guid=="string"&&(n=i.guid,this.particleSystem=oe.findByGuid(n,t)),Ug&&!(this.particleSystem instanceof zn)&&console.warn("Could not find particle system for sub emitter",n,t,this)}}function KG(s,e){if(e.set(1,1,1),s.gameObject.parent&&s.localspace)switch(s.main.scalingMode){case UM.Local:e=Hi(s.gameObject.parent,e),e.x=1/e.x,e.y=1/e.y,e.z=1/e.z;break;default:if(!s.unsupported_scaling_mode){s.unsupported_scaling_mode=!0;const t="ParticleSystem scale mode "+UM[s.main.scalingMode]+" is not supported";gt()&&dn(t),console.warn(t,s.name,s)}e=Hi(s.gameObject,e);break}return e}new w(1,1,1);new w(0,0,1);class rS{constructor(e,t,i,n){h(this,"type","NeedleParticleSubEmitter");h(this,"emitterType");h(this,"emitterProbability");h(this,"q_",new Ce);h(this,"v_",new w);h(this,"v2_",new w);h(this,"_emitterMatrix",new we);h(this,"_circularBuffer");this.system=e,this.particleSystem=t,this.subSystem=i,this.subParticleSystem=n,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const r=1e3;this._circularBuffer=new ea(()=>new we,r)}clone(){throw new Error("Method not implemented.")}initialize(e){e.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld),this._emitterMatrix.setPosition(0,0,0),this.emitterType===YM.Birth&&this.run(e)}update(e,t){this.run(e)}frameUpdate(e){}toJSON(){}reset(){}run(e){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!e.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const t=this.system.deltaTime;if(this.emitterType===YM.Death){let n=e.life;if(e[cp]!==void 0&&(n=e[cp]),!(e.age+t*1.2>=n))return;const o=this.subSystem.main.maxParticles-this.subSystem.currentParticles;e.emissionState.waitEmiting=o}const i=new we;i.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1),this.particleSystem.worldSpace||i.multiplyMatrices(this._emitterMatrix,i),this.subParticleSystem.emit(t,e.emissionState,i)}}var zle=Object.defineProperty,Gle=Object.getOwnPropertyDescriptor,Hle=(s,e,t,i)=>{for(var n=i>1?void 0:i?Gle(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&zle(e,t,n),n};class yy extends lr{constructor(){super(...arguments);h(this,"granularity")}get typeName(){return"PixelationEffect"}onCreateEffect(){const t=new q3;return this.granularity.onValueChanged=i=>{t.granularity=i},t}}Hle([x(kt)],yy.prototype,"granularity",2);aa("PixelationEffect",yy);class Vp extends Me{constructor(){super(...arguments);h(this,"_didAssignPlayerColor",!1);h(this,"tryAssignColor",()=>{const t=oe.getComponentInParent(this.gameObject,Yo);if(t&&t.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(t.owner),!0;const i=oe.getComponentInParent(this.gameObject,Yn);return i!=null&&i.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(i.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(ii.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(ii.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield d4(.2),!this.tryAssignColor()););}assignUserColor(t){const i=Vp.hashCode(t),n=Vp.colorFromHashCode(i);if(this.gameObject.type==="Mesh"){const r=this.gameObject;this.assignColor(n,t,r)}else if(this.gameObject.children)for(const r of this.gameObject.children){const o=r;o.material&&o.material.color&&this.assignColor(n,t,o)}}assignColor(t,i,n){let r=n.material;r&&(r._playerMaterial!==i&&(r=r.clone(),r._playerMaterial=i,n.material=r),r.color=t)}static hashCode(t){var i=0,n,r;if(t.length===0)return i;for(n=0;n<t.length;n++)r=t.charCodeAt(n),i=(i<<5)-i+r,i|=0;return i}static colorFromHashCode(t){const i=(t&16711680)>>16,n=(t&65280)>>8,r=t&255;return new xe(i/255,n/255,r/255)}}async function wP(s){const{NeedleEngineHTMLElement:e}=await Promise.resolve().then(()=>eue);e.observedAttributes.includes(s)||e.observedAttributes.push(s)}var Qle=Object.defineProperty,Vle=Object.getOwnPropertyDescriptor,_y=(s,e,t,i)=>{for(var n=i>1?void 0:i?Vle(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Qle(e,t,n),n};const Wo=ne("debugskybox");wP("skybox-image");wP("environment-image");function sk(s,e,t,i,n){const r=new bl;r.allowDrop=!1,r.allowNetworking=!1,r.background=t,r.environment=i,oe.addComponent(s.scene,r);const o=a=>{typeof a=="string"&&(Wo&&console.log(n,"CHANGED TO",a),r.setSkybox(a))};return NU(s.domElement,n,o),r.addEventListener("destroy",()=>{Wo&&console.log("Destroyed attribute remote skybox",n),zU(s.domElement,n,o)}),r.setSkybox(e)}ri.addContextCreatedCallback(s=>{var r;const e=s.context,t=e.domElement.getAttribute("skybox-image"),i=e.domElement.getAttribute("environment-image"),n=new Array;if(t){Wo&&console.log("Creating remote skybox to load "+t),((r=e.mainCameraComponent)==null?void 0:r.clearFlags)!==Sd.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const o=sk(e,t,!0,!1,"skybox-image");n.push(o)}if(i){Wo&&console.log("Creating remote environment to load "+i);const o=sk(e,i,!1,!0,"environment-image");n.push(o)}return n.length>0?wA(n):Promise.resolve()});function ZG(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function rk(s){const t=ZG().find(i=>i.src===s);return t?(Wo&&console.log("Skybox: Found previously loaded texture for "+s),t.texture):null}async function Wle(s){const e=await s;eR(e,!0),Li(e)}function jle(s,e){const t=ZG();for(;t.length>5;){const i=t.shift();i&&Wle(i.texture)}e.then(i=>eR(i,!1)),t.push({src:s,texture:e})}class bl extends Me{constructor(){super(...arguments);h(this,"url");h(this,"allowDrop",!0);h(this,"background",!0);h(this,"environment",!0);h(this,"allowNetworking",!0);h(this,"_loader");h(this,"_prevUrl");h(this,"_prevLoadedEnvironment");h(this,"_prevEnvironment",null);h(this,"_prevBackground",null);h(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]);h(this,"onDragOverEvent",t=>{if(this.allowDrop&&t.dataTransfer)for(const i of t.dataTransfer.types)(i==="text/uri-list"||i==="Files")&&t.preventDefault()});h(this,"onDrop",t=>{var i,n,r,o;if(this.allowDrop&&t.dataTransfer){for(const a of t.dataTransfer.types)if(Wo&&console.log(a),a==="text/uri-list"){const l=t.dataTransfer.getData(a);Wo&&console.log(a,l);let c=(n=(i=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(l))==null?void 0:i.groups)==null?void 0:n.name;if(c||(c=(o=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(l))==null?void 0:r.groups)==null?void 0:o.name),Wo&&console.log(c),c){const u="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+c+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${u}`),t.preventDefault(),this.setSkybox(u);break}else if(this.isValidTextureType(l)){console.log("[Remote Skybox] Setting skybox from url: "+l),t.preventDefault(),this.setSkybox(l);break}else{console.warn(`[RemoteSkybox] Unknown url ${l}. If you want to load a skybox from a url, make sure it is a valid image url. Url must end with${this.validTextureTypes.join(", ")}.`);const u=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:t,url:l,apply:d=>{t.preventDefault(),this.setSkybox(d)}}});this.dispatchEvent(u)}}else if(a=="Files"){const l=t.dataTransfer.files.item(0);if(Wo&&console.log(a,l),!l)continue;if(!this.isValidTextureType(l.name)){console.warn(`[RemoteSkybox]: File "${l.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(rk(l.name)===null){const c=new Blob([l]),u=URL.createObjectURL(c);t.preventDefault(),this.setSkybox(u,l.name)}else t.preventDefault(),this.setSkybox(l.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var t;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,zi.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(t=this.context.mainCameraComponent)==null||t.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(t,i){var o;if(!this.activeAndEnabled||!t)return!1;if(i??(i=t),this.isValidTextureType(i)||console.warn("Potentially invalid skybox url",i,"on",this.name),Wo&&console.log("Remote skybox url?: "+t),this._prevUrl===t&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(o=this._prevLoadedEnvironment)==null||o.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=t;const n=await this.loadTexture(t,i);if(!n||!this.enabled)return!1;this.url=t;const r=t.lastIndexOf("/");return n.name=t.substring(r>=0?r+1:0),this._loader instanceof ml&&(n.colorSpace=vt),this._prevLoadedEnvironment=n,this.applySkybox(),!0}async loadTexture(t,i){var c,u,d,f,p;if(!t)return Promise.resolve(null);i??(i=t);const n=rk(i);if(n){const m=await n;if(((u=(c=m.source)==null?void 0:c.data)==null?void 0:u.length)>0||(p=(f=(d=m.source)==null?void 0:d.data)==null?void 0:f.data)!=null&&p.length)return m}const r=i.endsWith(".exr"),o=i.endsWith(".hdr");r?this._loader instanceof Vb||(this._loader=new Vb):o?this._loader instanceof bM||(this._loader=new bM):this._loader instanceof ml||(this._loader=new ml),Wo&&console.log("Loading skybox: "+t);const a=this._loader.loadAsync(t);return jle(i,a),await a}applySkybox(){var i;const t=this._prevLoadedEnvironment;t&&(t.mapping=Tp,t.needsUpdate=!0,this.context.scene.background!==t&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==t&&(this._prevEnvironment=this.context.scene.environment),Wo&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=t),this.background&&!zi.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((i=this.context.mainCameraComponent)==null?void 0:i.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(t){return t.startsWith("http://")||t.startsWith("https://")}isValidTextureType(t){for(const i of this.validTextureTypes)if(t.endsWith(i))return!0;return!1}registerDropEvents(){this.unregisterDropEvents(),this.context.domElement.addEventListener("dragover",this.onDragOverEvent),this.context.domElement.addEventListener("drop",this.onDrop)}unregisterDropEvents(){this.context.domElement.removeEventListener("dragover",this.onDragOverEvent),this.context.domElement.removeEventListener("drop",this.onDrop)}}_y([BR(bl.prototype.urlChangedSyncField),x(URL)],bl.prototype,"url",2);_y([x()],bl.prototype,"allowDrop",2);_y([x()],bl.prototype,"background",2);_y([x()],bl.prototype,"environment",2);_y([x()],bl.prototype,"allowNetworking",2);var qle=Object.defineProperty,Xle=Object.getOwnPropertyDescriptor,Do=(s,e,t,i)=>{for(var n=i>1?void 0:i?Xle(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&qle(e,t,n),n};const co=ne("debugsceneswitcher"),ib="scene";wP(ib);const sh=Promise.resolve(!1);class hr extends Me{constructor(){super(...arguments);h(this,"autoLoadFirstScene",!0);h(this,"scenes");h(this,"loadingScene");h(this,"queryParameterName","scene");h(this,"useSceneName",!0);h(this,"clamp",!0);h(this,"useHistory",!0);h(this,"useKeyboard",!0);h(this,"useSwipe",!0);h(this,"useSceneLighting",!0);h(this,"preloadNext",1);h(this,"preloadPrevious",1);h(this,"preloadConcurrent",2);h(this,"_currentIndex",-1);h(this,"_currentScene");h(this,"_engineElementOverserver");h(this,"_preloadScheduler");h(this,"onPopState",async t=>{if(!this.useHistory)return;const i=this.useHistory;try{this.useHistory=!1;let n=!1;if(this.queryParameterName&&(n=await this.tryLoadFromQueryParam()),!n){const r=t==null?void 0:t.state;if(r&&r.startsWith(this.guid)){const o=r.substr(this.guid.length+2);co&&console.log("PopState",o),await this.trySelectSceneFromValue(o)}}}finally{this.useHistory=i}});h(this,"normalizedSwipeThresholdX",.1);h(this,"_didSwipe",!1);h(this,"onInputPointerMove",t=>{if(this.useSwipe&&!this._didSwipe&&t.button===0&&t.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const i=this.context.input.getPointerPositionDelta(t.button);if(i){const n=i.x/this.context.domWidth;n>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):n<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}});h(this,"onInputPointerUp",t=>{t.button===0&&(this._didSwipe=!1)});h(this,"onInputKeyDown",t=>{if(!this.useKeyboard||!this.scenes)return;const i=t.key.toLowerCase();if(!i)return;const n=parseInt(i)-1;if(n>=0){this.trySelectSceneFromValue(n);return}switch(i){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}});h(this,"__lastSwitchScene");h(this,"__lastSwitchScenePromise");h(this,"_currentlyLoadingScene");h(this,"_lastLoadingScene");h(this,"_loadingScenePromise");h(this,"_isCurrentlyLoading",!1);h(this,"_currentLoadingProgress")}get currentIndex(){return this._currentIndex}get currentLoadingProgress(){return this._currentLoadingProgress}get currentlyLoadingScene(){return this._currentlyLoadingScene}get currentlyLoadedScene(){return this._currentScene}awake(){this.scenes===void 0&&(this.scenes=[]),co&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(en.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(en.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(en.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(t=>{for(const i of t)if(i.type==="attributes"&&i.attributeName===ib){const n=this.context.domElement.getAttribute(ib);n!==null&&this.trySelectSceneFromValue(n)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new Yle(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin(),this.autoLoadFirstScene&&this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const t=this.context.domElement.getAttribute(ib);try{(t===null||!await this.trySelectSceneFromValue(t))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var t;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(en.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(en.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(en.PointerUp,this.onInputPointerUp),(t=this._preloadScheduler)==null||t.stop()}addScene(t){if(typeof t=="string"){let i=this.context.addressables.findAssetReference(t);return i||(i=new $t(t),this.context.addressables.registerAssetReference(i)),this.scenes.push(i),i}return this.scenes.push(t),t}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(t){var n,r,o;if(co&&console.log("select",t),typeof t=="object"&&console.warn('Switching to "'+t+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof t=="string"){const a=(n=this.scenes)==null?void 0:n.find(l=>l.uri===t);if(!a){const l=$t.getOrCreate(this.sourceId??"",t,this.context);return this.switchScene(l)}if(a)t=(r=this.scenes)==null?void 0:r.indexOf(a);else return sh}if(!((o=this.scenes)!=null&&o.length))return sh;if(t<0){if(this.clamp)return sh;t=this.scenes.length-1}else if(t>=this.scenes.length){if(this.clamp)return sh;t=0}const i=this.scenes[t];return this.switchScene(i)}async switchScene(t){if(!(t instanceof $t)){const n=typeof t;return n==="string"?this.select(t):n==="number"?this.select(t):(console.warn("SceneSwitcher: Can't switch to scene",t,"of type",n),!1)}return t.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===t&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=t,this.__lastSwitchScenePromise=this.__internalSwitchScene(t),await this.__lastSwitchScenePromise)}async __internalSwitchScene(t){var n,r;if(this._currentScene){co&&console.log("UNLOAD",t.uri);const o=this.tryGetSceneEventListener(this._currentScene.asset);if(o!=null&&o.sceneClosing){const a=o.sceneClosing();a instanceof Promise&&await a}this._currentScene.unload()}this._currentScene=void 0;const i=this._currentIndex=((n=this.scenes)==null?void 0:n.indexOf(t))??-1;try{this._currentlyLoadingScene=t,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const o=new CustomEvent("loadscene-start",{detail:{scene:t,switcher:this,index:i}});this.dispatchEvent(o),await this.onStartLoading(),await t.loadAssetAsync((l,c)=>{this._currentLoadingProgress=c,this.dispatchEvent(c)}).catch(console.error),await this.onEndLoading();const a=new CustomEvent("loadscene-finished",{detail:{scene:t,switcher:this,index:i}});if(this.dispatchEvent(a),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,a.defaultPrevented)return co&&console.warn("Adding loaded scene prevented:",t,a),!1;if(!t.asset)return co&&console.warn("Failed loading scene:",t),!1;if(this._currentIndex===i){if(co&&console.log("ADD",t.uri),this._currentScene=t,oe.add(t.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(t),this.useHistory&&i>=0){let u=i.toString();if(this.useSceneName&&(u=ok(t.uri)),(r=this.queryParameterName)!=null&&r.length)Sb(this.queryParameterName,u,this.useHistory);else{const d=history.state,f=this.guid+"::"+i;d!==f&&history.pushState(f,"unused",location.href)}}const l=this.tryGetSceneEventListener(t.asset);if(l!=null&&l.sceneOpened){const u=l.sceneOpened(this);u instanceof Promise&&await u}const c=new CustomEvent("scene-opened",{detail:{scene:t,switcher:this,index:i}});return this.dispatchEvent(c),!0}}catch(o){console.error(o)}return!1}preload(t){if(t>=0&&t<this.scenes.length){const i=this.scenes[t];if(i instanceof $t)return i.preload()}return sh}tryLoadFromQueryParam(){var i;if(!((i=this.queryParameterName)!=null&&i.length))return sh;const t=ne(this.queryParameterName);return typeof t=="boolean"?sh:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(t){if(typeof t=="string"){const i=parseInt(t);if(i>=0&&i<this.scenes.length)return this.select(i);{const n=t.toLowerCase();for(let r=0;r<this.scenes.length;r++){const o=this.scenes[r];if(o&&ok(o.uri).toLowerCase().includes(n))return this.select(r)}}}else if(typeof t=="number"&&t>=0&&t<this.scenes.length)return this.select(t);return xo()&&console.warn('Can not find scene: "'+t+'"',this),sh}async onStartLoading(){var t,i;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(t=this.loadingScene)==null?void 0:t.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&((i=this.loadingScene)!=null&&i.asset))){co&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const n=this.loadingScene.asset;oe.add(n,this.gameObject);const r=this.tryGetSceneEventListener(n);if(r!=null&&r.sceneOpened){const o=r.sceneOpened(this);o instanceof Promise&&await o}}if(this._isCurrentlyLoading){const n=this.tryGetSceneEventListener(this.gameObject);if(n&&n.sceneOpened){const r=n.sceneOpened(this);r instanceof Promise&&await r}}}async onEndLoading(){var t;if(this._isCurrentlyLoading=!1,(t=this.loadingScene)!=null&&t.asset){co&&console.log("Remove loading scene",this.loadingScene.uri);const i=this.loadingScene.asset,n=this.tryGetSceneEventListener(i);if(typeof(n==null?void 0:n.sceneClosing)=="function"){const r=n.sceneClosing();r instanceof Promise&&await r}oe.remove(i)}if(!this._isCurrentlyLoading){const i=this.tryGetSceneEventListener(this.gameObject);if(i&&i.sceneClosing){const n=i.sceneClosing();n instanceof Promise&&await n}}}tryGetSceneEventListener(t,i=0){const n=oe.foreachComponent(t,r=>r.sceneClosing?r:void 0);if(i===0&&!n&&t.children.length)for(const r of t.children){const o=this.tryGetSceneEventListener(r,i+1);if(o)return o}return n||null}}Do([x()],hr.prototype,"autoLoadFirstScene",2);Do([x($t)],hr.prototype,"scenes",2);Do([x($t)],hr.prototype,"loadingScene",2);Do([x()],hr.prototype,"queryParameterName",2);Do([x()],hr.prototype,"useSceneName",2);Do([x()],hr.prototype,"clamp",2);Do([x()],hr.prototype,"useHistory",2);Do([x()],hr.prototype,"useKeyboard",2);Do([x()],hr.prototype,"useSwipe",2);Do([x()],hr.prototype,"useSceneLighting",2);Do([x()],hr.prototype,"preloadNext",2);Do([x()],hr.prototype,"preloadPrevious",2);Do([x()],hr.prototype,"preloadConcurrent",2);function ok(s){const e=s.split("/").pop(),t=e==null?void 0:e.split(".").shift();return t!=null&&t.length?t:s}class Yle{constructor(e,t=1,i=1,n=2){h(this,"maxLoadAhead");h(this,"maxLoadBehind");h(this,"maxConcurrent");h(this,"_isRunning",!1);h(this,"_switcher");h(this,"_loadTasks",[]);h(this,"_maxConcurrentLoads",1);this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=i,this.maxConcurrent=n}begin(){if(this._isRunning)return;co&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,i;const n=this._switcher.scenes,r=setInterval(()=>{if(this.allLoaded()&&(co&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(r);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,i=0,t=0);const o=i%2===0;o&&(t+=1),i+=1;const a=o?this.maxLoadAhead:this.maxLoadBehind;if(t>a)return;const l=o?e+t:e-t;if(l<0||l<0||l>=n.length)return;const c=n[l];new Jle(l,c,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){if(this._switcher.scenes){for(const e of this._switcher.scenes)if((e==null?void 0:e.isLoaded())===!1)return!1}return!0}}class Jle{constructor(e,t,i){h(this,"index");h(this,"asset");h(this,"tasks");this.index=e,this.asset=t,this.tasks=i,i.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(co&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),co&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function Kle(){return new Promise((s,e)=>{const i=()=>{i!=null&&(document.removeEventListener("pointerdown",i),document.removeEventListener("click",i),document.removeEventListener("dragstart",i),document.removeEventListener("touchstart",i),s())};document.addEventListener("pointerdown",i),document.addEventListener("click",i),document.addEventListener("dragstart",i),document.addEventListener("touchstart",i)})}async function Zle(s){await Kle(),s()}var $le=Object.defineProperty,ece=Object.getOwnPropertyDescriptor,Oo=(s,e,t,i)=>{for(var n=i>1?void 0:i?ece(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&$le(e,t,n),n};const as=ne("debugvideo");var $G=(s=>(s[s.None=0]="None",s[s.AdjustHeight=1]="AdjustHeight",s[s.AdjustWidth=2]="AdjustWidth",s))($G||{}),eH=(s=>(s[s.VideoClip=0]="VideoClip",s[s.Url=1]="Url",s))(eH||{}),tH=(s=>(s[s.CameraFarPlane=0]="CameraFarPlane",s[s.CameraNearPlane=1]="CameraNearPlane",s[s.RenderTexture=2]="RenderTexture",s[s.MaterialOverride=3]="MaterialOverride",s))(tH||{});class ns extends Me{constructor(){super();h(this,"playOnAwake",!0);h(this,"aspectMode",0);h(this,"clip",null);h(this,"source",1);h(this,"_url",null);h(this,"renderMode");h(this,"targetMaterialProperty");h(this,"targetMaterialRenderer");h(this,"targetTexture");h(this,"time",0);h(this,"_playbackSpeed",1);h(this,"_isLooping",!1);h(this,"_muted",!1);h(this,"_audioOutputMode",2);h(this,"playInBackground",!0);h(this,"_crossOrigin","anonymous");h(this,"_videoElement",null);h(this,"_videoTexture",null);h(this,"_videoMaterial",null);h(this,"_isPlaying",!1);h(this,"wasPlaying",!1);h(this,"visibilityChanged",t=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}});h(this,"_receivedInput",!1);h(this,"_overlay",null);h(this,"_targetObjects");h(this,"_updateAspectRoutineId",-1);h(this,"_hls");h(this,"onHlsAvailable",()=>{var t;as&&console.log("HLS: available",this.clip),!(!this.shouldUseM3U||!this.url)&&(this._hls||(this._hls=new Hls),this.videoElement.autoplay=!0,this._hls.loadSource(this.url),this._hls.attachMedia(this.videoElement),(t=this._videoElement)==null||t.play(),as&&console.log("HLS: loaded",this.clip))});Zle(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],ne("videoscreenspace")&&window.addEventListener("keydown",t=>{t.key==="f"&&(this.screenspace=!this.screenspace)})}get url(){return this._url}set url(t){const n=this._url!==t;this.__didAwake?n&&this.setClipURL(t??""):this._url=t}get playbackSpeed(){var t;return((t=this._videoElement)==null?void 0:t.playbackRate)??this._playbackSpeed}set playbackSpeed(t){this._playbackSpeed=t,this._videoElement&&(this._videoElement.playbackRate=t)}get isLooping(){var t;return((t=this._videoElement)==null?void 0:t.loop)??this._isLooping}set isLooping(t){this._isLooping=t,this._videoElement&&(this._videoElement.loop=t)}get currentTime(){var t;return((t=this._videoElement)==null?void 0:t.currentTime)??this.time}set currentTime(t){this._videoElement?this._videoElement.currentTime=t:this.time=t}get isPlaying(){const t=this._videoElement;if(t){if(t.currentTime>0&&!t.paused&&!t.ended&&t.readyState>t.HAVE_CURRENT_DATA)return!0;if(t.srcObject&&t.srcObject.active)return!0}return!1}get crossOrigin(){var t;return((t=this._videoElement)==null?void 0:t.crossOrigin)??this._crossOrigin}set crossOrigin(t){this._crossOrigin=t,this._videoElement&&(t!==null?this._videoElement.setAttribute("crossorigin",t):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return!this._videoMaterial&&!this.create(!1)?null:this._videoMaterial}get videoTexture(){return!this._videoTexture&&!this.create(!1)?null:this._videoTexture}get videoElement(){return!this._videoElement&&!this.create(!1)?null:this._videoElement}get muted(){var t;return((t=this._videoElement)==null?void 0:t.muted)??this._muted}set muted(t){this._muted=t,this._videoElement&&(this._videoElement.muted=t)}get currentVideo(){return this.clip}set audioOutputMode(t){t!==this._audioOutputMode&&(t===1&&gt()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=t,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){as&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(t){this.clip=t,this.source=0,this._videoElement?(this._videoElement.srcObject=t,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(t){this._url!==t&&(this._url=t,this.source=1,as&&console.log("set url",t),this._videoElement?t.endsWith(".m3u8")||t.includes(".m3u")?this.ensureM3UCanBePlayed():(this._videoElement.src=t,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var t,i;as&&console.log("VideoPlayer.onEnable",eH[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(t=this._overlay)==null||t.start():(i=this._overlay)==null||i.stop()}onDisable(){var t;window.removeEventListener("visibilitychange",this.visibilityChanged),(t=this._overlay)==null||t.stop(),this.pause()}onDestroy(){var t;this._videoElement&&((t=this.videoElement)==null||t.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var t,i;if(this._videoElement||this.create(!1),!this._videoElement){as&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((t=this._videoElement)!=null&&t.ended)&&!((i=this._videoElement)!=null&&i.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U){this.ensureM3UCanBePlayed();return}as&&console.log("Video Play()",this.clip,this._videoElement,this.time),this._videoElement.currentTime=this.time,this._videoElement.play().catch(n=>{var r;console.log(n),as&&console.error("Error playing video",n,"CODE="+n.code,(r=this.videoElement)==null?void 0:r.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),as&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),as&&console.log("STOP",this))}pause(){var t,i;this.time=((t=this._videoElement)==null?void 0:t.currentTime)??0,this._isPlaying=!1,(i=this._videoElement)==null||i.pause(),as&&console.log("PAUSE",this,this.currentTime)}create(t){let i;switch(this.source){case 0:i=this.clip;break;case 1:i=this.url,!(i!=null&&i.length)&&typeof this.clip=="string"&&(i=this.clip);break}return i?(this._videoElement||(as&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof i=="string"?(as&&console.log("Set Video src",i),this._videoElement.src=i):(as&&console.log("Set Video srcObject",i),this._videoElement.srcObject=i),this._videoTexture||(this._videoTexture=new ZF(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=vt,t&&this.handleBeginPlaying(t),as&&console.log("Video: handle playing done...",i,t),!0):(as&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var t;return((t=this._overlay)==null?void 0:t.enabled)??!1}set screenspace(t){var i;if(t){if(!this._videoTexture)return;this._overlay||(this._overlay=new tce(this.context)),this._overlay.add(this._videoTexture)}else(i=this._overlay)==null||i.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=t)}createVideoElement(){const t=document.createElement("video");return this._crossOrigin&&t.setAttribute("crossorigin",this._crossOrigin),as&&console.log("created video element",t),t}handleBeginPlaying(t){var r,o;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let i=this.gameObject;switch(this.renderMode){case 3:i=(r=this.targetMaterialRenderer)==null?void 0:r.gameObject,i||(i=(o=oe.getComponent(this.gameObject,Dn))==null?void 0:o.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!i){console.error("Missing target for video material renderer",this.name,tH[this.renderMode],this);return}const n=i.material;if(n){this._targetObjects.push(i),n!==this._videoMaterial&&(this._videoMaterial=n.clone(),i.material=this._videoMaterial);const a="map",l=this._videoMaterial;if(!this.targetMaterialProperty)l[a]=this._videoTexture;else switch(this.targetMaterialProperty){default:l[a]=this._videoTexture;break}}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),t&&(this.shouldUseM3U&&this.ensureM3UCanBePlayed(),this.play())}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let t=!this._receivedInput||this.audioOutputMode===0;!t&&this._muted&&(t=!0),this._videoElement.muted=t,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const t=++this._updateAspectRoutineId,i=void 0,n=this.clip;for(;t===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&n===this.clip&&this._isPlaying;){if(!n||typeof n=="string")return;let r;for(const o of n.getVideoTracks()){const a=o.getSettings();if(a&&a.width&&a.height){r=a.width/a.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let o=0;o<10;o++)yield;if(!this.isPlaying)break;continue}if(i===r){yield;continue}for(const o of this._targetObjects){let a=1;if(o.parent){const l=Hi(o.parent);a=l.x/l.y}switch(this.aspectMode){case 1:o.scale.y=1/r*o.scale.x*a;break;case 2:o.scale.x=r*o.scale.y*a;break}}for(let o=0;o<3;o++)yield}}get shouldUseM3U(){return this.url!=null&&(this.url.endsWith(".m3u8")||this.url.endsWith(".m3u"))&&this.source===1}ensureM3UCanBePlayed(){if(!this.shouldUseM3U)return;let t=document.head.querySelector("script[data-hls_library]");t?globalThis.Hls?this.onHlsAvailable():t.addEventListener("load",this.onHlsAvailable):(as&&console.log("HLS: load script"),t=document.createElement("script"),t.dataset.hls_library="hls.js",t.src="https://cdn.jsdelivr.net/npm/hls.js@1",t.addEventListener("load",this.onHlsAvailable),document.head.append(t))}}Oo([x()],ns.prototype,"playOnAwake",2);Oo([x()],ns.prototype,"aspectMode",2);Oo([x(URL)],ns.prototype,"clip",2);Oo([x()],ns.prototype,"source",2);Oo([x(URL)],ns.prototype,"url",1);Oo([x()],ns.prototype,"renderMode",2);Oo([x()],ns.prototype,"targetMaterialProperty",2);Oo([x(Dn)],ns.prototype,"targetMaterialRenderer",2);Oo([x(_t)],ns.prototype,"targetTexture",2);Oo([x()],ns.prototype,"time",2);Oo([x()],ns.prototype,"playbackSpeed",1);Oo([x()],ns.prototype,"isLooping",1);Oo([x()],ns.prototype,"audioOutputMode",1);class tce{constructor(e){h(this,"context");h(this,"_videos",[]);h(this,"_screenspaceModeQuad");h(this,"_isInScreenspaceMode",!1);h(this,"_input");this.context=e,this._input=new ice(this)}get enabled(){return this._isInScreenspaceMode}set enabled(e){e?this.start():this.stop()}add(e){this._videos.indexOf(e)===-1&&this._videos.push(e)}remove(e){if(!e)return;const t=this._videos.indexOf(e);t>=0&&this._videos.splice(t,1)}start(){var n;if(this._isInScreenspaceMode||this._videos.length<0)return;const e=this._videos[this._videos.length-1];if(!e)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=LA.createPrimitive(bd.Quad,{material:new nce(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const t=this._screenspaceModeQuad;this.context.scene.add(t),this.updateScreenspaceMaterialUniforms();const i=t.material;i==null||i.reset(),(n=this._input)==null||n.enable(i)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var t;const e=(t=this._screenspaceModeQuad)==null?void 0:t.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class ice{constructor(e){h(this,"_onResizeScreenFn");h(this,"_onKeyUpFn");h(this,"_onMouseWheelFn");h(this,"context");h(this,"overlay");h(this,"_material");h(this,"_isPinching",!1);h(this,"_lastPinch",0);this.overlay=e,this.context=e.context}enable(e){this._material=e,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=n=>{n.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=n=>{this.overlay.enabled&&(e.zoom+=n.deltaY*5e-4,n.preventDefault())},{passive:!1});const t=new te;window.addEventListener("mousemove",n=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const r=new te(n.movementX,n.movementY);r.x/=this.context.domElement.clientWidth,r.y/=this.context.domElement.clientHeight,t.set(r.x,r.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",n=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(n.movementX,n.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let i=0;window.addEventListener("touchstart",n=>{if(n.touches.length<2){this.context.time.time-i<.3&&this.overlay.stop(),i=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",n=>{if(!this._isPinching||!this._material)return;const r=n.touches[0],o=n.touches[1],a=r.clientX-o.clientX,l=r.clientY-o.clientY,c=Math.sqrt(a*a+l*l);if(this._lastPinch!==0){const u=c-this._lastPinch;this._material.zoom-=u*.004}this._lastPinch=c}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class nce extends Bt{constructor(t){super();h(this,"_offset",new te);this.uniforms={map:{value:t},screenAspect:{value:1},offsetScale:{value:new Ze(0,0,1,1)}},this.vertexShader=`
6955
6955
  uniform sampler2D map;
6956
6956
  uniform float screenAspect;
6957
6957
  uniform vec4 offsetScale;
@@ -7015,7 +7015,7 @@ void main() {
7015
7015
  // be blended onto the scene.
7016
7016
  gl_FragColor = vec4(direct, max);
7017
7017
  return;
7018
- `)}}applyShadowMaterial(){if(this.targetMesh)if(this.targetMesh.material.type!=="ShadowMaterial"){const t=new Qx;t.color=this.shadowColor,t.opacity=this.shadowColor.alpha,this.applyMaterialOptions(t),this.targetMesh.material=t}else{const t=this.targetMesh.material;t.color=this.shadowColor,t.opacity=this.shadowColor.alpha,this.applyMaterialOptions(t)}}applyOccluderMaterial(){if(this.targetMesh){let t=this.targetMesh.material;if(!t){const i=new ai;this.targetMesh.material=i,t=i}t.depthWrite=!0,t.stencilWrite=!0,t.colorWrite=!1,this.gameObject.renderOrder=-100}}applyMaterialOptions(t){t&&(t.depthWrite=!1,t.stencilWrite=!1)}}iH([x()],xy.prototype,"mode",2);iH([x(wi)],xy.prototype,"shadowColor",2);var dce=Object.defineProperty,fce=Object.getOwnPropertyDescriptor,aS=(s,e,t,i)=>{for(var n=i>1?void 0:i?fce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&dce(e,t,n),n},QE;const nH=(QE=class extends Me{constructor(){super(...arguments);h(this,"target",null);h(this,"followFactor",.1);h(this,"rotateFactor",.1);h(this,"positionAxes",ap.All);h(this,"flipForward",!1);h(this,"_firstUpdate",!0)}onBeforeRender(){this.updateNow(!1)}updateNow(e){if(!(!this.target||this.target===this.gameObject)){if(this.followFactor>0){const t=Nt(this.target),i=this._firstUpdate||e?1:et.clamp01(this.context.time.deltaTime*this.followFactor),n=this.worldPosition;this.positionAxes&ap.X&&(n.x=et.lerp(n.x,t.x,i)),this.positionAxes&ap.Y&&(n.y=et.lerp(n.y,t.y,i)),this.positionAxes&ap.Z&&(n.z=et.lerp(n.z,t.z,i)),this.worldPosition=n}if(this.rotateFactor>0){const t=Ii(this.target);this.flipForward&&t.premultiply(nH._invertForward);const i=this._firstUpdate||e?1:et.clamp01(this.context.time.deltaTime*this.rotateFactor);this.worldQuaternion=this.worldQuaternion.slerp(t,i)}this._firstUpdate=!1}}},h(QE,"_invertForward",new Ce().setFromAxisAngle(new w(0,1,0),Math.PI)),QE);let su=nH;aS([x(me)],su.prototype,"target",2);aS([x()],su.prototype,"followFactor",2);aS([x()],su.prototype,"rotateFactor",2);aS([x()],su.prototype,"positionAxes",2);class pce extends de{constructor(e){const t=new mce(e),i=new Gn(t.image.width*.001,t.image.height*.001),n=new ai({map:t,toneMapped:!1,transparent:!0});super(i,n);function r(o){n.map.dispatchDOMEvent(o)}this.addEventListener("mousedown",r),this.addEventListener("mousemove",r),this.addEventListener("mouseup",r),this.addEventListener("click",r),this.dispose=function(){i.dispose(),n.dispose(),n.map.dispose(),ZM.delete(e),this.removeEventListener("mousedown",r),this.removeEventListener("mousemove",r),this.removeEventListener("mouseup",r),this.removeEventListener("click",r)}}}class mce extends FT{constructor(e){super(ak(e)),this.dom=e,this.anisotropy=16,this.colorSpace=vt,this.minFilter=It,this.magFilter=It;const t=new MutationObserver(()=>{this.scheduleUpdate||(this.scheduleUpdate=setTimeout(()=>this.update(),16))}),i={attributes:!0,childList:!0,subtree:!0,characterData:!0};t.observe(e,i),this.observer=t}dispatchDOMEvent(e){e.data&&gce(this.dom,e.type,e.data.x,e.data.y)}update(){this.image=ak(this.dom),this.needsUpdate=!0,this.scheduleUpdate=null}dispose(){this.observer&&this.observer.disconnect(),this.scheduleUpdate=clearTimeout(this.scheduleUpdate),super.dispose()}}const ZM=new WeakMap;function ak(s){const e=document.createRange(),t=new xe;function i(f){const p=[];let m=!1;function A(){if(m&&(m=!1,f.restore()),p.length===0)return;let g=-1/0,v=-1/0,_=1/0,y=1/0;for(let b=0;b<p.length;b++){const M=p[b];g=Math.max(g,M.x),v=Math.max(v,M.y),_=Math.min(_,M.x+M.width),y=Math.min(y,M.y+M.height)}f.save(),f.beginPath(),f.rect(g,v,_-g,y-v),f.clip(),m=!0}return{add:function(g){p.push(g),A()},remove:function(){p.pop(),A()}}}function n(f,p,m,A){A!==""&&(f.textTransform==="uppercase"&&(A=A.toUpperCase()),u.font=f.fontWeight+" "+f.fontSize+" "+f.fontFamily,u.textBaseline="top",u.fillStyle=f.color,u.fillText(A,p,m+parseFloat(f.fontSize)*.1))}function r(f,p,m,A,g){m<2*g&&(g=m/2),A<2*g&&(g=A/2),u.beginPath(),u.moveTo(f+g,p),u.arcTo(f+m,p,f+m,p+A,g),u.arcTo(f+m,p+A,f,p+A,g),u.arcTo(f,p+A,f,p,g),u.arcTo(f,p,f+m,p,g),u.closePath()}function o(f,p,m,A,g,v){const _=f[p+"Width"],y=f[p+"Style"],b=f[p+"Color"];_!=="0px"&&y!=="none"&&b!=="transparent"&&b!=="rgba(0, 0, 0, 0)"&&(u.strokeStyle=b,u.lineWidth=parseFloat(_),u.beginPath(),u.moveTo(m,A),u.lineTo(m+g,A+v),u.stroke())}function a(f,p){let m=0,A=0,g=0,v=0;if(f.nodeType===Node.TEXT_NODE){e.selectNode(f);const y=e.getBoundingClientRect();m=y.left-l.left-.5,A=y.top-l.top-.5,g=y.width,v=y.height,n(p,m,A,f.nodeValue.trim())}else{if(f.nodeType===Node.COMMENT_NODE)return;if(f instanceof HTMLCanvasElement){if(f.style.display==="none")return;const y=f.getBoundingClientRect();m=y.left-l.left-.5,A=y.top-l.top-.5,u.save();const b=window.devicePixelRatio;u.scale(1/b,1/b),u.drawImage(f,m,A),u.restore()}else if(f instanceof HTMLImageElement){if(f.style.display==="none")return;const y=f.getBoundingClientRect();m=y.left-l.left-.5,A=y.top-l.top-.5,g=y.width,v=y.height,u.drawImage(f,m,A,g,v)}else{if(f.style.display==="none")return;const y=f.getBoundingClientRect();m=y.left-l.left-.5,A=y.top-l.top-.5,g=y.width,v=y.height,p=window.getComputedStyle(f),r(m,A,g,v,parseFloat(p.borderRadius));const b=p.backgroundColor;b!=="transparent"&&b!=="rgba(0, 0, 0, 0)"&&(u.fillStyle=b,u.fill());const M=["borderTop","borderLeft","borderBottom","borderRight"];let E=!0,T=null;for(const C of M){if(T!==null&&(E=p[C+"Width"]===p[T+"Width"]&&p[C+"Color"]===p[T+"Color"]&&p[C+"Style"]===p[T+"Style"]),E===!1)break;T=C}if(E===!0){const C=parseFloat(p.borderTopWidth);p.borderTopWidth!=="0px"&&p.borderTopStyle!=="none"&&p.borderTopColor!=="transparent"&&p.borderTopColor!=="rgba(0, 0, 0, 0)"&&(u.strokeStyle=p.borderTopColor,u.lineWidth=C,u.stroke())}else o(p,"borderTop",m,A,g,0),o(p,"borderLeft",m,A,0,v),o(p,"borderBottom",m,A+v,g,0),o(p,"borderRight",m+g,A,0,v);if(f instanceof HTMLInputElement){let C=p.accentColor;(C===void 0||C==="auto")&&(C=p.color),t.set(C);const S=Math.sqrt(.299*t.r**2+.587*t.g**2+.114*t.b**2)<.5?"white":"#111111";if(f.type==="radio"&&(r(m,A,g,v,v),u.fillStyle="white",u.strokeStyle=C,u.lineWidth=1,u.fill(),u.stroke(),f.checked&&(r(m+2,A+2,g-4,v-4,v),u.fillStyle=C,u.strokeStyle=S,u.lineWidth=2,u.fill(),u.stroke())),f.type==="checkbox"&&(r(m,A,g,v,2),u.fillStyle=f.checked?C:"white",u.strokeStyle=f.checked?S:C,u.lineWidth=1,u.stroke(),u.fill(),f.checked)){const I=u.textAlign;u.textAlign="center";const H={color:S,fontFamily:p.fontFamily,fontSize:v+"px",fontWeight:"bold"};n(H,m+g/2,A,"✔"),u.textAlign=I}if(f.type==="range"){const[I,H,U]=["min","max","value"].map(V=>parseFloat(f[V])),D=(U-I)/(H-I)*(g-v);r(m,A+v/4,g,v/2,v/4),u.fillStyle=S,u.strokeStyle=C,u.lineWidth=1,u.fill(),u.stroke(),r(m,A+v/4,D+v/2,v/2,v/4),u.fillStyle=C,u.fill(),r(m+D,A,v,v,v/2),u.fillStyle=C,u.fill()}(f.type==="color"||f.type==="text"||f.type==="number")&&(d.add({x:m,y:A,width:g,height:v}),n(p,m+parseInt(p.paddingLeft),A+parseInt(p.paddingTop),f.value),d.remove())}}}const _=p.overflow==="auto"||p.overflow==="hidden";_&&d.add({x:m,y:A,width:g,height:v});for(let y=0;y<f.childNodes.length;y++)a(f.childNodes[y],p);_&&d.remove()}const l=s.getBoundingClientRect();let c=ZM.get(s);c===void 0&&(c=document.createElement("canvas"),c.width=l.width,c.height=l.height,ZM.set(s,c));const u=c.getContext("2d"),d=new i(u);return u.clearRect(0,0,c.width,c.height),a(s),c}function gce(s,e,t,i){const n={clientX:t*s.offsetWidth+s.offsetLeft,clientY:i*s.offsetHeight+s.offsetTop,view:s.ownerDocument.defaultView};window.dispatchEvent(new MouseEvent(e,n));const r=s.getBoundingClientRect();t=t*r.width+r.left,i=i*r.height+r.top;function o(a){if(a.nodeType!==Node.TEXT_NODE&&a.nodeType!==Node.COMMENT_NODE){const l=a.getBoundingClientRect();if(t>l.left&&t<l.right&&i>l.top&&i<l.bottom&&(a.dispatchEvent(new MouseEvent(e,n)),a instanceof HTMLInputElement&&a.type==="range"&&(e==="mousedown"||e==="click"))){const[c,u]=["min","max"].map(m=>parseFloat(a[m])),d=l.width,p=(t-l.x)/d;a.value=c+(u-c)*p,a.dispatchEvent(new InputEvent("input",{bubbles:!0}))}for(let c=0;c<a.childNodes.length;c++)o(a.childNodes[c])}}o(s)}const nb=new te,Ff={type:"",data:nb},lk=new Td;class vce extends Er{listenToPointerEvents(e,t){const i=this,n=new Td,r=e.domElement;function o(a){a.stopPropagation();const l=e.domElement.getBoundingClientRect();nb.x=(a.clientX-l.left)/l.width*2-1,nb.y=-(a.clientY-l.top)/l.height*2+1,n.setFromCamera(nb,t);const c=n.intersectObjects(i.children,!1);if(c.length>0){const u=c[0],d=u.object,f=u.uv;Ff.type=a.type,Ff.data.set(f.x,1-f.y),d.dispatchEvent(Ff)}}r.addEventListener("pointerdown",o),r.addEventListener("pointerup",o),r.addEventListener("pointermove",o),r.addEventListener("mousedown",o),r.addEventListener("mouseup",o),r.addEventListener("mousemove",o),r.addEventListener("click",o)}listenToXRControllerEvents(e){const t=this,i={move:"mousemove",select:"click",selectstart:"mousedown",selectend:"mouseup"};function n(r){const o=r.target;lk.setFromXRController(o);const a=lk.intersectObjects(t.children,!1);if(a.length>0){const l=a[0],c=l.object,u=l.uv;Ff.type=i[r.type],Ff.data.set(u.x,1-u.y),c.dispatchEvent(Ff)}}e.addEventListener("move",n),e.addEventListener("select",n),e.addEventListener("selectstart",n),e.addEventListener("selectend",n)}}var Ace=Object.defineProperty,yce=Object.getOwnPropertyDescriptor,sH=(s,e,t,i)=>{for(var n=i>1?void 0:i?yce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ace(e,t,n),n};class wy extends Me{constructor(){super(...arguments);h(this,"id",null);h(this,"keepAspect",!1);h(this,"_object",null)}onEnable(){if(this._object){this.gameObject.add(this._object);return}if(!this.id||!this.context.mainCamera)return;const t=document.getElementById(this.id);if(!t){console.warn('Could not find element with id "'+this.id+'"');return}t.style.display="block",t.style.visibility="hidden";const i=new vce;i.listenToPointerEvents(this.context.renderer,this.context.mainCamera),this.gameObject.add(i);const n=new pce(t);i.add(n),n.visible=!1;const r=n.material;r.transparent=!0,setTimeout(()=>{n.visible=!0;const o=MA(this.gameObject).clone();TA(this.gameObject,0,0,0),this.gameObject.updateMatrixWorld();const a=new Ai;a.setFromObject(i),this.setWorldRotation(o.x,o.y,o.z);const l=a.max.x-a.min.x,c=a.max.y-a.min.y;if(this.keepAspect){const d=l/c;l>c?n.scale.set(1/l,1/c/d,1):n.scale.set(1/l*d,1/c,1)}else n.scale.set(1/l,1/c,1);const u=this.gameObject.scale;n.scale.multiply(u)},1)}onDisable(){var t;(t=this._object)==null||t.removeFromParent()}}sH([x()],wy.prototype,"id",2);sH([x()],wy.prototype,"keepAspect",2);var _ce=Object.defineProperty,bce=Object.getOwnPropertyDescriptor,Sy=(s,e,t,i)=>{for(var n=i>1?void 0:i?bce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&_ce(e,t,n),n};const lv=ne("debugspatialtrigger"),ck=new sr,hk=new sr;function xce(s,e){return ck.mask=s,hk.mask=e,ck.test(hk)}class Al extends Me{constructor(){super(...arguments);h(this,"triggerMask",0);h(this,"onEnter");h(this,"onStay");h(this,"onExit");h(this,"currentIntersected",[]);h(this,"lastIntersected",[])}start(){lv&&console.log(this.name,this.triggerMask,this)}update(){this.currentIntersected.length=0;for(const t of Cy.triggers)xce(t.triggerMask,this.triggerMask)&&t.test(this.gameObject)&&this.currentIntersected.push(t);for(let t=this.lastIntersected.length-1;t>=0;t--){const i=this.lastIntersected[t];this.currentIntersected.indexOf(i)<0&&(this.onExitTrigger(i),this.lastIntersected.splice(t,1))}for(const t of this.currentIntersected)this.lastIntersected.indexOf(t)<0&&this.onEnterTrigger(t),this.onStayTrigger(t);this.lastIntersected.length=0,this.lastIntersected.push(...this.currentIntersected)}onEnterTrigger(t){var i;lv&&console.log("ENTER TRIGGER",this.name,t.name,this,t),t.raiseOnEnterEvent(this),(i=this.onEnter)==null||i.invoke(this,t)}onExitTrigger(t){var i;lv&&console.log("EXIT TRIGGER",this.name,t.name,this,t),t.raiseOnExitEvent(this),(i=this.onExit)==null||i.invoke(this,t)}onStayTrigger(t){var i;t.raiseOnStayEvent(this),(i=this.onStay)==null||i.invoke(this,t)}}Sy([x()],Al.prototype,"triggerMask",2);Sy([x($n)],Al.prototype,"onEnter",2);Sy([x($n)],Al.prototype,"onStay",2);Sy([x($n)],Al.prototype,"onExit",2);var VE;const sb=(VE=class extends Me{constructor(){super(...arguments);h(this,"triggerMask");h(this,"boxHelper")}start(){lv&&console.log(this.name,this.triggerMask,this)}onEnable(){var e;sb.triggers.push(this),this.boxHelper||(this.boxHelper=oe.addNewComponent(this.gameObject,Xo),(e=this.boxHelper)==null||e.showHelper(null,lv))}onDisable(){sb.triggers.splice(sb.triggers.indexOf(this),1)}test(e){return this.boxHelper?this.boxHelper.isInBox(e)??!1:!1}raiseOnEnterEvent(e){oe.foreachComponent(this.gameObject,t=>{t!==e&&t instanceof Al&&t.onEnterTrigger(this)},!1)}raiseOnStayEvent(e){oe.foreachComponent(this.gameObject,t=>{t!==e&&t instanceof Al&&t.onStayTrigger(this)},!1)}raiseOnExitEvent(e){oe.foreachComponent(this.gameObject,t=>{t!==e&&t instanceof Al&&t.onExitTrigger(this)},!1)}},h(VE,"triggers",[]),VE);let Cy=sb;Sy([x()],Cy.prototype,"triggerMask",2);var wce=Object.defineProperty,Sce=Object.getOwnPropertyDescriptor,Cce=(s,e,t,i)=>{for(var n=i>1?void 0:i?Sce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&wce(e,t,n),n};const po=ne("debugspectator");class lS extends Me{constructor(){super(...arguments);h(this,"cam",null);h(this,"useKeys",!0);h(this,"_mode",0);h(this,"orbit",null);h(this,"_handler");h(this,"eventSub_WebXRRequestStartEvent",null);h(this,"eventSub_WebXRStartEvent",null);h(this,"eventSub_WebXREndEvent",null);h(this,"_debug");h(this,"_networking")}get mode(){return this._mode}set mode(t){this._mode=t}get isSpectating(){var t;return((t=this._handler)==null?void 0:t.currentTarget)!==void 0}isSpectatingUser(t){var i;return((i=this.target)==null?void 0:i.userId)===t}isFollowedBy(t){var i;return(i=this.followers)==null?void 0:i.includes(t)}get followers(){return this._networking.followers}stopSpectating(){if(this.context.isInXR){this.followSelf();return}this.target=void 0}get localId(){return this.context.connection.connectionId??"local"}set target(t){var i;if(this._handler){const n=(i=this._handler.currentTarget)==null?void 0:i.userId,r=this.context.players.getPlayerView(this.localId);t===void 0||this.context.isInXR===!1&&(r==null?void 0:r.currentObject)===t.currentObject?this._handler.currentTarget!==void 0&&(this._handler.disable(),oe.setActive(this.gameObject,!1),this.orbit&&(this.orbit.enabled=!0),this._networking.onSpectatedObjectChanged(t,n)):this._handler.currentTarget!==t&&(this._handler.set(t),oe.setActive(this.gameObject,!0),this.orbit&&(this.orbit.enabled=!1),this._networking.onSpectatedObjectChanged(t,n))}}get target(){var t;return(t=this._handler)==null?void 0:t.currentTarget}requestAllFollowMe(){this._networking.onRequestFollowMe()}get isSpectatingSelf(){var t,i;return this.isSpectating&&((t=this.target)==null?void 0:t.currentObject)===((i=this.context.players.getPlayerView(this.localId))==null?void 0:i.currentObject)}awake(){if(this._debug=new Tce(this.context,this),this._networking=new Pce(this.context,this),this._networking.awake(),oe.setActive(this.gameObject,!1),this.cam=oe.getComponent(this.gameObject,zi),!this.cam){console.warn("SpectatorCamera: Spectator camera needs camera component on the same object.",this);return}!this._handler&&this.cam&&(this._handler=new Ece(this.context,this.cam,this)),this.orbit=oe.getComponent(this.context.mainCamera,Ci)}onDestroy(){var t,i;this.stopSpectating(),(t=this._handler)==null||t.destroy(),(i=this._networking)==null||i.destroy()}isSupportedPlatform(){const t=window.navigator.userAgent,i=/Windows|MacOS/.test(t),n=/Windows NT/.test(t)&&/Edg/.test(t)&&!/Win64/.test(t);return i&&!n}onBeforeXR(t){this.isSupportedPlatform()&&oe.setActive(this.gameObject,!0)}onEnterXR(t){this.isSupportedPlatform()&&(po&&console.log(this.context.mainCamera),this.context.mainCamera&&this.followSelf())}onLeaveXR(t){var i,n;this.context.removeCamera(this.cam),oe.setActive(this.gameObject,!1),this.orbit&&(this.orbit.enabled=!0),(i=this._handler)==null||i.set(void 0),(n=this._handler)==null||n.disable(),this.isSpectatingSelf&&this.stopSpectating()}followSelf(){this.target=this.context.players.getPlayerView(this.context.connection.connectionId),this.target||(this.context.players.setPlayerView(this.localId,this.context.mainCamera,Th.Headset),this.target=this.context.players.getPlayerView(this.localId)),po&&console.log("Follow self",this.target)}onAfterRender(){var u,d,f;if(!this.cam)return;const t=this.context.renderer,i=t.xr.enabled;if(!t.xr.isPresenting&&!((u=this._handler)!=null&&u.currentTarget))return;(d=this._handler)==null||d.update(this._mode);const n=t.getRenderTarget();let r=null;const o=t.state;if(!n){if(!t.state.bindFramebuffer||!o.bindXRFramebuffer)return;r=t._framebuffer,o.bindXRFramebuffer(null)}this.setAvatarFlagsBeforeRender();const a=this.context.mainCameraComponent;if(a){const p=a.backgroundColor;p&&t.setClearColor(p,p.alpha),this.cam.backgroundColor=p,this.cam.clearFlags=a.clearFlags,this.cam.nearClipPlane=a.nearClipPlane,this.cam.farClipPlane=a.farClipPlane}else t.setClearColor(new xe(1,1,1));t.setRenderTarget(null),t.xr.enabled=!1;const l=(f=this.cam)==null?void 0:f.cam;this.context.updateAspect(l);const c=t.xr.isPresenting;t.xr.isPresenting=!1,t.setSize(this.context.domWidth,this.context.domHeight),t.render(this.context.scene,l),t.xr.isPresenting=c,t.xr.enabled=i,n?t.setRenderTarget(n):o.bindXRFramebuffer&&o.bindXRFramebuffer(r),this.resetAvatarFlags()}setAvatarFlagsBeforeRender(){const t=this._mode===0;for(const i of Yn.instances)if(i.avatar&&"isLocalAvatar"in i.avatar&&"flags"in i.avatar){let n=nl.All;this.isSpectatingSelf&&(n=t&&i.avatar.isLocalAvatar?nl.FirstPerson:nl.ThirdPerson);const r=i.avatar.flags;if(!r)continue;for(const o of r)o.UpdateVisible(n)}}resetAvatarFlags(){var t;for(const i of Yn.instances)if(i.avatar&&"flags"in i.avatar){const n=i.avatar.flags;if(!n)continue;for(const r of n)"isLocalAvatar"in i.avatar&&((t=i.avatar)!=null&&t.isLocalAvatar)?r.UpdateVisible(nl.FirstPerson):r.UpdateVisible(nl.ThirdPerson)}}}Cce([x()],lS.prototype,"useKeys",2);class Ece{constructor(e,t,i){h(this,"context");h(this,"cam");h(this,"spectator");h(this,"follow");h(this,"target");h(this,"view");h(this,"currentObject");this.context=e,this.cam=t,this.spectator=i}get currentTarget(){return this.view}set(e){const t=e==null?void 0:e.currentObject;if(!t){this.spectator.stopSpectating();return}t!==this.currentObject&&(this.currentObject=t,this.view=e,this.follow||(this.follow=oe.addNewComponent(this.cam.gameObject,su)),this.target||(this.target=new me),t.add(this.target),this.follow.enabled=!0,this.follow.target=this.target,po&&console.log("FOLLOW",t),this.context.isInXR?this.context.removeCamera(this.cam):this.context.setCurrentCamera(this.cam))}disable(){po&&console.log("STOP FOLLOW",this.currentObject),this.view=void 0,this.currentObject=void 0,this.context.removeCamera(this.cam),this.follow&&(this.follow.enabled=!1)}destroy(){var e;(e=this.target)==null||e.removeFromParent(),this.follow&&oe.destroy(this.follow)}update(e){var n,r,o,a,l,c;if(((n=this.currentTarget)==null?void 0:n.isConnected)===!1||((r=this.currentTarget)==null?void 0:r.removed)===!0){po&&console.log("Target disconnected or timeout",this.currentTarget),this.spectator.stopSpectating();return}this.currentTarget&&((o=this.currentTarget)==null?void 0:o.currentObject)!==this.currentObject&&(po&&console.log("Target changed",this.currentObject,"to",this.currentTarget.currentObject),this.set(this.currentTarget));const t=this.context.mainCamera;t&&(this.cam.cam.near!==t.near||this.cam.cam.far!==t.far)&&(this.cam.cam.near=t.near,this.cam.cam.far=t.far,this.cam.cam.updateProjectionMatrix());const i=(a=this.follow)==null?void 0:a.target;if(!(!i||!this.follow)){switch(e){case 0:((l=this.view)==null?void 0:l.viewDevice)!==Th.Browser?(this.follow.followFactor=5,this.follow.rotateFactor=5):(this.follow.followFactor=50,this.follow.rotateFactor=50),i.position.set(0,0,0);break;case 1:this.follow.followFactor=3,this.follow.rotateFactor=2,i.position.set(0,.5,1.5);break}this.follow.flipForward=!1,((c=this.view)==null?void 0:c.viewDevice)!==Th.Browser?i.quaternion.copy(Mce):i.quaternion.identity()}}}const Mce=new Ce().setFromAxisAngle(new w(0,1,0),Math.PI);class Tce{constructor(e,t){h(this,"context");h(this,"spectator");this.context=e,this.spectator=t,console.log("Click other avatars or cameras to follow them. Press ESC to exit spectator mode."),this.context.domElement.addEventListener("keydown",n=>{if(!this.spectator.useKeys)return;n.key==="Escape"&&this.spectator.stopSpectating()});let i=0;this.context.input.addEventListener(en.PointerDown,n=>{i=this.context.time.time}),this.context.input.addEventListener(en.PointerUp,n=>{const r=this.context.time.time-i;r>1?this.spectator.stopSpectating():this.context.input.getPointerClicked(0)&&r<.3&&this.trySelectObject()})}trySelectObject(){const e=new ia;e.setMask(16777215);const t=this.context.physics.raycast(e);if(po&&console.log(...t),t!=null&&t.length)for(const i of t){if(i.distance<.2)continue;const n=i.object,r=oe.getComponentInParent(n,Yn),o=r==null?void 0:r.connectionId;if(o){const a=this.context.players.getPlayerView(o);this.spectator.target=a,po&&console.log("spectate",o,r);break}}}}class Ice{constructor(e,t,i){h(this,"guid");h(this,"dontSave",!0);h(this,"targetUserId");h(this,"stoppedFollowing");this.guid=e,this.targetUserId=t,this.stoppedFollowing=i}}class Rce{constructor(e,t){h(this,"guid");h(this,"userId");this.guid=e.guid,this.userId=t}}class Pce{constructor(e,t){h(this,"followers",[]);h(this,"context");h(this,"spectator");h(this,"_followerEventMethod");h(this,"_requestFollowMethod");h(this,"_joinedRoomMethod");h(this,"_lastRequestFollowUser");h(this,"_enforceFollowInterval");this.context=e,this.spectator=t,this._followerEventMethod=this.onFollowerEvent.bind(this),this._requestFollowMethod=this.onRequestFollowEvent.bind(this),this._joinedRoomMethod=this.onUserJoinedRoom.bind(this)}awake(){this.context.connection.beginListen("spectator-follower-changed",this._followerEventMethod),this.context.connection.beginListen("spectator-request-follow",this._requestFollowMethod),this.context.connection.beginListen(ii.JoinedRoom,this._joinedRoomMethod),this.context.domElement.addEventListener("keydown",e=>{this.spectator.useKeys&&(e.key==="f"?this.onRequestFollowMe():e.key==="Escape"&&this.onRequestFollowMe(!0))})}destroy(){this.context.connection.stopListen("spectator-follower-changed",this._followerEventMethod),this.context.connection.stopListen("spectator-request-follow",this._requestFollowMethod),this.context.connection.stopListen(ii.JoinedRoom,this._joinedRoomMethod)}onSpectatedObjectChanged(e,t){if(po&&console.log(this.context.connection.connectionId,"onSpectatedObjectChanged",e,t),this.context.connection.connectionId){const i=(e==null?void 0:e.userId)===void 0,n=i?t:e==null?void 0:e.userId,r=new Ice(this.context.connection.connectionId,n,i);this.context.connection.send("spectator-follower-changed",r)}}onRequestFollowMe(e=!1){if(po&&console.log("Request follow",this.context.connection.connectionId),this.context.connection.connectionId){this.spectator.stopSpectating();const t=e?void 0:this.context.connection.connectionId,i=new Rce(this.spectator,t);this.context.connection.send("spectator-request-follow",i)}}onUserJoinedRoom(){ne("followme")&&this.onRequestFollowMe()}onFollowerEvent(e){const t=e.targetUserId,i=e.guid;if(po&&console.log(e),t===this.context.connection.connectionId)if(e.stoppedFollowing){const n=this.followers.indexOf(i);n!==-1&&(this.followers.splice(n,1),this.removeDisconnectedFollowers(),console.log(i,"unfollows you",this.followers.length))}else this.followers.includes(i)||(this.followers.push(i),this.removeDisconnectedFollowers(),console.log(i,"follows you",this.followers.length))}removeDisconnectedFollowers(){for(let e=this.followers.length-1;e>=0;e--){const t=this.followers[e];this.context.connection.userIsInRoom(t)===!1&&this.followers.splice(e,1)}}onRequestFollowEvent(e){if(this._lastRequestFollowUser=e,e.userId===this.context.connection.connectionId)this.spectator.stopSpectating();else if(e.userId===void 0)this.spectator.stopSpectating();else{const t=this.context.players.getPlayerView(e.userId);if(t)this.spectator.target=t;else return po&&console.warn("Could not find view",e.userId),this.enforceFollow(),!1}return!0}enforceFollow(){this._enforceFollowInterval||(this._enforceFollowInterval=setInterval(()=>{this._lastRequestFollowUser===void 0||this._lastRequestFollowUser.userId&&this.spectator.isFollowedBy(this._lastRequestFollowUser.userId)?(clearInterval(this._enforceFollowInterval),this._enforceFollowInterval=void 0):(po&&console.log("REQUEST FOLLOW AGAIN",this._lastRequestFollowUser.userId),this.onRequestFollowEvent(this._lastRequestFollowUser))},1e3))}}var Bce=Object.defineProperty,Dce=Object.getOwnPropertyDescriptor,kr=(s,e,t,i)=>{for(var n=i>1?void 0:i?Dce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Bce(e,t,n),n};const ix=ne("debugspriterenderer"),Oce=ne("wireframe"),dx=class{static getOrCreateGeometry(e){if(e.__cached_geometry)return e.__cached_geometry;if(e.guid&&dx.cache[e.guid])return ix&&console.log("Take cached geometry for sprite",e.guid),dx.cache[e.guid];const t=new At;e.__cached_geometry=t;const i=new Float32Array(e.triangles.length*3),n=new Float32Array(e.triangles.length*2);for(let r=0;r<e.triangles.length;r+=1){const o=e.triangles[r];i[r*3]=-e.vertices[o].x,i[r*3+1]=e.vertices[o].y,i[r*3+2]=0;const a=e.uv[o];n[r*2]=a.x,n[r*2+1]=1-a.y}return t.setAttribute("position",new tt(i,3)),t.setAttribute("uv",new tt(n,2)),e.guid&&(this.cache[e.guid]=t),ix&&console.log("Built sprite geometry",e,t),t}};let cd=dx;h(cd,"cache",{});class Lc{constructor(){h(this,"guid");h(this,"texture");h(this,"triangles");h(this,"uv");h(this,"vertices");h(this,"__cached_geometry");h(this,"_mesh");h(this,"_material")}get mesh(){return this._mesh||(this._mesh=new de(cd.getOrCreateGeometry(this),this.material)),this._mesh}get material(){return this._material||(this.texture&&(this.texture.colorSpace=vt,this.texture.minFilter==zt&&this.texture.magFilter==zt&&(this.texture.anisotropy=1),this.texture.needsUpdate=!0),this._material=new ai({map:this.texture,color:16777215,side:di,transparent:!0})),this._material}getGeometry(){return cd.getOrCreateGeometry(this)}}kr([x()],Lc.prototype,"guid",2);kr([x(_t)],Lc.prototype,"texture",2);kr([tm()],Lc.prototype,"triangles",2);kr([tm()],Lc.prototype,"uv",2);kr([tm()],Lc.prototype,"vertices",2);const SE=Symbol("spriteOwner");class Ey{constructor(){h(this,"sprites")}}kr([x(Lc)],Ey.prototype,"sprites",2);class Tm{constructor(){h(this,"spriteSheet");h(this,"index",0)}update(e,t,i){if(!this.spriteSheet)return;const n=this.index;if(n<0||n>=this.spriteSheet.sprites.length)return;const r=this.spriteSheet.sprites[n],o=r==null?void 0:r.texture;if(o&&(o.colorSpace=vt,o.minFilter==zt&&o.magFilter==zt&&(o.anisotropy=1),o.needsUpdate=!0,!r.__hasLoadedProgressive)){r.__hasLoadedProgressive=!0;const a=o;Ti.assignTextureLOD(e,t,o,0).then(l=>{l instanceof _t&&(r.texture=l,(i==null?void 0:i.map)===a&&(i.map=l,i.needsUpdate=!0))})}}}kr([x(Ey)],Tm.prototype,"spriteSheet",2);kr([x()],Tm.prototype,"index",2);class Il extends Me{constructor(){super(...arguments);h(this,"drawMode",0);h(this,"size",{x:1,y:1});h(this,"color");h(this,"sharedMaterial");h(this,"transparent",!0);h(this,"cutoutThreshold",0);h(this,"castShadows",!1);h(this,"_spriteSheet");h(this,"_currentSprite")}get sprite(){return this._spriteSheet}set sprite(t){if(t!==this._spriteSheet)if(typeof t=="number"){const i=Math.floor(t);this.spriteIndex=i;return}else this._spriteSheet=t,this.updateSprite()}set spriteIndex(t){this._spriteSheet&&(this._spriteSheet.index=t,this.updateSprite())}get spriteIndex(){var t;return((t=this._spriteSheet)==null?void 0:t.index)??0}get spriteFrames(){var t,i;return((i=(t=this._spriteSheet)==null?void 0:t.spriteSheet)==null?void 0:i.sprites.length)??0}awake(){this._currentSprite=void 0,ix&&console.log("Awake",this.name,this,this.sprite)}start(){this._currentSprite?this.gameObject&&this.gameObject.add(this._currentSprite):this.updateSprite()}updateSprite(){var i,n,r;if(!this.__didAwake||!((n=(i=this.sprite)==null?void 0:i.spriteSheet)!=null&&n.sprites))return;const t=this.sprite.spriteSheet.sprites[this.spriteIndex];if(!t){ix&&console.warn("Sprite not found",this.spriteIndex,this.sprite.spriteSheet.sprites);return}if(this._currentSprite)this._currentSprite.geometry=cd.getOrCreateGeometry(t),this._currentSprite.material.map=t.texture;else{const o=new ai({color:16777215,side:di});if(!o)return;if(Oce&&(o.wireframe=!0),this.color&&(o.color||(o.color=new xe),o.color.copy(this.color),o.opacity=this.color.alpha),o.transparent=!0,t.texture&&!o.wireframe){let a=t.texture;a[SE]!==void 0&&a[SE]!==this&&this.spriteFrames>1&&(a=t.texture=a.clone()),a[SE]=this,o.map=a}this.sharedMaterial=o,this._currentSprite=new de(cd.getOrCreateGeometry(t),o),Ti.assignTextureLOD(this.context,this.sourceId,o,0)}this._currentSprite.parent!==this.gameObject&&(this.drawMode===2&&this._currentSprite.scale.set(this.size.x,this.size.y,1),this.gameObject&&this.gameObject.add(this._currentSprite)),this._currentSprite&&this._currentSprite.layers.set(this.layer),this.sharedMaterial&&(this.sharedMaterial.alphaTest=this.cutoutThreshold,this.sharedMaterial.transparent=this.transparent),this._currentSprite.castShadow=this.castShadows,(r=this._spriteSheet)==null||r.update(this.context,this.sourceId,this.sharedMaterial)}}kr([x()],Il.prototype,"drawMode",2);kr([x(wi)],Il.prototype,"color",2);kr([x(Ot)],Il.prototype,"sharedMaterial",2);kr([x()],Il.prototype,"transparent",2);kr([x()],Il.prototype,"cutoutThreshold",2);kr([x()],Il.prototype,"castShadows",2);kr([x(Tm)],Il.prototype,"sprite",1);class el{constructor(){h(this,"bb",null);h(this,"bb_pos",0)}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSyncedCameraModel(e,t){return(t||new el).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSyncedCameraModel(e,t){return e.setPosition(e.position()+pR),(t||new el).__init(e.readInt32(e.position())+e.position(),e)}userId(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}guid(e){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}dontSave(){const e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}pos(e){const t=this.bb.__offset(this.bb_pos,10);return t?(e||new rd).__init(this.bb_pos+t,this.bb):null}rot(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new rd).__init(this.bb_pos+t,this.bb):null}static startSyncedCameraModel(e){e.startObject(5)}static addUserId(e,t){e.addFieldOffset(0,t,0)}static addGuid(e,t){e.addFieldOffset(1,t,0)}static addDontSave(e,t){e.addFieldInt8(2,+t,0)}static addPos(e,t){e.addFieldStruct(3,t,0)}static addRot(e,t){e.addFieldStruct(4,t,0)}static endSyncedCameraModel(e){return e.endObject()}static finishSyncedCameraModelBuffer(e,t){e.finish(t)}static finishSizePrefixedSyncedCameraModelBuffer(e,t){e.finish(t,void 0,!0)}}var Lce=Object.defineProperty,kce=Object.getOwnPropertyDescriptor,Fce=(s,e,t,i)=>{for(var n=i>1?void 0:i?kce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Lce(e,t,n),n};const nx="SCAM";gR(nx,el.getRootAsSyncedCameraModel);const no=new DA;class Uce{constructor(e,t){h(this,"userId");h(this,"guid");this.guid=t,this.userId=e}send(e,t){if(e){no.clear();const i=no.createString(this.guid),n=no.createString(this.userId);el.startSyncedCameraModel(no),el.addGuid(no,i),el.addUserId(no,n);const r=Nt(e),o=MA(e);el.addPos(no,rd.createVec3(no,r.x,r.y,r.z)),el.addRot(no,rd.createVec3(no,o.x,o.y,o.z));const a=el.endSyncedCameraModel(no);no.finish(a,nx),t.sendBinary(no.asUint8Array())}}}var WE;const $M=(WE=class extends Me{constructor(){super(...arguments);h(this,"cameraPrefab",null);h(this,"_lastWorldPosition");h(this,"_lastWorldQuaternion");h(this,"_model",null);h(this,"_needsUpdate",!0);h(this,"_lastUpdateTime",0);h(this,"remoteCams",{});h(this,"userToCamMap",{});h(this,"_camTimeoutInSeconds",10);h(this,"_receiveCallback",null)}getCameraObject(e){const t=this.userToCamMap[e];return t?this.remoteCams[t].obj:null}async awake(){this._lastWorldPosition=this.worldPosition.clone(),this._lastWorldQuaternion=this.worldQuaternion.clone(),this.cameraPrefab&&("uri"in this.cameraPrefab&&(this.cameraPrefab=await this.cameraPrefab.instantiate(this.gameObject)),this.cameraPrefab&&"isObject3D"in this.cameraPrefab&&(this.cameraPrefab.visible=!1))}onEnable(){this._receiveCallback=this.context.connection.beginListenBinary(nx,this.onReceivedRemoteCameraInfoBin.bind(this))}onDisable(){this.context.connection.stopListenBinary(nx,this._receiveCallback)}update(){for(const n in this.remoteCams){const r=this.remoteCams[n],o=this.context.time.realtimeSinceStartup-r.lastUpdate;if(!r||o>this._camTimeoutInSeconds){gt()&&console.log("Remote cam timeout",n),r!=null&&r.obj&&oe.destroy(r.obj),delete this.remoteCams[n],r&&delete this.userToCamMap[r.userId],$M.instances.push(r),this.context.players.removePlayerView(r.userId,Th.Browser);continue}}if(this.context.isInXR)return;const e=this.context.mainCamera;if(e===null){this.enabled=!1;return}if(!this.context.connection.isConnected||this.context.connection.connectionId===null)return;this._model===null&&(this._model=new Uce(this.context.connection.connectionId,this.context.connection.connectionId+"_camera"));const t=Nt(e),i=Ii(e);(t.distanceTo(this._lastWorldPosition)>.001||i.angleTo(this._lastWorldQuaternion)>.01)&&(this._needsUpdate=!0),this._lastWorldPosition.copy(t),this._lastWorldQuaternion.copy(i),!((!this._needsUpdate||this.context.time.frameCount%2!==0)&&!(this.context.time.realtimeSinceStartup-this._lastUpdateTime>this._camTimeoutInSeconds*.5))&&(this._lastUpdateTime=this.context.time.realtimeSinceStartup,this._needsUpdate=!1,this._model.send(e,this.context.connection),this.context.isInXR||this.context.players.setPlayerView(this.context.connection.connectionId,e,Th.Browser))}onReceivedRemoteCameraInfoBin(e){const t=e.guid();if(!t)return;const i=e.userId();if(!i||!this.context.connection.userIsInRoom(i)||!this.cameraPrefab)return;let n=this.remoteCams[t];if(!n)if("isObject3D"in this.cameraPrefab){const l=new Fa;l.context=this.context;const c=oe.instantiate(this.cameraPrefab,l);n=this.remoteCams[t]={obj:c,lastUpdate:this.context.time.realtimeSinceStartup,userId:i},n.obj.visible=!0,this.gameObject.add(c),this.userToCamMap[i]=t,$M.instances.push(n);const u=oe.getOrAddComponent(c,Yn);u.connectionId=i,u.avatar=c}else return;const r=n.obj;this.context.players.setPlayerView(i,r,Th.Browser),n.lastUpdate=this.context.time.realtimeSinceStartup,Ko.markDirty(r);const o=e.pos();o&&_d(r,o.x(),o.y(),o.z());const a=e.rot();a&&TA(r,a.x(),a.y(),a.z())}},h(WE,"instances",[]),WE);let cS=$M;Fce([x([me,$t])],cS.prototype,"cameraPrefab",2);var Nce=Object.defineProperty,zce=Object.getOwnPropertyDescriptor,Im=(s,e,t,i)=>{for(var n=i>1?void 0:i?zce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Nce(e,t,n),n};const CE="view",EE=ne("debugsyncedroom");class kc extends Me{constructor(){super(...arguments);h(this,"roomName");h(this,"urlParameterName","room");h(this,"joinRandomRoom",!0);h(this,"requireRoomParameter",!1);h(this,"autoRejoin",!0);h(this,"createJoinButton",!0);h(this,"_roomPrefix");h(this,"_lastJoinedRoom","");h(this,"_lastPingTime",0);h(this,"_lastRoomTime",-1);h(this,"_userWantsToBeInARoom",!1);h(this,"_roomButton");h(this,"_roomButtonIconJoin");h(this,"_roomButtonIconLeave");h(this,"updateRoomButtonState",()=>{var t,i;this._roomButton&&(this.context.connection.isInRoom?(this._roomButton.title="Leave the networked room",this._roomButton.textContent="Leave Room",(t=this._roomButtonIconJoin)==null||t.remove(),this._roomButton.prepend(this._roomButtonIconLeave)):(this._roomButton.title="Create or join a networked room",this._roomButton.textContent="Join Room",(i=this._roomButtonIconLeave)==null||i.remove(),this._roomButton.prepend(this._roomButtonIconJoin)))})}get roomPrefix(){return this._roomPrefix}get RoomPrefix(){return this._roomPrefix}awake(){EE&&console.log("Room",this.roomName,this.urlParameterName,this.joinRandomRoom,this.requireRoomParameter,this.autoRejoin),this._roomPrefix===void 0&&(this._roomPrefix=this.roomName,this.roomName="")}onEnable(){const t=ne(CE);if(t&&typeof t=="string"&&t.length>0){console.log("Join as viewer"),this.context.connection.joinRoom(t,!0);return}if((this.joinRandomRoom||ne(this.urlParameterName))&&this.tryJoinRoom(),this.createJoinButton){const i=this.createRoomButton();this.context.menu.appendChild(i)}}onDisable(){var t;(t=this._roomButton)==null||t.remove(),this.roomName&&this.roomName.length>0&&this.context.connection.leaveRoom(this.roomName)}onDestroy(){this.destroyRoomButton()}tryJoinRandomRoom(){this.setRandomRoomUrlParameter(),this.tryJoinRoom()}tryJoinRoom(t=0){t===void 0&&(t=0);let i=!1;if(this.urlParameterName){const n=ne(this.urlParameterName);if(n&&typeof n=="string"||n==="number"){i=!0;const r=LU(n);this.roomName=r}else if(this.joinRandomRoom&&(console.log("No room name found in url, generating random one"),this.setRandomRoomUrlParameter(),t<1))return this.tryJoinRoom(t+1)}else this.joinRandomRoom&&(this.roomName===null||this.roomName===void 0||this.roomName.length<=0)&&(console.log("generate room name"),this.roomName=this.generateRoomName());return this.requireRoomParameter&&!i?(EE&&console.log('No required room parameter "'+this.urlParameterName+'" in url - will not connect to networking backend.'),!1):(this.context.connection.isConnected||this.context.connection.connect(),EE&&console.log("Join "+this.roomName),this._lastJoinedRoom=this.roomName,this._roomPrefix&&(this.roomName=this._roomPrefix+this.roomName),this._userWantsToBeInARoom=!0,this.context.connection.joinRoom(this.roomName),!0)}update(){this.context.connection.isConnected&&(this.context.time.time-this._lastPingTime>3&&(this._lastPingTime=this.context.time.time,this.context.connection.sendPing()),this.context.connection.isInRoom&&(this._lastRoomTime=this.context.time.time)),this._lastRoomTime>0&&this.context.time.time-this._lastRoomTime>.3&&(this._lastRoomTime=-1,this.autoRejoin?this._userWantsToBeInARoom&&(console.log("Disconnected from networking backend - attempt reconnecting now"),this.tryJoinRoom()):gt()&&console.warn("You are not connected to a room anymore (possibly because the tab was inactive for too long and the server kicked you?)"))}get currentRoomName(){const t=ne(CE);return t||ne(this.urlParameterName)}setRandomRoomUrlParameter(){const t=bA(),i=this.generateRoomName();ne(this.urlParameterName)?t.set(this.urlParameterName,i):t.append(this.urlParameterName,i),rI(i,t)}generateRoomName(){return oI()+"_"+Math.floor(et.random(100,999))}getViewOnlyUrl(){if(this.context.connection.isConnected&&this.context.connection.currentRoomViewId){const t=window.location.search,i=new URLSearchParams(t);return i.has(this.urlParameterName)&&i.delete(this.urlParameterName),i.set(CE,this.context.connection.currentRoomViewId),window.location.origin+window.location.pathname+"?"+i.toString()}return null}createRoomButton(){if(this._roomButton)return this._roomButton;const t=document.createElement("button");return this._roomButton=t,t.classList.add("create-room-button"),t.setAttribute("priority","90"),t.onclick=()=>{this.context.connection.isInRoom?(this.urlParameterName&&Sb(this.urlParameterName,null),this.context.connection.leaveRoom(),this._userWantsToBeInARoom=!1):(this.urlParameterName&&(ne(this.urlParameterName)||(this._lastJoinedRoom?Sb(this.urlParameterName,this._lastJoinedRoom):this.setRandomRoomUrlParameter())),this.tryJoinRoom())},this._roomButtonIconJoin=fo("group"),this._roomButtonIconLeave=fo("group_off"),this.updateRoomButtonState(),this.context.connection.beginListen(ii.JoinedRoom,this.updateRoomButtonState),this.context.connection.beginListen(ii.LeftRoom,this.updateRoomButtonState),t}destroyRoomButton(){this.context.connection.stopListen(ii.JoinedRoom,this.updateRoomButtonState),this.context.connection.stopListen(ii.LeftRoom,this.updateRoomButtonState)}}Im([x()],kc.prototype,"roomName",2);Im([x()],kc.prototype,"urlParameterName",2);Im([x()],kc.prototype,"joinRandomRoom",2);Im([x()],kc.prototype,"requireRoomParameter",2);Im([x()],kc.prototype,"autoRejoin",2);Im([x()],kc.prototype,"createJoinButton",2);class hS extends Me{}function Gce(){const s=ne("testwindowcount")||0;s&&s>0&&Hce(s)}function Hce(s){if(ne("testwindow"))return null;const e=new URL(window.location.href);R1(e.searchParams,zne,1),R1(e.searchParams,"testwindow",1);const t=e.toString(),i=[];window.onbeforeunload=()=>{for(const l of i)l.close()};const n=.05,r=128;let o=0,a=0;for(let l=0;l<s;l++){o*r+r*.01>=window.innerWidth&&(a+=1,o=0);const c=o*(r*(1+n))+window.screenLeft,u=a*(r*(1+n))+window.screenTop+90+60*a;o+=1;const d=window.open(t,"test window "+l,`popup=yes width=${r} height=${r} top=${u} left=${c}`);if(!d){console.warn("Failed to open window");continue}i.push(d),d.onload=()=>{d.onbeforeunload=()=>{for(let f=0;f<i.length;f++){const p=i[f];p!==d&&p.close()}i.length=0}}}return i}class SP extends Me{awake(){Gce()}}class CP extends Me{constructor(){super(...arguments);h(this,"transformsPerFrame",10);h(this,"interval",0);h(this,"useFlatbuffers",!0);h(this,"builder",null);h(this,"models",null)}awake(){if(this.useFlatbuffers)this.context.connection.beginListenBinary(Xv,t=>{});else{this.models=[];for(let t=0;t<this.transformsPerFrame;t++)this.models.push(new rH(this.context.connection.connectionId+"_simulatedTransform_"+t,this))}}update(){if(this.context.connection.isConnected){if(this.useFlatbuffers){if(!this.context.connection.connectionId||this.context.time.frameCount%this.interval!==0)return;this.builder===null&&(this.builder=new DA(1024));const t=this.builder;for(let i=0;i<this.transformsPerFrame;i++){t.clear();const n=tG(this.context.connection.connectionId,this);this.context.connection.sendBinary(n)}}else if(this.models)for(let t=0;t<this.models.length;t++){const i=this.models[t];i.dontSave=!0,i.update(this,null),this.context.connection.send("TestSimulateUserData-"+t,i)}}}}class rH{constructor(e,t){h(this,"guid");h(this,"fast",!1);h(this,"position");h(this,"rotation");h(this,"velocity");h(this,"dontSave");this.guid=e,this.position={x:0,y:0,z:0},this.rotation={x:0,y:0,z:0,w:0},this.update(t,null)}isValid(){return this.fast!==void 0||this.position!==void 0||this.rotation!==void 0||this.velocity!==void 0}update(e,t){const i=e.worldPosition;this.position.x=i.x,this.position.y=i.y,this.position.z=i.z;const n=e.worldQuaternion;if(this.rotation.x=n.x,this.rotation.y=n.y,this.rotation.z=n.z,this.rotation.w=n.w,this.fast=!1,t){const r=t.getVelocity();this.velocity===void 0&&(this.velocity={x:0,y:0,z:0}),this.velocity.x=r.x,this.velocity.y=r.y,this.velocity.z=r.z}}}h(rH,"temp",new w);var Qce=Object.defineProperty,Vce=Object.getOwnPropertyDescriptor,Rm=(s,e,t,i)=>{for(var n=i>1?void 0:i?Vce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Qce(e,t,n),n};class Rl extends lr{constructor(){super(...arguments);h(this,"offset");h(this,"rotation");h(this,"focusArea");h(this,"feather");h(this,"kernelSize");h(this,"resolutionScale")}get typeName(){return"TiltShiftEffect"}init(){this.offset.defaultValue=0,this.rotation.defaultValue=0,this.focusArea.defaultValue=.4,this.feather.defaultValue=.3,this.kernelSize.defaultValue=wc.MEDIUM,this.resolutionScale.defaultValue=1/window.devicePixelRatio}onCreateEffect(){console.log(this);const t=new W$({kernelSize:wc.VERY_LARGE});return this.offset.onValueChanged=i=>t.offset=i,this.rotation.onValueChanged=i=>t.rotation=i,this.focusArea.onValueChanged=i=>t.focusArea=i,this.feather.onValueChanged=i=>t.feather=i,this.kernelSize.onValueChanged=i=>t.blurPass.kernelSize=i,this.resolutionScale.onValueChanged=i=>t.resolution.scale=i/window.devicePixelRatio,t}}Rm([x(kt)],Rl.prototype,"offset",2);Rm([x(kt)],Rl.prototype,"rotation",2);Rm([x(kt)],Rl.prototype,"focusArea",2);Rm([x(kt)],Rl.prototype,"feather",2);Rm([x(kt)],Rl.prototype,"kernelSize",2);Rm([x(kt)],Rl.prototype,"resolutionScale",2);aa("TiltShiftEffect",Rl);var Wce=Object.defineProperty,jce=Object.getOwnPropertyDescriptor,qce=(s,e,t,i)=>{for(var n=i>1?void 0:i?jce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Wce(e,t,n),n};class My extends lr{constructor(){super(...arguments);h(this,"mode")}get typeName(){return"ToneMapping"}get isToneMapping(){return!0}init(){this.mode||(this.mode=new kt(Wr)),this.mode.defaultValue=Wr}apply(){this.mode||this.init(),this.mode.onValueChanged=this._apply.bind(this),this._apply(this.mode.value)}_apply(t){this.context.renderer.toneMapping=this.getThreeToneMapping(t)}getThreeToneMapping(t){switch(t){case 0:return Mp;case 1:return vx;case 2:return gx;default:return Mp}}}qce([x(kt)],My.prototype,"mode",2);aa("Tonemapping",My);var Xce=Object.defineProperty,Yce=Object.getOwnPropertyDescriptor,uS=(s,e,t,i)=>{for(var n=i>1?void 0:i?Yce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Xce(e,t,n),n};class rf extends Me{constructor(){super(...arguments);h(this,"isGizmo",!1);h(this,"translationSnap",1);h(this,"rotationSnapAngle",15);h(this,"scaleSnap",.25);h(this,"control");h(this,"orbit");h(this,"onControlChangedEvent",t=>{const i=this.orbit;if(i&&(i.enabled=!t.value),t.value){const n=oe.getComponentInParent(this.gameObject,zh);n&&n.requestOwnership()}});h(this,"windowKeyDownListener",t=>{if(this.enabled&&this.control)switch(t.keyCode){case 81:this.control.setSpace(this.control.space==="local"?"world":"local");break;case 16:this.enableSnapping();break;case 87:this.control.setMode("translate");break;case 69:this.control.setMode("rotate");break;case 82:this.control.setMode("scale");break;case 187:case 107:this.control.setSize(this.control.size+.1);break;case 189:case 109:this.control.setSize(Math.max(this.control.size-.1,.1));break;case 88:this.control.showX=!this.control.showX;break;case 89:this.control.showY=!this.control.showY;break;case 90:this.control.showZ=!this.control.showZ;break;case 32:this.control.enabled=!this.control.enabled;break}});h(this,"windowKeyUpListener",t=>{if(this.enabled)switch(t.keyCode){case 16:this.disableSnapping();break}})}onEnable(){var t;this.isGizmo&&!BA||this.context.mainCamera&&(this.control||(this.control=new yK(this.context.mainCamera,this.context.renderer.domElement),this.control.visible=!0,this.control.enabled=!0,this.control.getRaycaster().layers.set(2),this.control.size=1,this.control.traverse(i=>{const n=i;if(n.layers.set(2),n){const r=n.material;r&&(r.opacity=.3)}}),this.orbit=oe.getComponentInParent(this.context.mainCamera,Ci)??void 0),this.control&&(this.context.scene.add(this.control),this.control.attach(this.gameObject),(t=this.control)==null||t.addEventListener("dragging-changed",this.onControlChangedEvent),window.addEventListener("keydown",this.windowKeyDownListener),window.addEventListener("keyup",this.windowKeyUpListener)))}onDisable(){var t,i;(t=this.control)==null||t.removeFromParent(),(i=this.control)==null||i.removeEventListener("dragging-changed",this.onControlChangedEvent),window.removeEventListener("keydown",this.windowKeyDownListener),window.removeEventListener("keyup",this.windowKeyUpListener)}enableSnapping(){this.control&&(this.control.setTranslationSnap(this.translationSnap),this.control.setRotationSnap(Kn.degToRad(this.rotationSnapAngle)),this.control.setScaleSnap(this.scaleSnap))}disableSnapping(){this.control&&(this.control.setTranslationSnap(null),this.control.setRotationSnap(null),this.control.setScaleSnap(null))}}uS([x()],rf.prototype,"isGizmo",2);uS([x()],rf.prototype,"translationSnap",2);uS([x()],rf.prototype,"rotationSnapAngle",2);uS([x()],rf.prototype,"scaleSnap",2);var Jce=Object.defineProperty,Kce=Object.getOwnPropertyDescriptor,EP=(s,e,t,i)=>{for(var n=i>1?void 0:i?Kce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Jce(e,t,n),n};class of extends lr{constructor(){super(...arguments);h(this,"color");h(this,"intensity");h(this,"center")}get typeName(){return"Vignette"}init(){this.color.defaultValue={r:0,g:0,b:0,a:1},this.intensity.defaultValue=0,this.center.defaultValue={x:.5,y:.5}}onCreateEffect(){const t=new Z3;return this.intensity.onValueChanged=i=>{t.offset=i,this.updateDarkness(t)},this.color.onValueChanged=i=>{this.updateDarkness(t)},t}updateDarkness(t){const i=this.intensity.value;t.darkness=i}}EP([x(kt)],of.prototype,"color",2);EP([x(kt)],of.prototype,"intensity",2);EP([x(kt)],of.prototype,"center",2);aa("Vignette",of);var Zce=Object.defineProperty,$ce=Object.getOwnPropertyDescriptor,ehe=(s,e,t,i)=>{for(var n=i>1?void 0:i?$ce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Zce(e,t,n),n};const rb=ne("debugarcamera");class dS extends Me{constructor(){super(...arguments);h(this,"backgroundTint",new wi(1,1,1,1));h(this,"backgroundPlane");h(this,"threeTexture");h(this,"forceTextureInitialization",function(){const t=new ai,i=new Gn,n=new or;n.add(new de(i,t));const r=new Gt;return function(a,l){t.map=l,a.render(n,r),rb&&console.warn("Force texture initialization")}}());h(this,"preRender",()=>{if(!this||!this.gameObject)return;const i=this.context.renderer.xr.getFrame();i&&(!this.threeTexture&&this.context.renderer&&(this.threeTexture=new _t,this.forceTextureInitialization(this.context.renderer,this.threeTexture)),this.backgroundPlane===void 0&&(this.backgroundPlane=ihe(this.backgroundTint)),this.backgroundPlane.parent!==this.scene&&this.scene.add(this.backgroundPlane),this.updateFromFrame(i))})}onBeforeXR(t,i){i.optionalFeatures=i.optionalFeatures||[],i.optionalFeatures.push("camera-access"),rb&&console.warn("Requesting camera-access")}onEnterXR(t){this.backgroundPlane&&(this.context.scene.add(this.backgroundPlane),this.backgroundPlane.visible=!1),this.backgroundPlane&&this.context.scene.add(this.backgroundPlane),this.context.pre_render_callbacks.push(this.preRender)}onLeaveXR(t){this.backgroundPlane&&this.backgroundPlane.removeFromParent();const i=this.context.pre_render_callbacks.indexOf(this.preRender);i>=0&&this.context.pre_render_callbacks.splice(i,1)}get background(){return this.backgroundPlane}onBeforeRender(t){this.updateFromFrame(t)}updateFromFrame(t){if(!t)return;const i=t.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(i){for(const n of i.views)if("camera"in n&&n.camera){let o=this.context.renderer.xr.getBinding();if(o||(o=new XRWebGLBinding(t.session,this.context.renderer.getContext())),o){let a=null;if("getCameraImage"in o){a=o.getCameraImage(n.camera);const l=this.context.renderer.properties.get(this.threeTexture);l.__webglTexture=a,this.backgroundPlane?(this.backgroundPlane.setTexture(this.threeTexture),this.backgroundPlane.visible=!0):rb&&console.warn("No background plane to set texture on")}}}}}}ehe([x(wi)],dS.prototype,"backgroundTint",2);const the=`
7018
+ `)}}applyShadowMaterial(){if(this.targetMesh)if(this.targetMesh.material.type!=="ShadowMaterial"){const t=new Qx;t.color=this.shadowColor,t.opacity=this.shadowColor.alpha,this.applyMaterialOptions(t),this.targetMesh.material=t}else{const t=this.targetMesh.material;t.color=this.shadowColor,t.opacity=this.shadowColor.alpha,this.applyMaterialOptions(t)}}applyOccluderMaterial(){if(this.targetMesh){let t=this.targetMesh.material;if(!t){const i=new ai;this.targetMesh.material=i,t=i}t.depthWrite=!0,t.stencilWrite=!0,t.colorWrite=!1,this.gameObject.renderOrder=-100}}applyMaterialOptions(t){t&&(t.depthWrite=!1,t.stencilWrite=!1)}}iH([x()],xy.prototype,"mode",2);iH([x(wi)],xy.prototype,"shadowColor",2);var dce=Object.defineProperty,fce=Object.getOwnPropertyDescriptor,aS=(s,e,t,i)=>{for(var n=i>1?void 0:i?fce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&dce(e,t,n),n},QE;const nH=(QE=class extends Me{constructor(){super(...arguments);h(this,"target",null);h(this,"followFactor",.1);h(this,"rotateFactor",.1);h(this,"positionAxes",ap.All);h(this,"flipForward",!1);h(this,"_firstUpdate",!0)}onBeforeRender(){this.updateNow(!1)}updateNow(e){if(!(!this.target||this.target===this.gameObject)){if(this.followFactor>0){const t=Nt(this.target),i=this._firstUpdate||e?1:et.clamp01(this.context.time.deltaTime*this.followFactor),n=this.worldPosition;this.positionAxes&ap.X&&(n.x=et.lerp(n.x,t.x,i)),this.positionAxes&ap.Y&&(n.y=et.lerp(n.y,t.y,i)),this.positionAxes&ap.Z&&(n.z=et.lerp(n.z,t.z,i)),this.worldPosition=n}if(this.rotateFactor>0){const t=Ii(this.target);this.flipForward&&t.premultiply(nH._invertForward);const i=this._firstUpdate||e?1:et.clamp01(this.context.time.deltaTime*this.rotateFactor);this.worldQuaternion=this.worldQuaternion.slerp(t,i)}this._firstUpdate=!1}}},h(QE,"_invertForward",new Ce().setFromAxisAngle(new w(0,1,0),Math.PI)),QE);let su=nH;aS([x(me)],su.prototype,"target",2);aS([x()],su.prototype,"followFactor",2);aS([x()],su.prototype,"rotateFactor",2);aS([x()],su.prototype,"positionAxes",2);class pce extends de{constructor(e){const t=new mce(e),i=new Gn(t.image.width*.001,t.image.height*.001),n=new ai({map:t,toneMapped:!1,transparent:!0});super(i,n);function r(o){n.map.dispatchDOMEvent(o)}this.addEventListener("mousedown",r),this.addEventListener("mousemove",r),this.addEventListener("mouseup",r),this.addEventListener("click",r),this.dispose=function(){i.dispose(),n.dispose(),n.map.dispose(),ZM.delete(e),this.removeEventListener("mousedown",r),this.removeEventListener("mousemove",r),this.removeEventListener("mouseup",r),this.removeEventListener("click",r)}}}class mce extends FT{constructor(e){super(ak(e)),this.dom=e,this.anisotropy=16,this.colorSpace=vt,this.minFilter=It,this.magFilter=It;const t=new MutationObserver(()=>{this.scheduleUpdate||(this.scheduleUpdate=setTimeout(()=>this.update(),16))}),i={attributes:!0,childList:!0,subtree:!0,characterData:!0};t.observe(e,i),this.observer=t}dispatchDOMEvent(e){e.data&&gce(this.dom,e.type,e.data.x,e.data.y)}update(){this.image=ak(this.dom),this.needsUpdate=!0,this.scheduleUpdate=null}dispose(){this.observer&&this.observer.disconnect(),this.scheduleUpdate=clearTimeout(this.scheduleUpdate),super.dispose()}}const ZM=new WeakMap;function ak(s){const e=document.createRange(),t=new xe;function i(f){const p=[];let m=!1;function A(){if(m&&(m=!1,f.restore()),p.length===0)return;let g=-1/0,v=-1/0,_=1/0,y=1/0;for(let b=0;b<p.length;b++){const M=p[b];g=Math.max(g,M.x),v=Math.max(v,M.y),_=Math.min(_,M.x+M.width),y=Math.min(y,M.y+M.height)}f.save(),f.beginPath(),f.rect(g,v,_-g,y-v),f.clip(),m=!0}return{add:function(g){p.push(g),A()},remove:function(){p.pop(),A()}}}function n(f,p,m,A){A!==""&&(f.textTransform==="uppercase"&&(A=A.toUpperCase()),u.font=f.fontWeight+" "+f.fontSize+" "+f.fontFamily,u.textBaseline="top",u.fillStyle=f.color,u.fillText(A,p,m+parseFloat(f.fontSize)*.1))}function r(f,p,m,A,g){m<2*g&&(g=m/2),A<2*g&&(g=A/2),u.beginPath(),u.moveTo(f+g,p),u.arcTo(f+m,p,f+m,p+A,g),u.arcTo(f+m,p+A,f,p+A,g),u.arcTo(f,p+A,f,p,g),u.arcTo(f,p,f+m,p,g),u.closePath()}function o(f,p,m,A,g,v){const _=f[p+"Width"],y=f[p+"Style"],b=f[p+"Color"];_!=="0px"&&y!=="none"&&b!=="transparent"&&b!=="rgba(0, 0, 0, 0)"&&(u.strokeStyle=b,u.lineWidth=parseFloat(_),u.beginPath(),u.moveTo(m,A),u.lineTo(m+g,A+v),u.stroke())}function a(f,p){let m=0,A=0,g=0,v=0;if(f.nodeType===Node.TEXT_NODE){e.selectNode(f);const y=e.getBoundingClientRect();m=y.left-l.left-.5,A=y.top-l.top-.5,g=y.width,v=y.height,n(p,m,A,f.nodeValue.trim())}else{if(f.nodeType===Node.COMMENT_NODE)return;if(f instanceof HTMLCanvasElement){if(f.style.display==="none")return;const y=f.getBoundingClientRect();m=y.left-l.left-.5,A=y.top-l.top-.5,u.save();const b=window.devicePixelRatio;u.scale(1/b,1/b),u.drawImage(f,m,A),u.restore()}else if(f instanceof HTMLImageElement){if(f.style.display==="none")return;const y=f.getBoundingClientRect();m=y.left-l.left-.5,A=y.top-l.top-.5,g=y.width,v=y.height,u.drawImage(f,m,A,g,v)}else{if(f.style.display==="none")return;const y=f.getBoundingClientRect();m=y.left-l.left-.5,A=y.top-l.top-.5,g=y.width,v=y.height,p=window.getComputedStyle(f),r(m,A,g,v,parseFloat(p.borderRadius));const b=p.backgroundColor;b!=="transparent"&&b!=="rgba(0, 0, 0, 0)"&&(u.fillStyle=b,u.fill());const M=["borderTop","borderLeft","borderBottom","borderRight"];let E=!0,T=null;for(const C of M){if(T!==null&&(E=p[C+"Width"]===p[T+"Width"]&&p[C+"Color"]===p[T+"Color"]&&p[C+"Style"]===p[T+"Style"]),E===!1)break;T=C}if(E===!0){const C=parseFloat(p.borderTopWidth);p.borderTopWidth!=="0px"&&p.borderTopStyle!=="none"&&p.borderTopColor!=="transparent"&&p.borderTopColor!=="rgba(0, 0, 0, 0)"&&(u.strokeStyle=p.borderTopColor,u.lineWidth=C,u.stroke())}else o(p,"borderTop",m,A,g,0),o(p,"borderLeft",m,A,0,v),o(p,"borderBottom",m,A+v,g,0),o(p,"borderRight",m+g,A,0,v);if(f instanceof HTMLInputElement){let C=p.accentColor;(C===void 0||C==="auto")&&(C=p.color),t.set(C);const S=Math.sqrt(.299*t.r**2+.587*t.g**2+.114*t.b**2)<.5?"white":"#111111";if(f.type==="radio"&&(r(m,A,g,v,v),u.fillStyle="white",u.strokeStyle=C,u.lineWidth=1,u.fill(),u.stroke(),f.checked&&(r(m+2,A+2,g-4,v-4,v),u.fillStyle=C,u.strokeStyle=S,u.lineWidth=2,u.fill(),u.stroke())),f.type==="checkbox"&&(r(m,A,g,v,2),u.fillStyle=f.checked?C:"white",u.strokeStyle=f.checked?S:C,u.lineWidth=1,u.stroke(),u.fill(),f.checked)){const I=u.textAlign;u.textAlign="center";const H={color:S,fontFamily:p.fontFamily,fontSize:v+"px",fontWeight:"bold"};n(H,m+g/2,A,"✔"),u.textAlign=I}if(f.type==="range"){const[I,H,U]=["min","max","value"].map(V=>parseFloat(f[V])),D=(U-I)/(H-I)*(g-v);r(m,A+v/4,g,v/2,v/4),u.fillStyle=S,u.strokeStyle=C,u.lineWidth=1,u.fill(),u.stroke(),r(m,A+v/4,D+v/2,v/2,v/4),u.fillStyle=C,u.fill(),r(m+D,A,v,v,v/2),u.fillStyle=C,u.fill()}(f.type==="color"||f.type==="text"||f.type==="number")&&(d.add({x:m,y:A,width:g,height:v}),n(p,m+parseInt(p.paddingLeft),A+parseInt(p.paddingTop),f.value),d.remove())}}}const _=p.overflow==="auto"||p.overflow==="hidden";_&&d.add({x:m,y:A,width:g,height:v});for(let y=0;y<f.childNodes.length;y++)a(f.childNodes[y],p);_&&d.remove()}const l=s.getBoundingClientRect();let c=ZM.get(s);c===void 0&&(c=document.createElement("canvas"),c.width=l.width,c.height=l.height,ZM.set(s,c));const u=c.getContext("2d"),d=new i(u);return u.clearRect(0,0,c.width,c.height),a(s),c}function gce(s,e,t,i){const n={clientX:t*s.offsetWidth+s.offsetLeft,clientY:i*s.offsetHeight+s.offsetTop,view:s.ownerDocument.defaultView};window.dispatchEvent(new MouseEvent(e,n));const r=s.getBoundingClientRect();t=t*r.width+r.left,i=i*r.height+r.top;function o(a){if(a.nodeType!==Node.TEXT_NODE&&a.nodeType!==Node.COMMENT_NODE){const l=a.getBoundingClientRect();if(t>l.left&&t<l.right&&i>l.top&&i<l.bottom&&(a.dispatchEvent(new MouseEvent(e,n)),a instanceof HTMLInputElement&&a.type==="range"&&(e==="mousedown"||e==="click"))){const[c,u]=["min","max"].map(m=>parseFloat(a[m])),d=l.width,p=(t-l.x)/d;a.value=c+(u-c)*p,a.dispatchEvent(new InputEvent("input",{bubbles:!0}))}for(let c=0;c<a.childNodes.length;c++)o(a.childNodes[c])}}o(s)}const nb=new te,Ff={type:"",data:nb},lk=new Td;class vce extends Er{listenToPointerEvents(e,t){const i=this,n=new Td,r=e.domElement;function o(a){a.stopPropagation();const l=e.domElement.getBoundingClientRect();nb.x=(a.clientX-l.left)/l.width*2-1,nb.y=-(a.clientY-l.top)/l.height*2+1,n.setFromCamera(nb,t);const c=n.intersectObjects(i.children,!1);if(c.length>0){const u=c[0],d=u.object,f=u.uv;Ff.type=a.type,Ff.data.set(f.x,1-f.y),d.dispatchEvent(Ff)}}r.addEventListener("pointerdown",o),r.addEventListener("pointerup",o),r.addEventListener("pointermove",o),r.addEventListener("mousedown",o),r.addEventListener("mouseup",o),r.addEventListener("mousemove",o),r.addEventListener("click",o)}listenToXRControllerEvents(e){const t=this,i={move:"mousemove",select:"click",selectstart:"mousedown",selectend:"mouseup"};function n(r){const o=r.target;lk.setFromXRController(o);const a=lk.intersectObjects(t.children,!1);if(a.length>0){const l=a[0],c=l.object,u=l.uv;Ff.type=i[r.type],Ff.data.set(u.x,1-u.y),c.dispatchEvent(Ff)}}e.addEventListener("move",n),e.addEventListener("select",n),e.addEventListener("selectstart",n),e.addEventListener("selectend",n)}}var Ace=Object.defineProperty,yce=Object.getOwnPropertyDescriptor,sH=(s,e,t,i)=>{for(var n=i>1?void 0:i?yce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ace(e,t,n),n};class wy extends Me{constructor(){super(...arguments);h(this,"id",null);h(this,"keepAspect",!1);h(this,"_object",null)}onEnable(){if(this._object){this.gameObject.add(this._object);return}if(!this.id||!this.context.mainCamera)return;const t=document.getElementById(this.id);if(!t){console.warn('Could not find element with id "'+this.id+'"');return}t.style.display="block",t.style.visibility="hidden";const i=new vce;i.listenToPointerEvents(this.context.renderer,this.context.mainCamera),this.gameObject.add(i);const n=new pce(t);i.add(n),n.visible=!1;const r=n.material;r.transparent=!0,setTimeout(()=>{n.visible=!0;const o=MA(this.gameObject).clone();TA(this.gameObject,0,0,0),this.gameObject.updateMatrixWorld();const a=new Ai;a.setFromObject(i),this.setWorldRotation(o.x,o.y,o.z);const l=a.max.x-a.min.x,c=a.max.y-a.min.y;if(this.keepAspect){const d=l/c;l>c?n.scale.set(1/l,1/c/d,1):n.scale.set(1/l*d,1/c,1)}else n.scale.set(1/l,1/c,1);const u=this.gameObject.scale;n.scale.multiply(u)},1)}onDisable(){var t;(t=this._object)==null||t.removeFromParent()}}sH([x()],wy.prototype,"id",2);sH([x()],wy.prototype,"keepAspect",2);var _ce=Object.defineProperty,bce=Object.getOwnPropertyDescriptor,Sy=(s,e,t,i)=>{for(var n=i>1?void 0:i?bce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&_ce(e,t,n),n};const lv=ne("debugspatialtrigger"),ck=new sr,hk=new sr;function xce(s,e){return ck.mask=s,hk.mask=e,ck.test(hk)}class Al extends Me{constructor(){super(...arguments);h(this,"triggerMask",0);h(this,"onEnter");h(this,"onStay");h(this,"onExit");h(this,"currentIntersected",[]);h(this,"lastIntersected",[])}start(){lv&&console.log(this.name,this.triggerMask,this)}update(){this.currentIntersected.length=0;for(const t of Cy.triggers)xce(t.triggerMask,this.triggerMask)&&t.test(this.gameObject)&&this.currentIntersected.push(t);for(let t=this.lastIntersected.length-1;t>=0;t--){const i=this.lastIntersected[t];this.currentIntersected.indexOf(i)<0&&(this.onExitTrigger(i),this.lastIntersected.splice(t,1))}for(const t of this.currentIntersected)this.lastIntersected.indexOf(t)<0&&this.onEnterTrigger(t),this.onStayTrigger(t);this.lastIntersected.length=0,this.lastIntersected.push(...this.currentIntersected)}onEnterTrigger(t){var i;lv&&console.log("ENTER TRIGGER",this.name,t.name,this,t),t.raiseOnEnterEvent(this),(i=this.onEnter)==null||i.invoke(this,t)}onExitTrigger(t){var i;lv&&console.log("EXIT TRIGGER",this.name,t.name,this,t),t.raiseOnExitEvent(this),(i=this.onExit)==null||i.invoke(this,t)}onStayTrigger(t){var i;t.raiseOnStayEvent(this),(i=this.onStay)==null||i.invoke(this,t)}}Sy([x()],Al.prototype,"triggerMask",2);Sy([x($n)],Al.prototype,"onEnter",2);Sy([x($n)],Al.prototype,"onStay",2);Sy([x($n)],Al.prototype,"onExit",2);var VE;const sb=(VE=class extends Me{constructor(){super(...arguments);h(this,"triggerMask");h(this,"boxHelper")}start(){lv&&console.log(this.name,this.triggerMask,this)}onEnable(){var e;sb.triggers.push(this),this.boxHelper||(this.boxHelper=oe.addNewComponent(this.gameObject,Xo),(e=this.boxHelper)==null||e.showHelper(null,lv))}onDisable(){sb.triggers.splice(sb.triggers.indexOf(this),1)}test(e){return this.boxHelper?this.boxHelper.isInBox(e)??!1:!1}raiseOnEnterEvent(e){oe.foreachComponent(this.gameObject,t=>{t!==e&&t instanceof Al&&t.onEnterTrigger(this)},!1)}raiseOnStayEvent(e){oe.foreachComponent(this.gameObject,t=>{t!==e&&t instanceof Al&&t.onStayTrigger(this)},!1)}raiseOnExitEvent(e){oe.foreachComponent(this.gameObject,t=>{t!==e&&t instanceof Al&&t.onExitTrigger(this)},!1)}},h(VE,"triggers",[]),VE);let Cy=sb;Sy([x()],Cy.prototype,"triggerMask",2);var wce=Object.defineProperty,Sce=Object.getOwnPropertyDescriptor,Cce=(s,e,t,i)=>{for(var n=i>1?void 0:i?Sce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&wce(e,t,n),n};const po=ne("debugspectator");class lS extends Me{constructor(){super(...arguments);h(this,"cam",null);h(this,"useKeys",!0);h(this,"_mode",0);h(this,"orbit",null);h(this,"_handler");h(this,"eventSub_WebXRRequestStartEvent",null);h(this,"eventSub_WebXRStartEvent",null);h(this,"eventSub_WebXREndEvent",null);h(this,"_debug");h(this,"_networking")}get mode(){return this._mode}set mode(t){this._mode=t}get isSpectating(){var t;return((t=this._handler)==null?void 0:t.currentTarget)!==void 0}isSpectatingUser(t){var i;return((i=this.target)==null?void 0:i.userId)===t}isFollowedBy(t){var i;return(i=this.followers)==null?void 0:i.includes(t)}get followers(){return this._networking.followers}stopSpectating(){if(this.context.isInXR){this.followSelf();return}this.target=void 0}get localId(){return this.context.connection.connectionId??"local"}set target(t){var i;if(this._handler){const n=(i=this._handler.currentTarget)==null?void 0:i.userId,r=this.context.players.getPlayerView(this.localId);t===void 0||this.context.isInXR===!1&&(r==null?void 0:r.currentObject)===t.currentObject?this._handler.currentTarget!==void 0&&(this._handler.disable(),oe.setActive(this.gameObject,!1),this.orbit&&(this.orbit.enabled=!0),this._networking.onSpectatedObjectChanged(t,n)):this._handler.currentTarget!==t&&(this._handler.set(t),oe.setActive(this.gameObject,!0),this.orbit&&(this.orbit.enabled=!1),this._networking.onSpectatedObjectChanged(t,n))}}get target(){var t;return(t=this._handler)==null?void 0:t.currentTarget}requestAllFollowMe(){this._networking.onRequestFollowMe()}get isSpectatingSelf(){var t,i;return this.isSpectating&&((t=this.target)==null?void 0:t.currentObject)===((i=this.context.players.getPlayerView(this.localId))==null?void 0:i.currentObject)}awake(){if(this._debug=new Tce(this.context,this),this._networking=new Pce(this.context,this),this._networking.awake(),oe.setActive(this.gameObject,!1),this.cam=oe.getComponent(this.gameObject,zi),!this.cam){console.warn("SpectatorCamera: Spectator camera needs camera component on the same object.",this);return}!this._handler&&this.cam&&(this._handler=new Ece(this.context,this.cam,this)),this.orbit=oe.getComponent(this.context.mainCamera,Ci)}onDestroy(){var t,i;this.stopSpectating(),(t=this._handler)==null||t.destroy(),(i=this._networking)==null||i.destroy()}isSupportedPlatform(){const t=window.navigator.userAgent,i=/Windows|MacOS/.test(t),n=/Windows NT/.test(t)&&/Edg/.test(t)&&!/Win64/.test(t);return i&&!n}onBeforeXR(t){this.isSupportedPlatform()&&oe.setActive(this.gameObject,!0)}onEnterXR(t){this.isSupportedPlatform()&&(po&&console.log(this.context.mainCamera),this.context.mainCamera&&this.followSelf())}onLeaveXR(t){var i,n;this.context.removeCamera(this.cam),oe.setActive(this.gameObject,!1),this.orbit&&(this.orbit.enabled=!0),(i=this._handler)==null||i.set(void 0),(n=this._handler)==null||n.disable(),this.isSpectatingSelf&&this.stopSpectating()}followSelf(){this.target=this.context.players.getPlayerView(this.context.connection.connectionId),this.target||(this.context.players.setPlayerView(this.localId,this.context.mainCamera,Th.Headset),this.target=this.context.players.getPlayerView(this.localId)),po&&console.log("Follow self",this.target)}onAfterRender(){var u,d,f;if(!this.cam)return;const t=this.context.renderer,i=t.xr.enabled;if(!t.xr.isPresenting&&!((u=this._handler)!=null&&u.currentTarget))return;(d=this._handler)==null||d.update(this._mode);const n=t.getRenderTarget();let r=null;const o=t.state;if(!n){if(!t.state.bindFramebuffer||!o.bindXRFramebuffer)return;r=t._framebuffer,o.bindXRFramebuffer(null)}this.setAvatarFlagsBeforeRender();const a=this.context.mainCameraComponent;if(a){const p=a.backgroundColor;p&&t.setClearColor(p,p.alpha),this.cam.backgroundColor=p,this.cam.clearFlags=a.clearFlags,this.cam.nearClipPlane=a.nearClipPlane,this.cam.farClipPlane=a.farClipPlane}else t.setClearColor(new xe(1,1,1));t.setRenderTarget(null),t.xr.enabled=!1;const l=(f=this.cam)==null?void 0:f.cam;this.context.updateAspect(l);const c=t.xr.isPresenting;t.xr.isPresenting=!1,t.setSize(this.context.domWidth,this.context.domHeight),t.render(this.context.scene,l),t.xr.isPresenting=c,t.xr.enabled=i,n?t.setRenderTarget(n):o.bindXRFramebuffer&&o.bindXRFramebuffer(r),this.resetAvatarFlags()}setAvatarFlagsBeforeRender(){const t=this._mode===0;for(const i of Yn.instances)if(i.avatar&&"isLocalAvatar"in i.avatar&&"flags"in i.avatar){let n=nl.All;this.isSpectatingSelf&&(n=t&&i.avatar.isLocalAvatar?nl.FirstPerson:nl.ThirdPerson);const r=i.avatar.flags;if(!r)continue;for(const o of r)o.UpdateVisible(n)}}resetAvatarFlags(){var t;for(const i of Yn.instances)if(i.avatar&&"flags"in i.avatar){const n=i.avatar.flags;if(!n)continue;for(const r of n)"isLocalAvatar"in i.avatar&&((t=i.avatar)!=null&&t.isLocalAvatar)?r.UpdateVisible(nl.FirstPerson):r.UpdateVisible(nl.ThirdPerson)}}}Cce([x()],lS.prototype,"useKeys",2);class Ece{constructor(e,t,i){h(this,"context");h(this,"cam");h(this,"spectator");h(this,"follow");h(this,"target");h(this,"view");h(this,"currentObject");this.context=e,this.cam=t,this.spectator=i}get currentTarget(){return this.view}set(e){const t=e==null?void 0:e.currentObject;if(!t){this.spectator.stopSpectating();return}t!==this.currentObject&&(this.currentObject=t,this.view=e,this.follow||(this.follow=oe.addNewComponent(this.cam.gameObject,su)),this.target||(this.target=new me),t.add(this.target),this.follow.enabled=!0,this.follow.target=this.target,po&&console.log("FOLLOW",t),this.context.isInXR?this.context.removeCamera(this.cam):this.context.setCurrentCamera(this.cam))}disable(){po&&console.log("STOP FOLLOW",this.currentObject),this.view=void 0,this.currentObject=void 0,this.context.removeCamera(this.cam),this.follow&&(this.follow.enabled=!1)}destroy(){var e;(e=this.target)==null||e.removeFromParent(),this.follow&&oe.destroy(this.follow)}update(e){var n,r,o,a,l,c;if(((n=this.currentTarget)==null?void 0:n.isConnected)===!1||((r=this.currentTarget)==null?void 0:r.removed)===!0){po&&console.log("Target disconnected or timeout",this.currentTarget),this.spectator.stopSpectating();return}this.currentTarget&&((o=this.currentTarget)==null?void 0:o.currentObject)!==this.currentObject&&(po&&console.log("Target changed",this.currentObject,"to",this.currentTarget.currentObject),this.set(this.currentTarget));const t=this.context.mainCamera;t&&(this.cam.cam.near!==t.near||this.cam.cam.far!==t.far)&&(this.cam.cam.near=t.near,this.cam.cam.far=t.far,this.cam.cam.updateProjectionMatrix());const i=(a=this.follow)==null?void 0:a.target;if(!(!i||!this.follow)){switch(e){case 0:((l=this.view)==null?void 0:l.viewDevice)!==Th.Browser?(this.follow.followFactor=5,this.follow.rotateFactor=5):(this.follow.followFactor=50,this.follow.rotateFactor=50),i.position.set(0,0,0);break;case 1:this.follow.followFactor=3,this.follow.rotateFactor=2,i.position.set(0,.5,1.5);break}this.follow.flipForward=!1,((c=this.view)==null?void 0:c.viewDevice)!==Th.Browser?i.quaternion.copy(Mce):i.quaternion.identity()}}}const Mce=new Ce().setFromAxisAngle(new w(0,1,0),Math.PI);class Tce{constructor(e,t){h(this,"context");h(this,"spectator");this.context=e,this.spectator=t,console.log("Click other avatars or cameras to follow them. Press ESC to exit spectator mode."),this.context.domElement.addEventListener("keydown",n=>{if(!this.spectator.useKeys)return;n.key==="Escape"&&this.spectator.stopSpectating()});let i=0;this.context.input.addEventListener(en.PointerDown,n=>{i=this.context.time.time}),this.context.input.addEventListener(en.PointerUp,n=>{const r=this.context.time.time-i;r>1?this.spectator.stopSpectating():this.context.input.getPointerClicked(0)&&r<.3&&this.trySelectObject()})}trySelectObject(){const e=new ia;e.setMask(16777215);const t=this.context.physics.raycast(e);if(po&&console.log(...t),t!=null&&t.length)for(const i of t){if(i.distance<.2)continue;const n=i.object,r=oe.getComponentInParent(n,Yn),o=r==null?void 0:r.connectionId;if(o){const a=this.context.players.getPlayerView(o);this.spectator.target=a,po&&console.log("spectate",o,r);break}}}}class Ice{constructor(e,t,i){h(this,"guid");h(this,"dontSave",!0);h(this,"targetUserId");h(this,"stoppedFollowing");this.guid=e,this.targetUserId=t,this.stoppedFollowing=i}}class Rce{constructor(e,t){h(this,"guid");h(this,"userId");this.guid=e.guid,this.userId=t}}class Pce{constructor(e,t){h(this,"followers",[]);h(this,"context");h(this,"spectator");h(this,"_followerEventMethod");h(this,"_requestFollowMethod");h(this,"_joinedRoomMethod");h(this,"_lastRequestFollowUser");h(this,"_enforceFollowInterval");this.context=e,this.spectator=t,this._followerEventMethod=this.onFollowerEvent.bind(this),this._requestFollowMethod=this.onRequestFollowEvent.bind(this),this._joinedRoomMethod=this.onUserJoinedRoom.bind(this)}awake(){this.context.connection.beginListen("spectator-follower-changed",this._followerEventMethod),this.context.connection.beginListen("spectator-request-follow",this._requestFollowMethod),this.context.connection.beginListen(ii.JoinedRoom,this._joinedRoomMethod),this.context.domElement.addEventListener("keydown",e=>{this.spectator.useKeys&&(e.key==="f"?this.onRequestFollowMe():e.key==="Escape"&&this.onRequestFollowMe(!0))})}destroy(){this.context.connection.stopListen("spectator-follower-changed",this._followerEventMethod),this.context.connection.stopListen("spectator-request-follow",this._requestFollowMethod),this.context.connection.stopListen(ii.JoinedRoom,this._joinedRoomMethod)}onSpectatedObjectChanged(e,t){if(po&&console.log(this.context.connection.connectionId,"onSpectatedObjectChanged",e,t),this.context.connection.connectionId){const i=(e==null?void 0:e.userId)===void 0,n=i?t:e==null?void 0:e.userId,r=new Ice(this.context.connection.connectionId,n,i);this.context.connection.send("spectator-follower-changed",r)}}onRequestFollowMe(e=!1){if(po&&console.log("Request follow",this.context.connection.connectionId),this.context.connection.connectionId){this.spectator.stopSpectating();const t=e?void 0:this.context.connection.connectionId,i=new Rce(this.spectator,t);this.context.connection.send("spectator-request-follow",i)}}onUserJoinedRoom(){ne("followme")&&this.onRequestFollowMe()}onFollowerEvent(e){const t=e.targetUserId,i=e.guid;if(po&&console.log(e),t===this.context.connection.connectionId)if(e.stoppedFollowing){const n=this.followers.indexOf(i);n!==-1&&(this.followers.splice(n,1),this.removeDisconnectedFollowers(),console.log(i,"unfollows you",this.followers.length))}else this.followers.includes(i)||(this.followers.push(i),this.removeDisconnectedFollowers(),console.log(i,"follows you",this.followers.length))}removeDisconnectedFollowers(){for(let e=this.followers.length-1;e>=0;e--){const t=this.followers[e];this.context.connection.userIsInRoom(t)===!1&&this.followers.splice(e,1)}}onRequestFollowEvent(e){if(this._lastRequestFollowUser=e,e.userId===this.context.connection.connectionId)this.spectator.stopSpectating();else if(e.userId===void 0)this.spectator.stopSpectating();else{const t=this.context.players.getPlayerView(e.userId);if(t)this.spectator.target=t;else return po&&console.warn("Could not find view",e.userId),this.enforceFollow(),!1}return!0}enforceFollow(){this._enforceFollowInterval||(this._enforceFollowInterval=setInterval(()=>{this._lastRequestFollowUser===void 0||this._lastRequestFollowUser.userId&&this.spectator.isFollowedBy(this._lastRequestFollowUser.userId)?(clearInterval(this._enforceFollowInterval),this._enforceFollowInterval=void 0):(po&&console.log("REQUEST FOLLOW AGAIN",this._lastRequestFollowUser.userId),this.onRequestFollowEvent(this._lastRequestFollowUser))},1e3))}}var Bce=Object.defineProperty,Dce=Object.getOwnPropertyDescriptor,kr=(s,e,t,i)=>{for(var n=i>1?void 0:i?Dce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Bce(e,t,n),n};const ix=ne("debugspriterenderer"),Oce=ne("wireframe"),dx=class{static getOrCreateGeometry(e){if(e.__cached_geometry)return e.__cached_geometry;if(e.guid&&dx.cache[e.guid])return ix&&console.log("Take cached geometry for sprite",e.guid),dx.cache[e.guid];const t=new At;e.__cached_geometry=t;const i=new Float32Array(e.triangles.length*3),n=new Float32Array(e.triangles.length*2);for(let r=0;r<e.triangles.length;r+=1){const o=e.triangles[r];i[r*3]=-e.vertices[o].x,i[r*3+1]=e.vertices[o].y,i[r*3+2]=0;const a=e.uv[o];n[r*2]=a.x,n[r*2+1]=1-a.y}return t.setAttribute("position",new tt(i,3)),t.setAttribute("uv",new tt(n,2)),e.guid&&(this.cache[e.guid]=t),ix&&console.log("Built sprite geometry",e,t),t}};let cd=dx;h(cd,"cache",{});class Lc{constructor(){h(this,"guid");h(this,"texture");h(this,"triangles");h(this,"uv");h(this,"vertices");h(this,"__cached_geometry");h(this,"_mesh");h(this,"_material")}get mesh(){return this._mesh||(this._mesh=new de(cd.getOrCreateGeometry(this),this.material)),this._mesh}get material(){return this._material||(this.texture&&(this.texture.colorSpace=vt,this.texture.minFilter==zt&&this.texture.magFilter==zt&&(this.texture.anisotropy=1),this.texture.needsUpdate=!0),this._material=new ai({map:this.texture,color:16777215,side:di,transparent:!0})),this._material}getGeometry(){return cd.getOrCreateGeometry(this)}}kr([x()],Lc.prototype,"guid",2);kr([x(_t)],Lc.prototype,"texture",2);kr([tm()],Lc.prototype,"triangles",2);kr([tm()],Lc.prototype,"uv",2);kr([tm()],Lc.prototype,"vertices",2);const SE=Symbol("spriteOwner");class Ey{constructor(){h(this,"sprites")}}kr([x(Lc)],Ey.prototype,"sprites",2);class Tm{constructor(){h(this,"spriteSheet");h(this,"index",0)}update(e,t,i){if(!this.spriteSheet)return;const n=this.index;if(n<0||n>=this.spriteSheet.sprites.length)return;const r=this.spriteSheet.sprites[n],o=r==null?void 0:r.texture;if(o&&(o.colorSpace=vt,o.minFilter==zt&&o.magFilter==zt&&(o.anisotropy=1),o.needsUpdate=!0,!r.__hasLoadedProgressive)){r.__hasLoadedProgressive=!0;const a=o;Ti.assignTextureLOD(e,t,o,0).then(l=>{l instanceof _t&&(r.texture=l,(i==null?void 0:i.map)===a&&(i.map=l,i.needsUpdate=!0))})}}}kr([x(Ey)],Tm.prototype,"spriteSheet",2);kr([x()],Tm.prototype,"index",2);class Il extends Me{constructor(){super(...arguments);h(this,"drawMode",0);h(this,"size",{x:1,y:1});h(this,"color");h(this,"sharedMaterial");h(this,"transparent",!0);h(this,"cutoutThreshold",0);h(this,"castShadows",!1);h(this,"_spriteSheet");h(this,"_currentSprite")}get sprite(){return this._spriteSheet}set sprite(t){if(t!==this._spriteSheet)if(typeof t=="number"){const i=Math.floor(t);this.spriteIndex=i;return}else this._spriteSheet=t,this.updateSprite()}set spriteIndex(t){this._spriteSheet&&(this._spriteSheet.index=t,this.updateSprite())}get spriteIndex(){var t;return((t=this._spriteSheet)==null?void 0:t.index)??0}get spriteFrames(){var t,i;return((i=(t=this._spriteSheet)==null?void 0:t.spriteSheet)==null?void 0:i.sprites.length)??0}awake(){this._currentSprite=void 0,ix&&console.log("Awake",this.name,this,this.sprite)}start(){this._currentSprite?this.gameObject&&this.gameObject.add(this._currentSprite):this.updateSprite()}updateSprite(){var i,n,r;if(!this.__didAwake||!((n=(i=this.sprite)==null?void 0:i.spriteSheet)!=null&&n.sprites))return;const t=this.sprite.spriteSheet.sprites[this.spriteIndex];if(!t){ix&&console.warn("Sprite not found",this.spriteIndex,this.sprite.spriteSheet.sprites);return}if(this._currentSprite)this._currentSprite.geometry=cd.getOrCreateGeometry(t),this._currentSprite.material.map=t.texture;else{const o=new ai({color:16777215,side:di});if(!o)return;if(Oce&&(o.wireframe=!0),this.color&&(o.color||(o.color=new xe),o.color.copy(this.color),o.opacity=this.color.alpha),o.transparent=!0,t.texture&&!o.wireframe){let a=t.texture;a[SE]!==void 0&&a[SE]!==this&&this.spriteFrames>1&&(a=t.texture=a.clone()),a[SE]=this,o.map=a}this.sharedMaterial=o,this._currentSprite=new de(cd.getOrCreateGeometry(t),o),Ti.assignTextureLOD(this.context,this.sourceId,o,0)}this._currentSprite.parent!==this.gameObject&&(this.drawMode===2&&this._currentSprite.scale.set(this.size.x,this.size.y,1),this.gameObject&&this.gameObject.add(this._currentSprite)),this._currentSprite&&this._currentSprite.layers.set(this.layer),this.sharedMaterial&&(this.sharedMaterial.alphaTest=this.cutoutThreshold,this.sharedMaterial.transparent=this.transparent),this._currentSprite.castShadow=this.castShadows,(r=this._spriteSheet)==null||r.update(this.context,this.sourceId,this.sharedMaterial)}}kr([x()],Il.prototype,"drawMode",2);kr([x(wi)],Il.prototype,"color",2);kr([x(Ot)],Il.prototype,"sharedMaterial",2);kr([x()],Il.prototype,"transparent",2);kr([x()],Il.prototype,"cutoutThreshold",2);kr([x()],Il.prototype,"castShadows",2);kr([x(Tm)],Il.prototype,"sprite",1);class el{constructor(){h(this,"bb",null);h(this,"bb_pos",0)}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSyncedCameraModel(e,t){return(t||new el).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSyncedCameraModel(e,t){return e.setPosition(e.position()+pR),(t||new el).__init(e.readInt32(e.position())+e.position(),e)}userId(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}guid(e){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}dontSave(){const e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}pos(e){const t=this.bb.__offset(this.bb_pos,10);return t?(e||new rd).__init(this.bb_pos+t,this.bb):null}rot(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new rd).__init(this.bb_pos+t,this.bb):null}static startSyncedCameraModel(e){e.startObject(5)}static addUserId(e,t){e.addFieldOffset(0,t,0)}static addGuid(e,t){e.addFieldOffset(1,t,0)}static addDontSave(e,t){e.addFieldInt8(2,+t,0)}static addPos(e,t){e.addFieldStruct(3,t,0)}static addRot(e,t){e.addFieldStruct(4,t,0)}static endSyncedCameraModel(e){return e.endObject()}static finishSyncedCameraModelBuffer(e,t){e.finish(t)}static finishSizePrefixedSyncedCameraModelBuffer(e,t){e.finish(t,void 0,!0)}}var Lce=Object.defineProperty,kce=Object.getOwnPropertyDescriptor,Fce=(s,e,t,i)=>{for(var n=i>1?void 0:i?kce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Lce(e,t,n),n};const nx="SCAM";gR(nx,el.getRootAsSyncedCameraModel);const no=new DA;class Uce{constructor(e,t){h(this,"userId");h(this,"guid");this.guid=t,this.userId=e}send(e,t){if(e){no.clear();const i=no.createString(this.guid),n=no.createString(this.userId);el.startSyncedCameraModel(no),el.addGuid(no,i),el.addUserId(no,n);const r=Nt(e),o=MA(e);el.addPos(no,rd.createVec3(no,r.x,r.y,r.z)),el.addRot(no,rd.createVec3(no,o.x,o.y,o.z));const a=el.endSyncedCameraModel(no);no.finish(a,nx),t.sendBinary(no.asUint8Array())}}}var WE;const $M=(WE=class extends Me{constructor(){super(...arguments);h(this,"cameraPrefab",null);h(this,"_lastWorldPosition");h(this,"_lastWorldQuaternion");h(this,"_model",null);h(this,"_needsUpdate",!0);h(this,"_lastUpdateTime",0);h(this,"remoteCams",{});h(this,"userToCamMap",{});h(this,"_camTimeoutInSeconds",10);h(this,"_receiveCallback",null)}getCameraObject(e){const t=this.userToCamMap[e];return t?this.remoteCams[t].obj:null}async awake(){this._lastWorldPosition=this.worldPosition.clone(),this._lastWorldQuaternion=this.worldQuaternion.clone(),this.cameraPrefab&&("uri"in this.cameraPrefab&&(this.cameraPrefab=await this.cameraPrefab.instantiate(this.gameObject)),this.cameraPrefab&&"isObject3D"in this.cameraPrefab&&(this.cameraPrefab.visible=!1))}onEnable(){this._receiveCallback=this.context.connection.beginListenBinary(nx,this.onReceivedRemoteCameraInfoBin.bind(this))}onDisable(){this.context.connection.stopListenBinary(nx,this._receiveCallback)}update(){for(const n in this.remoteCams){const r=this.remoteCams[n],o=this.context.time.realtimeSinceStartup-r.lastUpdate;if(!r||o>this._camTimeoutInSeconds){gt()&&console.log("Remote cam timeout",n),r!=null&&r.obj&&oe.destroy(r.obj),delete this.remoteCams[n],r&&delete this.userToCamMap[r.userId],$M.instances.push(r),this.context.players.removePlayerView(r.userId,Th.Browser);continue}}if(this.context.isInXR)return;const e=this.context.mainCamera;if(e===null){this.enabled=!1;return}if(!this.context.connection.isConnected||this.context.connection.connectionId===null)return;this._model===null&&(this._model=new Uce(this.context.connection.connectionId,this.context.connection.connectionId+"_camera"));const t=Nt(e),i=Ii(e);(t.distanceTo(this._lastWorldPosition)>.001||i.angleTo(this._lastWorldQuaternion)>.01)&&(this._needsUpdate=!0),this._lastWorldPosition.copy(t),this._lastWorldQuaternion.copy(i),!((!this._needsUpdate||this.context.time.frameCount%2!==0)&&!(this.context.time.realtimeSinceStartup-this._lastUpdateTime>this._camTimeoutInSeconds*.5))&&(this._lastUpdateTime=this.context.time.realtimeSinceStartup,this._needsUpdate=!1,this._model.send(e,this.context.connection),this.context.isInXR||this.context.players.setPlayerView(this.context.connection.connectionId,e,Th.Browser))}onReceivedRemoteCameraInfoBin(e){const t=e.guid();if(!t)return;const i=e.userId();if(!i||!this.context.connection.userIsInRoom(i)||!this.cameraPrefab)return;let n=this.remoteCams[t];if(!n)if("isObject3D"in this.cameraPrefab){const l=new Fa;l.context=this.context;const c=oe.instantiate(this.cameraPrefab,l);n=this.remoteCams[t]={obj:c,lastUpdate:this.context.time.realtimeSinceStartup,userId:i},n.obj.visible=!0,this.gameObject.add(c),this.userToCamMap[i]=t,$M.instances.push(n);const u=oe.getOrAddComponent(c,Yn);u.connectionId=i,u.avatar=c}else return;const r=n.obj;this.context.players.setPlayerView(i,r,Th.Browser),n.lastUpdate=this.context.time.realtimeSinceStartup,Ko.markDirty(r);const o=e.pos();o&&_d(r,o.x(),o.y(),o.z());const a=e.rot();a&&TA(r,a.x(),a.y(),a.z())}},h(WE,"instances",[]),WE);let cS=$M;Fce([x([me,$t])],cS.prototype,"cameraPrefab",2);var Nce=Object.defineProperty,zce=Object.getOwnPropertyDescriptor,Im=(s,e,t,i)=>{for(var n=i>1?void 0:i?zce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Nce(e,t,n),n};const CE="view",EE=ne("debugsyncedroom");class kc extends Me{constructor(){super(...arguments);h(this,"roomName");h(this,"urlParameterName","room");h(this,"joinRandomRoom",!0);h(this,"requireRoomParameter",!1);h(this,"autoRejoin",!0);h(this,"createJoinButton",!0);h(this,"_roomPrefix");h(this,"_lastJoinedRoom","");h(this,"_lastPingTime",0);h(this,"_lastRoomTime",-1);h(this,"_userWantsToBeInARoom",!1);h(this,"_roomButton");h(this,"_roomButtonIconJoin");h(this,"_roomButtonIconLeave");h(this,"updateRoomButtonState",()=>{var t,i;this._roomButton&&(this.context.connection.isInRoom?(this._roomButton.title="Leave the networked room",this._roomButton.textContent="Leave Room",(t=this._roomButtonIconJoin)==null||t.remove(),this._roomButton.prepend(this._roomButtonIconLeave)):(this._roomButton.title="Create or join a networked room",this._roomButton.textContent="Join Room",(i=this._roomButtonIconLeave)==null||i.remove(),this._roomButton.prepend(this._roomButtonIconJoin)))})}get roomPrefix(){return this._roomPrefix}get RoomPrefix(){return this._roomPrefix}awake(){EE&&console.log("Room",this.roomName,this.urlParameterName,this.joinRandomRoom,this.requireRoomParameter,this.autoRejoin),this._roomPrefix===void 0&&(this._roomPrefix=this.roomName,this.roomName="")}onEnable(){const t=ne(CE);if(t&&typeof t=="string"&&t.length>0){console.log("Join as viewer"),this.context.connection.joinRoom(t,!0);return}if((this.joinRandomRoom||ne(this.urlParameterName))&&this.tryJoinRoom(),this.createJoinButton){const i=this.createRoomButton();this.context.menu.appendChild(i)}}onDisable(){var t;(t=this._roomButton)==null||t.remove(),this.roomName&&this.roomName.length>0&&this.context.connection.leaveRoom(this.roomName)}onDestroy(){this.destroyRoomButton()}tryJoinRandomRoom(){this.setRandomRoomUrlParameter(),this.tryJoinRoom()}tryJoinRoom(t=0){t===void 0&&(t=0);let i=!1;if(this.urlParameterName){const n=ne(this.urlParameterName);if(n&&typeof n=="string"||n==="number"){i=!0;const r=LU(n);this.roomName=r}else if(this.joinRandomRoom&&(console.log("No room name found in url, generating random one"),this.setRandomRoomUrlParameter(),t<1))return this.tryJoinRoom(t+1)}else this.joinRandomRoom&&(this.roomName===null||this.roomName===void 0||this.roomName.length<=0)&&(console.log("generate room name"),this.roomName=this.generateRoomName());return this.requireRoomParameter&&!i?(EE&&console.log('No required room parameter "'+this.urlParameterName+'" in url - will not connect to networking backend.'),!1):(this.context.connection.isConnected||this.context.connection.connect(),EE&&console.log("Join "+this.roomName),this._lastJoinedRoom=this.roomName,this._roomPrefix&&(this.roomName=this._roomPrefix+this.roomName),this._userWantsToBeInARoom=!0,this.context.connection.joinRoom(this.roomName),!0)}update(){this.context.connection.isConnected&&(this.context.time.time-this._lastPingTime>3&&(this._lastPingTime=this.context.time.time,this.context.connection.sendPing()),this.context.connection.isInRoom&&(this._lastRoomTime=this.context.time.time)),this._lastRoomTime>0&&this.context.time.time-this._lastRoomTime>.3&&(this._lastRoomTime=-1,this.autoRejoin?this._userWantsToBeInARoom&&(console.log("Disconnected from networking backend - attempt reconnecting now"),this.tryJoinRoom()):gt()&&console.warn("You are not connected to a room anymore (possibly because the tab was inactive for too long and the server kicked you?)"))}get currentRoomName(){const t=ne(CE);return t||ne(this.urlParameterName)}setRandomRoomUrlParameter(){const t=bA(),i=this.generateRoomName();ne(this.urlParameterName)?t.set(this.urlParameterName,i):t.append(this.urlParameterName,i),rI(i,t)}generateRoomName(){return oI()+"_"+Math.floor(et.random(100,999))}getViewOnlyUrl(){if(this.context.connection.isConnected&&this.context.connection.currentRoomViewId){const t=window.location.search,i=new URLSearchParams(t);return i.has(this.urlParameterName)&&i.delete(this.urlParameterName),i.set(CE,this.context.connection.currentRoomViewId),window.location.origin+window.location.pathname+"?"+i.toString()}return null}createRoomButton(){if(this._roomButton)return this._roomButton;const t=document.createElement("button");return this._roomButton=t,t.classList.add("create-room-button"),t.setAttribute("priority","90"),t.onclick=()=>{this.context.connection.isInRoom?(this.urlParameterName&&Sb(this.urlParameterName,null),this.context.connection.leaveRoom(),this._userWantsToBeInARoom=!1):(this.urlParameterName&&(ne(this.urlParameterName)||(this._lastJoinedRoom?Sb(this.urlParameterName,this._lastJoinedRoom):this.setRandomRoomUrlParameter())),this.tryJoinRoom())},this._roomButtonIconJoin=fo("group"),this._roomButtonIconLeave=fo("group_off"),this.updateRoomButtonState(),this.context.connection.beginListen(ii.JoinedRoom,this.updateRoomButtonState),this.context.connection.beginListen(ii.LeftRoom,this.updateRoomButtonState),t}destroyRoomButton(){this.context.connection.stopListen(ii.JoinedRoom,this.updateRoomButtonState),this.context.connection.stopListen(ii.LeftRoom,this.updateRoomButtonState)}}Im([x()],kc.prototype,"roomName",2);Im([x()],kc.prototype,"urlParameterName",2);Im([x()],kc.prototype,"joinRandomRoom",2);Im([x()],kc.prototype,"requireRoomParameter",2);Im([x()],kc.prototype,"autoRejoin",2);Im([x()],kc.prototype,"createJoinButton",2);class hS extends Me{}function Gce(){const s=ne("testwindowcount")||0;s&&s>0&&Hce(s)}function Hce(s){if(ne("testwindow"))return null;const e=new URL(window.location.href);R1(e.searchParams,zne,1),R1(e.searchParams,"testwindow",1);const t=e.toString(),i=[];window.onbeforeunload=()=>{for(const l of i)l.close()};const n=.05,r=128;let o=0,a=0;for(let l=0;l<s;l++){o*r+r*.01>=window.innerWidth&&(a+=1,o=0);const c=o*(r*(1+n))+window.screenLeft,u=a*(r*(1+n))+window.screenTop+90+60*a;o+=1;const d=window.open(t,"test window "+l,`popup=yes width=${r} height=${r} top=${u} left=${c}`);if(!d){console.warn("Failed to open window");continue}i.push(d),d.onload=()=>{d.onbeforeunload=()=>{for(let f=0;f<i.length;f++){const p=i[f];p!==d&&p.close()}i.length=0}}}return i}class SP extends Me{awake(){Gce()}}class CP extends Me{constructor(){super(...arguments);h(this,"transformsPerFrame",10);h(this,"interval",0);h(this,"useFlatbuffers",!0);h(this,"builder",null);h(this,"models",null)}awake(){if(this.useFlatbuffers)this.context.connection.beginListenBinary(Xv,t=>{});else{this.models=[];for(let t=0;t<this.transformsPerFrame;t++)this.models.push(new rH(this.context.connection.connectionId+"_simulatedTransform_"+t,this))}}update(){if(this.context.connection.isConnected){if(this.useFlatbuffers){if(!this.context.connection.connectionId||this.context.time.frameCount%this.interval!==0)return;this.builder===null&&(this.builder=new DA(1024));const t=this.builder;for(let i=0;i<this.transformsPerFrame;i++){t.clear();const n=tG(this.context.connection.connectionId,this);this.context.connection.sendBinary(n)}}else if(this.models)for(let t=0;t<this.models.length;t++){const i=this.models[t];i.dontSave=!0,i.update(this,null),this.context.connection.send("TestSimulateUserData-"+t,i)}}}}class rH{constructor(e,t){h(this,"guid");h(this,"fast",!1);h(this,"position");h(this,"rotation");h(this,"velocity");h(this,"dontSave");this.guid=e,this.position={x:0,y:0,z:0},this.rotation={x:0,y:0,z:0,w:0},this.update(t,null)}isValid(){return this.fast!==void 0||this.position!==void 0||this.rotation!==void 0||this.velocity!==void 0}update(e,t){const i=e.worldPosition;this.position.x=i.x,this.position.y=i.y,this.position.z=i.z;const n=e.worldQuaternion;if(this.rotation.x=n.x,this.rotation.y=n.y,this.rotation.z=n.z,this.rotation.w=n.w,this.fast=!1,t){const r=t.getVelocity();this.velocity===void 0&&(this.velocity={x:0,y:0,z:0}),this.velocity.x=r.x,this.velocity.y=r.y,this.velocity.z=r.z}}}h(rH,"temp",new w);var Qce=Object.defineProperty,Vce=Object.getOwnPropertyDescriptor,Rm=(s,e,t,i)=>{for(var n=i>1?void 0:i?Vce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Qce(e,t,n),n};class Rl extends lr{constructor(){super(...arguments);h(this,"offset");h(this,"rotation");h(this,"focusArea");h(this,"feather");h(this,"kernelSize");h(this,"resolutionScale")}get typeName(){return"TiltShiftEffect"}init(){this.offset.defaultValue=0,this.rotation.defaultValue=0,this.focusArea.defaultValue=.4,this.feather.defaultValue=.3,this.kernelSize.defaultValue=wc.MEDIUM,this.resolutionScale.defaultValue=1/window.devicePixelRatio}onCreateEffect(){console.log(this);const t=new W$({kernelSize:wc.VERY_LARGE});return this.offset.onValueChanged=i=>t.offset=i,this.rotation.onValueChanged=i=>t.rotation=i,this.focusArea.onValueChanged=i=>t.focusArea=i,this.feather.onValueChanged=i=>t.feather=i,this.kernelSize.onValueChanged=i=>t.blurPass.kernelSize=i,this.resolutionScale.onValueChanged=i=>t.resolution.scale=i/window.devicePixelRatio,t}}Rm([x(kt)],Rl.prototype,"offset",2);Rm([x(kt)],Rl.prototype,"rotation",2);Rm([x(kt)],Rl.prototype,"focusArea",2);Rm([x(kt)],Rl.prototype,"feather",2);Rm([x(kt)],Rl.prototype,"kernelSize",2);Rm([x(kt)],Rl.prototype,"resolutionScale",2);aa("TiltShiftEffect",Rl);var Wce=Object.defineProperty,jce=Object.getOwnPropertyDescriptor,qce=(s,e,t,i)=>{for(var n=i>1?void 0:i?jce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Wce(e,t,n),n};class My extends lr{constructor(){super(...arguments);h(this,"mode")}get typeName(){return"ToneMapping"}get isToneMapping(){return!0}init(){this.mode||(this.mode=new kt(Wr)),this.mode.defaultValue=Wr}apply(){this.mode||this.init(),this.mode.onValueChanged=this._apply.bind(this),this._apply(this.mode.value)}_apply(t){this.context.renderer.toneMapping=this.getThreeToneMapping(t)}getThreeToneMapping(t){switch(t){case 0:return Mp;case 1:return vx;case 2:return gx;default:return Mp}}}qce([x(kt)],My.prototype,"mode",2);aa("Tonemapping",My);var Xce=Object.defineProperty,Yce=Object.getOwnPropertyDescriptor,uS=(s,e,t,i)=>{for(var n=i>1?void 0:i?Yce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Xce(e,t,n),n};class rf extends Me{constructor(){super(...arguments);h(this,"isGizmo",!1);h(this,"translationSnap",1);h(this,"rotationSnapAngle",15);h(this,"scaleSnap",.25);h(this,"control");h(this,"orbit");h(this,"onControlChangedEvent",t=>{const i=this.orbit;if(i&&(i.enabled=!t.value),t.value){const n=oe.getComponentInParent(this.gameObject,zh);n&&n.requestOwnership()}});h(this,"windowKeyDownListener",t=>{if(this.enabled&&this.control)switch(t.keyCode){case 81:this.control.setSpace(this.control.space==="local"?"world":"local");break;case 16:this.enableSnapping();break;case 87:this.control.setMode("translate");break;case 69:this.control.setMode("rotate");break;case 82:this.control.setMode("scale");break;case 187:case 107:this.control.setSize(this.control.size+.1);break;case 189:case 109:this.control.setSize(Math.max(this.control.size-.1,.1));break;case 88:this.control.showX=!this.control.showX;break;case 89:this.control.showY=!this.control.showY;break;case 90:this.control.showZ=!this.control.showZ;break;case 32:this.control.enabled=!this.control.enabled;break}});h(this,"windowKeyUpListener",t=>{if(this.enabled)switch(t.keyCode){case 16:this.disableSnapping();break}})}onEnable(){var t;this.isGizmo&&!BA||this.context.mainCamera&&(this.control||(this.control=new yK(this.context.mainCamera,this.context.renderer.domElement),this.control.visible=!0,this.control.enabled=!0,this.control.getRaycaster().layers.set(2),this.control.size=1,this.control.traverse(i=>{const n=i;if(n.layers.set(2),n){const r=n.material;r&&(r.opacity=.3)}}),this.orbit=oe.getComponentInParent(this.context.mainCamera,Ci)??void 0),this.control&&(this.context.scene.add(this.control),this.control.attach(this.gameObject),(t=this.control)==null||t.addEventListener("dragging-changed",this.onControlChangedEvent),window.addEventListener("keydown",this.windowKeyDownListener),window.addEventListener("keyup",this.windowKeyUpListener)))}onDisable(){var t,i;(t=this.control)==null||t.removeFromParent(),(i=this.control)==null||i.removeEventListener("dragging-changed",this.onControlChangedEvent),window.removeEventListener("keydown",this.windowKeyDownListener),window.removeEventListener("keyup",this.windowKeyUpListener)}enableSnapping(){this.control&&(this.control.setTranslationSnap(this.translationSnap),this.control.setRotationSnap(Kn.degToRad(this.rotationSnapAngle)),this.control.setScaleSnap(this.scaleSnap))}disableSnapping(){this.control&&(this.control.setTranslationSnap(null),this.control.setRotationSnap(null),this.control.setScaleSnap(null))}}uS([x()],rf.prototype,"isGizmo",2);uS([x()],rf.prototype,"translationSnap",2);uS([x()],rf.prototype,"rotationSnapAngle",2);uS([x()],rf.prototype,"scaleSnap",2);var Jce=Object.defineProperty,Kce=Object.getOwnPropertyDescriptor,EP=(s,e,t,i)=>{for(var n=i>1?void 0:i?Kce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Jce(e,t,n),n};class of extends lr{constructor(){super(...arguments);h(this,"color");h(this,"intensity");h(this,"center")}get typeName(){return"Vignette"}init(){this.color.defaultValue={r:0,g:0,b:0,a:1},this.intensity.defaultValue=0,this.center.defaultValue={x:.5,y:.5}}onCreateEffect(){const t=new Z3;return this.intensity.onValueChanged=i=>{t.offset=i,this.updateDarkness(t)},this.color.onValueChanged=i=>{this.updateDarkness(t)},t}updateDarkness(t){const i=this.intensity.value;t.darkness=i}}EP([x(kt)],of.prototype,"color",2);EP([x(kt)],of.prototype,"intensity",2);EP([x(kt)],of.prototype,"center",2);aa("Vignette",of);var Zce=Object.defineProperty,$ce=Object.getOwnPropertyDescriptor,ehe=(s,e,t,i)=>{for(var n=i>1?void 0:i?$ce(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Zce(e,t,n),n};const rb=ne("debugarcamera");class dS extends Me{constructor(){super(...arguments);h(this,"backgroundTint",new wi(1,1,1,1));h(this,"backgroundPlane");h(this,"threeTexture");h(this,"forceTextureInitialization",function(){const t=new ai,i=new Gn,n=new or;n.add(new de(i,t));const r=new Gt;return function(a,l){t.map=l,a.render(n,r),rb&&console.warn("Force texture initialization")}}());h(this,"preRender",()=>{if(!this||!this.gameObject)return;const i=this.context.renderer.xr.getFrame();i&&(!this.threeTexture&&this.context.renderer&&(this.threeTexture=new _t,this.forceTextureInitialization(this.context.renderer,this.threeTexture)),this.backgroundPlane===void 0&&(this.backgroundPlane=ihe(this.backgroundTint)),this.backgroundPlane.parent!==this.scene&&this.scene.add(this.backgroundPlane),this.updateFromFrame(i))})}onBeforeXR(t,i){i.optionalFeatures=i.optionalFeatures||[],i.optionalFeatures.push("camera-access"),rb&&console.warn("Requesting camera-access")}onEnterXR(t){this.backgroundPlane&&(this.context.scene.add(this.backgroundPlane),this.backgroundPlane.visible=!1),this.backgroundPlane&&this.context.scene.add(this.backgroundPlane),this.context.pre_render_callbacks.push(this.preRender)}onLeaveXR(t){this.backgroundPlane&&this.backgroundPlane.removeFromParent();const i=this.context.pre_render_callbacks.indexOf(this.preRender);i>=0&&this.context.pre_render_callbacks.splice(i,1)}get background(){return this.backgroundPlane}onBeforeRender(t){this.updateFromFrame(t)}updateFromFrame(t){if(!t)return;const i=t.session.enabledFeatures;if(i&&!i.some(r=>r==="camera-access")){this.background&&(this.background.visible=!1);return}const n=t.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(n){for(const r of n.views)if("camera"in r&&r.camera){let a=this.context.renderer.xr.getBinding();if(a||(a=new XRWebGLBinding(t.session,this.context.renderer.getContext())),a){let l=null;if("getCameraImage"in a){l=a.getCameraImage(r.camera);const c=this.context.renderer.properties.get(this.threeTexture);c.__webglTexture=l,this.backgroundPlane?(this.backgroundPlane.setTexture(this.threeTexture),this.backgroundPlane.visible=!0):rb&&console.warn("No background plane to set texture on")}}}}}}ehe([x(wi)],dS.prototype,"backgroundTint",2);const the=`
7019
7019
  uniform sampler2D t2D;
7020
7020
 
7021
7021
  varying vec2 vUv;