@playcanvas/supersplat-viewer 1.27.0 → 1.28.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/README.md +3 -1
- package/dist/index.js +2 -2
- package/package.json +4 -4
- package/public/index.html +5 -0
- package/public/index.js +159 -50
- 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.28.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",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"@rollup/plugin-json": "6.1.0",
|
|
46
46
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
47
47
|
"@rollup/plugin-typescript": "12.3.0",
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
49
|
-
"@typescript-eslint/parser": "8.
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "8.63.0",
|
|
49
|
+
"@typescript-eslint/parser": "8.63.0",
|
|
50
50
|
"autoprefixer": "10.5.2",
|
|
51
51
|
"concurrently": "9.2.3",
|
|
52
52
|
"eslint": "9.39.4",
|
|
53
53
|
"globals": "17.7.0",
|
|
54
|
-
"playcanvas": "2.20.
|
|
54
|
+
"playcanvas": "2.20.6",
|
|
55
55
|
"postcss": "8.5.16",
|
|
56
56
|
"publint": "0.3.21",
|
|
57
57
|
"rollup": "4.62.2",
|
package/public/index.html
CHANGED
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
heatmap: url.searchParams.has('heatmap'),
|
|
45
45
|
fullload: url.searchParams.has('fullload'),
|
|
46
46
|
debug: url.searchParams.has('debug'),
|
|
47
|
+
lang: url.searchParams.get('lang'),
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
window.sse = {
|
|
@@ -203,6 +204,10 @@
|
|
|
203
204
|
<div id="gamingControlsOption" data-i18n="settings.gaming-controls">Gaming Controls</div>
|
|
204
205
|
<div id="gamingControlsCheck" class="toggleSwitch"><div class="toggleTrack"><div class="toggleThumb"></div></div></div>
|
|
205
206
|
</div>
|
|
207
|
+
<div id="annotationsRow" class="settingsRow">
|
|
208
|
+
<div id="annotationsOption" data-i18n="settings.show-annotations">Show Annotations</div>
|
|
209
|
+
<div id="annotationsCheck" class="toggleSwitch active"><div class="toggleTrack"><div class="toggleThumb"></div></div></div>
|
|
210
|
+
</div>
|
|
206
211
|
<div class="divider"></div>
|
|
207
212
|
<div class="settingsRow">
|
|
208
213
|
<button id="frame" data-i18n="settings.frame">Frame</button>
|
package/public/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const TRACEID_GPU_TIMINGS = "GpuTimings";
|
|
2
2
|
|
|
3
|
-
const version$1 = "2.20.
|
|
4
|
-
const revision = "
|
|
3
|
+
const version$1 = "2.20.6";
|
|
4
|
+
const revision = "9a2a8ef";
|
|
5
5
|
function extend(target, ex) {
|
|
6
6
|
for (const prop in ex) {
|
|
7
7
|
const copy = ex[prop];
|
|
@@ -6209,13 +6209,13 @@ class GraphicsDevice extends EventHandler {
|
|
|
6209
6209
|
this.updateClientRect();
|
|
6210
6210
|
}
|
|
6211
6211
|
updateClientRect() {
|
|
6212
|
-
if (
|
|
6213
|
-
this.clientRect.width = this.canvas.width;
|
|
6214
|
-
this.clientRect.height = this.canvas.height;
|
|
6215
|
-
} else {
|
|
6212
|
+
if (typeof this.canvas.getBoundingClientRect === "function") {
|
|
6216
6213
|
const rect = this.canvas.getBoundingClientRect();
|
|
6217
6214
|
this.clientRect.width = rect.width;
|
|
6218
6215
|
this.clientRect.height = rect.height;
|
|
6216
|
+
} else {
|
|
6217
|
+
this.clientRect.width = this.canvas.width ?? 0;
|
|
6218
|
+
this.clientRect.height = this.canvas.height ?? 0;
|
|
6219
6219
|
}
|
|
6220
6220
|
}
|
|
6221
6221
|
get width() {
|
|
@@ -18406,8 +18406,8 @@ class Mesh extends RefCountedObject {
|
|
|
18406
18406
|
this._geometryData.recreate = true;
|
|
18407
18407
|
this._geometryData.maxVertices = maxVertices;
|
|
18408
18408
|
this._geometryData.maxIndices = maxIndices;
|
|
18409
|
-
this._geometryData.verticesUsage = verticesDynamic ?
|
|
18410
|
-
this._geometryData.indicesUsage = indicesDynamic ?
|
|
18409
|
+
this._geometryData.verticesUsage = verticesDynamic ? BUFFER_DYNAMIC : BUFFER_STATIC;
|
|
18410
|
+
this._geometryData.indicesUsage = indicesDynamic ? BUFFER_DYNAMIC : BUFFER_STATIC;
|
|
18411
18411
|
}
|
|
18412
18412
|
setVertexStream(semantic, data, componentCount, numVertices, dataType = TYPE_FLOAT32, dataTypeNormalize = false, asInt = false) {
|
|
18413
18413
|
this._initGeometryData();
|
|
@@ -57972,6 +57972,9 @@ class GSplatOctree {
|
|
|
57972
57972
|
}
|
|
57973
57973
|
}
|
|
57974
57974
|
ensureFileResource(fileIndex) {
|
|
57975
|
+
if (!this.assetLoader) {
|
|
57976
|
+
return;
|
|
57977
|
+
}
|
|
57975
57978
|
if (this.fileResources.has(fileIndex)) {
|
|
57976
57979
|
return;
|
|
57977
57980
|
}
|
|
@@ -58569,6 +58572,14 @@ class GSplatWorld {
|
|
|
58569
58572
|
result.newVersion = false;
|
|
58570
58573
|
result.overdrawDirty = false;
|
|
58571
58574
|
result.sortNeeded = false;
|
|
58575
|
+
for (const [placement, inst] of this._octreeInstances) {
|
|
58576
|
+
if (inst.octree.destroyed || !placement.resource) {
|
|
58577
|
+
this._octreeInstances.delete(placement);
|
|
58578
|
+
this._layerPlacementsDirty = true;
|
|
58579
|
+
this._placementSetChanged = true;
|
|
58580
|
+
this._octreeInstancesToDestroy.push(inst);
|
|
58581
|
+
}
|
|
58582
|
+
}
|
|
58572
58583
|
if (--this._framesTillFullUpdate <= 0) {
|
|
58573
58584
|
this._framesTillFullUpdate = 10;
|
|
58574
58585
|
this._lodUpdateRequested = true;
|
|
@@ -61100,6 +61111,9 @@ class GSplatHybridRenderer extends GSplatRenderer {
|
|
|
61100
61111
|
ic.sortElementCountBuffer,
|
|
61101
61112
|
sortIndirectInfo
|
|
61102
61113
|
);
|
|
61114
|
+
if (pickMode) {
|
|
61115
|
+
this.device.submit();
|
|
61116
|
+
}
|
|
61103
61117
|
return gpuSorter.sortIndirect(
|
|
61104
61118
|
projector.sortKeys,
|
|
61105
61119
|
elementCount,
|
|
@@ -68929,11 +68943,16 @@ class SogParser {
|
|
|
68929
68943
|
});
|
|
68930
68944
|
const textureAssets = subs.map((sub) => textures[sub]).flat();
|
|
68931
68945
|
let unloaded = false;
|
|
68946
|
+
let ownedByResource = false;
|
|
68932
68947
|
asset.once("unload", () => {
|
|
68933
68948
|
unloaded = true;
|
|
68934
68949
|
textureAssets.forEach((t) => {
|
|
68935
68950
|
assets.remove(t);
|
|
68936
|
-
|
|
68951
|
+
if (!ownedByResource) {
|
|
68952
|
+
t.unload();
|
|
68953
|
+
} else {
|
|
68954
|
+
assets._loader.clearCache(t.getFileUrl(), t.type);
|
|
68955
|
+
}
|
|
68937
68956
|
});
|
|
68938
68957
|
});
|
|
68939
68958
|
combineProgress(asset, textureAssets);
|
|
@@ -68978,6 +68997,7 @@ class SogParser {
|
|
|
68978
68997
|
}
|
|
68979
68998
|
const prepareCenters = gsplatCentersEnabledAtLoad;
|
|
68980
68999
|
const resource = decompress ? new GSplatResource(this.app.graphicsDevice, await data.decompress(), { prepareCenters }) : new GSplatSogResource(this.app.graphicsDevice, data, { prepareCenters });
|
|
69000
|
+
ownedByResource = !decompress;
|
|
68981
69001
|
if (this._shouldAbort(asset, unloaded)) {
|
|
68982
69002
|
resource.destroy();
|
|
68983
69003
|
callback(null, null);
|
|
@@ -69124,10 +69144,34 @@ class SogBundleParser {
|
|
|
69124
69144
|
this.app = app;
|
|
69125
69145
|
this.maxRetries = maxRetries;
|
|
69126
69146
|
}
|
|
69147
|
+
_shouldAbort(asset, unloaded) {
|
|
69148
|
+
if (unloaded || !this.app.assets.get(asset.id)) return true;
|
|
69149
|
+
if (!this.app?.graphicsDevice || this.app.graphicsDevice._destroyed) return true;
|
|
69150
|
+
return false;
|
|
69151
|
+
}
|
|
69127
69152
|
async load(url, callback, asset) {
|
|
69128
69153
|
const gsplatCentersEnabledAtLoad = this.app.scene?.gsplatCentersEnabled !== false;
|
|
69129
69154
|
try {
|
|
69155
|
+
const { assets } = this.app;
|
|
69156
|
+
let unloaded = false;
|
|
69157
|
+
let ownedByResource = false;
|
|
69158
|
+
const textures = {};
|
|
69159
|
+
asset.once("unload", () => {
|
|
69160
|
+
unloaded = true;
|
|
69161
|
+
Object.values(textures).forEach((t) => {
|
|
69162
|
+
assets.remove(t);
|
|
69163
|
+
if (!ownedByResource) {
|
|
69164
|
+
t.unload();
|
|
69165
|
+
} else {
|
|
69166
|
+
assets._loader.clearCache(t.getFileUrl(), t.type);
|
|
69167
|
+
}
|
|
69168
|
+
});
|
|
69169
|
+
});
|
|
69130
69170
|
const arrayBuffer = await downloadArrayBuffer(url, asset);
|
|
69171
|
+
if (this._shouldAbort(asset, unloaded)) {
|
|
69172
|
+
callback(null, null);
|
|
69173
|
+
return;
|
|
69174
|
+
}
|
|
69131
69175
|
const files = parseZipArchive(arrayBuffer);
|
|
69132
69176
|
for (const file of files) {
|
|
69133
69177
|
if (file.compression === "deflate") {
|
|
@@ -69147,7 +69191,6 @@ class SogBundleParser {
|
|
|
69147
69191
|
return;
|
|
69148
69192
|
}
|
|
69149
69193
|
const filenames = ["means", "scales", "quats", "sh0", "shN"].map((key) => meta[key]?.files ?? []).flat();
|
|
69150
|
-
const textures = {};
|
|
69151
69194
|
const promises = [];
|
|
69152
69195
|
for (const filename of filenames) {
|
|
69153
69196
|
const file = files.find((f) => f.filename === filename);
|
|
@@ -69183,17 +69226,18 @@ class SogBundleParser {
|
|
|
69183
69226
|
}
|
|
69184
69227
|
Object.values(textures).forEach((t) => this.app.assets.load(t));
|
|
69185
69228
|
await Promise.allSettled(promises);
|
|
69186
|
-
|
|
69187
|
-
if (t.file) {
|
|
69188
|
-
t.file.contents = null;
|
|
69189
|
-
}
|
|
69190
|
-
});
|
|
69191
|
-
const { assets } = this.app;
|
|
69192
|
-
asset.once("unload", () => {
|
|
69229
|
+
if (this._shouldAbort(asset, unloaded)) {
|
|
69193
69230
|
Object.values(textures).forEach((t) => {
|
|
69194
69231
|
assets.remove(t);
|
|
69195
69232
|
t.unload();
|
|
69196
69233
|
});
|
|
69234
|
+
callback(null, null);
|
|
69235
|
+
return;
|
|
69236
|
+
}
|
|
69237
|
+
Object.values(textures).forEach((t) => {
|
|
69238
|
+
if (t.file) {
|
|
69239
|
+
t.file.contents = null;
|
|
69240
|
+
}
|
|
69197
69241
|
});
|
|
69198
69242
|
const decompress = asset.data?.decompress;
|
|
69199
69243
|
const data = new GSplatSogData();
|
|
@@ -69209,13 +69253,29 @@ class SogBundleParser {
|
|
|
69209
69253
|
data.sh_labels = textures[meta.shN?.files[1]]?.resource;
|
|
69210
69254
|
data.shBands = GSplatSogData.calcBands(data.sh_centroids?.width);
|
|
69211
69255
|
if (!decompress) {
|
|
69256
|
+
if (this._shouldAbort(asset, unloaded)) {
|
|
69257
|
+
data.destroy();
|
|
69258
|
+
callback(null, null);
|
|
69259
|
+
return;
|
|
69260
|
+
}
|
|
69212
69261
|
data.prepareCodebook();
|
|
69213
69262
|
if (gsplatCentersEnabledAtLoad) {
|
|
69214
69263
|
await data.prepareGpuData();
|
|
69215
69264
|
}
|
|
69216
69265
|
}
|
|
69266
|
+
if (this._shouldAbort(asset, unloaded)) {
|
|
69267
|
+
data.destroy();
|
|
69268
|
+
callback(null, null);
|
|
69269
|
+
return;
|
|
69270
|
+
}
|
|
69217
69271
|
const prepareCenters = gsplatCentersEnabledAtLoad;
|
|
69218
69272
|
const resource = decompress ? new GSplatResource(this.app.graphicsDevice, await data.decompress(), { prepareCenters }) : new GSplatSogResource(this.app.graphicsDevice, data, { prepareCenters });
|
|
69273
|
+
ownedByResource = !decompress;
|
|
69274
|
+
if (this._shouldAbort(asset, unloaded)) {
|
|
69275
|
+
resource.destroy();
|
|
69276
|
+
callback(null, null);
|
|
69277
|
+
return;
|
|
69278
|
+
}
|
|
69219
69279
|
callback(null, resource);
|
|
69220
69280
|
} catch (err) {
|
|
69221
69281
|
callback(err);
|
|
@@ -80326,6 +80386,7 @@ const observe = (events, target) => {
|
|
|
80326
80386
|
var deJson = {
|
|
80327
80387
|
"settings.performance-mode": "Leistungsmodus",
|
|
80328
80388
|
"settings.gaming-controls": "Gaming-Steuerung",
|
|
80389
|
+
"settings.show-annotations": "Anmerkungen anzeigen",
|
|
80329
80390
|
"settings.frame": "Einpassen",
|
|
80330
80391
|
"settings.reset": "Zurücksetzen",
|
|
80331
80392
|
"tooltip.play": "Wiedergabe",
|
|
@@ -80399,6 +80460,7 @@ var deJson = {
|
|
|
80399
80460
|
var enJson = {
|
|
80400
80461
|
"settings.performance-mode": "Performance Mode",
|
|
80401
80462
|
"settings.gaming-controls": "Gaming Controls",
|
|
80463
|
+
"settings.show-annotations": "Show Annotations",
|
|
80402
80464
|
"settings.frame": "Frame",
|
|
80403
80465
|
"settings.reset": "Reset",
|
|
80404
80466
|
"tooltip.play": "Play",
|
|
@@ -80472,6 +80534,7 @@ var enJson = {
|
|
|
80472
80534
|
var esJson = {
|
|
80473
80535
|
"settings.performance-mode": "Modo rendimiento",
|
|
80474
80536
|
"settings.gaming-controls": "Controles de juego",
|
|
80537
|
+
"settings.show-annotations": "Mostrar anotaciones",
|
|
80475
80538
|
"settings.frame": "Encuadrar",
|
|
80476
80539
|
"settings.reset": "Restablecer",
|
|
80477
80540
|
"tooltip.play": "Reproducir",
|
|
@@ -80545,6 +80608,7 @@ var esJson = {
|
|
|
80545
80608
|
var frJson = {
|
|
80546
80609
|
"settings.performance-mode": "Mode performance",
|
|
80547
80610
|
"settings.gaming-controls": "Commandes de jeu",
|
|
80611
|
+
"settings.show-annotations": "Afficher les annotations",
|
|
80548
80612
|
"settings.frame": "Cadrer",
|
|
80549
80613
|
"settings.reset": "Réinitialiser",
|
|
80550
80614
|
"tooltip.play": "Lecture",
|
|
@@ -80618,6 +80682,7 @@ var frJson = {
|
|
|
80618
80682
|
var jaJson = {
|
|
80619
80683
|
"settings.performance-mode": "パフォーマンスモード",
|
|
80620
80684
|
"settings.gaming-controls": "ゲームコントロール",
|
|
80685
|
+
"settings.show-annotations": "注釈を表示",
|
|
80621
80686
|
"settings.frame": "フィット",
|
|
80622
80687
|
"settings.reset": "リセット",
|
|
80623
80688
|
"tooltip.play": "再生",
|
|
@@ -80691,6 +80756,7 @@ var jaJson = {
|
|
|
80691
80756
|
var koJson = {
|
|
80692
80757
|
"settings.performance-mode": "성능 모드",
|
|
80693
80758
|
"settings.gaming-controls": "게임 컨트롤",
|
|
80759
|
+
"settings.show-annotations": "주석 표시",
|
|
80694
80760
|
"settings.frame": "맞춤",
|
|
80695
80761
|
"settings.reset": "재설정",
|
|
80696
80762
|
"tooltip.play": "재생",
|
|
@@ -80764,6 +80830,7 @@ var koJson = {
|
|
|
80764
80830
|
var ptBRJson = {
|
|
80765
80831
|
"settings.performance-mode": "Modo de desempenho",
|
|
80766
80832
|
"settings.gaming-controls": "Controles de jogo",
|
|
80833
|
+
"settings.show-annotations": "Mostrar anotações",
|
|
80767
80834
|
"settings.frame": "Enquadrar",
|
|
80768
80835
|
"settings.reset": "Redefinir",
|
|
80769
80836
|
"tooltip.play": "Reproduzir",
|
|
@@ -80837,6 +80904,7 @@ var ptBRJson = {
|
|
|
80837
80904
|
var ruJson = {
|
|
80838
80905
|
"settings.performance-mode": "Режим производительности",
|
|
80839
80906
|
"settings.gaming-controls": "Игровое управление",
|
|
80907
|
+
"settings.show-annotations": "Показать аннотации",
|
|
80840
80908
|
"settings.frame": "Кадрировать",
|
|
80841
80909
|
"settings.reset": "Сбросить",
|
|
80842
80910
|
"tooltip.play": "Воспроизвести",
|
|
@@ -80910,6 +80978,7 @@ var ruJson = {
|
|
|
80910
80978
|
var zhCNJson = {
|
|
80911
80979
|
"settings.performance-mode": "性能模式",
|
|
80912
80980
|
"settings.gaming-controls": "游戏控制",
|
|
80981
|
+
"settings.show-annotations": "显示注释",
|
|
80913
80982
|
"settings.frame": "适应",
|
|
80914
80983
|
"settings.reset": "重置",
|
|
80915
80984
|
"tooltip.play": "播放",
|
|
@@ -80993,9 +81062,9 @@ const dictionaries = {
|
|
|
80993
81062
|
'zh-CN': zhCNJson
|
|
80994
81063
|
};
|
|
80995
81064
|
let current = en;
|
|
80996
|
-
const detectLocale = () => {
|
|
81065
|
+
const detectLocale = (lang) => {
|
|
80997
81066
|
const candidates = [
|
|
80998
|
-
|
|
81067
|
+
lang,
|
|
80999
81068
|
...(navigator.languages ?? [navigator.language])
|
|
81000
81069
|
];
|
|
81001
81070
|
const keys = Object.keys(dictionaries);
|
|
@@ -81021,8 +81090,8 @@ const localize = (key) => current[key] ?? en[key] ?? key;
|
|
|
81021
81090
|
// Detect the preferred locale and replace the text of every `[data-i18n]`
|
|
81022
81091
|
// element with its translation. Call once after the DOM is parsed and before
|
|
81023
81092
|
// any code reads localized strings.
|
|
81024
|
-
const initLocalization = () => {
|
|
81025
|
-
const locale = detectLocale();
|
|
81093
|
+
const initLocalization = (lang) => {
|
|
81094
|
+
const locale = detectLocale(lang);
|
|
81026
81095
|
current = dictionaries[locale];
|
|
81027
81096
|
document.documentElement.lang = locale;
|
|
81028
81097
|
document.querySelectorAll('[data-i18n]').forEach((el) => {
|
|
@@ -81141,7 +81210,7 @@ const importSettings = (settings) => {
|
|
|
81141
81210
|
return result;
|
|
81142
81211
|
};
|
|
81143
81212
|
|
|
81144
|
-
var version = "1.
|
|
81213
|
+
var version = "1.28.0";
|
|
81145
81214
|
|
|
81146
81215
|
class Tooltip {
|
|
81147
81216
|
register;
|
|
@@ -81354,6 +81423,10 @@ const initAnnotationNav = (dom, events, state, annotations) => {
|
|
|
81354
81423
|
const updateMode = () => {
|
|
81355
81424
|
if (!state.loaded)
|
|
81356
81425
|
return;
|
|
81426
|
+
if (!state.showAnnotations) {
|
|
81427
|
+
dom.annotationNav.classList.add('hidden');
|
|
81428
|
+
return;
|
|
81429
|
+
}
|
|
81357
81430
|
dom.annotationNav.classList.remove('desktop', 'touch', 'hidden');
|
|
81358
81431
|
dom.annotationNav.classList.add(state.inputMode);
|
|
81359
81432
|
};
|
|
@@ -81392,6 +81465,10 @@ const initAnnotationNav = (dom, events, state, annotations) => {
|
|
|
81392
81465
|
});
|
|
81393
81466
|
events.on('inputMode:changed', updateMode);
|
|
81394
81467
|
events.on('controlsHidden:changed', updateFade);
|
|
81468
|
+
events.on('showAnnotations:changed', () => {
|
|
81469
|
+
updateMode();
|
|
81470
|
+
updateFade();
|
|
81471
|
+
});
|
|
81395
81472
|
// Initial state
|
|
81396
81473
|
updateDisplay();
|
|
81397
81474
|
};
|
|
@@ -81421,6 +81498,7 @@ const initUI = (global) => {
|
|
|
81421
81498
|
'buttonContainer',
|
|
81422
81499
|
'play', 'pause',
|
|
81423
81500
|
'settings', 'settingsPanel',
|
|
81501
|
+
'annotationsRow', 'annotationsOption', 'annotationsCheck',
|
|
81424
81502
|
'orbitCamera', 'flyCamera', 'fpsCamera',
|
|
81425
81503
|
'performanceModeRow', 'performanceModeCheck', 'performanceModeOption',
|
|
81426
81504
|
'gamingControlsDivider', 'gamingControlsRow', 'gamingControlsCheck', 'gamingControlsOption',
|
|
@@ -81528,7 +81606,6 @@ const initUI = (global) => {
|
|
|
81528
81606
|
});
|
|
81529
81607
|
const updatePerformanceMode = () => {
|
|
81530
81608
|
dom.performanceModeCheck.classList.toggle('active', state.performanceMode);
|
|
81531
|
-
localStorage.setItem('performanceMode', String(state.performanceMode));
|
|
81532
81609
|
};
|
|
81533
81610
|
events.on('performanceMode:changed', updatePerformanceMode);
|
|
81534
81611
|
updatePerformanceMode();
|
|
@@ -81553,18 +81630,33 @@ const initUI = (global) => {
|
|
|
81553
81630
|
dom.touchFlyGamingControls.classList.toggle('hidden', !state.gamingControls);
|
|
81554
81631
|
dom.touchClickToWalk.classList.toggle('hidden', state.gamingControls);
|
|
81555
81632
|
dom.touchGamingControls.classList.toggle('hidden', !state.gamingControls);
|
|
81556
|
-
localStorage.setItem('gamingControls', String(state.gamingControls));
|
|
81557
81633
|
};
|
|
81558
81634
|
events.on('gamingControls:changed', updateGamingControls);
|
|
81559
81635
|
events.on('inputMode:changed', updateGamingControls);
|
|
81560
81636
|
updateGamingControls();
|
|
81637
|
+
// Annotation visibility toggle
|
|
81638
|
+
const updateAnnotationsVisibility = () => {
|
|
81639
|
+
dom.annotationsRow.classList.toggle('hidden', global.settings.annotations.length === 0);
|
|
81640
|
+
dom.annotationsCheck.classList.toggle('active', state.showAnnotations);
|
|
81641
|
+
global.app.renderNextFrame = true;
|
|
81642
|
+
};
|
|
81643
|
+
dom.annotationsRow.addEventListener('click', () => {
|
|
81644
|
+
state.showAnnotations = !state.showAnnotations;
|
|
81645
|
+
});
|
|
81646
|
+
events.on('showAnnotations:changed', updateAnnotationsVisibility);
|
|
81647
|
+
updateAnnotationsVisibility();
|
|
81648
|
+
// persist user preferences on change (never at startup, so defaults are not written into storage)
|
|
81649
|
+
events.on('performanceMode:changed', (value) => localStorage.setItem('performanceMode', String(value)));
|
|
81650
|
+
events.on('gamingControls:changed', (value) => localStorage.setItem('gamingControls', String(value)));
|
|
81651
|
+
events.on('showAnnotations:changed', (value) => localStorage.setItem('showAnnotations', String(value)));
|
|
81561
81652
|
// AR/VR
|
|
81562
81653
|
const arChanged = () => dom.arMode.classList[state.hasAR ? 'remove' : 'add']('hidden');
|
|
81563
81654
|
const vrChanged = () => dom.vrMode.classList[state.hasVR ? 'remove' : 'add']('hidden');
|
|
81564
|
-
//
|
|
81565
|
-
// the viewer with the WebGL renderer before
|
|
81566
|
-
// the renderer-switch reload doesn't add a
|
|
81567
|
-
// because the viewer often runs inside an
|
|
81655
|
+
// When a session can't start on the current (WebGPU) device but would work on
|
|
81656
|
+
// WebGL, prompt the user to reload the viewer with the WebGL renderer before
|
|
81657
|
+
// starting AR/VR. Use replace() so the renderer-switch reload doesn't add a
|
|
81658
|
+
// back-button entry — important because the viewer often runs inside an
|
|
81659
|
+
// iframe (e.g. superspl.at /scene).
|
|
81568
81660
|
const reloadWithWebgl = () => {
|
|
81569
81661
|
const reloadUrl = new URL(location.href);
|
|
81570
81662
|
reloadUrl.searchParams.set('webgl', '');
|
|
@@ -81576,11 +81668,14 @@ const initUI = (global) => {
|
|
|
81576
81668
|
dom.xrModalCancel.addEventListener('click', hideXrModal);
|
|
81577
81669
|
dom.xrModal.addEventListener('pointerdown', hideXrModal);
|
|
81578
81670
|
const handleXrClick = (type) => {
|
|
81579
|
-
|
|
81580
|
-
|
|
81671
|
+
// Availability is backend-aware: when the session can start on the current
|
|
81672
|
+
// device (WebGPU included), start it directly. Otherwise the button is only
|
|
81673
|
+
// visible because the session would work on WebGL, so offer the reload.
|
|
81674
|
+
if (global.app.xr.isAvailable(type === 'AR' ? 'immersive-ar' : 'immersive-vr')) {
|
|
81675
|
+
events.fire(type === 'AR' ? 'startAR' : 'startVR');
|
|
81581
81676
|
}
|
|
81582
81677
|
else {
|
|
81583
|
-
|
|
81678
|
+
showXrModal();
|
|
81584
81679
|
}
|
|
81585
81680
|
};
|
|
81586
81681
|
dom.arMode.addEventListener('click', () => handleXrClick('AR'));
|
|
@@ -82417,14 +82512,18 @@ class Annotations {
|
|
|
82417
82512
|
const updateVisibility = () => {
|
|
82418
82513
|
const firstPersonGamingControls = ((state.cameraMode === 'walk' || state.cameraMode === 'fly') &&
|
|
82419
82514
|
state.gamingControls);
|
|
82420
|
-
const hidden = state.controlsHidden || firstPersonGamingControls;
|
|
82515
|
+
const hidden = !state.showAnnotations || state.controlsHidden || firstPersonGamingControls;
|
|
82421
82516
|
parentDom.style.display = hidden ? 'none' : 'block';
|
|
82422
82517
|
Annotation.opacity = hidden ? 0.0 : 1.0;
|
|
82518
|
+
if (hidden && Annotation.activeAnnotation) {
|
|
82519
|
+
Annotation.activeAnnotation.hideTooltip();
|
|
82520
|
+
}
|
|
82423
82521
|
if (this.annotations.length > 0) {
|
|
82424
82522
|
global.app.renderNextFrame = true;
|
|
82425
82523
|
}
|
|
82426
82524
|
};
|
|
82427
82525
|
global.events.on('controlsHidden:changed', updateVisibility);
|
|
82526
|
+
global.events.on('showAnnotations:changed', updateVisibility);
|
|
82428
82527
|
global.events.on('cameraMode:changed', updateVisibility);
|
|
82429
82528
|
global.events.on('gamingControls:changed', updateVisibility);
|
|
82430
82529
|
updateVisibility();
|
|
@@ -89432,19 +89531,28 @@ class XrNavigation extends Script {
|
|
|
89432
89531
|
// On entering/exiting AR, we need to set the camera clear color to transparent black
|
|
89433
89532
|
const initXr = (global) => {
|
|
89434
89533
|
const { app, events, state, camera, renderer } = global;
|
|
89435
|
-
|
|
89436
|
-
|
|
89437
|
-
//
|
|
89438
|
-
|
|
89439
|
-
|
|
89440
|
-
|
|
89441
|
-
|
|
89442
|
-
|
|
89443
|
-
|
|
89444
|
-
|
|
89445
|
-
|
|
89446
|
-
|
|
89447
|
-
|
|
89534
|
+
// Engine availability is backend-aware (2.20+): under WebGPU a session is only
|
|
89535
|
+
// reported available when it can start on the current device (browser exposes
|
|
89536
|
+
// XRGPUBinding, e.g. Safari on Apple Vision Pro). A session the WebGPU device
|
|
89537
|
+
// can't host may still run after reloading into WebGL, so keep the buttons
|
|
89538
|
+
// visible then — the UI offers that reload when the session can't start directly.
|
|
89539
|
+
let webglAR = false;
|
|
89540
|
+
let webglVR = false;
|
|
89541
|
+
const updateAvailable = () => {
|
|
89542
|
+
state.hasAR = app.xr.isAvailable('immersive-ar') || webglAR;
|
|
89543
|
+
state.hasVR = app.xr.isAvailable('immersive-vr') || webglVR;
|
|
89544
|
+
};
|
|
89545
|
+
updateAvailable();
|
|
89546
|
+
app.xr.on('available', updateAvailable);
|
|
89547
|
+
if (renderer === 'webgpu') {
|
|
89548
|
+
Promise.all([
|
|
89549
|
+
XrManager.isDeviceSupported(DEVICETYPE_WEBGL2, 'immersive-ar'),
|
|
89550
|
+
XrManager.isDeviceSupported(DEVICETYPE_WEBGL2, 'immersive-vr')
|
|
89551
|
+
]).then(([ar, vr]) => {
|
|
89552
|
+
webglAR = ar;
|
|
89553
|
+
webglVR = vr;
|
|
89554
|
+
updateAvailable();
|
|
89555
|
+
});
|
|
89448
89556
|
}
|
|
89449
89557
|
const parent = camera.parent;
|
|
89450
89558
|
const clearColor = new Color();
|
|
@@ -89561,8 +89669,8 @@ const loadSkybox = (app, url) => {
|
|
|
89561
89669
|
const createApp = async (canvas, config) => {
|
|
89562
89670
|
const useWebGPU = config.renderer === 'webgpu';
|
|
89563
89671
|
// Create the graphics device. The engine auto-appends WebGL2/null fallbacks
|
|
89564
|
-
// when WebGPU isn't supported
|
|
89565
|
-
// is
|
|
89672
|
+
// when WebGPU isn't supported. Request xrCompatible so the device — WebGPU
|
|
89673
|
+
// (via XRGPUBinding) or the WebGL fallback — is usable for AR/VR.
|
|
89566
89674
|
const device = await createGraphicsDevice(canvas, {
|
|
89567
89675
|
deviceTypes: useWebGPU ? ['webgpu'] : [],
|
|
89568
89676
|
antialias: false,
|
|
@@ -89680,6 +89788,7 @@ const main = async (canvas, settingsJson, config) => {
|
|
|
89680
89788
|
collisionOverlayEnabled: false,
|
|
89681
89789
|
isFullscreen: false,
|
|
89682
89790
|
controlsHidden: false,
|
|
89791
|
+
showAnnotations: localStorage.getItem('showAnnotations') !== 'false',
|
|
89683
89792
|
gamingControls: localStorage.getItem('gamingControls') === 'true'
|
|
89684
89793
|
});
|
|
89685
89794
|
const global = {
|
|
@@ -89699,11 +89808,11 @@ const main = async (canvas, settingsJson, config) => {
|
|
|
89699
89808
|
initPoster(events);
|
|
89700
89809
|
}
|
|
89701
89810
|
camera.addComponent('camera');
|
|
89702
|
-
// Initialize XR support (
|
|
89703
|
-
//
|
|
89811
|
+
// Initialize XR support (any backend; when the current device can't host a
|
|
89812
|
+
// session the UI can offer a reload into WebGL instead)
|
|
89704
89813
|
initXr(global);
|
|
89705
89814
|
// Initialize user interface
|
|
89706
|
-
initLocalization();
|
|
89815
|
+
initLocalization(config.lang);
|
|
89707
89816
|
initUI(global);
|
|
89708
89817
|
// Load model
|
|
89709
89818
|
const gsplatLoad = loadGsplat(app, config, (progress) => {
|