@playcanvas/supersplat-viewer 1.23.0 → 1.24.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/dist/index.js +2 -2
- package/package.json +1 -1
- package/public/index.html +2 -1
- package/public/index.js +392 -40
- package/public/index.js.map +1 -1
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
budget,
|
|
44
44
|
heatmap: url.searchParams.has('heatmap'),
|
|
45
45
|
fullload: url.searchParams.has('fullload'),
|
|
46
|
+
debug: url.searchParams.has('debug'),
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
window.sse = {
|
|
@@ -354,7 +355,7 @@
|
|
|
354
355
|
<span class="control-action">Toggle Gaming Controls</span>
|
|
355
356
|
<span class="control-key">G</span>
|
|
356
357
|
</div>
|
|
357
|
-
<div class="control-item">
|
|
358
|
+
<div id="desktopShowCollisionHelp" class="control-item hidden">
|
|
358
359
|
<span class="control-action">Show Collision</span>
|
|
359
360
|
<span class="control-key">V</span>
|
|
360
361
|
</div>
|
package/public/index.js
CHANGED
|
@@ -77723,7 +77723,7 @@ const importSettings = (settings) => {
|
|
|
77723
77723
|
return result;
|
|
77724
77724
|
};
|
|
77725
77725
|
|
|
77726
|
-
var version = "1.
|
|
77726
|
+
var version = "1.24.0";
|
|
77727
77727
|
|
|
77728
77728
|
class Tooltip {
|
|
77729
77729
|
register;
|
|
@@ -78013,7 +78013,7 @@ const initUI = (global) => {
|
|
|
78013
78013
|
'reset', 'frame',
|
|
78014
78014
|
'loadingText', 'loadingBar',
|
|
78015
78015
|
'joystickBase', 'joystick',
|
|
78016
|
-
'showCollision',
|
|
78016
|
+
'showCollision', 'desktopShowCollisionHelp',
|
|
78017
78017
|
'tooltip',
|
|
78018
78018
|
'annotationNav', 'annotationPrev', 'annotationNext', 'annotationInfo', 'annotationNavTitle',
|
|
78019
78019
|
'viewerBranding', 'viewerTitle', 'appVersionLabel'
|
|
@@ -78367,9 +78367,10 @@ const initUI = (global) => {
|
|
|
78367
78367
|
dom.flyCamera.classList.toggle('middle', value);
|
|
78368
78368
|
dom.flyCamera.classList.toggle('right', !value);
|
|
78369
78369
|
});
|
|
78370
|
-
// Collision overlay toggle (only visible when overlay is available)
|
|
78370
|
+
// Collision overlay toggle + matching help-panel row (only visible when overlay is available)
|
|
78371
78371
|
events.on('hasCollisionOverlay:changed', (value) => {
|
|
78372
78372
|
dom.showCollision.classList.toggle('hidden', !value);
|
|
78373
|
+
dom.desktopShowCollisionHelp.classList.toggle('hidden', !value);
|
|
78373
78374
|
});
|
|
78374
78375
|
dom.showCollision.addEventListener('click', () => {
|
|
78375
78376
|
state.collisionOverlayEnabled = !state.collisionOverlayEnabled;
|
|
@@ -80589,6 +80590,11 @@ const createFrameCamera = (bbox, fov) => {
|
|
|
80589
80590
|
};
|
|
80590
80591
|
class CameraManager {
|
|
80591
80592
|
update;
|
|
80593
|
+
// Re-seed the active controller from the current camera pose and
|
|
80594
|
+
// cancel any in-progress transition lerp. Use after externally
|
|
80595
|
+
// mutating `camera` and/or `state.cameraMode` to make the change
|
|
80596
|
+
// visible instantly.
|
|
80597
|
+
snap;
|
|
80592
80598
|
// holds the camera state
|
|
80593
80599
|
camera = new Camera();
|
|
80594
80600
|
constructor(global, bbox, collision = null) {
|
|
@@ -80664,6 +80670,12 @@ class CameraManager {
|
|
|
80664
80670
|
from.copy(this.camera);
|
|
80665
80671
|
transitionTimer = 0;
|
|
80666
80672
|
};
|
|
80673
|
+
this.snap = () => {
|
|
80674
|
+
getController(state.cameraMode).onEnter(this.camera);
|
|
80675
|
+
target.copy(this.camera);
|
|
80676
|
+
transitionTimer = 1;
|
|
80677
|
+
global.app.renderNextFrame = true;
|
|
80678
|
+
};
|
|
80667
80679
|
// application update
|
|
80668
80680
|
this.update = (deltaTime, frame) => {
|
|
80669
80681
|
// use dt of 0 if animation is paused
|
|
@@ -80822,6 +80834,363 @@ class CameraManager {
|
|
|
80822
80834
|
}
|
|
80823
80835
|
}
|
|
80824
80836
|
|
|
80837
|
+
const captureCameraState = (cm, state) => ({
|
|
80838
|
+
position: [cm.camera.position.x, cm.camera.position.y, cm.camera.position.z],
|
|
80839
|
+
angles: [cm.camera.angles.x, cm.camera.angles.y, cm.camera.angles.z],
|
|
80840
|
+
distance: cm.camera.distance,
|
|
80841
|
+
fov: cm.camera.fov,
|
|
80842
|
+
mode: state.cameraMode
|
|
80843
|
+
});
|
|
80844
|
+
const restoreCameraState = (cm, state, snapshot) => {
|
|
80845
|
+
cm.camera.position.set(snapshot.position[0], snapshot.position[1], snapshot.position[2]);
|
|
80846
|
+
cm.camera.angles.set(snapshot.angles[0], snapshot.angles[1], snapshot.angles[2]);
|
|
80847
|
+
cm.camera.distance = snapshot.distance;
|
|
80848
|
+
cm.camera.fov = snapshot.fov;
|
|
80849
|
+
// Mode change (if any) fires cameraMode:changed which runs the new
|
|
80850
|
+
// controller's onEnter against our just-set pose; snap() then cancels
|
|
80851
|
+
// the resulting transition lerp. Same-mode case: snap() re-seeds the
|
|
80852
|
+
// active controller in place.
|
|
80853
|
+
if (state.cameraMode !== snapshot.mode) {
|
|
80854
|
+
state.cameraMode = snapshot.mode;
|
|
80855
|
+
}
|
|
80856
|
+
cm.snap();
|
|
80857
|
+
};
|
|
80858
|
+
|
|
80859
|
+
// Developer / debug panel. Hidden by default; surfaced via `?debug` URL
|
|
80860
|
+
// param or Ctrl+Shift+D keyboard shortcut. DOM and styles are injected
|
|
80861
|
+
// lazily on first show so there's no footprint on production URLs.
|
|
80862
|
+
const STYLE_ID = 'sse-debug-panel-style';
|
|
80863
|
+
const PANEL_ID = 'sse-debug-panel';
|
|
80864
|
+
const STYLES = `
|
|
80865
|
+
#${PANEL_ID} {
|
|
80866
|
+
position: fixed;
|
|
80867
|
+
top: max(8px, env(safe-area-inset-top));
|
|
80868
|
+
left: max(8px, env(safe-area-inset-left));
|
|
80869
|
+
padding: 8px 10px;
|
|
80870
|
+
background: rgba(0, 0, 0, 0.7);
|
|
80871
|
+
color: #eee;
|
|
80872
|
+
font: 11px/1.4 ui-monospace, Menlo, Consolas, monospace;
|
|
80873
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
80874
|
+
border-radius: 4px;
|
|
80875
|
+
z-index: 1000;
|
|
80876
|
+
pointer-events: auto;
|
|
80877
|
+
user-select: none;
|
|
80878
|
+
min-width: 220px;
|
|
80879
|
+
}
|
|
80880
|
+
#${PANEL_ID} .row {
|
|
80881
|
+
display: flex;
|
|
80882
|
+
justify-content: space-between;
|
|
80883
|
+
gap: 12px;
|
|
80884
|
+
white-space: nowrap;
|
|
80885
|
+
}
|
|
80886
|
+
#${PANEL_ID} .row .label {
|
|
80887
|
+
color: #888;
|
|
80888
|
+
}
|
|
80889
|
+
#${PANEL_ID} .row .value {
|
|
80890
|
+
color: #eee;
|
|
80891
|
+
font-variant-numeric: tabular-nums;
|
|
80892
|
+
cursor: text;
|
|
80893
|
+
padding: 0 4px;
|
|
80894
|
+
margin: 0 -4px;
|
|
80895
|
+
border-radius: 2px;
|
|
80896
|
+
transition: background-color 0.15s ease;
|
|
80897
|
+
outline: none;
|
|
80898
|
+
}
|
|
80899
|
+
#${PANEL_ID} .row .value:hover {
|
|
80900
|
+
background: rgba(255, 255, 255, 0.08);
|
|
80901
|
+
}
|
|
80902
|
+
#${PANEL_ID} .row .value:focus {
|
|
80903
|
+
background: rgba(255, 255, 255, 0.12);
|
|
80904
|
+
box-shadow: inset 0 0 0 1px rgba(120, 180, 255, 0.45);
|
|
80905
|
+
}
|
|
80906
|
+
#${PANEL_ID} .row .value.flash-ok {
|
|
80907
|
+
background: rgba(120, 220, 140, 0.35);
|
|
80908
|
+
}
|
|
80909
|
+
#${PANEL_ID} .row .value.flash-bad {
|
|
80910
|
+
background: rgba(220, 100, 100, 0.45);
|
|
80911
|
+
}
|
|
80912
|
+
#${PANEL_ID} .buttons {
|
|
80913
|
+
display: flex;
|
|
80914
|
+
gap: 6px;
|
|
80915
|
+
margin-top: 6px;
|
|
80916
|
+
}
|
|
80917
|
+
#${PANEL_ID} button {
|
|
80918
|
+
flex: 1;
|
|
80919
|
+
background: rgba(255, 255, 255, 0.08);
|
|
80920
|
+
color: #eee;
|
|
80921
|
+
border: 1px solid rgba(255, 255, 255, 0.12);
|
|
80922
|
+
border-radius: 3px;
|
|
80923
|
+
padding: 4px 8px;
|
|
80924
|
+
font: inherit;
|
|
80925
|
+
cursor: pointer;
|
|
80926
|
+
transition: background-color 0.15s ease;
|
|
80927
|
+
}
|
|
80928
|
+
#${PANEL_ID} button:hover {
|
|
80929
|
+
background: rgba(255, 255, 255, 0.16);
|
|
80930
|
+
}
|
|
80931
|
+
#${PANEL_ID} button.flash {
|
|
80932
|
+
background: rgba(120, 220, 140, 0.35);
|
|
80933
|
+
}
|
|
80934
|
+
`;
|
|
80935
|
+
const fmt = (v) => `${v.x.toFixed(3)}, ${v.y.toFixed(3)}, ${v.z.toFixed(3)}`;
|
|
80936
|
+
// Accepts "1,2,3", "1, 2, 3", "1 2 3", with or without trailing whitespace.
|
|
80937
|
+
const parseVector = (text) => {
|
|
80938
|
+
const parts = text.trim().split(/[\s,]+/).filter(p => p.length > 0);
|
|
80939
|
+
if (parts.length !== 3)
|
|
80940
|
+
return null;
|
|
80941
|
+
const nums = parts.map(Number);
|
|
80942
|
+
if (nums.some(n => !Number.isFinite(n)))
|
|
80943
|
+
return null;
|
|
80944
|
+
return [nums[0], nums[1], nums[2]];
|
|
80945
|
+
};
|
|
80946
|
+
class DebugPanel {
|
|
80947
|
+
_global;
|
|
80948
|
+
_cameraManager;
|
|
80949
|
+
_focusTmp = new Vec3();
|
|
80950
|
+
_root = null;
|
|
80951
|
+
_positionValue = null;
|
|
80952
|
+
_focusValue = null;
|
|
80953
|
+
_copyButton = null;
|
|
80954
|
+
_pasteButton = null;
|
|
80955
|
+
_screenshotButton = null;
|
|
80956
|
+
_editing = null;
|
|
80957
|
+
_editCanceled = false;
|
|
80958
|
+
_visible = false;
|
|
80959
|
+
_onPrerender = () => this._render();
|
|
80960
|
+
_onKeyDown = (event) => {
|
|
80961
|
+
// Ctrl+Shift+D — also accept Meta+Shift+D on macOS for parity
|
|
80962
|
+
if (event.code === 'KeyD' && event.shiftKey && (event.ctrlKey || event.metaKey)) {
|
|
80963
|
+
event.preventDefault();
|
|
80964
|
+
this.toggle();
|
|
80965
|
+
}
|
|
80966
|
+
};
|
|
80967
|
+
constructor(global, cameraManager) {
|
|
80968
|
+
this._global = global;
|
|
80969
|
+
this._cameraManager = cameraManager;
|
|
80970
|
+
window.addEventListener('keydown', this._onKeyDown);
|
|
80971
|
+
if (global.config.debug) {
|
|
80972
|
+
this.show();
|
|
80973
|
+
}
|
|
80974
|
+
}
|
|
80975
|
+
show() {
|
|
80976
|
+
if (this._visible)
|
|
80977
|
+
return;
|
|
80978
|
+
this._visible = true;
|
|
80979
|
+
if (!this._root) {
|
|
80980
|
+
this._build();
|
|
80981
|
+
}
|
|
80982
|
+
this._root.style.display = '';
|
|
80983
|
+
this._global.app.on('prerender', this._onPrerender);
|
|
80984
|
+
window.getCameraState = () => captureCameraState(this._cameraManager, this._global.state);
|
|
80985
|
+
window.setCameraState = snapshot => restoreCameraState(this._cameraManager, this._global.state, snapshot);
|
|
80986
|
+
this._render();
|
|
80987
|
+
}
|
|
80988
|
+
hide() {
|
|
80989
|
+
if (!this._visible)
|
|
80990
|
+
return;
|
|
80991
|
+
this._visible = false;
|
|
80992
|
+
if (this._root) {
|
|
80993
|
+
this._root.style.display = 'none';
|
|
80994
|
+
}
|
|
80995
|
+
this._global.app.off('prerender', this._onPrerender);
|
|
80996
|
+
delete window.getCameraState;
|
|
80997
|
+
delete window.setCameraState;
|
|
80998
|
+
}
|
|
80999
|
+
toggle() {
|
|
81000
|
+
if (this._visible)
|
|
81001
|
+
this.hide();
|
|
81002
|
+
else
|
|
81003
|
+
this.show();
|
|
81004
|
+
}
|
|
81005
|
+
destroy() {
|
|
81006
|
+
this.hide();
|
|
81007
|
+
window.removeEventListener('keydown', this._onKeyDown);
|
|
81008
|
+
if (this._root) {
|
|
81009
|
+
this._root.remove();
|
|
81010
|
+
this._root = null;
|
|
81011
|
+
}
|
|
81012
|
+
document.getElementById(STYLE_ID)?.remove();
|
|
81013
|
+
}
|
|
81014
|
+
_build() {
|
|
81015
|
+
if (!document.getElementById(STYLE_ID)) {
|
|
81016
|
+
const style = document.createElement('style');
|
|
81017
|
+
style.id = STYLE_ID;
|
|
81018
|
+
style.textContent = STYLES;
|
|
81019
|
+
document.head.appendChild(style);
|
|
81020
|
+
}
|
|
81021
|
+
const root = document.createElement('div');
|
|
81022
|
+
root.id = PANEL_ID;
|
|
81023
|
+
root.innerHTML = `
|
|
81024
|
+
<div class="row"><span class="label">camera</span><span class="value" data-id="position" contenteditable="plaintext-only" spellcheck="false" title="Edit to set camera position">—</span></div>
|
|
81025
|
+
<div class="row"><span class="label">focus</span><span class="value" data-id="focus" contenteditable="plaintext-only" spellcheck="false" title="Edit to look at this point">—</span></div>
|
|
81026
|
+
<div class="buttons">
|
|
81027
|
+
<button data-id="copy">Copy</button>
|
|
81028
|
+
<button data-id="paste">Paste</button>
|
|
81029
|
+
</div>
|
|
81030
|
+
<div class="buttons">
|
|
81031
|
+
<button data-id="screenshot">Screenshot</button>
|
|
81032
|
+
</div>
|
|
81033
|
+
`;
|
|
81034
|
+
document.body.appendChild(root);
|
|
81035
|
+
this._root = root;
|
|
81036
|
+
this._positionValue = root.querySelector('[data-id="position"]');
|
|
81037
|
+
this._focusValue = root.querySelector('[data-id="focus"]');
|
|
81038
|
+
this._copyButton = root.querySelector('[data-id="copy"]');
|
|
81039
|
+
this._pasteButton = root.querySelector('[data-id="paste"]');
|
|
81040
|
+
this._screenshotButton = root.querySelector('[data-id="screenshot"]');
|
|
81041
|
+
this._copyButton.addEventListener('click', () => this._copy());
|
|
81042
|
+
this._pasteButton.addEventListener('click', () => this._paste());
|
|
81043
|
+
this._screenshotButton.addEventListener('click', () => this._screenshot());
|
|
81044
|
+
this._wireEditable(this._positionValue, 'position');
|
|
81045
|
+
this._wireEditable(this._focusValue, 'focus');
|
|
81046
|
+
}
|
|
81047
|
+
_wireEditable(span, kind) {
|
|
81048
|
+
span.addEventListener('focus', () => {
|
|
81049
|
+
this._editing = span;
|
|
81050
|
+
this._editCanceled = false;
|
|
81051
|
+
// select all text so the user can start typing to replace
|
|
81052
|
+
const range = document.createRange();
|
|
81053
|
+
range.selectNodeContents(span);
|
|
81054
|
+
const sel = window.getSelection();
|
|
81055
|
+
sel?.removeAllRanges();
|
|
81056
|
+
sel?.addRange(range);
|
|
81057
|
+
});
|
|
81058
|
+
// Stop key events from bubbling to the canvas / window listeners
|
|
81059
|
+
// (PlayCanvas KeyboardMouseSource and the wheel/key interrupt
|
|
81060
|
+
// listeners) so arrow keys, WASD, etc. behave as text editing
|
|
81061
|
+
// instead of moving the camera.
|
|
81062
|
+
const stopKey = (e) => e.stopPropagation();
|
|
81063
|
+
span.addEventListener('keydown', (e) => {
|
|
81064
|
+
stopKey(e);
|
|
81065
|
+
if (e.key === 'Enter') {
|
|
81066
|
+
e.preventDefault();
|
|
81067
|
+
span.blur();
|
|
81068
|
+
}
|
|
81069
|
+
else if (e.key === 'Escape') {
|
|
81070
|
+
e.preventDefault();
|
|
81071
|
+
this._editCanceled = true;
|
|
81072
|
+
span.blur();
|
|
81073
|
+
}
|
|
81074
|
+
});
|
|
81075
|
+
span.addEventListener('keyup', stopKey);
|
|
81076
|
+
span.addEventListener('keypress', stopKey);
|
|
81077
|
+
span.addEventListener('blur', () => {
|
|
81078
|
+
const wasCanceled = this._editCanceled;
|
|
81079
|
+
this._editing = null;
|
|
81080
|
+
this._editCanceled = false;
|
|
81081
|
+
// clear any leftover selection
|
|
81082
|
+
window.getSelection()?.removeAllRanges();
|
|
81083
|
+
if (wasCanceled) {
|
|
81084
|
+
this._render();
|
|
81085
|
+
return;
|
|
81086
|
+
}
|
|
81087
|
+
const parsed = parseVector(span.textContent ?? '');
|
|
81088
|
+
if (!parsed) {
|
|
81089
|
+
this._flashBad(span);
|
|
81090
|
+
this._render();
|
|
81091
|
+
return;
|
|
81092
|
+
}
|
|
81093
|
+
if (kind === 'position') {
|
|
81094
|
+
this._applyPosition(parsed);
|
|
81095
|
+
}
|
|
81096
|
+
else {
|
|
81097
|
+
this._applyFocus(parsed);
|
|
81098
|
+
}
|
|
81099
|
+
this._flashOk(span);
|
|
81100
|
+
});
|
|
81101
|
+
}
|
|
81102
|
+
_applyPosition(pos) {
|
|
81103
|
+
this._cameraManager.camera.position.set(pos[0], pos[1], pos[2]);
|
|
81104
|
+
this._cameraManager.snap();
|
|
81105
|
+
}
|
|
81106
|
+
_applyFocus(focus) {
|
|
81107
|
+
// Keep camera position fixed; recompute angles + distance so the
|
|
81108
|
+
// camera looks at the new focus point. Camera.look() does the math
|
|
81109
|
+
// in place; snap() then re-seeds the active controller.
|
|
81110
|
+
const cam = this._cameraManager.camera;
|
|
81111
|
+
const from = this._focusTmp.copy(cam.position);
|
|
81112
|
+
const to = new Vec3(focus[0], focus[1], focus[2]);
|
|
81113
|
+
cam.look(from, to);
|
|
81114
|
+
this._cameraManager.snap();
|
|
81115
|
+
}
|
|
81116
|
+
_render() {
|
|
81117
|
+
if (!this._visible || !this._positionValue || !this._focusValue)
|
|
81118
|
+
return;
|
|
81119
|
+
const cam = this._cameraManager.camera;
|
|
81120
|
+
cam.calcFocusPoint(this._focusTmp);
|
|
81121
|
+
// Skip the span currently being edited so user input isn't
|
|
81122
|
+
// overwritten by the per-frame refresh.
|
|
81123
|
+
if (this._editing !== this._positionValue) {
|
|
81124
|
+
this._positionValue.textContent = fmt(cam.position);
|
|
81125
|
+
}
|
|
81126
|
+
if (this._editing !== this._focusValue) {
|
|
81127
|
+
this._focusValue.textContent = fmt(this._focusTmp);
|
|
81128
|
+
}
|
|
81129
|
+
}
|
|
81130
|
+
async _copy() {
|
|
81131
|
+
const snapshot = captureCameraState(this._cameraManager, this._global.state);
|
|
81132
|
+
try {
|
|
81133
|
+
await navigator.clipboard.writeText(JSON.stringify(snapshot));
|
|
81134
|
+
this._flash(this._copyButton);
|
|
81135
|
+
}
|
|
81136
|
+
catch (err) {
|
|
81137
|
+
console.warn('[debug-panel] copy failed', err);
|
|
81138
|
+
}
|
|
81139
|
+
}
|
|
81140
|
+
async _paste() {
|
|
81141
|
+
try {
|
|
81142
|
+
const text = await navigator.clipboard.readText();
|
|
81143
|
+
const snapshot = JSON.parse(text);
|
|
81144
|
+
restoreCameraState(this._cameraManager, this._global.state, snapshot);
|
|
81145
|
+
this._flash(this._pasteButton);
|
|
81146
|
+
}
|
|
81147
|
+
catch (err) {
|
|
81148
|
+
console.warn('[debug-panel] paste failed', err);
|
|
81149
|
+
}
|
|
81150
|
+
}
|
|
81151
|
+
_screenshot() {
|
|
81152
|
+
const app = this._global.app;
|
|
81153
|
+
const canvas = app.graphicsDevice.canvas;
|
|
81154
|
+
// PlayCanvas runs with preserveDrawingBuffer off, so the canvas
|
|
81155
|
+
// pixels are only readable in the same task as the render. Force
|
|
81156
|
+
// a render and capture in frameend.
|
|
81157
|
+
app.renderNextFrame = true;
|
|
81158
|
+
app.once('frameend', () => {
|
|
81159
|
+
// Quality 1.0 with image/webp produces lossless WebP in
|
|
81160
|
+
// Chromium / Firefox. Safari (which lacks WebP encode) falls
|
|
81161
|
+
// back to PNG automatically — blob.type tells us which.
|
|
81162
|
+
canvas.toBlob((blob) => {
|
|
81163
|
+
if (!blob) {
|
|
81164
|
+
console.warn('[debug-panel] screenshot toBlob returned null');
|
|
81165
|
+
return;
|
|
81166
|
+
}
|
|
81167
|
+
const ext = blob.type === 'image/webp' ? 'webp' : 'png';
|
|
81168
|
+
const url = URL.createObjectURL(blob);
|
|
81169
|
+
const a = document.createElement('a');
|
|
81170
|
+
a.href = url;
|
|
81171
|
+
a.download = `supersplat-viewer.${ext}`;
|
|
81172
|
+
a.click();
|
|
81173
|
+
URL.revokeObjectURL(url);
|
|
81174
|
+
this._flash(this._screenshotButton);
|
|
81175
|
+
}, 'image/webp', 1.0);
|
|
81176
|
+
});
|
|
81177
|
+
}
|
|
81178
|
+
_flash(el) {
|
|
81179
|
+
if (!el)
|
|
81180
|
+
return;
|
|
81181
|
+
el.classList.add('flash');
|
|
81182
|
+
setTimeout(() => el.classList.remove('flash'), 250);
|
|
81183
|
+
}
|
|
81184
|
+
_flashOk(el) {
|
|
81185
|
+
el.classList.add('flash-ok');
|
|
81186
|
+
setTimeout(() => el.classList.remove('flash-ok'), 250);
|
|
81187
|
+
}
|
|
81188
|
+
_flashBad(el) {
|
|
81189
|
+
el.classList.add('flash-bad');
|
|
81190
|
+
setTimeout(() => el.classList.remove('flash-bad'), 400);
|
|
81191
|
+
}
|
|
81192
|
+
}
|
|
81193
|
+
|
|
80825
81194
|
/**
|
|
80826
81195
|
* Watches global pointer events and updates `state.inputMode` to reflect
|
|
80827
81196
|
* whether the user is on a touch device or desktop.
|
|
@@ -81590,7 +81959,6 @@ class KeyboardMouseDevice {
|
|
|
81590
81959
|
const tmpV$2 = new Vec3();
|
|
81591
81960
|
const orbitMove = new Vec3();
|
|
81592
81961
|
const flyMoveTmp = new Vec3();
|
|
81593
|
-
const flyTouchPan = new Vec3();
|
|
81594
81962
|
const pinchMoveTmp = new Vec3();
|
|
81595
81963
|
const orbitRotate = new Vec3();
|
|
81596
81964
|
const flyRotate = new Vec3();
|
|
@@ -81599,19 +81967,12 @@ class TouchDevice {
|
|
|
81599
81967
|
moveSpeed = 4;
|
|
81600
81968
|
pinchSpeed = 0.4;
|
|
81601
81969
|
touchRotateSensitivity = 1.5;
|
|
81602
|
-
touchPinchMoveSensitivity = 1.5;
|
|
81603
|
-
pinchVelocitySensitivity = 0.006;
|
|
81604
|
-
panVelocitySensitivity = 0.005;
|
|
81605
81970
|
_source = new MultiTouchSource();
|
|
81606
81971
|
_global = null;
|
|
81607
81972
|
/** Touches currently active (running count from .read() deltas). */
|
|
81608
81973
|
_touchCount = 0;
|
|
81609
81974
|
/** UI joystick value [x, y], -1..1. */
|
|
81610
81975
|
_joystick = [0, 0];
|
|
81611
|
-
/** Smoothed forward/back velocity from pinch gesture (-1..1). */
|
|
81612
|
-
_pinchVelocity = 0;
|
|
81613
|
-
/** Smoothed strafe/vertical velocity from two-finger pan, -1..1 each. */
|
|
81614
|
-
_panVelocity = [0, 0];
|
|
81615
81976
|
/** Tap-detection state — touch count, max touches, and accumulated movement. */
|
|
81616
81977
|
_tapTouches = 0;
|
|
81617
81978
|
_tapMaxTouches = 0;
|
|
@@ -81692,49 +82053,38 @@ class TouchDevice {
|
|
|
81692
82053
|
this._tapTouches = 0;
|
|
81693
82054
|
this._tapMaxTouches = 0;
|
|
81694
82055
|
}
|
|
81695
|
-
// smoothed velocities for fly/walk first-person motion (non-gaming)
|
|
81696
|
-
if (isFirstPerson && !gamingControls && this._touchCount > 1) {
|
|
81697
|
-
// pinch[0] = oldDist - newDist: negative when spreading,
|
|
81698
|
-
// positive when closing. Spreading = forward → subtract.
|
|
81699
|
-
this._pinchVelocity -= pinch[0] * this.pinchVelocitySensitivity;
|
|
81700
|
-
this._pinchVelocity = math.clamp(this._pinchVelocity, -1, 1.0);
|
|
81701
|
-
this._panVelocity[0] += touch[0] * this.panVelocitySensitivity;
|
|
81702
|
-
this._panVelocity[0] = math.clamp(this._panVelocity[0], -1, 1.0);
|
|
81703
|
-
this._panVelocity[1] += touch[1] * this.panVelocitySensitivity;
|
|
81704
|
-
this._panVelocity[1] = math.clamp(this._panVelocity[1], -1, 1.0);
|
|
81705
|
-
}
|
|
81706
|
-
else if (isFirstPerson && this._touchCount <= 1) {
|
|
81707
|
-
this._pinchVelocity = 0;
|
|
81708
|
-
this._panVelocity[0] = 0;
|
|
81709
|
-
this._panVelocity[1] = 0;
|
|
81710
|
-
}
|
|
81711
82056
|
const orbit = isOrbit ? 1 : 0;
|
|
81712
82057
|
const fly = isFirstPerson ? 1 : 0;
|
|
81713
82058
|
const double = this._touchCount > 1 ? 1 : 0;
|
|
81714
82059
|
const orbitFactor = isFirstPerson ? cameraComponent.fov / 120 : 1;
|
|
81715
82060
|
const dragInvert = (isFirstPerson && !gamingControls) ? -1 : 1;
|
|
82061
|
+
// First-person modes (fly and walk) opt into the direct two-finger
|
|
82062
|
+
// model only outside gaming controls (gaming uses the joystick).
|
|
82063
|
+
const directFirstPerson = fly * (gamingControls ? 0 : 1);
|
|
81716
82064
|
const { deltas } = frame;
|
|
81717
82065
|
// move
|
|
81718
82066
|
const v = tmpV$2.set(0, 0, 0);
|
|
81719
|
-
//
|
|
82067
|
+
// Two-finger pan: orbit pans the target; fly strafes/rises in the
|
|
82068
|
+
// camera basis; walk strafes along the ground plane. Identical 1:1
|
|
82069
|
+
// screen-space mapping in every mode so dragging feels the same —
|
|
82070
|
+
// what your fingers move, the camera moves. Walk zeros y because
|
|
82071
|
+
// WalkController treats any nonzero move[1] as a jump trigger.
|
|
81720
82072
|
screenToWorld(cameraComponent, touch[0], touch[1], distance, orbitMove);
|
|
81721
|
-
|
|
82073
|
+
if (isWalk) {
|
|
82074
|
+
orbitMove.y = 0;
|
|
82075
|
+
}
|
|
82076
|
+
v.add(orbitMove.mulScalar((orbit + directFirstPerson) * double));
|
|
81722
82077
|
if (gamingControls) {
|
|
81723
82078
|
// joystick UI drives strafe + forward/back in fly/walk
|
|
81724
82079
|
flyMoveTmp.set(this._joystick[0], 0, -this._joystick[1]);
|
|
81725
82080
|
v.add(flyMoveTmp.mulScalar(fly * this.moveSpeed * dt));
|
|
81726
82081
|
}
|
|
81727
|
-
|
|
81728
|
-
|
|
81729
|
-
|
|
81730
|
-
|
|
81731
|
-
|
|
81732
|
-
|
|
81733
|
-
v.add(flyMoveTmp.mulScalar(fly * this.touchPinchMoveSensitivity * this.moveSpeed * dt));
|
|
81734
|
-
}
|
|
81735
|
-
// raw pinch for orbit-mode zoom
|
|
81736
|
-
pinchMoveTmp.set(0, 0, pinch[0]);
|
|
81737
|
-
v.add(pinchMoveTmp.mulScalar(orbit * double * this.pinchSpeed * DISPLACEMENT_SCALE));
|
|
82082
|
+
// Two-finger pinch z: orbit interprets +z as "farther from target"
|
|
82083
|
+
// (close-pinch = +pinch[0] = zoom out). First-person modes interpret
|
|
82084
|
+
// +z as "forward", so spreading (pinch[0] < 0) should move forward —
|
|
82085
|
+
// flip the sign there.
|
|
82086
|
+
pinchMoveTmp.set(0, 0, (orbit - directFirstPerson) * pinch[0]);
|
|
82087
|
+
v.add(pinchMoveTmp.mulScalar(double * this.pinchSpeed * DISPLACEMENT_SCALE));
|
|
81738
82088
|
// tap-to-jump in walk + gaming controls
|
|
81739
82089
|
if (isWalk && this._tapJump) {
|
|
81740
82090
|
v.y = 1;
|
|
@@ -84011,6 +84361,7 @@ class Viewer {
|
|
|
84011
84361
|
voxelOverlay = null;
|
|
84012
84362
|
meshOverlay = null;
|
|
84013
84363
|
navCursor = null;
|
|
84364
|
+
debugPanel = null;
|
|
84014
84365
|
origChunks;
|
|
84015
84366
|
constructor(global, gsplatLoad, skyboxLoad, collisionLoad) {
|
|
84016
84367
|
this.global = global;
|
|
@@ -84186,6 +84537,7 @@ class Viewer {
|
|
|
84186
84537
|
if (!config.noui) {
|
|
84187
84538
|
this.navCursor = new NavCursor(app, camera, collision ?? null, events, state);
|
|
84188
84539
|
}
|
|
84540
|
+
this.debugPanel = new DebugPanel(global, this.cameraManager);
|
|
84189
84541
|
const { instance } = gsplat;
|
|
84190
84542
|
if (instance) {
|
|
84191
84543
|
// kick off gsplat sorting immediately now that camera is in position
|