@playcanvas/supersplat-viewer 1.12.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcanvas/supersplat-viewer",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "author": "PlayCanvas <support@playcanvas.com>",
5
5
  "homepage": "https://github.com/playcanvas/supersplat-viewer#readme",
6
6
  "description": "Viewer for https://superspl.at",
package/public/index.css CHANGED
@@ -333,6 +333,7 @@ button {
333
333
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2666666667) 0%, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.2666666667) 100%);
334
334
  background-color: rgba(0, 0, 0, 0.2);
335
335
  border: 2px solid rgba(255, 255, 255, 0.2);
336
+ transition: width 0.2s ease, height 0.2s ease, border-radius 0.2s ease;
336
337
  }
337
338
  #joystickBase > #joystick {
338
339
  position: absolute;
@@ -343,6 +344,17 @@ button {
343
344
  touch-action: none;
344
345
  background-color: rgba(255, 255, 255, 0.5333333333);
345
346
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
347
+ transition: left 0.1s ease;
348
+ }
349
+ #joystickBase.mode-2d {
350
+ width: 120px;
351
+ height: 120px;
352
+ border-radius: 60px;
353
+ background: radial-gradient(circle, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.2666666667) 100%);
354
+ background-color: rgba(0, 0, 0, 0.2);
355
+ }
356
+ #joystickBase.mode-2d > #joystick {
357
+ left: 36px;
346
358
  }
347
359
 
348
360
  #tooltip {
