@playcanvas/supersplat-viewer 1.8.3 → 1.9.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 +3 -3
- package/package.json +7 -6
- package/public/index.css +9 -0
- package/public/index.html +4 -1
- package/public/index.js +132 -48
- package/public/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcanvas/supersplat-viewer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"author": "PlayCanvas <support@playcanvas.com>",
|
|
5
5
|
"homepage": "https://github.com/playcanvas/supersplat-viewer#readme",
|
|
6
6
|
"description": "Viewer for https://superspl.at",
|
|
@@ -39,22 +39,23 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@playcanvas/eslint-config": "2.1.0",
|
|
41
41
|
"@playcanvas/web-components": "0.2.11",
|
|
42
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
42
43
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
43
44
|
"@rollup/plugin-typescript": "12.3.0",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
45
|
-
"@typescript-eslint/parser": "8.
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "8.48.0",
|
|
46
|
+
"@typescript-eslint/parser": "8.48.0",
|
|
46
47
|
"autoprefixer": "10.4.22",
|
|
47
48
|
"concurrently": "9.2.1",
|
|
48
49
|
"eslint": "9.39.1",
|
|
49
50
|
"globals": "16.5.0",
|
|
50
|
-
"playcanvas": "2.13.
|
|
51
|
+
"playcanvas": "2.13.6",
|
|
51
52
|
"postcss": "8.5.6",
|
|
52
53
|
"publint": "0.3.15",
|
|
53
|
-
"rollup": "4.53.
|
|
54
|
+
"rollup": "4.53.3",
|
|
54
55
|
"rollup-plugin-copy": "3.5.0",
|
|
55
56
|
"rollup-plugin-scss": "4.0.1",
|
|
56
57
|
"rollup-plugin-string": "3.0.0",
|
|
57
|
-
"sass": "1.94.
|
|
58
|
+
"sass": "1.94.2",
|
|
58
59
|
"serve": "14.2.5",
|
|
59
60
|
"typescript": "5.9.3"
|
|
60
61
|
},
|
package/public/index.css
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--canvas-opacity: 1;
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
* {
|
|
2
6
|
margin: 0;
|
|
3
7
|
padding: 0;
|
|
@@ -13,6 +17,10 @@ body {
|
|
|
13
17
|
-webkit-touch-callout: none;
|
|
14
18
|
}
|
|
15
19
|
|
|
20
|
+
canvas {
|
|
21
|
+
opacity: var(--canvas-opacity);
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
button {
|
|
17
25
|
-webkit-appearance: none;
|
|
18
26
|
-moz-appearance: none;
|
|
@@ -48,6 +56,7 @@ button {
|
|
|
48
56
|
left: 0;
|
|
49
57
|
width: 100%;
|
|
50
58
|
height: 100%;
|
|
59
|
+
background-image: var(--poster-url);
|
|
51
60
|
background-size: cover;
|
|
52
61
|
background-position: center;
|
|
53
62
|
background-repeat: no-repeat;
|
package/public/index.html
CHANGED
|
@@ -311,9 +311,12 @@
|
|
|
311
311
|
// Show the poster image
|
|
312
312
|
if (poster) {
|
|
313
313
|
const element = document.getElementById('poster');
|
|
314
|
-
element.style.
|
|
314
|
+
element.style.setProperty('--poster-url', `url(${poster.src})`);
|
|
315
315
|
element.style.display = 'block';
|
|
316
316
|
element.style.filter = 'blur(40px)';
|
|
317
|
+
|
|
318
|
+
// hide the canvas
|
|
319
|
+
document.documentElement.style.setProperty('--canvas-opacity', '0');
|
|
317
320
|
}
|
|
318
321
|
|
|
319
322
|
document.addEventListener('DOMContentLoaded', async () => {
|
package/public/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const TRACEID_GPU_TIMINGS = 'GpuTimings';
|
|
2
2
|
|
|
3
|
-
const version = '2.13.
|
|
4
|
-
const revision = '
|
|
3
|
+
const version$1 = '2.13.6';
|
|
4
|
+
const revision = 'e43e870';
|
|
5
5
|
function extend(target, ex) {
|
|
6
6
|
for(const prop in ex){
|
|
7
7
|
const copy = ex[prop];
|
|
@@ -3608,13 +3608,18 @@ class BoundingBox {
|
|
|
3608
3608
|
return this._max.copy(this.center).add(this.halfExtents);
|
|
3609
3609
|
}
|
|
3610
3610
|
containsPoint(point) {
|
|
3611
|
-
const
|
|
3612
|
-
const
|
|
3613
|
-
if (point.x <
|
|
3611
|
+
const c = this.center;
|
|
3612
|
+
const h = this.halfExtents;
|
|
3613
|
+
if (point.x < c.x - h.x || point.x > c.x + h.x || point.y < c.y - h.y || point.y > c.y + h.y || point.z < c.z - h.z || point.z > c.z + h.z) {
|
|
3614
3614
|
return false;
|
|
3615
3615
|
}
|
|
3616
3616
|
return true;
|
|
3617
3617
|
}
|
|
3618
|
+
closestPoint(point, result = new Vec3()) {
|
|
3619
|
+
const c = this.center;
|
|
3620
|
+
const h = this.halfExtents;
|
|
3621
|
+
return result.set(Math.max(c.x - h.x, Math.min(point.x, c.x + h.x)), Math.max(c.y - h.y, Math.min(point.y, c.y + h.y)), Math.max(c.z - h.z, Math.min(point.z, c.z + h.z)));
|
|
3622
|
+
}
|
|
3618
3623
|
setFromTransformedAabb(aabb, m, ignoreScale = false) {
|
|
3619
3624
|
const ac = aabb.center;
|
|
3620
3625
|
const ar = aabb.halfExtents;
|
|
@@ -6499,7 +6504,7 @@ class GraphicsDevice extends EventHandler {
|
|
|
6499
6504
|
}, this._shadersDirty = false, this.capsDefines = new Map(), this.mapsToClear = new Set();
|
|
6500
6505
|
this.canvas = canvas;
|
|
6501
6506
|
if ('setAttribute' in canvas) {
|
|
6502
|
-
canvas.setAttribute('data-engine', `PlayCanvas ${version}`);
|
|
6507
|
+
canvas.setAttribute('data-engine', `PlayCanvas ${version$1}`);
|
|
6503
6508
|
}
|
|
6504
6509
|
this.initOptions = {
|
|
6505
6510
|
...options
|
|
@@ -11272,6 +11277,7 @@ class WebgpuUploadStream {
|
|
|
11272
11277
|
this.uploadStream = uploadStream;
|
|
11273
11278
|
this.useSingleBuffer = uploadStream.useSingleBuffer;
|
|
11274
11279
|
}
|
|
11280
|
+
_onDeviceLost() {}
|
|
11275
11281
|
destroy() {
|
|
11276
11282
|
this._destroyed = true;
|
|
11277
11283
|
this.availableStagingBuffers.forEach((buffer)=>buffer.destroy());
|
|
@@ -13114,6 +13120,10 @@ class WebglUploadStream {
|
|
|
13114
13120
|
gl.deleteBuffer(item.pbo);
|
|
13115
13121
|
});
|
|
13116
13122
|
}
|
|
13123
|
+
_onDeviceLost() {
|
|
13124
|
+
this.availablePBOs.length = 0;
|
|
13125
|
+
this.pendingPBOs.length = 0;
|
|
13126
|
+
}
|
|
13117
13127
|
update(minByteSize) {
|
|
13118
13128
|
const gl = this.uploadStream.device.gl;
|
|
13119
13129
|
const pending = this.pendingPBOs;
|
|
@@ -13168,10 +13178,12 @@ class WebglUploadStream {
|
|
|
13168
13178
|
gl.bufferSubData(gl.PIXEL_UNPACK_BUFFER, 0, new Uint8Array(data.buffer, data.byteOffset, byteSize));
|
|
13169
13179
|
gl.bindBuffer(gl.PIXEL_UNPACK_BUFFER, null);
|
|
13170
13180
|
device.setTexture(target, 0);
|
|
13181
|
+
device.activeTexture(0);
|
|
13182
|
+
device.bindTexture(target);
|
|
13171
13183
|
gl.bindBuffer(gl.PIXEL_UNPACK_BUFFER, pboInfo.pbo);
|
|
13172
13184
|
device.setUnpackFlipY(false);
|
|
13173
13185
|
device.setUnpackPremultiplyAlpha(false);
|
|
13174
|
-
gl.pixelStorei(gl.UNPACK_ALIGNMENT,
|
|
13186
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, data.BYTES_PER_ELEMENT);
|
|
13175
13187
|
gl.pixelStorei(gl.UNPACK_ROW_LENGTH, 0);
|
|
13176
13188
|
gl.pixelStorei(gl.UNPACK_SKIP_ROWS, 0);
|
|
13177
13189
|
gl.pixelStorei(gl.UNPACK_SKIP_PIXELS, 0);
|
|
@@ -33608,7 +33620,7 @@ class ProgramLibrary {
|
|
|
33608
33620
|
}
|
|
33609
33621
|
text += '\n];\n';
|
|
33610
33622
|
text += 'pc.getProgramLibrary(device).precompile(shaders);\n';
|
|
33611
|
-
text += `if (pc.version != \"${version}\" || pc.revision != \"${revision}\")\n`;
|
|
33623
|
+
text += `if (pc.version != \"${version$1}\" || pc.revision != \"${revision}\")\n`;
|
|
33612
33624
|
text += '\tconsole.warn(\"precompile-shaders.js: engine version mismatch, rebuild shaders lib with current engine\");';
|
|
33613
33625
|
const element = document.createElement('a');
|
|
33614
33626
|
element.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`);
|
|
@@ -33976,17 +33988,24 @@ class GSplatData {
|
|
|
33976
33988
|
|
|
33977
33989
|
class UploadStream {
|
|
33978
33990
|
constructor(device, useSingleBuffer = false){
|
|
33991
|
+
this._deviceLostEvent = null;
|
|
33979
33992
|
this.device = device;
|
|
33980
33993
|
this.useSingleBuffer = useSingleBuffer;
|
|
33981
33994
|
this.impl = device.createUploadStreamImpl(this);
|
|
33982
|
-
|
|
33983
|
-
upload(data, target, offset = 0, size = data.length) {
|
|
33984
|
-
this.impl?.upload(data, target, offset, size);
|
|
33995
|
+
this._deviceLostEvent = this.device.on('devicelost', this._onDeviceLost, this);
|
|
33985
33996
|
}
|
|
33986
33997
|
destroy() {
|
|
33998
|
+
this._deviceLostEvent?.off();
|
|
33999
|
+
this._deviceLostEvent = null;
|
|
33987
34000
|
this.impl?.destroy();
|
|
33988
34001
|
this.impl = null;
|
|
33989
34002
|
}
|
|
34003
|
+
upload(data, target, offset = 0, size = data.length) {
|
|
34004
|
+
this.impl?.upload(data, target, offset, size);
|
|
34005
|
+
}
|
|
34006
|
+
_onDeviceLost() {
|
|
34007
|
+
this.impl?._onDeviceLost?.();
|
|
34008
|
+
}
|
|
33990
34009
|
}
|
|
33991
34010
|
|
|
33992
34011
|
var glslGsplatCopyToWorkBufferPS = `
|
|
@@ -76208,8 +76227,12 @@ new BoundingBox();
|
|
|
76208
76227
|
new Color(1, 0, 1)
|
|
76209
76228
|
];
|
|
76210
76229
|
class GSplatOctreeInstance {
|
|
76211
|
-
get
|
|
76212
|
-
|
|
76230
|
+
get pendingLoadCount() {
|
|
76231
|
+
let count = this.pending.size + this.prefetchPending.size;
|
|
76232
|
+
if (this.octree.environmentUrl && !this.environmentPlacement) {
|
|
76233
|
+
count++;
|
|
76234
|
+
}
|
|
76235
|
+
return count;
|
|
76213
76236
|
}
|
|
76214
76237
|
constructor(octree, placement, assetLoader){
|
|
76215
76238
|
this.activePlacements = new Set();
|
|
@@ -76255,7 +76278,8 @@ class GSplatOctreeInstance {
|
|
|
76255
76278
|
}
|
|
76256
76279
|
calculateNodeLod(localCameraPosition, localCameraForward, nodeIndex, maxLod, lodDistances, lodBehindPenalty) {
|
|
76257
76280
|
const node = this.octree.nodes[nodeIndex];
|
|
76258
|
-
|
|
76281
|
+
node.bounds.closestPoint(localCameraPosition, _dirToNode);
|
|
76282
|
+
_dirToNode.sub(localCameraPosition);
|
|
76259
76283
|
let distance = _dirToNode.length();
|
|
76260
76284
|
if (lodBehindPenalty > 1 && distance > 0.01) {
|
|
76261
76285
|
const dotOverDistance = localCameraForward.dot(_dirToNode) / distance;
|
|
@@ -77072,16 +77096,15 @@ class GSplatManager {
|
|
|
77072
77096
|
}
|
|
77073
77097
|
fireFrameReadyEvent() {
|
|
77074
77098
|
const ready = this.sortedVersion === this.lastWorldStateVersion;
|
|
77075
|
-
let
|
|
77076
|
-
|
|
77077
|
-
|
|
77078
|
-
loading ||= inst.hasPendingLoads;
|
|
77079
|
-
}
|
|
77099
|
+
let loadingCount = 0;
|
|
77100
|
+
for (const [, inst] of this.octreeInstances){
|
|
77101
|
+
loadingCount += inst.pendingLoadCount;
|
|
77080
77102
|
}
|
|
77081
|
-
this.director.eventHandler.fire('frame:ready', this.cameraNode.camera, this.renderer.layer, ready,
|
|
77103
|
+
this.director.eventHandler.fire('frame:ready', this.cameraNode.camera, this.renderer.layer, ready, loadingCount);
|
|
77082
77104
|
}
|
|
77083
77105
|
update() {
|
|
77084
77106
|
this.sorter.applyPendingSorted();
|
|
77107
|
+
this.renderer.updateViewport(this.cameraNode);
|
|
77085
77108
|
let fullUpdate = false;
|
|
77086
77109
|
this.framesTillFullUpdate--;
|
|
77087
77110
|
if (this.framesTillFullUpdate <= 0) {
|
|
@@ -77221,7 +77244,6 @@ class GSplatManager {
|
|
|
77221
77244
|
});
|
|
77222
77245
|
});
|
|
77223
77246
|
this.sorter.setSortParams(sorterRequest, this.scene.gsplat.radialSorting);
|
|
77224
|
-
this.renderer.updateViewport(cameraNode);
|
|
77225
77247
|
}
|
|
77226
77248
|
prepareSortParameters(worldState) {
|
|
77227
77249
|
return {
|
|
@@ -77680,9 +77702,6 @@ class GSplatAssetLoaderBase {
|
|
|
77680
77702
|
load(url) {}
|
|
77681
77703
|
unload(url) {}
|
|
77682
77704
|
getResource(url) {}
|
|
77683
|
-
get isLoading() {
|
|
77684
|
-
return false;
|
|
77685
|
-
}
|
|
77686
77705
|
constructor(){
|
|
77687
77706
|
this.cooldownTicks = 100;
|
|
77688
77707
|
}
|
|
@@ -77693,9 +77712,6 @@ class GSplatAssetLoader extends GSplatAssetLoaderBase {
|
|
|
77693
77712
|
super(), this._urlToAsset = new Map(), this.maxConcurrentLoads = 2, this.maxRetries = 2, this._currentlyLoading = new Set(), this._loadQueue = [], this._retryCount = new Map();
|
|
77694
77713
|
this._registry = registry;
|
|
77695
77714
|
}
|
|
77696
|
-
get isLoading() {
|
|
77697
|
-
return this._currentlyLoading.size > 0 || this._loadQueue.length > 0;
|
|
77698
|
-
}
|
|
77699
77715
|
load(url) {
|
|
77700
77716
|
const asset = this._urlToAsset.get(url);
|
|
77701
77717
|
if (asset?.loaded || this._currentlyLoading.has(url)) {
|
|
@@ -99771,14 +99787,15 @@ class Tooltip {
|
|
|
99771
99787
|
const v = new Vec3();
|
|
99772
99788
|
// update the poster image to start blurry and then resolve to sharp during loading
|
|
99773
99789
|
const initPoster = (events) => {
|
|
99774
|
-
const
|
|
99775
|
-
const blur = (progress) => `blur(${Math.floor((100 - progress) * 0.4)}px)`;
|
|
99776
|
-
events.on('progress:changed', (progress) => {
|
|
99777
|
-
element.style.filter = blur(progress);
|
|
99778
|
-
});
|
|
99790
|
+
const poster = document.getElementById('poster');
|
|
99779
99791
|
events.on('firstFrame', () => {
|
|
99780
|
-
|
|
99792
|
+
poster.style.display = 'none';
|
|
99793
|
+
document.documentElement.style.setProperty('--canvas-opacity', '1');
|
|
99781
99794
|
});
|
|
99795
|
+
const blur = (progress) => {
|
|
99796
|
+
poster.style.filter = `blur(${Math.floor((100 - progress) * 0.4)}px)`;
|
|
99797
|
+
};
|
|
99798
|
+
events.on('progress:changed', blur);
|
|
99782
99799
|
};
|
|
99783
99800
|
const initUI = (global) => {
|
|
99784
99801
|
const { config, events, state } = global;
|
|
@@ -101187,8 +101204,16 @@ class Picker {
|
|
|
101187
101204
|
}
|
|
101188
101205
|
}
|
|
101189
101206
|
|
|
101207
|
+
/* Vec initialisation to avoid recurrent memory allocation */
|
|
101190
101208
|
const tmpV1 = new Vec3();
|
|
101191
101209
|
const tmpV2 = new Vec3();
|
|
101210
|
+
const mouseRotate = new Vec3();
|
|
101211
|
+
const flyMove = new Vec3();
|
|
101212
|
+
const pinchMove = new Vec3();
|
|
101213
|
+
const orbitRotate = new Vec3();
|
|
101214
|
+
const flyRotate = new Vec3();
|
|
101215
|
+
const stickMove = new Vec3();
|
|
101216
|
+
const stickRotate = new Vec3();
|
|
101192
101217
|
/**
|
|
101193
101218
|
* Converts screen space mouse deltas to world space pan vector.
|
|
101194
101219
|
*
|
|
@@ -101374,33 +101399,33 @@ class InputController {
|
|
|
101374
101399
|
deltas.move.append([v.x, v.y, orbit ? -v.z : v.z]);
|
|
101375
101400
|
// desktop rotate
|
|
101376
101401
|
v.set(0, 0, 0);
|
|
101377
|
-
|
|
101402
|
+
mouseRotate.set(mouse[0], mouse[1], 0);
|
|
101378
101403
|
v.add(mouseRotate.mulScalar((1 - pan) * this.orbitSpeed * orbitFactor * dt));
|
|
101379
101404
|
deltas.rotate.append([v.x, v.y, v.z]);
|
|
101380
101405
|
// mobile move
|
|
101381
101406
|
v.set(0, 0, 0);
|
|
101382
101407
|
const orbitMove = screenToWorld(camera, touch[0], touch[1], distance);
|
|
101383
101408
|
v.add(orbitMove.mulScalar(orbit * pan));
|
|
101384
|
-
|
|
101409
|
+
flyMove.set(leftInput[0], 0, -leftInput[1]);
|
|
101385
101410
|
v.add(flyMove.mulScalar(fly * this.moveSpeed * dt));
|
|
101386
|
-
|
|
101411
|
+
pinchMove.set(0, 0, pinch[0]);
|
|
101387
101412
|
v.add(pinchMove.mulScalar(orbit * double * this.pinchSpeed * dt));
|
|
101388
101413
|
deltas.move.append([v.x, v.y, v.z]);
|
|
101389
101414
|
// mobile rotate
|
|
101390
101415
|
v.set(0, 0, 0);
|
|
101391
|
-
|
|
101416
|
+
orbitRotate.set(touch[0], touch[1], 0);
|
|
101392
101417
|
v.add(orbitRotate.mulScalar(orbit * (1 - pan) * this.orbitSpeed * dt));
|
|
101393
|
-
|
|
101418
|
+
flyRotate.set(rightInput[0], rightInput[1], 0);
|
|
101394
101419
|
v.add(flyRotate.mulScalar(fly * this.orbitSpeed * orbitFactor * dt));
|
|
101395
101420
|
deltas.rotate.append([v.x, v.y, v.z]);
|
|
101396
101421
|
// gamepad move
|
|
101397
101422
|
v.set(0, 0, 0);
|
|
101398
|
-
|
|
101423
|
+
stickMove.set(leftStick[0], 0, -leftStick[1]);
|
|
101399
101424
|
v.add(stickMove.mulScalar(this.moveSpeed * dt));
|
|
101400
101425
|
deltas.move.append([v.x, v.y, v.z]);
|
|
101401
101426
|
// gamepad rotate
|
|
101402
101427
|
v.set(0, 0, 0);
|
|
101403
|
-
|
|
101428
|
+
stickRotate.set(rightStick[0], rightStick[1], 0);
|
|
101404
101429
|
v.add(stickRotate.mulScalar(this.orbitSpeed * orbitFactor * dt));
|
|
101405
101430
|
deltas.rotate.append([v.x, v.y, v.z]);
|
|
101406
101431
|
// update touch joystick UI
|
|
@@ -101502,6 +101527,7 @@ class Viewer {
|
|
|
101502
101527
|
inputController;
|
|
101503
101528
|
cameraManager;
|
|
101504
101529
|
annotations;
|
|
101530
|
+
forceRenderNextFrame = false;
|
|
101505
101531
|
constructor(global, gsplatLoad, skyboxLoad) {
|
|
101506
101532
|
this.global = global;
|
|
101507
101533
|
const { app, settings, config, events, state, camera } = global;
|
|
@@ -101538,7 +101564,7 @@ class Viewer {
|
|
|
101538
101564
|
};
|
|
101539
101565
|
events.on('hqMode:changed', updateHqMode);
|
|
101540
101566
|
updateHqMode();
|
|
101541
|
-
//
|
|
101567
|
+
// construct debug ministats
|
|
101542
101568
|
if (config.ministats) {
|
|
101543
101569
|
const options = MiniStats.getDefaultOptions();
|
|
101544
101570
|
options.cpu.enabled = false;
|
|
@@ -101550,6 +101576,13 @@ class Viewer {
|
|
|
101550
101576
|
multiplier: 1 / (1024 * 1024),
|
|
101551
101577
|
unitsName: 'MB',
|
|
101552
101578
|
watermark: 1024
|
|
101579
|
+
}, {
|
|
101580
|
+
name: 'Splats',
|
|
101581
|
+
stats: ['frame.gsplats'],
|
|
101582
|
+
decimalPlaces: 3,
|
|
101583
|
+
multiplier: 1 / 1000000,
|
|
101584
|
+
unitsName: 'M',
|
|
101585
|
+
watermark: 5
|
|
101553
101586
|
});
|
|
101554
101587
|
// eslint-disable-next-line no-new
|
|
101555
101588
|
new MiniStats(app, options);
|
|
@@ -101572,6 +101605,9 @@ class Viewer {
|
|
|
101572
101605
|
if (!state.readyToRender) {
|
|
101573
101606
|
app.renderNextFrame = false;
|
|
101574
101607
|
}
|
|
101608
|
+
if (this.forceRenderNextFrame) {
|
|
101609
|
+
app.renderNextFrame = true;
|
|
101610
|
+
}
|
|
101575
101611
|
if (app.renderNextFrame) {
|
|
101576
101612
|
prevWorld.copy(world);
|
|
101577
101613
|
prevProj.copy(proj);
|
|
@@ -101607,6 +101643,10 @@ class Viewer {
|
|
|
101607
101643
|
applyCamera(this.cameraManager.camera);
|
|
101608
101644
|
}
|
|
101609
101645
|
});
|
|
101646
|
+
// unpause the animation on first frame
|
|
101647
|
+
events.on('firstFrame', () => {
|
|
101648
|
+
state.animationPaused = !!config.noanim;
|
|
101649
|
+
});
|
|
101610
101650
|
// wait for the model to load
|
|
101611
101651
|
Promise.all([gsplatLoad, skyboxLoad]).then((results) => {
|
|
101612
101652
|
const gsplat = results[0].gsplat;
|
|
@@ -101615,7 +101655,9 @@ class Viewer {
|
|
|
101615
101655
|
if (gsplatBbox) {
|
|
101616
101656
|
sceneBound.setFromTransformedAabb(gsplatBbox, results[0].getWorldTransform());
|
|
101617
101657
|
}
|
|
101618
|
-
|
|
101658
|
+
if (!config.noui) {
|
|
101659
|
+
this.annotations = new Annotations(global, this.cameraFrame != null);
|
|
101660
|
+
}
|
|
101619
101661
|
this.inputController = new InputController(global);
|
|
101620
101662
|
this.cameraManager = new CameraManager(global, sceneBound);
|
|
101621
101663
|
applyCamera(this.cameraManager.camera);
|
|
@@ -101640,11 +101682,50 @@ class Viewer {
|
|
|
101640
101682
|
});
|
|
101641
101683
|
}
|
|
101642
101684
|
else {
|
|
101643
|
-
|
|
101644
|
-
//
|
|
101645
|
-
|
|
101646
|
-
|
|
101647
|
-
|
|
101685
|
+
const { gsplat } = app.scene;
|
|
101686
|
+
// lod ranges
|
|
101687
|
+
const low = [2, 5];
|
|
101688
|
+
const high = [0, 2];
|
|
101689
|
+
// in unified mode, for now we hard-code LOD range on mobile vs desktop
|
|
101690
|
+
gsplat.lodRangeMin = low[0];
|
|
101691
|
+
gsplat.lodRangeMax = low[1];
|
|
101692
|
+
// these two allow LOD behind camera to drop, saves lots of splats
|
|
101693
|
+
gsplat.lodUpdateAngle = 90;
|
|
101694
|
+
gsplat.lodBehindPenalty = 5;
|
|
101695
|
+
// same performance, but rotating on slow devices does not give us unsorted splats on sides
|
|
101696
|
+
gsplat.radialSorting = true;
|
|
101697
|
+
const eventHandler = app.systems.gsplat;
|
|
101698
|
+
// force render empty frames otherwise unified rendering doesn't update
|
|
101699
|
+
this.forceRenderNextFrame = true;
|
|
101700
|
+
let current = 0;
|
|
101701
|
+
let watermark = 1;
|
|
101702
|
+
const readyHandler = (camera, layer, ready, loading) => {
|
|
101703
|
+
if (ready && !loading) {
|
|
101704
|
+
// scene is done loading
|
|
101705
|
+
eventHandler.off('frame:ready', readyHandler);
|
|
101706
|
+
this.forceRenderNextFrame = false;
|
|
101707
|
+
state.readyToRender = true;
|
|
101708
|
+
const range = platform.mobile ? low : high;
|
|
101709
|
+
gsplat.lodRangeMin = range[0];
|
|
101710
|
+
gsplat.lodRangeMax = range[1];
|
|
101711
|
+
// wait for the first valid frame to complete rendering
|
|
101712
|
+
app.once('frameend', () => {
|
|
101713
|
+
events.fire('firstFrame');
|
|
101714
|
+
// emit first frame event on window
|
|
101715
|
+
window.firstFrame?.();
|
|
101716
|
+
});
|
|
101717
|
+
}
|
|
101718
|
+
if (ready) {
|
|
101719
|
+
app.renderNextFrame = true;
|
|
101720
|
+
}
|
|
101721
|
+
// update loading status
|
|
101722
|
+
if (loading !== current) {
|
|
101723
|
+
watermark = Math.max(watermark, loading);
|
|
101724
|
+
current = watermark - loading;
|
|
101725
|
+
state.progress = Math.trunc(current / watermark * 100);
|
|
101726
|
+
}
|
|
101727
|
+
};
|
|
101728
|
+
eventHandler.on('frame:ready', readyHandler);
|
|
101648
101729
|
}
|
|
101649
101730
|
});
|
|
101650
101731
|
}
|
|
@@ -102258,6 +102339,8 @@ const initXr = (global) => {
|
|
|
102258
102339
|
});
|
|
102259
102340
|
};
|
|
102260
102341
|
|
|
102342
|
+
var version = "1.9.0";
|
|
102343
|
+
|
|
102261
102344
|
const loadGsplat = async (app, config, progressCallback) => {
|
|
102262
102345
|
const { contents, contentUrl, unified, aa } = config;
|
|
102263
102346
|
const c = contents;
|
|
@@ -102327,7 +102410,7 @@ const main = (app, camera, settingsJson, config) => {
|
|
|
102327
102410
|
hasAnimation: false,
|
|
102328
102411
|
animationDuration: 0,
|
|
102329
102412
|
animationTime: 0,
|
|
102330
|
-
animationPaused:
|
|
102413
|
+
animationPaused: true,
|
|
102331
102414
|
hasAR: false,
|
|
102332
102415
|
hasVR: false,
|
|
102333
102416
|
isFullscreen: false,
|
|
@@ -102375,6 +102458,7 @@ const main = (app, camera, settingsJson, config) => {
|
|
|
102375
102458
|
// Create the viewer
|
|
102376
102459
|
return new Viewer(global, gsplatLoad, skyboxLoad);
|
|
102377
102460
|
};
|
|
102461
|
+
console.log(`SuperSplat Viewer v${version} | Engine v${version$1} (${revision})`);
|
|
102378
102462
|
|
|
102379
102463
|
export { main };
|
|
102380
102464
|
//# sourceMappingURL=index.js.map
|