@playcanvas/supersplat-viewer 1.24.1 → 1.26.0

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.
package/public/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const TRACEID_GPU_TIMINGS = 'GpuTimings';
2
2
 
3
- const version$1 = '2.19.0-preview.1';
4
- const revision = '4ceb7e8';
3
+ const version$1 = '2.19.0-preview.2';
4
+ const revision = '40bc881';
5
5
  function extend(target, ex) {
6
6
  for(const prop in ex){
7
7
  const copy = ex[prop];
@@ -47765,7 +47765,6 @@ var skyboxVS = `
47765
47765
 
47766
47766
  var sortIndirectArgsCS = `
47767
47767
  fn writeSortIndirectArgs(
47768
- buf: ptr<storage, array<u32>, read_write>,
47769
47768
  baseSlot: u32,
47770
47769
  count: u32,
47771
47770
  slotInfo: vec4<u32>
@@ -47775,25 +47774,25 @@ fn writeSortIndirectArgs(
47775
47774
  let g = slotInfo.y;
47776
47775
  let wc = (count + g - 1u) / g;
47777
47776
  let off = baseSlot * 3u;
47778
- (*buf)[off + 0u] = wc;
47779
- (*buf)[off + 1u] = 1u;
47780
- (*buf)[off + 2u] = 1u;
47777
+ indirectDispatchArgs[off + 0u] = wc;
47778
+ indirectDispatchArgs[off + 1u] = 1u;
47779
+ indirectDispatchArgs[off + 2u] = 1u;
47781
47780
  }
47782
47781
  if (n >= 2u) {
47783
47782
  let g = slotInfo.z;
47784
47783
  let wc = (count + g - 1u) / g;
47785
47784
  let off = (baseSlot + 1u) * 3u;
47786
- (*buf)[off + 0u] = wc;
47787
- (*buf)[off + 1u] = 1u;
47788
- (*buf)[off + 2u] = 1u;
47785
+ indirectDispatchArgs[off + 0u] = wc;
47786
+ indirectDispatchArgs[off + 1u] = 1u;
47787
+ indirectDispatchArgs[off + 2u] = 1u;
47789
47788
  }
47790
47789
  if (n >= 3u) {
47791
47790
  let g = slotInfo.w;
47792
47791
  let wc = (count + g - 1u) / g;
47793
47792
  let off = (baseSlot + 2u) * 3u;
47794
- (*buf)[off + 0u] = wc;
47795
- (*buf)[off + 1u] = 1u;
47796
- (*buf)[off + 2u] = 1u;
47793
+ indirectDispatchArgs[off + 0u] = wc;
47794
+ indirectDispatchArgs[off + 1u] = 1u;
47795
+ indirectDispatchArgs[off + 2u] = 1u;
47797
47796
  }
47798
47797
  }
47799
47798
  `;
@@ -56996,7 +56995,7 @@ fn main() {
56996
56995
  );
56997
56996
  numSplatsBuf[0] = count;
56998
56997
  sortElementCountBuf[0] = count;
56999
- writeSortIndirectArgs(&indirectDispatchArgs, uniforms.sortSlotBase, count, uniforms.sortIndirectInfo);
56998
+ writeSortIndirectArgs(uniforms.sortSlotBase, count, uniforms.sortIndirectInfo);
57000
56999
  }
57001
57000
  `;
57002
57001
 
@@ -58533,7 +58532,7 @@ fn main(@builtin(global_invocation_id) gid: vec3u) {
58533
58532
  indirectDispatchArgs[keygenOffset + 0u] = keygenDim.x;
58534
58533
  indirectDispatchArgs[keygenOffset + 1u] = keygenDim.y;
58535
58534
  indirectDispatchArgs[keygenOffset + 2u] = 1u;
58536
- writeSortIndirectArgs(&indirectDispatchArgs, keygenSlot + 1u, count, uniforms.sortIndirectInfo);
58535
+ writeSortIndirectArgs(keygenSlot + 1u, count, uniforms.sortIndirectInfo);
58537
58536
  sortElementCountBuf[0] = count;
58538
58537
  }
58539
58538
  `;
@@ -76052,6 +76051,12 @@ class App extends AppBase {
76052
76051
  }
76053
76052
  }
76054
76053
 
76054
+ /**
76055
+ * Fallback voxel cell size for mesh collision, which doesn't carry the carve
76056
+ * metadata itself. Assumes the mesh was generated from a voxel grid at this
76057
+ * resolution (matches the default `splat-transform --voxel-carve` output).
76058
+ */
76059
+ const DEFAULT_VOXEL_RESOLUTION = 0.05;
76055
76060
  /** Minimum penetration depth to report (avoids floating-point noise) */
76056
76061
  const PENETRATION_EPSILON = 1e-4;
76057
76062
  /** Maximum iterations for iterative sphere/capsule resolution */
@@ -76376,6 +76381,12 @@ const _closest = { x: 0, y: 0, z: 0 };
76376
76381
  const _segClosest = { x: 0, y: 0, z: 0 };
76377
76382
  const _triClosest = { x: 0, y: 0, z: 0 };
76378
76383
  class MeshCollision {
76384
+ /**
76385
+ * Assumed voxel resolution of the source carve that produced this mesh.
76386
+ * The mesh itself doesn't carry this metadata, so we fall back to the
76387
+ * default; can be overridden post-construction if a loader knows better.
76388
+ */
76389
+ voxelResolution = DEFAULT_VOXEL_RESOLUTION;
76379
76390
  _tris;
76380
76391
  _root;
76381
76392
  _normalResult = { nx: 0, ny: 0, nz: 0 };
@@ -76480,6 +76491,12 @@ class MeshCollision {
76480
76491
  queryCapsule(cx, cy, cz, halfHeight, radius, out) {
76481
76492
  return resolveIterative(cx, cy, cz, (rx, ry, rz, push) => this._deepestCapsulePenetration(rx, ry, rz, halfHeight, radius, push), this._constraintNormals, this._push, out);
76482
76493
  }
76494
+ isFreeAt(x, y, z) {
76495
+ // Approximation: a point is in free space iff no triangle is within
76496
+ // half a voxel of it. Matches the voxel-grid notion for data derived
76497
+ // from the same carve.
76498
+ return !this._deepestSpherePenetration(x, y, z, this.voxelResolution * 0.5, this._push);
76499
+ }
76483
76500
  querySurfaceNormal(x, y, z, rdx, rdy, rdz) {
76484
76501
  const len = Math.sqrt(rdx * rdx + rdy * rdy + rdz * rdz);
76485
76502
  if (len < 1e-10) {
@@ -77013,6 +77030,25 @@ class VoxelCollision {
77013
77030
  get flipXY() {
77014
77031
  return false;
77015
77032
  }
77033
+ isFreeAt(x, y, z) {
77034
+ // Without voxel data, there's no carve to consult — report not-free
77035
+ // rather than have the lattice search treat the world as wide open.
77036
+ if (this._nodes.length === 0) {
77037
+ return false;
77038
+ }
77039
+ const res = this._voxelResolution;
77040
+ const ix = Math.floor((x - this._gridMinX) / res);
77041
+ const iy = Math.floor((y - this._gridMinY) / res);
77042
+ const iz = Math.floor((z - this._gridMinZ) / res);
77043
+ // Outside the carved grid is "no data" — also not-free. Without this
77044
+ // check the lattice search would spend candidates on out-of-bounds
77045
+ // cells (and `isVoxelSolid` would mislead callers by returning false).
77046
+ if (ix < 0 || iy < 0 || iz < 0 ||
77047
+ ix >= this._numVoxelsX || iy >= this._numVoxelsY || iz >= this._numVoxelsZ) {
77048
+ return false;
77049
+ }
77050
+ return !this.isVoxelSolid(ix, iy, iz);
77051
+ }
77016
77052
  querySurfaceNormal(x, y, z, rdx, rdy, rdz) {
77017
77053
  const nudge = this._voxelResolution * 0.25;
77018
77054
  const ix = Math.floor((x + Math.sign(rdx) * nudge - this._gridMinX) / this._voxelResolution);
@@ -77555,6 +77591,9 @@ class FlippedVoxelCollision extends VoxelCollision {
77555
77591
  }
77556
77592
  return result;
77557
77593
  }
77594
+ isFreeAt(x, y, z) {
77595
+ return super.isFreeAt(-x, -y, z);
77596
+ }
77558
77597
  }
77559
77598
  /**
77560
77599
  * Load a VoxelCollision from a .voxel.json URL.
@@ -77612,6 +77651,713 @@ const observe = (events, target) => {
77612
77651
  });
77613
77652
  };
77614
77653
 
77654
+ var deJson = {
77655
+ "settings.performance-mode": "Leistungsmodus",
77656
+ "settings.gaming-controls": "Gaming-Steuerung",
77657
+ "settings.frame": "Einpassen",
77658
+ "settings.reset": "Zurücksetzen",
77659
+ "tooltip.play": "Wiedergabe",
77660
+ "tooltip.pause": "Pause",
77661
+ "tooltip.orbit-camera": "Umlaufkamera",
77662
+ "tooltip.fly-camera": "Flugkamera",
77663
+ "tooltip.walk-mode": "Gehmodus",
77664
+ "tooltip.reset-camera": "Kamera zurücksetzen",
77665
+ "tooltip.frame-scene": "Szene einpassen",
77666
+ "tooltip.show-collision": "Kollision anzeigen",
77667
+ "tooltip.settings": "Einstellungen",
77668
+ "tooltip.help": "Hilfe",
77669
+ "tooltip.enter-ar": "AR starten",
77670
+ "tooltip.enter-vr": "VR starten",
77671
+ "tooltip.fullscreen": "Vollbild",
77672
+ "help.tab.desktop": "Desktop",
77673
+ "help.tab.touch": "Touch",
77674
+ "help.section.orbit": "Umlaufmodus",
77675
+ "help.section.fly": "Flugmodus",
77676
+ "help.section.walk": "Gehmodus",
77677
+ "help.section.modes": "Modus wechseln",
77678
+ "help.action.orbit": "Umkreisen",
77679
+ "help.action.pan": "Schwenken",
77680
+ "help.action.zoom": "Zoomen",
77681
+ "help.action.set-focus": "Fokus setzen",
77682
+ "help.action.fly-to": "Fliegen zu",
77683
+ "help.action.fly-to-point": "Zum Punkt fliegen",
77684
+ "help.action.walk-to": "Gehen zu",
77685
+ "help.action.look-around": "Umsehen",
77686
+ "help.action.move": "Bewegen",
77687
+ "help.action.vertical": "Vertikal",
77688
+ "help.action.jump": "Springen",
77689
+ "help.action.run-slow": "Rennen / Gehen",
77690
+ "help.action.focus-point": "Fokuspunkt",
77691
+ "help.action.frame-scene": "Szene einpassen",
77692
+ "help.action.reset-camera": "Kamera zurücksetzen",
77693
+ "help.action.orbit-mode": "Umlaufmodus",
77694
+ "help.action.fly-mode": "Flugmodus",
77695
+ "help.action.toggle-walk": "Gehen umschalten",
77696
+ "help.action.toggle-gaming": "Gaming-Steuerung umschalten",
77697
+ "help.action.show-collision": "Kollision anzeigen",
77698
+ "help.action.play-pause": "Wiedergabe / Pause",
77699
+ "help.action.toggle-help": "Hilfe umschalten",
77700
+ "help.action.exit-cancel": "Beenden / Abbrechen",
77701
+ "help.key.left-click": "Linksklick",
77702
+ "help.key.left-click-drag": "Linksklick + Ziehen",
77703
+ "help.key.right-click-drag": "Rechtsklick + Ziehen",
77704
+ "help.key.mouse-wheel": "Mausrad",
77705
+ "help.key.mouse": "Maus",
77706
+ "help.key.double-click": "Doppelklick",
77707
+ "help.key.double-tap": "Doppeltippen",
77708
+ "help.key.tap": "Tippen",
77709
+ "help.key.touch-drag": "Berühren + Ziehen",
77710
+ "help.key.one-finger-drag": "Mit einem Finger ziehen",
77711
+ "help.key.two-finger-drag": "Mit zwei Fingern ziehen",
77712
+ "help.key.pinch": "Zwei-Finger-Zoom",
77713
+ "help.key.pinch-two-finger": "Zwei-Finger-Zoom / Ziehen",
77714
+ "help.key.joystick": "Joystick",
77715
+ "help.key.shift-ctrl": "Umschalt / Strg",
77716
+ "help.key.space": "Leertaste",
77717
+ "help.key.esc": "Esc",
77718
+ "xr-modal.title": "WebGL erforderlich",
77719
+ "xr-modal.message": "AR und VR werden vom WebGPU-Renderer nicht unterstützt. Mit OK wird der Viewer mit WebGL neu geladen.",
77720
+ "xr-modal.cancel": "Abbrechen",
77721
+ "xr-modal.ok": "OK",
77722
+ "walk-hint.desktop": "Zum Gehen klicken. WASD für freie Bewegung.",
77723
+ "walk-hint.touch-tap": "Zum Gehen tippen. Ziehen, um sich umzusehen.",
77724
+ "walk-hint.touch-gaming": "Mit dem Joystick bewegen. Ziehen, um sich umzusehen. Zum Springen tippen."
77725
+ };
77726
+
77727
+ var enJson = {
77728
+ "settings.performance-mode": "Performance Mode",
77729
+ "settings.gaming-controls": "Gaming Controls",
77730
+ "settings.frame": "Frame",
77731
+ "settings.reset": "Reset",
77732
+ "tooltip.play": "Play",
77733
+ "tooltip.pause": "Pause",
77734
+ "tooltip.orbit-camera": "Orbit Camera",
77735
+ "tooltip.fly-camera": "Fly Camera",
77736
+ "tooltip.walk-mode": "Walk Mode",
77737
+ "tooltip.reset-camera": "Reset Camera",
77738
+ "tooltip.frame-scene": "Frame Scene",
77739
+ "tooltip.show-collision": "Show Collision",
77740
+ "tooltip.settings": "Settings",
77741
+ "tooltip.help": "Help",
77742
+ "tooltip.enter-ar": "Enter AR",
77743
+ "tooltip.enter-vr": "Enter VR",
77744
+ "tooltip.fullscreen": "Fullscreen",
77745
+ "help.tab.desktop": "Desktop",
77746
+ "help.tab.touch": "Touch",
77747
+ "help.section.orbit": "Orbit Mode",
77748
+ "help.section.fly": "Fly Mode",
77749
+ "help.section.walk": "Walk Mode",
77750
+ "help.section.modes": "Mode Switching",
77751
+ "help.action.orbit": "Orbit",
77752
+ "help.action.pan": "Pan",
77753
+ "help.action.zoom": "Zoom",
77754
+ "help.action.set-focus": "Set Focus",
77755
+ "help.action.fly-to": "Fly To",
77756
+ "help.action.fly-to-point": "Fly to Point",
77757
+ "help.action.walk-to": "Walk To",
77758
+ "help.action.look-around": "Look Around",
77759
+ "help.action.move": "Move",
77760
+ "help.action.vertical": "Vertical",
77761
+ "help.action.jump": "Jump",
77762
+ "help.action.run-slow": "Run / Slow",
77763
+ "help.action.focus-point": "Focus Point",
77764
+ "help.action.frame-scene": "Frame Scene",
77765
+ "help.action.reset-camera": "Reset Camera",
77766
+ "help.action.orbit-mode": "Orbit Mode",
77767
+ "help.action.fly-mode": "Fly Mode",
77768
+ "help.action.toggle-walk": "Toggle Walk",
77769
+ "help.action.toggle-gaming": "Toggle Gaming Controls",
77770
+ "help.action.show-collision": "Show Collision",
77771
+ "help.action.play-pause": "Play / Pause",
77772
+ "help.action.toggle-help": "Toggle Help",
77773
+ "help.action.exit-cancel": "Exit / Cancel",
77774
+ "help.key.left-click": "Left Click",
77775
+ "help.key.left-click-drag": "Left Click + Drag",
77776
+ "help.key.right-click-drag": "Right Click + Drag",
77777
+ "help.key.mouse-wheel": "Mouse Wheel",
77778
+ "help.key.mouse": "Mouse",
77779
+ "help.key.double-click": "Double-click",
77780
+ "help.key.double-tap": "Double-tap",
77781
+ "help.key.tap": "Tap",
77782
+ "help.key.touch-drag": "Touch + Drag",
77783
+ "help.key.one-finger-drag": "One Finger Drag",
77784
+ "help.key.two-finger-drag": "Two Finger Drag",
77785
+ "help.key.pinch": "Pinch",
77786
+ "help.key.pinch-two-finger": "Pinch / Two Finger Drag",
77787
+ "help.key.joystick": "Joystick",
77788
+ "help.key.shift-ctrl": "Shift / Ctrl",
77789
+ "help.key.space": "Space",
77790
+ "help.key.esc": "Esc",
77791
+ "xr-modal.title": "WebGL Required",
77792
+ "xr-modal.message": "AR and VR are not supported on the WebGPU renderer. Pressing OK will reload the viewer with WebGL.",
77793
+ "xr-modal.cancel": "Cancel",
77794
+ "xr-modal.ok": "OK",
77795
+ "walk-hint.desktop": "Click to walk. WASD to move freely.",
77796
+ "walk-hint.touch-tap": "Tap to walk. Drag to look around.",
77797
+ "walk-hint.touch-gaming": "Use the joystick to move. Drag to look around. Tap to jump."
77798
+ };
77799
+
77800
+ var esJson = {
77801
+ "settings.performance-mode": "Modo rendimiento",
77802
+ "settings.gaming-controls": "Controles de juego",
77803
+ "settings.frame": "Encuadrar",
77804
+ "settings.reset": "Restablecer",
77805
+ "tooltip.play": "Reproducir",
77806
+ "tooltip.pause": "Pausar",
77807
+ "tooltip.orbit-camera": "Cámara orbital",
77808
+ "tooltip.fly-camera": "Cámara de vuelo",
77809
+ "tooltip.walk-mode": "Modo caminar",
77810
+ "tooltip.reset-camera": "Restablecer cámara",
77811
+ "tooltip.frame-scene": "Encuadrar escena",
77812
+ "tooltip.show-collision": "Mostrar colisión",
77813
+ "tooltip.settings": "Ajustes",
77814
+ "tooltip.help": "Ayuda",
77815
+ "tooltip.enter-ar": "Entrar en AR",
77816
+ "tooltip.enter-vr": "Entrar en VR",
77817
+ "tooltip.fullscreen": "Pantalla completa",
77818
+ "help.tab.desktop": "Escritorio",
77819
+ "help.tab.touch": "Táctil",
77820
+ "help.section.orbit": "Modo orbital",
77821
+ "help.section.fly": "Modo vuelo",
77822
+ "help.section.walk": "Modo caminar",
77823
+ "help.section.modes": "Cambio de modo",
77824
+ "help.action.orbit": "Orbitar",
77825
+ "help.action.pan": "Desplazar",
77826
+ "help.action.zoom": "Zoom",
77827
+ "help.action.set-focus": "Fijar foco",
77828
+ "help.action.fly-to": "Volar a",
77829
+ "help.action.fly-to-point": "Volar al punto",
77830
+ "help.action.walk-to": "Caminar a",
77831
+ "help.action.look-around": "Mirar alrededor",
77832
+ "help.action.move": "Mover",
77833
+ "help.action.vertical": "Vertical",
77834
+ "help.action.jump": "Saltar",
77835
+ "help.action.run-slow": "Correr / Lento",
77836
+ "help.action.focus-point": "Punto focal",
77837
+ "help.action.frame-scene": "Encuadrar escena",
77838
+ "help.action.reset-camera": "Restablecer cámara",
77839
+ "help.action.orbit-mode": "Modo orbital",
77840
+ "help.action.fly-mode": "Modo vuelo",
77841
+ "help.action.toggle-walk": "Alternar caminar",
77842
+ "help.action.toggle-gaming": "Alternar controles de juego",
77843
+ "help.action.show-collision": "Mostrar colisión",
77844
+ "help.action.play-pause": "Reproducir / Pausar",
77845
+ "help.action.toggle-help": "Alternar ayuda",
77846
+ "help.action.exit-cancel": "Salir / Cancelar",
77847
+ "help.key.left-click": "Clic izquierdo",
77848
+ "help.key.left-click-drag": "Clic izquierdo + arrastrar",
77849
+ "help.key.right-click-drag": "Clic derecho + arrastrar",
77850
+ "help.key.mouse-wheel": "Rueda del ratón",
77851
+ "help.key.mouse": "Ratón",
77852
+ "help.key.double-click": "Doble clic",
77853
+ "help.key.double-tap": "Doble toque",
77854
+ "help.key.tap": "Toque",
77855
+ "help.key.touch-drag": "Toque + arrastrar",
77856
+ "help.key.one-finger-drag": "Arrastre con un dedo",
77857
+ "help.key.two-finger-drag": "Arrastre con dos dedos",
77858
+ "help.key.pinch": "Pellizcar",
77859
+ "help.key.pinch-two-finger": "Pellizcar / Arrastre con dos dedos",
77860
+ "help.key.joystick": "Joystick",
77861
+ "help.key.shift-ctrl": "Mayús / Ctrl",
77862
+ "help.key.space": "Espacio",
77863
+ "help.key.esc": "Esc",
77864
+ "xr-modal.title": "Se requiere WebGL",
77865
+ "xr-modal.message": "AR y VR no son compatibles con el renderizador WebGPU. Al pulsar OK se recargará el visor con WebGL.",
77866
+ "xr-modal.cancel": "Cancelar",
77867
+ "xr-modal.ok": "OK",
77868
+ "walk-hint.desktop": "Haz clic para caminar. WASD para moverte libremente.",
77869
+ "walk-hint.touch-tap": "Toca para caminar. Arrastra para mirar alrededor.",
77870
+ "walk-hint.touch-gaming": "Usa el joystick para moverte. Arrastra para mirar. Toca para saltar."
77871
+ };
77872
+
77873
+ var frJson = {
77874
+ "settings.performance-mode": "Mode performance",
77875
+ "settings.gaming-controls": "Commandes de jeu",
77876
+ "settings.frame": "Cadrer",
77877
+ "settings.reset": "Réinitialiser",
77878
+ "tooltip.play": "Lecture",
77879
+ "tooltip.pause": "Pause",
77880
+ "tooltip.orbit-camera": "Caméra orbitale",
77881
+ "tooltip.fly-camera": "Caméra volante",
77882
+ "tooltip.walk-mode": "Mode marche",
77883
+ "tooltip.reset-camera": "Réinitialiser la caméra",
77884
+ "tooltip.frame-scene": "Cadrer la scène",
77885
+ "tooltip.show-collision": "Afficher les collisions",
77886
+ "tooltip.settings": "Paramètres",
77887
+ "tooltip.help": "Aide",
77888
+ "tooltip.enter-ar": "Entrer en AR",
77889
+ "tooltip.enter-vr": "Entrer en VR",
77890
+ "tooltip.fullscreen": "Plein écran",
77891
+ "help.tab.desktop": "Bureau",
77892
+ "help.tab.touch": "Tactile",
77893
+ "help.section.orbit": "Mode orbital",
77894
+ "help.section.fly": "Mode vol",
77895
+ "help.section.walk": "Mode marche",
77896
+ "help.section.modes": "Changement de mode",
77897
+ "help.action.orbit": "Orbiter",
77898
+ "help.action.pan": "Panoramique",
77899
+ "help.action.zoom": "Zoom",
77900
+ "help.action.set-focus": "Définir le focus",
77901
+ "help.action.fly-to": "Voler vers",
77902
+ "help.action.fly-to-point": "Voler vers le point",
77903
+ "help.action.walk-to": "Marcher vers",
77904
+ "help.action.look-around": "Regarder autour",
77905
+ "help.action.move": "Se déplacer",
77906
+ "help.action.vertical": "Vertical",
77907
+ "help.action.jump": "Sauter",
77908
+ "help.action.run-slow": "Courir / Lent",
77909
+ "help.action.focus-point": "Point focal",
77910
+ "help.action.frame-scene": "Cadrer la scène",
77911
+ "help.action.reset-camera": "Réinitialiser la caméra",
77912
+ "help.action.orbit-mode": "Mode orbital",
77913
+ "help.action.fly-mode": "Mode vol",
77914
+ "help.action.toggle-walk": "Basculer la marche",
77915
+ "help.action.toggle-gaming": "Basculer les commandes de jeu",
77916
+ "help.action.show-collision": "Afficher les collisions",
77917
+ "help.action.play-pause": "Lecture / Pause",
77918
+ "help.action.toggle-help": "Basculer l'aide",
77919
+ "help.action.exit-cancel": "Quitter / Annuler",
77920
+ "help.key.left-click": "Clic gauche",
77921
+ "help.key.left-click-drag": "Clic gauche + glisser",
77922
+ "help.key.right-click-drag": "Clic droit + glisser",
77923
+ "help.key.mouse-wheel": "Molette",
77924
+ "help.key.mouse": "Souris",
77925
+ "help.key.double-click": "Double clic",
77926
+ "help.key.double-tap": "Double tape",
77927
+ "help.key.tap": "Tape",
77928
+ "help.key.touch-drag": "Toucher + glisser",
77929
+ "help.key.one-finger-drag": "Glisser à un doigt",
77930
+ "help.key.two-finger-drag": "Glisser à deux doigts",
77931
+ "help.key.pinch": "Pincer",
77932
+ "help.key.pinch-two-finger": "Pincer / Glisser à deux doigts",
77933
+ "help.key.joystick": "Joystick",
77934
+ "help.key.shift-ctrl": "Maj / Ctrl",
77935
+ "help.key.space": "Espace",
77936
+ "help.key.esc": "Échap",
77937
+ "xr-modal.title": "WebGL requis",
77938
+ "xr-modal.message": "L'AR et la VR ne sont pas prises en charge par le moteur de rendu WebGPU. Cliquer sur OK rechargera le visualiseur avec WebGL.",
77939
+ "xr-modal.cancel": "Annuler",
77940
+ "xr-modal.ok": "OK",
77941
+ "walk-hint.desktop": "Cliquez pour marcher. WASD pour vous déplacer librement.",
77942
+ "walk-hint.touch-tap": "Tapez pour marcher. Glissez pour regarder autour.",
77943
+ "walk-hint.touch-gaming": "Utilisez le joystick pour vous déplacer. Glissez pour regarder. Tapez pour sauter."
77944
+ };
77945
+
77946
+ var jaJson = {
77947
+ "settings.performance-mode": "パフォーマンスモード",
77948
+ "settings.gaming-controls": "ゲームコントロール",
77949
+ "settings.frame": "フィット",
77950
+ "settings.reset": "リセット",
77951
+ "tooltip.play": "再生",
77952
+ "tooltip.pause": "一時停止",
77953
+ "tooltip.orbit-camera": "オービットカメラ",
77954
+ "tooltip.fly-camera": "フライカメラ",
77955
+ "tooltip.walk-mode": "ウォークモード",
77956
+ "tooltip.reset-camera": "カメラをリセット",
77957
+ "tooltip.frame-scene": "シーンにフィット",
77958
+ "tooltip.show-collision": "コリジョンを表示",
77959
+ "tooltip.settings": "設定",
77960
+ "tooltip.help": "ヘルプ",
77961
+ "tooltip.enter-ar": "ARを開始",
77962
+ "tooltip.enter-vr": "VRを開始",
77963
+ "tooltip.fullscreen": "全画面表示",
77964
+ "help.tab.desktop": "デスクトップ",
77965
+ "help.tab.touch": "タッチ",
77966
+ "help.section.orbit": "オービットモード",
77967
+ "help.section.fly": "フライモード",
77968
+ "help.section.walk": "ウォークモード",
77969
+ "help.section.modes": "モード切り替え",
77970
+ "help.action.orbit": "オービット",
77971
+ "help.action.pan": "パン",
77972
+ "help.action.zoom": "ズーム",
77973
+ "help.action.set-focus": "フォーカスを設定",
77974
+ "help.action.fly-to": "飛ぶ",
77975
+ "help.action.fly-to-point": "ポイントへ飛ぶ",
77976
+ "help.action.walk-to": "歩く",
77977
+ "help.action.look-around": "周りを見る",
77978
+ "help.action.move": "移動",
77979
+ "help.action.vertical": "垂直",
77980
+ "help.action.jump": "ジャンプ",
77981
+ "help.action.run-slow": "走る / 歩く",
77982
+ "help.action.focus-point": "フォーカスポイント",
77983
+ "help.action.frame-scene": "シーンにフィット",
77984
+ "help.action.reset-camera": "カメラをリセット",
77985
+ "help.action.orbit-mode": "オービットモード",
77986
+ "help.action.fly-mode": "フライモード",
77987
+ "help.action.toggle-walk": "ウォークを切り替え",
77988
+ "help.action.toggle-gaming": "ゲームコントロールを切り替え",
77989
+ "help.action.show-collision": "コリジョンを表示",
77990
+ "help.action.play-pause": "再生 / 一時停止",
77991
+ "help.action.toggle-help": "ヘルプを切り替え",
77992
+ "help.action.exit-cancel": "終了 / キャンセル",
77993
+ "help.key.left-click": "左クリック",
77994
+ "help.key.left-click-drag": "左クリック + ドラッグ",
77995
+ "help.key.right-click-drag": "右クリック + ドラッグ",
77996
+ "help.key.mouse-wheel": "マウスホイール",
77997
+ "help.key.mouse": "マウス",
77998
+ "help.key.double-click": "ダブルクリック",
77999
+ "help.key.double-tap": "ダブルタップ",
78000
+ "help.key.tap": "タップ",
78001
+ "help.key.touch-drag": "タッチ + ドラッグ",
78002
+ "help.key.one-finger-drag": "1本指でドラッグ",
78003
+ "help.key.two-finger-drag": "2本指でドラッグ",
78004
+ "help.key.pinch": "ピンチ",
78005
+ "help.key.pinch-two-finger": "ピンチ / 2本指でドラッグ",
78006
+ "help.key.joystick": "ジョイスティック",
78007
+ "help.key.shift-ctrl": "Shift / Ctrl",
78008
+ "help.key.space": "スペース",
78009
+ "help.key.esc": "Esc",
78010
+ "xr-modal.title": "WebGLが必要です",
78011
+ "xr-modal.message": "ARとVRはWebGPUレンダラーでは利用できません。OKを押すとWebGLでビューアーを再読み込みします。",
78012
+ "xr-modal.cancel": "キャンセル",
78013
+ "xr-modal.ok": "OK",
78014
+ "walk-hint.desktop": "クリックで歩行。WASDで自由に移動。",
78015
+ "walk-hint.touch-tap": "タップで歩行。ドラッグで視点移動。",
78016
+ "walk-hint.touch-gaming": "ジョイスティックで移動。ドラッグで視点移動。タップでジャンプ。"
78017
+ };
78018
+
78019
+ var koJson = {
78020
+ "settings.performance-mode": "성능 모드",
78021
+ "settings.gaming-controls": "게임 컨트롤",
78022
+ "settings.frame": "맞춤",
78023
+ "settings.reset": "재설정",
78024
+ "tooltip.play": "재생",
78025
+ "tooltip.pause": "일시 정지",
78026
+ "tooltip.orbit-camera": "오빗 카메라",
78027
+ "tooltip.fly-camera": "플라이 카메라",
78028
+ "tooltip.walk-mode": "워크 모드",
78029
+ "tooltip.reset-camera": "카메라 재설정",
78030
+ "tooltip.frame-scene": "씬에 맞춤",
78031
+ "tooltip.show-collision": "충돌 표시",
78032
+ "tooltip.settings": "설정",
78033
+ "tooltip.help": "도움말",
78034
+ "tooltip.enter-ar": "AR 시작",
78035
+ "tooltip.enter-vr": "VR 시작",
78036
+ "tooltip.fullscreen": "전체 화면",
78037
+ "help.tab.desktop": "데스크톱",
78038
+ "help.tab.touch": "터치",
78039
+ "help.section.orbit": "오빗 모드",
78040
+ "help.section.fly": "플라이 모드",
78041
+ "help.section.walk": "워크 모드",
78042
+ "help.section.modes": "모드 전환",
78043
+ "help.action.orbit": "오빗",
78044
+ "help.action.pan": "팬",
78045
+ "help.action.zoom": "줌",
78046
+ "help.action.set-focus": "포커스 설정",
78047
+ "help.action.fly-to": "비행",
78048
+ "help.action.fly-to-point": "지점으로 비행",
78049
+ "help.action.walk-to": "걷기",
78050
+ "help.action.look-around": "둘러보기",
78051
+ "help.action.move": "이동",
78052
+ "help.action.vertical": "수직",
78053
+ "help.action.jump": "점프",
78054
+ "help.action.run-slow": "달리기 / 천천히",
78055
+ "help.action.focus-point": "포커스 포인트",
78056
+ "help.action.frame-scene": "씬에 맞춤",
78057
+ "help.action.reset-camera": "카메라 재설정",
78058
+ "help.action.orbit-mode": "오빗 모드",
78059
+ "help.action.fly-mode": "플라이 모드",
78060
+ "help.action.toggle-walk": "워크 전환",
78061
+ "help.action.toggle-gaming": "게임 컨트롤 전환",
78062
+ "help.action.show-collision": "충돌 표시",
78063
+ "help.action.play-pause": "재생 / 일시 정지",
78064
+ "help.action.toggle-help": "도움말 전환",
78065
+ "help.action.exit-cancel": "나가기 / 취소",
78066
+ "help.key.left-click": "왼쪽 클릭",
78067
+ "help.key.left-click-drag": "왼쪽 클릭 + 드래그",
78068
+ "help.key.right-click-drag": "오른쪽 클릭 + 드래그",
78069
+ "help.key.mouse-wheel": "마우스 휠",
78070
+ "help.key.mouse": "마우스",
78071
+ "help.key.double-click": "더블 클릭",
78072
+ "help.key.double-tap": "더블 탭",
78073
+ "help.key.tap": "탭",
78074
+ "help.key.touch-drag": "터치 + 드래그",
78075
+ "help.key.one-finger-drag": "한 손가락 드래그",
78076
+ "help.key.two-finger-drag": "두 손가락 드래그",
78077
+ "help.key.pinch": "핀치",
78078
+ "help.key.pinch-two-finger": "핀치 / 두 손가락 드래그",
78079
+ "help.key.joystick": "조이스틱",
78080
+ "help.key.shift-ctrl": "Shift / Ctrl",
78081
+ "help.key.space": "스페이스",
78082
+ "help.key.esc": "Esc",
78083
+ "xr-modal.title": "WebGL 필요",
78084
+ "xr-modal.message": "AR과 VR은 WebGPU 렌더러에서 지원되지 않습니다. 확인을 누르면 WebGL로 뷰어를 다시 불러옵니다.",
78085
+ "xr-modal.cancel": "취소",
78086
+ "xr-modal.ok": "확인",
78087
+ "walk-hint.desktop": "클릭하여 걷기. WASD로 자유롭게 이동.",
78088
+ "walk-hint.touch-tap": "탭하여 걷기. 드래그하여 둘러보기.",
78089
+ "walk-hint.touch-gaming": "조이스틱으로 이동. 드래그하여 둘러보기. 탭하여 점프."
78090
+ };
78091
+
78092
+ var ptBRJson = {
78093
+ "settings.performance-mode": "Modo de desempenho",
78094
+ "settings.gaming-controls": "Controles de jogo",
78095
+ "settings.frame": "Enquadrar",
78096
+ "settings.reset": "Redefinir",
78097
+ "tooltip.play": "Reproduzir",
78098
+ "tooltip.pause": "Pausar",
78099
+ "tooltip.orbit-camera": "Câmera orbital",
78100
+ "tooltip.fly-camera": "Câmera de voo",
78101
+ "tooltip.walk-mode": "Modo caminhar",
78102
+ "tooltip.reset-camera": "Redefinir câmera",
78103
+ "tooltip.frame-scene": "Enquadrar cena",
78104
+ "tooltip.show-collision": "Mostrar colisão",
78105
+ "tooltip.settings": "Configurações",
78106
+ "tooltip.help": "Ajuda",
78107
+ "tooltip.enter-ar": "Entrar em AR",
78108
+ "tooltip.enter-vr": "Entrar em VR",
78109
+ "tooltip.fullscreen": "Tela cheia",
78110
+ "help.tab.desktop": "Desktop",
78111
+ "help.tab.touch": "Toque",
78112
+ "help.section.orbit": "Modo orbital",
78113
+ "help.section.fly": "Modo voo",
78114
+ "help.section.walk": "Modo caminhar",
78115
+ "help.section.modes": "Troca de modo",
78116
+ "help.action.orbit": "Orbitar",
78117
+ "help.action.pan": "Deslocar",
78118
+ "help.action.zoom": "Zoom",
78119
+ "help.action.set-focus": "Definir foco",
78120
+ "help.action.fly-to": "Voar para",
78121
+ "help.action.fly-to-point": "Voar até o ponto",
78122
+ "help.action.walk-to": "Caminhar para",
78123
+ "help.action.look-around": "Olhar em volta",
78124
+ "help.action.move": "Mover",
78125
+ "help.action.vertical": "Vertical",
78126
+ "help.action.jump": "Pular",
78127
+ "help.action.run-slow": "Correr / Devagar",
78128
+ "help.action.focus-point": "Ponto focal",
78129
+ "help.action.frame-scene": "Enquadrar cena",
78130
+ "help.action.reset-camera": "Redefinir câmera",
78131
+ "help.action.orbit-mode": "Modo orbital",
78132
+ "help.action.fly-mode": "Modo voo",
78133
+ "help.action.toggle-walk": "Alternar caminhar",
78134
+ "help.action.toggle-gaming": "Alternar controles de jogo",
78135
+ "help.action.show-collision": "Mostrar colisão",
78136
+ "help.action.play-pause": "Reproduzir / Pausar",
78137
+ "help.action.toggle-help": "Alternar ajuda",
78138
+ "help.action.exit-cancel": "Sair / Cancelar",
78139
+ "help.key.left-click": "Clique esquerdo",
78140
+ "help.key.left-click-drag": "Clique esquerdo + arrastar",
78141
+ "help.key.right-click-drag": "Clique direito + arrastar",
78142
+ "help.key.mouse-wheel": "Roda do mouse",
78143
+ "help.key.mouse": "Mouse",
78144
+ "help.key.double-click": "Clique duplo",
78145
+ "help.key.double-tap": "Toque duplo",
78146
+ "help.key.tap": "Toque",
78147
+ "help.key.touch-drag": "Toque + arrastar",
78148
+ "help.key.one-finger-drag": "Arrastar com um dedo",
78149
+ "help.key.two-finger-drag": "Arrastar com dois dedos",
78150
+ "help.key.pinch": "Pinçar",
78151
+ "help.key.pinch-two-finger": "Pinçar / Arrastar com dois dedos",
78152
+ "help.key.joystick": "Joystick",
78153
+ "help.key.shift-ctrl": "Shift / Ctrl",
78154
+ "help.key.space": "Espaço",
78155
+ "help.key.esc": "Esc",
78156
+ "xr-modal.title": "WebGL necessário",
78157
+ "xr-modal.message": "AR e VR não são compatíveis com o renderizador WebGPU. Ao pressionar OK, o visualizador será recarregado com WebGL.",
78158
+ "xr-modal.cancel": "Cancelar",
78159
+ "xr-modal.ok": "OK",
78160
+ "walk-hint.desktop": "Clique para caminhar. WASD para se mover livremente.",
78161
+ "walk-hint.touch-tap": "Toque para caminhar. Arraste para olhar em volta.",
78162
+ "walk-hint.touch-gaming": "Use o joystick para se mover. Arraste para olhar. Toque para pular."
78163
+ };
78164
+
78165
+ var ruJson = {
78166
+ "settings.performance-mode": "Режим производительности",
78167
+ "settings.gaming-controls": "Игровое управление",
78168
+ "settings.frame": "Кадрировать",
78169
+ "settings.reset": "Сбросить",
78170
+ "tooltip.play": "Воспроизвести",
78171
+ "tooltip.pause": "Пауза",
78172
+ "tooltip.orbit-camera": "Орбитальная камера",
78173
+ "tooltip.fly-camera": "Полётная камера",
78174
+ "tooltip.walk-mode": "Режим ходьбы",
78175
+ "tooltip.reset-camera": "Сбросить камеру",
78176
+ "tooltip.frame-scene": "Кадрировать сцену",
78177
+ "tooltip.show-collision": "Показать коллизию",
78178
+ "tooltip.settings": "Настройки",
78179
+ "tooltip.help": "Справка",
78180
+ "tooltip.enter-ar": "Войти в AR",
78181
+ "tooltip.enter-vr": "Войти в VR",
78182
+ "tooltip.fullscreen": "Полный экран",
78183
+ "help.tab.desktop": "Десктоп",
78184
+ "help.tab.touch": "Сенсор",
78185
+ "help.section.orbit": "Орбитальный режим",
78186
+ "help.section.fly": "Режим полёта",
78187
+ "help.section.walk": "Режим ходьбы",
78188
+ "help.section.modes": "Смена режимов",
78189
+ "help.action.orbit": "Вращение",
78190
+ "help.action.pan": "Панорама",
78191
+ "help.action.zoom": "Масштаб",
78192
+ "help.action.set-focus": "Задать фокус",
78193
+ "help.action.fly-to": "Лететь к",
78194
+ "help.action.fly-to-point": "Лететь к точке",
78195
+ "help.action.walk-to": "Идти к",
78196
+ "help.action.look-around": "Осмотреться",
78197
+ "help.action.move": "Движение",
78198
+ "help.action.vertical": "Вертикально",
78199
+ "help.action.jump": "Прыжок",
78200
+ "help.action.run-slow": "Бег / Медленно",
78201
+ "help.action.focus-point": "Точка фокуса",
78202
+ "help.action.frame-scene": "Кадрировать сцену",
78203
+ "help.action.reset-camera": "Сбросить камеру",
78204
+ "help.action.orbit-mode": "Орбитальный режим",
78205
+ "help.action.fly-mode": "Режим полёта",
78206
+ "help.action.toggle-walk": "Переключить ходьбу",
78207
+ "help.action.toggle-gaming": "Переключить игровое управление",
78208
+ "help.action.show-collision": "Показать коллизию",
78209
+ "help.action.play-pause": "Воспроизведение / Пауза",
78210
+ "help.action.toggle-help": "Переключить справку",
78211
+ "help.action.exit-cancel": "Выход / Отмена",
78212
+ "help.key.left-click": "Левый клик",
78213
+ "help.key.left-click-drag": "Левый клик + перетаскивание",
78214
+ "help.key.right-click-drag": "Правый клик + перетаскивание",
78215
+ "help.key.mouse-wheel": "Колесо мыши",
78216
+ "help.key.mouse": "Мышь",
78217
+ "help.key.double-click": "Двойной клик",
78218
+ "help.key.double-tap": "Двойной тап",
78219
+ "help.key.tap": "Тап",
78220
+ "help.key.touch-drag": "Касание + перетаскивание",
78221
+ "help.key.one-finger-drag": "Перетаскивание одним пальцем",
78222
+ "help.key.two-finger-drag": "Перетаскивание двумя пальцами",
78223
+ "help.key.pinch": "Щипок",
78224
+ "help.key.pinch-two-finger": "Щипок / Перетаскивание двумя пальцами",
78225
+ "help.key.joystick": "Джойстик",
78226
+ "help.key.shift-ctrl": "Shift / Ctrl",
78227
+ "help.key.space": "Пробел",
78228
+ "help.key.esc": "Esc",
78229
+ "xr-modal.title": "Требуется WebGL",
78230
+ "xr-modal.message": "AR и VR не поддерживаются рендером WebGPU. Нажмите OK, чтобы перезагрузить просмотрщик с WebGL.",
78231
+ "xr-modal.cancel": "Отмена",
78232
+ "xr-modal.ok": "OK",
78233
+ "walk-hint.desktop": "Кликните для ходьбы. WASD для свободного движения.",
78234
+ "walk-hint.touch-tap": "Тапните для ходьбы. Перетаскивайте, чтобы осмотреться.",
78235
+ "walk-hint.touch-gaming": "Используйте джойстик для движения. Перетаскивайте, чтобы осмотреться. Тапните для прыжка."
78236
+ };
78237
+
78238
+ var zhCNJson = {
78239
+ "settings.performance-mode": "性能模式",
78240
+ "settings.gaming-controls": "游戏控制",
78241
+ "settings.frame": "适应",
78242
+ "settings.reset": "重置",
78243
+ "tooltip.play": "播放",
78244
+ "tooltip.pause": "暂停",
78245
+ "tooltip.orbit-camera": "环绕相机",
78246
+ "tooltip.fly-camera": "飞行相机",
78247
+ "tooltip.walk-mode": "行走模式",
78248
+ "tooltip.reset-camera": "重置相机",
78249
+ "tooltip.frame-scene": "适应场景",
78250
+ "tooltip.show-collision": "显示碰撞",
78251
+ "tooltip.settings": "设置",
78252
+ "tooltip.help": "帮助",
78253
+ "tooltip.enter-ar": "进入 AR",
78254
+ "tooltip.enter-vr": "进入 VR",
78255
+ "tooltip.fullscreen": "全屏",
78256
+ "help.tab.desktop": "桌面",
78257
+ "help.tab.touch": "触屏",
78258
+ "help.section.orbit": "环绕模式",
78259
+ "help.section.fly": "飞行模式",
78260
+ "help.section.walk": "行走模式",
78261
+ "help.section.modes": "模式切换",
78262
+ "help.action.orbit": "环绕",
78263
+ "help.action.pan": "平移",
78264
+ "help.action.zoom": "缩放",
78265
+ "help.action.set-focus": "设置焦点",
78266
+ "help.action.fly-to": "飞至",
78267
+ "help.action.fly-to-point": "飞至该点",
78268
+ "help.action.walk-to": "走到",
78269
+ "help.action.look-around": "环顾",
78270
+ "help.action.move": "移动",
78271
+ "help.action.vertical": "垂直",
78272
+ "help.action.jump": "跳跃",
78273
+ "help.action.run-slow": "奔跑 / 慢走",
78274
+ "help.action.focus-point": "焦点",
78275
+ "help.action.frame-scene": "适应场景",
78276
+ "help.action.reset-camera": "重置相机",
78277
+ "help.action.orbit-mode": "环绕模式",
78278
+ "help.action.fly-mode": "飞行模式",
78279
+ "help.action.toggle-walk": "切换行走",
78280
+ "help.action.toggle-gaming": "切换游戏控制",
78281
+ "help.action.show-collision": "显示碰撞",
78282
+ "help.action.play-pause": "播放 / 暂停",
78283
+ "help.action.toggle-help": "切换帮助",
78284
+ "help.action.exit-cancel": "退出 / 取消",
78285
+ "help.key.left-click": "左键点击",
78286
+ "help.key.left-click-drag": "左键点击 + 拖动",
78287
+ "help.key.right-click-drag": "右键点击 + 拖动",
78288
+ "help.key.mouse-wheel": "鼠标滚轮",
78289
+ "help.key.mouse": "鼠标",
78290
+ "help.key.double-click": "双击",
78291
+ "help.key.double-tap": "双击",
78292
+ "help.key.tap": "点击",
78293
+ "help.key.touch-drag": "触摸 + 拖动",
78294
+ "help.key.one-finger-drag": "单指拖动",
78295
+ "help.key.two-finger-drag": "双指拖动",
78296
+ "help.key.pinch": "捏合",
78297
+ "help.key.pinch-two-finger": "捏合 / 双指拖动",
78298
+ "help.key.joystick": "摇杆",
78299
+ "help.key.shift-ctrl": "Shift / Ctrl",
78300
+ "help.key.space": "空格",
78301
+ "help.key.esc": "Esc",
78302
+ "xr-modal.title": "需要 WebGL",
78303
+ "xr-modal.message": "WebGPU 渲染器不支持 AR 和 VR。按下确定将以 WebGL 重新加载查看器。",
78304
+ "xr-modal.cancel": "取消",
78305
+ "xr-modal.ok": "确定",
78306
+ "walk-hint.desktop": "点击行走。WASD 自由移动。",
78307
+ "walk-hint.touch-tap": "点击行走。拖动环顾四周。",
78308
+ "walk-hint.touch-gaming": "使用摇杆移动。拖动环顾四周。点击跳跃。"
78309
+ };
78310
+
78311
+ const en = enJson;
78312
+ const dictionaries = {
78313
+ de: deJson,
78314
+ en,
78315
+ es: esJson,
78316
+ fr: frJson,
78317
+ ja: jaJson,
78318
+ ko: koJson,
78319
+ 'pt-BR': ptBRJson,
78320
+ ru: ruJson,
78321
+ 'zh-CN': zhCNJson
78322
+ };
78323
+ let current = en;
78324
+ const detectLocale = () => {
78325
+ const candidates = [
78326
+ new URLSearchParams(location.search).get('lang'),
78327
+ ...(navigator.languages ?? [navigator.language])
78328
+ ];
78329
+ const keys = Object.keys(dictionaries);
78330
+ for (const c of candidates) {
78331
+ if (!c)
78332
+ continue;
78333
+ const lc = c.toLowerCase();
78334
+ const base = lc.split('-')[0];
78335
+ // 1. exact tag match (case-insensitive: "DE" → "de", "pt-br" → "pt-BR")
78336
+ // 2. base-language match ("fr-CA" → "fr")
78337
+ // 3. any region variant sharing the base ("pt" → "pt-BR", "zh" → "zh-CN")
78338
+ const match = keys.find(k => k.toLowerCase() === lc) ??
78339
+ keys.find(k => k.toLowerCase() === base) ??
78340
+ keys.find(k => k.toLowerCase().split('-')[0] === base);
78341
+ if (match)
78342
+ return match;
78343
+ }
78344
+ return 'en';
78345
+ };
78346
+ // Look up a key in the active locale, falling back to English, then the key
78347
+ // itself so missing translations are visible rather than blank.
78348
+ const localize = (key) => current[key] ?? en[key] ?? key;
78349
+ // Detect the preferred locale and replace the text of every `[data-i18n]`
78350
+ // element with its translation. Call once after the DOM is parsed and before
78351
+ // any code reads localized strings.
78352
+ const initLocalization = () => {
78353
+ const locale = detectLocale();
78354
+ current = dictionaries[locale];
78355
+ document.documentElement.lang = locale;
78356
+ document.querySelectorAll('[data-i18n]').forEach((el) => {
78357
+ el.textContent = localize(el.dataset.i18n);
78358
+ });
78359
+ };
78360
+
77615
78361
  const migrateV1 = (settings) => {
77616
78362
  if (settings.animTracks) {
77617
78363
  settings.animTracks?.forEach((track) => {
@@ -77723,7 +78469,7 @@ const importSettings = (settings) => {
77723
78469
  return result;
77724
78470
  };
77725
78471
 
77726
- var version = "1.24.1";
78472
+ var version = "1.26.0";
77727
78473
 
77728
78474
  class Tooltip {
77729
78475
  register;
@@ -78016,7 +78762,8 @@ const initUI = (global) => {
78016
78762
  'showCollision', 'desktopShowCollisionHelp',
78017
78763
  'tooltip',
78018
78764
  'annotationNav', 'annotationPrev', 'annotationNext', 'annotationInfo', 'annotationNavTitle',
78019
- 'viewerBranding', 'viewerTitle', 'appVersionLabel'
78765
+ 'viewerBranding', 'viewerTitle', 'appVersionLabel',
78766
+ 'xrModal', 'xrModalOk', 'xrModalCancel'
78020
78767
  ].reduce((acc, id) => {
78021
78768
  acc[id] = document.getElementById(id);
78022
78769
  return acc;
@@ -78142,8 +78889,30 @@ const initUI = (global) => {
78142
78889
  // AR/VR
78143
78890
  const arChanged = () => dom.arMode.classList[state.hasAR ? 'remove' : 'add']('hidden');
78144
78891
  const vrChanged = () => dom.vrMode.classList[state.hasVR ? 'remove' : 'add']('hidden');
78145
- dom.arMode.addEventListener('click', () => events.fire('startAR'));
78146
- dom.vrMode.addEventListener('click', () => events.fire('startVR'));
78892
+ // XR sessions require a WebGL device. Under WebGPU, prompt the user to reload
78893
+ // the viewer with the WebGL renderer before starting AR/VR. Use replace() so
78894
+ // the renderer-switch reload doesn't add a back-button entry — important
78895
+ // because the viewer often runs inside an iframe (e.g. superspl.at /scene).
78896
+ const reloadWithWebgl = () => {
78897
+ const reloadUrl = new URL(location.href);
78898
+ reloadUrl.searchParams.set('webgl', '');
78899
+ location.replace(reloadUrl.toString());
78900
+ };
78901
+ const showXrModal = () => dom.xrModal.classList.remove('hidden');
78902
+ const hideXrModal = () => dom.xrModal.classList.add('hidden');
78903
+ dom.xrModalOk.addEventListener('click', reloadWithWebgl);
78904
+ dom.xrModalCancel.addEventListener('click', hideXrModal);
78905
+ dom.xrModal.addEventListener('pointerdown', hideXrModal);
78906
+ const handleXrClick = (type) => {
78907
+ if (global.renderer !== 'webgl') {
78908
+ showXrModal();
78909
+ }
78910
+ else {
78911
+ events.fire(type === 'AR' ? 'startAR' : 'startVR');
78912
+ }
78913
+ };
78914
+ dom.arMode.addEventListener('click', () => handleXrClick('AR'));
78915
+ dom.vrMode.addEventListener('click', () => handleXrClick('VR'));
78147
78916
  events.on('hasAR:changed', arChanged);
78148
78917
  events.on('hasVR:changed', vrChanged);
78149
78918
  arChanged();
@@ -78337,11 +79106,9 @@ const initUI = (global) => {
78337
79106
  let walkHintShown = false;
78338
79107
  const getWalkHintText = () => {
78339
79108
  if (state.inputMode === 'desktop') {
78340
- return 'Click to walk. WASD to move freely.';
79109
+ return localize('walk-hint.desktop');
78341
79110
  }
78342
- return state.gamingControls ?
78343
- 'Use the joystick to move. Drag to look around. Tap to jump.' :
78344
- 'Tap to walk. Drag to look around.';
79111
+ return localize(state.gamingControls ? 'walk-hint.touch-gaming' : 'walk-hint.touch-tap');
78345
79112
  };
78346
79113
  events.on('cameraMode:changed', (value) => {
78347
79114
  if (value === 'walk' && !walkHintShown && !isPointerCapturedMode()) {
@@ -78406,20 +79173,20 @@ const initUI = (global) => {
78406
79173
  }
78407
79174
  // tooltips
78408
79175
  const tooltip = new Tooltip(dom.tooltip);
78409
- tooltip.register(dom.play, 'Play', 'top');
78410
- tooltip.register(dom.pause, 'Pause', 'top');
78411
- tooltip.register(dom.orbitCamera, 'Orbit Camera', 'top');
78412
- tooltip.register(dom.flyCamera, 'Fly Camera', 'top');
78413
- tooltip.register(dom.fpsCamera, 'Walk Mode', 'top');
78414
- tooltip.register(dom.reset, 'Reset Camera', 'bottom');
78415
- tooltip.register(dom.frame, 'Frame Scene', 'bottom');
78416
- tooltip.register(dom.showCollision, 'Show Collision', 'top');
78417
- tooltip.register(dom.settings, 'Settings', 'top');
78418
- tooltip.register(dom.info, 'Help', 'top');
78419
- tooltip.register(dom.arMode, 'Enter AR', 'top');
78420
- tooltip.register(dom.vrMode, 'Enter VR', 'top');
78421
- tooltip.register(dom.enterFullscreen, 'Fullscreen', 'top');
78422
- tooltip.register(dom.exitFullscreen, 'Fullscreen', 'top');
79176
+ tooltip.register(dom.play, localize('tooltip.play'), 'top');
79177
+ tooltip.register(dom.pause, localize('tooltip.pause'), 'top');
79178
+ tooltip.register(dom.orbitCamera, localize('tooltip.orbit-camera'), 'top');
79179
+ tooltip.register(dom.flyCamera, localize('tooltip.fly-camera'), 'top');
79180
+ tooltip.register(dom.fpsCamera, localize('tooltip.walk-mode'), 'top');
79181
+ tooltip.register(dom.reset, localize('tooltip.reset-camera'), 'bottom');
79182
+ tooltip.register(dom.frame, localize('tooltip.frame-scene'), 'bottom');
79183
+ tooltip.register(dom.showCollision, localize('tooltip.show-collision'), 'top');
79184
+ tooltip.register(dom.settings, localize('tooltip.settings'), 'top');
79185
+ tooltip.register(dom.info, localize('tooltip.help'), 'top');
79186
+ tooltip.register(dom.arMode, localize('tooltip.enter-ar'), 'top');
79187
+ tooltip.register(dom.vrMode, localize('tooltip.enter-vr'), 'top');
79188
+ tooltip.register(dom.enterFullscreen, localize('tooltip.fullscreen'), 'top');
79189
+ tooltip.register(dom.exitFullscreen, localize('tooltip.fullscreen'), 'top');
78423
79190
  const isThirdPartyEmbedded = () => {
78424
79191
  try {
78425
79192
  return window.location.hostname !== window.parent.location.hostname;
@@ -79150,6 +79917,161 @@ const createRotateTrack = (position, target, fov, keys = 12, duration = 20) => {
79150
79917
  };
79151
79918
  };
79152
79919
 
79920
+ /**
79921
+ * Damping function to smooth out transitions.
79922
+ *
79923
+ * @param damping - Damping factor (0 < damping < 1).
79924
+ * @param dt - Delta time in seconds.
79925
+ * @returns - Damping factor adjusted for the delta time.
79926
+ */
79927
+ const damp = (damping, dt) => 1 - Math.pow(damping, dt * 1000);
79928
+ /**
79929
+ * Easing function for smooth transitions.
79930
+ *
79931
+ * @param x - Input value in the range [0, 1].
79932
+ * @returns - Output value in the range [0, 1].
79933
+ */
79934
+ const easeOut = (x) => (1 - (2 ** (-10 * x))) / (1 - (2 ** -10));
79935
+ /**
79936
+ * Modulus function that handles negative values correctly.
79937
+ *
79938
+ * @param n - The number to be modulated.
79939
+ * @param m - The modulus value.
79940
+ * @returns - The result of n mod m, adjusted to be non-negative.
79941
+ */
79942
+ const mod = (n, m) => ((n % m) + m) % m;
79943
+ const nearlyEquals = (a, b, epsilon = 1e-4) => {
79944
+ return !a.some((v, i) => Math.abs(v - b[i]) >= epsilon);
79945
+ };
79946
+ const vecToAngles = (result, vec) => {
79947
+ const radToDeg = 180 / Math.PI;
79948
+ const horizLenSq = vec.x * vec.x + vec.z * vec.z;
79949
+ result.x = Math.asin(Math.max(-1, Math.min(1, vec.y))) * radToDeg;
79950
+ result.y = horizLenSq > 1e-8 ? Math.atan2(-vec.x, -vec.z) * radToDeg : 0;
79951
+ result.z = 0;
79952
+ return result;
79953
+ };
79954
+
79955
+ /**
79956
+ * Shared damping factor for controller smoothing (rotate / move / zoom) so
79957
+ * orbit, fly, and walk feel the same. Used as `damp(damping, dt)` →
79958
+ * `1 - damping^(dt*1000)`. Higher means smoother / more lag. Not used for
79959
+ * physics-style velocity decay (e.g. walk's grounded/air velocity damping),
79960
+ * which has different tuning needs.
79961
+ */
79962
+ const DEFAULT_CONTROLLER_DAMPING = 0.95;
79963
+ const rotation$1 = new Quat();
79964
+ /**
79965
+ * Apply a CameraFrame rotate delta to camera Euler angles.
79966
+ *
79967
+ * CameraFrame rotate uses [yaw, pitch, roll]-style input deltas, while camera
79968
+ * angles are stored as [pitch, yaw, roll].
79969
+ *
79970
+ * @param angles - Camera Euler angles to mutate.
79971
+ * @param rotate - Frame rotate delta.
79972
+ * @param minPitch - Minimum pitch angle in degrees.
79973
+ * @param maxPitch - Maximum pitch angle in degrees.
79974
+ * @returns The mutated angles.
79975
+ */
79976
+ const applyFrameRotation = (angles, rotate, minPitch = -90, maxPitch = 90) => {
79977
+ angles.x -= rotate[1];
79978
+ angles.y -= rotate[0];
79979
+ angles.z = 0;
79980
+ angles.x = math.clamp(angles.x, minPitch, maxPitch);
79981
+ return angles;
79982
+ };
79983
+ /**
79984
+ * Calculate camera-relative basis vectors from Euler angles.
79985
+ *
79986
+ * @param angles - Camera Euler angles in degrees.
79987
+ * @param forward - Receives the forward vector.
79988
+ * @param right - Receives the right vector.
79989
+ * @param up - Receives the up vector.
79990
+ */
79991
+ const setCameraBasis = (angles, forward, right, up) => {
79992
+ rotation$1.setFromEulerAngles(angles);
79993
+ rotation$1.transformVector(Vec3.FORWARD, forward);
79994
+ rotation$1.transformVector(Vec3.RIGHT, right);
79995
+ rotation$1.transformVector(Vec3.UP, up);
79996
+ };
79997
+ /**
79998
+ * Calculate a camera forward vector from Euler angles.
79999
+ *
80000
+ * @param angles - Camera Euler angles in degrees.
80001
+ * @param forward - Receives the forward vector.
80002
+ */
80003
+ const setCameraForward = (angles, forward) => {
80004
+ rotation$1.setFromEulerAngles(angles);
80005
+ rotation$1.transformVector(Vec3.FORWARD, forward);
80006
+ };
80007
+ /**
80008
+ * Calculate yaw-only movement basis vectors.
80009
+ *
80010
+ * @param yaw - Camera yaw angle in degrees.
80011
+ * @param forward - Receives the horizontal forward vector.
80012
+ * @param right - Receives the horizontal right vector.
80013
+ */
80014
+ const setYawBasis = (yaw, forward, right) => {
80015
+ rotation$1.setFromEulerAngles(0, yaw, 0);
80016
+ rotation$1.transformVector(Vec3.FORWARD, forward);
80017
+ rotation$1.transformVector(Vec3.RIGHT, right);
80018
+ };
80019
+ /**
80020
+ * Build a world-space offset from local movement along camera basis vectors.
80021
+ *
80022
+ * @param out - Receives the world-space offset.
80023
+ * @param x - Local right movement.
80024
+ * @param y - Local up movement.
80025
+ * @param z - Local forward movement.
80026
+ * @param forward - Forward basis vector.
80027
+ * @param right - Right basis vector.
80028
+ * @param up - Up basis vector.
80029
+ * @returns The mutated output vector.
80030
+ */
80031
+ const setBasisOffset = (out, x, y, z, forward, right, up) => {
80032
+ out.set(right.x * x + up.x * y + forward.x * z, right.y * x + up.y * y + forward.y * z, right.z * x + up.z * y + forward.z * z);
80033
+ return out;
80034
+ };
80035
+ /**
80036
+ * Lerp Euler angles toward a target using frame-rate-independent shortest-path
80037
+ * interpolation. Yaw/roll on both `angles` and `target` are wrapped into
80038
+ * `[0, 360)` so `lerpAngle`'s single-shift shortest-path stays valid after
80039
+ * many full rotations (otherwise the camera takes the long way around). Pitch
80040
+ * is left untouched since callers clamp it.
80041
+ *
80042
+ * @param angles - Current angles, mutated toward target.
80043
+ * @param target - Target angles. Yaw/roll are wrapped in place to keep
80044
+ * accumulated drift bounded across frames.
80045
+ * @param damping - Damping factor in [0, 1]. Higher = smoother (1 = never moves).
80046
+ * @param dt - Delta time in seconds.
80047
+ * @returns The mutated angles.
80048
+ */
80049
+ const dampAngles = (angles, target, damping, dt) => {
80050
+ if (dt <= 0) {
80051
+ return angles;
80052
+ }
80053
+ const t = damp(damping, dt);
80054
+ angles.y = mod(angles.y, 360);
80055
+ angles.z = mod(angles.z, 360);
80056
+ target.y = mod(target.y, 360);
80057
+ target.z = mod(target.z, 360);
80058
+ angles.x = math.lerpAngle(angles.x, target.x, t);
80059
+ angles.y = math.lerpAngle(angles.y, target.y, t);
80060
+ angles.z = math.lerpAngle(angles.z, target.z, t);
80061
+ return angles;
80062
+ };
80063
+ /**
80064
+ * Discard any pending input deltas in the frame. `InputFrame.read()` zeros
80065
+ * deltas as a side-effect of reading, so calling this prevents accumulated
80066
+ * input from leaking into the next controller when a non-input-driven mode
80067
+ * (e.g. animation) is active.
80068
+ *
80069
+ * @param frame - The camera frame whose deltas should be drained.
80070
+ */
80071
+ const drainInputFrame = (frame) => {
80072
+ frame.read();
80073
+ };
80074
+
79153
80075
  class CubicSpline {
79154
80076
  // control times
79155
80077
  times;
@@ -79261,41 +80183,6 @@ class CubicSpline {
79261
80183
  }
79262
80184
  }
79263
80185
 
79264
- /**
79265
- * Damping function to smooth out transitions.
79266
- *
79267
- * @param damping - Damping factor (0 < damping < 1).
79268
- * @param dt - Delta time in seconds.
79269
- * @returns - Damping factor adjusted for the delta time.
79270
- */
79271
- const damp = (damping, dt) => 1 - Math.pow(damping, dt * 1000);
79272
- /**
79273
- * Easing function for smooth transitions.
79274
- *
79275
- * @param x - Input value in the range [0, 1].
79276
- * @returns - Output value in the range [0, 1].
79277
- */
79278
- const easeOut = (x) => (1 - (2 ** (-10 * x))) / (1 - (2 ** -10));
79279
- /**
79280
- * Modulus function that handles negative values correctly.
79281
- *
79282
- * @param n - The number to be modulated.
79283
- * @param m - The modulus value.
79284
- * @returns - The result of n mod m, adjusted to be non-negative.
79285
- */
79286
- const mod = (n, m) => ((n % m) + m) % m;
79287
- const nearlyEquals = (a, b, epsilon = 1e-4) => {
79288
- return !a.some((v, i) => Math.abs(v - b[i]) >= epsilon);
79289
- };
79290
- const vecToAngles = (result, vec) => {
79291
- const radToDeg = 180 / Math.PI;
79292
- const horizLenSq = vec.x * vec.x + vec.z * vec.z;
79293
- result.x = Math.asin(Math.max(-1, Math.min(1, vec.y))) * radToDeg;
79294
- result.y = horizLenSq > 1e-8 ? Math.atan2(-vec.x, -vec.z) * radToDeg : 0;
79295
- result.z = 0;
79296
- return result;
79297
- };
79298
-
79299
80186
  // track an animation cursor with support for repeat and ping-pong loop modes
79300
80187
  class AnimCursor {
79301
80188
  duration = 0;
@@ -79397,13 +80284,13 @@ class AnimController {
79397
80284
  this.animState.update(deltaTime);
79398
80285
  camera.look(this.animState.position, this.animState.target);
79399
80286
  camera.fov = this.animState.fov;
79400
- inputFrame.read();
80287
+ drainInputFrame(inputFrame);
79401
80288
  }
79402
80289
  onExit(camera) {
79403
80290
  }
79404
80291
  }
79405
80292
 
79406
- const rotation$1 = new Quat();
80293
+ const rotation = new Quat();
79407
80294
  const avec = new Vec3();
79408
80295
  const bvec = new Vec3();
79409
80296
  class Camera {
@@ -79438,88 +80325,72 @@ class Camera {
79438
80325
  vecToAngles(this.angles, dir);
79439
80326
  }
79440
80327
  calcFocusPoint(result) {
79441
- rotation$1.setFromEulerAngles(this.angles)
80328
+ rotation.setFromEulerAngles(this.angles)
79442
80329
  .transformVector(Vec3.FORWARD, result)
79443
80330
  .mulScalar(this.distance)
79444
80331
  .add(this.position);
79445
80332
  }
79446
80333
  }
79447
80334
 
79448
- const rotation = new Quat();
79449
80335
  /**
79450
- * Apply a CameraFrame rotate delta to camera Euler angles.
80336
+ * Captures a controller's pose at its initial spawn so it can be restored
80337
+ * later (e.g. via the "reset" UI gesture). Shared by fly and walk controllers
80338
+ * which both implement `resetToSpawn`.
79451
80339
  *
79452
- * CameraFrame rotate uses [yaw, pitch, roll]-style input deltas, while camera
79453
- * angles are stored as [pitch, yaw, roll].
79454
- *
79455
- * @param angles - Camera Euler angles to mutate.
79456
- * @param rotate - Frame rotate delta.
79457
- * @param minPitch - Minimum pitch angle in degrees.
79458
- * @param maxPitch - Maximum pitch angle in degrees.
79459
- * @returns The mutated angles.
79460
- */
79461
- const applyFrameRotation = (angles, rotate, minPitch = -90, maxPitch = 90) => {
79462
- angles.x -= rotate[1];
79463
- angles.y -= rotate[0];
79464
- angles.z = 0;
79465
- angles.x = math.clamp(angles.x, minPitch, maxPitch);
79466
- return angles;
79467
- };
79468
- /**
79469
- * Calculate camera-relative basis vectors from Euler angles.
79470
- *
79471
- * @param angles - Camera Euler angles in degrees.
79472
- * @param forward - Receives the forward vector.
79473
- * @param right - Receives the right vector.
79474
- * @param up - Receives the up vector.
80340
+ * Position / angles / distance are the basic camera-pose components. Callers
80341
+ * with extra controller-specific state (e.g. walk's grounded flag) keep that
80342
+ * alongside as a separate field.
79475
80343
  */
79476
- const setCameraBasis = (angles, forward, right, up) => {
79477
- rotation.setFromEulerAngles(angles);
79478
- rotation.transformVector(Vec3.FORWARD, forward);
79479
- rotation.transformVector(Vec3.RIGHT, right);
79480
- rotation.transformVector(Vec3.UP, up);
79481
- };
79482
- /**
79483
- * Calculate a camera forward vector from Euler angles.
79484
- *
79485
- * @param angles - Camera Euler angles in degrees.
79486
- * @param forward - Receives the forward vector.
79487
- */
79488
- const setCameraForward = (angles, forward) => {
79489
- rotation.setFromEulerAngles(angles);
79490
- rotation.transformVector(Vec3.FORWARD, forward);
79491
- };
79492
- /**
79493
- * Calculate yaw-only movement basis vectors.
79494
- *
79495
- * @param yaw - Camera yaw angle in degrees.
79496
- * @param forward - Receives the horizontal forward vector.
79497
- * @param right - Receives the horizontal right vector.
79498
- */
79499
- const setYawBasis = (yaw, forward, right) => {
79500
- rotation.setFromEulerAngles(0, yaw, 0);
79501
- rotation.transformVector(Vec3.FORWARD, forward);
79502
- rotation.transformVector(Vec3.RIGHT, right);
79503
- };
79504
- /**
79505
- * Build a world-space offset from local movement along camera basis vectors.
79506
- *
79507
- * @param out - Receives the world-space offset.
79508
- * @param x - Local right movement.
79509
- * @param y - Local up movement.
79510
- * @param z - Local forward movement.
79511
- * @param forward - Forward basis vector.
79512
- * @param right - Right basis vector.
79513
- * @param up - Up basis vector.
79514
- * @returns The mutated output vector.
79515
- */
79516
- const setBasisOffset = (out, x, y, z, forward, right, up) => {
79517
- out.set(right.x * x + up.x * y + forward.x * z, right.y * x + up.y * y + forward.y * z, right.z * x + up.z * y + forward.z * z);
79518
- return out;
79519
- };
80344
+ class SpawnState {
80345
+ _position = new Vec3();
80346
+ _angles = new Vec3();
80347
+ _distance = 1;
80348
+ _has = false;
80349
+ /**
80350
+ * True once `store` has been called at least once.
80351
+ *
80352
+ * @returns Whether a spawn pose has been captured.
80353
+ */
80354
+ get has() {
80355
+ return this._has;
80356
+ }
80357
+ /**
80358
+ * Capture the given pose as the spawn state.
80359
+ *
80360
+ * @param position - World-space position to remember.
80361
+ * @param angles - Euler angles to remember.
80362
+ * @param distance - Camera distance (orbit-style) to remember.
80363
+ */
80364
+ store(position, angles, distance) {
80365
+ this._position.copy(position);
80366
+ this._angles.copy(angles);
80367
+ this._distance = distance;
80368
+ this._has = true;
80369
+ }
80370
+ /**
80371
+ * Forget any previously-stored spawn pose so a subsequent `has` check
80372
+ * reports false. Used by controllers that scope spawn to a single mode
80373
+ * entry (e.g. walk).
80374
+ */
80375
+ clear() {
80376
+ this._has = false;
80377
+ }
80378
+ /**
80379
+ * Copy the captured pose into the supplied targets. Caller must check
80380
+ * `has` first; calling `restore` before `store` returns the field
80381
+ * defaults (position and angles zeroed, distance `1`).
80382
+ *
80383
+ * @param position - Mutated with the stored world position.
80384
+ * @param angles - Mutated with the stored Euler angles.
80385
+ * @returns The stored camera distance.
80386
+ */
80387
+ restore(position, angles) {
80388
+ position.copy(this._position);
80389
+ angles.copy(this._angles);
80390
+ return this._distance;
80391
+ }
80392
+ }
79520
80393
 
79521
- /** Extra resolve passes above the collider's internal iteration for tight corners */
79522
- const MAX_COLLISION_PASSES = 4;
79523
80394
  /** Small clearance that keeps the sphere from resting exactly on a collision surface */
79524
80395
  const COLLISION_SKIN = 1e-3;
79525
80396
  /** Maximum surface planes to slide along in a single frame */
@@ -79537,7 +80408,7 @@ const SWEEP_RAY_OFFSETS = [
79537
80408
  [-INV_SQRT2, -INV_SQRT2, false],
79538
80409
  [INV_SQRT2, -INV_SQRT2, false]
79539
80410
  ];
79540
- const v$2 = new Vec3();
80411
+ const v$1 = new Vec3();
79541
80412
  const remainingMove = new Vec3();
79542
80413
  const collisionPush = new Vec3();
79543
80414
  const sweepDir = new Vec3();
@@ -79611,10 +80482,10 @@ class SphereMover {
79611
80482
  this.resolve(position);
79612
80483
  return false;
79613
80484
  }
79614
- position.add(v$2.copy(sweepDir).mulScalar(sweepHit.travel));
80485
+ position.add(v$1.copy(sweepDir).mulScalar(sweepHit.travel));
79615
80486
  this.resolve(position);
79616
80487
  sweepNormal.set(sweepHit.nx, sweepHit.ny, sweepHit.nz);
79617
- move.add(v$2.copy(sweepDir).mulScalar(-sweepHit.travel));
80488
+ move.add(v$1.copy(sweepDir).mulScalar(-sweepHit.travel));
79618
80489
  this._clipMove(move, sweepNormal);
79619
80490
  return true;
79620
80491
  }
@@ -79634,8 +80505,8 @@ class SphereMover {
79634
80505
  const rayExtension = centerRay ? this.radius : 0;
79635
80506
  sweepOrigin.copy(position);
79636
80507
  if (!centerRay) {
79637
- sweepOrigin.add(v$2.copy(sweepTangent).mulScalar(tx * radiusOffset));
79638
- sweepOrigin.add(v$2.copy(sweepBitangent).mulScalar(ty * radiusOffset));
80508
+ sweepOrigin.add(v$1.copy(sweepTangent).mulScalar(tx * radiusOffset));
80509
+ sweepOrigin.add(v$1.copy(sweepBitangent).mulScalar(ty * radiusOffset));
79639
80510
  }
79640
80511
  const hit = this.collision.queryRay(sweepOrigin.x, sweepOrigin.y, sweepOrigin.z, dir.x, dir.y, dir.z, distance + rayExtension + COLLISION_SKIN);
79641
80512
  if (!hit) {
@@ -79664,21 +80535,20 @@ class SphereMover {
79664
80535
  return found;
79665
80536
  }
79666
80537
  _resolveSphere(position, push) {
79667
- let collided = false;
79668
- push.set(0, 0, 0);
79669
- for (let i = 0; i < MAX_COLLISION_PASSES; i++) {
79670
- if (!this.collision.querySphere(position.x, position.y, position.z, this.radius, pushOut)) {
79671
- break;
79672
- }
79673
- position.x += pushOut.x;
79674
- position.y += pushOut.y;
79675
- position.z += pushOut.z;
79676
- push.x += pushOut.x;
79677
- push.y += pushOut.y;
79678
- push.z += pushOut.z;
79679
- collided = true;
80538
+ // `querySphere` is already corner-aware (resolveIterative inside the
80539
+ // collider iterates up to 4 passes with constraint-normal projection),
80540
+ // so a single call here is enough.
80541
+ if (!this.collision.querySphere(position.x, position.y, position.z, this.radius, pushOut)) {
80542
+ push.set(0, 0, 0);
80543
+ return false;
79680
80544
  }
79681
- return collided;
80545
+ position.x += pushOut.x;
80546
+ position.y += pushOut.y;
80547
+ position.z += pushOut.z;
80548
+ push.x = pushOut.x;
80549
+ push.y = pushOut.y;
80550
+ push.z = pushOut.z;
80551
+ return true;
79682
80552
  }
79683
80553
  _clipMove(move, push) {
79684
80554
  const normalSq = push.x * push.x + push.y * push.y + push.z * push.z;
@@ -79708,20 +80578,192 @@ class SphereMover {
79708
80578
  }
79709
80579
  }
79710
80580
 
80581
+ /** Maximum Euclidean distance (metres) from the spawn origin to search for a valid placement. */
80582
+ const SEARCH_RADIUS = 5;
80583
+ const SEARCH_RADIUS_SQ = SEARCH_RADIUS * SEARCH_RADIUS;
80584
+ /** Ray budget when probing for ground/ceiling under or above a candidate column. */
80585
+ const RAY_MAX_DIST = 1000;
80586
+ // Scratch values reused across calls — these helpers run only at spawn time
80587
+ // so the lack of re-entrancy is fine.
80588
+ const scratchPush = { x: 0, y: 0, z: 0 };
80589
+ /**
80590
+ * Find the closest sphere placement to (ox, oy, oz) where a sphere of `radius`
80591
+ * fits clear of geometry. Output is the sphere centre. Used for fly-camera
80592
+ * spawn — fly cameras have no ground constraint.
80593
+ *
80594
+ * Lattice search across voxel-spaced offsets from the origin (step =
80595
+ * `collision.voxelResolution`), ordered by Chebyshev shell with Euclidean
80596
+ * tie-break within a shell. Search bounded by `SEARCH_RADIUS`.
80597
+ *
80598
+ * @param collision - Active collision implementation.
80599
+ * @param ox - Origin X (world space).
80600
+ * @param oy - Origin Y (world space).
80601
+ * @param oz - Origin Z (world space).
80602
+ * @param radius - Sphere radius.
80603
+ * @param out - Receives the sphere centre on success.
80604
+ * @returns True if a valid placement was found.
80605
+ */
80606
+ const findSphereSpawn = (collision, ox, oy, oz, radius, out) => {
80607
+ const step = collision.voxelResolution;
80608
+ const maxCells = Math.ceil(SEARCH_RADIUS / step);
80609
+ let bestDistSq = Infinity;
80610
+ let found = false;
80611
+ for (let r = 0; r <= maxCells; r++) {
80612
+ const shellMinDistSq = (r * step) * (r * step);
80613
+ if (shellMinDistSq >= bestDistSq)
80614
+ break;
80615
+ for (let dy = -r; dy <= r; dy++) {
80616
+ const absDy = dy < 0 ? -dy : dy;
80617
+ for (let dz = -r; dz <= r; dz++) {
80618
+ const absDz = dz < 0 ? -dz : dz;
80619
+ for (let dx = -r; dx <= r; dx++) {
80620
+ const absDx = dx < 0 ? -dx : dx;
80621
+ // Only cells on the Chebyshev shell of radius r.
80622
+ if (absDx < r && absDy < r && absDz < r)
80623
+ continue;
80624
+ const distSq = (dx * dx + dy * dy + dz * dz) * step * step;
80625
+ if (distSq >= bestDistSq || distSq > SEARCH_RADIUS_SQ)
80626
+ continue;
80627
+ const cx = ox + dx * step;
80628
+ const cy = oy + dy * step;
80629
+ const cz = oz + dz * step;
80630
+ if (collision.querySphere(cx, cy, cz, radius, scratchPush))
80631
+ continue;
80632
+ bestDistSq = distSq;
80633
+ out.x = cx;
80634
+ out.y = cy;
80635
+ out.z = cz;
80636
+ found = true;
80637
+ }
80638
+ }
80639
+ }
80640
+ }
80641
+ return found;
80642
+ };
80643
+ /**
80644
+ * Find the closest standable cylinder placement to (ox, oy, oz). Output is the
80645
+ * floor world position the cylinder rests on (highest geometry hit across the
80646
+ * footprint). Used for walk-camera spawn.
80647
+ *
80648
+ * The algorithm:
80649
+ *
80650
+ * 1. Lattice search for the closest free voxel `C` (per `isFreeAt`) that has
80651
+ * geometry somewhere below — i.e. a downward ray from `C` hits.
80652
+ * 2. At `(C.x, C.z)`, fan rays up and down from `C.y` through every cell
80653
+ * (step = `collision.voxelResolution`) within the xz footprint disc.
80654
+ * Compute, across columns:
80655
+ * - `floor = max(yDown_i)` (highest ground in the footprint)
80656
+ * - `ceiling = min(yUp_i)` (lowest obstruction overhead, or ∞)
80657
+ * Every column must have a `yDown` hit; otherwise the cylinder is partly
80658
+ * unsupported and the candidate is discarded.
80659
+ * 3. The cylinder fits iff `floor + halfHeight ≤ ceiling - halfHeight`,
80660
+ * i.e. enough vertical clearance for the full cylinder above the floor.
80661
+ * The "resting on ground" placement has centre at `floor + halfHeight`.
80662
+ *
80663
+ * Cylinder math (flat ends, no hemispheres) intentionally matches the carve,
80664
+ * which used a separable XYZ dilation.
80665
+ *
80666
+ * @param collision - Active collision implementation.
80667
+ * @param ox - Origin X (world space).
80668
+ * @param oy - Origin Y (world space).
80669
+ * @param oz - Origin Z (world space).
80670
+ * @param halfHeight - Cylinder half-height (full height = 2 × halfHeight).
80671
+ * @param radius - Cylinder radius.
80672
+ * @param out - Receives the floor position the cylinder rests on.
80673
+ * @returns True if a valid placement was found.
80674
+ */
80675
+ const findCylinderSpawn = (collision, ox, oy, oz, halfHeight, radius, out) => {
80676
+ const step = collision.voxelResolution;
80677
+ const maxCells = Math.ceil(SEARCH_RADIUS / step);
80678
+ // Round up so float division (e.g. 0.2 / 0.05) can't accidentally drop
80679
+ // the outer ring of footprint cells; the Euclidean check below trims any
80680
+ // overshoot back to the true radius.
80681
+ const footCells = Math.ceil(radius / step);
80682
+ const radiusSq = radius * radius;
80683
+ let bestDistSq = Infinity;
80684
+ let found = false;
80685
+ for (let r = 0; r <= maxCells; r++) {
80686
+ const shellMinDistSq = (r * step) * (r * step);
80687
+ if (shellMinDistSq >= bestDistSq)
80688
+ break;
80689
+ for (let dy = -r; dy <= r; dy++) {
80690
+ const absDy = dy < 0 ? -dy : dy;
80691
+ for (let dz = -r; dz <= r; dz++) {
80692
+ const absDz = dz < 0 ? -dz : dz;
80693
+ for (let dx = -r; dx <= r; dx++) {
80694
+ const absDx = dx < 0 ? -dx : dx;
80695
+ if (absDx < r && absDy < r && absDz < r)
80696
+ continue;
80697
+ const distSq = (dx * dx + dy * dy + dz * dz) * step * step;
80698
+ if (distSq >= bestDistSq || distSq > SEARCH_RADIUS_SQ)
80699
+ continue;
80700
+ const cx = ox + dx * step;
80701
+ const cy = oy + dy * step;
80702
+ const cz = oz + dz * step;
80703
+ // Stage 1: cheap filter — only consider free voxels.
80704
+ // The footprint loop below will reject candidates whose
80705
+ // center column has no ground support, so no separate
80706
+ // down-ray probe is needed here.
80707
+ if (!collision.isFreeAt(cx, cy, cz))
80708
+ continue;
80709
+ // Stage 2/3: fan rays through the xz footprint.
80710
+ let floor = -Infinity;
80711
+ let ceiling = Infinity;
80712
+ let supported = true;
80713
+ for (let i = -footCells; i <= footCells && supported; i++) {
80714
+ const fxOff = i * step;
80715
+ const fxOffSq = fxOff * fxOff;
80716
+ for (let j = -footCells; j <= footCells; j++) {
80717
+ const fzOff = j * step;
80718
+ if (fxOffSq + fzOff * fzOff > radiusSq)
80719
+ continue;
80720
+ const fx = cx + fxOff;
80721
+ const fz = cz + fzOff;
80722
+ const down = collision.queryRay(fx, cy, fz, 0, -1, 0, RAY_MAX_DIST);
80723
+ if (!down) {
80724
+ supported = false;
80725
+ break;
80726
+ }
80727
+ if (down.y > floor)
80728
+ floor = down.y;
80729
+ const up = collision.queryRay(fx, cy, fz, 0, 1, 0, RAY_MAX_DIST);
80730
+ if (up && up.y < ceiling)
80731
+ ceiling = up.y;
80732
+ }
80733
+ }
80734
+ if (!supported)
80735
+ continue;
80736
+ // Cylinder vertical extent = 2 × halfHeight. Need that
80737
+ // much room between floor and ceiling.
80738
+ if (floor + 2 * halfHeight > ceiling)
80739
+ continue;
80740
+ bestDistSq = distSq;
80741
+ out.x = cx;
80742
+ out.y = floor;
80743
+ out.z = cz;
80744
+ found = true;
80745
+ }
80746
+ }
80747
+ }
80748
+ }
80749
+ return found;
80750
+ };
80751
+
79711
80752
  /** Radius of the camera collision sphere (meters) */
79712
80753
  const CAMERA_RADIUS = 0.2;
79713
80754
  const forward$2 = new Vec3();
79714
80755
  const right$2 = new Vec3();
79715
80756
  const up$1 = new Vec3();
79716
80757
  const offset$1 = new Vec3();
80758
+ const spawnProbe$1 = new Vec3();
79717
80759
  class FlyController {
79718
80760
  fov = 90;
80761
+ rotateDamping = DEFAULT_CONTROLLER_DAMPING;
79719
80762
  _position = new Vec3();
79720
80763
  _angles = new Vec3();
80764
+ _targetAngles = new Vec3();
79721
80765
  _distance = 1;
79722
- _spawnPosition = new Vec3();
79723
- _spawnAngles = new Vec3();
79724
- _spawnDistance = 1;
80766
+ _spawn = new SpawnState();
79725
80767
  _mover = new SphereMover(CAMERA_RADIUS);
79726
80768
  /** Optional collision for sphere collision with sliding */
79727
80769
  set collision(value) {
@@ -79731,15 +80773,19 @@ class FlyController {
79731
80773
  get collision() {
79732
80774
  return this._mover.collision;
79733
80775
  }
79734
- _hasSpawn = false;
79735
80776
  onEnter(camera) {
79736
80777
  this.goto(camera);
79737
- this._mover.resolve(this._position);
80778
+ if (this.collision &&
80779
+ findSphereSpawn(this.collision, this._position.x, this._position.y, this._position.z, CAMERA_RADIUS, spawnProbe$1)) {
80780
+ this._position.copy(spawnProbe$1);
80781
+ this._mover.reset(this._position);
80782
+ }
79738
80783
  this._storeSpawn();
79739
80784
  }
79740
80785
  update(deltaTime, inputFrame, camera) {
79741
80786
  const { move, rotate } = inputFrame.read();
79742
- applyFrameRotation(this._angles, rotate);
80787
+ applyFrameRotation(this._targetAngles, rotate);
80788
+ dampAngles(this._angles, this._targetAngles, this.rotateDamping, deltaTime);
79743
80789
  this._step(move);
79744
80790
  camera.position.copy(this._position);
79745
80791
  camera.angles.set(this._angles.x, this._angles.y, 0);
@@ -79751,16 +80797,16 @@ class FlyController {
79751
80797
  goto(camera) {
79752
80798
  this._position.copy(camera.position);
79753
80799
  this._angles.set(camera.angles.x, camera.angles.y, 0);
80800
+ this._targetAngles.copy(this._angles);
79754
80801
  this._distance = camera.distance;
79755
80802
  this._mover.reset(this._position);
79756
80803
  }
79757
80804
  resetToSpawn(camera) {
79758
- if (!this._hasSpawn) {
80805
+ if (!this._spawn.has) {
79759
80806
  return false;
79760
80807
  }
79761
- this._position.copy(this._spawnPosition);
79762
- this._angles.copy(this._spawnAngles);
79763
- this._distance = this._spawnDistance;
80808
+ this._distance = this._spawn.restore(this._position, this._angles);
80809
+ this._targetAngles.copy(this._angles);
79764
80810
  this._mover.reset(this._position);
79765
80811
  camera.position.copy(this._position);
79766
80812
  camera.angles.copy(this._angles);
@@ -79769,10 +80815,7 @@ class FlyController {
79769
80815
  return true;
79770
80816
  }
79771
80817
  _storeSpawn() {
79772
- this._spawnPosition.copy(this._position);
79773
- this._spawnAngles.copy(this._angles);
79774
- this._spawnDistance = this._distance;
79775
- this._hasSpawn = true;
80818
+ this._spawn.store(this._position, this._angles, this._distance);
79776
80819
  }
79777
80820
  _step(move) {
79778
80821
  setCameraBasis(this._angles, forward$2, right$2, up$1);
@@ -80012,9 +81055,9 @@ class OrbitController {
80012
81055
  this.controller = new OrbitController$1();
80013
81056
  this.controller.zoomRange = new Vec2(0.01, Infinity);
80014
81057
  this.controller.pitchRange = new Vec2(-90, 90);
80015
- this.controller.rotateDamping = 0.97;
80016
- this.controller.moveDamping = 0.97;
80017
- this.controller.zoomDamping = 0.97;
81058
+ this.controller.rotateDamping = DEFAULT_CONTROLLER_DAMPING;
81059
+ this.controller.moveDamping = DEFAULT_CONTROLLER_DAMPING;
81060
+ this.controller.zoomDamping = DEFAULT_CONTROLLER_DAMPING;
80018
81061
  }
80019
81062
  onEnter(camera) {
80020
81063
  this._attach(camera);
@@ -80040,103 +81083,6 @@ class OrbitController {
80040
81083
  }
80041
81084
  }
80042
81085
 
80043
- const SPAWN_HIT_EPSILON = 1e-3;
80044
- const SPAWN_SEARCH_MIN_STEP = 0.05;
80045
- const SPAWN_SEARCH_MAX_STEPS = 128;
80046
- const out$1 = { x: 0, y: 0, z: 0 };
80047
- const v$1 = new Vec3();
80048
- const probe = new Vec3();
80049
- const queryCapsule = (collision, pos, p) => {
80050
- const half = p.capsuleHeight * 0.5 - p.capsuleRadius;
80051
- const center = pos.y - p.eyeHeight + p.capsuleHeight * 0.5;
80052
- return collision.queryCapsule(pos.x, center, pos.z, half, p.capsuleRadius, out$1);
80053
- };
80054
- const eyeYFromGround = (groundY, p) => groundY + p.hoverHeight + p.eyeHeight;
80055
- const isInsideSolid = (collision, pos) => {
80056
- return collision.querySphere(pos.x, pos.y, pos.z, SPAWN_HIT_EPSILON, out$1);
80057
- };
80058
- const probeGroundY = (collision, pos, p) => {
80059
- const hit = collision.queryRay(pos.x, pos.y, pos.z, 0, -1, 0, p.spawnSearchRange);
80060
- return hit ? hit.y : null;
80061
- };
80062
- const hasSpawnGroundSupport = (collision, pos, p) => {
80063
- const groundY = probeGroundY(collision, pos, p);
80064
- if (groundY === null) {
80065
- return false;
80066
- }
80067
- const clearance = pos.y - p.eyeHeight - groundY;
80068
- return clearance >= -SPAWN_HIT_EPSILON &&
80069
- clearance <= p.hoverHeight + p.capsuleRadius + SPAWN_HIT_EPSILON;
80070
- };
80071
- // Push a candidate eye position out of solid geometry. Returns true if the
80072
- // candidate becomes clear within the allowed budget and remains supported by
80073
- // ground beneath it.
80074
- const resolveSpawnCandidate = (collision, pos, p) => {
80075
- const startX = pos.x;
80076
- const startY = pos.y;
80077
- const startZ = pos.z;
80078
- const maxResolveDistance = p.capsuleRadius + p.hoverHeight;
80079
- const maxResolveDistanceSq = maxResolveDistance * maxResolveDistance;
80080
- for (let i = 0; i < 100; i++) {
80081
- if (!queryCapsule(collision, pos, p)) {
80082
- return hasSpawnGroundSupport(collision, pos, p);
80083
- }
80084
- pos.add(v$1.set(out$1.x, out$1.y, out$1.z));
80085
- const dx = pos.x - startX;
80086
- const dy = pos.y - startY;
80087
- const dz = pos.z - startZ;
80088
- if (dx * dx + dy * dy + dz * dz > maxResolveDistanceSq) {
80089
- return false;
80090
- }
80091
- }
80092
- return false;
80093
- };
80094
- // Find the first collision surface below a point that can hold a clear walk
80095
- // capsule. Writes the resolved eye position to outPos on success.
80096
- const findClearSpawnGroundBelow = (collision, pos, range, allowInitialHit, p, outPos) => {
80097
- const hit = collision.queryRay(pos.x, pos.y, pos.z, 0, -1, 0, range);
80098
- if (!hit) {
80099
- return false;
80100
- }
80101
- if (!allowInitialHit && Math.abs(pos.y - hit.y) <= SPAWN_HIT_EPSILON) {
80102
- return false;
80103
- }
80104
- outPos.set(pos.x, eyeYFromGround(hit.y, p), pos.z);
80105
- const clear = !queryCapsule(collision, outPos, p);
80106
- return clear || resolveSpawnCandidate(collision, outPos, p);
80107
- };
80108
- const searchSpawnGround = (collision, pos, direction, p, outPos) => {
80109
- const step = Math.max(p.capsuleRadius, p.hoverHeight, SPAWN_SEARCH_MIN_STEP, p.spawnSearchRange / SPAWN_SEARCH_MAX_STEPS);
80110
- const endY = pos.y + direction * p.spawnSearchRange;
80111
- for (let y = pos.y + direction * step; direction < 0 ? y >= endY : y <= endY; y += direction * step) {
80112
- probe.set(pos.x, y, pos.z);
80113
- if (findClearSpawnGroundBelow(collision, probe, p.spawnSearchRange, false, p, outPos)) {
80114
- return true;
80115
- }
80116
- }
80117
- return false;
80118
- };
80119
- /**
80120
- * Find an eye position for spawning into walk mode. Prefer ground directly
80121
- * below the camera; if that is not usable, search down and then up for the
80122
- * first clear walk placement with ground below it. On success, the resolved
80123
- * eye position is written to outPos.
80124
- *
80125
- * @param collision - The active collision implementation.
80126
- * @param pos - Incoming camera position.
80127
- * @param p - Walk capsule and spawn-search parameters.
80128
- * @param outPos - Receives the resolved eye position.
80129
- * @returns True if a spawn position was found.
80130
- */
80131
- const findWalkSpawn = (collision, pos, p, outPos) => {
80132
- const insideSolid = isInsideSolid(collision, pos);
80133
- if (findClearSpawnGroundBelow(collision, pos, p.spawnSearchRange, !insideSolid, p, outPos)) {
80134
- return true;
80135
- }
80136
- return searchSpawnGround(collision, pos, -1, p, outPos) ||
80137
- searchSpawnGround(collision, pos, 1, p, outPos);
80138
- };
80139
-
80140
81086
  const FIXED_DT = 1 / 60;
80141
81087
  const MAX_SUBSTEPS = 10;
80142
81088
  /** Pre-allocated push-out vector for capsule collision */
@@ -80193,14 +81139,10 @@ class WalkController {
80193
81139
  * Movement speed in m/s when in the air (for air control)
80194
81140
  */
80195
81141
  moveAirSpeed = 1;
80196
- /**
80197
- * Movement damping factor (0 = no damping, 1 = full damping)
80198
- */
80199
- moveDamping = 0.97;
80200
81142
  /**
80201
81143
  * Rotation damping factor (0 = no damping, 1 = full damping)
80202
81144
  */
80203
- rotateDamping = 0.97;
81145
+ rotateDamping = DEFAULT_CONTROLLER_DAMPING;
80204
81146
  /**
80205
81147
  * Velocity damping factor when grounded (0 = no damping, 1 = full damping)
80206
81148
  */
@@ -80227,31 +81169,36 @@ class WalkController {
80227
81169
  * Maximum downward raycast distance to search for ground below the capsule.
80228
81170
  */
80229
81171
  groundProbeRange = 1.0;
80230
- /**
80231
- * Maximum vertical raycast distance to search for walk spawn ground.
80232
- */
80233
- spawnSearchRange = 1000;
80234
81172
  _position = new Vec3();
80235
81173
  _prevPosition = new Vec3();
80236
81174
  _angles = new Vec3();
81175
+ _targetAngles = new Vec3();
80237
81176
  _distance = 1;
80238
- _spawnPosition = new Vec3();
80239
- _spawnAngles = new Vec3();
80240
- _spawnDistance = 1;
81177
+ _spawn = new SpawnState();
81178
+ _spawnGrounded = false;
80241
81179
  _velocity = new Vec3();
80242
81180
  _pendingMove = [0, 0, 0];
80243
81181
  _accumulator = 0;
80244
81182
  _grounded = false;
80245
81183
  _jumping = false;
80246
81184
  _jumpHeld = false;
80247
- _spawnGrounded = false;
80248
- _hasSpawn = false;
80249
81185
  onEnter(camera) {
80250
81186
  this.goto(camera);
80251
81187
  if (this.collision) {
80252
- this._hasSpawn = false;
80253
- if (findWalkSpawn(this.collision, camera.position, this, spawnProbe)) {
80254
- this._position.copy(spawnProbe);
81188
+ // Spawn is scoped to this walk-mode entry; reset so a stale spawn
81189
+ // from a previous entry can't be restored if this entry fails.
81190
+ this._spawn.clear();
81191
+ // Treat the walk capsule as a tight-superset cylinder for spawn.
81192
+ // The carve was produced with a separable XYZ dilation (flat ends,
81193
+ // no hemispheres), so cylinder math matches the data exactly.
81194
+ // Include `hoverHeight` in the height so the ceiling-clearance
81195
+ // check accounts for the placed capsule's full vertical envelope:
81196
+ // foot sits at `floor + hoverHeight`, head at `floor + hoverHeight
81197
+ // + capsuleHeight`.
81198
+ if (findCylinderSpawn(this.collision, camera.position.x, camera.position.y, camera.position.z, (this.capsuleHeight + this.hoverHeight) * 0.5, this.capsuleRadius, spawnProbe)) {
81199
+ // spawnProbe is the floor world position the cylinder rests
81200
+ // on. Eye sits hoverHeight + eyeHeight above the floor.
81201
+ this._position.set(spawnProbe.x, spawnProbe.y + this.hoverHeight + this.eyeHeight, spawnProbe.z);
80255
81202
  this._grounded = true;
80256
81203
  this._velocity.y = 0;
80257
81204
  this._storeSpawn();
@@ -80262,7 +81209,8 @@ class WalkController {
80262
81209
  update(deltaTime, inputFrame, camera) {
80263
81210
  const { move, rotate } = inputFrame.read();
80264
81211
  // apply rotation at display rate for responsive mouse look
80265
- applyFrameRotation(this._angles, rotate);
81212
+ applyFrameRotation(this._targetAngles, rotate);
81213
+ dampAngles(this._angles, this._targetAngles, this.rotateDamping, deltaTime);
80266
81214
  // accumulate movement input so frames without a physics step don't lose input
80267
81215
  this._pendingMove[0] += move[0];
80268
81216
  this._pendingMove[1] = this._pendingMove[1] || move[1];
@@ -80354,6 +81302,7 @@ class WalkController {
80354
81302
  this._prevPosition.copy(this._position);
80355
81303
  // angles (clamp pitch to avoid gimbal lock)
80356
81304
  this._angles.set(camera.angles.x, camera.angles.y, 0);
81305
+ this._targetAngles.copy(this._angles);
80357
81306
  this._distance = camera.distance;
80358
81307
  // reset velocity and state
80359
81308
  this._resetMotion();
@@ -80365,13 +81314,12 @@ class WalkController {
80365
81314
  * @returns True if a spawn pose was available.
80366
81315
  */
80367
81316
  resetToSpawn(camera) {
80368
- if (!this._hasSpawn) {
81317
+ if (!this._spawn.has) {
80369
81318
  return false;
80370
81319
  }
80371
- this._position.copy(this._spawnPosition);
81320
+ this._distance = this._spawn.restore(this._position, this._angles);
80372
81321
  this._prevPosition.copy(this._position);
80373
- this._angles.copy(this._spawnAngles);
80374
- this._distance = this._spawnDistance;
81322
+ this._targetAngles.copy(this._angles);
80375
81323
  this._resetMotion();
80376
81324
  this._grounded = this._spawnGrounded;
80377
81325
  camera.position.copy(this._position);
@@ -80381,11 +81329,8 @@ class WalkController {
80381
81329
  return true;
80382
81330
  }
80383
81331
  _storeSpawn() {
80384
- this._spawnPosition.copy(this._position);
80385
- this._spawnAngles.copy(this._angles);
80386
- this._spawnDistance = this._distance;
81332
+ this._spawn.store(this._position, this._angles, this._distance);
80387
81333
  this._spawnGrounded = this._grounded;
80388
- this._hasSpawn = true;
80389
81334
  }
80390
81335
  _resetMotion() {
80391
81336
  this._velocity.set(0, 0, 0);
@@ -82623,11 +83568,12 @@ const NUM_SAMPLES = 12;
82623
83568
  const BASE_OUTER_RADIUS = 0.2;
82624
83569
  const INNER_OUTER_RATIO = 0.17 / 0.2;
82625
83570
  // Screen-space diameter (in CSS pixels) used for both hover and target
82626
- // rings when the scene has no collision data. With collision present the
82627
- // rings render world-space (BASE_OUTER_RADIUS) so they orient to the
82628
- // surface; without collision the picks fall back to splat depth and a
82629
- // fixed pixel size is more legible. Selection happens in
82630
- // screenPixelsForRing(), keyed on state.hasCollision.
83571
+ // rings when the scene isn't walk-sized. Walk-sized scenes render
83572
+ // world-space (BASE_OUTER_RADIUS) so the ring orients to the surface and
83573
+ // reads as a physical footprint; smaller scenes (or no collision) fall
83574
+ // back to a fixed pixel size, which keeps the ring legible when 0.2 world
83575
+ // units would eat too much of the scene. Selection happens in
83576
+ // screenPixelsForRing(), keyed on state.walkAllowed.
82631
83577
  const SCREEN_OUTER_PIXELS = 48;
82632
83578
  const BEZIER_K = 1 / 6;
82633
83579
  const NORMAL_SMOOTH_FACTOR = 0.25;
@@ -82900,13 +83846,14 @@ class NavCursor {
82900
83846
  app.on('prerender', this.onPrerender);
82901
83847
  updateActive();
82902
83848
  }
82903
- // Ring sizing is per-scene: when the scene has collision data we get
82904
- // accurate surface picks with real normals, so world-space rings read
82905
- // as physical footprints on the surface with visible orientation.
82906
- // Without collision the pick falls back to splat depth which can be
82907
- // noisy at distance, so a fixed screen-size ring is more legible.
83849
+ // Ring sizing is per-scene: walk-sized scenes (collision present and
83850
+ // bbox large enough — same predicate as walk mode) get world-space
83851
+ // rings, which read as physical footprints on the surface with visible
83852
+ // orientation. Smaller scenes or scenes without collision use a fixed
83853
+ // screen-pixel ring — 0.2 world units would dominate a small scene,
83854
+ // and the pick already falls back to splat depth without collision.
82908
83855
  screenPixelsForRing() {
82909
- return this.state.hasCollision ? null : SCREEN_OUTER_PIXELS;
83856
+ return this.state.walkAllowed ? null : SCREEN_OUTER_PIXELS;
82910
83857
  }
82911
83858
  setTarget(pos, normal, mode) {
82912
83859
  this.targetPos = pos.clone();
@@ -84365,10 +85312,8 @@ class Viewer {
84365
85312
  origChunks;
84366
85313
  constructor(global, gsplatLoad, skyboxLoad, collisionLoad) {
84367
85314
  this.global = global;
84368
- const { app, settings, config, events, state, camera } = global;
85315
+ const { app, settings, config, events, state, camera, renderer } = global;
84369
85316
  const { graphicsDevice } = app;
84370
- // enable anonymous CORS for image loading in safari
84371
- app.loader.getHandler('texture').imgParser.crossOrigin = 'anonymous';
84372
85317
  // render skybox as plain equirect
84373
85318
  const glsl = ShaderChunks.get(graphicsDevice, 'glsl');
84374
85319
  glsl.set('skyboxPS', patchChunk(glsl.get('skyboxPS'), 'mapRoughnessUv(uv, mipLevel)', 'uv', 'glsl skyboxPS'));
@@ -84515,7 +85460,7 @@ class Viewer {
84515
85460
  state.walkAllowed = isWalkAllowed(sceneBound, collision ?? null);
84516
85461
  // Create collision debug overlay (voxel uses a compute shader, mesh
84517
85462
  // uses standard line rendering). The voxel path requires WebGPU.
84518
- if (collision instanceof VoxelCollision && config.renderer !== 'webgl') {
85463
+ if (collision instanceof VoxelCollision && renderer !== 'webgl') {
84519
85464
  this.voxelOverlay = new VoxelDebugOverlay(app, collision, camera);
84520
85465
  this.voxelOverlay.mode = config.heatmap ? 'heatmap' : 'overlay';
84521
85466
  state.hasCollisionOverlay = true;
@@ -84632,7 +85577,7 @@ class Viewer {
84632
85577
  applyPerfSettings();
84633
85578
  // debug colorize lods
84634
85579
  gsplat.debug = config.colorize ? GSPLAT_DEBUG_LOD : GSPLAT_DEBUG_NONE;
84635
- gsplat.renderer = rendererTable[config.renderer];
85580
+ gsplat.renderer = rendererTable[renderer];
84636
85581
  // wait for the first valid frame to complete rendering
84637
85582
  app.once('frameend', () => {
84638
85583
  events.fire('firstFrame');
@@ -85549,7 +86494,7 @@ class XrNavigation extends Script {
85549
86494
 
85550
86495
  // On entering/exiting AR, we need to set the camera clear color to transparent black
85551
86496
  const initXr = (global) => {
85552
- const { app, events, state, camera } = global;
86497
+ const { app, events, state, camera, renderer } = global;
85553
86498
  state.hasAR = app.xr.isAvailable('immersive-ar');
85554
86499
  state.hasVR = app.xr.isAvailable('immersive-vr');
85555
86500
  // initialize ar/vr
@@ -85559,6 +86504,11 @@ const initXr = (global) => {
85559
86504
  app.xr.on('available:immersive-vr', (available) => {
85560
86505
  state.hasVR = available;
85561
86506
  });
86507
+ // XR sessions require a WebGL device; under WebGPU we only expose availability so
86508
+ // the UI can offer to reload the viewer in WebGL mode.
86509
+ if (renderer !== 'webgl') {
86510
+ return;
86511
+ }
85562
86512
  const parent = camera.parent;
85563
86513
  const clearColor = new Color();
85564
86514
  const parentPosition = new Vec3();
@@ -85676,16 +86626,21 @@ const loadSkybox = (app, url) => {
85676
86626
  };
85677
86627
  const createApp = async (canvas, config) => {
85678
86628
  const useWebGPU = config.renderer === 'webgpu';
85679
- // Create the graphics device
86629
+ // Create the graphics device. The engine auto-appends WebGL2/null fallbacks
86630
+ // when WebGPU isn't supported, so request xrCompatible so the WebGL fallback
86631
+ // is also usable for AR/VR.
85680
86632
  const device = await createGraphicsDevice(canvas, {
85681
86633
  deviceTypes: useWebGPU ? ['webgpu'] : [],
85682
86634
  antialias: false,
85683
86635
  depth: true,
85684
86636
  stencil: false,
85685
- xrCompatible: !useWebGPU,
86637
+ xrCompatible: true,
85686
86638
  powerPreference: 'high-performance'
85687
86639
  });
85688
86640
  console.log(`Renderer: ${device.deviceType}`);
86641
+ // The engine may have fallen back from WebGPU to WebGL2; downstream code
86642
+ // (voxel overlay, XR, gsplat renderer selection) needs the *actual* renderer.
86643
+ const renderer = device.deviceType === 'webgpu' ? 'webgpu' : 'webgl';
85689
86644
  // Set maxPixelRatio so the XR framebuffer scale factor is computed correctly.
85690
86645
  // Regular rendering bypasses maxPixelRatio via the custom initCanvas sizing.
85691
86646
  device.maxPixelRatio = window.devicePixelRatio;
@@ -85696,6 +86651,10 @@ const createApp = async (canvas, config) => {
85696
86651
  touch: new TouchDevice$1(canvas),
85697
86652
  keyboard: new Keyboard(window)
85698
86653
  });
86654
+ // enable anonymous CORS for image loading in safari (must be set before any
86655
+ // texture asset starts loading, otherwise the <img> is fetched without the
86656
+ // crossorigin attribute and WebGL rejects it with SecurityError)
86657
+ app.loader.getHandler('texture').imgParser.crossOrigin = 'anonymous';
85699
86658
  // Create entity hierarchy
85700
86659
  const cameraRoot = new Entity('camera root');
85701
86660
  app.root.addChild(cameraRoot);
@@ -85709,7 +86668,7 @@ const createApp = async (canvas, config) => {
85709
86668
  });
85710
86669
  app.root.addChild(light);
85711
86670
  app.scene.ambientLight.set(0.51, 0.55, 0.65);
85712
- return { app, camera };
86671
+ return { app, camera, renderer };
85713
86672
  };
85714
86673
  // initialize canvas size and resizing
85715
86674
  const initCanvas = (global) => {
@@ -85759,7 +86718,7 @@ const initCanvas = (global) => {
85759
86718
  apply();
85760
86719
  };
85761
86720
  const main = async (canvas, settingsJson, config) => {
85762
- const { app, camera } = await createApp(canvas, config);
86721
+ const { app, camera, renderer } = await createApp(canvas, config);
85763
86722
  // create events
85764
86723
  const events = new EventHandler();
85765
86724
  // migrate legacy `retinaDisplay` preference (inverted) to `performanceMode`
@@ -85796,7 +86755,8 @@ const main = async (canvas, settingsJson, config) => {
85796
86755
  config,
85797
86756
  state,
85798
86757
  events,
85799
- camera
86758
+ camera,
86759
+ renderer
85800
86760
  };
85801
86761
  initCanvas(global);
85802
86762
  // start the application
@@ -85806,20 +86766,22 @@ const main = async (canvas, settingsJson, config) => {
85806
86766
  initPoster(events);
85807
86767
  }
85808
86768
  camera.addComponent('camera');
85809
- // Initialize XR support
85810
- if (config.renderer === 'webgl') {
85811
- initXr(global);
85812
- }
86769
+ // Initialize XR support (availability detection always runs so the UI can offer
86770
+ // a reload into WebGL when the user requests AR/VR under WebGPU)
86771
+ initXr(global);
85813
86772
  // Initialize user interface
86773
+ initLocalization();
85814
86774
  initUI(global);
85815
86775
  // Load model
85816
86776
  const gsplatLoad = loadGsplat(app, config, (progress) => {
85817
86777
  state.progress = progress;
85818
86778
  });
85819
- // Load skybox
86779
+ // Load skybox (continue without if it fails — e.g. CORS, 404)
85820
86780
  const skyboxLoad = config.skyboxUrl &&
85821
86781
  loadSkybox(app, config.skyboxUrl).then((asset) => {
85822
86782
  app.scene.envAtlas = asset.resource;
86783
+ }).catch((err) => {
86784
+ console.warn('Failed to load skybox:', err);
85823
86785
  });
85824
86786
  // Load collision data (type determined by file extension)
85825
86787
  let collisionLoad;