@playcanvas/supersplat-viewer 1.11.2 → 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/dist/index.js +2 -2
- package/package.json +1 -1
- package/public/index.css +20 -6
- package/public/index.js +157 -283
- package/public/index.js.map +1 -1
package/package.json
CHANGED
package/public/index.css
CHANGED
|
@@ -325,22 +325,36 @@ button {
|
|
|
325
325
|
|
|
326
326
|
#joystickBase {
|
|
327
327
|
position: absolute;
|
|
328
|
-
width:
|
|
329
|
-
height:
|
|
328
|
+
width: 64px;
|
|
329
|
+
height: 120px;
|
|
330
330
|
transform: translate(-50%, -50%);
|
|
331
|
-
border-radius:
|
|
331
|
+
border-radius: 32px;
|
|
332
332
|
touch-action: none;
|
|
333
|
-
background:
|
|
334
|
-
background-color: rgba(0, 0, 0, 0.
|
|
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
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
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;
|
|
335
337
|
}
|
|
336
338
|
#joystickBase > #joystick {
|
|
337
339
|
position: absolute;
|
|
340
|
+
left: 8px;
|
|
338
341
|
width: 48px;
|
|
339
342
|
height: 48px;
|
|
340
|
-
transform: translate(-50%, -50%);
|
|
341
343
|
border-radius: 50%;
|
|
342
344
|
touch-action: none;
|
|
343
345
|
background-color: rgba(255, 255, 255, 0.5333333333);
|
|
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;
|
|
344
358
|
}
|
|
345
359
|
|
|
346
360
|
#tooltip {
|
package/public/index.js
CHANGED
|
@@ -96589,9 +96589,6 @@ let InputController$1 = class InputController extends InputConsumer {
|
|
|
96589
96589
|
}
|
|
96590
96590
|
};
|
|
96591
96591
|
|
|
96592
|
-
const DOUBLE_TAP_THRESHOLD = 250;
|
|
96593
|
-
const DOUBLE_TAP_VARIANCE = 100;
|
|
96594
|
-
|
|
96595
96592
|
const movementState = ()=>{
|
|
96596
96593
|
const state = new Map();
|
|
96597
96594
|
return {
|
|
@@ -96624,223 +96621,6 @@ const movementState = ()=>{
|
|
|
96624
96621
|
};
|
|
96625
96622
|
};
|
|
96626
96623
|
|
|
96627
|
-
const v$1 = new Vec2();
|
|
96628
|
-
class VirtualJoystick {
|
|
96629
|
-
get value() {
|
|
96630
|
-
return this._value;
|
|
96631
|
-
}
|
|
96632
|
-
down(x, y) {
|
|
96633
|
-
this._position.set(x, y);
|
|
96634
|
-
this._value.set(0, 0);
|
|
96635
|
-
return [
|
|
96636
|
-
x,
|
|
96637
|
-
y,
|
|
96638
|
-
x,
|
|
96639
|
-
y
|
|
96640
|
-
];
|
|
96641
|
-
}
|
|
96642
|
-
move(x, y) {
|
|
96643
|
-
v$1.set(x - this._position.x, y - this._position.y);
|
|
96644
|
-
if (v$1.length() > this._range) {
|
|
96645
|
-
v$1.normalize().mulScalar(this._range);
|
|
96646
|
-
}
|
|
96647
|
-
this._value.set(math.clamp(v$1.x / this._range, -1, 1), math.clamp(v$1.y / this._range, -1, 1));
|
|
96648
|
-
const { x: bx, y: by } = this._position;
|
|
96649
|
-
return [
|
|
96650
|
-
bx,
|
|
96651
|
-
by,
|
|
96652
|
-
bx + v$1.x,
|
|
96653
|
-
by + v$1.y
|
|
96654
|
-
];
|
|
96655
|
-
}
|
|
96656
|
-
up() {
|
|
96657
|
-
this._position.set(0, 0);
|
|
96658
|
-
this._value.set(0, 0);
|
|
96659
|
-
return [
|
|
96660
|
-
-1,
|
|
96661
|
-
-1,
|
|
96662
|
-
-1,
|
|
96663
|
-
-1
|
|
96664
|
-
];
|
|
96665
|
-
}
|
|
96666
|
-
constructor({ range } = {}){
|
|
96667
|
-
this._range = 70;
|
|
96668
|
-
this._position = new Vec2();
|
|
96669
|
-
this._value = new Vec2();
|
|
96670
|
-
this._range = range ?? this._range;
|
|
96671
|
-
}
|
|
96672
|
-
}
|
|
96673
|
-
|
|
96674
|
-
const startsWith = (str, prefix)=>str.indexOf(prefix) === 0;
|
|
96675
|
-
const endsWith = (str, suffix)=>str.indexOf(suffix, str.length - suffix.length) !== -1;
|
|
96676
|
-
class DualGestureSource extends InputSource {
|
|
96677
|
-
set layout(value) {
|
|
96678
|
-
if (this._layout === value) {
|
|
96679
|
-
return;
|
|
96680
|
-
}
|
|
96681
|
-
this._layout = value;
|
|
96682
|
-
this.read();
|
|
96683
|
-
this._pointerData.clear();
|
|
96684
|
-
}
|
|
96685
|
-
get layout() {
|
|
96686
|
-
return this._layout;
|
|
96687
|
-
}
|
|
96688
|
-
get leftJoystick() {
|
|
96689
|
-
return this._leftJoystick;
|
|
96690
|
-
}
|
|
96691
|
-
get rightJoystick() {
|
|
96692
|
-
return this._rightJoystick;
|
|
96693
|
-
}
|
|
96694
|
-
_onPointerDown(event) {
|
|
96695
|
-
const { pointerType, pointerId, clientX, clientY } = event;
|
|
96696
|
-
this._movementState.down(event);
|
|
96697
|
-
if (pointerType !== 'touch') {
|
|
96698
|
-
return;
|
|
96699
|
-
}
|
|
96700
|
-
this._element?.setPointerCapture(pointerId);
|
|
96701
|
-
const left = clientX < window.innerWidth * 0.5;
|
|
96702
|
-
this._pointerData.set(pointerId, {
|
|
96703
|
-
x: clientX,
|
|
96704
|
-
y: clientY,
|
|
96705
|
-
left
|
|
96706
|
-
});
|
|
96707
|
-
const now = Date.now();
|
|
96708
|
-
const sqrDist = (this._lastPointer.x - clientX) ** 2 + (this._lastPointer.y - clientY) ** 2;
|
|
96709
|
-
if (sqrDist < DOUBLE_TAP_VARIANCE && now - this._lastPointer.time < DOUBLE_TAP_THRESHOLD) {
|
|
96710
|
-
this.deltas.doubleTap.append([
|
|
96711
|
-
1
|
|
96712
|
-
]);
|
|
96713
|
-
}
|
|
96714
|
-
this._lastPointer.x = clientX;
|
|
96715
|
-
this._lastPointer.y = clientY;
|
|
96716
|
-
this._lastPointer.time = now;
|
|
96717
|
-
if (left && startsWith(this._layout, 'joystick')) {
|
|
96718
|
-
this.fire('joystick:position:left', this._leftJoystick.down(clientX, clientY));
|
|
96719
|
-
}
|
|
96720
|
-
if (!left && endsWith(this._layout, 'joystick')) {
|
|
96721
|
-
this.fire('joystick:position:right', this._rightJoystick.down(clientX, clientY));
|
|
96722
|
-
}
|
|
96723
|
-
}
|
|
96724
|
-
_onPointerMove(event) {
|
|
96725
|
-
const { pointerType, pointerId, target, clientX, clientY } = event;
|
|
96726
|
-
const [movementX, movementY] = this._movementState.move(event);
|
|
96727
|
-
if (pointerType !== 'touch') {
|
|
96728
|
-
return;
|
|
96729
|
-
}
|
|
96730
|
-
if (target !== this._element) {
|
|
96731
|
-
return;
|
|
96732
|
-
}
|
|
96733
|
-
const data = this._pointerData.get(pointerId);
|
|
96734
|
-
if (!data) {
|
|
96735
|
-
return;
|
|
96736
|
-
}
|
|
96737
|
-
const { left } = data;
|
|
96738
|
-
data.x = clientX;
|
|
96739
|
-
data.y = clientY;
|
|
96740
|
-
if (left) {
|
|
96741
|
-
if (startsWith(this._layout, 'joystick')) {
|
|
96742
|
-
this.fire('joystick:position:left', this._leftJoystick.move(clientX, clientY));
|
|
96743
|
-
} else {
|
|
96744
|
-
this.deltas.leftInput.append([
|
|
96745
|
-
movementX,
|
|
96746
|
-
movementY
|
|
96747
|
-
]);
|
|
96748
|
-
}
|
|
96749
|
-
} else {
|
|
96750
|
-
if (endsWith(this._layout, 'joystick')) {
|
|
96751
|
-
this.fire('joystick:position:right', this._rightJoystick.move(clientX, clientY));
|
|
96752
|
-
} else {
|
|
96753
|
-
this.deltas.rightInput.append([
|
|
96754
|
-
movementX,
|
|
96755
|
-
movementY
|
|
96756
|
-
]);
|
|
96757
|
-
}
|
|
96758
|
-
}
|
|
96759
|
-
}
|
|
96760
|
-
_onPointerUp(event) {
|
|
96761
|
-
const { pointerType, pointerId } = event;
|
|
96762
|
-
this._movementState.up(event);
|
|
96763
|
-
if (pointerType !== 'touch') {
|
|
96764
|
-
return;
|
|
96765
|
-
}
|
|
96766
|
-
this._element?.releasePointerCapture(pointerId);
|
|
96767
|
-
const data = this._pointerData.get(pointerId);
|
|
96768
|
-
if (!data) {
|
|
96769
|
-
return;
|
|
96770
|
-
}
|
|
96771
|
-
const { left } = data;
|
|
96772
|
-
this._pointerData.delete(pointerId);
|
|
96773
|
-
if (left && startsWith(this._layout, 'joystick')) {
|
|
96774
|
-
this.fire('joystick:position:left', this._leftJoystick.up());
|
|
96775
|
-
}
|
|
96776
|
-
if (!left && endsWith(this._layout, 'joystick')) {
|
|
96777
|
-
this.fire('joystick:position:right', this._rightJoystick.up());
|
|
96778
|
-
}
|
|
96779
|
-
}
|
|
96780
|
-
attach(element) {
|
|
96781
|
-
super.attach(element);
|
|
96782
|
-
this._element = element;
|
|
96783
|
-
this._element.addEventListener('pointerdown', this._onPointerDown);
|
|
96784
|
-
this._element.addEventListener('pointermove', this._onPointerMove);
|
|
96785
|
-
this._element.addEventListener('pointerup', this._onPointerUp);
|
|
96786
|
-
this._element.addEventListener('pointercancel', this._onPointerUp);
|
|
96787
|
-
}
|
|
96788
|
-
detach() {
|
|
96789
|
-
if (!this._element) {
|
|
96790
|
-
return;
|
|
96791
|
-
}
|
|
96792
|
-
this._element.removeEventListener('pointerdown', this._onPointerDown);
|
|
96793
|
-
this._element.removeEventListener('pointermove', this._onPointerMove);
|
|
96794
|
-
this._element.removeEventListener('pointerup', this._onPointerUp);
|
|
96795
|
-
this._element.removeEventListener('pointercancel', this._onPointerUp);
|
|
96796
|
-
this._pointerData.clear();
|
|
96797
|
-
super.detach();
|
|
96798
|
-
}
|
|
96799
|
-
read() {
|
|
96800
|
-
this.deltas.leftInput.append([
|
|
96801
|
-
this._leftJoystick.value.x,
|
|
96802
|
-
this._leftJoystick.value.y
|
|
96803
|
-
]);
|
|
96804
|
-
this.deltas.rightInput.append([
|
|
96805
|
-
this._rightJoystick.value.x,
|
|
96806
|
-
this._rightJoystick.value.y
|
|
96807
|
-
]);
|
|
96808
|
-
return super.read();
|
|
96809
|
-
}
|
|
96810
|
-
destroy() {
|
|
96811
|
-
this._leftJoystick.up();
|
|
96812
|
-
this._rightJoystick.up();
|
|
96813
|
-
super.destroy();
|
|
96814
|
-
}
|
|
96815
|
-
constructor(layout){
|
|
96816
|
-
super({
|
|
96817
|
-
leftInput: [
|
|
96818
|
-
0,
|
|
96819
|
-
0
|
|
96820
|
-
],
|
|
96821
|
-
rightInput: [
|
|
96822
|
-
0,
|
|
96823
|
-
0
|
|
96824
|
-
],
|
|
96825
|
-
doubleTap: [
|
|
96826
|
-
0
|
|
96827
|
-
]
|
|
96828
|
-
}), this._movementState = movementState(), this._layout = 'joystick-touch', this._pointerData = new Map(), this._lastPointer = {
|
|
96829
|
-
x: 0,
|
|
96830
|
-
y: 0,
|
|
96831
|
-
time: 0
|
|
96832
|
-
};
|
|
96833
|
-
if (layout) {
|
|
96834
|
-
this.layout = layout;
|
|
96835
|
-
}
|
|
96836
|
-
this._leftJoystick = new VirtualJoystick();
|
|
96837
|
-
this._rightJoystick = new VirtualJoystick();
|
|
96838
|
-
this._onPointerDown = this._onPointerDown.bind(this);
|
|
96839
|
-
this._onPointerMove = this._onPointerMove.bind(this);
|
|
96840
|
-
this._onPointerUp = this._onPointerUp.bind(this);
|
|
96841
|
-
}
|
|
96842
|
-
}
|
|
96843
|
-
|
|
96844
96624
|
const tmpVa = new Vec2();
|
|
96845
96625
|
class MultiTouchSource extends InputSource {
|
|
96846
96626
|
_onPointerDown(event) {
|
|
@@ -102519,7 +102299,116 @@ class Tooltip {
|
|
|
102519
102299
|
}
|
|
102520
102300
|
}
|
|
102521
102301
|
|
|
102522
|
-
|
|
102302
|
+
// Initialize the touch joystick for fly mode camera control
|
|
102303
|
+
const initJoystick = (dom, events, state) => {
|
|
102304
|
+
// Joystick dimensions (matches SCSS: base height=120, stick size=48)
|
|
102305
|
+
const joystickHeight = 120;
|
|
102306
|
+
const stickSize = 48;
|
|
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)
|
|
102309
|
+
const maxStickTravel = stickCenterY; // can travel 36px up or down from center
|
|
102310
|
+
// Fixed joystick position (bottom-left corner with safe area)
|
|
102311
|
+
const joystickFixedX = 60;
|
|
102312
|
+
const joystickFixedY = () => window.innerHeight - 140;
|
|
102313
|
+
// Joystick touch state
|
|
102314
|
+
let joystickPointerId = null;
|
|
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;
|
|
102321
|
+
// Update joystick visibility based on camera mode and input mode
|
|
102322
|
+
const updateJoystickVisibility = () => {
|
|
102323
|
+
if (state.cameraMode === 'fly' && state.inputMode === 'touch') {
|
|
102324
|
+
dom.joystickBase.classList.remove('hidden');
|
|
102325
|
+
dom.joystickBase.classList.toggle('mode-2d', joystickMode === '2d');
|
|
102326
|
+
dom.joystickBase.style.left = `${joystickFixedX}px`;
|
|
102327
|
+
dom.joystickBase.style.top = `${joystickFixedY()}px`;
|
|
102328
|
+
// Center the stick
|
|
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
|
+
}
|
|
102336
|
+
}
|
|
102337
|
+
else {
|
|
102338
|
+
dom.joystickBase.classList.add('hidden');
|
|
102339
|
+
}
|
|
102340
|
+
};
|
|
102341
|
+
events.on('cameraMode:changed', updateJoystickVisibility);
|
|
102342
|
+
events.on('inputMode:changed', updateJoystickVisibility);
|
|
102343
|
+
window.addEventListener('resize', updateJoystickVisibility);
|
|
102344
|
+
// Handle joystick touch input directly on the joystick element
|
|
102345
|
+
const updateJoystickStick = (clientX, clientY) => {
|
|
102346
|
+
const baseY = joystickFixedY();
|
|
102347
|
+
// Calculate Y offset from joystick center (positive = down/backward)
|
|
102348
|
+
const offsetY = clientY - baseY;
|
|
102349
|
+
// Clamp to max travel and normalize to -1 to 1
|
|
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
|
+
}
|
|
102366
|
+
// Fire input event for the input controller
|
|
102367
|
+
events.fire('joystickInput', { x: joystickValueX, y: joystickValueY });
|
|
102368
|
+
};
|
|
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
|
+
}
|
|
102380
|
+
if (joystickPointerId !== null)
|
|
102381
|
+
return; // Already tracking a touch
|
|
102382
|
+
joystickPointerId = event.pointerId;
|
|
102383
|
+
dom.joystickBase.setPointerCapture(event.pointerId);
|
|
102384
|
+
updateJoystickStick(event.clientX, event.clientY);
|
|
102385
|
+
event.preventDefault();
|
|
102386
|
+
event.stopPropagation();
|
|
102387
|
+
});
|
|
102388
|
+
dom.joystickBase.addEventListener('pointermove', (event) => {
|
|
102389
|
+
if (event.pointerId !== joystickPointerId)
|
|
102390
|
+
return;
|
|
102391
|
+
updateJoystickStick(event.clientX, event.clientY);
|
|
102392
|
+
event.preventDefault();
|
|
102393
|
+
});
|
|
102394
|
+
const endJoystickTouch = (event) => {
|
|
102395
|
+
if (event.pointerId !== joystickPointerId)
|
|
102396
|
+
return;
|
|
102397
|
+
joystickPointerId = null;
|
|
102398
|
+
joystickValueX = 0;
|
|
102399
|
+
joystickValueY = 0;
|
|
102400
|
+
// Reset stick to center
|
|
102401
|
+
dom.joystick.style.top = `${stickCenterY}px`;
|
|
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 });
|
|
102407
|
+
dom.joystickBase.releasePointerCapture(event.pointerId);
|
|
102408
|
+
};
|
|
102409
|
+
dom.joystickBase.addEventListener('pointerup', endJoystickTouch);
|
|
102410
|
+
dom.joystickBase.addEventListener('pointercancel', endJoystickTouch);
|
|
102411
|
+
};
|
|
102523
102412
|
// update the poster image to start blurry and then resolve to sharp during loading
|
|
102524
102413
|
const initPoster = (events) => {
|
|
102525
102414
|
const poster = document.getElementById('poster');
|
|
@@ -102787,24 +102676,8 @@ const initUI = (global) => {
|
|
|
102787
102676
|
dom.frame.addEventListener('click', (event) => {
|
|
102788
102677
|
events.fire('inputEvent', 'frame', event);
|
|
102789
102678
|
});
|
|
102790
|
-
//
|
|
102791
|
-
|
|
102792
|
-
if (base === null) {
|
|
102793
|
-
dom.joystickBase.classList.add('hidden');
|
|
102794
|
-
}
|
|
102795
|
-
else {
|
|
102796
|
-
v.set(stick[0], stick[1], 0).mulScalar(1 / 48);
|
|
102797
|
-
if (v.length() > 1) {
|
|
102798
|
-
v.normalize();
|
|
102799
|
-
}
|
|
102800
|
-
v.mulScalar(48);
|
|
102801
|
-
dom.joystickBase.classList.remove('hidden');
|
|
102802
|
-
dom.joystickBase.style.left = `${base[0]}px`;
|
|
102803
|
-
dom.joystickBase.style.top = `${base[1]}px`;
|
|
102804
|
-
dom.joystick.style.left = `${48 + v.x}px`;
|
|
102805
|
-
dom.joystick.style.top = `${48 + v.y}px`;
|
|
102806
|
-
}
|
|
102807
|
-
});
|
|
102679
|
+
// Initialize touch joystick for fly mode
|
|
102680
|
+
initJoystick(dom, events, state);
|
|
102808
102681
|
// Hide all UI (poster, loading bar, controls)
|
|
102809
102682
|
if (config.noui) {
|
|
102810
102683
|
dom.ui.classList.add('hidden');
|
|
@@ -104075,6 +103948,28 @@ const screenToWorld = (camera, dx, dy, dz, out = new Vec3()) => {
|
|
|
104075
103948
|
out.mul(halfSize);
|
|
104076
103949
|
return out;
|
|
104077
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
|
+
};
|
|
104078
103973
|
class InputController {
|
|
104079
103974
|
_state = {
|
|
104080
103975
|
axis: new Vec3(),
|
|
@@ -104085,14 +103980,15 @@ class InputController {
|
|
|
104085
103980
|
};
|
|
104086
103981
|
_desktopInput = new KeyboardMouseSource();
|
|
104087
103982
|
_orbitInput = new MultiTouchSource();
|
|
104088
|
-
_flyInput = new DualGestureSource();
|
|
104089
103983
|
_gamepadInput = new GamepadSource();
|
|
104090
103984
|
global;
|
|
104091
103985
|
frame = new InputFrame({
|
|
104092
103986
|
move: [0, 0, 0],
|
|
104093
103987
|
rotate: [0, 0, 0]
|
|
104094
103988
|
});
|
|
104095
|
-
|
|
103989
|
+
// Touch joystick input values (-1 to 1)
|
|
103990
|
+
_touchJoystickX = 0; // negative = left, positive = right
|
|
103991
|
+
_touchJoystickY = 0; // negative = forward, positive = backward
|
|
104096
103992
|
// this gets overridden by the viewer based on scene size
|
|
104097
103993
|
moveSpeed = 4;
|
|
104098
103994
|
orbitSpeed = 18;
|
|
@@ -104101,18 +103997,13 @@ class InputController {
|
|
|
104101
103997
|
constructor(global) {
|
|
104102
103998
|
const { app, camera, events, state } = global;
|
|
104103
103999
|
const canvas = app.graphicsDevice.canvas;
|
|
104000
|
+
patchKeyboardMeta(this._desktopInput);
|
|
104104
104001
|
this._desktopInput.attach(canvas);
|
|
104105
104002
|
this._orbitInput.attach(canvas);
|
|
104106
|
-
|
|
104107
|
-
|
|
104108
|
-
|
|
104109
|
-
|
|
104110
|
-
this.joystick.base = null;
|
|
104111
|
-
this.joystick.stick = null;
|
|
104112
|
-
return;
|
|
104113
|
-
}
|
|
104114
|
-
this.joystick.base = [bx, by];
|
|
104115
|
-
this.joystick.stick = [sx - bx, sy - by];
|
|
104003
|
+
// Listen for joystick input from the UI (touch joystick element)
|
|
104004
|
+
events.on('joystickInput', (value) => {
|
|
104005
|
+
this._touchJoystickX = value.x;
|
|
104006
|
+
this._touchJoystickY = value.y;
|
|
104116
104007
|
});
|
|
104117
104008
|
this.global = global;
|
|
104118
104009
|
// Generate input events
|
|
@@ -104193,9 +104084,8 @@ class InputController {
|
|
|
104193
104084
|
const { keyCode } = KeyboardMouseSource;
|
|
104194
104085
|
const { key, button, mouse, wheel } = this._desktopInput.read();
|
|
104195
104086
|
const { touch, pinch, count } = this._orbitInput.read();
|
|
104196
|
-
const { leftInput, rightInput } = this._flyInput.read();
|
|
104197
104087
|
const { leftStick, rightStick } = this._gamepadInput.read();
|
|
104198
|
-
const {
|
|
104088
|
+
const { state } = this.global;
|
|
104199
104089
|
const { camera } = this.global.camera;
|
|
104200
104090
|
// update state
|
|
104201
104091
|
this._state.axis.add(tmpV1.set((key[keyCode.D] - key[keyCode.A]) + (key[keyCode.RIGHT] - key[keyCode.LEFT]), (key[keyCode.E] - key[keyCode.Q]), (key[keyCode.W] - key[keyCode.S]) + (key[keyCode.UP] - key[keyCode.DOWN])));
|
|
@@ -104233,7 +104123,8 @@ class InputController {
|
|
|
104233
104123
|
v.set(0, 0, 0);
|
|
104234
104124
|
const orbitMove = screenToWorld(camera, touch[0], touch[1], distance);
|
|
104235
104125
|
v.add(orbitMove.mulScalar(orbit * pan));
|
|
104236
|
-
|
|
104126
|
+
// Use touch joystick values for fly movement (X = strafe, Y = forward/backward)
|
|
104127
|
+
flyMove.set(this._touchJoystickX, 0, -this._touchJoystickY);
|
|
104237
104128
|
v.add(flyMove.mulScalar(fly * this.moveSpeed * dt));
|
|
104238
104129
|
pinchMove.set(0, 0, pinch[0]);
|
|
104239
104130
|
v.add(pinchMove.mulScalar(orbit * double * this.pinchSpeed * dt));
|
|
@@ -104242,8 +104133,11 @@ class InputController {
|
|
|
104242
104133
|
v.set(0, 0, 0);
|
|
104243
104134
|
orbitRotate.set(touch[0], touch[1], 0);
|
|
104244
104135
|
v.add(orbitRotate.mulScalar(orbit * (1 - pan) * this.orbitSpeed * dt));
|
|
104245
|
-
|
|
104246
|
-
|
|
104136
|
+
// In fly mode, use any touch for look-around (joystick captures its own touches)
|
|
104137
|
+
// Exclude multi-touch (double) to avoid interference with pinch gestures
|
|
104138
|
+
// 1.25x sensitivity for touch look-around
|
|
104139
|
+
flyRotate.set(touch[0], touch[1], 0);
|
|
104140
|
+
v.add(flyRotate.mulScalar(fly * (1 - double) * this.orbitSpeed * orbitFactor * 1.25 * dt));
|
|
104247
104141
|
deltas.rotate.append([v.x, v.y, v.z]);
|
|
104248
104142
|
// gamepad move
|
|
104249
104143
|
v.set(0, 0, 0);
|
|
@@ -104255,10 +104149,6 @@ class InputController {
|
|
|
104255
104149
|
stickRotate.set(rightStick[0], rightStick[1], 0);
|
|
104256
104150
|
v.add(stickRotate.mulScalar(this.orbitSpeed * orbitFactor * dt));
|
|
104257
104151
|
deltas.rotate.append([v.x, v.y, v.z]);
|
|
104258
|
-
// update touch joystick UI
|
|
104259
|
-
if (state.cameraMode === 'fly') {
|
|
104260
|
-
events.fire('touchJoystickUpdate', this.joystick.base, this.joystick.stick);
|
|
104261
|
-
}
|
|
104262
104152
|
}
|
|
104263
104153
|
}
|
|
104264
104154
|
|
|
@@ -104514,31 +104404,17 @@ class Viewer {
|
|
|
104514
104404
|
// quality ranges
|
|
104515
104405
|
const ranges = {
|
|
104516
104406
|
mobile: {
|
|
104517
|
-
low:
|
|
104518
|
-
|
|
104519
|
-
splatBudget: 1
|
|
104520
|
-
},
|
|
104521
|
-
high: {
|
|
104522
|
-
range: [1, 8],
|
|
104523
|
-
splatBudget: 2
|
|
104524
|
-
}
|
|
104407
|
+
low: 1,
|
|
104408
|
+
high: 2
|
|
104525
104409
|
},
|
|
104526
104410
|
desktop: {
|
|
104527
|
-
low:
|
|
104528
|
-
|
|
104529
|
-
splatBudget: 3
|
|
104530
|
-
},
|
|
104531
|
-
high: {
|
|
104532
|
-
range: [0, 8],
|
|
104533
|
-
splatBudget: 6
|
|
104534
|
-
}
|
|
104411
|
+
low: 3,
|
|
104412
|
+
high: 6
|
|
104535
104413
|
}
|
|
104536
104414
|
};
|
|
104537
104415
|
const quality = platform.mobile ? ranges.mobile : ranges.desktop;
|
|
104538
104416
|
// start in low quality mode so we can get user interacting asap
|
|
104539
|
-
gsplat.
|
|
104540
|
-
gsplat.lodRangeMax = quality.low.range[1];
|
|
104541
|
-
results[0].gsplat.splatBudget = quality.low.splatBudget * 1000000;
|
|
104417
|
+
results[0].gsplat.splatBudget = quality.low * 1000000;
|
|
104542
104418
|
// these two allow LOD behind camera to drop, saves lots of splats
|
|
104543
104419
|
gsplat.lodUpdateAngle = 90;
|
|
104544
104420
|
gsplat.lodBehindPenalty = 5;
|
|
@@ -104557,9 +104433,7 @@ class Viewer {
|
|
|
104557
104433
|
// handle quality mode changes
|
|
104558
104434
|
const updateLod = () => {
|
|
104559
104435
|
const settings = state.hqMode ? quality.high : quality.low;
|
|
104560
|
-
gsplat.
|
|
104561
|
-
gsplat.lodRangeMax = settings.range[1];
|
|
104562
|
-
results[0].gsplat.splatBudget = settings.splatBudget * 1000000;
|
|
104436
|
+
results[0].gsplat.splatBudget = settings * 1000000;
|
|
104563
104437
|
};
|
|
104564
104438
|
events.on('hqMode:changed', updateLod);
|
|
104565
104439
|
updateLod();
|
|
@@ -105521,7 +105395,7 @@ const initXr = (global) => {
|
|
|
105521
105395
|
});
|
|
105522
105396
|
};
|
|
105523
105397
|
|
|
105524
|
-
var version = "1.
|
|
105398
|
+
var version = "1.12.1";
|
|
105525
105399
|
|
|
105526
105400
|
const loadGsplat = async (app, config, progressCallback) => {
|
|
105527
105401
|
const { contents, contentUrl, unified, aa } = config;
|