@playcanvas/supersplat-viewer 1.16.6 → 1.16.8

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
@@ -69478,7 +69478,7 @@ const initJoystick = (dom, events, state) => {
69478
69478
  let lastTapTime = 0;
69479
69479
  // Update joystick visibility based on camera mode and input mode
69480
69480
  const updateJoystickVisibility = () => {
69481
- if ((state.cameraMode === 'fly' || state.cameraMode === 'fps') && state.inputMode === 'touch' && state.touchControlScheme === 'joystick') {
69481
+ if ((state.cameraMode === 'fly' || state.cameraMode === 'fps') && state.inputMode === 'touch' && state.gamingControls) {
69482
69482
  dom.joystickBase.classList.remove('hidden');
69483
69483
  dom.joystickBase.classList.toggle('mode-2d', joystickMode === '2d');
69484
69484
  dom.joystickBase.style.left = `${joystickFixedX}px`;
@@ -69498,7 +69498,7 @@ const initJoystick = (dom, events, state) => {
69498
69498
  };
69499
69499
  events.on('cameraMode:changed', updateJoystickVisibility);
69500
69500
  events.on('inputMode:changed', updateJoystickVisibility);
69501
- events.on('touchControlScheme:changed', updateJoystickVisibility);
69501
+ events.on('gamingControls:changed', updateJoystickVisibility);
69502
69502
  window.addEventListener('resize', updateJoystickVisibility);
69503
69503
  // Handle joystick touch input directly on the joystick element
69504
69504
  const updateJoystickStick = (clientX, clientY) => {
@@ -69648,10 +69648,12 @@ const initUI = (global) => {
69648
69648
  'play', 'pause',
69649
69649
  'settings', 'settingsPanel',
69650
69650
  'orbitCamera', 'flyCamera', 'fpsCamera',
69651
- 'hqCheck', 'hqOption', 'lqCheck', 'lqOption',
69652
- 'touchControlsDivider', 'joystickSchemeRow', 'pinchSchemeRow',
69653
- 'joystickSchemeCheck', 'joystickSchemeOption', 'pinchSchemeCheck', 'pinchSchemeOption',
69654
- 'touchFlyJoystick', 'touchFlyPinch',
69651
+ 'retinaDisplayRow', 'retinaDisplayCheck', 'retinaDisplayOption',
69652
+ 'gamingControlsRow', 'gamingControlsCheck', 'gamingControlsOption',
69653
+ 'desktopClickToWalk', 'desktopGamingControls',
69654
+ 'touchFlyClickToWalk', 'touchFlyGamingControls',
69655
+ 'touchClickToWalk', 'touchGamingControls',
69656
+ 'walkHint',
69655
69657
  'reset', 'frame',
69656
69658
  'loadingText', 'loadingBar',
69657
69659
  'joystickBase', 'joystick',
@@ -69740,47 +69742,32 @@ const initUI = (global) => {
69740
69742
  dom.enterFullscreen.classList[value ? 'add' : 'remove']('hidden');
69741
69743
  dom.exitFullscreen.classList[value ? 'remove' : 'add']('hidden');
69742
69744
  });
69743
- // HQ mode (click anywhere in the row, not just the label)
69744
- dom.hqOption.parentElement.addEventListener('click', () => {
69745
- state.hqMode = true;
69745
+ // Retina display toggle
69746
+ dom.retinaDisplayRow.addEventListener('click', () => {
69747
+ state.retinaDisplay = !state.retinaDisplay;
69746
69748
  });
69747
- dom.lqOption.parentElement.addEventListener('click', () => {
69748
- state.hqMode = false;
69749
- });
69750
- const updateHQ = () => {
69751
- dom.hqCheck.classList[state.hqMode ? 'add' : 'remove']('active');
69752
- dom.lqCheck.classList[state.hqMode ? 'remove' : 'add']('active');
69749
+ const updateRetinaDisplay = () => {
69750
+ dom.retinaDisplayCheck.classList.toggle('active', state.retinaDisplay);
69751
+ localStorage.setItem('retinaDisplay', String(state.retinaDisplay));
69753
69752
  };
69754
- events.on('hqMode:changed', () => {
69755
- updateHQ();
69756
- localStorage.setItem('hqMode', String(state.hqMode));
69757
- });
69758
- updateHQ();
69759
- // Touch control scheme toggle (only visible on touch devices)
69760
- dom.joystickSchemeRow.addEventListener('click', () => {
69761
- state.touchControlScheme = 'joystick';
69753
+ events.on('retinaDisplay:changed', updateRetinaDisplay);
69754
+ updateRetinaDisplay();
69755
+ // Gaming mode toggle
69756
+ dom.gamingControlsRow.addEventListener('click', () => {
69757
+ state.gamingControls = !state.gamingControls;
69762
69758
  });
69763
- dom.pinchSchemeRow.addEventListener('click', () => {
69764
- state.touchControlScheme = 'pinch';
69765
- });
69766
- const updateTouchControlScheme = () => {
69767
- const isJoystick = state.touchControlScheme === 'joystick';
69768
- dom.joystickSchemeCheck.classList.toggle('active', isJoystick);
69769
- dom.pinchSchemeCheck.classList.toggle('active', !isJoystick);
69770
- dom.touchFlyJoystick.classList.toggle('hidden', !isJoystick);
69771
- dom.touchFlyPinch.classList.toggle('hidden', isJoystick);
69772
- localStorage.setItem('touchControlScheme', state.touchControlScheme);
69773
- };
69774
- const updateTouchControlsVisibility = () => {
69775
- const isTouch = state.inputMode === 'touch';
69776
- dom.touchControlsDivider.classList.toggle('hidden', !isTouch);
69777
- dom.joystickSchemeRow.classList.toggle('hidden', !isTouch);
69778
- dom.pinchSchemeRow.classList.toggle('hidden', !isTouch);
69759
+ const updateGamingControls = () => {
69760
+ dom.gamingControlsCheck.classList.toggle('active', state.gamingControls);
69761
+ dom.desktopClickToWalk.classList.toggle('hidden', state.gamingControls);
69762
+ dom.desktopGamingControls.classList.toggle('hidden', !state.gamingControls);
69763
+ dom.touchFlyClickToWalk.classList.toggle('hidden', state.gamingControls);
69764
+ dom.touchFlyGamingControls.classList.toggle('hidden', !state.gamingControls);
69765
+ dom.touchClickToWalk.classList.toggle('hidden', state.gamingControls);
69766
+ dom.touchGamingControls.classList.toggle('hidden', !state.gamingControls);
69767
+ localStorage.setItem('gamingControls', String(state.gamingControls));
69779
69768
  };
69780
- events.on('touchControlScheme:changed', updateTouchControlScheme);
69781
- events.on('inputMode:changed', updateTouchControlsVisibility);
69782
- updateTouchControlScheme();
69783
- updateTouchControlsVisibility();
69769
+ events.on('gamingControls:changed', updateGamingControls);
69770
+ updateGamingControls();
69784
69771
  // AR/VR
69785
69772
  const arChanged = () => dom.arMode.classList[state.hasAR ? 'remove' : 'add']('hidden');
69786
69773
  const vrChanged = () => dom.vrMode.classList[state.hasVR ? 'remove' : 'add']('hidden');
@@ -69943,6 +69930,34 @@ const initUI = (global) => {
69943
69930
  dom.fpsCamera.classList.toggle('active', state.cameraMode === 'fps');
69944
69931
  };
69945
69932
  events.on('cameraMode:changed', updateCameraModeUI);
69933
+ // Walk mode hint banner (shown once per session on first FPS entry)
69934
+ let walkHintShown = false;
69935
+ const getWalkHintText = () => {
69936
+ if (state.inputMode === 'desktop') {
69937
+ return state.gamingControls ?
69938
+ 'WASD to move. Mouse to look around. Space to jump.' :
69939
+ 'Click to walk. Click and drag to look around.';
69940
+ }
69941
+ return state.gamingControls ?
69942
+ 'Use the joystick to move. Drag to look around. Tap to jump.' :
69943
+ 'Tap to walk. Drag to look around.';
69944
+ };
69945
+ events.on('cameraMode:changed', (value) => {
69946
+ if (value === 'fps' && !walkHintShown) {
69947
+ walkHintShown = true;
69948
+ dom.walkHint.textContent = getWalkHintText();
69949
+ dom.walkHint.classList.remove('hidden');
69950
+ }
69951
+ else if (value !== 'fps') {
69952
+ dom.walkHint.classList.add('hidden');
69953
+ }
69954
+ });
69955
+ const dismissWalkHint = () => dom.walkHint.classList.add('hidden');
69956
+ dom.walkHint.addEventListener('click', dismissWalkHint);
69957
+ events.on('inputEvent', (type) => {
69958
+ if (type === 'interrupt')
69959
+ dismissWalkHint();
69960
+ });
69946
69961
  // show/hide the FPS button based on voxel data availability
69947
69962
  events.on('hasCollision:changed', (value) => {
69948
69963
  dom.fpsCamera.classList.toggle('hidden', !value);
@@ -71797,9 +71812,12 @@ class InputController {
71797
71812
  _tapTouches = 0;
71798
71813
  _tapDelta = 0;
71799
71814
  _tapJump = false;
71800
- // Screen coordinates of the last touch start (for tap-to-walk picking)
71801
- _lastTouchOffsetX = 0;
71802
- _lastTouchOffsetY = 0;
71815
+ // Screen coordinates of the last pointer start (for click/tap-to-walk picking)
71816
+ _lastPointerOffsetX = 0;
71817
+ _lastPointerOffsetY = 0;
71818
+ // Desktop click-to-walk tracking
71819
+ _mouseClickTracking = false;
71820
+ _mouseClickDelta = 0;
71803
71821
  _picker = null;
71804
71822
  moveSpeed = 4;
71805
71823
  orbitSpeed = 18;
@@ -71821,6 +71839,14 @@ class InputController {
71821
71839
  this._touchJoystick[1] = value.y;
71822
71840
  });
71823
71841
  this.global = global;
71842
+ const updateCanvasCursor = () => {
71843
+ if (state.cameraMode === 'fps' && !state.gamingControls && state.inputMode === 'desktop') {
71844
+ canvas.style.cursor = this._mouseClickTracking ? 'move' : 'pointer';
71845
+ }
71846
+ else {
71847
+ canvas.style.cursor = '';
71848
+ }
71849
+ };
71824
71850
  // Generate input events
71825
71851
  ['wheel', 'pointerdown', 'contextmenu', 'keydown'].forEach((eventName) => {
71826
71852
  canvas.addEventListener(eventName, (event) => {
@@ -71833,13 +71859,19 @@ class InputController {
71833
71859
  // Detect double taps manually because iOS doesn't send dblclick events
71834
71860
  const lastTap = { time: 0, x: 0, y: 0 };
71835
71861
  canvas.addEventListener('pointerdown', (event) => {
71836
- // Store touch coordinates for tap-to-walk picking
71837
- this._lastTouchOffsetX = event.offsetX;
71838
- this._lastTouchOffsetY = event.offsetY;
71839
- // Cancel any active auto-walk on new touch input
71840
- if (state.cameraMode === 'fps' && event.pointerType === 'touch') {
71862
+ // Store coordinates for click/tap-to-walk picking
71863
+ this._lastPointerOffsetX = event.offsetX;
71864
+ this._lastPointerOffsetY = event.offsetY;
71865
+ // Cancel any active auto-walk in click-to-walk mode
71866
+ if (state.cameraMode === 'fps' && !state.gamingControls) {
71841
71867
  events.fire('walkCancel');
71842
71868
  }
71869
+ // Start desktop click-to-walk tracking
71870
+ if (event.pointerType !== 'touch' && event.button === 0) {
71871
+ this._mouseClickTracking = true;
71872
+ this._mouseClickDelta = 0;
71873
+ updateCanvasCursor();
71874
+ }
71843
71875
  const now = Date.now();
71844
71876
  const delay = Math.max(0, now - lastTap.time);
71845
71877
  if (delay < 300 &&
@@ -71854,6 +71886,31 @@ class InputController {
71854
71886
  lastTap.y = event.clientY;
71855
71887
  }
71856
71888
  });
71889
+ // Desktop click-to-walk: accumulate displacement during mouse drag
71890
+ canvas.addEventListener('pointermove', (event) => {
71891
+ if (this._mouseClickTracking && event.pointerType !== 'touch') {
71892
+ this._mouseClickDelta += Math.abs(event.movementX) + Math.abs(event.movementY);
71893
+ }
71894
+ });
71895
+ // Desktop click-to-walk: detect click (low displacement) on mouse button release
71896
+ canvas.addEventListener('pointerup', (event) => {
71897
+ if (this._mouseClickTracking && event.pointerType !== 'touch' && event.button === 0) {
71898
+ this._mouseClickTracking = false;
71899
+ updateCanvasCursor();
71900
+ if (this._mouseClickDelta < TAP_EPSILON && state.cameraMode === 'fps' && !state.gamingControls) {
71901
+ if (!this._picker) {
71902
+ this._picker = new Picker(app, camera);
71903
+ }
71904
+ const pickX = this._lastPointerOffsetX / canvas.clientWidth;
71905
+ const pickY = this._lastPointerOffsetY / canvas.clientHeight;
71906
+ this._picker.pick(pickX, pickY).then((result) => {
71907
+ if (result && state.cameraMode === 'fps' && !state.gamingControls) {
71908
+ events.fire('walkTo', result);
71909
+ }
71910
+ });
71911
+ }
71912
+ }
71913
+ });
71857
71914
  // Calculate pick location on double click
71858
71915
  events.on('inputEvent', async (eventName, event) => {
71859
71916
  switch (eventName) {
@@ -71912,6 +71969,11 @@ class InputController {
71912
71969
  case ' ':
71913
71970
  events.fire('inputEvent', 'playPause', event);
71914
71971
  break;
71972
+ case 'v':
71973
+ if (state.hasVoxelOverlay) {
71974
+ state.voxelOverlayEnabled = !state.voxelOverlayEnabled;
71975
+ }
71976
+ break;
71915
71977
  }
71916
71978
  }
71917
71979
  }
@@ -71919,43 +71981,64 @@ class InputController {
71919
71981
  // Lock/unlock Escape key in fullscreen to prevent the browser from
71920
71982
  // exiting both pointer lock and fullscreen on the same Escape press.
71921
71983
  const lockEscape = () => {
71922
- if ('keyboard' in navigator && 'lock' in navigator.keyboard) {
71923
- navigator.keyboard.lock(['Escape']).catch(() => { });
71984
+ const keyboard = navigator.keyboard;
71985
+ if (keyboard && 'lock' in keyboard) {
71986
+ keyboard.lock(['Escape']).catch(() => { });
71924
71987
  }
71925
71988
  };
71926
71989
  const unlockKeyboard = () => {
71927
- if ('keyboard' in navigator && 'unlock' in navigator.keyboard) {
71928
- navigator.keyboard.unlock();
71990
+ const keyboard = navigator.keyboard;
71991
+ if (keyboard && 'unlock' in keyboard) {
71992
+ keyboard.unlock();
71929
71993
  }
71930
71994
  };
71931
- // Pointer lock management for FPS mode on desktop
71932
- events.on('cameraMode:changed', (value, prev) => {
71933
- if (value === 'fps' && state.inputMode === 'desktop') {
71934
- this._desktopInput._pointerLock = true;
71935
- canvas.requestPointerLock();
71995
+ const activatePointerLock = () => {
71996
+ this._desktopInput._pointerLock = true;
71997
+ canvas.requestPointerLock();
71998
+ if (state.isFullscreen) {
71999
+ lockEscape();
72000
+ }
72001
+ };
72002
+ const deactivatePointerLock = () => {
72003
+ unlockKeyboard();
72004
+ this._desktopInput._pointerLock = false;
72005
+ if (document.pointerLockElement === canvas) {
71936
72006
  if (state.isFullscreen) {
71937
- lockEscape();
72007
+ events.fire('restoreFullscreen');
71938
72008
  }
72009
+ document.exitPointerLock();
72010
+ }
72011
+ };
72012
+ // Pointer lock management for FPS mode on desktop (gaming controls only)
72013
+ events.on('cameraMode:changed', (value, prev) => {
72014
+ if (value === 'fps' && state.inputMode === 'desktop' && state.gamingControls) {
72015
+ activatePointerLock();
71939
72016
  }
71940
72017
  else if (prev === 'fps') {
71941
- unlockKeyboard();
71942
- this._desktopInput._pointerLock = false;
71943
- if (document.pointerLockElement === canvas) {
71944
- if (state.isFullscreen) {
71945
- events.fire('restoreFullscreen');
71946
- }
71947
- document.exitPointerLock();
72018
+ deactivatePointerLock();
72019
+ }
72020
+ updateCanvasCursor();
72021
+ });
72022
+ // Toggle pointer lock when gaming controls changes while in FPS
72023
+ events.on('gamingControls:changed', (value) => {
72024
+ if (state.cameraMode === 'fps' && state.inputMode === 'desktop') {
72025
+ if (value) {
72026
+ activatePointerLock();
72027
+ }
72028
+ else {
72029
+ deactivatePointerLock();
71948
72030
  }
71949
72031
  }
72032
+ updateCanvasCursor();
71950
72033
  });
71951
72034
  // Also lock Escape if entering fullscreen while already in FPS mode
71952
72035
  events.on('isFullscreen:changed', (value) => {
71953
- if (value && state.cameraMode === 'fps' && state.inputMode === 'desktop') {
72036
+ if (value && state.cameraMode === 'fps' && state.inputMode === 'desktop' && state.gamingControls) {
71954
72037
  lockEscape();
71955
72038
  }
71956
72039
  });
71957
72040
  document.addEventListener('pointerlockchange', () => {
71958
- if (!document.pointerLockElement && state.cameraMode === 'fps') {
72041
+ if (!document.pointerLockElement && state.cameraMode === 'fps' && state.gamingControls) {
71959
72042
  recentlyExitedFps = true;
71960
72043
  requestAnimationFrame(() => {
71961
72044
  recentlyExitedFps = false;
@@ -72012,17 +72095,17 @@ class InputController {
72012
72095
  // Touch just ended (1+ → 0): check if it was a tap
72013
72096
  if (prevTaps > 0 && this._tapTouches === 0) {
72014
72097
  if (this._tapDelta < TAP_EPSILON) {
72015
- if (state.touchControlScheme === 'pinch') {
72098
+ if (!state.gamingControls) {
72016
72099
  // Tap-to-walk: pick the 3D location and auto-walk toward it
72017
72100
  const { app, camera } = this.global;
72018
72101
  const canvas = app.graphicsDevice.canvas;
72019
72102
  if (!this._picker) {
72020
72103
  this._picker = new Picker(app, camera);
72021
72104
  }
72022
- const pickX = this._lastTouchOffsetX / canvas.clientWidth;
72023
- const pickY = this._lastTouchOffsetY / canvas.clientHeight;
72105
+ const pickX = this._lastPointerOffsetX / canvas.clientWidth;
72106
+ const pickY = this._lastPointerOffsetY / canvas.clientHeight;
72024
72107
  this._picker.pick(pickX, pickY).then((result) => {
72025
- if (result && state.cameraMode === 'fps') {
72108
+ if (result && state.cameraMode === 'fps' && !state.gamingControls) {
72026
72109
  events.fire('walkTo', result);
72027
72110
  }
72028
72111
  });
@@ -72037,10 +72120,10 @@ class InputController {
72037
72120
  this._tapTouches = 0;
72038
72121
  }
72039
72122
  const isFirstPerson = state.cameraMode === 'fly' || isFps;
72040
- // Accumulate pinch and pan deltas into velocity when using pinch control scheme
72123
+ // Accumulate pinch and pan deltas into velocity when not in gaming controls
72041
72124
  // pinch[0] = oldDist - newDist: negative when spreading, positive when closing
72042
72125
  // Spreading = forward → subtract pinch delta
72043
- if (isFirstPerson && state.touchControlScheme === 'pinch' && this._state.touches > 1) {
72126
+ if (isFirstPerson && !state.gamingControls && this._state.touches > 1) {
72044
72127
  this._pinchVelocity -= pinch[0] * this.pinchVelocitySensitivity;
72045
72128
  this._pinchVelocity = math.clamp(this._pinchVelocity, -1, 1.0);
72046
72129
  this._panVelocity[0] += touch[0] * this.panVelocitySensitivity;
@@ -72061,6 +72144,7 @@ class InputController {
72061
72144
  const double = +(this._state.touches > 1);
72062
72145
  const pan = this._state.mouse[2] || +(button[2] === -1) || double;
72063
72146
  const orbitFactor = fly ? camera.fov / 120 : 1;
72147
+ const dragInvert = (isFps && !state.gamingControls) ? -1 : 1;
72064
72148
  const { deltas } = this.frame;
72065
72149
  // desktop move
72066
72150
  const v = tmpV1.set(0, 0, 0);
@@ -72086,14 +72170,14 @@ class InputController {
72086
72170
  deltas.move.append([v.x, v.y, orbit ? -v.z : v.z]);
72087
72171
  // desktop rotate
72088
72172
  v.set(0, 0, 0);
72089
- mouseRotate.set(mouse[0], mouse[1], 0);
72173
+ mouseRotate.set(mouse[0] * dragInvert, mouse[1] * dragInvert, 0);
72090
72174
  v.add(mouseRotate.mulScalar((1 - pan) * this.orbitSpeed * orbitFactor * this.mouseRotateSensitivity * DISPLACEMENT_SCALE));
72091
72175
  deltas.rotate.append([v.x, v.y, v.z]);
72092
72176
  // mobile move
72093
72177
  v.set(0, 0, 0);
72094
72178
  const orbitMove = screenToWorld(camera, touch[0], touch[1], distance);
72095
72179
  v.add(orbitMove.mulScalar(orbit * pan));
72096
- if (state.touchControlScheme === 'joystick') {
72180
+ if (state.gamingControls) {
72097
72181
  // Use touch joystick values for fly movement (X = strafe, Y = forward/backward)
72098
72182
  flyMove.set(this._touchJoystick[0], 0, -this._touchJoystick[1]);
72099
72183
  v.add(flyMove.mulScalar(fly * this.moveSpeed * dt));
@@ -72120,7 +72204,7 @@ class InputController {
72120
72204
  v.add(orbitRotate.mulScalar(orbit * (1 - pan) * this.orbitSpeed * this.touchRotateSensitivity * DISPLACEMENT_SCALE));
72121
72205
  // In fly mode, use single touch for look-around (inverted direction)
72122
72206
  // Exclude multi-touch (double) to avoid interference with pinch/strafe gestures
72123
- flyRotate.set(touch[0], touch[1], 0);
72207
+ flyRotate.set(touch[0] * dragInvert, touch[1] * dragInvert, 0);
72124
72208
  v.add(flyRotate.mulScalar(fly * (1 - double) * this.orbitSpeed * orbitFactor * this.touchRotateSensitivity * DISPLACEMENT_SCALE));
72125
72209
  deltas.rotate.append([v.x, v.y, v.z]);
72126
72210
  // gamepad move
@@ -73023,101 +73107,6 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
73023
73107
 
73024
73108
  return output;
73025
73109
  }`;
73026
- // ── Core billboard shaders ──────────────────────────────────────────────────
73027
- const coreVS = /* glsl */ `
73028
- attribute vec3 vertex_position;
73029
-
73030
- uniform mat4 matrix_viewProjection;
73031
- uniform mat4 walk_viewInverse;
73032
- uniform vec3 walk_target;
73033
- uniform vec4 viewport_size;
73034
-
73035
- varying vec2 vUV;
73036
-
73037
- void main() {
73038
- vec3 camRight = normalize(vec3(walk_viewInverse[0][0], 0.0, walk_viewInverse[0][2]));
73039
- vec3 up = vec3(0.0, 1.0, 0.0);
73040
-
73041
- float halfWidth = 0.0075;
73042
- float halfHeight = 10000.0;
73043
-
73044
- vec3 centerWorld = walk_target + up * vertex_position.y * halfHeight;
73045
-
73046
- vec4 targetClip = matrix_viewProjection * vec4(walk_target, 1.0);
73047
- float minPixelHalf = 1.0 / viewport_size.x * targetClip.w;
73048
- float effectiveHalfWidth = max(halfWidth, minPixelHalf);
73049
-
73050
- vec3 worldPos = centerWorld + camRight * vertex_position.x * effectiveHalfWidth;
73051
-
73052
- gl_Position = matrix_viewProjection * vec4(worldPos, 1.0);
73053
- vUV = vertex_position.xy;
73054
- }
73055
- `;
73056
- const coreVS_WGSL = /* wgsl */ `
73057
- attribute vertex_position: vec3f;
73058
- uniform matrix_viewProjection: mat4x4f;
73059
- uniform walk_viewInverse: mat4x4f;
73060
- uniform walk_target: vec3f;
73061
- uniform viewport_size: vec4f;
73062
- varying vUV: vec2f;
73063
-
73064
- @vertex fn vertexMain(input: VertexInput) -> VertexOutput {
73065
- var output: VertexOutput;
73066
-
73067
- let camRight = normalize(vec3f(uniform.walk_viewInverse[0][0], 0.0, uniform.walk_viewInverse[0][2]));
73068
- let up = vec3f(0.0, 1.0, 0.0);
73069
-
73070
- let halfWidth = 0.0075;
73071
- let halfHeight = 10000.0;
73072
-
73073
- let centerWorld = uniform.walk_target + up * input.vertex_position.y * halfHeight;
73074
-
73075
- let targetClip = uniform.matrix_viewProjection * vec4f(uniform.walk_target, 1.0);
73076
- let minPixelHalf = 1.0 / uniform.viewport_size.x * targetClip.w;
73077
- let effectiveHalfWidth = max(halfWidth, minPixelHalf);
73078
-
73079
- let worldPos = centerWorld + camRight * input.vertex_position.x * effectiveHalfWidth;
73080
-
73081
- output.position = uniform.matrix_viewProjection * vec4f(worldPos, 1.0);
73082
- output.vUV = input.vertex_position.xy;
73083
- return output;
73084
- }
73085
- `;
73086
- const coreFS = /* glsl */ `
73087
- precision highp float;
73088
-
73089
- uniform float walk_time;
73090
-
73091
- varying vec2 vUV;
73092
-
73093
- void main() {
73094
- if (abs(vUV.y) > 0.95) discard;
73095
-
73096
- float pulse = 1.0 + 0.08 * sin(walk_time * 3.0);
73097
- vec3 color = vec3(2.55, 2.76, 3.0) * pulse;
73098
-
73099
- gl_FragColor = vec4(color, 1.0);
73100
- }
73101
- `;
73102
- const coreFS_WGSL = /* wgsl */ `
73103
- uniform walk_time: f32;
73104
- varying vUV: vec2f;
73105
-
73106
- @fragment fn fragmentMain(input: FragmentInput) -> FragmentOutput {
73107
- var output: FragmentOutput;
73108
-
73109
- if (abs(input.vUV.y) > 0.95) {
73110
- discard;
73111
- return output;
73112
- }
73113
-
73114
- let pulse = 1.0 + 0.08 * sin(uniform.walk_time * 3.0);
73115
- let color = vec3f(2.55, 2.76, 3.0) * pulse;
73116
-
73117
- output.color = vec4f(color, 1.0);
73118
- return output;
73119
- }
73120
- `;
73121
73110
  // ── Particle shaders ────────────────────────────────────────────────────────
73122
73111
  const particleVS = /* glsl */ `
73123
73112
  attribute vec3 vertex_position;
@@ -73259,7 +73248,6 @@ class WalkIndicator {
73259
73248
  visible = false;
73260
73249
  origGlsl;
73261
73250
  origWgsl;
73262
- coreEntity;
73263
73251
  particleEntity;
73264
73252
  constructor(app) {
73265
73253
  this.app = app;
@@ -73270,7 +73258,6 @@ class WalkIndicator {
73270
73258
  this.origWgsl = wgsl.get('gsplatPS');
73271
73259
  glsl.set('gsplatPS', gsplatPSGlsl);
73272
73260
  wgsl.set('gsplatPS', gsplatPSWgsl);
73273
- this.coreEntity = this.createCoreEntity();
73274
73261
  this.particleEntity = this.createParticleEntity();
73275
73262
  app.on('framerender', () => {
73276
73263
  if (this.target && this.visible) {
@@ -73278,37 +73265,6 @@ class WalkIndicator {
73278
73265
  }
73279
73266
  });
73280
73267
  }
73281
- createCoreEntity() {
73282
- const device = this.app.graphicsDevice;
73283
- const mesh = new Mesh(device);
73284
- mesh.setPositions([-1, -1, 0, 1, -1, 0, 1, 1, 0, -1, 1, 0], 3);
73285
- mesh.setIndices([0, 1, 2, 0, 2, 3]);
73286
- mesh.update(PRIMITIVE_TRIANGLES);
73287
- const material = new ShaderMaterial({
73288
- uniqueName: 'walkCoreMaterial',
73289
- vertexGLSL: coreVS,
73290
- fragmentGLSL: coreFS,
73291
- vertexWGSL: coreVS_WGSL,
73292
- fragmentWGSL: coreFS_WGSL,
73293
- attributes: {
73294
- vertex_position: SEMANTIC_POSITION
73295
- }
73296
- });
73297
- material.blendType = BLEND_NONE;
73298
- material.depthWrite = true;
73299
- material.depthTest = true;
73300
- material.cull = CULLFACE_NONE;
73301
- material.update();
73302
- const mi = new MeshInstance(mesh, material);
73303
- mi.cull = false;
73304
- const entity = new Entity('walkCore');
73305
- entity.addComponent('render', {
73306
- meshInstances: [mi]
73307
- });
73308
- entity.enabled = false;
73309
- this.app.root.addChild(entity);
73310
- return entity;
73311
- }
73312
73268
  createParticleEntity() {
73313
73269
  const device = this.app.graphicsDevice;
73314
73270
  const rng = mulberry32(42);
@@ -73380,7 +73336,6 @@ class WalkIndicator {
73380
73336
  if (pos) {
73381
73337
  this.startTime = performance.now() / 1000;
73382
73338
  }
73383
- this.coreEntity.enabled = this.visible;
73384
73339
  this.particleEntity.enabled = this.visible;
73385
73340
  this.app.renderNextFrame = true;
73386
73341
  }
@@ -73400,7 +73355,6 @@ class WalkIndicator {
73400
73355
  const camPos = camera.getPosition();
73401
73356
  const dist = camPos.distance(this.target);
73402
73357
  this.visible = dist > 2.0;
73403
- this.coreEntity.enabled = this.visible;
73404
73358
  this.particleEntity.enabled = this.visible;
73405
73359
  const elapsed = performance.now() / 1000 - this.startTime;
73406
73360
  targetVec[0] = this.target.x;
@@ -73423,7 +73377,6 @@ class WalkIndicator {
73423
73377
  const device = this.app.graphicsDevice;
73424
73378
  ShaderChunks.get(device, 'glsl').set('gsplatPS', this.origGlsl);
73425
73379
  ShaderChunks.get(device, 'wgsl').set('gsplatPS', this.origWgsl);
73426
- this.coreEntity.destroy();
73427
73380
  this.particleEntity.destroy();
73428
73381
  }
73429
73382
  }
@@ -73691,8 +73644,11 @@ class Viewer {
73691
73644
  }
73692
73645
  };
73693
73646
  const quality = platform.mobile ? ranges.mobile : ranges.desktop;
73694
- // start in low quality mode so we can get user interacting asap
73695
- results[0].gsplat.splatBudget = quality.low * 1000000;
73647
+ // start by streaming in low lod
73648
+ const lodLevels = results[0].gsplat.resource?.octree?.lodLevels;
73649
+ if (lodLevels) {
73650
+ gsplat.lodRangeMax = gsplat.lodRangeMin = lodLevels - 1;
73651
+ }
73696
73652
  // these two allow LOD behind camera to drop, saves lots of splats
73697
73653
  gsplat.lodUpdateAngle = 90;
73698
73654
  gsplat.lodBehindPenalty = 5;
@@ -73710,10 +73666,12 @@ class Viewer {
73710
73666
  state.readyToRender = true;
73711
73667
  // handle quality mode changes
73712
73668
  const updateLod = () => {
73713
- const settings = state.hqMode ? quality.high : quality.low;
73669
+ const settings = state.retinaDisplay ? quality.high : quality.low;
73714
73670
  results[0].gsplat.splatBudget = settings * 1000000;
73671
+ gsplat.lodRangeMin = 0;
73672
+ gsplat.lodRangeMax = 1000;
73715
73673
  };
73716
- events.on('hqMode:changed', updateLod);
73674
+ events.on('retinaDisplay:changed', updateLod);
73717
73675
  updateLod();
73718
73676
  // debug colorize lods
73719
73677
  gsplat.colorizeLod = config.colorize;
@@ -75380,7 +75338,7 @@ const initXr = (global) => {
75380
75338
  });
75381
75339
  };
75382
75340
 
75383
- var version = "1.16.6";
75341
+ var version = "1.16.8";
75384
75342
 
75385
75343
  const loadGsplat = async (app, config, progressCallback) => {
75386
75344
  const { contents, contentUrl, unified, aa } = config;
@@ -75494,7 +75452,7 @@ const initCanvas = (global) => {
75494
75452
  // and resetting canvas dimensions can invalidate the XRWebGLLayer
75495
75453
  if (app.xr?.active)
75496
75454
  return;
75497
- const s = state.hqMode ? 1.0 : 0.5;
75455
+ const s = state.retinaDisplay ? 1.0 : 0.5;
75498
75456
  const w = Math.ceil(deviceSize.width * s);
75499
75457
  const h = Math.ceil(deviceSize.height * s);
75500
75458
  if (w !== canvas.width || h !== canvas.height) {
@@ -75510,7 +75468,7 @@ const initCanvas = (global) => {
75510
75468
  }
75511
75469
  });
75512
75470
  resizeObserver.observe(canvas);
75513
- events.on('hqMode:changed', () => {
75471
+ events.on('retinaDisplay:changed', () => {
75514
75472
  app.renderNextFrame = true;
75515
75473
  });
75516
75474
  // Resize canvas before render() so the swap chain texture is acquired at the correct size.
@@ -75528,7 +75486,7 @@ const main = async (canvas, settingsJson, config) => {
75528
75486
  const state = observe(events, {
75529
75487
  loaded: false,
75530
75488
  readyToRender: false,
75531
- hqMode: localStorage.getItem('hqMode') !== 'false',
75489
+ retinaDisplay: platform.mobile ? localStorage.getItem('retinaDisplay') === 'true' : localStorage.getItem('retinaDisplay') !== 'false',
75532
75490
  progress: 0,
75533
75491
  inputMode: platform.mobile ? 'touch' : 'desktop',
75534
75492
  cameraMode: 'orbit',
@@ -75543,7 +75501,7 @@ const main = async (canvas, settingsJson, config) => {
75543
75501
  voxelOverlayEnabled: false,
75544
75502
  isFullscreen: false,
75545
75503
  controlsHidden: false,
75546
- touchControlScheme: localStorage.getItem('touchControlScheme') || 'joystick'
75504
+ gamingControls: localStorage.getItem('gamingControls') === 'true'
75547
75505
  });
75548
75506
  const global = {
75549
75507
  app,