@playcanvas/supersplat-viewer 1.39.0 → 1.40.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.d.ts +90 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/viewer.css +34 -7
- package/dist/viewer.d.ts +15 -7
- package/dist/viewer.js +715 -210
- package/dist/viewer.js.map +1 -1
- package/package.json +1 -1
- package/public/index.css +34 -7
- package/public/index.html +7 -0
- package/public/index.js +715 -210
- package/public/index.js.map +1 -1
package/dist/viewer.js
CHANGED
|
@@ -3514,6 +3514,33 @@ const buildResidentSet = (state) => {
|
|
|
3514
3514
|
nodeSpheres: new Float32Array(spheres)
|
|
3515
3515
|
};
|
|
3516
3516
|
};
|
|
3517
|
+
// TEMPORARY, until the engine reports these (an upstream PR, noted in docs/follow-up-plan.md):
|
|
3518
|
+
// counts for the debug panel, read through the same internals. The splats in the files the
|
|
3519
|
+
// engine has loaded for a resource (in use or cooling down), or a single file's own
|
|
3520
|
+
const loadedSplats = (resource) => {
|
|
3521
|
+
const loaded = resource;
|
|
3522
|
+
if (!loaded)
|
|
3523
|
+
return null;
|
|
3524
|
+
if (!loaded.octree)
|
|
3525
|
+
return loaded.numSplats ?? null;
|
|
3526
|
+
let count = 0;
|
|
3527
|
+
for (const file of loaded.octree.fileResources.values())
|
|
3528
|
+
count += file.numSplats;
|
|
3529
|
+
return count;
|
|
3530
|
+
};
|
|
3531
|
+
// the splats the engine's own gpu-sorted renderer kept after its frustum cull the last time it
|
|
3532
|
+
// drew for this camera and layer, or null where it has not (WebGL's cpu sort, or the stochastic
|
|
3533
|
+
// renderer drawing instead)
|
|
3534
|
+
const readEngineVisibleSplats = async (app, camera, layer) => {
|
|
3535
|
+
const director = app.renderer.gsplatDirector;
|
|
3536
|
+
const manager = director?.camerasMap.get(camera.camera)?.layersMap.get(layer)?.gsplatManager;
|
|
3537
|
+
const buffer = manager?.renderer.intervalCompaction?.numSplatsBuffer;
|
|
3538
|
+
if (!buffer)
|
|
3539
|
+
return null;
|
|
3540
|
+
const data = new Uint32Array(1);
|
|
3541
|
+
await buffer.read(0, 4, data, true);
|
|
3542
|
+
return data[0];
|
|
3543
|
+
};
|
|
3517
3544
|
|
|
3518
3545
|
// The foveated target (variant warp): the splats render into a target whose pixels are spread
|
|
3519
3546
|
// over the screen unevenly, densest where the screen is, and every pass that maps between the
|
|
@@ -6929,10 +6956,15 @@ const parseVariant = (text) => {
|
|
|
6929
6956
|
// defaults) for quality, and for phones and headsets the interleaved pixel sets with jittered
|
|
6930
6957
|
// strata, small splats drawn per splat and no colour clamp, the fastest at that quality on a Mali
|
|
6931
6958
|
// phone (docs/mobile-gpu-splat-rendering.md)
|
|
6959
|
+
// sol, the "speed of light" mode, is the fastest coverage there is (a solid ellipse per splat, no
|
|
6960
|
+
// discard): no device gets it, but it is the bound the others are measured against
|
|
6932
6961
|
const MODE_VARIANTS = {
|
|
6933
6962
|
pixel: '',
|
|
6934
|
-
mobile: 'coverage:interleaved,jitter:2,interleaveArea:256,taaClip:0'
|
|
6963
|
+
mobile: 'coverage:interleaved,jitter:2,interleaveArea:256,taaClip:0',
|
|
6964
|
+
sol: 'coverage:splat'
|
|
6935
6965
|
};
|
|
6966
|
+
/** The modes, in the order the debug controls step through them. */
|
|
6967
|
+
const STOCHASTIC_MODES = Object.keys(MODE_VARIANTS);
|
|
6936
6968
|
// The switches a stereo session adds over the mode's. A head never rests, so every frame takes the
|
|
6937
6969
|
// moving history, whose cap of 16 left the coverage noise pulsing in semi-transparent areas; the
|
|
6938
6970
|
// eyes keep up to 64 samples and shorten them four times as fast with the motion
|
|
@@ -7291,7 +7323,8 @@ class SplatView {
|
|
|
7291
7323
|
}
|
|
7292
7324
|
class StochasticSplatRenderer {
|
|
7293
7325
|
variant;
|
|
7294
|
-
/** The mode
|
|
7326
|
+
/** The mode, and its switches, which setVariant's string applies over. */
|
|
7327
|
+
modeName;
|
|
7295
7328
|
modeVariant;
|
|
7296
7329
|
/** setVariant's last string, applied again when a stereo session starts or ends. */
|
|
7297
7330
|
variantText;
|
|
@@ -7543,7 +7576,8 @@ class StochasticSplatRenderer {
|
|
|
7543
7576
|
(() => {
|
|
7544
7577
|
this.app.renderNextFrame = true;
|
|
7545
7578
|
});
|
|
7546
|
-
this.
|
|
7579
|
+
this.modeName = options.mode ?? 'pixel';
|
|
7580
|
+
this.modeVariant = MODE_VARIANTS[this.modeName];
|
|
7547
7581
|
this.variantText = options.variant ?? '';
|
|
7548
7582
|
this.variant = parseVariant(`${this.modeVariant},${this.variantText}`);
|
|
7549
7583
|
const { device } = this;
|
|
@@ -7815,6 +7849,23 @@ class StochasticSplatRenderer {
|
|
|
7815
7849
|
}
|
|
7816
7850
|
this.app.renderNextFrame = true;
|
|
7817
7851
|
}
|
|
7852
|
+
/** The mode whose switches the variant starts from. */
|
|
7853
|
+
get mode() {
|
|
7854
|
+
return this.modeName;
|
|
7855
|
+
}
|
|
7856
|
+
/**
|
|
7857
|
+
* Switch to another mode (the debug controls): its switches, then the session's and the last
|
|
7858
|
+
* setVariant string, as constructing in that mode would. Any switch changed since resets.
|
|
7859
|
+
*
|
|
7860
|
+
* @param mode - The mode.
|
|
7861
|
+
*/
|
|
7862
|
+
setMode(mode) {
|
|
7863
|
+
if (mode === this.modeName)
|
|
7864
|
+
return;
|
|
7865
|
+
this.modeName = mode;
|
|
7866
|
+
this.modeVariant = MODE_VARIANTS[mode];
|
|
7867
|
+
this.setVariant(this.variantText);
|
|
7868
|
+
}
|
|
7818
7869
|
/** Replace the experiment switches from a `key:value,key:value` string (unset keys reset to the mode's, and the session's). */
|
|
7819
7870
|
setVariant(text) {
|
|
7820
7871
|
this.variantText = text;
|
|
@@ -7837,11 +7888,6 @@ class StochasticSplatRenderer {
|
|
|
7837
7888
|
}
|
|
7838
7889
|
this.frameIndex = 0;
|
|
7839
7890
|
}
|
|
7840
|
-
/** Set the display sharpen (variant taaSharpen): a display-only switch, so the history stays. */
|
|
7841
|
-
setSharpen(strength) {
|
|
7842
|
-
this.variant.taaSharpen = Math.max(0, strength);
|
|
7843
|
-
this.app.renderNextFrame = true;
|
|
7844
|
-
}
|
|
7845
7891
|
/** Re-read {@link variant} after a field changed. */
|
|
7846
7892
|
applyVariant() {
|
|
7847
7893
|
// a switch changes what the frames hold; an old history would leak into the new ones
|
|
@@ -8924,6 +8970,8 @@ class StochasticSplatRenderer {
|
|
|
8924
8970
|
// them into a budget from the device class's ladder, a resolution scale, the XR session's start
|
|
8925
8971
|
// parameters and the renderer, and disables the slider positions the device cannot hold
|
|
8926
8972
|
// (state.qualityAvailable).
|
|
8973
|
+
/** The debug controls' choices, in the order they step through them. */
|
|
8974
|
+
const DEBUG_MODES = ['sorted', ...STOCHASTIC_MODES];
|
|
8927
8975
|
/** The slider's positions, left to right. */
|
|
8928
8976
|
const QUALITY_LEVELS = ['performance', 'default', 'high', 'max'];
|
|
8929
8977
|
// Standalone headsets run XR on a mobile gpu, which draws every splat once per eye, but their
|
|
@@ -8988,19 +9036,24 @@ const canvasPixelRatio = () => {
|
|
|
8988
9036
|
const resolutionScaleFor = (level, stochastic) => level === 'performance' && !stochastic ? PERFORMANCE_SCALE : 1;
|
|
8989
9037
|
class Quality {
|
|
8990
9038
|
deviceClass;
|
|
8991
|
-
/** Whether the
|
|
9039
|
+
/** Whether the stochastic renderer may be chosen here: WebGPU, not a standalone headset, and not turned off by the flag. */
|
|
8992
9040
|
stochasticAllowed;
|
|
8993
9041
|
app;
|
|
8994
9042
|
config;
|
|
8995
9043
|
state;
|
|
8996
9044
|
renderer;
|
|
9045
|
+
events;
|
|
8997
9046
|
ceilingMB;
|
|
9047
|
+
// the debug controls' choice of renderer and mode, over Performance Mode and the flag; not
|
|
9048
|
+
// saved, null until it is used, and cleared by the Performance Mode toggle
|
|
9049
|
+
debugOverride = null;
|
|
8998
9050
|
handles;
|
|
8999
9051
|
constructor(app, config, state, events, renderer) {
|
|
9000
9052
|
this.app = app;
|
|
9001
9053
|
this.config = config;
|
|
9002
9054
|
this.state = state;
|
|
9003
9055
|
this.renderer = renderer;
|
|
9056
|
+
this.events = events;
|
|
9004
9057
|
const device = app.graphicsDevice;
|
|
9005
9058
|
const info = device.gpuAdapter?.info;
|
|
9006
9059
|
// the Vision Pro test (a Mac user agent with touch points) also matches a Mac with a touch
|
|
@@ -9024,7 +9077,13 @@ class Quality {
|
|
|
9024
9077
|
: classCeiling;
|
|
9025
9078
|
// the available positions follow the renderer choice and the session
|
|
9026
9079
|
this.handles = [
|
|
9027
|
-
|
|
9080
|
+
// made before the viewer's listeners, so a toggle clears the debug choice before they
|
|
9081
|
+
// read the renderer
|
|
9082
|
+
events.on('performanceMode:changed', () => {
|
|
9083
|
+
this.debugOverride = null;
|
|
9084
|
+
this.updateAvailable();
|
|
9085
|
+
}),
|
|
9086
|
+
events.on('debugMode:changed', () => this.updateAvailable()),
|
|
9028
9087
|
events.on('xrMode:changed', () => this.updateAvailable()),
|
|
9029
9088
|
events.on('quality:changed', () => this.updateAvailable())
|
|
9030
9089
|
];
|
|
@@ -9034,21 +9093,57 @@ class Quality {
|
|
|
9034
9093
|
for (const handle of this.handles)
|
|
9035
9094
|
handle.off();
|
|
9036
9095
|
}
|
|
9037
|
-
/**
|
|
9096
|
+
/**
|
|
9097
|
+
* Whether the stochastic renderer should draw: chosen on the debug controls, forced by the
|
|
9098
|
+
* flag, or by the toggle where allowed.
|
|
9099
|
+
*/
|
|
9038
9100
|
get stochastic() {
|
|
9101
|
+
if (this.debugOverride !== null)
|
|
9102
|
+
return this.renderer === 'webgpu' && this.debugOverride !== 'sorted';
|
|
9039
9103
|
const { stochastic } = this.config;
|
|
9040
9104
|
if (stochastic === true || stochastic === 'mobile')
|
|
9041
9105
|
return this.renderer === 'webgpu';
|
|
9042
9106
|
return this.stochasticAllowed && this.state.performanceMode;
|
|
9043
9107
|
}
|
|
9044
|
-
/**
|
|
9108
|
+
/**
|
|
9109
|
+
* Which stochastic mode draws: the debug controls' choice, the flag's, or the device's: per-pixel
|
|
9110
|
+
* coverage on a desktop, interleaved pixel sets on a mobile-class device.
|
|
9111
|
+
*/
|
|
9045
9112
|
get stochasticMode() {
|
|
9113
|
+
if (this.debugOverride !== null && this.debugOverride !== 'sorted')
|
|
9114
|
+
return this.debugOverride;
|
|
9046
9115
|
if (this.config.stochastic === 'mobile')
|
|
9047
9116
|
return 'mobile';
|
|
9048
9117
|
if (this.config.stochastic === true)
|
|
9049
9118
|
return 'pixel';
|
|
9050
9119
|
return this.deviceClass.ladder === 'mobile' ? 'mobile' : 'pixel';
|
|
9051
9120
|
}
|
|
9121
|
+
/**
|
|
9122
|
+
* Whether the debug controls offer the renderer and mode: on WebGPU where the Performance Mode
|
|
9123
|
+
* toggle can switch renderers, or anywhere on WebGPU with the debug flag (a standalone headset,
|
|
9124
|
+
* a stochastic flag). The budget is then fitted to both renderers from the start, so a switch
|
|
9125
|
+
* never meets splats resident for a budget the other renderer cannot hold.
|
|
9126
|
+
*/
|
|
9127
|
+
get debugModes() {
|
|
9128
|
+
return this.renderer === 'webgpu' && (this.switchable || this.config.debug);
|
|
9129
|
+
}
|
|
9130
|
+
/** The renderer and mode drawing: sorted, or the stochastic renderer's mode. */
|
|
9131
|
+
get debugMode() {
|
|
9132
|
+
return this.stochastic ? this.stochasticMode : 'sorted';
|
|
9133
|
+
}
|
|
9134
|
+
/**
|
|
9135
|
+
* The debug controls' choice of renderer and mode, where {@link debugModes}: not saved, so a
|
|
9136
|
+
* reload is back to the usual choice, and the Performance Mode toggle clears it. The budget,
|
|
9137
|
+
* fitted to both renderers wherever this is offered, stays as it is.
|
|
9138
|
+
*
|
|
9139
|
+
* @param mode - Sorted, or the stochastic renderer's mode.
|
|
9140
|
+
*/
|
|
9141
|
+
setDebugMode(mode) {
|
|
9142
|
+
if (!this.debugModes || mode === this.debugOverride)
|
|
9143
|
+
return;
|
|
9144
|
+
this.debugOverride = mode;
|
|
9145
|
+
this.events.fire('debugMode:changed', mode);
|
|
9146
|
+
}
|
|
9052
9147
|
/**
|
|
9053
9148
|
* The slider position in use: the stored one where it can be held, else the nearest available
|
|
9054
9149
|
* below it, else the lowest available. It differs from the stored position only in an XR
|
|
@@ -9124,21 +9219,24 @@ class Quality {
|
|
|
9124
9219
|
}
|
|
9125
9220
|
return levels.find((entry) => entry.budget !== null)?.budget ?? levels[0].budget ?? 1;
|
|
9126
9221
|
}
|
|
9127
|
-
|
|
9222
|
+
/**
|
|
9223
|
+
* Whether the Performance Mode toggle can switch renderers here, so the menus offer it:
|
|
9224
|
+
* allowed, and not forced on by the flag.
|
|
9225
|
+
*/
|
|
9128
9226
|
get switchable() {
|
|
9129
9227
|
const { stochastic } = this.config;
|
|
9130
9228
|
return this.stochasticAllowed && stochastic !== true && stochastic !== 'mobile';
|
|
9131
9229
|
}
|
|
9132
9230
|
// The largest budget up to `budget`, in steps of 0.1M, that every renderer which may draw it
|
|
9133
9231
|
// can hold: its cache in one storage binding and its estimated total under the ceiling; null
|
|
9134
|
-
// when none does. Where the toggle can switch renderers, both are
|
|
9135
|
-
// changes the budget: the splats resident for one renderer's budget
|
|
9136
|
-
// binding (sorted fails every frame past it) until coarser detail
|
|
9137
|
-
// files cooled down. It costs the stochastic renderer its headroom where it holds more (a
|
|
9232
|
+
// when none does. Where the toggle or the debug controls can switch renderers, both are
|
|
9233
|
+
// fitted, so a switch never changes the budget: the splats resident for one renderer's budget
|
|
9234
|
+
// could overflow the other's binding (sorted fails every frame past it) until coarser detail
|
|
9235
|
+
// streamed in and the finer files cooled down. It costs the stochastic renderer its headroom where it holds more (a
|
|
9138
9236
|
// 128 MiB binding at the 4M rung, 4.0M against sorted's 3.8M; Max on Chrome reporting 4 GB or
|
|
9139
9237
|
// less of memory)
|
|
9140
9238
|
fitBudget(budget) {
|
|
9141
|
-
const renderers = this.
|
|
9239
|
+
const renderers = this.debugModes ? [false, true] : [this.stochastic];
|
|
9142
9240
|
for (let b = budget; b >= 0.1; b = Math.round((b - 0.1) * 10) / 10) {
|
|
9143
9241
|
const fits = (stochastic) => this.cacheFits(b, stochastic) && this.estimateMB(b, stochastic) <= this.ceilingMB;
|
|
9144
9242
|
if (renderers.every(fits))
|
|
@@ -9404,7 +9502,18 @@ const importSettings = (settings) => {
|
|
|
9404
9502
|
return result;
|
|
9405
9503
|
};
|
|
9406
9504
|
|
|
9407
|
-
|
|
9505
|
+
// The touch-only bottom inset, normalised from what an embedder passes. Free of imports, so the
|
|
9506
|
+
// unit tests can load the source on its own, without a build or a dom.
|
|
9507
|
+
// the most a host's chrome can plausibly cover; beyond it the toolbar would leave a short
|
|
9508
|
+
// viewer altogether
|
|
9509
|
+
const TOUCH_INSET_BOTTOM_MAX = 200;
|
|
9510
|
+
// css pixels, clamped to 0..TOUCH_INSET_BOTTOM_MAX; a value that is not a finite number is 0
|
|
9511
|
+
const resolveTouchInsetBottom = (insetBottom) => {
|
|
9512
|
+
const value = Number(insetBottom);
|
|
9513
|
+
return Number.isFinite(value) ? Math.min(TOUCH_INSET_BOTTOM_MAX, Math.max(0, value)) : 0;
|
|
9514
|
+
};
|
|
9515
|
+
|
|
9516
|
+
var version = "1.40.0";
|
|
9408
9517
|
|
|
9409
9518
|
class Tooltip {
|
|
9410
9519
|
register;
|
|
@@ -12417,9 +12526,9 @@ class XrIceCream {
|
|
|
12417
12526
|
// The menu's rows, a column centred on its anchor (meters, at real size), each ROW_HEIGHT tall and
|
|
12418
12527
|
// drawn at PIXELS per meter: a hand's length across, read from about 40 cm
|
|
12419
12528
|
const ROW_WIDTH = 0.12;
|
|
12420
|
-
const ROW_HEIGHT = 0.024;
|
|
12421
|
-
const ROW_GAP = 0.004;
|
|
12422
|
-
const PIXELS = 4000;
|
|
12529
|
+
const ROW_HEIGHT$1 = 0.024;
|
|
12530
|
+
const ROW_GAP$1 = 0.004;
|
|
12531
|
+
const PIXELS$1 = 4000;
|
|
12423
12532
|
// Where the menu shows, as the engine's XrMenu script does it: an open hand, at least FINGERS_OPEN
|
|
12424
12533
|
// of its four fingers' tips more than FINGER_REACH from their knuckles, its palm facing the eyes
|
|
12425
12534
|
// within PALM_FACING (the cosine), puts the menu PALM_OFFSET out from the middle of the palm,
|
|
@@ -12466,6 +12575,8 @@ const GLASS_PRESS = 'rgba(88, 94, 108, 0.96)';
|
|
|
12466
12575
|
const ON = '#4cc38a';
|
|
12467
12576
|
const OFF = 'rgba(255, 255, 255, 0.28)';
|
|
12468
12577
|
const FINGERS = ['index', 'middle', 'ring', 'pinky'];
|
|
12578
|
+
// a submenu's first row, back to the main page
|
|
12579
|
+
const BACK = '‹ Back';
|
|
12469
12580
|
const rayOrigin = new Vec3();
|
|
12470
12581
|
const rayDirection = new Vec3();
|
|
12471
12582
|
const localOrigin = new Vec3();
|
|
@@ -12487,6 +12598,55 @@ const ease = (t) => t * t * (3 - 2 * t);
|
|
|
12487
12598
|
const lerp = (a, b, t) => a + (b - a) * t;
|
|
12488
12599
|
// moves value toward goal by step
|
|
12489
12600
|
const approach$1 = (value, goal, step) => value < goal ? Math.min(goal, value + step) : Math.max(goal, value - step);
|
|
12601
|
+
// A quad of a canvas, drawn as painted over the scene, a child of `parent` facing its +z, hidden;
|
|
12602
|
+
// width and height in meters, drawn at `pixels` per meter
|
|
12603
|
+
const createQuad = (app, parent, width, height, pixels) => {
|
|
12604
|
+
const canvas = document.createElement('canvas');
|
|
12605
|
+
canvas.width = Math.round(width * pixels);
|
|
12606
|
+
canvas.height = Math.round(height * pixels);
|
|
12607
|
+
// the canvas holds srgb colours, which a linear texture would brighten on the way out
|
|
12608
|
+
const texture = new Texture(app.graphicsDevice, {
|
|
12609
|
+
name: 'sse-xr-quad',
|
|
12610
|
+
width: canvas.width,
|
|
12611
|
+
height: canvas.height,
|
|
12612
|
+
format: PIXELFORMAT_SRGBA8,
|
|
12613
|
+
mipmaps: false,
|
|
12614
|
+
addressU: ADDRESS_CLAMP_TO_EDGE,
|
|
12615
|
+
addressV: ADDRESS_CLAMP_TO_EDGE
|
|
12616
|
+
});
|
|
12617
|
+
const material = new StandardMaterial();
|
|
12618
|
+
// drawn as painted: no light, sky, fog or the scene's tonemapping
|
|
12619
|
+
material.useLighting = false;
|
|
12620
|
+
material.useSkybox = false;
|
|
12621
|
+
material.useFog = false;
|
|
12622
|
+
material.useTonemap = false;
|
|
12623
|
+
material.diffuse.set(0, 0, 0);
|
|
12624
|
+
material.emissive.set(1, 1, 1);
|
|
12625
|
+
material.emissiveMap = texture;
|
|
12626
|
+
material.opacityMap = texture;
|
|
12627
|
+
material.opacityMapChannel = 'a';
|
|
12628
|
+
material.blendType = BLEND_NORMAL;
|
|
12629
|
+
// its depth goes to the compositor where it is drawn, so the background is not
|
|
12630
|
+
// reprojected through it, and it draws over the scene
|
|
12631
|
+
material.alphaTest = 0.1;
|
|
12632
|
+
material.depthTest = false;
|
|
12633
|
+
material.update();
|
|
12634
|
+
const entity = new Entity('XrQuad', app);
|
|
12635
|
+
entity.addComponent('render', { type: 'plane', castShadows: false, receiveShadows: false });
|
|
12636
|
+
entity.render.material = material;
|
|
12637
|
+
for (const meshInstance of entity.render.meshInstances)
|
|
12638
|
+
meshInstance.drawBucket = XR_OVERLAY_DRAW_BUCKET;
|
|
12639
|
+
// the plane lies flat facing up; stood up, it faces the parent's +z
|
|
12640
|
+
entity.setLocalEulerAngles(90, 0, 0);
|
|
12641
|
+
entity.setLocalScale(width, 1, height);
|
|
12642
|
+
entity.enabled = false;
|
|
12643
|
+
parent.addChild(entity);
|
|
12644
|
+
return { entity, canvas, texture, material };
|
|
12645
|
+
};
|
|
12646
|
+
const uploadQuad = (quad) => {
|
|
12647
|
+
quad.texture.setSource(quad.canvas);
|
|
12648
|
+
quad.texture.upload();
|
|
12649
|
+
};
|
|
12490
12650
|
/**
|
|
12491
12651
|
* A menu for XR sessions held in the hand, shown and placed as the engine's XrMenu script does:
|
|
12492
12652
|
* an open palm facing the eyes shows it just out from the palm, facing the eyes, the left hand's
|
|
@@ -12499,12 +12659,18 @@ const approach$1 = (value, goal, step) => value < goal ? Math.min(goal, value +
|
|
|
12499
12659
|
* navigation aims with it ({@link XrPalmMenu#select}), so the selects it takes do not teleport.
|
|
12500
12660
|
* A press clicks, pulses a controller, and shows on the row; the rows fade in and out and the
|
|
12501
12661
|
* switches slide. A stepper's halves are buttons of their own, and one that cannot step is greyed
|
|
12502
|
-
* out and takes no press.
|
|
12662
|
+
* out and takes no press. A submenu's row shows its page in the menu's place, a Back row at its
|
|
12663
|
+
* top. The menu scales with a scaled rig, staying the size of the hand.
|
|
12503
12664
|
*/
|
|
12504
12665
|
class XrPalmMenu {
|
|
12505
12666
|
app;
|
|
12506
12667
|
camera;
|
|
12507
|
-
|
|
12668
|
+
// the rows of every page, the main page's first, the page each is on, and the page a submenu's
|
|
12669
|
+
// row opens; the page shown, 0 the main one
|
|
12670
|
+
items = [];
|
|
12671
|
+
pageOf = [];
|
|
12672
|
+
submenuPage = new Map();
|
|
12673
|
+
page = 0;
|
|
12508
12674
|
// the column's parent, placed at the anchor and facing the eyes
|
|
12509
12675
|
container;
|
|
12510
12676
|
// a dot per pointing ray, where it meets the menu's plane
|
|
@@ -12545,12 +12711,26 @@ class XrPalmMenu {
|
|
|
12545
12711
|
constructor(app, camera, items) {
|
|
12546
12712
|
this.app = app;
|
|
12547
12713
|
this.camera = camera;
|
|
12548
|
-
|
|
12714
|
+
const add = (item, page) => {
|
|
12715
|
+
this.items.push(item);
|
|
12716
|
+
this.pageOf.push(page);
|
|
12717
|
+
};
|
|
12718
|
+
for (const item of items)
|
|
12719
|
+
add(item, 0);
|
|
12720
|
+
for (const item of items) {
|
|
12721
|
+
if (!item.submenu)
|
|
12722
|
+
continue;
|
|
12723
|
+
const page = this.submenuPage.size + 1;
|
|
12724
|
+
this.submenuPage.set(item, page);
|
|
12725
|
+
add({ label: () => BACK, action: () => this.setPage(0) }, page);
|
|
12726
|
+
for (const row of item.submenu)
|
|
12727
|
+
add(row, page);
|
|
12728
|
+
}
|
|
12549
12729
|
this.container = new Entity('XrPalmMenu', app);
|
|
12550
12730
|
app.root.addChild(this.container);
|
|
12551
|
-
this.rows = items.map(() => this.createQuad(ROW_WIDTH, ROW_HEIGHT));
|
|
12552
|
-
this.knobs = items.map((item) => (item.checked?.() ? 1 : 0));
|
|
12553
|
-
this.shown = items.map(() => 0);
|
|
12731
|
+
this.rows = this.items.map(() => this.createQuad(ROW_WIDTH, ROW_HEIGHT$1));
|
|
12732
|
+
this.knobs = this.items.map((item) => (item.checked?.() ? 1 : 0));
|
|
12733
|
+
this.shown = this.items.map(() => 0);
|
|
12554
12734
|
this.cursors = [0, 1].map(() => this.createQuad(CURSOR_SIZE, CURSOR_SIZE));
|
|
12555
12735
|
for (const cursor of this.cursors)
|
|
12556
12736
|
this.drawCursor(cursor);
|
|
@@ -12598,47 +12778,7 @@ class XrPalmMenu {
|
|
|
12598
12778
|
this.audio = null;
|
|
12599
12779
|
}
|
|
12600
12780
|
createQuad(width, height) {
|
|
12601
|
-
|
|
12602
|
-
canvas.width = Math.round(width * PIXELS);
|
|
12603
|
-
canvas.height = Math.round(height * PIXELS);
|
|
12604
|
-
// the canvas holds srgb colours, which a linear texture would brighten on the way out
|
|
12605
|
-
const texture = new Texture(this.app.graphicsDevice, {
|
|
12606
|
-
name: 'sse-xr-palm-menu',
|
|
12607
|
-
width: canvas.width,
|
|
12608
|
-
height: canvas.height,
|
|
12609
|
-
format: PIXELFORMAT_SRGBA8,
|
|
12610
|
-
mipmaps: false,
|
|
12611
|
-
addressU: ADDRESS_CLAMP_TO_EDGE,
|
|
12612
|
-
addressV: ADDRESS_CLAMP_TO_EDGE
|
|
12613
|
-
});
|
|
12614
|
-
const material = new StandardMaterial();
|
|
12615
|
-
// drawn as painted: no light, sky, fog or the scene's tonemapping
|
|
12616
|
-
material.useLighting = false;
|
|
12617
|
-
material.useSkybox = false;
|
|
12618
|
-
material.useFog = false;
|
|
12619
|
-
material.useTonemap = false;
|
|
12620
|
-
material.diffuse.set(0, 0, 0);
|
|
12621
|
-
material.emissive.set(1, 1, 1);
|
|
12622
|
-
material.emissiveMap = texture;
|
|
12623
|
-
material.opacityMap = texture;
|
|
12624
|
-
material.opacityMapChannel = 'a';
|
|
12625
|
-
material.blendType = BLEND_NORMAL;
|
|
12626
|
-
// its depth goes to the compositor where it is drawn, so the background is not
|
|
12627
|
-
// reprojected through it, and it draws over the scene
|
|
12628
|
-
material.alphaTest = 0.1;
|
|
12629
|
-
material.depthTest = false;
|
|
12630
|
-
material.update();
|
|
12631
|
-
const entity = new Entity('XrPalmMenu', this.app);
|
|
12632
|
-
entity.addComponent('render', { type: 'plane', castShadows: false, receiveShadows: false });
|
|
12633
|
-
entity.render.material = material;
|
|
12634
|
-
for (const meshInstance of entity.render.meshInstances)
|
|
12635
|
-
meshInstance.drawBucket = XR_OVERLAY_DRAW_BUCKET;
|
|
12636
|
-
// the plane lies flat facing up; stood up, it faces the container's +z, the eyes
|
|
12637
|
-
entity.setLocalEulerAngles(90, 0, 0);
|
|
12638
|
-
entity.setLocalScale(width, 1, height);
|
|
12639
|
-
entity.enabled = false;
|
|
12640
|
-
this.container.addChild(entity);
|
|
12641
|
-
return { entity, canvas, texture, material };
|
|
12781
|
+
return createQuad(this.app, this.container, width, height, PIXELS$1);
|
|
12642
12782
|
}
|
|
12643
12783
|
// the point in the quad's space, its plane at y = 0, its front at y > 0 and its size 1 across
|
|
12644
12784
|
// in x and z; y is in meters at real size
|
|
@@ -12678,10 +12818,12 @@ class XrPalmMenu {
|
|
|
12678
12818
|
rayDirection.copy(source.getDirection());
|
|
12679
12819
|
return this.rows.find((row) => row.entity.enabled && this.hits(row)) ?? null;
|
|
12680
12820
|
}
|
|
12681
|
-
// closed at once, as a session starts and ends
|
|
12821
|
+
// closed at once, on the main page, as a session starts and ends. Closing the hand keeps the
|
|
12822
|
+
// page, so a submenu is where it was when the hand opens again
|
|
12682
12823
|
hide() {
|
|
12683
12824
|
this.setOpen(false);
|
|
12684
12825
|
this.openness = 0;
|
|
12826
|
+
this.page = 0;
|
|
12685
12827
|
this.anchor = null;
|
|
12686
12828
|
this.toggleWasDown = false;
|
|
12687
12829
|
for (const row of this.rows)
|
|
@@ -12706,6 +12848,22 @@ class XrPalmMenu {
|
|
|
12706
12848
|
}
|
|
12707
12849
|
}
|
|
12708
12850
|
}
|
|
12851
|
+
// shows another page in the menu's place, its rows dropping in as on opening
|
|
12852
|
+
setPage(page) {
|
|
12853
|
+
this.page = page;
|
|
12854
|
+
this.openness = 0;
|
|
12855
|
+
this.hovered = null;
|
|
12856
|
+
this.hoveredSide = 0;
|
|
12857
|
+
this.flash = null;
|
|
12858
|
+
this.items.forEach((item, i) => {
|
|
12859
|
+
if (this.pageOf[i] === page)
|
|
12860
|
+
this.drawRow(i);
|
|
12861
|
+
});
|
|
12862
|
+
}
|
|
12863
|
+
// whether a row is shown: on the page shown, and visible
|
|
12864
|
+
showing(index) {
|
|
12865
|
+
return this.pageOf[index] === this.page && (this.items[index].visible?.() ?? true);
|
|
12866
|
+
}
|
|
12709
12867
|
startPress(source, quad, side) {
|
|
12710
12868
|
const release = () => this.endPress();
|
|
12711
12869
|
source.once('selectend', release);
|
|
@@ -12734,6 +12892,11 @@ class XrPalmMenu {
|
|
|
12734
12892
|
// switch's knob (the sharpen cycle)
|
|
12735
12893
|
run(index, side) {
|
|
12736
12894
|
const item = this.items[index];
|
|
12895
|
+
const page = this.submenuPage.get(item);
|
|
12896
|
+
if (page !== undefined) {
|
|
12897
|
+
this.setPage(page);
|
|
12898
|
+
return;
|
|
12899
|
+
}
|
|
12737
12900
|
if (item.stepper) {
|
|
12738
12901
|
item.stepper.step(side);
|
|
12739
12902
|
}
|
|
@@ -13015,14 +13178,14 @@ class XrPalmMenu {
|
|
|
13015
13178
|
}
|
|
13016
13179
|
animate(dt) {
|
|
13017
13180
|
// the column: each shown row ROW_TIME after the one above it starts, closing from the bottom
|
|
13018
|
-
const shown = this.items.filter((
|
|
13181
|
+
const shown = this.items.filter((_, i) => this.showing(i)).length;
|
|
13019
13182
|
const total = ROW_TIME + STAGGER * Math.max(shown - 1, 0);
|
|
13020
13183
|
this.openness = approach$1(this.openness, this.open ? 1 : 0, dt / total);
|
|
13021
13184
|
let k = 0;
|
|
13022
|
-
let y = 0.5 * (shown * ROW_HEIGHT + Math.max(shown - 1, 0) * ROW_GAP);
|
|
13185
|
+
let y = 0.5 * (shown * ROW_HEIGHT$1 + Math.max(shown - 1, 0) * ROW_GAP$1);
|
|
13023
13186
|
this.items.forEach((item, i) => {
|
|
13024
13187
|
const row = this.rows[i];
|
|
13025
|
-
const visible =
|
|
13188
|
+
const visible = this.showing(i);
|
|
13026
13189
|
const t = visible ? Math.min(Math.max((this.openness * total - k * STAGGER) / ROW_TIME, 0), 1) : 0;
|
|
13027
13190
|
const e = ease(t);
|
|
13028
13191
|
row.entity.enabled = t > 0;
|
|
@@ -13038,16 +13201,16 @@ class XrPalmMenu {
|
|
|
13038
13201
|
}
|
|
13039
13202
|
if (visible) {
|
|
13040
13203
|
if (row.entity.enabled) {
|
|
13041
|
-
row.entity.setLocalPosition(0, y - ROW_HEIGHT * 0.5 + (1 - e) * DROP, 0);
|
|
13204
|
+
row.entity.setLocalPosition(0, y - ROW_HEIGHT$1 * 0.5 + (1 - e) * DROP, 0);
|
|
13042
13205
|
const s = lerp(ROW_GROW, 1, e) * this.pressScale(row);
|
|
13043
|
-
row.entity.setLocalScale(ROW_WIDTH * s, 1, ROW_HEIGHT * s);
|
|
13206
|
+
row.entity.setLocalScale(ROW_WIDTH * s, 1, ROW_HEIGHT$1 * s);
|
|
13044
13207
|
if (e !== this.shown[i]) {
|
|
13045
13208
|
this.shown[i] = e;
|
|
13046
13209
|
row.material.opacity = e;
|
|
13047
13210
|
row.material.update();
|
|
13048
13211
|
}
|
|
13049
13212
|
}
|
|
13050
|
-
y -= ROW_HEIGHT + ROW_GAP;
|
|
13213
|
+
y -= ROW_HEIGHT$1 + ROW_GAP$1;
|
|
13051
13214
|
k++;
|
|
13052
13215
|
}
|
|
13053
13216
|
});
|
|
@@ -13178,8 +13341,123 @@ class XrPalmMenu {
|
|
|
13178
13341
|
this.upload(quad);
|
|
13179
13342
|
}
|
|
13180
13343
|
upload(quad) {
|
|
13181
|
-
|
|
13182
|
-
|
|
13344
|
+
uploadQuad(quad);
|
|
13345
|
+
}
|
|
13346
|
+
}
|
|
13347
|
+
|
|
13348
|
+
// The panel, in the camera's space (meters): low and to the left of the view, a metre away, out of
|
|
13349
|
+
// the scene's middle but a glance from it, LINES lines of LINE_HEIGHT drawn at PIXELS per meter
|
|
13350
|
+
// and redrawn every INTERVAL seconds, often enough to read and seldom enough not to cost a frame
|
|
13351
|
+
const POSITION = new Vec3(-0.24, -0.28, -1);
|
|
13352
|
+
const WIDTH = 0.36;
|
|
13353
|
+
const LINES = 3;
|
|
13354
|
+
const LINE_HEIGHT = 0.034;
|
|
13355
|
+
const HEIGHT = LINES * LINE_HEIGHT + 0.012;
|
|
13356
|
+
const PIXELS = 1600;
|
|
13357
|
+
const INTERVAL = 0.25;
|
|
13358
|
+
/**
|
|
13359
|
+
* Frame numbers in an XR session, which hides the page's MiniStats: the frame's time (and frames a
|
|
13360
|
+
* second), the GPU's time, and the splats the level of detail selected (the page's MiniStats'
|
|
13361
|
+
* Splats), a line each, head-locked low in the view while `enabled` in a session. The GPU's time
|
|
13362
|
+
* needs the device's GPU profiler, which the panel turns on while it shows and puts back as it was.
|
|
13363
|
+
*/
|
|
13364
|
+
class XrStats {
|
|
13365
|
+
app;
|
|
13366
|
+
quad;
|
|
13367
|
+
value = false;
|
|
13368
|
+
// whether the panel has the profiler on, and what it was before
|
|
13369
|
+
profiling = false;
|
|
13370
|
+
profilerWas = false;
|
|
13371
|
+
wait = 0;
|
|
13372
|
+
handle;
|
|
13373
|
+
/**
|
|
13374
|
+
* @param app - The application.
|
|
13375
|
+
* @param camera - The XR camera's entity, which the panel follows.
|
|
13376
|
+
*/
|
|
13377
|
+
constructor(app, camera) {
|
|
13378
|
+
this.app = app;
|
|
13379
|
+
// facing the camera's +z, back at the eyes from in front of them
|
|
13380
|
+
this.quad = createQuad(app, camera, WIDTH, HEIGHT, PIXELS);
|
|
13381
|
+
this.quad.entity.setLocalPosition(POSITION);
|
|
13382
|
+
this.handle = app.on('update', (dt) => this.update(dt));
|
|
13383
|
+
}
|
|
13384
|
+
get enabled() {
|
|
13385
|
+
return this.value;
|
|
13386
|
+
}
|
|
13387
|
+
set enabled(value) {
|
|
13388
|
+
if (value === this.value)
|
|
13389
|
+
return;
|
|
13390
|
+
this.value = value;
|
|
13391
|
+
this.wait = 0;
|
|
13392
|
+
this.show(value && this.app.xr.active);
|
|
13393
|
+
}
|
|
13394
|
+
destroy() {
|
|
13395
|
+
this.show(false);
|
|
13396
|
+
this.handle.off();
|
|
13397
|
+
this.quad.entity.destroy();
|
|
13398
|
+
this.quad.material.destroy();
|
|
13399
|
+
this.quad.texture.destroy();
|
|
13400
|
+
}
|
|
13401
|
+
// shows or hides the panel, the gpu profiler on only while it shows (it costs every frame's
|
|
13402
|
+
// passes their timestamps), and put back as it was after: a session's end hides it too
|
|
13403
|
+
show(shown) {
|
|
13404
|
+
this.quad.entity.enabled = shown;
|
|
13405
|
+
if (shown === this.profiling)
|
|
13406
|
+
return;
|
|
13407
|
+
this.profiling = shown;
|
|
13408
|
+
const profiler = this.app.graphicsDevice.gpuProfiler;
|
|
13409
|
+
if (!profiler)
|
|
13410
|
+
return;
|
|
13411
|
+
if (shown) {
|
|
13412
|
+
this.profilerWas = profiler.enabled;
|
|
13413
|
+
profiler.enabled = true;
|
|
13414
|
+
}
|
|
13415
|
+
else {
|
|
13416
|
+
profiler.enabled = this.profilerWas;
|
|
13417
|
+
}
|
|
13418
|
+
}
|
|
13419
|
+
update(dt) {
|
|
13420
|
+
const shown = this.value && this.app.xr.active;
|
|
13421
|
+
this.show(shown);
|
|
13422
|
+
if (!shown)
|
|
13423
|
+
return;
|
|
13424
|
+
this.wait -= dt;
|
|
13425
|
+
if (this.wait > 0)
|
|
13426
|
+
return;
|
|
13427
|
+
this.wait = INTERVAL;
|
|
13428
|
+
this.draw();
|
|
13429
|
+
}
|
|
13430
|
+
draw() {
|
|
13431
|
+
const { fps, frameTime, gpuFrameTime, frame } = this.app.stats;
|
|
13432
|
+
const gpu = gpuFrameTime === undefined ? '–' : gpuFrameTime.toFixed(1);
|
|
13433
|
+
const lines = [
|
|
13434
|
+
`Frame: ${frameTime.toFixed(1)} ms (${fps} fps)`,
|
|
13435
|
+
`GPU: ${gpu} ms`,
|
|
13436
|
+
`Splats: ${(frame.gsplats / 1e6).toFixed(2)}M`
|
|
13437
|
+
];
|
|
13438
|
+
const { canvas } = this.quad;
|
|
13439
|
+
const ctx = canvas.getContext('2d');
|
|
13440
|
+
const { width, height } = canvas;
|
|
13441
|
+
const line = LINE_HEIGHT * PIXELS;
|
|
13442
|
+
const left = line * 0.4;
|
|
13443
|
+
ctx.clearRect(0, 0, width, height);
|
|
13444
|
+
ctx.fillStyle = 'rgba(20, 22, 28, 0.78)';
|
|
13445
|
+
ctx.beginPath();
|
|
13446
|
+
ctx.roundRect(1, 1, width - 2, height - 2, line * 0.4);
|
|
13447
|
+
ctx.fill();
|
|
13448
|
+
// the type smaller where the longest line would run off the panel
|
|
13449
|
+
const font = (size) => `500 ${size}px ui-monospace, Menlo, monospace`;
|
|
13450
|
+
const size = Math.round(line * 0.6);
|
|
13451
|
+
ctx.font = font(size);
|
|
13452
|
+
const widest = Math.max(...lines.map((text) => ctx.measureText(text).width));
|
|
13453
|
+
const room = width - 2 * left;
|
|
13454
|
+
if (widest > room)
|
|
13455
|
+
ctx.font = font(Math.floor((size * room) / widest));
|
|
13456
|
+
ctx.fillStyle = '#ffffff';
|
|
13457
|
+
ctx.textBaseline = 'middle';
|
|
13458
|
+
const top = (height - lines.length * line) / 2;
|
|
13459
|
+
lines.forEach((text, i) => ctx.fillText(text, left, top + (i + 0.5) * line));
|
|
13460
|
+
uploadQuad(this.quad);
|
|
13183
13461
|
}
|
|
13184
13462
|
}
|
|
13185
13463
|
|
|
@@ -13200,7 +13478,7 @@ const CAPSULE_HOVER = 0.2;
|
|
|
13200
13478
|
// for the ui
|
|
13201
13479
|
// The viewer reconfigures the camera (clear color, post effects) when state.xrMode changes
|
|
13202
13480
|
const initXr = (global) => {
|
|
13203
|
-
const { app, events, state, camera, renderer, root, localize, quality } = global;
|
|
13481
|
+
const { app, config, events, state, camera, renderer, root, localize, quality } = global;
|
|
13204
13482
|
const { xr } = app;
|
|
13205
13483
|
let destroyed = false;
|
|
13206
13484
|
let restoreFrame = null;
|
|
@@ -13584,6 +13862,53 @@ const initXr = (global) => {
|
|
|
13584
13862
|
const index = available.indexOf(quality.level);
|
|
13585
13863
|
return index < 0 ? null : (available[index + direction] ?? null);
|
|
13586
13864
|
};
|
|
13865
|
+
// With the debug flag, the menu has a Debug page: the renderer and mode (sorted, or a stochastic
|
|
13866
|
+
// mode) on WebGPU, the stochastic renderer's TAA while it draws, and frame numbers. Its labels
|
|
13867
|
+
// are the developer's, in English
|
|
13868
|
+
let splatRenderer = null;
|
|
13869
|
+
const rendererHandles = [
|
|
13870
|
+
events.on('splatRenderer:ready', (renderer) => {
|
|
13871
|
+
splatRenderer = quality.stochastic ? renderer : null;
|
|
13872
|
+
}),
|
|
13873
|
+
events.on('splatRenderer:changed', (renderer) => {
|
|
13874
|
+
splatRenderer = renderer;
|
|
13875
|
+
})
|
|
13876
|
+
];
|
|
13877
|
+
const stats = config.debug ? new XrStats(app, camera) : null;
|
|
13878
|
+
const modeStep = (direction) => DEBUG_MODES[DEBUG_MODES.indexOf(quality.debugMode) + direction] ?? null;
|
|
13879
|
+
const debugItems = [
|
|
13880
|
+
{
|
|
13881
|
+
label: () => `Mode: ${quality.debugMode}`,
|
|
13882
|
+
visible: () => quality.debugModes,
|
|
13883
|
+
stepper: {
|
|
13884
|
+
can: (direction) => modeStep(direction) !== null,
|
|
13885
|
+
step: (direction) => {
|
|
13886
|
+
const next = modeStep(direction);
|
|
13887
|
+
if (next)
|
|
13888
|
+
quality.setDebugMode(next);
|
|
13889
|
+
}
|
|
13890
|
+
}
|
|
13891
|
+
},
|
|
13892
|
+
{
|
|
13893
|
+
label: () => 'TAA',
|
|
13894
|
+
checked: () => splatRenderer?.variant.taa === 'on',
|
|
13895
|
+
visible: () => !!splatRenderer,
|
|
13896
|
+
action: () => {
|
|
13897
|
+
if (!splatRenderer)
|
|
13898
|
+
return;
|
|
13899
|
+
splatRenderer.variant.taa = splatRenderer.variant.taa === 'on' ? 'off' : 'on';
|
|
13900
|
+
splatRenderer.applyVariant();
|
|
13901
|
+
}
|
|
13902
|
+
},
|
|
13903
|
+
{
|
|
13904
|
+
label: () => 'MiniStats',
|
|
13905
|
+
checked: () => !!stats?.enabled,
|
|
13906
|
+
action: () => {
|
|
13907
|
+
if (stats)
|
|
13908
|
+
stats.enabled = !stats.enabled;
|
|
13909
|
+
}
|
|
13910
|
+
}
|
|
13911
|
+
];
|
|
13587
13912
|
// The menu held in the hand, which takes the selects that start on it before the navigation aims
|
|
13588
13913
|
// with them
|
|
13589
13914
|
const menu = new XrPalmMenu(app, camera, [
|
|
@@ -13602,7 +13927,7 @@ const initXr = (global) => {
|
|
|
13602
13927
|
{
|
|
13603
13928
|
label: () => localize('settings.performance-mode'),
|
|
13604
13929
|
checked: () => state.performanceMode,
|
|
13605
|
-
visible: () => quality.
|
|
13930
|
+
visible: () => quality.switchable,
|
|
13606
13931
|
action: () => {
|
|
13607
13932
|
state.performanceMode = !state.performanceMode;
|
|
13608
13933
|
}
|
|
@@ -13616,6 +13941,7 @@ const initXr = (global) => {
|
|
|
13616
13941
|
state.iceCream = !state.iceCream;
|
|
13617
13942
|
}
|
|
13618
13943
|
},
|
|
13944
|
+
...(config.debug ? [{ label: () => 'Debug ›', submenu: debugItems }] : []),
|
|
13619
13945
|
{
|
|
13620
13946
|
label: () => localize(xr.type === 'immersive-ar' ? 'xr-menu.exit-ar' : 'xr-menu.exit-vr'),
|
|
13621
13947
|
action: () => {
|
|
@@ -13675,6 +14001,9 @@ const initXr = (global) => {
|
|
|
13675
14001
|
handStyle.destroy();
|
|
13676
14002
|
forgetReferenceSpace();
|
|
13677
14003
|
menu.destroy();
|
|
14004
|
+
stats?.destroy();
|
|
14005
|
+
for (const handle of rendererHandles)
|
|
14006
|
+
handle.off();
|
|
13678
14007
|
iceCreamChanged.off();
|
|
13679
14008
|
iceCream?.destroy();
|
|
13680
14009
|
iceCream = null;
|
|
@@ -13874,8 +14203,9 @@ const initUI = (global, viewer, getPicker, getCameraProgress) => {
|
|
|
13874
14203
|
on('quality:changed', updateQuality);
|
|
13875
14204
|
on('qualityAvailable:changed', updateQuality);
|
|
13876
14205
|
updateQuality();
|
|
13877
|
-
// Performance Mode, the stochastic renderer's toggle, where the
|
|
13878
|
-
|
|
14206
|
+
// Performance Mode, the stochastic renderer's toggle, where it can switch the renderer: the
|
|
14207
|
+
// device offers it and the stochastic flag does not force the renderer
|
|
14208
|
+
dom.performanceModeRow.classList.toggle('sse-hidden', !global.quality.switchable);
|
|
13879
14209
|
dom.performanceModeRow.addEventListener('click', () => {
|
|
13880
14210
|
state.performanceMode = !state.performanceMode;
|
|
13881
14211
|
});
|
|
@@ -16991,6 +17321,12 @@ class PickDepthOverlay {
|
|
|
16991
17321
|
// lazily on first show so there's no footprint on production URLs.
|
|
16992
17322
|
const STYLE_ID = 'sse-debug-panel-style';
|
|
16993
17323
|
const PANEL_CLASS = 'sse-debug-panel';
|
|
17324
|
+
// every row and button the same height, a row's gap between rows and a group's before a group
|
|
17325
|
+
const ROW_HEIGHT = 20;
|
|
17326
|
+
const ROW_GAP = 2;
|
|
17327
|
+
const GROUP_GAP = 8;
|
|
17328
|
+
// every option of every choice the same width, so the choices line up at the right
|
|
17329
|
+
const SEGMENT_WIDTH = '10ch';
|
|
16994
17330
|
const STYLES = `
|
|
16995
17331
|
.${PANEL_CLASS} {
|
|
16996
17332
|
position: absolute;
|
|
@@ -17013,10 +17349,13 @@ const STYLES = `
|
|
|
17013
17349
|
.${PANEL_CLASS} .sse-debug-row {
|
|
17014
17350
|
display: flex;
|
|
17015
17351
|
justify-content: space-between;
|
|
17352
|
+
align-items: center;
|
|
17016
17353
|
gap: 12px;
|
|
17017
17354
|
white-space: nowrap;
|
|
17355
|
+
min-height: ${ROW_HEIGHT}px;
|
|
17356
|
+
margin-top: ${ROW_GAP}px;
|
|
17018
17357
|
}
|
|
17019
|
-
.${PANEL_CLASS} .sse-debug-
|
|
17358
|
+
.${PANEL_CLASS} .sse-debug-label {
|
|
17020
17359
|
color: #888;
|
|
17021
17360
|
}
|
|
17022
17361
|
.${PANEL_CLASS} .sse-debug-row .sse-debug-value {
|
|
@@ -17043,17 +17382,6 @@ const STYLES = `
|
|
|
17043
17382
|
.${PANEL_CLASS} .sse-debug-row .sse-debug-value.sse-flash-bad {
|
|
17044
17383
|
background: rgba(220, 100, 100, 0.45);
|
|
17045
17384
|
}
|
|
17046
|
-
.${PANEL_CLASS} .sse-debug-buttons {
|
|
17047
|
-
display: grid;
|
|
17048
|
-
grid-auto-flow: column;
|
|
17049
|
-
grid-auto-columns: minmax(0, 1fr);
|
|
17050
|
-
gap: 6px;
|
|
17051
|
-
margin-top: 6px;
|
|
17052
|
-
}
|
|
17053
|
-
.${PANEL_CLASS} .sse-debug-buttons.sse-debug-grid {
|
|
17054
|
-
grid-auto-flow: row;
|
|
17055
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
17056
|
-
}
|
|
17057
17385
|
.${PANEL_CLASS} button {
|
|
17058
17386
|
min-width: 0;
|
|
17059
17387
|
white-space: nowrap;
|
|
@@ -17063,7 +17391,9 @@ const STYLES = `
|
|
|
17063
17391
|
color: #eee;
|
|
17064
17392
|
border: 1px solid rgba(255, 255, 255, 0.12);
|
|
17065
17393
|
border-radius: 3px;
|
|
17066
|
-
|
|
17394
|
+
box-sizing: border-box;
|
|
17395
|
+
height: ${ROW_HEIGHT}px;
|
|
17396
|
+
padding: 0 8px;
|
|
17067
17397
|
font: inherit;
|
|
17068
17398
|
cursor: pointer;
|
|
17069
17399
|
transition: background-color 0.15s ease;
|
|
@@ -17080,18 +17410,128 @@ const STYLES = `
|
|
|
17080
17410
|
.${PANEL_CLASS} input.sse-debug-paste {
|
|
17081
17411
|
width: 100%;
|
|
17082
17412
|
box-sizing: border-box;
|
|
17083
|
-
|
|
17413
|
+
height: ${ROW_HEIGHT}px;
|
|
17414
|
+
margin-top: ${ROW_GAP}px;
|
|
17084
17415
|
background: rgba(255, 255, 255, 0.08);
|
|
17085
17416
|
color: #eee;
|
|
17086
17417
|
border: 1px solid rgba(120, 180, 255, 0.6);
|
|
17087
17418
|
border-radius: 3px;
|
|
17088
|
-
padding:
|
|
17419
|
+
padding: 0 8px;
|
|
17089
17420
|
font: inherit;
|
|
17090
17421
|
}
|
|
17091
17422
|
.${PANEL_CLASS} button.sse-debug-on {
|
|
17092
17423
|
background: rgba(120, 180, 255, 0.35);
|
|
17093
17424
|
}
|
|
17425
|
+
/* the camera's rows beside the view buttons, stacked a row each */
|
|
17426
|
+
.${PANEL_CLASS} .sse-debug-top {
|
|
17427
|
+
display: grid;
|
|
17428
|
+
grid-template-columns: minmax(0, 1fr) 13ch;
|
|
17429
|
+
column-gap: 12px;
|
|
17430
|
+
}
|
|
17431
|
+
.${PANEL_CLASS} .sse-debug-stack {
|
|
17432
|
+
display: grid;
|
|
17433
|
+
row-gap: ${ROW_GAP}px;
|
|
17434
|
+
align-content: start;
|
|
17435
|
+
}
|
|
17436
|
+
/* a row whose label has small actions at the right */
|
|
17437
|
+
.${PANEL_CLASS} .sse-debug-head {
|
|
17438
|
+
display: flex;
|
|
17439
|
+
justify-content: space-between;
|
|
17440
|
+
align-items: center;
|
|
17441
|
+
min-height: ${ROW_HEIGHT}px;
|
|
17442
|
+
}
|
|
17443
|
+
.${PANEL_CLASS} .sse-debug-head .sse-debug-actions {
|
|
17444
|
+
display: flex;
|
|
17445
|
+
gap: 4px;
|
|
17446
|
+
}
|
|
17447
|
+
/* a group's label on the line of its controls, which line up at the right */
|
|
17448
|
+
.${PANEL_CLASS} .sse-debug-line {
|
|
17449
|
+
display: flex;
|
|
17450
|
+
justify-content: space-between;
|
|
17451
|
+
align-items: center;
|
|
17452
|
+
gap: 12px;
|
|
17453
|
+
min-height: ${ROW_HEIGHT}px;
|
|
17454
|
+
margin-top: ${GROUP_GAP}px;
|
|
17455
|
+
}
|
|
17456
|
+
/* a control that does not apply to the renderer in use */
|
|
17457
|
+
.${PANEL_CLASS} button:disabled {
|
|
17458
|
+
opacity: 0.35;
|
|
17459
|
+
cursor: default;
|
|
17460
|
+
}
|
|
17461
|
+
.${PANEL_CLASS} button:disabled:hover {
|
|
17462
|
+
background: rgba(255, 255, 255, 0.08);
|
|
17463
|
+
}
|
|
17464
|
+
.${PANEL_CLASS} .sse-debug-off .sse-debug-label {
|
|
17465
|
+
color: #555;
|
|
17466
|
+
}
|
|
17467
|
+
/* the splat counts: a label row over a value row */
|
|
17468
|
+
.${PANEL_CLASS} .sse-debug-table {
|
|
17469
|
+
display: grid;
|
|
17470
|
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
17471
|
+
column-gap: 8px;
|
|
17472
|
+
row-gap: ${ROW_GAP}px;
|
|
17473
|
+
margin-top: ${GROUP_GAP}px;
|
|
17474
|
+
}
|
|
17475
|
+
.${PANEL_CLASS} .sse-debug-table > span {
|
|
17476
|
+
display: flex;
|
|
17477
|
+
align-items: center;
|
|
17478
|
+
min-height: ${ROW_HEIGHT}px;
|
|
17479
|
+
white-space: nowrap;
|
|
17480
|
+
font-variant-numeric: tabular-nums;
|
|
17481
|
+
}
|
|
17482
|
+
/* a choice of one: the options joined, the chosen one lit */
|
|
17483
|
+
.${PANEL_CLASS} .sse-debug-segments {
|
|
17484
|
+
display: grid;
|
|
17485
|
+
grid-auto-flow: column;
|
|
17486
|
+
grid-auto-columns: ${SEGMENT_WIDTH};
|
|
17487
|
+
}
|
|
17488
|
+
.${PANEL_CLASS} .sse-debug-segments button {
|
|
17489
|
+
border-radius: 0;
|
|
17490
|
+
margin-left: -1px;
|
|
17491
|
+
}
|
|
17492
|
+
.${PANEL_CLASS} .sse-debug-segments button:first-child {
|
|
17493
|
+
border-radius: 3px 0 0 3px;
|
|
17494
|
+
margin-left: 0;
|
|
17495
|
+
}
|
|
17496
|
+
.${PANEL_CLASS} .sse-debug-segments button:last-child {
|
|
17497
|
+
border-radius: 0 3px 3px 0;
|
|
17498
|
+
}
|
|
17094
17499
|
`;
|
|
17500
|
+
// the renderer and mode choices' tooltips
|
|
17501
|
+
const MODE_TITLES = {
|
|
17502
|
+
sorted: "The engine's renderer: splats sorted by depth and blended",
|
|
17503
|
+
pixel: 'Stochastic, a coverage threshold per pixel (desktops)',
|
|
17504
|
+
mobile: 'Stochastic, interleaved pixel sets with jittered strata (phones, tablets)',
|
|
17505
|
+
sol: 'Stochastic, a solid ellipse per splat: the speed-of-light bound'
|
|
17506
|
+
};
|
|
17507
|
+
// fills `host` with a button per option, each choosing its value
|
|
17508
|
+
const segments = (host, options, choose) => {
|
|
17509
|
+
const buttons = new Map();
|
|
17510
|
+
for (const { value, label, title } of options) {
|
|
17511
|
+
const button = document.createElement('button');
|
|
17512
|
+
button.textContent = label;
|
|
17513
|
+
if (title)
|
|
17514
|
+
button.title = title;
|
|
17515
|
+
button.addEventListener('click', () => choose(value));
|
|
17516
|
+
host.appendChild(button);
|
|
17517
|
+
buttons.set(value, button);
|
|
17518
|
+
}
|
|
17519
|
+
return buttons;
|
|
17520
|
+
};
|
|
17521
|
+
// a count compactly: thousands and millions
|
|
17522
|
+
const count = (value) => {
|
|
17523
|
+
if (value === null)
|
|
17524
|
+
return '—';
|
|
17525
|
+
if (value >= 1e6)
|
|
17526
|
+
return `${(value / 1e6).toFixed(2)}M`;
|
|
17527
|
+
if (value >= 1e3)
|
|
17528
|
+
return `${(value / 1e3).toFixed(1)}K`;
|
|
17529
|
+
return `${value}`;
|
|
17530
|
+
};
|
|
17531
|
+
// lights the chosen option, or none
|
|
17532
|
+
const light = (buttons, chosen) => {
|
|
17533
|
+
buttons?.forEach((button, value) => button.classList.toggle('sse-debug-on', value === chosen));
|
|
17534
|
+
};
|
|
17095
17535
|
// each component padded to a fixed width, so the values hold their place as the camera moves
|
|
17096
17536
|
const fmt = (v) => [v.x, v.y, v.z].map((c) => c.toFixed(3).padStart(8)).join(',');
|
|
17097
17537
|
// Accepts "1,2,3", "1, 2, 3", "1 2 3", with or without trailing whitespace.
|
|
@@ -17111,15 +17551,22 @@ class DebugPanel {
|
|
|
17111
17551
|
_global;
|
|
17112
17552
|
_cameraManager;
|
|
17113
17553
|
_picker;
|
|
17114
|
-
// the stochastic renderer
|
|
17554
|
+
// the stochastic renderer while it draws, for its depth cull toggle and counts: Performance
|
|
17555
|
+
// Mode switches it in and out, and its controls show only while it is in
|
|
17115
17556
|
_splatRenderer;
|
|
17116
|
-
|
|
17117
|
-
|
|
17118
|
-
|
|
17119
|
-
|
|
17120
|
-
|
|
17121
|
-
|
|
17122
|
-
|
|
17557
|
+
_stochasticSection = null;
|
|
17558
|
+
_splatRendererChanged;
|
|
17559
|
+
// the choices, a button per option
|
|
17560
|
+
_modeButtons = null;
|
|
17561
|
+
_taaButtons = null;
|
|
17562
|
+
_cullButtons = null;
|
|
17563
|
+
// the splat counts
|
|
17564
|
+
_loadedValue = null;
|
|
17565
|
+
_selectedValue = null;
|
|
17566
|
+
_onScreenValue = null;
|
|
17567
|
+
_renderedValue = null;
|
|
17568
|
+
_countsFrames = 0;
|
|
17569
|
+
_countsPending = false;
|
|
17123
17570
|
_pickDepthOverlay = null;
|
|
17124
17571
|
_focusTmp = new Vec3();
|
|
17125
17572
|
_root = null;
|
|
@@ -17140,8 +17587,8 @@ class DebugPanel {
|
|
|
17140
17587
|
_editCanceled = false;
|
|
17141
17588
|
_visible = false;
|
|
17142
17589
|
_onPrerender = () => this._render();
|
|
17143
|
-
// the
|
|
17144
|
-
_onFrameEnd = () => this.
|
|
17590
|
+
// the counts are the frame's, so they refresh after it
|
|
17591
|
+
_onFrameEnd = () => this._renderCounts();
|
|
17145
17592
|
_onKeyDown = (event) => {
|
|
17146
17593
|
// Ctrl+Shift+D — also accept Meta+Shift+D on macOS for parity
|
|
17147
17594
|
if (!this._global.state.inputEnabled)
|
|
@@ -17157,6 +17604,10 @@ class DebugPanel {
|
|
|
17157
17604
|
this._picker = picker;
|
|
17158
17605
|
this._splatRenderer = splatRenderer;
|
|
17159
17606
|
this._miniStats = miniStats;
|
|
17607
|
+
this._splatRendererChanged = global.events.on('splatRenderer:changed', (renderer) => {
|
|
17608
|
+
this._splatRenderer = renderer;
|
|
17609
|
+
this._renderStochastic();
|
|
17610
|
+
});
|
|
17160
17611
|
window.addEventListener('keydown', this._onKeyDown);
|
|
17161
17612
|
if (global.config.debug) {
|
|
17162
17613
|
this.show();
|
|
@@ -17204,6 +17655,7 @@ class DebugPanel {
|
|
|
17204
17655
|
this.hide();
|
|
17205
17656
|
this._pickDepthOverlay?.destroy();
|
|
17206
17657
|
this._pickDepthOverlay = null;
|
|
17658
|
+
this._splatRendererChanged.off();
|
|
17207
17659
|
window.removeEventListener('keydown', this._onKeyDown);
|
|
17208
17660
|
if (this._root) {
|
|
17209
17661
|
this._root.remove();
|
|
@@ -17225,28 +17677,45 @@ class DebugPanel {
|
|
|
17225
17677
|
const root = document.createElement('div');
|
|
17226
17678
|
root.className = PANEL_CLASS;
|
|
17227
17679
|
root.innerHTML = `
|
|
17228
|
-
<div class="sse-debug-
|
|
17229
|
-
|
|
17230
|
-
|
|
17231
|
-
|
|
17232
|
-
|
|
17680
|
+
<div class="sse-debug-top">
|
|
17681
|
+
<div>
|
|
17682
|
+
<div class="sse-debug-head">
|
|
17683
|
+
<span class="sse-debug-label">Camera</span>
|
|
17684
|
+
<span class="sse-debug-actions">
|
|
17685
|
+
<button data-id="copy" title="Copy the camera's state">Copy</button>
|
|
17686
|
+
<button data-id="paste" title="Paste a copied camera state">Paste</button>
|
|
17687
|
+
</span>
|
|
17688
|
+
</div>
|
|
17689
|
+
<div class="sse-debug-row"><span class="sse-debug-label">Position</span><span class="sse-debug-value" data-id="position" contenteditable="plaintext-only" spellcheck="false" title="Edit to set camera position">—</span></div>
|
|
17690
|
+
<div class="sse-debug-row"><span class="sse-debug-label">Focus</span><span class="sse-debug-value" data-id="focus" contenteditable="plaintext-only" spellcheck="false" title="Edit to look at this point">—</span></div>
|
|
17691
|
+
</div>
|
|
17692
|
+
<div class="sse-debug-stack">
|
|
17693
|
+
<button data-id="screenshot">Screenshot</button>
|
|
17694
|
+
<button data-id="pick-depth" title="Show the depth a navigation pick finds at every pixel">Show depth</button>
|
|
17695
|
+
<button data-id="ministats" title="Show the engine's MiniStats graphs (the viewer then renders every frame)">MiniStats</button>
|
|
17696
|
+
</div>
|
|
17233
17697
|
</div>
|
|
17234
|
-
<
|
|
17235
|
-
|
|
17236
|
-
<
|
|
17237
|
-
|
|
17698
|
+
<input class="sse-debug-paste" data-id="paste-field" placeholder="Clipboard blocked here: paste with Ctrl/Cmd+V" spellcheck="false" style="display: none">
|
|
17699
|
+
<div data-id="renderer">
|
|
17700
|
+
<div class="sse-debug-line">
|
|
17701
|
+
<span class="sse-debug-label">Renderer</span>
|
|
17702
|
+
<div class="sse-debug-segments" data-id="mode"></div>
|
|
17703
|
+
</div>
|
|
17704
|
+
<div data-id="stochastic">
|
|
17705
|
+
<div class="sse-debug-row"><span class="sse-debug-label">TAA</span><span class="sse-debug-segments" data-id="taa" title="Stochastic modes: accumulate the samples over frames (reprojected while the camera moves)"></span></div>
|
|
17706
|
+
<div class="sse-debug-row"><span class="sse-debug-label">Depth cull</span><span class="sse-debug-segments" data-id="depth-cull" title="Stochastic modes: cull splats hidden in the previous frame's depth (auto suspends the test when it removes too little)"></span></div>
|
|
17707
|
+
</div>
|
|
17238
17708
|
</div>
|
|
17239
|
-
|
|
17240
|
-
|
|
17241
|
-
|
|
17242
|
-
<
|
|
17243
|
-
<
|
|
17244
|
-
<
|
|
17245
|
-
<
|
|
17709
|
+
<div class="sse-debug-table" title="Splats in the files loaded (in use or cooling down), selected by the level of detail and budget, in view after the frustum cull (and a stochastic mode's random coverage), and drawn after the depth cull, with the share it removed">
|
|
17710
|
+
<span class="sse-debug-label">Loaded</span>
|
|
17711
|
+
<span class="sse-debug-label">Splats</span>
|
|
17712
|
+
<span class="sse-debug-label">On screen</span>
|
|
17713
|
+
<span class="sse-debug-label">Rendered</span>
|
|
17714
|
+
<span data-id="loaded">—</span>
|
|
17715
|
+
<span data-id="selected">—</span>
|
|
17716
|
+
<span data-id="on-screen">—</span>
|
|
17717
|
+
<span data-id="rendered">—</span>
|
|
17246
17718
|
</div>
|
|
17247
|
-
<div class="sse-debug-row"><span class="sse-debug-label">culled</span><span class="sse-debug-value" data-id="culled">—</span></div>`
|
|
17248
|
-
: ''}
|
|
17249
|
-
<input class="sse-debug-paste" data-id="paste-field" placeholder="Clipboard blocked here: paste with Ctrl/Cmd+V" spellcheck="false" style="display: none">
|
|
17250
17719
|
`;
|
|
17251
17720
|
host.appendChild(root);
|
|
17252
17721
|
this._root = root;
|
|
@@ -17275,45 +17744,56 @@ class DebugPanel {
|
|
|
17275
17744
|
this._pickDepthButton.addEventListener('click', () => {
|
|
17276
17745
|
this._setPickDepth(!this._pickDepthOverlay?.enabled);
|
|
17277
17746
|
});
|
|
17278
|
-
|
|
17279
|
-
|
|
17280
|
-
|
|
17281
|
-
|
|
17282
|
-
|
|
17283
|
-
|
|
17284
|
-
|
|
17285
|
-
|
|
17286
|
-
|
|
17287
|
-
this._renderCull();
|
|
17288
|
-
});
|
|
17289
|
-
this._sharpenButton = root.querySelector('[data-id="sharpen"]');
|
|
17290
|
-
// cycles the display sharpen: off -> 1 -> 2 -> off, without resetting the history
|
|
17291
|
-
this._sharpenButton.addEventListener('click', () => {
|
|
17292
|
-
const renderer = this._splatRenderer;
|
|
17293
|
-
const k = renderer.variant.taaSharpen;
|
|
17294
|
-
renderer.setSharpen(k >= 2 ? 0 : k >= 1 ? 2 : 1);
|
|
17295
|
-
this._renderCull();
|
|
17296
|
-
});
|
|
17297
|
-
this._culledValue = root.querySelector('[data-id="culled"]');
|
|
17298
|
-
this._taaButton.addEventListener('click', () => {
|
|
17299
|
-
const renderer = this._splatRenderer;
|
|
17300
|
-
renderer.variant.taa = renderer.variant.taa === 'on' ? 'off' : 'on';
|
|
17301
|
-
renderer.applyVariant();
|
|
17302
|
-
this._renderCull();
|
|
17303
|
-
});
|
|
17304
|
-
// cycles the cull mode: auto (the default) -> on (both grid levels) -> off
|
|
17305
|
-
this._cullButton.addEventListener('click', () => {
|
|
17306
|
-
const renderer = this._splatRenderer;
|
|
17307
|
-
const next = { auto: 'l2', l2: 'off', l1: 'off', off: 'auto' };
|
|
17308
|
-
renderer.variant.cull = next[renderer.variant.cull];
|
|
17309
|
-
renderer.applyVariant();
|
|
17310
|
-
this._renderCull();
|
|
17311
|
-
});
|
|
17312
|
-
this._renderCull();
|
|
17747
|
+
this._stochasticSection = root.querySelector('[data-id="stochastic"]');
|
|
17748
|
+
this._loadedValue = root.querySelector('[data-id="loaded"]');
|
|
17749
|
+
this._selectedValue = root.querySelector('[data-id="selected"]');
|
|
17750
|
+
this._onScreenValue = root.querySelector('[data-id="on-screen"]');
|
|
17751
|
+
this._renderedValue = root.querySelector('[data-id="rendered"]');
|
|
17752
|
+
// the renderer and mode where WebGPU offers them: sorted, pixel, mobile or sol
|
|
17753
|
+
const { quality } = this._global;
|
|
17754
|
+
if (quality.debugModes) {
|
|
17755
|
+
this._buildRendererControls(root);
|
|
17313
17756
|
}
|
|
17757
|
+
else {
|
|
17758
|
+
// no choice of renderer here (WebGL), so none of its rows
|
|
17759
|
+
root.querySelector('[data-id="renderer"]').remove();
|
|
17760
|
+
this._stochasticSection = null;
|
|
17761
|
+
}
|
|
17762
|
+
this._renderStochastic();
|
|
17314
17763
|
this._wireEditable(this._positionValue, 'position');
|
|
17315
17764
|
this._wireEditable(this._focusValue, 'focus');
|
|
17316
17765
|
}
|
|
17766
|
+
// the renderer and mode, and the stochastic renderer's choices
|
|
17767
|
+
_buildRendererControls(root) {
|
|
17768
|
+
const { quality } = this._global;
|
|
17769
|
+
this._modeButtons = segments(root.querySelector('[data-id="mode"]'), DEBUG_MODES.map((mode) => ({
|
|
17770
|
+
value: mode,
|
|
17771
|
+
label: mode[0].toUpperCase() + mode.slice(1),
|
|
17772
|
+
title: MODE_TITLES[mode]
|
|
17773
|
+
})), (mode) => quality.setDebugMode(mode));
|
|
17774
|
+
// each acts on the renderer in use; the rows are disabled while there is none
|
|
17775
|
+
const onRenderer = (change) => (value) => {
|
|
17776
|
+
if (!this._splatRenderer)
|
|
17777
|
+
return;
|
|
17778
|
+
change(this._splatRenderer, value);
|
|
17779
|
+
this._splatRenderer.applyVariant();
|
|
17780
|
+
this._renderCull();
|
|
17781
|
+
};
|
|
17782
|
+
this._taaButtons = segments(root.querySelector('[data-id="taa"]'), [
|
|
17783
|
+
{ value: 'on', label: 'On' },
|
|
17784
|
+
{ value: 'off', label: 'Off' }
|
|
17785
|
+
], onRenderer((renderer, value) => {
|
|
17786
|
+
renderer.variant.taa = value;
|
|
17787
|
+
}));
|
|
17788
|
+
// on is both grid levels
|
|
17789
|
+
this._cullButtons = segments(root.querySelector('[data-id="depth-cull"]'), [
|
|
17790
|
+
{ value: 'auto', label: 'Auto' },
|
|
17791
|
+
{ value: 'on', label: 'On' },
|
|
17792
|
+
{ value: 'off', label: 'Off' }
|
|
17793
|
+
], onRenderer((renderer, value) => {
|
|
17794
|
+
renderer.variant.cull = value === 'on' ? 'l2' : value;
|
|
17795
|
+
}));
|
|
17796
|
+
}
|
|
17317
17797
|
_wireEditable(span, kind) {
|
|
17318
17798
|
span.addEventListener('focus', () => {
|
|
17319
17799
|
this._editing = span;
|
|
@@ -17406,52 +17886,68 @@ class DebugPanel {
|
|
|
17406
17886
|
this._focusValue.textContent = fmt(this._focusTmp);
|
|
17407
17887
|
}
|
|
17408
17888
|
}
|
|
17409
|
-
// the
|
|
17889
|
+
// the mode in use, and the stochastic renderer's rows, which apply only while it draws
|
|
17890
|
+
_renderStochastic() {
|
|
17891
|
+
if (!this._stochasticSection)
|
|
17892
|
+
return;
|
|
17893
|
+
light(this._modeButtons, this._global.quality.debugMode);
|
|
17894
|
+
const drawing = !!this._splatRenderer;
|
|
17895
|
+
this._stochasticSection.classList.toggle('sse-debug-off', !drawing);
|
|
17896
|
+
for (const buttons of [this._taaButtons, this._cullButtons]) {
|
|
17897
|
+
buttons?.forEach((button) => {
|
|
17898
|
+
button.disabled = !drawing;
|
|
17899
|
+
});
|
|
17900
|
+
}
|
|
17901
|
+
if (!drawing) {
|
|
17902
|
+
light(this._taaButtons, null);
|
|
17903
|
+
light(this._cullButtons, null);
|
|
17904
|
+
}
|
|
17905
|
+
this._renderCull();
|
|
17906
|
+
}
|
|
17907
|
+
// the stochastic renderer's choices as they are
|
|
17410
17908
|
_renderCull() {
|
|
17411
17909
|
const renderer = this._splatRenderer;
|
|
17412
|
-
if (!renderer
|
|
17910
|
+
if (!renderer)
|
|
17413
17911
|
return;
|
|
17414
17912
|
const mode = renderer.variant.cull;
|
|
17415
|
-
this.
|
|
17416
|
-
this.
|
|
17417
|
-
|
|
17418
|
-
|
|
17419
|
-
|
|
17420
|
-
|
|
17421
|
-
if (this.
|
|
17422
|
-
this._coverageButton.textContent = `Coverage: ${renderer.variant.coverage}`;
|
|
17423
|
-
this._coverageButton.classList.toggle('sse-debug-on', renderer.variant.coverage !== 'pixel');
|
|
17424
|
-
}
|
|
17425
|
-
if (this._sharpenButton) {
|
|
17426
|
-
const k = renderer.variant.taaSharpen;
|
|
17427
|
-
this._sharpenButton.textContent = `Sharpen: ${k > 0 ? k : 'off'}`;
|
|
17428
|
-
this._sharpenButton.classList.toggle('sse-debug-on', k > 0);
|
|
17429
|
-
}
|
|
17430
|
-
if (mode === 'off') {
|
|
17431
|
-
this._culledValue.textContent = 'off';
|
|
17432
|
-
return;
|
|
17433
|
-
}
|
|
17434
|
-
if (!renderer.culling) {
|
|
17435
|
-
this._culledValue.textContent = renderer.cullSuspended ? 'suspended' : 'no previous frame';
|
|
17436
|
-
return;
|
|
17437
|
-
}
|
|
17438
|
-
if (this._cullStatsPending || this._cullStatsFrames++ % 15 !== 0)
|
|
17913
|
+
light(this._cullButtons, mode === 'l1' || mode === 'l2' ? 'on' : mode);
|
|
17914
|
+
light(this._taaButtons, renderer.variant.taa);
|
|
17915
|
+
}
|
|
17916
|
+
// The counts, every few frames: loaded and selected from the engine, on screen and rendered
|
|
17917
|
+
// back from the gpu, the stochastic renderer's projector or the engine's frustum cull
|
|
17918
|
+
_renderCounts() {
|
|
17919
|
+
if (!this._loadedValue || !this._selectedValue || this._countsPending || this._countsFrames++ % 15 !== 0)
|
|
17439
17920
|
return;
|
|
17440
|
-
|
|
17441
|
-
|
|
17442
|
-
|
|
17443
|
-
|
|
17444
|
-
|
|
17445
|
-
|
|
17446
|
-
|
|
17447
|
-
|
|
17448
|
-
|
|
17921
|
+
const { app, camera } = this._global;
|
|
17922
|
+
const gsplat = app.root.findComponent('gsplat');
|
|
17923
|
+
this._loadedValue.textContent = count(loadedSplats(gsplat?.resource));
|
|
17924
|
+
this._selectedValue.textContent = count(app.stats.frame.gsplats);
|
|
17925
|
+
const renderer = this._splatRenderer;
|
|
17926
|
+
const layer = app.scene.layers.getLayerByName('World');
|
|
17927
|
+
const read = renderer
|
|
17928
|
+
? renderer.readStats().then(({ survivors, occluded }) => ({
|
|
17929
|
+
onScreen: survivors + occluded,
|
|
17930
|
+
rendered: survivors,
|
|
17931
|
+
culled: renderer.culling ? occluded : null
|
|
17932
|
+
}))
|
|
17933
|
+
: camera.camera && layer
|
|
17934
|
+
? readEngineVisibleSplats(app, camera.camera, layer).then((visible) => visible === null ? null : { onScreen: visible, rendered: visible, culled: null })
|
|
17935
|
+
: Promise.resolve(null);
|
|
17936
|
+
this._countsPending = true;
|
|
17937
|
+
read.then((counts) => {
|
|
17938
|
+
if (!this._onScreenValue || !this._renderedValue)
|
|
17939
|
+
return;
|
|
17940
|
+
this._onScreenValue.textContent = count(counts?.onScreen ?? null);
|
|
17941
|
+
const share = counts && counts.culled !== null && counts.onScreen > 0
|
|
17942
|
+
? ` −${((100 * counts.culled) / counts.onScreen).toFixed(0)}%`
|
|
17943
|
+
: '';
|
|
17944
|
+
this._renderedValue.textContent = `${count(counts?.rendered ?? null)}${share}`;
|
|
17449
17945
|
})
|
|
17450
17946
|
.catch(() => {
|
|
17451
17947
|
// a destroyed buffer or lost device; the next refresh tries again
|
|
17452
17948
|
})
|
|
17453
17949
|
.finally(() => {
|
|
17454
|
-
this.
|
|
17950
|
+
this._countsPending = false;
|
|
17455
17951
|
});
|
|
17456
17952
|
}
|
|
17457
17953
|
// The clipboard api, else a selection copied with execCommand: the api is refused in a
|
|
@@ -17554,9 +18050,7 @@ class DebugPanel {
|
|
|
17554
18050
|
_renderMiniStats() {
|
|
17555
18051
|
if (!this._miniStats || !this._miniStatsButton)
|
|
17556
18052
|
return;
|
|
17557
|
-
|
|
17558
|
-
this._miniStatsButton.textContent = `MiniStats: ${shown ? 'on' : 'off'}`;
|
|
17559
|
-
this._miniStatsButton.classList.toggle('sse-debug-on', shown);
|
|
18053
|
+
this._miniStatsButton.classList.toggle('sse-debug-on', this._miniStats.shown());
|
|
17560
18054
|
}
|
|
17561
18055
|
_screenshot() {
|
|
17562
18056
|
const app = this._global.app;
|
|
@@ -20710,11 +21204,12 @@ class Viewer {
|
|
|
20710
21204
|
// announced on the first frame rather than here: createViewer resolves after this
|
|
20711
21205
|
// constructor, so a page can only subscribe once loading is under way
|
|
20712
21206
|
events.once('firstFrame', () => events.fire('splatRenderer:ready', this.splatRenderer));
|
|
20713
|
-
|
|
21207
|
+
// Performance Mode, or the debug controls' renderer and mode
|
|
21208
|
+
const stochasticChanged = ['performanceMode:changed', 'debugMode:changed'].map((name) => events.on(name, () => {
|
|
20714
21209
|
if (!this.destroyed)
|
|
20715
21210
|
this.syncSplatRenderer();
|
|
20716
|
-
});
|
|
20717
|
-
this.onDestroy(() => stochasticChanged.off());
|
|
21211
|
+
}));
|
|
21212
|
+
this.onDestroy(() => stochasticChanged.forEach((handle) => handle.off()));
|
|
20718
21213
|
// reconfigure camera when entering/exiting XR. The stochastic renderer draws the session
|
|
20719
21214
|
// too, one view per eye on WebGPU. Follows xrMode rather than app.xr.active, which still
|
|
20720
21215
|
// reports the session while its 'end' handlers run
|
|
@@ -21013,7 +21508,9 @@ class Viewer {
|
|
|
21013
21508
|
// collision may already have landed while the splats were still streaming
|
|
21014
21509
|
if (collisionReady)
|
|
21015
21510
|
attachCollision(collisionReady);
|
|
21016
|
-
|
|
21511
|
+
// the stochastic renderer if it draws now: switched off, it stays made but out
|
|
21512
|
+
const drawing = global.quality.stochastic ? this.splatRenderer : null;
|
|
21513
|
+
this.debugPanel = new DebugPanel(global, this.cameraManager, this.picker, drawing, {
|
|
21017
21514
|
shown: () => !!this.miniStats?.enabled,
|
|
21018
21515
|
show: (value) => this.setMiniStats(value)
|
|
21019
21516
|
});
|
|
@@ -21082,6 +21579,7 @@ class Viewer {
|
|
|
21082
21579
|
const perfHandles = [
|
|
21083
21580
|
events.on('quality:changed', applyPerfSettings),
|
|
21084
21581
|
events.on('performanceMode:changed', applyPerfSettings),
|
|
21582
|
+
events.on('debugMode:changed', applyPerfSettings),
|
|
21085
21583
|
events.on('xrMode:changed', applyPerfSettings)
|
|
21086
21584
|
];
|
|
21087
21585
|
this.onDestroy(() => perfHandles.forEach((handle) => handle.off()));
|
|
@@ -21105,7 +21603,7 @@ class Viewer {
|
|
|
21105
21603
|
}
|
|
21106
21604
|
// Makes the stochastic renderer the first time the quality module wants it, then switches it
|
|
21107
21605
|
// in and out in place: off, it hands the splats back to the engine's renderer. Announces the
|
|
21108
|
-
// change for the parts that hold the renderer (the
|
|
21606
|
+
// change for the parts that hold the renderer (the debug panel, the dev pages)
|
|
21109
21607
|
syncSplatRenderer() {
|
|
21110
21608
|
const { app, config, events, camera, quality } = this.global;
|
|
21111
21609
|
const wanted = quality.stochastic;
|
|
@@ -21125,6 +21623,9 @@ class Viewer {
|
|
|
21125
21623
|
});
|
|
21126
21624
|
}
|
|
21127
21625
|
}
|
|
21626
|
+
// in the mode wanted, which the debug controls change on a renderer already made
|
|
21627
|
+
if (wanted)
|
|
21628
|
+
this.splatRenderer?.setMode(quality.stochasticMode);
|
|
21128
21629
|
this.splatRenderer?.setEnabled(wanted);
|
|
21129
21630
|
events.fire('splatRenderer:changed', wanted ? this.splatRenderer : null);
|
|
21130
21631
|
}
|
|
@@ -21533,11 +22034,12 @@ const createApp = async (canvas, config) => {
|
|
|
21533
22034
|
touch: new TouchDevice$1(canvas),
|
|
21534
22035
|
keyboard: new Keyboard(window)
|
|
21535
22036
|
});
|
|
21536
|
-
// The
|
|
21537
|
-
//
|
|
21538
|
-
//
|
|
21539
|
-
//
|
|
21540
|
-
|
|
22037
|
+
// The per-splat centres the engine reads back for its cpu sort (12 bytes each, plus a gpu
|
|
22038
|
+
// readback per file) serve only that sort and non-unified rendering. On WebGPU the viewer
|
|
22039
|
+
// renders unified, and neither renderer sorts on the cpu (the engine's sorts on the gpu, the
|
|
22040
|
+
// stochastic renderer does not sort), so they are dead weight there. Read once per file at
|
|
22041
|
+
// load, so it has to be set before any asset loads; WebGL's cpu sort keeps them
|
|
22042
|
+
if (renderer === 'webgpu') {
|
|
21541
22043
|
app.scene.gsplatCentersEnabled = false;
|
|
21542
22044
|
}
|
|
21543
22045
|
// enable anonymous CORS for image loading in safari (must be set before any
|
|
@@ -21632,6 +22134,7 @@ const resolveConfig = (options) => ({
|
|
|
21632
22134
|
(isPrefetchable(options.contentUrl, options.contentFilename) ? fetch(options.contentUrl) : undefined),
|
|
21633
22135
|
renderer: options.renderer ?? 'webgpu',
|
|
21634
22136
|
ui: options.ui ?? true,
|
|
22137
|
+
experimentalTouchInsetBottom: resolveTouchInsetBottom(options.experimentalTouchInsetBottom),
|
|
21635
22138
|
reticle: options.reticle ?? false,
|
|
21636
22139
|
noanim: options.noanim ?? false,
|
|
21637
22140
|
nofx: options.nofx ?? false,
|
|
@@ -21665,6 +22168,8 @@ const createViewer = async (options) => {
|
|
|
21665
22168
|
else {
|
|
21666
22169
|
root.appendChild(document.createElement('canvas'));
|
|
21667
22170
|
}
|
|
22171
|
+
// the stylesheet lifts what sits on the bottom edge by this, on touch devices alone
|
|
22172
|
+
root.style.setProperty('--sse-experimental-touch-inset-bottom', `${config.experimentalTouchInsetBottom}px`);
|
|
21668
22173
|
container.appendChild(root);
|
|
21669
22174
|
const canvas = root.querySelector('canvas');
|
|
21670
22175
|
// create events
|