package/public/index.js CHANGED
@@ -102305,21 +102305,34 @@ const initJoystick = (dom, events, state) => {
102305
102305
  const joystickHeight = 120;
102306
102306
  const stickSize = 48;
102307
102307
  const stickCenterY = (joystickHeight - stickSize) / 2; // 36px - top position when centered
102308
+ const stickCenterX = (joystickHeight - stickSize) / 2; // 36px - left position when centered (for 2D mode)
102308
102309
  const maxStickTravel = stickCenterY; // can travel 36px up or down from center
102309
102310
  // Fixed joystick position (bottom-left corner with safe area)
102310
102311
  const joystickFixedX = 60;
102311
102312
  const joystickFixedY = () => window.innerHeight - 140;
102312
102313
  // Joystick touch state
102313
102314
  let joystickPointerId = null;
102314
- let joystickValue = 0; // -1 to 1, negative = forward, positive = backward
102315
+ let joystickValueX = 0; // -1 to 1, negative = left, positive = right
102316
+ let joystickValueY = 0; // -1 to 1, negative = forward, positive = backward
102317
+ // Joystick mode: '1d' for vertical only, '2d' for full directional
102318
+ let joystickMode = '1d';
102319
+ // Double-tap detection for mode toggle
102320
+ let lastTapTime = 0;
102315
102321
  // Update joystick visibility based on camera mode and input mode
102316
102322
  const updateJoystickVisibility = () => {
102317
102323
  if (state.cameraMode === 'fly' && state.inputMode === 'touch') {
102318
102324
  dom.joystickBase.classList.remove('hidden');
102325
+ dom.joystickBase.classList.toggle('mode-2d', joystickMode === '2d');
102319
102326
  dom.joystickBase.style.left = `${joystickFixedX}px`;
102320
102327
  dom.joystickBase.style.top = `${joystickFixedY()}px`;
102321
- // Center the stick vertically (top edge at 36px)
102328
+ // Center the stick
102322
102329
  dom.joystick.style.top = `${stickCenterY}px`;
102330
+ if (joystickMode === '2d') {
102331
+ dom.joystick.style.left = `${stickCenterX}px`;
102332
+ }
102333
+ else {
102334
+ dom.joystick.style.left = '8px'; // Reset to 1D centered position
102335
+ }
102323
102336
  }
102324
102337
  else {
102325
102338
  dom.joystickBase.classList.add('hidden');
@@ -102329,42 +102342,68 @@ const initJoystick = (dom, events, state) => {
102329
102342
  events.on('inputMode:changed', updateJoystickVisibility);
102330
102343
  window.addEventListener('resize', updateJoystickVisibility);
102331
102344
  // Handle joystick touch input directly on the joystick element
102332
- const updateJoystickStick = (clientY) => {
102345
+ const updateJoystickStick = (clientX, clientY) => {
102333
102346
  const baseY = joystickFixedY();
102334
- // Calculate offset from joystick center (positive = down/backward)
102347
+ // Calculate Y offset from joystick center (positive = down/backward)
102335
102348
  const offsetY = clientY - baseY;
102336
102349
  // Clamp to max travel and normalize to -1 to 1
102337
- const clampedOffset = Math.max(-maxStickTravel, Math.min(maxStickTravel, offsetY));
102338
- joystickValue = clampedOffset / maxStickTravel;
102339
- // Update stick visual position
102340
- dom.joystick.style.top = `${stickCenterY + clampedOffset}px`;
102350
+ const clampedOffsetY = Math.max(-maxStickTravel, Math.min(maxStickTravel, offsetY));
102351
+ joystickValueY = clampedOffsetY / maxStickTravel;
102352
+ // Update stick visual Y position
102353
+ dom.joystick.style.top = `${stickCenterY + clampedOffsetY}px`;
102354
+ // Handle X axis in 2D mode
102355
+ if (joystickMode === '2d') {
102356
+ const baseX = joystickFixedX;
102357
+ const offsetX = clientX - baseX;
102358
+ const clampedOffsetX = Math.max(-maxStickTravel, Math.min(maxStickTravel, offsetX));
102359
+ joystickValueX = clampedOffsetX / maxStickTravel;
102360
+ // Update stick visual X position
102361
+ dom.joystick.style.left = `${stickCenterX + clampedOffsetX}px`;
102362
+ }
102363
+ else {
102364
+ joystickValueX = 0;
102365
+ }
102341
102366
  // Fire input event for the input controller
102342
- events.fire('joystickInput', joystickValue);
102367
+ events.fire('joystickInput', { x: joystickValueX, y: joystickValueY });
102343
102368
  };
102344
102369
  dom.joystickBase.addEventListener('pointerdown', (event) => {
102370
+ // Double-tap detection for mode toggle
102371
+ const now = Date.now();
102372
+ if (now - lastTapTime < 300) {
102373
+ joystickMode = joystickMode === '1d' ? '2d' : '1d';
102374
+ updateJoystickVisibility();
102375
+ lastTapTime = 0;
102376
+ }
102377
+ else {
102378
+ lastTapTime = now;
102379
+ }
102345
102380
  if (joystickPointerId !== null)
102346
102381
  return; // Already tracking a touch
102347
102382
  joystickPointerId = event.pointerId;
102348
102383
  dom.joystickBase.setPointerCapture(event.pointerId);
102349
- updateJoystickStick(event.clientY);
102384
+ updateJoystickStick(event.clientX, event.clientY);
102350
102385
  event.preventDefault();
102351
102386
  event.stopPropagation();
102352
102387
  });
102353
102388
  dom.joystickBase.addEventListener('pointermove', (event) => {
102354
102389
  if (event.pointerId !== joystickPointerId)
102355
102390
  return;
102356
- updateJoystickStick(event.clientY);
102391
+ updateJoystickStick(event.clientX, event.clientY);
102357
102392
  event.preventDefault();
102358
102393
  });
102359
102394
  const endJoystickTouch = (event) => {
102360
102395
  if (event.pointerId !== joystickPointerId)
102361
102396
  return;
102362
102397
  joystickPointerId = null;
102363
- joystickValue = 0;
102398
+ joystickValueX = 0;
102399
+ joystickValueY = 0;
102364
102400
  // Reset stick to center
102365
102401
  dom.joystick.style.top = `${stickCenterY}px`;
102366
- // Fire input event with zero value
102367
- events.fire('joystickInput', 0);
102402
+ if (joystickMode === '2d') {
102403
+ dom.joystick.style.left = `${stickCenterX}px`;
102404
+ }
102405
+ // Fire input event with zero values
102406
+ events.fire('joystickInput', { x: 0, y: 0 });
102368
102407
  dom.joystickBase.releasePointerCapture(event.pointerId);
102369
102408
  };
102370
102409
  dom.joystickBase.addEventListener('pointerup', endJoystickTouch);
@@ -103909,6 +103948,28 @@ const screenToWorld = (camera, dx, dy, dz, out = new Vec3()) => {
103909
103948
  out.mul(halfSize);
103910
103949
  return out;
103911
103950
  };
103951
+ // patch keydown and keyup to ignore events with meta key otherwise
103952
+ // keys can get stuck on macOS.
103953
+ const patchKeyboardMeta = (desktopInput) => {
103954
+ const origOnKeyDown = desktopInput._onKeyDown;
103955
+ desktopInput._onKeyDown = (event) => {
103956
+ if (event.key === 'Meta') {
103957
+ desktopInput._keyNow.fill(0);
103958
+ }
103959
+ else if (!event.metaKey) {
103960
+ origOnKeyDown(event);
103961
+ }
103962
+ };
103963
+ const origOnKeyUp = desktopInput._onKeyUp;
103964
+ desktopInput._onKeyUp = (event) => {
103965
+ if (event.key === 'Meta') {
103966
+ desktopInput._keyNow.fill(0);
103967
+ }
103968
+ else if (!event.metaKey) {
103969
+ origOnKeyUp(event);
103970
+ }
103971
+ };
103972
+ };
103912
103973
  class InputController {
103913
103974
  _state = {
103914
103975
  axis: new Vec3(),
@@ -103925,8 +103986,9 @@ class InputController {
103925
103986
  move: [0, 0, 0],
103926
103987
  rotate: [0, 0, 0]
103927
103988
  });
103928
- // Touch joystick input value (-1 to 1, negative = forward)
103929
- _touchJoystickValue = 0;
103989
+ // Touch joystick input values (-1 to 1)
103990
+ _touchJoystickX = 0; // negative = left, positive = right
103991
+ _touchJoystickY = 0; // negative = forward, positive = backward
103930
103992
  // this gets overridden by the viewer based on scene size
103931
103993
  moveSpeed = 4;
103932
103994
  orbitSpeed = 18;
@@ -103935,11 +103997,13 @@ class InputController {
103935
103997
  constructor(global) {
103936
103998
  const { app, camera, events, state } = global;
103937
103999
  const canvas = app.graphicsDevice.canvas;
104000
+ patchKeyboardMeta(this._desktopInput);
103938
104001
  this._desktopInput.attach(canvas);
103939
104002
  this._orbitInput.attach(canvas);
103940
104003
  // Listen for joystick input from the UI (touch joystick element)
103941
104004
  events.on('joystickInput', (value) => {
103942
- this._touchJoystickValue = value;
104005
+ this._touchJoystickX = value.x;
104006
+ this._touchJoystickY = value.y;
103943
104007
  });
103944
104008
  this.global = global;
103945
104009
  // Generate input events
@@ -104059,8 +104123,8 @@ class InputController {
104059
104123
  v.set(0, 0, 0);
104060
104124
  const orbitMove = screenToWorld(camera, touch[0], touch[1], distance);
104061
104125
  v.add(orbitMove.mulScalar(orbit * pan));
104062
- // Use touch joystick value for fly movement (negative = forward)
104063
- flyMove.set(0, 0, -this._touchJoystickValue);
104126
+ // Use touch joystick values for fly movement (X = strafe, Y = forward/backward)
104127
+ flyMove.set(this._touchJoystickX, 0, -this._touchJoystickY);
104064
104128
  v.add(flyMove.mulScalar(fly * this.moveSpeed * dt));
104065
104129
  pinchMove.set(0, 0, pinch[0]);
104066
104130
  v.add(pinchMove.mulScalar(orbit * double * this.pinchSpeed * dt));
@@ -104071,9 +104135,9 @@ class InputController {
104071
104135
  v.add(orbitRotate.mulScalar(orbit * (1 - pan) * this.orbitSpeed * dt));
104072
104136
  // In fly mode, use any touch for look-around (joystick captures its own touches)
104073
104137
  // Exclude multi-touch (double) to avoid interference with pinch gestures
104074
- // 1.5x sensitivity for touch look-around
104138
+ // 1.25x sensitivity for touch look-around
104075
104139
  flyRotate.set(touch[0], touch[1], 0);
104076
- v.add(flyRotate.mulScalar(fly * (1 - double) * this.orbitSpeed * orbitFactor * 1.5 * dt));
104140
+ v.add(flyRotate.mulScalar(fly * (1 - double) * this.orbitSpeed * orbitFactor * 1.25 * dt));
104077
104141
  deltas.rotate.append([v.x, v.y, v.z]);
104078
104142
  // gamepad move
104079
104143
  v.set(0, 0, 0);
@@ -105331,7 +105395,7 @@ const initXr = (global) => {
105331
105395
  });
105332
105396
  };
105333
105397
 
105334
- var version = "1.12.0";
105398
+ var version = "1.12.1";
105335
105399
 
105336
105400
  const loadGsplat = async (app, config, progressCallback) => {
105337
105401
  const { contents, contentUrl, unified, aa } = config;