@smarterplan/ngx-smarterplan-core 1.4.23 → 1.4.24
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 +24 -24
- package/esm2022/lib/components/inventory-runs/inventory-files.component.mjs +125 -0
- package/esm2022/lib/components/inventory-runs/inventory-runs.component.mjs +150 -0
- package/esm2022/lib/components/loader/loader.component.mjs +3 -3
- package/esm2022/lib/components/menu-bar/avatar/avatar.component.mjs +1 -1
- package/esm2022/lib/components/menu-bar/navigation-bar/navigation-bar.component.mjs +3 -3
- package/esm2022/lib/components/modal-switch-visit/modal-switch-visit.component.mjs +3 -3
- package/esm2022/lib/components/search-bar/search-bar.component.mjs +3 -3
- package/esm2022/lib/components/splat-viewer/splat-viewer.component.mjs +2 -2
- package/esm2022/lib/components/support-modal/support-modal.component.mjs +3 -3
- package/esm2022/lib/config.mjs +1 -1
- package/esm2022/lib/matterport-extensions/nest-thermostat/CanvasImage.mjs +1 -1
- package/esm2022/lib/matterport-extensions/nest-thermostat/CanvasRenderer.mjs +1 -1
- package/esm2022/lib/matterport-extensions/nest-thermostat/NestThermostat.mjs +1 -1
- package/esm2022/lib/matterport-extensions/nest-thermostat/PlaneRenderer.mjs +1 -1
- package/esm2022/lib/matterport-extensions/scene-component/SceneComponent.mjs +1 -1
- package/esm2022/lib/matterport-extensions/security-camera/SecurityCamera.mjs +22 -22
- package/esm2022/lib/matterport-extensions/tv-player/TvPlayer.mjs +1 -1
- package/esm2022/lib/matterport-extensions/view-frustum-mesh/ViewFrustumMesh.mjs +22 -22
- package/esm2022/lib/mattertagData.mjs +1 -1
- package/esm2022/lib/ngx-smarterplan-core.module.mjs +14 -4
- package/esm2022/lib/ngx-smarterplan-core.service.mjs +1 -1
- package/esm2022/lib/pipes/duration-to-string.pipe.mjs +1 -1
- package/esm2022/lib/pipes/format-date-number-to-digits.pipe.mjs +1 -1
- package/esm2022/lib/pipes/hashtag-from-id.pipe.mjs +1 -1
- package/esm2022/lib/pipes/safe-url.pipe.mjs +1 -1
- package/esm2022/lib/pipes/time-date-to-local-string.pipe.mjs +1 -1
- package/esm2022/lib/pipes/username-from-id.pipe.mjs +1 -1
- package/esm2022/lib/services/amplify-cache.service.mjs +1 -1
- package/esm2022/lib/services/base-tab.service.mjs +1 -1
- package/esm2022/lib/services/baseVisibility.service.mjs +1 -1
- package/esm2022/lib/services/content.service.mjs +1 -1
- package/esm2022/lib/services/filter.service.mjs +1 -1
- package/esm2022/lib/services/intervention.service.mjs +1 -1
- package/esm2022/lib/services/locale.service.mjs +1 -1
- package/esm2022/lib/services/matterport-import.service.mjs +4 -3
- package/esm2022/lib/services/matterport-measurement.service.mjs +1 -1
- package/esm2022/lib/services/matterport-navigation.service.mjs +1 -1
- package/esm2022/lib/services/matterport-object3d.service.mjs +1 -1
- package/esm2022/lib/services/matterport-pointer.service.mjs +6 -6
- package/esm2022/lib/services/matterport-tag-copy.service.mjs +1 -1
- package/esm2022/lib/services/matterport-tag.service.mjs +1 -1
- package/esm2022/lib/services/matterport.service.mjs +17 -17
- package/esm2022/lib/services/models/affectation.service.mjs +1 -1
- package/esm2022/lib/services/models/base-object.service.mjs +1 -1
- package/esm2022/lib/services/models/capture.service.mjs +1 -1
- package/esm2022/lib/services/models/comment.service.mjs +1 -1
- package/esm2022/lib/services/models/domain.service.mjs +1 -1
- package/esm2022/lib/services/models/equipment.service.mjs +1 -1
- package/esm2022/lib/services/models/event.service.mjs +1 -1
- package/esm2022/lib/services/models/feature.service.mjs +1 -1
- package/esm2022/lib/services/models/hashtag.service.mjs +1 -1
- package/esm2022/lib/services/models/inventory.service.mjs +252 -0
- package/esm2022/lib/services/models/layer.service.mjs +1 -1
- package/esm2022/lib/services/models/measurement.service.mjs +1 -1
- package/esm2022/lib/services/models/mission.service.mjs +1 -1
- package/esm2022/lib/services/models/navigation.service.mjs +1 -1
- package/esm2022/lib/services/models/node.service.mjs +1 -1
- package/esm2022/lib/services/models/object3D.service.mjs +1 -1
- package/esm2022/lib/services/models/operation.service.mjs +1 -1
- package/esm2022/lib/services/models/organisation.service.mjs +1 -1
- package/esm2022/lib/services/models/plan.service.mjs +1 -1
- package/esm2022/lib/services/models/poi.service.mjs +27 -27
- package/esm2022/lib/services/models/profile.service.mjs +1 -1
- package/esm2022/lib/services/models/property.service.mjs +1 -1
- package/esm2022/lib/services/models/space.service.mjs +1 -1
- package/esm2022/lib/services/models/template.service.mjs +1 -1
- package/esm2022/lib/services/models/ticket.service.mjs +1 -1
- package/esm2022/lib/services/models/visit.service.mjs +1 -1
- package/esm2022/lib/services/models/zone.service.mjs +1 -1
- package/esm2022/lib/services/navigator.service.mjs +1 -1
- package/esm2022/lib/services/obj-to-glb.mjs +1 -1
- package/esm2022/lib/services/s3.service.mjs +1 -1
- package/esm2022/lib/services/search.service.mjs +1 -1
- package/esm2022/lib/services/support.service.mjs +1 -1
- package/esm2022/lib/services/sweep-locator.service.mjs +1 -1
- package/esm2022/lib/services/tag.service.mjs +16 -16
- package/esm2022/lib/services/threejs-import.service.mjs +1 -1
- package/esm2022/lib/services/threejs.service.mjs +1 -1
- package/esm2022/lib/services/user.service.mjs +1 -1
- package/esm2022/lib/services/utils/matterport-framing.util.mjs +1 -1
- package/esm2022/lib/services/utils/matterport-transform.util.mjs +1 -1
- package/esm2022/lib/services/validators.service.mjs +1 -1
- package/esm2022/lib/services/viewer.service.mjs +1 -1
- package/esm2022/lib/services/zoneChange.service.mjs +1 -1
- package/esm2022/lib/tokens/matterport-sdk-key.token.mjs +1 -1
- package/esm2022/lib/types.service.mjs +2 -1
- package/esm2022/lib/validators/email.directive.mjs +1 -1
- package/esm2022/lib/validators/no-empty.directive.mjs +1 -1
- package/esm2022/lib/validators/number.directive.mjs +1 -1
- package/esm2022/lib/validators/text.directive.mjs +1 -1
- package/esm2022/public-api.mjs +4 -1
- package/fesm2022/smarterplan-ngx-smarterplan-core.mjs +646 -125
- package/fesm2022/smarterplan-ngx-smarterplan-core.mjs.map +1 -1
- package/lib/components/inventory-runs/inventory-files.component.d.ts +23 -0
- package/lib/components/inventory-runs/inventory-runs.component.d.ts +49 -0
- package/lib/components/splat-viewer/splat-viewer.component.d.ts +1 -1
- package/lib/ngx-smarterplan-core.module.d.ts +9 -7
- package/lib/services/models/inventory.service.d.ts +112 -0
- package/lib/types.service.d.ts +2 -1
- package/package.json +1 -1
- package/public-api.d.ts +3 -0
- package/src/assets/viewers/splat/{chunk-WZ5Z4TU3.js → chunk-EG4HD6E6.js} +2 -2
- package/src/assets/viewers/splat/{convert-4DRLH77X.js → convert-AJMRDWU6.js} +1 -1
- package/src/assets/viewers/splat/convert.html +11 -11
- package/src/assets/viewers/splat/{converter-SLBB5MHG.js → converter-UV7KH5KN.js} +1 -1
- package/src/assets/viewers/splat/index.html +90 -90
- package/src/assets/viewers/splat/{viewer-W4X3FWQJ.js → viewer-QLWW4L3N.js} +2 -2
- package/src/assets/viewers/splat/webp.wasm +0 -0
- package/src/assets/vs-app.json +67 -67
- /package/src/assets/viewers/splat/{chunk-BYLI4YBI.js → chunk-KX25RBTZ.js} +0 -0
- /package/src/assets/viewers/splat/{spz-DEYRea_v-QE6YSGIB.js → spz-DEYRea_v-ZGM37WHQ.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as r}from"./chunk-
|
|
1
|
+
import{b as r}from"./chunk-EG4HD6E6.js";import"./chunk-KX25RBTZ.js";import"./chunk-LDV6YPMG.js";function t(o){window.parent.postMessage(o,window.location.origin)}window.addEventListener("message",o=>{if(o.origin!==window.location.origin||o.source!==window.parent||o.data?.type!=="convert")return;let{file:a,baseName:i}=o.data;r(a,i,(e,n)=>t({type:"convert-progress",step:e,fraction:n})).then(({files:e,entry:n,splats:s,sh:d,levels:c})=>t({type:"converted",files:e,entry:n,splats:s,sh:d,levels:c})).catch(e=>{console.error("Splat converter:",e),t({type:"convert-error",message:e?.message??String(e)})})});t({type:"ready"});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<title>SmarterPlan splat converter</title>
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<!-- Opened unseen by the app's 3D models form, which hands it a splat file to turn into .sog. -->
|
|
9
|
-
<script type="module" src="convert-
|
|
10
|
-
</body>
|
|
11
|
-
</html>
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>SmarterPlan splat converter</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<!-- Opened unseen by the app's 3D models form, which hands it a splat file to turn into .sog. -->
|
|
9
|
+
<script type="module" src="convert-AJMRDWU6.js"></script>
|
|
10
|
+
</body>
|
|
11
|
+
</html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c}from"./chunk-
|
|
1
|
+
import{a,b,c}from"./chunk-EG4HD6E6.js";import"./chunk-KX25RBTZ.js";import"./chunk-LDV6YPMG.js";export{a as STREAMED_ENTRY,b as convertForUpload,c as toCompressedPly};
|
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
-
<title>SmarterPlan splat viewer</title>
|
|
7
|
-
<!-- SuperSplat's viewer builds its controls inside #viewer; this is their stylesheet. -->
|
|
8
|
-
<link rel="stylesheet" href="viewer.css">
|
|
9
|
-
<style>
|
|
10
|
-
/* The app's colours, which main.ts sets from those the page is opened with; these, the SmarterPlan
|
|
11
|
-
app's, when it is not. The background is also the scene's where there are no splats. */
|
|
12
|
-
:root { --app-accent: rgb(83, 182, 187); --app-background: #e0f7ff; }
|
|
13
|
-
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--app-background); }
|
|
14
|
-
/* SuperSplat's controls in the app's colour rather than its orange. */
|
|
15
|
-
:root .sse-viewer { --sse-accent: var(--app-accent); --sse-grip: color-mix(in srgb, var(--app-accent), white 15%); }
|
|
16
|
-
#viewer { position: absolute; inset: 0; }
|
|
17
|
-
/* The app's tags, over the scene, as Matterport draws them: a disc at the end of a stem standing
|
|
18
|
-
out of the surface, and the tag's name in a bubble on hover. Only the discs take the pointer. */
|
|
19
|
-
#tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
|
|
20
|
-
#stems { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
|
|
21
|
-
#stems line { stroke: #fff; stroke-width: 2; stroke-linecap: round; filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.6)); }
|
|
22
|
-
.tag { position: absolute; left: 0; top: 0; width: 0; height: 0; display: none; }
|
|
23
|
-
.disc {
|
|
24
|
-
position: absolute; left: -14px; top: -14px; width: 28px; height: 28px; padding: 0;
|
|
25
|
-
border: 2px solid #fff; border-radius: 50%; cursor: pointer; pointer-events: auto;
|
|
26
|
-
background-size: 70%; background-position: center; background-repeat: no-repeat;
|
|
27
|
-
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); transition: transform 0.15s ease-out;
|
|
28
|
-
}
|
|
29
|
-
.tag:hover .disc { transform: scale(1.3); }
|
|
30
|
-
.bubble {
|
|
31
|
-
position: absolute; bottom: 24px; left: 0; transform: translate(-50%, 6px); opacity: 0;
|
|
32
|
-
padding: 6px 10px; border-radius: 6px; background: #fff; color: #222; font: 13px/1.3 sans-serif;
|
|
33
|
-
white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); pointer-events: none;
|
|
34
|
-
transition: opacity 0.15s ease-out, transform 0.15s ease-out;
|
|
35
|
-
}
|
|
36
|
-
.bubble::after {
|
|
37
|
-
content: ''; position: absolute; top: 100%; left: 50%; margin-left: -6px;
|
|
38
|
-
border: 6px solid transparent; border-top-color: #fff;
|
|
39
|
-
}
|
|
40
|
-
.bubble:empty { display: none; }
|
|
41
|
-
.tag:hover .bubble { opacity: 1; transform: translate(-50%, 0); }
|
|
42
|
-
.tag.pointed .disc { animation: pointed 0.6s ease-in-out 3; }
|
|
43
|
-
/* The tag following the pointer while one is placed: where a click would put it. */
|
|
44
|
-
.tag.ghost { opacity: 0.75; }
|
|
45
|
-
.tag.ghost .disc { pointer-events: none; background-color: #fff; border-color: #1E88E5; }
|
|
46
|
-
#stems line.ghost { stroke-dasharray: 4 3; }
|
|
47
|
-
/* While a tag is placed: over the whole scene, taking the click that picks its spot. */
|
|
48
|
-
#placing { position: absolute; inset: 0; z-index: 6; display: none; cursor: crosshair; }
|
|
49
|
-
/* The app shows how loading goes, as for its other viewers: the viewer's own bar would be a second one. */
|
|
50
|
-
.sse-viewer .sse-loadingWrap { display: none !important; }
|
|
51
|
-
#placing.missed { cursor: not-allowed; }
|
|
52
|
-
/* A calibration, in the app's 3D viewer's colours: a green numbered pin where each matched tag
|
|
53
|
-
really is, with a line to it from the tag, faded; and an amber ring round the tag being matched. */
|
|
54
|
-
.pin {
|
|
55
|
-
position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; box-sizing: border-box;
|
|
56
|
-
display: none; border: 2px solid #fff; border-radius: 50%; background: #1E9E5A; color: #fff;
|
|
57
|
-
font: bold 13px/20px sans-serif; text-align: center; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
|
|
58
|
-
pointer-events: none; z-index: 1000001;
|
|
59
|
-
}
|
|
60
|
-
#stems line.link { stroke: #1E9E5A; stroke-opacity: 0.75; stroke-dasharray: none; }
|
|
61
|
-
.tag.matched, #stems line.matched { opacity: 0.4; }
|
|
62
|
-
.tag.selected .disc { box-shadow: 0 0 0 4px #FFB103, 0 1px 4px rgba(0, 0, 0, 0.5); }
|
|
63
|
-
/* A measurement, in the app's 3D viewer's colours: amber points and segments, each length on a dark label. */
|
|
64
|
-
.measure-point {
|
|
65
|
-
position: absolute; left: 0; top: 0; width: 12px; height: 12px; box-sizing: border-box; display: none;
|
|
66
|
-
border: 2px solid #fff; border-radius: 50%; background: #FFB103; pointer-events: none; z-index: 1000002;
|
|
67
|
-
}
|
|
68
|
-
#stems line.measure { stroke: #FFB103; stroke-width: 3; filter: none; }
|
|
69
|
-
#stems line.measure.rubber { stroke-opacity: 0.6; }
|
|
70
|
-
.measure-label {
|
|
71
|
-
position: absolute; left: 0; top: 0; display: none; padding: 3px 8px; border-radius: 9px;
|
|
72
|
-
background: rgba(0, 0, 0, 0.78); color: #fff; font: bold 13px/18px sans-serif; white-space: nowrap;
|
|
73
|
-
pointer-events: none; z-index: 1000003;
|
|
74
|
-
}
|
|
75
|
-
.measure-label.rubber { opacity: 0.85; }
|
|
76
|
-
.tag.ghost.measure-ghost .disc { left: -6px; top: -6px; width: 12px; height: 12px; box-sizing: border-box; background: #FFB103; border-color: #fff; }
|
|
77
|
-
.tag.ghost.pin-ghost .disc {
|
|
78
|
-
left: -12px; top: -12px; width: 24px; height: 24px; box-sizing: border-box;
|
|
79
|
-
background: #1E9E5A; border-color: #fff; color: #fff; font: bold 13px/20px sans-serif; text-align: center;
|
|
80
|
-
}
|
|
81
|
-
@keyframes pointed { 50% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.6); } }
|
|
82
|
-
</style>
|
|
83
|
-
</head>
|
|
84
|
-
<body>
|
|
85
|
-
<div id="viewer"></div>
|
|
86
|
-
<div id="tags"><svg id="stems"></svg></div>
|
|
87
|
-
<div id="placing"></div>
|
|
88
|
-
<script type="module" src="viewer-
|
|
89
|
-
</body>
|
|
90
|
-
</html>
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>SmarterPlan splat viewer</title>
|
|
7
|
+
<!-- SuperSplat's viewer builds its controls inside #viewer; this is their stylesheet. -->
|
|
8
|
+
<link rel="stylesheet" href="viewer.css">
|
|
9
|
+
<style>
|
|
10
|
+
/* The app's colours, which main.ts sets from those the page is opened with; these, the SmarterPlan
|
|
11
|
+
app's, when it is not. The background is also the scene's where there are no splats. */
|
|
12
|
+
:root { --app-accent: rgb(83, 182, 187); --app-background: #e0f7ff; }
|
|
13
|
+
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--app-background); }
|
|
14
|
+
/* SuperSplat's controls in the app's colour rather than its orange. */
|
|
15
|
+
:root .sse-viewer { --sse-accent: var(--app-accent); --sse-grip: color-mix(in srgb, var(--app-accent), white 15%); }
|
|
16
|
+
#viewer { position: absolute; inset: 0; }
|
|
17
|
+
/* The app's tags, over the scene, as Matterport draws them: a disc at the end of a stem standing
|
|
18
|
+
out of the surface, and the tag's name in a bubble on hover. Only the discs take the pointer. */
|
|
19
|
+
#tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
|
|
20
|
+
#stems { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
|
|
21
|
+
#stems line { stroke: #fff; stroke-width: 2; stroke-linecap: round; filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.6)); }
|
|
22
|
+
.tag { position: absolute; left: 0; top: 0; width: 0; height: 0; display: none; }
|
|
23
|
+
.disc {
|
|
24
|
+
position: absolute; left: -14px; top: -14px; width: 28px; height: 28px; padding: 0;
|
|
25
|
+
border: 2px solid #fff; border-radius: 50%; cursor: pointer; pointer-events: auto;
|
|
26
|
+
background-size: 70%; background-position: center; background-repeat: no-repeat;
|
|
27
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); transition: transform 0.15s ease-out;
|
|
28
|
+
}
|
|
29
|
+
.tag:hover .disc { transform: scale(1.3); }
|
|
30
|
+
.bubble {
|
|
31
|
+
position: absolute; bottom: 24px; left: 0; transform: translate(-50%, 6px); opacity: 0;
|
|
32
|
+
padding: 6px 10px; border-radius: 6px; background: #fff; color: #222; font: 13px/1.3 sans-serif;
|
|
33
|
+
white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); pointer-events: none;
|
|
34
|
+
transition: opacity 0.15s ease-out, transform 0.15s ease-out;
|
|
35
|
+
}
|
|
36
|
+
.bubble::after {
|
|
37
|
+
content: ''; position: absolute; top: 100%; left: 50%; margin-left: -6px;
|
|
38
|
+
border: 6px solid transparent; border-top-color: #fff;
|
|
39
|
+
}
|
|
40
|
+
.bubble:empty { display: none; }
|
|
41
|
+
.tag:hover .bubble { opacity: 1; transform: translate(-50%, 0); }
|
|
42
|
+
.tag.pointed .disc { animation: pointed 0.6s ease-in-out 3; }
|
|
43
|
+
/* The tag following the pointer while one is placed: where a click would put it. */
|
|
44
|
+
.tag.ghost { opacity: 0.75; }
|
|
45
|
+
.tag.ghost .disc { pointer-events: none; background-color: #fff; border-color: #1E88E5; }
|
|
46
|
+
#stems line.ghost { stroke-dasharray: 4 3; }
|
|
47
|
+
/* While a tag is placed: over the whole scene, taking the click that picks its spot. */
|
|
48
|
+
#placing { position: absolute; inset: 0; z-index: 6; display: none; cursor: crosshair; }
|
|
49
|
+
/* The app shows how loading goes, as for its other viewers: the viewer's own bar would be a second one. */
|
|
50
|
+
.sse-viewer .sse-loadingWrap { display: none !important; }
|
|
51
|
+
#placing.missed { cursor: not-allowed; }
|
|
52
|
+
/* A calibration, in the app's 3D viewer's colours: a green numbered pin where each matched tag
|
|
53
|
+
really is, with a line to it from the tag, faded; and an amber ring round the tag being matched. */
|
|
54
|
+
.pin {
|
|
55
|
+
position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; box-sizing: border-box;
|
|
56
|
+
display: none; border: 2px solid #fff; border-radius: 50%; background: #1E9E5A; color: #fff;
|
|
57
|
+
font: bold 13px/20px sans-serif; text-align: center; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
|
|
58
|
+
pointer-events: none; z-index: 1000001;
|
|
59
|
+
}
|
|
60
|
+
#stems line.link { stroke: #1E9E5A; stroke-opacity: 0.75; stroke-dasharray: none; }
|
|
61
|
+
.tag.matched, #stems line.matched { opacity: 0.4; }
|
|
62
|
+
.tag.selected .disc { box-shadow: 0 0 0 4px #FFB103, 0 1px 4px rgba(0, 0, 0, 0.5); }
|
|
63
|
+
/* A measurement, in the app's 3D viewer's colours: amber points and segments, each length on a dark label. */
|
|
64
|
+
.measure-point {
|
|
65
|
+
position: absolute; left: 0; top: 0; width: 12px; height: 12px; box-sizing: border-box; display: none;
|
|
66
|
+
border: 2px solid #fff; border-radius: 50%; background: #FFB103; pointer-events: none; z-index: 1000002;
|
|
67
|
+
}
|
|
68
|
+
#stems line.measure { stroke: #FFB103; stroke-width: 3; filter: none; }
|
|
69
|
+
#stems line.measure.rubber { stroke-opacity: 0.6; }
|
|
70
|
+
.measure-label {
|
|
71
|
+
position: absolute; left: 0; top: 0; display: none; padding: 3px 8px; border-radius: 9px;
|
|
72
|
+
background: rgba(0, 0, 0, 0.78); color: #fff; font: bold 13px/18px sans-serif; white-space: nowrap;
|
|
73
|
+
pointer-events: none; z-index: 1000003;
|
|
74
|
+
}
|
|
75
|
+
.measure-label.rubber { opacity: 0.85; }
|
|
76
|
+
.tag.ghost.measure-ghost .disc { left: -6px; top: -6px; width: 12px; height: 12px; box-sizing: border-box; background: #FFB103; border-color: #fff; }
|
|
77
|
+
.tag.ghost.pin-ghost .disc {
|
|
78
|
+
left: -12px; top: -12px; width: 24px; height: 24px; box-sizing: border-box;
|
|
79
|
+
background: #1E9E5A; border-color: #fff; color: #fff; font: bold 13px/20px sans-serif; text-align: center;
|
|
80
|
+
}
|
|
81
|
+
@keyframes pointed { 50% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.6); } }
|
|
82
|
+
</style>
|
|
83
|
+
</head>
|
|
84
|
+
<body>
|
|
85
|
+
<div id="viewer"></div>
|
|
86
|
+
<div id="tags"><svg id="stems"></svg></div>
|
|
87
|
+
<div id="placing"></div>
|
|
88
|
+
<script type="module" src="viewer-QLWW4L3N.js"></script>
|
|
89
|
+
</body>
|
|
90
|
+
</html>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$a as ua,A as Fn,Aa as ie,B as pe,Ba as Ss,C as In,Ca as Cs,D as Vn,Da as Ye,E as Pi,Ea as $t,F as Li,Fa as ke,G as Ue,Ga as Qi,H as oe,Ha as qn,I as ns,Ia as Ji,J as os,Ja as Ze,K as xt,L as G,La as ea,M as On,Ma as Ps,N as X,Na as ht,O as Bt,Oa as ce,P as Z,Pa as ta,Q as Ei,Qa as sa,R as Ri,Ra as na,S as lt,Sa as oa,T as is,Ta as ia,U as ze,Ua as aa,V as fe,Va as ra,W as Xe,Wa as la,X as Ai,Xa as ca,Y as q,Ya as ha,Z as Nt,Za as da,_ as ct,_a as Ls,a as Tn,aa as Ti,ab as $n,b as gi,ba as Fe,bb as pa,c as Ot,ca as Di,cb as fa,d as vi,da as zi,db as ma,e as Dn,ea as Fi,eb as ga,f as Y,fa as wt,fb as Hn,g as K,ga as Ms,gb as va,ha as Bn,hb as ya,i as x,ia as Ii,ib as xa,ja as Vi,k as yt,ka as qt,l as yi,la as Oi,m as U,ma as Bi,n as Q,na as Ni,o as xi,oa as qi,p as wi,pa as $i,q as bi,qa as Hi,r as ss,ra as ji,s as ks,sa as Wi,t as zn,ta as Gi,u as _i,ua as Nn,v as ki,va as Ui,w as Mi,wa as Xi,x as Si,xa as Yi,y as Ci,ya as Zi,z as rt,za as Ki}from"./chunk-BYLI4YBI.js";import"./chunk-LDV6YPMG.js";var Es=class extends ht{static scriptName="xrControllers";basePath="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets/dist/profiles";controllers=new Map;_pendingInputSources=new Set;_models=new Map;_visible=!0;_handlers=null;initialize(){if(!this.app.xr){console.error("XrControllers script requires XR to be enabled on the application");return}this._handlers={onAdd:this._onInputSourceAdd.bind(this),onRemove:this._onInputSourceRemove.bind(this),onXrEnd:this._onXrEnd.bind(this)},this.app.xr.input.on("add",this._handlers.onAdd),this.app.xr.input.on("remove",this._handlers.onRemove),this.app.xr.on("end",this._handlers.onXrEnd),this.once("destroy",()=>{this._onDestroy()})}_onDestroy(){this._handlers&&this.app.xr&&(this.app.xr.input.off("add",this._handlers.onAdd),this.app.xr.input.off("remove",this._handlers.onRemove),this.app.xr.off("end",this._handlers.onXrEnd)),this._destroyAllControllers(),this._handlers=null,this._pendingInputSources.clear();for(let e of this._models.values())e.asset?this._releaseModel(e.asset):e.load.then(t=>this._releaseModel(t),()=>{});this._models.clear()}_onXrEnd(){this._destroyAllControllers(),this._pendingInputSources.clear()}_destroyController(e){let t=this.controllers.get(e);t&&(t.entity.destroy(),this.controllers.delete(e),this.app.fire("xr:controller:remove",e))}_destroyAllControllers(){for(let e of this.controllers.keys())this._destroyController(e)}async _tryLoadProfiles(e,t,s=0){if(s>=t.length||!this._pendingInputSources.has(e))return null;let n=await this._loadProfile(e,t[s]);return n||this._tryLoadProfiles(e,t,s+1)}async _onInputSourceAdd(e){if(!e.profiles?.length){console.warn("XrControllers: No profiles available for input source");return}this._pendingInputSources.add(e);let t=await this._tryLoadProfiles(e,e.profiles);if(this._pendingInputSources.has(e))if(this._pendingInputSources.delete(e),t){let{asset:s}=t,o=s.resource.instantiateRenderEntity();this.app.root.addChild(o),o.enabled=this._visible;let r=new Map;if(e.hand)for(let a of e.hand.joints){let l=o.findByName(a.id);l&&r.set(a,l)}this.controllers.set(e,{entity:o,jointMap:r,asset:s,tracked:!0,enabledWhenTracked:!0}),this.app.fire("xr:controller:add",e,o)}else console.warn("XrControllers: No compatible profiles found for input source")}async _loadProfile(e,t){let s=`${this.basePath}/${t}/profile.json`;try{let n=await fetch(s);if(!n.ok)return null;let o=await n.json(),r=o.layouts[e.handedness]?.assetPath||"",a=`${this.basePath}/${o.profileId}/${e.handedness}${r.replace(/^\/?(left|right)/,"")}`;if(!this._pendingInputSources.has(e))return null;let l=await this._loadModel(a);return{profileId:t,asset:l}}catch{return null}}_loadModel(e){let t=this._models.get(e);if(t)return t.load;let s={load:new Promise((n,o)=>{this.app.assets.loadFromUrl(e,"container",(r,a)=>{r?o(r):n(a)})}),asset:null};return this._models.set(e,s),s.load.then(n=>{s.asset=n},()=>{this._models.get(e)===s&&this._models.delete(e)}),s.load}_releaseModel(e){let{assets:t}=this.app;t&&(t.remove(e),e.unload())}_onInputSourceRemove(e){this._pendingInputSources.delete(e),this._destroyController(e)}set visible(e){if(this._visible!==e){this._visible=e;for(let[,t]of this.controllers)t.tracked?t.entity.enabled=e:t.enabledWhenTracked=e}}get visible(){return this._visible}update(e){if(!this.app.xr?.active||!this._visible)return;let t=this.app.xr.visibilityState==="visible";for(let[s,n]of this.controllers){let o=t&&(!s.hand||s.hand.tracking);if(n.tracked!==o&&(n.tracked=o,o?n.entity.enabled=n.enabledWhenTracked:(n.enabledWhenTracked=n.entity.enabled,n.entity.enabled=!1)),!o)continue;let{entity:r,jointMap:a}=n;if(s.hand)for(let[l,c]of a)c.setPosition(l.getPosition()),c.setRotation(l.getRotation());else{let l=s.getPosition(),c=s.getRotation();l&&r.setPosition(l),c&&r.setRotation(c)}}}};var Rs=.001,As=1e-4,bt=new x,_t=new x,jn=new x,Ie=new x,kt=new x,Ke=new x,Qe=new x,Me=new x,Ts=new Q,Ds=new Q,zs=(i,e)=>{let t=Math.cos(e),s=Math.sin(e),n=i.x*t+i.z*s;return i.z=-i.x*s+i.z*t,i.x=n,i},Wn=i=>(i%=Math.PI*2,i>Math.PI?i-=Math.PI*2:i<=-Math.PI&&(i+=Math.PI*2),i),Fs=class extends ht{static scriptName="xrManipulation";target=null;enableTranslate=!0;enableRotate=!0;enableScale=!0;scaleThreshold=.15;scalePivot="feet";minScale=.2;maxScale=5;resetEvent="xr:manipulation:reset";_inputSources=new Set;_grabbing=!1;_leftSource=null;_rightSource=null;_grabTarget=null;_framePos=new x;_frameYaw=0;_frameScale=1;_targetPos0=new x;_targetRot0=new Q;_targetScale0=new x;_midPose0=new x;_grabDist=0;_grabHeading=null;_prevLeft=new x;_prevRight=new x;_prevTranslateEnabled=!0;_menuActive=!1;_resetEventName="";_baselineTarget=null;_initPosition=new x;_initRotation=new Q;_initScale=new x(1,1,1);initialize(){if(!this.app.xr){console.error("XrManipulation script requires XR to be enabled on the application");return}this.target||console.warn("XrManipulation: No target entity assigned. Grabbing will not work until one is set."),!this.enableTranslate&&!this.enableRotate&&!this.enableScale&&console.warn("XrManipulation: All manipulation modes are disabled. Grabbing will not work."),this._captureBaseline(this.target);let e=n=>{this._inputSources.add(n)};this.app.xr.input.on("add",e);let t=n=>{this._inputSources.delete(n),this._grabbing&&(n===this._leftSource||n===this._rightSource)&&this._endGrab()};this.app.xr.input.on("remove",t);let s=n=>{this._menuActive=!!n,this._menuActive&&this._endGrab()};this.app.on("xr:menu:active",s),this._resetEventName=this.resetEvent,this._resetEventName&&this.app.on(this._resetEventName,this.reset,this),this.once("destroy",()=>{this.app.xr.input.off("add",e),this.app.xr.input.off("remove",t),this.app.off("xr:menu:active",s),this._resetEventName&&this.app.off(this._resetEventName,this.reset,this),this._inputSources.clear(),this._endGrab()})}reset(){this._endGrab();let e=this._baselineTarget;e&&(e.setPosition(this._initPosition),e.setRotation(this._initRotation),e.setLocalScale(this._initScale))}_captureBaseline(e){this._baselineTarget=e,e&&(this._initPosition.copy(e.getPosition()),this._initRotation.copy(e.getRotation()),this._initScale.copy(e.getLocalScale()))}_hasUsablePose(e){return e.grip||!!(e.hand&&e.hand.tracking&&e.hand.wrist)}_canContinueGrab(e){return!!e&&this._inputSources.has(e)&&e.squeezing&&(e.grip||!!e.hand)}_getRigSpacePosition(e,t){if(e.grip)t.copy(e.getLocalPosition());else{t.copy(e.hand.wrist.getPosition());let s=this.app.xr.camera?.parent;if(s){let n=s.getPosition(),o=s.forward,r=Math.atan2(-o.x,-o.z),a=s.getLocalScale().x||1;t.sub(n),zs(t,-r),t.mulScalar(1/a)}}return t}_captureFrame(){let e=this.app.xr.camera?.parent;if(e){this._framePos.copy(e.getPosition());let t=e.forward;this._frameYaw=Math.atan2(-t.x,-t.z),this._frameScale=e.getLocalScale().x||1}else this._framePos.set(0,0,0),this._frameYaw=0,this._frameScale=1}_frameStale(){let e=this.app.xr.camera?.parent;if(!e)return!1;let t=e.forward,s=Math.atan2(-t.x,-t.z),n=e.getPosition(),o=n.x-this._framePos.x,r=n.y-this._framePos.y,a=n.z-this._framePos.z;return o*o+r*r+a*a>1e-12||Math.abs(Wn(s-this._frameYaw))>1e-6}_frameToWorld(e){return zs(e,this._frameYaw),e.mulScalar(this._frameScale).add(this._framePos),e}_captureGrabState(e,t){let s=this._grabTarget;this._targetPos0.copy(s.getPosition()),this._targetRot0.copy(s.getRotation()),this._targetScale0.copy(s.getLocalScale()),this._midPose0.add2(e,t).mulScalar(.5),Me.sub2(t,e),this._grabDist=Me.length();let n=Math.sqrt(Me.x*Me.x+Me.z*Me.z);this._grabHeading=n>As?Math.atan2(Me.x,Me.z):null}_startGrab(e,t,s){this._grabTarget=e,this._leftSource=t,this._rightSource=s,this._captureFrame(),this._getRigSpacePosition(t,this._prevLeft),this._getRigSpacePosition(s,this._prevRight),this._captureGrabState(this._prevLeft,this._prevRight),this._prevTranslateEnabled=this.enableTranslate,this._grabbing=!0,this.app.fire("xr:manipulation:active",!0)}_endGrab(){this._grabbing&&(this._leftSource=null,this._rightSource=null,this._grabTarget=null,this._grabbing=!1,this.app.fire("xr:manipulation:active",!1))}_applyScaleDeadZone(e){let t=Y.clamp(this.scaleThreshold,0,.9);return t<=0?e:e>1+t?e/(1+t):e<1-t?e/(1-t):1}_clampScaleFactor(e,t){let s=this._initScale.x||1,n=Y.clamp(t*e/s,this.minScale,this.maxScale);return t>0?n*s/t:1}update(e){let t=this.target;if(t!==this._baselineTarget&&this._captureBaseline(t),!this.app.xr?.active){this._endGrab();return}if(!t||this._menuActive||!this.enableTranslate&&!this.enableRotate&&!this.enableScale){this._endGrab();return}if(this._grabbing&&(t!==this._grabTarget||!this._canContinueGrab(this._leftSource)||!this._canContinueGrab(this._rightSource))&&this._endGrab(),!this._grabbing){let r=null,a=null,l=null,c=null;for(let h of this._inputSources)!h.squeezing||!this._hasUsablePose(h)||(h.handedness==="left"&&!r?r=h:h.handedness==="right"&&!a&&(a=h),l?c||(c=h):l=h);r&&a?this._startGrab(t,r,a):l&&c&&this._startGrab(t,l,c);return}this._getRigSpacePosition(this._leftSource,bt),this._getRigSpacePosition(this._rightSource,_t),jn.add2(bt,_t).mulScalar(.5),Ie.sub2(_t,bt);let s=Ie.length(),n=Math.sqrt(Ie.x*Ie.x+Ie.z*Ie.z),o=n>As?Math.atan2(Ie.x,Ie.z):null;this._frameStale()&&(this._captureFrame(),this._captureGrabState(bt,_t)),this.enableTranslate!==this._prevTranslateEnabled&&(this._captureGrabState(bt,_t),this._prevTranslateEnabled=this.enableTranslate),this.enableTranslate?this._solveAnchored(s,o):this._solveIncremental(s,n),this._prevLeft.copy(bt),this._prevRight.copy(_t)}_solveAnchored(e,t){let s=0,n=!1;this.enableRotate&&(t!==null&&this._grabHeading!==null?s=Wn(t-this._grabHeading):n=!0);let o=1,r=!1,a=!1;if(this.enableScale)if(e>Rs&&this._grabDist>Rs){let l=this._applyScaleDeadZone(e/this._grabDist);o=this._clampScaleFactor(l,this._targetScale0.x),a=o!==l}else r=!0;if(Ke.copy(this._midPose0),this._frameToWorld(Ke),Me.copy(jn),this._frameToWorld(Me),Qe.sub2(this._targetPos0,Ke),zs(Qe,s),Qe.mulScalar(o).add(Me),this.scalePivot!=="hands"){let l=this._framePos.y;Qe.y=l+o*(this._targetPos0.y-l)+(Me.y-Ke.y)}Ts.setFromEulerAngles(0,s*Y.RAD_TO_DEG,0),Ds.mul2(Ts,this._targetRot0),this._grabTarget.setPosition(Qe),this._grabTarget.setRotation(Ds),this._grabTarget.setLocalScale(this._targetScale0.x*o,this._targetScale0.y*o,this._targetScale0.z*o),(n||r||a)&&this._captureGrabState(bt,_t)}_solveIncremental(e,t){let s=this._grabTarget.getLocalScale();kt.sub2(this._prevRight,this._prevLeft);let n=Math.sqrt(kt.x*kt.x+kt.z*kt.z),o=0;this.enableRotate&&t>As&&n>As&&(o=Wn(Math.atan2(Ie.x,Ie.z)-Math.atan2(kt.x,kt.z)));let r=1;if(this.enableScale&&e>Rs&&this._grabDist>Rs&&s.x>0){let a=this._applyScaleDeadZone(e/this._grabDist);r=this._clampScaleFactor(a,this._targetScale0.x)*this._targetScale0.x/s.x}Ke.copy(jn),this._frameToWorld(Ke),this.scalePivot!=="hands"&&(Ke.y=this._framePos.y),Qe.sub2(this._grabTarget.getPosition(),Ke),zs(Qe,o),Qe.mulScalar(r).add(Ke),Ts.setFromEulerAngles(0,o*Y.RAD_TO_DEG,0),Ds.mul2(Ts,this._grabTarget.getRotation()),this._grabTarget.setPosition(Qe),this._grabTarget.setRotation(Ds),this._grabTarget.setLocalScale(s.x*r,s.y*r,s.z*r)}};var Al=9.81,Se=new yt,as=new yt,Is=new x,Gn=new x,wa=new x,Ve=new x,Mt=new x,St=new x,ba=new x,Un=new x,_a=new x,Tl=1e3,ka=`
|
|
1
|
+
import{$a as ua,A as Fn,Aa as ie,B as pe,Ba as Ss,C as In,Ca as Cs,D as Vn,Da as Ye,E as Pi,Ea as $t,F as Li,Fa as ke,G as Ue,Ga as Qi,H as oe,Ha as qn,I as ns,Ia as Ji,J as os,Ja as Ze,K as xt,L as G,La as ea,M as On,Ma as Ps,N as X,Na as ht,O as Bt,Oa as ce,P as Z,Pa as ta,Q as Ei,Qa as sa,R as Ri,Ra as na,S as lt,Sa as oa,T as is,Ta as ia,U as ze,Ua as aa,V as fe,Va as ra,W as Xe,Wa as la,X as Ai,Xa as ca,Y as q,Ya as ha,Z as Nt,Za as da,_ as ct,_a as Ls,a as Tn,aa as Ti,ab as $n,b as gi,ba as Fe,bb as pa,c as Ot,ca as Di,cb as fa,d as vi,da as zi,db as ma,e as Dn,ea as Fi,eb as ga,f as Y,fa as wt,fb as Hn,g as K,ga as Ms,gb as va,ha as Bn,hb as ya,i as x,ia as Ii,ib as xa,ja as Vi,k as yt,ka as qt,l as yi,la as Oi,m as U,ma as Bi,n as Q,na as Ni,o as xi,oa as qi,p as wi,pa as $i,q as bi,qa as Hi,r as ss,ra as ji,s as ks,sa as Wi,t as zn,ta as Gi,u as _i,ua as Nn,v as ki,va as Ui,w as Mi,wa as Xi,x as Si,xa as Yi,y as Ci,ya as Zi,z as rt,za as Ki}from"./chunk-KX25RBTZ.js";import"./chunk-LDV6YPMG.js";var Es=class extends ht{static scriptName="xrControllers";basePath="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets/dist/profiles";controllers=new Map;_pendingInputSources=new Set;_models=new Map;_visible=!0;_handlers=null;initialize(){if(!this.app.xr){console.error("XrControllers script requires XR to be enabled on the application");return}this._handlers={onAdd:this._onInputSourceAdd.bind(this),onRemove:this._onInputSourceRemove.bind(this),onXrEnd:this._onXrEnd.bind(this)},this.app.xr.input.on("add",this._handlers.onAdd),this.app.xr.input.on("remove",this._handlers.onRemove),this.app.xr.on("end",this._handlers.onXrEnd),this.once("destroy",()=>{this._onDestroy()})}_onDestroy(){this._handlers&&this.app.xr&&(this.app.xr.input.off("add",this._handlers.onAdd),this.app.xr.input.off("remove",this._handlers.onRemove),this.app.xr.off("end",this._handlers.onXrEnd)),this._destroyAllControllers(),this._handlers=null,this._pendingInputSources.clear();for(let e of this._models.values())e.asset?this._releaseModel(e.asset):e.load.then(t=>this._releaseModel(t),()=>{});this._models.clear()}_onXrEnd(){this._destroyAllControllers(),this._pendingInputSources.clear()}_destroyController(e){let t=this.controllers.get(e);t&&(t.entity.destroy(),this.controllers.delete(e),this.app.fire("xr:controller:remove",e))}_destroyAllControllers(){for(let e of this.controllers.keys())this._destroyController(e)}async _tryLoadProfiles(e,t,s=0){if(s>=t.length||!this._pendingInputSources.has(e))return null;let n=await this._loadProfile(e,t[s]);return n||this._tryLoadProfiles(e,t,s+1)}async _onInputSourceAdd(e){if(!e.profiles?.length){console.warn("XrControllers: No profiles available for input source");return}this._pendingInputSources.add(e);let t=await this._tryLoadProfiles(e,e.profiles);if(this._pendingInputSources.has(e))if(this._pendingInputSources.delete(e),t){let{asset:s}=t,o=s.resource.instantiateRenderEntity();this.app.root.addChild(o),o.enabled=this._visible;let r=new Map;if(e.hand)for(let a of e.hand.joints){let l=o.findByName(a.id);l&&r.set(a,l)}this.controllers.set(e,{entity:o,jointMap:r,asset:s,tracked:!0,enabledWhenTracked:!0}),this.app.fire("xr:controller:add",e,o)}else console.warn("XrControllers: No compatible profiles found for input source")}async _loadProfile(e,t){let s=`${this.basePath}/${t}/profile.json`;try{let n=await fetch(s);if(!n.ok)return null;let o=await n.json(),r=o.layouts[e.handedness]?.assetPath||"",a=`${this.basePath}/${o.profileId}/${e.handedness}${r.replace(/^\/?(left|right)/,"")}`;if(!this._pendingInputSources.has(e))return null;let l=await this._loadModel(a);return{profileId:t,asset:l}}catch{return null}}_loadModel(e){let t=this._models.get(e);if(t)return t.load;let s={load:new Promise((n,o)=>{this.app.assets.loadFromUrl(e,"container",(r,a)=>{r?o(r):n(a)})}),asset:null};return this._models.set(e,s),s.load.then(n=>{s.asset=n},()=>{this._models.get(e)===s&&this._models.delete(e)}),s.load}_releaseModel(e){let{assets:t}=this.app;t&&(t.remove(e),e.unload())}_onInputSourceRemove(e){this._pendingInputSources.delete(e),this._destroyController(e)}set visible(e){if(this._visible!==e){this._visible=e;for(let[,t]of this.controllers)t.tracked?t.entity.enabled=e:t.enabledWhenTracked=e}}get visible(){return this._visible}update(e){if(!this.app.xr?.active||!this._visible)return;let t=this.app.xr.visibilityState==="visible";for(let[s,n]of this.controllers){let o=t&&(!s.hand||s.hand.tracking);if(n.tracked!==o&&(n.tracked=o,o?n.entity.enabled=n.enabledWhenTracked:(n.enabledWhenTracked=n.entity.enabled,n.entity.enabled=!1)),!o)continue;let{entity:r,jointMap:a}=n;if(s.hand)for(let[l,c]of a)c.setPosition(l.getPosition()),c.setRotation(l.getRotation());else{let l=s.getPosition(),c=s.getRotation();l&&r.setPosition(l),c&&r.setRotation(c)}}}};var Rs=.001,As=1e-4,bt=new x,_t=new x,jn=new x,Ie=new x,kt=new x,Ke=new x,Qe=new x,Me=new x,Ts=new Q,Ds=new Q,zs=(i,e)=>{let t=Math.cos(e),s=Math.sin(e),n=i.x*t+i.z*s;return i.z=-i.x*s+i.z*t,i.x=n,i},Wn=i=>(i%=Math.PI*2,i>Math.PI?i-=Math.PI*2:i<=-Math.PI&&(i+=Math.PI*2),i),Fs=class extends ht{static scriptName="xrManipulation";target=null;enableTranslate=!0;enableRotate=!0;enableScale=!0;scaleThreshold=.15;scalePivot="feet";minScale=.2;maxScale=5;resetEvent="xr:manipulation:reset";_inputSources=new Set;_grabbing=!1;_leftSource=null;_rightSource=null;_grabTarget=null;_framePos=new x;_frameYaw=0;_frameScale=1;_targetPos0=new x;_targetRot0=new Q;_targetScale0=new x;_midPose0=new x;_grabDist=0;_grabHeading=null;_prevLeft=new x;_prevRight=new x;_prevTranslateEnabled=!0;_menuActive=!1;_resetEventName="";_baselineTarget=null;_initPosition=new x;_initRotation=new Q;_initScale=new x(1,1,1);initialize(){if(!this.app.xr){console.error("XrManipulation script requires XR to be enabled on the application");return}this.target||console.warn("XrManipulation: No target entity assigned. Grabbing will not work until one is set."),!this.enableTranslate&&!this.enableRotate&&!this.enableScale&&console.warn("XrManipulation: All manipulation modes are disabled. Grabbing will not work."),this._captureBaseline(this.target);let e=n=>{this._inputSources.add(n)};this.app.xr.input.on("add",e);let t=n=>{this._inputSources.delete(n),this._grabbing&&(n===this._leftSource||n===this._rightSource)&&this._endGrab()};this.app.xr.input.on("remove",t);let s=n=>{this._menuActive=!!n,this._menuActive&&this._endGrab()};this.app.on("xr:menu:active",s),this._resetEventName=this.resetEvent,this._resetEventName&&this.app.on(this._resetEventName,this.reset,this),this.once("destroy",()=>{this.app.xr.input.off("add",e),this.app.xr.input.off("remove",t),this.app.off("xr:menu:active",s),this._resetEventName&&this.app.off(this._resetEventName,this.reset,this),this._inputSources.clear(),this._endGrab()})}reset(){this._endGrab();let e=this._baselineTarget;e&&(e.setPosition(this._initPosition),e.setRotation(this._initRotation),e.setLocalScale(this._initScale))}_captureBaseline(e){this._baselineTarget=e,e&&(this._initPosition.copy(e.getPosition()),this._initRotation.copy(e.getRotation()),this._initScale.copy(e.getLocalScale()))}_hasUsablePose(e){return e.grip||!!(e.hand&&e.hand.tracking&&e.hand.wrist)}_canContinueGrab(e){return!!e&&this._inputSources.has(e)&&e.squeezing&&(e.grip||!!e.hand)}_getRigSpacePosition(e,t){if(e.grip)t.copy(e.getLocalPosition());else{t.copy(e.hand.wrist.getPosition());let s=this.app.xr.camera?.parent;if(s){let n=s.getPosition(),o=s.forward,r=Math.atan2(-o.x,-o.z),a=s.getLocalScale().x||1;t.sub(n),zs(t,-r),t.mulScalar(1/a)}}return t}_captureFrame(){let e=this.app.xr.camera?.parent;if(e){this._framePos.copy(e.getPosition());let t=e.forward;this._frameYaw=Math.atan2(-t.x,-t.z),this._frameScale=e.getLocalScale().x||1}else this._framePos.set(0,0,0),this._frameYaw=0,this._frameScale=1}_frameStale(){let e=this.app.xr.camera?.parent;if(!e)return!1;let t=e.forward,s=Math.atan2(-t.x,-t.z),n=e.getPosition(),o=n.x-this._framePos.x,r=n.y-this._framePos.y,a=n.z-this._framePos.z;return o*o+r*r+a*a>1e-12||Math.abs(Wn(s-this._frameYaw))>1e-6}_frameToWorld(e){return zs(e,this._frameYaw),e.mulScalar(this._frameScale).add(this._framePos),e}_captureGrabState(e,t){let s=this._grabTarget;this._targetPos0.copy(s.getPosition()),this._targetRot0.copy(s.getRotation()),this._targetScale0.copy(s.getLocalScale()),this._midPose0.add2(e,t).mulScalar(.5),Me.sub2(t,e),this._grabDist=Me.length();let n=Math.sqrt(Me.x*Me.x+Me.z*Me.z);this._grabHeading=n>As?Math.atan2(Me.x,Me.z):null}_startGrab(e,t,s){this._grabTarget=e,this._leftSource=t,this._rightSource=s,this._captureFrame(),this._getRigSpacePosition(t,this._prevLeft),this._getRigSpacePosition(s,this._prevRight),this._captureGrabState(this._prevLeft,this._prevRight),this._prevTranslateEnabled=this.enableTranslate,this._grabbing=!0,this.app.fire("xr:manipulation:active",!0)}_endGrab(){this._grabbing&&(this._leftSource=null,this._rightSource=null,this._grabTarget=null,this._grabbing=!1,this.app.fire("xr:manipulation:active",!1))}_applyScaleDeadZone(e){let t=Y.clamp(this.scaleThreshold,0,.9);return t<=0?e:e>1+t?e/(1+t):e<1-t?e/(1-t):1}_clampScaleFactor(e,t){let s=this._initScale.x||1,n=Y.clamp(t*e/s,this.minScale,this.maxScale);return t>0?n*s/t:1}update(e){let t=this.target;if(t!==this._baselineTarget&&this._captureBaseline(t),!this.app.xr?.active){this._endGrab();return}if(!t||this._menuActive||!this.enableTranslate&&!this.enableRotate&&!this.enableScale){this._endGrab();return}if(this._grabbing&&(t!==this._grabTarget||!this._canContinueGrab(this._leftSource)||!this._canContinueGrab(this._rightSource))&&this._endGrab(),!this._grabbing){let r=null,a=null,l=null,c=null;for(let h of this._inputSources)!h.squeezing||!this._hasUsablePose(h)||(h.handedness==="left"&&!r?r=h:h.handedness==="right"&&!a&&(a=h),l?c||(c=h):l=h);r&&a?this._startGrab(t,r,a):l&&c&&this._startGrab(t,l,c);return}this._getRigSpacePosition(this._leftSource,bt),this._getRigSpacePosition(this._rightSource,_t),jn.add2(bt,_t).mulScalar(.5),Ie.sub2(_t,bt);let s=Ie.length(),n=Math.sqrt(Ie.x*Ie.x+Ie.z*Ie.z),o=n>As?Math.atan2(Ie.x,Ie.z):null;this._frameStale()&&(this._captureFrame(),this._captureGrabState(bt,_t)),this.enableTranslate!==this._prevTranslateEnabled&&(this._captureGrabState(bt,_t),this._prevTranslateEnabled=this.enableTranslate),this.enableTranslate?this._solveAnchored(s,o):this._solveIncremental(s,n),this._prevLeft.copy(bt),this._prevRight.copy(_t)}_solveAnchored(e,t){let s=0,n=!1;this.enableRotate&&(t!==null&&this._grabHeading!==null?s=Wn(t-this._grabHeading):n=!0);let o=1,r=!1,a=!1;if(this.enableScale)if(e>Rs&&this._grabDist>Rs){let l=this._applyScaleDeadZone(e/this._grabDist);o=this._clampScaleFactor(l,this._targetScale0.x),a=o!==l}else r=!0;if(Ke.copy(this._midPose0),this._frameToWorld(Ke),Me.copy(jn),this._frameToWorld(Me),Qe.sub2(this._targetPos0,Ke),zs(Qe,s),Qe.mulScalar(o).add(Me),this.scalePivot!=="hands"){let l=this._framePos.y;Qe.y=l+o*(this._targetPos0.y-l)+(Me.y-Ke.y)}Ts.setFromEulerAngles(0,s*Y.RAD_TO_DEG,0),Ds.mul2(Ts,this._targetRot0),this._grabTarget.setPosition(Qe),this._grabTarget.setRotation(Ds),this._grabTarget.setLocalScale(this._targetScale0.x*o,this._targetScale0.y*o,this._targetScale0.z*o),(n||r||a)&&this._captureGrabState(bt,_t)}_solveIncremental(e,t){let s=this._grabTarget.getLocalScale();kt.sub2(this._prevRight,this._prevLeft);let n=Math.sqrt(kt.x*kt.x+kt.z*kt.z),o=0;this.enableRotate&&t>As&&n>As&&(o=Wn(Math.atan2(Ie.x,Ie.z)-Math.atan2(kt.x,kt.z)));let r=1;if(this.enableScale&&e>Rs&&this._grabDist>Rs&&s.x>0){let a=this._applyScaleDeadZone(e/this._grabDist);r=this._clampScaleFactor(a,this._targetScale0.x)*this._targetScale0.x/s.x}Ke.copy(jn),this._frameToWorld(Ke),this.scalePivot!=="hands"&&(Ke.y=this._framePos.y),Qe.sub2(this._grabTarget.getPosition(),Ke),zs(Qe,o),Qe.mulScalar(r).add(Ke),Ts.setFromEulerAngles(0,o*Y.RAD_TO_DEG,0),Ds.mul2(Ts,this._grabTarget.getRotation()),this._grabTarget.setPosition(Qe),this._grabTarget.setRotation(Ds),this._grabTarget.setLocalScale(s.x*r,s.y*r,s.z*r)}};var Al=9.81,Se=new yt,as=new yt,Is=new x,Gn=new x,wa=new x,Ve=new x,Mt=new x,St=new x,ba=new x,Un=new x,_a=new x,Tl=1e3,ka=`
|
|
2
2
|
attribute vec3 vertex_position;
|
|
3
3
|
attribute vec2 aUv0;
|
|
4
4
|
|
|
@@ -2701,4 +2701,4 @@ vec3 prepareOutputFromGamma(vec3 gammaColor, float depth) {
|
|
|
2701
2701
|
fn prepareOutputFromGamma(gammaColor: vec3f, depth: f32) -> vec3f {
|
|
2702
2702
|
return gammaColor;
|
|
2703
2703
|
}
|
|
2704
|
-
`,Qd={webgl:Xi,webgpu:Yi},rn={mobile:{low:1,high:2},desktop:{low:2,high:4}},Jd=1,Lr=5,Er=90,Rr={none:Wi,linear:Bi,filmic:Ni,hejl:qi,aces:$i,aces2:Hi,neutral:ji},eu=(i,e)=>{e.sharpness.enabled?i.rendering.sharpness=e.sharpness.amount:i.rendering.sharpness=0;let{bloom:t}=i;e.bloom.enabled?(t.intensity=e.bloom.intensity,t.blurLevel=e.bloom.blurLevel):t.intensity=0;let{grading:s}=i;e.grading.enabled?(s.enabled=!0,s.brightness=e.grading.brightness,s.contrast=e.grading.contrast,s.saturation=e.grading.saturation,s.tint=new K().fromArray(e.grading.tint)):s.enabled=!1;let{vignette:n}=i;e.vignette.enabled?(n.intensity=e.vignette.intensity,n.inner=e.vignette.inner,n.outer=e.vignette.outer,n.curvature=e.vignette.curvature):n.intensity=0;let{fringing:o}=i;e.fringing.enabled?o.intensity=e.fringing.intensity:o.intensity=0},tu=i=>i.sharpness.enabled&&i.sharpness.amount>0||i.bloom.enabled&&i.bloom.intensity>0||i.grading.enabled||i.vignette.enabled&&i.vignette.intensity>0||i.fringing.enabled&&i.fringing.intensity>0,Ar=new x,sl=Xe.prototype.isColorBufferSrgb,cn=new Set,su=function(i){return cn.has(this.device)&&this===this.device.backBuffer?!0:sl.call(this,i)},eo=(i,e)=>{e?cn.add(i):cn.delete(i),Xe.prototype.isColorBufferSrgb=cn.size?su:sl},Zo=class{global;cameraFrame;inputController;cameraManager;picker;voxelOverlay=null;meshOverlay=null;navCursor=null;debugPanel=null;splatRenderer=null;miniStats=null;destroyed=!1;disposers=[];fullscreen;xr;capture=null;captureQueue=Promise.resolve();ready;failReady;abortHandlers=new Set;origChunks;constructor(e,t,s,n){this.global=e;let{app:o,settings:r,config:a,events:l,state:c,camera:h,renderer:d}=e,{graphicsDevice:u}=o;this.fullscreen=rd(e),this.xr=Yd(e),this.ready=new Promise((_,R)=>{l.once("firstFrame",()=>_()),this.failReady=R}),this.ready.catch(()=>{});let p=ie.get(u,"glsl");p.set("skyboxPS",an(p.get("skyboxPS"),"mapRoughnessUv(uv, mipLevel)","uv","glsl skyboxPS"));let g=ie.get(u,"wgsl");if(g.set("skyboxPS",an(g.get("skyboxPS"),"mapRoughnessUv(uv, uniform.mipLevel)","uv","wgsl skyboxPS")),this.origChunks={glsl:{gsplatOutputVS:p.get("gsplatOutputVS"),skyboxPS:p.get("skyboxPS")},wgsl:{gsplatOutputVS:g.get("gsplatOutputVS"),skyboxPS:g.get("skyboxPS")}},o.autoRender=!0,this.configureCamera(r),a.stochastic&&d==="webgpu"){let _=o.scene.layers.getLayerByName("World"),R=(a.budget&&a.budget>0?a.budget:(Ot.mobile?rn.mobile:rn.desktop).high)*1e6;bn.cacheFits(o.graphicsDevice,R)?_&&(this.splatRenderer=new bn(o,h.camera,_,{source:a.splatSource,variant:a.variant}),l.once("firstFrame",()=>l.fire("splatRenderer:ready",this.splatRenderer))):console.warn(`stochastic renderer: a ${R/1e6}M splat budget exceeds this device's storage binding limit; the sorted renderer draws`)}let m=l.on("xrMode:changed",()=>{this.destroyed||(this.configureCamera(r),this.splatRenderer?.setEnabled(c.xrMode===null))});this.onDestroy(()=>m.off()),this.setMiniStats(a.ministats),this.onDestroy(()=>{this.miniStats?.destroy(),this.miniStats=null});let f=new U,v=new U,y=new xi;o.on("framerender",()=>{let _=h.getWorldTransform(),R=h.camera.projectionMatrix;o.renderNextFrame||(this.miniStats?.enabled||!Aa(_.data,v.data)||!Aa(R.data,f.data))&&(o.renderNextFrame=!0),o.renderNextFrame&&(v.copy(_),f.copy(R))});let k=_=>{let R=e.camera;R.setPosition(_.position),R.setEulerAngles(_.angles),R.camera.fov=_.fov,R.camera.horizontalFov=u.width>u.height;let L=y.halfExtents.length();Ar.sub2(y.center,_.position);let M=Ar.dot(R.forward),T=Math.max(M+L,.01),V=Math.max(M-L,T/(1024*16));R.camera.farClip=T,R.camera.nearClip=Math.min(1,V)};o.on("update",_=>{o.xr.active||this.inputController&&this.cameraManager&&(this.inputController.update(_,this.cameraManager.camera.distance),this.cameraManager.update(_,this.inputController.frame),k(this.cameraManager.camera))}),o.on("prerender",()=>{this.voxelOverlay?.update()}),l.on("firstFrame",()=>{c.animationPaused=!!a.noanim,c.loaded=!0,a.exposeGlobals&&(window.scrubTo=async _=>{this.seek(_),c.animationPaused=!0;let R,L=new Promise(M=>{R=M,o.once("frameend",R)});try{await this.untilDestroyed(L)}finally{o.off("frameend",R)}},window.animationDuration=c.animationDuration,window.app=o,window.captureFrame=_=>this.captureFrame(_))});let{gsplat:w}=o.scene;w.lodUpdateAngle=Er,w.lodBehindPenalty=Lr,w.minContribution=1,w.alphaClip=1/255,w.antiAlias=a.aa,w.radialSorting=!0,w.debug=a.colorize?Ki:Zi;let P=()=>{};a.fullload||t.then(_=>{if(this.destroyed)return;let R=_.gsplat,M=R.resource?.octree?.lodLevels;M&&(R.lodRangeMax=R.lodRangeMin=M-1)},P);let S;t.then(()=>{if(this.destroyed)return;let _=o.systems.gsplat,R=0,L=0,M=(T,V,B,I)=>{L+=Math.max(0,R-I),R=I;let C=L+I;C>0&&(c.progress=Math.max(c.progress,Math.min(99,Math.trunc(L/C*100))))};_.on("frame:ready",M),S=()=>_.off("frame:ready",M),this.onDestroy(S)},P);let b=null,z;n?.then(_=>{this.destroyed||!_||(b=_,z?.(_))},P),Promise.all([t,s]).then(_=>{if(this.destroyed)return;let R=_[0].gsplat;this.xr.setManipulationTarget(_[0]);let L=R.customAabb;L&&y.setFromTransformedAabb(L,_[0].getWorldTransform()),this.picker=this.splatRenderer?new $o(o,h,this.splatRenderer):new Po(o,h),l.fire("picker:ready",this.picker),this.inputController=new Oo(e,this.picker),this.cameraManager=new So(e,y),k(this.cameraManager.camera),a.ui&&(this.navCursor=new qo(o,h,null,l,c,a.reticle)),z=C=>{if(this.inputController.collision=C,this.cameraManager.setCollision(C),this.navCursor&&(this.navCursor.collision=C),c.hasCollision=!0,c.walkAllowed=Mo(y,C),C instanceof hs&&d!=="webgl"){let A=D=>{D&&!this.voxelOverlay&&(this.voxelOverlay=new Xo(o,C,h),this.voxelOverlay.mode=a.heatmap?"heatmap":"overlay"),this.voxelOverlay&&(this.voxelOverlay.enabled=D),o.renderNextFrame=!0};l.on("collisionOverlayEnabled:changed",A),c.hasCollisionOverlay=!0,A(c.collisionOverlayEnabled)}else C instanceof un&&(this.meshOverlay=new Bo(o,C,h,!!this.cameraFrame),c.hasCollisionOverlay=!0,l.on("collisionOverlayEnabled:changed",A=>{this.meshOverlay.enabled=A,o.renderNextFrame=!0}));o.renderNextFrame=!0},b&&z(b),this.debugPanel=new Eo(e,this.cameraManager,this.picker,this.splatRenderer,{shown:()=>!!this.miniStats?.enabled,show:C=>this.setMiniStats(C)});let M=()=>{let C=()=>{if(a.budget!==void 0&&Number.isFinite(a.budget)&&a.budget>0)return a.budget;if(Yo&&c.xrMode!==null)return Jd;let A=Ot.mobile?rn.mobile:rn.desktop;return c.performanceMode?A.low:A.high};w.splatBudget=C()*1e6,w.colorUpdateAngle=c.performanceMode?1:.2,w.lodBehindPenalty=c.xrMode===null?Lr:1,w.lodUpdateAngle=c.xrMode===null?Er:0,R.lodRangeMin=0,R.lodRangeMax=1e3,o.renderNextFrame=!0};a.fullload&&M();let T=o.systems.gsplat;T.on("frame:request",()=>{o.renderNextFrame=!0});let B=!(R.resource?.octree??null),I=(C,A,D,O)=>{(O>0||o.stats.frame.gsplats>0)&&(B=!0),D&&O===0&&B&&(T.off("frame:ready",I),S?.(),c.progress=100,o.autoRender=!1,l.on("performanceMode:changed",M),l.on("xrMode:changed",M),M(),this.splatRenderer||(w.renderer=Qd[d]),o.once("frameend",()=>{l.fire("firstFrame"),window.firstFrame?.()}))};T.on("frame:ready",I)},P)}requireAlive(e){if(this.destroyed)throw new Error(`${e}: the viewer has been destroyed`)}requireLoaded(e){if(this.requireAlive(e),!this.global.state.loaded)throw new Error(`${e}: the viewer is not loaded`)}frameScene(){this.requireLoaded("frameScene"),this.global.events.fire("inputEvent","frame")}resetCamera(){this.requireLoaded("resetCamera"),this.global.events.fire("inputEvent","reset")}toggleWalk(){this.requireLoaded("toggleWalk"),this.global.events.fire("inputEvent","toggleWalk")}selectAnnotation(e){this.requireLoaded("selectAnnotation");let{settings:t,state:s,app:n}=this.global;if(e!==null){if(!Number.isInteger(e)||e<0||e>=t.annotations.length)throw new RangeError("selectAnnotation: index must be an integer in range or null");this.cameraManager.selectAnnotation(t.annotations[e])}s.selectedAnnotation=e,n.renderNextFrame=!0}setMoveInput(e,t){if(this.requireLoaded("setMoveInput"),!Number.isFinite(e)||!Number.isFinite(t))throw new Error("setMoveInput: axes must be finite numbers");this.inputController.setMoveInput(Math.max(-1,Math.min(1,e)),Math.max(-1,Math.min(1,t)))}async requestFullscreen(){return this.requireAlive("requestFullscreen"),this.untilDestroyed(this.fullscreen.request())}async exitFullscreen(){return this.requireAlive("exitFullscreen"),this.untilDestroyed(this.fullscreen.exit())}async startXR(e){return this.requireLoaded("startXR"),this.xr.start(e)}async endXR(){return this.requireAlive("endXR"),this.xr.end()}seek(e){this.requireLoaded("seek");let{state:t,app:s}=this.global;if(!t.hasAnimation)throw new Error("seek: no animation track");if(!Number.isFinite(e))throw new Error("seek: time must be finite");this.cameraManager.seek(e),s.renderNextFrame=!0}captureFrame({time:e,width:t=480,height:s=t,supersample:n}={}){let o=async()=>{if(await this.ready,this.destroyed)throw new Error("captureFrame: the viewer has been destroyed");let{app:a,camera:l,state:c}=this.global;this.capture||(this.capture=new Co(a,l.camera,()=>this.cameraFrame??null));let h=this.capture.grab({time:e,width:t,height:s,supersample:n,scrub:d=>{c.hasAnimation&&(c.animationPaused=!0,this.seek(d))}});return this.untilDestroyed(h)},r=this.captureQueue.then(o,o);return this.captureQueue=r.then(()=>{},()=>{}),r}untilDestroyed(e){let t,s=new Promise((n,o)=>{t=o});return this.abortHandlers.add(t),Promise.race([e,s]).finally(()=>{this.abortHandlers.delete(t)})}onDestroy(e){if(this.destroyed){e();return}this.disposers.push(e)}setMiniStats(e){if(e===!!this.miniStats?.enabled)return;if(this.miniStats){if(this.miniStats.enabled=e,this.miniStats.div.style.display=e?"":"none",e){let s=this.miniStats.activeSizeIndex;this.miniStats.activeSizeIndex=s,this.global.app.renderNextFrame=!0}return}let t=$n.getDefaultOptions();t.cpu.enabled=!1,t.stats=t.stats.filter(s=>s.name!=="DrawCalls"),t.stats.push({name:"VRAM",stats:["vram.tex"],decimalPlaces:1,multiplier:1/(1024*1024),unitsName:"MB",watermark:1024},{name:"Splats",stats:["frame.gsplats"],decimalPlaces:3,multiplier:1/1e6,unitsName:"M",watermark:5}),this.miniStats=new $n(this.global.app,t),this.global.app.renderNextFrame=!0}destroy(){if(this.destroyed)return;this.destroyed=!0;let e=()=>new Error("the viewer has been destroyed");this.failReady(e());for(let r of this.abortHandlers)r(e());this.abortHandlers.clear();let{app:t}=this.global;this.fullscreen.destroy(),this.xr.destroy(),this.debugPanel?.destroy(),this.navCursor?.destroy(),this.inputController?.destroy(),this.voxelOverlay?.destroy(),this.meshOverlay?.destroy(),this.picker?.release(),this.splatRenderer?.destroy(),this.splatRenderer=null,this.capture?.destroy(),this.capture=null,this.cameraFrame&&(this.cameraFrame.destroy(),this.cameraFrame=null),eo(t.graphicsDevice,!1);for(let r of this.disposers.reverse())r();this.disposers.length=0,window.app===t&&(delete window.app,delete window.scrubTo,delete window.captureFrame,delete window.animationDuration);let s=t.graphicsDevice,n=s.gl??null,o=s.wgpu??null;t.destroy(),n?.getExtension("WEBGL_lose_context")?.loseContext(),o?.destroy(),this.global.root.remove()}configureCamera(e){let{global:t}=this,{app:s,config:n,camera:o,state:r}=t,{postEffectSettings:a}=e,{background:l}=e,c=n.hpr??e.highPrecisionRendering,h=!n.nofx&&(tu(a)||c);if(r.xrMode===null&&h){this.cameraFrame||(this.cameraFrame=new pa(s,o.camera));let{cameraFrame:p}=this;p.enabled=!0,p.rendering.toneMapping=Rr[e.tonemapping],p.rendering.renderFormats=c?[ks,zn]:[],eu(p,a),p.update(),ie.get(s.graphicsDevice,"glsl").set("gsplatOutputVS",Zd),ie.get(s.graphicsDevice,"wgsl").set("gsplatOutputVS",Kd),ie.get(s.graphicsDevice,"glsl").set("skyboxPS",an(this.origChunks.glsl.skyboxPS,"gammaCorrectOutput(toneMap(processEnvironment(linear)))","pow(toneMap(processEnvironment(linear)) + 0.0000001, vec3(1.0 / 2.2))","glsl skyboxPS gamma override")),ie.get(s.graphicsDevice,"wgsl").set("skyboxPS",an(this.origChunks.wgsl.skyboxPS,"gammaCorrectOutput(toneMap(processEnvironment(linear)))","pow(toneMap(processEnvironment(linear)) + 0.0000001, vec3f(1.0 / 2.2))","wgsl skyboxPS gamma override")),eo(s.graphicsDevice,!0),o.camera.clearColor=new K(l.color)}else this.cameraFrame&&(this.cameraFrame.destroy(),this.cameraFrame=null),ie.get(s.graphicsDevice,"glsl").set("gsplatOutputVS",this.origChunks.glsl.gsplatOutputVS),ie.get(s.graphicsDevice,"wgsl").set("gsplatOutputVS",this.origChunks.wgsl.gsplatOutputVS),ie.get(s.graphicsDevice,"glsl").set("skyboxPS",this.origChunks.glsl.skyboxPS),ie.get(s.graphicsDevice,"wgsl").set("skyboxPS",this.origChunks.wgsl.skyboxPS),eo(s.graphicsDevice,!1),o.camera.toneMapping=Rr[e.tonemapping],o.camera.clearColor=r.xrMode==="ar"?new K(0,0,0,0):new K(l.color);let u=s.scene.layers.getLayerById(Ii);u&&(u.enabled=r.xrMode!=="ar"),this.meshOverlay?.setCameraFrameEnabled(!!this.cameraFrame)}},nl=(i,e)=>e||new URL(i,location.href).pathname.split("/").pop(),nu=(i,e)=>nl(i,e)?.toLowerCase()!=="lod-meta.json",ou=async(i,e,t,s)=>{let{contents:n,contentUrl:o,contentFilename:r}=e,a=n,l=nl(o,r),c=l.toLowerCase()==="meta.json"?await(await n).json():void 0;if(s())throw new Error("loadGsplat: the viewer was destroyed while loading");let h=new Ps(l,"gsplat",{url:o,filename:l,contents:a},c);return new Promise((d,u)=>{h.on("load",()=>{let g=new ce("gsplat",i);g.setLocalEulerAngles(0,0,180),g.addComponent("gsplat",{unified:!0,asset:h}),i.root.addChild(g),d(g)});let p=0;h.on("progress",(g,m)=>{let f=Math.min(1,g/m)*100;f>p&&(p=f,t(Math.trunc(p)))}),h.on("error",g=>{console.log(g),u(g)}),i.assets.add(h),i.assets.load(h)})},iu=(i,e)=>new Promise((t,s)=>{let n=new Ps("skybox","texture",{url:e},{type:"rgbp",mipmaps:!1,addressu:"repeat",addressv:"clamp"});n.on("load",()=>{t(n)}),n.on("error",o=>{console.log(o),s(o)}),i.assets.add(n),i.assets.load(n)}),au=async(i,e)=>{let t=e.renderer==="webgpu",s=await Ti(i,{deviceTypes:t?["webgpu"]:[],antialias:!1,depth:!0,stencil:!1,xrCompatible:!0,powerPreference:"high-performance"});console.log(`Renderer: ${s.deviceType}`);let n=s.deviceType==="webgpu"?"webgpu":"webgl";s.maxPixelRatio=window.devicePixelRatio;let o=new to(i,{graphicsDevice:s,mouse:new zi(i),touch:new Fi(i),keyboard:new Di(window)});e.stochastic&&n==="webgpu"&&(o.scene.gsplatCentersEnabled=!1),o.loader.getHandler("texture").imgParser.crossOrigin="anonymous";let r=new ce("camera root",o);o.root.addChild(r);let a=new ce("camera",o);r.addChild(a);let l=new ce("light",o);return l.setEulerAngles(35,45,0),l.addComponent("light",{color:new K(1,.98,.957),intensity:1}),o.root.addChild(l),o.scene.ambientLight.set(.51,.55,.65),{app:o,camera:a,renderer:n}},ol=i=>({width:i.clientWidth,height:i.clientHeight}),il=(i,e,t)=>{if(!e.width||!e.height)return;let s=Ot.mobile?1080:2160,o=Math.min(s/Math.min(screen.width,screen.height),window.devicePixelRatio)*(t?.5:1),r=Math.ceil(e.width*o),a=Math.ceil(e.height*o);(r!==i.width||a!==i.height)&&(i.width=r,i.height=a)},ru=i=>{let{app:e,events:t,state:s}=i,{canvas:n}=e.graphicsDevice,o=ol(n),r=()=>{e.xr?.active||il(n,o,s.performanceMode)},a=new ResizeObserver(l=>{let c=l[0]?.contentBoxSize?.[0];c&&c.inlineSize&&c.blockSize&&(o.width=c.inlineSize,o.height=c.blockSize,e.renderNextFrame=!0)});return a.observe(n),t.on("performanceMode:changed",()=>{e.renderNextFrame=!0}),e.on("framerender",r),e._allowResize=!1,r(),()=>a.disconnect()},lu=i=>{let e=new Image;return e.src=i,e},cu=i=>({contentUrl:i.contentUrl,contentFilename:i.contentFilename,posterUrl:i.posterUrl,skyboxUrl:i.skyboxUrl,collisionUrl:i.collisionUrl,poster:i.poster??(i.posterUrl?lu(i.posterUrl):void 0),contents:i.contents??(nu(i.contentUrl,i.contentFilename)?fetch(i.contentUrl):void 0),renderer:i.renderer??"webgpu",ui:i.ui??!0,reticle:i.reticle??!1,noanim:i.noanim??!1,nofx:i.nofx??!1,hpr:i.hpr,ministats:i.ministats??!1,colorize:i.colorize??!1,fullload:i.fullload??!1,aa:i.aa??!1,stochastic:i.stochastic??!1,splatSource:i.splatSource??"workbuffer",variant:i.variant??"",budget:i.budget,heatmap:i.heatmap??!1,debug:i.debug??!1,lang:i.lang,exposeGlobals:i.exposeGlobals??!1}),al=async i=>{let{container:e}=i,t=cu(i),s=document.createElement("div");s.className="sse-viewer",t.ui?s.innerHTML=jc:s.appendChild(document.createElement("canvas")),e.appendChild(s);let n=s.querySelector("canvas"),o=new vi;t.poster&&t.ui&&qc(s,t.poster,o);let r=typeof i.settings=="string"?await(await fetch(i.settings)).json():await i.settings,a=hc(Ot.mobile);il(n,ol(n),a.performanceMode);let{app:l,camera:c,renderer:h}=await au(n,t),d=cc(t.lang,s),u=Ql(o,{loaded:!1,...a,progress:0,inputMode:Ot.mobile?"touch":"desktop",cameraMode:"orbit",hasAnimation:!1,animationDuration:0,animationTime:0,animationPaused:!0,hasAR:!1,hasVR:!1,canStartAR:!1,canStartVR:!1,xrMode:null,hasCollision:!1,hasCollisionOverlay:!1,walkAllowed:!1,collisionOverlayEnabled:!1,isFullscreen:!1,controlsHidden:!1,selectedAnnotation:null,inputEnabled:!0}),p={app:l,settings:gc(r),config:t,state:u,events:o,camera:c,renderer:h,root:s,localize:d},g=ru(p);l.start(),c.addComponent("camera");let m=!1,f=ou(l,t,b=>{u.progress=b},()=>m),v=t.skyboxUrl&&iu(l,t.skyboxUrl).then(b=>{l.scene.envAtlas=b.resource}).catch(b=>{console.warn("Failed to load skybox:",b)}),y;t.collisionUrl&&(new URL(t.collisionUrl,location.href).pathname.split(".").pop()?.toLowerCase()==="glb"?y=un.fromGlb(l,t.collisionUrl).catch(z=>(console.warn("Failed to load mesh collision:",z),null)):y=Kl(t.collisionUrl).catch(z=>(console.warn("Failed to load voxel data:",z),null)));let k;if(p.settings.soundUrl){let b=new Audio(p.settings.soundUrl);b.crossOrigin="anonymous";let z=()=>{b&&b.play()};s.addEventListener("click",z,{capture:!0,once:!0}),k=()=>{s.removeEventListener("click",z,{capture:!0}),b.pause()}}let w=new Zo(p,f,v,y);w.onDestroy(dc(o));let P={app:l,state:u,events:o,annotations:p.settings.annotations,captureFrame:b=>w.captureFrame(b),seek:b=>w.seek(b),frameScene:()=>w.frameScene(),resetCamera:()=>w.resetCamera(),toggleWalk:()=>w.toggleWalk(),selectAnnotation:b=>w.selectAnnotation(b),setMoveInput:(b,z)=>w.setMoveInput(b,z),requestFullscreen:()=>w.requestFullscreen(),exitFullscreen:()=>w.exitFullscreen(),startXR:b=>w.startXR(b),endXR:()=>w.endXR(),destroy:()=>w.destroy(),cameraManager:()=>w.cameraManager},S=t.ui?Hc(p,P,()=>w.picker,()=>w.cameraManager?.transitionProgress()??1):null;return w.onDestroy(()=>{m=!0}),w.onDestroy(g),S&&w.onDestroy(S),k&&w.onDestroy(k),P};console.log(`SuperSplat Viewer v${zr} | Engine v${Tn} (${gi})`);var hu=Object.freeze([0,0,0]),du="linear",rl=85,uu=(i="environment")=>i==="environment"?{position:[0,2,0],target:[2,2,0],fov:rl}:{position:[2,2,-2],target:[0,0,0],fov:rl},pu=()=>({sharpness:{enabled:!1,amount:0},bloom:{enabled:!1,intensity:.1,blurLevel:2},grading:{enabled:!1,brightness:1,contrast:1,saturation:1,tint:[1,1,1]},vignette:{enabled:!1,intensity:.5,inner:.3,outer:.75,curvature:1},fringing:{enabled:!1,intensity:.5}}),ll=(i="environment")=>({version:2,tonemapping:du,highPrecisionRendering:!1,background:{color:[...hu]},postEffectSettings:pu(),animTracks:[],cameras:[{initial:uu(i)}],annotations:[],startMode:"default"});var fs=i=>(i!==null&&typeof i=="object"&&(Object.values(i).forEach(fs),Object.freeze(i)),i),ep=fs({min:10,max:120,step:1}),tp=fs({sharpness:{amount:{min:0,max:1,step:.01}},bloom:{intensity:{min:0,max:.1,step:.01},blurLevel:{min:1,max:16,step:1}},grading:{brightness:{min:0,max:3,step:.01},contrast:{min:.5,max:1.5,step:.01},saturation:{min:0,max:2,step:.01}},vignette:{intensity:{min:0,max:1,step:.01},inner:{min:0,max:3,step:.01},outer:{min:0,max:3,step:.01},curvature:{min:.01,max:10,step:.01}},fringing:{intensity:{min:0,max:100,step:1}}}),sp=fs({duration:{min:.1,max:600},frameRate:{min:1,max:120},smoothness:{min:0,max:1},maxKeyframes:1e3,nameMax:120,maxTracks:10}),np=fs({maxCount:25,titleMax:60,textMax:280});var ot=null;function ii(){if(ot!==null)return ot;let i=16,e=document.createElement("canvas").getContext("webgl2");if(!e||!e.getExtension("EXT_color_buffer_float"))return ot=!0,ot;let t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),e.texStorage2D(e.TEXTURE_2D,1,e.RGBA16F,i,i),e.bindFramebuffer(e.FRAMEBUFFER,e.createFramebuffer()),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),e.enable(e.SCISSOR_TEST);let s=4,n=(r,a)=>[(r+1)/32,(a+1)/32,(r+a+1)/64,.5];for(let r=0;r<i;r+=s)for(let a=0;a<i;a+=s)e.scissor(a,r,s,s),e.clearColor(...n(a,r)),e.clear(e.COLOR_BUFFER_BIT);let o=new Float32Array(i*i*4);e.readPixels(0,0,i,i,e.RGBA,e.FLOAT,o),ot=!0;for(let r=0;r<i&&ot;r++)for(let a=0;a<i&&ot;a++)ot=n(a-a%s,r-r%s).every((c,h)=>Math.abs(o[(r*i+a)*4+h]-c)<.001);return ot}var oi=[4,8,16,32,48],fu=6,cl=48,mu=.05,ms=class{constructor(e,t){this.app=e;this.camera=t}soundness=new WeakMap;toldUnsound=!1;pick(e,t){return Promise.resolve(this.find(e,t,!1)?.position??null)}pickSurface(e,t){return Promise.resolve(this.find(e,t,!0))}drawn(){let e=this.app.renderer.gsplatDirector,t=this.app.scene.layers.getLayerByName("World"),s=e?.camerasMap.get(this.camera.camera?.camera)?.layersMap.get(t)?.gsplatManager?.world,o=(s?.getState(s.lastWorldStateVersion)?.splats??[]).filter(a=>a.resource?.centers),r=o.filter(a=>this.sound(a.resource.centers,a.resource.aabb));return o.length>0&&r.length===0&&!this.toldUnsound&&(this.toldUnsound=!0,console.warn("[splat viewer] the splats' centres are scrambled as well, read back from the graphics card the same way:","nothing can be found under the pointer in this browser, short of turning its protection against fingerprinting off for this site.")),r.map(a=>({centres:a.resource.centers,ranges:a.intervals.length>0?a.intervals:[0,a.resource.numSplats],world:a.node.getWorldTransform()}))}sound(e,t){let s=this.soundness.get(e);if(s===void 0){if(!t)s=!0;else{let n=t.getMin(),o=t.getMax(),r=t.halfExtents.length()*.05,a=e.length/3,l=Math.max(1,Math.floor(a/256)),c=0,h=0;for(let d=0;d<a;d+=l){c++;let u=e[d*3],p=e[d*3+1],g=e[d*3+2];u>=n.x-r&&u<=o.x+r&&p>=n.y-r&&p<=o.y+r&&g>=n.z-r&&g<=o.z+r&&h++}s=h>=c*.95}this.soundness.set(e,s)}return s}find(e,t,s){let n=this.camera.camera,o=this.app.graphicsDevice.canvas,r=o.clientWidth,a=o.clientHeight;if(!n||!r||!a)return null;let l=new U().mul2(n.projectionMatrix,n.viewMatrix),c=e*2-1,h=1-t*2,d=s?cl:oi[oi.length-1],u=n.nearClip,p=[],g=new U;for(let{centres:_,ranges:R,world:L}of this.drawn()){let M=g.mul2(l,L).data,T=L.data;for(let V=0;V<R.length;V+=2){let B=Math.min(R[V+1],_.length/3);for(let I=R[V];I<B;I++){let C=_[I*3],A=_[I*3+1],D=_[I*3+2],O=M[3]*C+M[7]*A+M[11]*D+M[15];if(O<=u)continue;let H=((M[0]*C+M[4]*A+M[8]*D+M[12])/O-c)*r/2;if(H>d||H<-d)continue;let N=((M[1]*C+M[5]*A+M[9]*D+M[13])/O-h)*a/2,E=H*H+N*N;E<=d*d&&p.push({depth:O,pixels2:E,x:T[0]*C+T[4]*A+T[8]*D+T[12],y:T[1]*C+T[5]*A+T[9]*D+T[13],z:T[2]*C+T[6]*A+T[10]*D+T[14]})}}}let m=[];for(let _ of oi)if(m=p.filter(R=>R.pixels2<=_*_).map(R=>R.depth),m.length>=fu)break;if(m.length===0)return null;let f=gu(m.sort((_,R)=>_-R)),v=this.camera.getPosition(),y=this.camera.forward,k=(_,R)=>{let L=n.screenToWorld(_,R,1,new x).sub(v).normalize();return L.mulScalar(f/L.dot(y)).add(v)},w=k(e*r,t*a);if(!s)return{position:w,normal:new x};let P=k(e*r+1,t*a).distance(w)*(cl/2),S=p.filter(_=>(_.x-w.x)**2+(_.y-w.y)**2+(_.z-w.z)**2<=P*P),b=vu(S)??new x,z=new x().sub2(v,w);return b.lengthSq()===0?b.copy(z):b.dot(z)<0&&b.mulScalar(-1),{position:w,normal:b.normalize()}}};function gu(i){let e=Math.min(i.length,3);for(let t=0;t<i.length;t++){let s=t;for(;s+1<i.length&&i[s+1]<=i[t]*(1+mu);)s++;if(s-t+1>=e)return i[t+s>>1]}return i[0]}function vu(i){if(i.length<5)return null;let e=0,t=0,s=0;for(let g of i)e+=g.x,t+=g.y,s+=g.z;e/=i.length,t/=i.length,s/=i.length;let n=0,o=0,r=0,a=0,l=0,c=0;for(let g of i){let m=g.x-e,f=g.y-t,v=g.z-s;n+=m*m,o+=m*f,r+=m*v,a+=f*f,l+=f*v,c+=v*v}let h=a*c-l*l,d=n*c-r*r,u=n*a-o*o,p=Math.max(h,d,u);return p<=0?null:p===h?new x(h,r*l-o*c,o*l-r*a):p===d?new x(r*l-o*c,d,o*r-l*n):new x(o*l-r*a,o*r-l*n,u)}xa();var hl=document.getElementById("viewer"),Kt=document.getElementById("tags"),we=document.getElementById("placing"),ws=new URLSearchParams(window.location.search);for(let[i,e]of[["accent","--app-accent"],["background","--app-background"]]){let t=ws.get(i);t&&document.documentElement.style.setProperty(e,t)}var be=null,Zt=0,Sn="-y";function xe(i){window.parent.postMessage(i,window.location.origin)}window.addEventListener("message",i=>{if(i.origin!==window.location.origin||i.source!==window.parent)return;let e=i.data;if(e?.type==="load")gl(e.url,e.fileName,e.up??null).catch(t=>{console.error("Splat viewer: could not load",e.fileName,t),xe({type:"error",message:t?.message??String(t)})});else if(e?.type==="tags")wl(e.tags,e.alignment??null);else if(e?.type==="goToTag")Fu(e.id);else if(e?.type==="mode")Pu(e.mode);else if(e?.type==="placing")_s(e.on);else if(e?.type==="calibration")_l(e.calibration);else if(e?.type==="cancel-load")wu();else if(e?.type==="measuring")Vu(e.on);else if(e?.type==="measurement")Ou(e.measurement);else if(e?.type==="snapshot"){let{id:t}=e;Rl().catch(s=>(console.error("[splat viewer] could not take the picture.",s),null)).then(s=>xe({type:"snapshot",id:t,image:s}))}else e?.type==="signed"&&(ui.get(e.id)?.(e.url),ui.delete(e.id))});var dl="https://splat.invalid/",ui=new Map,yu=0;function xu(i){return new Promise((e,t)=>{let s=++yu;ui.set(s,n=>n?e(n):t(new Error(`No link to ${i}`))),xe({type:"sign",id:s,file:i})})}var ul=window.fetch.bind(window);window.fetch=(i,e)=>{let t=typeof i=="string"?i:i instanceof URL?i.href:i.url;if(!t.startsWith(dl))return ul(i,e);let s=decodeURIComponent(t.slice(dl.length).split(/[?#]/)[0]);return xu(s).then(n=>ul(n,e))};var pl=!1;async function gl(i,e,t){if(pl){location.reload();return}pl=!0;let s=++Zt;be?.destroy(),be=null,zt=null,Ge=!1,_s(!1),hl.replaceChildren(),Sn=t??"-y",xe({type:"progress",fraction:0});let n=i,o=e;if(/\.(spz|splat|ksplat)$/i.test(e)){let c=new Uint8Array(await(await fetch(i)).arrayBuffer()),{toCompressedPly:h}=await import("./converter-SLBB5MHG.js"),d=await h(c,e);if(s!==Zt)return;n=URL.createObjectURL(d),o="scene.compressed.ply"}let r=ll();r.background.color=[...bu()];let a=await al({container:hl,settings:r,contentUrl:n,contentFilename:o,renderer:ws.has("webgl")?"webgl":void 0,lang:ws.get("lang")??void 0});if(s!==Zt){a.destroy();return}be=a,Cu(a),a.events.on("picker:ready",c=>{if(s!==Zt)return;let h=Ft();h&&Lu(c,new ms(a.app,h.entity),a.app.graphicsDevice.isWebGL2),zt=c}),a.events.on("progress:changed",c=>xe({type:"progress",fraction:c/100})),a.events.on("cameraMode:changed",c=>{xe({type:"mode",mode:c==="fly"||c==="walk"?"walk":"orbit"})});let l=()=>{if(s!==Zt)return;ku();let c=a.app.graphicsDevice;console.info("[splat viewer] loaded:",c.deviceType,`${c.width}x${c.height} drawn,`,`${c.canvas.clientWidth}x${c.canvas.clientHeight} on the page, pixel ratio ${window.devicePixelRatio},`,`WebGL read-back ${ii()?"faithful":"SCRAMBLED"}`),xe({type:"loaded",kind:"splats",count:null,up:Sn}),a.app.on("frameend",es),es()};a.state.loaded?l():a.events.once("loaded:changed",l)}function wu(){Zt++,location.reload()}function bu(){let[,i,e,t,s]=getComputedStyle(document.body).backgroundColor.match(/rgba?\((\d+), (\d+), (\d+)(?:, ([\d.]+))?\)/)??[];return i===void 0||s==="0"?[224/255,247/255,255/255]:[Number(i)/255,Number(e)/255,Number(t)/255]}function vt(){return be?.app.root.findByName("gsplat")??null}function _u(i){let e=new x;e[i.replace("-","")]=i.startsWith("-")?-1:1;let t=e.dot(x.UP);if(t>.9999)return new Q;if(t<-.9999)return new Q().setFromAxisAngle(x.BACK,180);let s=new x().cross(e,x.UP).normalize();return new Q().setFromAxisAngle(s,Math.acos(t)*(180/Math.PI))}function ku(){let i=vt();i&&Sn!=="-y"&&(i.setLocalRotation(_u(Sn)),be?.frameScene())}var Mu=1.4,Su=Math.cos(Math.PI/180*40);function Cu(i){let e=i.events,t=e.fire.bind(e),s=null,n=()=>{s&&(s=null,t("navTarget:clear"))};e.fire=(o,...r)=>{let[a,l]=r,c=i.cameraManager?.();if(o==="navigateTo"&&i.state.cameraMode==="fly"&&c&&a&&l&&l.clone().normalize().y>=Su){n();let h=c.camera,d=a.clone().add(new x(0,Mu,0)),u=h.position.distance(d);return s={pitch:h.angles.x,yaw:h.angles.y,from:h.position.clone(),to:d,time:0,duration:Math.min(2,Math.max(.6,.5+u*.15)),last:h.position.clone(),lastPitch:h.angles.x},t("navTarget:set",a,l),e}return(o==="navigateTo"||o==="navigateCancel")&&n(),t(o,...r)},i.app.on("update",o=>{let r=i.cameraManager?.();if(!s||!r)return;let a=r.camera;if(i.state.cameraMode!=="fly"||a.position.distance(s.last)>.001||Math.abs(a.angles.x-s.lastPitch)>.01||Math.abs(a.angles.y-s.yaw)>.01){n();return}s.time=Math.min(1,s.time+o/s.duration);let l=s.time*s.time*(3-2*s.time);a.position.lerp(s.from,s.to,l),a.angles.set(s.pitch*(1-l),s.yaw,0),r.snap(),s.last.copy(a.position),s.lastPitch=a.angles.x,s.time>=1&&n()})}function Pu(i){be?.state.loaded&&(be.state.cameraMode=i==="walk"?be.state.walkAllowed?"walk":"fly":"orbit")}var zt=null;function Lu(i,e,t){if(t&&!ii()||ws.has("centres")){i.pick=(a,l)=>e.pick(a,l),i.pickSurface=(a,l)=>e.pickSurface(a,l),console.warn("[splat viewer] the spot under the pointer is found from the splats' centres:",ws.has("centres")?"asked to.":"this browser scrambles what WebGL reads back (protection against fingerprinting).");return}let s=i.pick,n=i.pickSurface,o=!1,r=a=>(a&&!o&&(o=!0,console.warn("[splat viewer] the graphics card found nothing under the pointer, the splats' centres did: they are used where it finds nothing.")),a);i.pick=async(a,l)=>await s(a,l)??r(await e.pick(a,l)),i.pickSurface=async(a,l)=>await n(a,l)??r(await e.pickSurface(a,l))}var vl=Math.PI/180,Eu=Math.cos(vl*25),Ru=Math.sin(vl*20);function Au(i){let e=i.clone().normalize();return Math.abs(e.y)>=Eu?new x(0,Math.sign(e.y),0):Math.abs(e.y)<=Ru?(e.y=0,e.normalize()):e}var fl=!1;async function yl(i,e){if(!zt||!vt())return null;let t=we.getBoundingClientRect(),s=(i-t.left)/t.width,n=(e-t.top)/t.height;if(!fl)try{let o=await zt.pickSurface(s,n);return o?{position:o.position.clone(),normal:Au(o.normal)}:null}catch(o){fl=!0,console.error("[splat viewer] finding the surface under the pointer failed; the point alone is used.",o)}try{let o=await zt.pick(s,n);return o?{position:o.clone(),normal:x.UP.clone()}:null}catch(o){return console.error("[splat viewer] finding the point under the pointer failed.",o),null}}var se={element:document.createElement("div"),disc:document.createElement("div"),stem:document.createElementNS("http://www.w3.org/2000/svg","line")};se.element.className="tag ghost";se.disc.className="disc";se.element.appendChild(se.disc);se.stem.classList.add("ghost");var Ee=null;function _s(i){i&&we.style.display!=="block"&&(Qt.nothing=!1,Qt.hidden=!1),we.style.display=i?"block":"none",we.classList.remove("missed"),i&&!se.element.parentNode&&(Kt.appendChild(se.element),Jt.appendChild(se.stem)),Ee=null,Ln()}var ys=null,ai=!1;async function xl(){if(ai||!ys)return;ai=!0;let i=ys;ys=null;try{if(Ee=await yl(i.x,i.y),we.classList.toggle("missed",!Ee),!Ee&&!Qt.nothing){Qt.nothing=!0;let e=we.getBoundingClientRect();console.warn("[splat viewer] nothing found under the pointer at",i,"over",`${e.width}x${e.height}`,"- picker",zt?"ready":"NOT READY","- model",vt()?"in":"NOT IN")}Ln()}finally{ai=!1}xl()}we.addEventListener("mousemove",i=>{ys={x:i.clientX,y:i.clientY},xl()});we.addEventListener("mouseleave",()=>{ys=null,Ee=null,Ln()});we.addEventListener("click",async i=>{let e=vt(),t=await yl(i.clientX,i.clientY);if(!e||!t){we.classList.add("missed");return}let s=e.getWorldTransform().clone().invert(),n=s.transformPoint(t.position,new x),o=s.transformVector(t.normal,new x).normalize();if(Ge){xe({type:"measure-point",position:{x:n.x,y:n.y,z:n.z}});return}_s(!1),xe({type:"picked",position:{x:n.x,y:n.y,z:n.z},normal:{x:o.x,y:o.y,z:o.z}})});window.addEventListener("keydown",i=>{i.key==="Escape"&&we.style.display==="block"?(Ge=!1,_s(!1),xe({type:"placing-cancelled"})):at&&(i.key==="Backspace"||(i.ctrlKey||i.metaKey)&&!i.shiftKey&&i.key.toLowerCase()==="z")&&(i.preventDefault(),xe({type:"calibration-undo"}))});function Ln(){let i=Ft(),t=!!Ee&&!!i&&we.style.display==="block"&&(at||Ge?Sl(se.element,Ee.position,i)&&ye(se.stem):bl(se.element,se.stem,Ee.position,Ee.normal,i));$u(t&&Ge?Ee.position:null),t||(se.element.style.display="none",se.stem.style.display="none",Ee&&i&&we.style.display==="block"&&!Qt.hidden&&(Qt.hidden=!0,console.warn("[splat viewer] the ghost is found but cannot be drawn:",Tu(Ee.position,i))))}var Qt={nothing:!1,hidden:!1};function Tu(i,e){let t=e.entity.getPosition(),s=new x().sub2(i,t).dot(e.entity.forward),n=e.worldToScreen(i,new x);return`spot (${i.x.toFixed(2)}, ${i.y.toFixed(2)}, ${i.z.toFixed(2)}), ${s.toFixed(3)} ahead of the camera (near clip ${e.nearClip.toFixed(3)}), on screen at (${n.x.toFixed(0)}, ${n.y.toFixed(0)})`}var Du=.3,Jt=document.getElementById("stems"),it=new Map,Cn=new U;function zu(i){if(!i)return new U;let e=180/Math.PI,t=new Q().setFromAxisAngle(x.RIGHT,i.rotation.x*e).mul(new Q().setFromAxisAngle(x.UP,i.rotation.y*e)).mul(new Q().setFromAxisAngle(x.BACK,i.rotation.z*e));return new U().setTRS(new x(i.translation.x,i.translation.y,i.translation.z),t,new x(i.scale,i.scale,i.scale))}function wl(i,e){Cn=zu(e);let t=new Set(i.map(s=>s.id));it.forEach((s,n)=>{t.has(n)||(s.element.remove(),s.stem.remove(),it.delete(n))}),i.forEach(s=>{let n=it.get(s.id);if(!n){let o=document.createElement("div");o.className="tag";let r=document.createElement("button");r.type="button",r.className="disc",r.addEventListener("click",c=>{c.stopPropagation(),xe({type:"tagClick",id:s.id})});let a=document.createElement("div");a.className="bubble",o.append(a,r),Kt.appendChild(o);let l=document.createElementNS("http://www.w3.org/2000/svg","line");Jt.appendChild(l),n={tag:s,element:o,disc:r,bubble:a,stem:l,spot:null},it.set(s.id,n)}n.tag=s,n.bubble.textContent=s.label??"",n.disc.setAttribute("aria-label",s.label??""),n.disc.style.backgroundColor=s.color??"#1E88E5",n.disc.style.backgroundImage=s.iconUrl?`url("${s.iconUrl}")`:"none"}),Ml(),es()}var ri=new x,_n=new x,kn=new x,gt=new x,li=new x,gs=new x,pi=new x;function Ft(){return be?.app.root.findComponents("camera")[0]}function bl(i,e,t,s,n){let o=n.entity.getPosition(),r=n.entity.forward,a=l=>pi.sub2(l,o).dot(r)>n.nearClip;return _n.copy(s).normalize().mulScalar(Du).add(t),!a(t)||!a(_n)?!1:(n.worldToScreen(t,li),n.worldToScreen(_n,gs),e.style.display="",e.setAttribute("x1",String(li.x)),e.setAttribute("y1",String(li.y)),e.setAttribute("x2",String(gs.x)),e.setAttribute("y2",String(gs.y)),i.style.display="block",i.style.transform=`translate(${gs.x}px, ${gs.y}px)`,i.style.zIndex=String(Math.max(1,1e6-Math.round(pi.sub2(_n,o).length()*100))),!0)}function es(){let i=vt(),e=Ft();it.forEach(t=>{let{tag:s,element:n,stem:o}=t,r=!1;if(i&&e){let a=i.getWorldTransform();kn.set(s.position.x,s.position.y,s.position.z),s.inModelFrame||Cn.transformPoint(kn,kn),a.transformPoint(kn,ri),s.normal&&(gt.set(s.normal.x,s.normal.y,s.normal.z),s.inModelFrame||Cn.transformVector(gt,gt),a.transformVector(gt,gt)),(!s.normal||gt.lengthSq()===0)&>.copy(x.UP),r=bl(n,o,ri,gt,e),t.spot=r?(t.spot??new x).copy(ri):null}r||(n.style.display="none",o.style.display="none")}),Iu(),qu(),Ln()}function Fu(i){let e=it.get(i)?.element;e&&(e.classList.remove("pointed"),e.offsetWidth,e.classList.add("pointed"))}var at=null,Dt=[],ci=new x,xs=new x,hi=new x;function _l(i){at=i;let e=i?.pairs.length??0;for(;Dt.length>e;){let t=Dt.pop();t.element.remove(),t.link.remove()}for(;Dt.length<e;){let t=document.createElement("div");t.className="pin";let s=document.createElementNS("http://www.w3.org/2000/svg","line");s.classList.add("link"),Kt.appendChild(t),Jt.insertBefore(s,Jt.firstChild),Dt.push({element:t,link:s})}Dt.forEach((t,s)=>{t.element.textContent=String(s+1)}),kl(),Ml(),es()}function kl(){se.element.classList.toggle("pin-ghost",!!at&&!Ge),se.element.classList.toggle("measure-ghost",Ge),se.disc.textContent=at&&!Ge?String(at.pairs.length+1):""}function Ml(){let i=new Set(at?.pairs.map(e=>e.tagId));it.forEach((e,t)=>{e.element.classList.toggle("matched",i.has(t)),e.stem.classList.toggle("matched",i.has(t)),e.element.classList.toggle("selected",at?.selected===t)})}function bs(i,e){return pi.sub2(e,i.entity.getPosition()).dot(i.entity.forward)>i.nearClip}function Sl(i,e,t){return bs(t,e)?(t.worldToScreen(e,xs),i.style.display="block",i.style.transform=`translate(${xs.x}px, ${xs.y}px)`,!0):!1}function ye(i){return i.style.display="none",!0}function Iu(){let i=vt(),e=Ft();Dt.forEach((t,s)=>{let n=at?.pairs[s];if(!n||!i||!e){ye(t.element),ye(t.link);return}if(i.getWorldTransform().transformPoint(ci.set(n.target.x,n.target.y,n.target.z),ci),!Sl(t.element,ci,e)){ye(t.element),ye(t.link);return}let o=it.get(n.tagId)?.spot;if(!o||!bs(e,o)){ye(t.link);return}e.worldToScreen(o,hi),t.link.style.display="",t.link.setAttribute("x1",String(hi.x)),t.link.setAttribute("y1",String(hi.y)),t.link.setAttribute("x2",String(xs.x)),t.link.setAttribute("y2",String(xs.y))})}var ts=null,Ge=!1,Cl=[],Pl=[],Pn=[],Re={line:document.createElementNS("http://www.w3.org/2000/svg","line"),label:document.createElement("div")};Re.line.classList.add("measure","rubber");Re.label.className="measure-label rubber";function Vu(i){i!==Ge&&(Ge=i,kl(),_s(i))}function Ou(i){ts=i;let e=i?.points.length??0,t=Math.max(0,e-1);di(Cl,e,()=>{let s=document.createElement("div");return s.className="measure-point",Kt.appendChild(s)}),di(Pl,t,()=>{let s=document.createElementNS("http://www.w3.org/2000/svg","line");return s.classList.add("measure"),Jt.appendChild(s)}),di(Pn,t,()=>{let s=document.createElement("div");return s.className="measure-label",Kt.appendChild(s)}),Pn.forEach((s,n)=>{s.textContent=`${(i?.distances[n]??0).toFixed(2)} m`}),Re.line.parentNode||(Jt.appendChild(Re.line),Kt.appendChild(Re.label)),es()}function di(i,e,t){for(;i.length>e;)i.pop().remove();for(;i.length<e;)i.push(t())}var Bu=[],Nu=[],vs=new x,Mn=new x;function Ll(i){let e=vt();return!e||!ts?[]:ts.points.map((t,s)=>{let n=Bu[s]??=new x;return e.getWorldTransform().transformPoint(n.set(t.x,t.y,t.z),n),bs(i,n)?i.worldToScreen(n,Nu[s]??=new x):null})}function El(i,e,t){i.style.display="",i.setAttribute("x1",String(e.x)),i.setAttribute("y1",String(e.y)),i.setAttribute("x2",String(t.x)),i.setAttribute("y2",String(t.y))}function fi(i,e,t){i.style.display="block",i.style.transform=`translate(${e}px, ${t}px) translate(-50%, -50%)`}function qu(){let i=Ft(),e=i?Ll(i):[];Cl.forEach((t,s)=>{let n=e[s];n?fi(t,n.x,n.y):ye(t)}),Pl.forEach((t,s)=>{let n=e[s],o=e[s+1];n&&o?(El(t,n,o),fi(Pn[s],(n.x+o.x)/2,(n.y+o.y)/2)):(ye(t),ye(Pn[s]))})}function $u(i){let e=Ft(),t=vt(),s=ts?.points[ts.points.length-1];if(!i||!e||!t||!s||!bs(e,i)){ye(Re.line),ye(Re.label);return}if(t.getWorldTransform().transformPoint(vs.set(s.x,s.y,s.z),vs),!bs(e,vs)){ye(Re.line),ye(Re.label);return}let n=t.getWorldTransform().getScale(new x).x,o=vs.distance(i)/n/(Cn.getScale(new x).x||1),r=e.worldToScreen(vs,new x);e.worldToScreen(i,Mn),El(Re.line,r,Mn),Re.label.textContent=`${o.toFixed(2)} m`,fi(Re.label,(r.x+Mn.x)/2,(r.y+Mn.y)/2)}async function Rl(){let i=Ft();if(!be?.state.loaded||!i)return null;let e=be.app.graphicsDevice.canvas,t=Math.min(1,800/e.clientWidth,600/e.clientHeight),s=Math.max(1,Math.round(e.clientWidth*t)),n=Math.max(1,Math.round(e.clientHeight*t)),o=await be.captureFrame({width:s,height:n}),r=document.createElement("canvas");r.width=s,r.height=n;let a=r.getContext("2d"),l=Uint8ClampedArray.from(atob(o.data),h=>h.charCodeAt(0));a.putImageData(new ImageData(l,s,n),0,0);let c=Ll(i).map(h=>h&&{x:h.x*t,y:h.y*t});return a.lineWidth=3,a.strokeStyle=ml,c.forEach((h,d)=>{let u=c[d-1];u&&h&&(a.beginPath(),a.moveTo(u.x,u.y),a.lineTo(h.x,h.y),a.stroke())}),c.forEach(h=>{h&&(a.beginPath(),a.arc(h.x,h.y,6,0,Math.PI*2),a.fillStyle=ml,a.fill(),a.lineWidth=2,a.strokeStyle="#fff",a.stroke())}),a.font="bold 13px sans-serif",a.textAlign="center",a.textBaseline="middle",c.forEach((h,d)=>{let u=c[d-1];if(u&&h){let p=`${(ts?.distances[d-1]??0).toFixed(2)} m`,g=(u.x+h.x)/2,m=(u.y+h.y)/2,f=a.measureText(p).width+16;a.fillStyle="rgba(0, 0, 0, 0.78)",a.beginPath(),a.roundRect(g-f/2,m-12,f,24,9),a.fill(),a.fillStyle="#fff",a.fillText(p,g,m+1)}}),r.toDataURL("image/jpeg",.85)}var ml="#FFB103";window.__splatViewer={viewer:()=>be,picker:()=>zt,CentresPicker:ms,load:gl,setTags:wl,setCalibration:_l,markers:it,pins:Dt,placeTags:es,snapshot:Rl};xe({type:"ready"});
|
|
2704
|
+
`,Qd={webgl:Xi,webgpu:Yi},rn={mobile:{low:1,high:2},desktop:{low:2,high:4}},Jd=1,Lr=5,Er=90,Rr={none:Wi,linear:Bi,filmic:Ni,hejl:qi,aces:$i,aces2:Hi,neutral:ji},eu=(i,e)=>{e.sharpness.enabled?i.rendering.sharpness=e.sharpness.amount:i.rendering.sharpness=0;let{bloom:t}=i;e.bloom.enabled?(t.intensity=e.bloom.intensity,t.blurLevel=e.bloom.blurLevel):t.intensity=0;let{grading:s}=i;e.grading.enabled?(s.enabled=!0,s.brightness=e.grading.brightness,s.contrast=e.grading.contrast,s.saturation=e.grading.saturation,s.tint=new K().fromArray(e.grading.tint)):s.enabled=!1;let{vignette:n}=i;e.vignette.enabled?(n.intensity=e.vignette.intensity,n.inner=e.vignette.inner,n.outer=e.vignette.outer,n.curvature=e.vignette.curvature):n.intensity=0;let{fringing:o}=i;e.fringing.enabled?o.intensity=e.fringing.intensity:o.intensity=0},tu=i=>i.sharpness.enabled&&i.sharpness.amount>0||i.bloom.enabled&&i.bloom.intensity>0||i.grading.enabled||i.vignette.enabled&&i.vignette.intensity>0||i.fringing.enabled&&i.fringing.intensity>0,Ar=new x,sl=Xe.prototype.isColorBufferSrgb,cn=new Set,su=function(i){return cn.has(this.device)&&this===this.device.backBuffer?!0:sl.call(this,i)},eo=(i,e)=>{e?cn.add(i):cn.delete(i),Xe.prototype.isColorBufferSrgb=cn.size?su:sl},Zo=class{global;cameraFrame;inputController;cameraManager;picker;voxelOverlay=null;meshOverlay=null;navCursor=null;debugPanel=null;splatRenderer=null;miniStats=null;destroyed=!1;disposers=[];fullscreen;xr;capture=null;captureQueue=Promise.resolve();ready;failReady;abortHandlers=new Set;origChunks;constructor(e,t,s,n){this.global=e;let{app:o,settings:r,config:a,events:l,state:c,camera:h,renderer:d}=e,{graphicsDevice:u}=o;this.fullscreen=rd(e),this.xr=Yd(e),this.ready=new Promise((_,R)=>{l.once("firstFrame",()=>_()),this.failReady=R}),this.ready.catch(()=>{});let p=ie.get(u,"glsl");p.set("skyboxPS",an(p.get("skyboxPS"),"mapRoughnessUv(uv, mipLevel)","uv","glsl skyboxPS"));let g=ie.get(u,"wgsl");if(g.set("skyboxPS",an(g.get("skyboxPS"),"mapRoughnessUv(uv, uniform.mipLevel)","uv","wgsl skyboxPS")),this.origChunks={glsl:{gsplatOutputVS:p.get("gsplatOutputVS"),skyboxPS:p.get("skyboxPS")},wgsl:{gsplatOutputVS:g.get("gsplatOutputVS"),skyboxPS:g.get("skyboxPS")}},o.autoRender=!0,this.configureCamera(r),a.stochastic&&d==="webgpu"){let _=o.scene.layers.getLayerByName("World"),R=(a.budget&&a.budget>0?a.budget:(Ot.mobile?rn.mobile:rn.desktop).high)*1e6;bn.cacheFits(o.graphicsDevice,R)?_&&(this.splatRenderer=new bn(o,h.camera,_,{source:a.splatSource,variant:a.variant}),l.once("firstFrame",()=>l.fire("splatRenderer:ready",this.splatRenderer))):console.warn(`stochastic renderer: a ${R/1e6}M splat budget exceeds this device's storage binding limit; the sorted renderer draws`)}let m=l.on("xrMode:changed",()=>{this.destroyed||(this.configureCamera(r),this.splatRenderer?.setEnabled(c.xrMode===null))});this.onDestroy(()=>m.off()),this.setMiniStats(a.ministats),this.onDestroy(()=>{this.miniStats?.destroy(),this.miniStats=null});let f=new U,v=new U,y=new xi;o.on("framerender",()=>{let _=h.getWorldTransform(),R=h.camera.projectionMatrix;o.renderNextFrame||(this.miniStats?.enabled||!Aa(_.data,v.data)||!Aa(R.data,f.data))&&(o.renderNextFrame=!0),o.renderNextFrame&&(v.copy(_),f.copy(R))});let k=_=>{let R=e.camera;R.setPosition(_.position),R.setEulerAngles(_.angles),R.camera.fov=_.fov,R.camera.horizontalFov=u.width>u.height;let L=y.halfExtents.length();Ar.sub2(y.center,_.position);let M=Ar.dot(R.forward),T=Math.max(M+L,.01),V=Math.max(M-L,T/(1024*16));R.camera.farClip=T,R.camera.nearClip=Math.min(1,V)};o.on("update",_=>{o.xr.active||this.inputController&&this.cameraManager&&(this.inputController.update(_,this.cameraManager.camera.distance),this.cameraManager.update(_,this.inputController.frame),k(this.cameraManager.camera))}),o.on("prerender",()=>{this.voxelOverlay?.update()}),l.on("firstFrame",()=>{c.animationPaused=!!a.noanim,c.loaded=!0,a.exposeGlobals&&(window.scrubTo=async _=>{this.seek(_),c.animationPaused=!0;let R,L=new Promise(M=>{R=M,o.once("frameend",R)});try{await this.untilDestroyed(L)}finally{o.off("frameend",R)}},window.animationDuration=c.animationDuration,window.app=o,window.captureFrame=_=>this.captureFrame(_))});let{gsplat:w}=o.scene;w.lodUpdateAngle=Er,w.lodBehindPenalty=Lr,w.minContribution=1,w.alphaClip=1/255,w.antiAlias=a.aa,w.radialSorting=!0,w.debug=a.colorize?Ki:Zi;let P=()=>{};a.fullload||t.then(_=>{if(this.destroyed)return;let R=_.gsplat,M=R.resource?.octree?.lodLevels;M&&(R.lodRangeMax=R.lodRangeMin=M-1)},P);let S;t.then(()=>{if(this.destroyed)return;let _=o.systems.gsplat,R=0,L=0,M=(T,V,B,I)=>{L+=Math.max(0,R-I),R=I;let C=L+I;C>0&&(c.progress=Math.max(c.progress,Math.min(99,Math.trunc(L/C*100))))};_.on("frame:ready",M),S=()=>_.off("frame:ready",M),this.onDestroy(S)},P);let b=null,z;n?.then(_=>{this.destroyed||!_||(b=_,z?.(_))},P),Promise.all([t,s]).then(_=>{if(this.destroyed)return;let R=_[0].gsplat;this.xr.setManipulationTarget(_[0]);let L=R.customAabb;L&&y.setFromTransformedAabb(L,_[0].getWorldTransform()),this.picker=this.splatRenderer?new $o(o,h,this.splatRenderer):new Po(o,h),l.fire("picker:ready",this.picker),this.inputController=new Oo(e,this.picker),this.cameraManager=new So(e,y),k(this.cameraManager.camera),a.ui&&(this.navCursor=new qo(o,h,null,l,c,a.reticle)),z=C=>{if(this.inputController.collision=C,this.cameraManager.setCollision(C),this.navCursor&&(this.navCursor.collision=C),c.hasCollision=!0,c.walkAllowed=Mo(y,C),C instanceof hs&&d!=="webgl"){let A=D=>{D&&!this.voxelOverlay&&(this.voxelOverlay=new Xo(o,C,h),this.voxelOverlay.mode=a.heatmap?"heatmap":"overlay"),this.voxelOverlay&&(this.voxelOverlay.enabled=D),o.renderNextFrame=!0};l.on("collisionOverlayEnabled:changed",A),c.hasCollisionOverlay=!0,A(c.collisionOverlayEnabled)}else C instanceof un&&(this.meshOverlay=new Bo(o,C,h,!!this.cameraFrame),c.hasCollisionOverlay=!0,l.on("collisionOverlayEnabled:changed",A=>{this.meshOverlay.enabled=A,o.renderNextFrame=!0}));o.renderNextFrame=!0},b&&z(b),this.debugPanel=new Eo(e,this.cameraManager,this.picker,this.splatRenderer,{shown:()=>!!this.miniStats?.enabled,show:C=>this.setMiniStats(C)});let M=()=>{let C=()=>{if(a.budget!==void 0&&Number.isFinite(a.budget)&&a.budget>0)return a.budget;if(Yo&&c.xrMode!==null)return Jd;let A=Ot.mobile?rn.mobile:rn.desktop;return c.performanceMode?A.low:A.high};w.splatBudget=C()*1e6,w.colorUpdateAngle=c.performanceMode?1:.2,w.lodBehindPenalty=c.xrMode===null?Lr:1,w.lodUpdateAngle=c.xrMode===null?Er:0,R.lodRangeMin=0,R.lodRangeMax=1e3,o.renderNextFrame=!0};a.fullload&&M();let T=o.systems.gsplat;T.on("frame:request",()=>{o.renderNextFrame=!0});let B=!(R.resource?.octree??null),I=(C,A,D,O)=>{(O>0||o.stats.frame.gsplats>0)&&(B=!0),D&&O===0&&B&&(T.off("frame:ready",I),S?.(),c.progress=100,o.autoRender=!1,l.on("performanceMode:changed",M),l.on("xrMode:changed",M),M(),this.splatRenderer||(w.renderer=Qd[d]),o.once("frameend",()=>{l.fire("firstFrame"),window.firstFrame?.()}))};T.on("frame:ready",I)},P)}requireAlive(e){if(this.destroyed)throw new Error(`${e}: the viewer has been destroyed`)}requireLoaded(e){if(this.requireAlive(e),!this.global.state.loaded)throw new Error(`${e}: the viewer is not loaded`)}frameScene(){this.requireLoaded("frameScene"),this.global.events.fire("inputEvent","frame")}resetCamera(){this.requireLoaded("resetCamera"),this.global.events.fire("inputEvent","reset")}toggleWalk(){this.requireLoaded("toggleWalk"),this.global.events.fire("inputEvent","toggleWalk")}selectAnnotation(e){this.requireLoaded("selectAnnotation");let{settings:t,state:s,app:n}=this.global;if(e!==null){if(!Number.isInteger(e)||e<0||e>=t.annotations.length)throw new RangeError("selectAnnotation: index must be an integer in range or null");this.cameraManager.selectAnnotation(t.annotations[e])}s.selectedAnnotation=e,n.renderNextFrame=!0}setMoveInput(e,t){if(this.requireLoaded("setMoveInput"),!Number.isFinite(e)||!Number.isFinite(t))throw new Error("setMoveInput: axes must be finite numbers");this.inputController.setMoveInput(Math.max(-1,Math.min(1,e)),Math.max(-1,Math.min(1,t)))}async requestFullscreen(){return this.requireAlive("requestFullscreen"),this.untilDestroyed(this.fullscreen.request())}async exitFullscreen(){return this.requireAlive("exitFullscreen"),this.untilDestroyed(this.fullscreen.exit())}async startXR(e){return this.requireLoaded("startXR"),this.xr.start(e)}async endXR(){return this.requireAlive("endXR"),this.xr.end()}seek(e){this.requireLoaded("seek");let{state:t,app:s}=this.global;if(!t.hasAnimation)throw new Error("seek: no animation track");if(!Number.isFinite(e))throw new Error("seek: time must be finite");this.cameraManager.seek(e),s.renderNextFrame=!0}captureFrame({time:e,width:t=480,height:s=t,supersample:n}={}){let o=async()=>{if(await this.ready,this.destroyed)throw new Error("captureFrame: the viewer has been destroyed");let{app:a,camera:l,state:c}=this.global;this.capture||(this.capture=new Co(a,l.camera,()=>this.cameraFrame??null));let h=this.capture.grab({time:e,width:t,height:s,supersample:n,scrub:d=>{c.hasAnimation&&(c.animationPaused=!0,this.seek(d))}});return this.untilDestroyed(h)},r=this.captureQueue.then(o,o);return this.captureQueue=r.then(()=>{},()=>{}),r}untilDestroyed(e){let t,s=new Promise((n,o)=>{t=o});return this.abortHandlers.add(t),Promise.race([e,s]).finally(()=>{this.abortHandlers.delete(t)})}onDestroy(e){if(this.destroyed){e();return}this.disposers.push(e)}setMiniStats(e){if(e===!!this.miniStats?.enabled)return;if(this.miniStats){if(this.miniStats.enabled=e,this.miniStats.div.style.display=e?"":"none",e){let s=this.miniStats.activeSizeIndex;this.miniStats.activeSizeIndex=s,this.global.app.renderNextFrame=!0}return}let t=$n.getDefaultOptions();t.cpu.enabled=!1,t.stats=t.stats.filter(s=>s.name!=="DrawCalls"),t.stats.push({name:"VRAM",stats:["vram.tex"],decimalPlaces:1,multiplier:1/(1024*1024),unitsName:"MB",watermark:1024},{name:"Splats",stats:["frame.gsplats"],decimalPlaces:3,multiplier:1/1e6,unitsName:"M",watermark:5}),this.miniStats=new $n(this.global.app,t),this.global.app.renderNextFrame=!0}destroy(){if(this.destroyed)return;this.destroyed=!0;let e=()=>new Error("the viewer has been destroyed");this.failReady(e());for(let r of this.abortHandlers)r(e());this.abortHandlers.clear();let{app:t}=this.global;this.fullscreen.destroy(),this.xr.destroy(),this.debugPanel?.destroy(),this.navCursor?.destroy(),this.inputController?.destroy(),this.voxelOverlay?.destroy(),this.meshOverlay?.destroy(),this.picker?.release(),this.splatRenderer?.destroy(),this.splatRenderer=null,this.capture?.destroy(),this.capture=null,this.cameraFrame&&(this.cameraFrame.destroy(),this.cameraFrame=null),eo(t.graphicsDevice,!1);for(let r of this.disposers.reverse())r();this.disposers.length=0,window.app===t&&(delete window.app,delete window.scrubTo,delete window.captureFrame,delete window.animationDuration);let s=t.graphicsDevice,n=s.gl??null,o=s.wgpu??null;t.destroy(),n?.getExtension("WEBGL_lose_context")?.loseContext(),o?.destroy(),this.global.root.remove()}configureCamera(e){let{global:t}=this,{app:s,config:n,camera:o,state:r}=t,{postEffectSettings:a}=e,{background:l}=e,c=n.hpr??e.highPrecisionRendering,h=!n.nofx&&(tu(a)||c);if(r.xrMode===null&&h){this.cameraFrame||(this.cameraFrame=new pa(s,o.camera));let{cameraFrame:p}=this;p.enabled=!0,p.rendering.toneMapping=Rr[e.tonemapping],p.rendering.renderFormats=c?[ks,zn]:[],eu(p,a),p.update(),ie.get(s.graphicsDevice,"glsl").set("gsplatOutputVS",Zd),ie.get(s.graphicsDevice,"wgsl").set("gsplatOutputVS",Kd),ie.get(s.graphicsDevice,"glsl").set("skyboxPS",an(this.origChunks.glsl.skyboxPS,"gammaCorrectOutput(toneMap(processEnvironment(linear)))","pow(toneMap(processEnvironment(linear)) + 0.0000001, vec3(1.0 / 2.2))","glsl skyboxPS gamma override")),ie.get(s.graphicsDevice,"wgsl").set("skyboxPS",an(this.origChunks.wgsl.skyboxPS,"gammaCorrectOutput(toneMap(processEnvironment(linear)))","pow(toneMap(processEnvironment(linear)) + 0.0000001, vec3f(1.0 / 2.2))","wgsl skyboxPS gamma override")),eo(s.graphicsDevice,!0),o.camera.clearColor=new K(l.color)}else this.cameraFrame&&(this.cameraFrame.destroy(),this.cameraFrame=null),ie.get(s.graphicsDevice,"glsl").set("gsplatOutputVS",this.origChunks.glsl.gsplatOutputVS),ie.get(s.graphicsDevice,"wgsl").set("gsplatOutputVS",this.origChunks.wgsl.gsplatOutputVS),ie.get(s.graphicsDevice,"glsl").set("skyboxPS",this.origChunks.glsl.skyboxPS),ie.get(s.graphicsDevice,"wgsl").set("skyboxPS",this.origChunks.wgsl.skyboxPS),eo(s.graphicsDevice,!1),o.camera.toneMapping=Rr[e.tonemapping],o.camera.clearColor=r.xrMode==="ar"?new K(0,0,0,0):new K(l.color);let u=s.scene.layers.getLayerById(Ii);u&&(u.enabled=r.xrMode!=="ar"),this.meshOverlay?.setCameraFrameEnabled(!!this.cameraFrame)}},nl=(i,e)=>e||new URL(i,location.href).pathname.split("/").pop(),nu=(i,e)=>nl(i,e)?.toLowerCase()!=="lod-meta.json",ou=async(i,e,t,s)=>{let{contents:n,contentUrl:o,contentFilename:r}=e,a=n,l=nl(o,r),c=l.toLowerCase()==="meta.json"?await(await n).json():void 0;if(s())throw new Error("loadGsplat: the viewer was destroyed while loading");let h=new Ps(l,"gsplat",{url:o,filename:l,contents:a},c);return new Promise((d,u)=>{h.on("load",()=>{let g=new ce("gsplat",i);g.setLocalEulerAngles(0,0,180),g.addComponent("gsplat",{unified:!0,asset:h}),i.root.addChild(g),d(g)});let p=0;h.on("progress",(g,m)=>{let f=Math.min(1,g/m)*100;f>p&&(p=f,t(Math.trunc(p)))}),h.on("error",g=>{console.log(g),u(g)}),i.assets.add(h),i.assets.load(h)})},iu=(i,e)=>new Promise((t,s)=>{let n=new Ps("skybox","texture",{url:e},{type:"rgbp",mipmaps:!1,addressu:"repeat",addressv:"clamp"});n.on("load",()=>{t(n)}),n.on("error",o=>{console.log(o),s(o)}),i.assets.add(n),i.assets.load(n)}),au=async(i,e)=>{let t=e.renderer==="webgpu",s=await Ti(i,{deviceTypes:t?["webgpu"]:[],antialias:!1,depth:!0,stencil:!1,xrCompatible:!0,powerPreference:"high-performance"});console.log(`Renderer: ${s.deviceType}`);let n=s.deviceType==="webgpu"?"webgpu":"webgl";s.maxPixelRatio=window.devicePixelRatio;let o=new to(i,{graphicsDevice:s,mouse:new zi(i),touch:new Fi(i),keyboard:new Di(window)});e.stochastic&&n==="webgpu"&&(o.scene.gsplatCentersEnabled=!1),o.loader.getHandler("texture").imgParser.crossOrigin="anonymous";let r=new ce("camera root",o);o.root.addChild(r);let a=new ce("camera",o);r.addChild(a);let l=new ce("light",o);return l.setEulerAngles(35,45,0),l.addComponent("light",{color:new K(1,.98,.957),intensity:1}),o.root.addChild(l),o.scene.ambientLight.set(.51,.55,.65),{app:o,camera:a,renderer:n}},ol=i=>({width:i.clientWidth,height:i.clientHeight}),il=(i,e,t)=>{if(!e.width||!e.height)return;let s=Ot.mobile?1080:2160,o=Math.min(s/Math.min(screen.width,screen.height),window.devicePixelRatio)*(t?.5:1),r=Math.ceil(e.width*o),a=Math.ceil(e.height*o);(r!==i.width||a!==i.height)&&(i.width=r,i.height=a)},ru=i=>{let{app:e,events:t,state:s}=i,{canvas:n}=e.graphicsDevice,o=ol(n),r=()=>{e.xr?.active||il(n,o,s.performanceMode)},a=new ResizeObserver(l=>{let c=l[0]?.contentBoxSize?.[0];c&&c.inlineSize&&c.blockSize&&(o.width=c.inlineSize,o.height=c.blockSize,e.renderNextFrame=!0)});return a.observe(n),t.on("performanceMode:changed",()=>{e.renderNextFrame=!0}),e.on("framerender",r),e._allowResize=!1,r(),()=>a.disconnect()},lu=i=>{let e=new Image;return e.src=i,e},cu=i=>({contentUrl:i.contentUrl,contentFilename:i.contentFilename,posterUrl:i.posterUrl,skyboxUrl:i.skyboxUrl,collisionUrl:i.collisionUrl,poster:i.poster??(i.posterUrl?lu(i.posterUrl):void 0),contents:i.contents??(nu(i.contentUrl,i.contentFilename)?fetch(i.contentUrl):void 0),renderer:i.renderer??"webgpu",ui:i.ui??!0,reticle:i.reticle??!1,noanim:i.noanim??!1,nofx:i.nofx??!1,hpr:i.hpr,ministats:i.ministats??!1,colorize:i.colorize??!1,fullload:i.fullload??!1,aa:i.aa??!1,stochastic:i.stochastic??!1,splatSource:i.splatSource??"workbuffer",variant:i.variant??"",budget:i.budget,heatmap:i.heatmap??!1,debug:i.debug??!1,lang:i.lang,exposeGlobals:i.exposeGlobals??!1}),al=async i=>{let{container:e}=i,t=cu(i),s=document.createElement("div");s.className="sse-viewer",t.ui?s.innerHTML=jc:s.appendChild(document.createElement("canvas")),e.appendChild(s);let n=s.querySelector("canvas"),o=new vi;t.poster&&t.ui&&qc(s,t.poster,o);let r=typeof i.settings=="string"?await(await fetch(i.settings)).json():await i.settings,a=hc(Ot.mobile);il(n,ol(n),a.performanceMode);let{app:l,camera:c,renderer:h}=await au(n,t),d=cc(t.lang,s),u=Ql(o,{loaded:!1,...a,progress:0,inputMode:Ot.mobile?"touch":"desktop",cameraMode:"orbit",hasAnimation:!1,animationDuration:0,animationTime:0,animationPaused:!0,hasAR:!1,hasVR:!1,canStartAR:!1,canStartVR:!1,xrMode:null,hasCollision:!1,hasCollisionOverlay:!1,walkAllowed:!1,collisionOverlayEnabled:!1,isFullscreen:!1,controlsHidden:!1,selectedAnnotation:null,inputEnabled:!0}),p={app:l,settings:gc(r),config:t,state:u,events:o,camera:c,renderer:h,root:s,localize:d},g=ru(p);l.start(),c.addComponent("camera");let m=!1,f=ou(l,t,b=>{u.progress=b},()=>m),v=t.skyboxUrl&&iu(l,t.skyboxUrl).then(b=>{l.scene.envAtlas=b.resource}).catch(b=>{console.warn("Failed to load skybox:",b)}),y;t.collisionUrl&&(new URL(t.collisionUrl,location.href).pathname.split(".").pop()?.toLowerCase()==="glb"?y=un.fromGlb(l,t.collisionUrl).catch(z=>(console.warn("Failed to load mesh collision:",z),null)):y=Kl(t.collisionUrl).catch(z=>(console.warn("Failed to load voxel data:",z),null)));let k;if(p.settings.soundUrl){let b=new Audio(p.settings.soundUrl);b.crossOrigin="anonymous";let z=()=>{b&&b.play()};s.addEventListener("click",z,{capture:!0,once:!0}),k=()=>{s.removeEventListener("click",z,{capture:!0}),b.pause()}}let w=new Zo(p,f,v,y);w.onDestroy(dc(o));let P={app:l,state:u,events:o,annotations:p.settings.annotations,captureFrame:b=>w.captureFrame(b),seek:b=>w.seek(b),frameScene:()=>w.frameScene(),resetCamera:()=>w.resetCamera(),toggleWalk:()=>w.toggleWalk(),selectAnnotation:b=>w.selectAnnotation(b),setMoveInput:(b,z)=>w.setMoveInput(b,z),requestFullscreen:()=>w.requestFullscreen(),exitFullscreen:()=>w.exitFullscreen(),startXR:b=>w.startXR(b),endXR:()=>w.endXR(),destroy:()=>w.destroy(),cameraManager:()=>w.cameraManager},S=t.ui?Hc(p,P,()=>w.picker,()=>w.cameraManager?.transitionProgress()??1):null;return w.onDestroy(()=>{m=!0}),w.onDestroy(g),S&&w.onDestroy(S),k&&w.onDestroy(k),P};console.log(`SuperSplat Viewer v${zr} | Engine v${Tn} (${gi})`);var hu=Object.freeze([0,0,0]),du="linear",rl=85,uu=(i="environment")=>i==="environment"?{position:[0,2,0],target:[2,2,0],fov:rl}:{position:[2,2,-2],target:[0,0,0],fov:rl},pu=()=>({sharpness:{enabled:!1,amount:0},bloom:{enabled:!1,intensity:.1,blurLevel:2},grading:{enabled:!1,brightness:1,contrast:1,saturation:1,tint:[1,1,1]},vignette:{enabled:!1,intensity:.5,inner:.3,outer:.75,curvature:1},fringing:{enabled:!1,intensity:.5}}),ll=(i="environment")=>({version:2,tonemapping:du,highPrecisionRendering:!1,background:{color:[...hu]},postEffectSettings:pu(),animTracks:[],cameras:[{initial:uu(i)}],annotations:[],startMode:"default"});var fs=i=>(i!==null&&typeof i=="object"&&(Object.values(i).forEach(fs),Object.freeze(i)),i),ep=fs({min:10,max:120,step:1}),tp=fs({sharpness:{amount:{min:0,max:1,step:.01}},bloom:{intensity:{min:0,max:.1,step:.01},blurLevel:{min:1,max:16,step:1}},grading:{brightness:{min:0,max:3,step:.01},contrast:{min:.5,max:1.5,step:.01},saturation:{min:0,max:2,step:.01}},vignette:{intensity:{min:0,max:1,step:.01},inner:{min:0,max:3,step:.01},outer:{min:0,max:3,step:.01},curvature:{min:.01,max:10,step:.01}},fringing:{intensity:{min:0,max:100,step:1}}}),sp=fs({duration:{min:.1,max:600},frameRate:{min:1,max:120},smoothness:{min:0,max:1},maxKeyframes:1e3,nameMax:120,maxTracks:10}),np=fs({maxCount:25,titleMax:60,textMax:280});var ot=null;function ii(){if(ot!==null)return ot;let i=16,e=document.createElement("canvas").getContext("webgl2");if(!e||!e.getExtension("EXT_color_buffer_float"))return ot=!0,ot;let t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),e.texStorage2D(e.TEXTURE_2D,1,e.RGBA16F,i,i),e.bindFramebuffer(e.FRAMEBUFFER,e.createFramebuffer()),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),e.enable(e.SCISSOR_TEST);let s=4,n=(r,a)=>[(r+1)/32,(a+1)/32,(r+a+1)/64,.5];for(let r=0;r<i;r+=s)for(let a=0;a<i;a+=s)e.scissor(a,r,s,s),e.clearColor(...n(a,r)),e.clear(e.COLOR_BUFFER_BIT);let o=new Float32Array(i*i*4);e.readPixels(0,0,i,i,e.RGBA,e.FLOAT,o),ot=!0;for(let r=0;r<i&&ot;r++)for(let a=0;a<i&&ot;a++)ot=n(a-a%s,r-r%s).every((c,h)=>Math.abs(o[(r*i+a)*4+h]-c)<.001);return ot}var oi=[4,8,16,32,48],fu=6,cl=48,mu=.05,ms=class{constructor(e,t){this.app=e;this.camera=t}soundness=new WeakMap;toldUnsound=!1;pick(e,t){return Promise.resolve(this.find(e,t,!1)?.position??null)}pickSurface(e,t){return Promise.resolve(this.find(e,t,!0))}drawn(){let e=this.app.renderer.gsplatDirector,t=this.app.scene.layers.getLayerByName("World"),s=e?.camerasMap.get(this.camera.camera?.camera)?.layersMap.get(t)?.gsplatManager?.world,o=(s?.getState(s.lastWorldStateVersion)?.splats??[]).filter(a=>a.resource?.centers),r=o.filter(a=>this.sound(a.resource.centers,a.resource.aabb));return o.length>0&&r.length===0&&!this.toldUnsound&&(this.toldUnsound=!0,console.warn("[splat viewer] the splats' centres are scrambled as well, read back from the graphics card the same way:","nothing can be found under the pointer in this browser, short of turning its protection against fingerprinting off for this site.")),r.map(a=>({centres:a.resource.centers,ranges:a.intervals.length>0?a.intervals:[0,a.resource.numSplats],world:a.node.getWorldTransform()}))}sound(e,t){let s=this.soundness.get(e);if(s===void 0){if(!t)s=!0;else{let n=t.getMin(),o=t.getMax(),r=t.halfExtents.length()*.05,a=e.length/3,l=Math.max(1,Math.floor(a/256)),c=0,h=0;for(let d=0;d<a;d+=l){c++;let u=e[d*3],p=e[d*3+1],g=e[d*3+2];u>=n.x-r&&u<=o.x+r&&p>=n.y-r&&p<=o.y+r&&g>=n.z-r&&g<=o.z+r&&h++}s=h>=c*.95}this.soundness.set(e,s)}return s}find(e,t,s){let n=this.camera.camera,o=this.app.graphicsDevice.canvas,r=o.clientWidth,a=o.clientHeight;if(!n||!r||!a)return null;let l=new U().mul2(n.projectionMatrix,n.viewMatrix),c=e*2-1,h=1-t*2,d=s?cl:oi[oi.length-1],u=n.nearClip,p=[],g=new U;for(let{centres:_,ranges:R,world:L}of this.drawn()){let M=g.mul2(l,L).data,T=L.data;for(let V=0;V<R.length;V+=2){let B=Math.min(R[V+1],_.length/3);for(let I=R[V];I<B;I++){let C=_[I*3],A=_[I*3+1],D=_[I*3+2],O=M[3]*C+M[7]*A+M[11]*D+M[15];if(O<=u)continue;let H=((M[0]*C+M[4]*A+M[8]*D+M[12])/O-c)*r/2;if(H>d||H<-d)continue;let N=((M[1]*C+M[5]*A+M[9]*D+M[13])/O-h)*a/2,E=H*H+N*N;E<=d*d&&p.push({depth:O,pixels2:E,x:T[0]*C+T[4]*A+T[8]*D+T[12],y:T[1]*C+T[5]*A+T[9]*D+T[13],z:T[2]*C+T[6]*A+T[10]*D+T[14]})}}}let m=[];for(let _ of oi)if(m=p.filter(R=>R.pixels2<=_*_).map(R=>R.depth),m.length>=fu)break;if(m.length===0)return null;let f=gu(m.sort((_,R)=>_-R)),v=this.camera.getPosition(),y=this.camera.forward,k=(_,R)=>{let L=n.screenToWorld(_,R,1,new x).sub(v).normalize();return L.mulScalar(f/L.dot(y)).add(v)},w=k(e*r,t*a);if(!s)return{position:w,normal:new x};let P=k(e*r+1,t*a).distance(w)*(cl/2),S=p.filter(_=>(_.x-w.x)**2+(_.y-w.y)**2+(_.z-w.z)**2<=P*P),b=vu(S)??new x,z=new x().sub2(v,w);return b.lengthSq()===0?b.copy(z):b.dot(z)<0&&b.mulScalar(-1),{position:w,normal:b.normalize()}}};function gu(i){let e=Math.min(i.length,3);for(let t=0;t<i.length;t++){let s=t;for(;s+1<i.length&&i[s+1]<=i[t]*(1+mu);)s++;if(s-t+1>=e)return i[t+s>>1]}return i[0]}function vu(i){if(i.length<5)return null;let e=0,t=0,s=0;for(let g of i)e+=g.x,t+=g.y,s+=g.z;e/=i.length,t/=i.length,s/=i.length;let n=0,o=0,r=0,a=0,l=0,c=0;for(let g of i){let m=g.x-e,f=g.y-t,v=g.z-s;n+=m*m,o+=m*f,r+=m*v,a+=f*f,l+=f*v,c+=v*v}let h=a*c-l*l,d=n*c-r*r,u=n*a-o*o,p=Math.max(h,d,u);return p<=0?null:p===h?new x(h,r*l-o*c,o*l-r*a):p===d?new x(r*l-o*c,d,o*r-l*n):new x(o*l-r*a,o*r-l*n,u)}xa();var hl=document.getElementById("viewer"),Kt=document.getElementById("tags"),we=document.getElementById("placing"),ws=new URLSearchParams(window.location.search);for(let[i,e]of[["accent","--app-accent"],["background","--app-background"]]){let t=ws.get(i);t&&document.documentElement.style.setProperty(e,t)}var be=null,Zt=0,Sn="-y";function xe(i){window.parent.postMessage(i,window.location.origin)}window.addEventListener("message",i=>{if(i.origin!==window.location.origin||i.source!==window.parent)return;let e=i.data;if(e?.type==="load")gl(e.url,e.fileName,e.up??null).catch(t=>{console.error("Splat viewer: could not load",e.fileName,t),xe({type:"error",message:t?.message??String(t)})});else if(e?.type==="tags")wl(e.tags,e.alignment??null);else if(e?.type==="goToTag")Fu(e.id);else if(e?.type==="mode")Pu(e.mode);else if(e?.type==="placing")_s(e.on);else if(e?.type==="calibration")_l(e.calibration);else if(e?.type==="cancel-load")wu();else if(e?.type==="measuring")Vu(e.on);else if(e?.type==="measurement")Ou(e.measurement);else if(e?.type==="snapshot"){let{id:t}=e;Rl().catch(s=>(console.error("[splat viewer] could not take the picture.",s),null)).then(s=>xe({type:"snapshot",id:t,image:s}))}else e?.type==="signed"&&(ui.get(e.id)?.(e.url),ui.delete(e.id))});var dl="https://splat.invalid/",ui=new Map,yu=0;function xu(i){return new Promise((e,t)=>{let s=++yu;ui.set(s,n=>n?e(n):t(new Error(`No link to ${i}`))),xe({type:"sign",id:s,file:i})})}var ul=window.fetch.bind(window);window.fetch=(i,e)=>{let t=typeof i=="string"?i:i instanceof URL?i.href:i.url;if(!t.startsWith(dl))return ul(i,e);let s=decodeURIComponent(t.slice(dl.length).split(/[?#]/)[0]);return xu(s).then(n=>ul(n,e))};var pl=!1;async function gl(i,e,t){if(pl){location.reload();return}pl=!0;let s=++Zt;be?.destroy(),be=null,zt=null,Ge=!1,_s(!1),hl.replaceChildren(),Sn=t??"-y",xe({type:"progress",fraction:0});let n=i,o=e;if(/\.(spz|splat|ksplat)$/i.test(e)){let c=new Uint8Array(await(await fetch(i)).arrayBuffer()),{toCompressedPly:h}=await import("./converter-UV7KH5KN.js"),d=await h(c,e);if(s!==Zt)return;n=URL.createObjectURL(d),o="scene.compressed.ply"}let r=ll();r.background.color=[...bu()];let a=await al({container:hl,settings:r,contentUrl:n,contentFilename:o,renderer:ws.has("webgl")?"webgl":void 0,lang:ws.get("lang")??void 0});if(s!==Zt){a.destroy();return}be=a,Cu(a),a.events.on("picker:ready",c=>{if(s!==Zt)return;let h=Ft();h&&Lu(c,new ms(a.app,h.entity),a.app.graphicsDevice.isWebGL2),zt=c}),a.events.on("progress:changed",c=>xe({type:"progress",fraction:c/100})),a.events.on("cameraMode:changed",c=>{xe({type:"mode",mode:c==="fly"||c==="walk"?"walk":"orbit"})});let l=()=>{if(s!==Zt)return;ku();let c=a.app.graphicsDevice;console.info("[splat viewer] loaded:",c.deviceType,`${c.width}x${c.height} drawn,`,`${c.canvas.clientWidth}x${c.canvas.clientHeight} on the page, pixel ratio ${window.devicePixelRatio},`,`WebGL read-back ${ii()?"faithful":"SCRAMBLED"}`),xe({type:"loaded",kind:"splats",count:null,up:Sn}),a.app.on("frameend",es),es()};a.state.loaded?l():a.events.once("loaded:changed",l)}function wu(){Zt++,location.reload()}function bu(){let[,i,e,t,s]=getComputedStyle(document.body).backgroundColor.match(/rgba?\((\d+), (\d+), (\d+)(?:, ([\d.]+))?\)/)??[];return i===void 0||s==="0"?[224/255,247/255,255/255]:[Number(i)/255,Number(e)/255,Number(t)/255]}function vt(){return be?.app.root.findByName("gsplat")??null}function _u(i){let e=new x;e[i.replace("-","")]=i.startsWith("-")?-1:1;let t=e.dot(x.UP);if(t>.9999)return new Q;if(t<-.9999)return new Q().setFromAxisAngle(x.BACK,180);let s=new x().cross(e,x.UP).normalize();return new Q().setFromAxisAngle(s,Math.acos(t)*(180/Math.PI))}function ku(){let i=vt();i&&Sn!=="-y"&&(i.setLocalRotation(_u(Sn)),be?.frameScene())}var Mu=1.4,Su=Math.cos(Math.PI/180*40);function Cu(i){let e=i.events,t=e.fire.bind(e),s=null,n=()=>{s&&(s=null,t("navTarget:clear"))};e.fire=(o,...r)=>{let[a,l]=r,c=i.cameraManager?.();if(o==="navigateTo"&&i.state.cameraMode==="fly"&&c&&a&&l&&l.clone().normalize().y>=Su){n();let h=c.camera,d=a.clone().add(new x(0,Mu,0)),u=h.position.distance(d);return s={pitch:h.angles.x,yaw:h.angles.y,from:h.position.clone(),to:d,time:0,duration:Math.min(2,Math.max(.6,.5+u*.15)),last:h.position.clone(),lastPitch:h.angles.x},t("navTarget:set",a,l),e}return(o==="navigateTo"||o==="navigateCancel")&&n(),t(o,...r)},i.app.on("update",o=>{let r=i.cameraManager?.();if(!s||!r)return;let a=r.camera;if(i.state.cameraMode!=="fly"||a.position.distance(s.last)>.001||Math.abs(a.angles.x-s.lastPitch)>.01||Math.abs(a.angles.y-s.yaw)>.01){n();return}s.time=Math.min(1,s.time+o/s.duration);let l=s.time*s.time*(3-2*s.time);a.position.lerp(s.from,s.to,l),a.angles.set(s.pitch*(1-l),s.yaw,0),r.snap(),s.last.copy(a.position),s.lastPitch=a.angles.x,s.time>=1&&n()})}function Pu(i){be?.state.loaded&&(be.state.cameraMode=i==="walk"?be.state.walkAllowed?"walk":"fly":"orbit")}var zt=null;function Lu(i,e,t){if(t&&!ii()||ws.has("centres")){i.pick=(a,l)=>e.pick(a,l),i.pickSurface=(a,l)=>e.pickSurface(a,l),console.warn("[splat viewer] the spot under the pointer is found from the splats' centres:",ws.has("centres")?"asked to.":"this browser scrambles what WebGL reads back (protection against fingerprinting).");return}let s=i.pick,n=i.pickSurface,o=!1,r=a=>(a&&!o&&(o=!0,console.warn("[splat viewer] the graphics card found nothing under the pointer, the splats' centres did: they are used where it finds nothing.")),a);i.pick=async(a,l)=>await s(a,l)??r(await e.pick(a,l)),i.pickSurface=async(a,l)=>await n(a,l)??r(await e.pickSurface(a,l))}var vl=Math.PI/180,Eu=Math.cos(vl*25),Ru=Math.sin(vl*20);function Au(i){let e=i.clone().normalize();return Math.abs(e.y)>=Eu?new x(0,Math.sign(e.y),0):Math.abs(e.y)<=Ru?(e.y=0,e.normalize()):e}var fl=!1;async function yl(i,e){if(!zt||!vt())return null;let t=we.getBoundingClientRect(),s=(i-t.left)/t.width,n=(e-t.top)/t.height;if(!fl)try{let o=await zt.pickSurface(s,n);return o?{position:o.position.clone(),normal:Au(o.normal)}:null}catch(o){fl=!0,console.error("[splat viewer] finding the surface under the pointer failed; the point alone is used.",o)}try{let o=await zt.pick(s,n);return o?{position:o.clone(),normal:x.UP.clone()}:null}catch(o){return console.error("[splat viewer] finding the point under the pointer failed.",o),null}}var se={element:document.createElement("div"),disc:document.createElement("div"),stem:document.createElementNS("http://www.w3.org/2000/svg","line")};se.element.className="tag ghost";se.disc.className="disc";se.element.appendChild(se.disc);se.stem.classList.add("ghost");var Ee=null;function _s(i){i&&we.style.display!=="block"&&(Qt.nothing=!1,Qt.hidden=!1),we.style.display=i?"block":"none",we.classList.remove("missed"),i&&!se.element.parentNode&&(Kt.appendChild(se.element),Jt.appendChild(se.stem)),Ee=null,Ln()}var ys=null,ai=!1;async function xl(){if(ai||!ys)return;ai=!0;let i=ys;ys=null;try{if(Ee=await yl(i.x,i.y),we.classList.toggle("missed",!Ee),!Ee&&!Qt.nothing){Qt.nothing=!0;let e=we.getBoundingClientRect();console.warn("[splat viewer] nothing found under the pointer at",i,"over",`${e.width}x${e.height}`,"- picker",zt?"ready":"NOT READY","- model",vt()?"in":"NOT IN")}Ln()}finally{ai=!1}xl()}we.addEventListener("mousemove",i=>{ys={x:i.clientX,y:i.clientY},xl()});we.addEventListener("mouseleave",()=>{ys=null,Ee=null,Ln()});we.addEventListener("click",async i=>{let e=vt(),t=await yl(i.clientX,i.clientY);if(!e||!t){we.classList.add("missed");return}let s=e.getWorldTransform().clone().invert(),n=s.transformPoint(t.position,new x),o=s.transformVector(t.normal,new x).normalize();if(Ge){xe({type:"measure-point",position:{x:n.x,y:n.y,z:n.z}});return}_s(!1),xe({type:"picked",position:{x:n.x,y:n.y,z:n.z},normal:{x:o.x,y:o.y,z:o.z}})});window.addEventListener("keydown",i=>{i.key==="Escape"&&we.style.display==="block"?(Ge=!1,_s(!1),xe({type:"placing-cancelled"})):at&&(i.key==="Backspace"||(i.ctrlKey||i.metaKey)&&!i.shiftKey&&i.key.toLowerCase()==="z")&&(i.preventDefault(),xe({type:"calibration-undo"}))});function Ln(){let i=Ft(),t=!!Ee&&!!i&&we.style.display==="block"&&(at||Ge?Sl(se.element,Ee.position,i)&&ye(se.stem):bl(se.element,se.stem,Ee.position,Ee.normal,i));$u(t&&Ge?Ee.position:null),t||(se.element.style.display="none",se.stem.style.display="none",Ee&&i&&we.style.display==="block"&&!Qt.hidden&&(Qt.hidden=!0,console.warn("[splat viewer] the ghost is found but cannot be drawn:",Tu(Ee.position,i))))}var Qt={nothing:!1,hidden:!1};function Tu(i,e){let t=e.entity.getPosition(),s=new x().sub2(i,t).dot(e.entity.forward),n=e.worldToScreen(i,new x);return`spot (${i.x.toFixed(2)}, ${i.y.toFixed(2)}, ${i.z.toFixed(2)}), ${s.toFixed(3)} ahead of the camera (near clip ${e.nearClip.toFixed(3)}), on screen at (${n.x.toFixed(0)}, ${n.y.toFixed(0)})`}var Du=.3,Jt=document.getElementById("stems"),it=new Map,Cn=new U;function zu(i){if(!i)return new U;let e=180/Math.PI,t=new Q().setFromAxisAngle(x.RIGHT,i.rotation.x*e).mul(new Q().setFromAxisAngle(x.UP,i.rotation.y*e)).mul(new Q().setFromAxisAngle(x.BACK,i.rotation.z*e));return new U().setTRS(new x(i.translation.x,i.translation.y,i.translation.z),t,new x(i.scale,i.scale,i.scale))}function wl(i,e){Cn=zu(e);let t=new Set(i.map(s=>s.id));it.forEach((s,n)=>{t.has(n)||(s.element.remove(),s.stem.remove(),it.delete(n))}),i.forEach(s=>{let n=it.get(s.id);if(!n){let o=document.createElement("div");o.className="tag";let r=document.createElement("button");r.type="button",r.className="disc",r.addEventListener("click",c=>{c.stopPropagation(),xe({type:"tagClick",id:s.id})});let a=document.createElement("div");a.className="bubble",o.append(a,r),Kt.appendChild(o);let l=document.createElementNS("http://www.w3.org/2000/svg","line");Jt.appendChild(l),n={tag:s,element:o,disc:r,bubble:a,stem:l,spot:null},it.set(s.id,n)}n.tag=s,n.bubble.textContent=s.label??"",n.disc.setAttribute("aria-label",s.label??""),n.disc.style.backgroundColor=s.color??"#1E88E5",n.disc.style.backgroundImage=s.iconUrl?`url("${s.iconUrl}")`:"none"}),Ml(),es()}var ri=new x,_n=new x,kn=new x,gt=new x,li=new x,gs=new x,pi=new x;function Ft(){return be?.app.root.findComponents("camera")[0]}function bl(i,e,t,s,n){let o=n.entity.getPosition(),r=n.entity.forward,a=l=>pi.sub2(l,o).dot(r)>n.nearClip;return _n.copy(s).normalize().mulScalar(Du).add(t),!a(t)||!a(_n)?!1:(n.worldToScreen(t,li),n.worldToScreen(_n,gs),e.style.display="",e.setAttribute("x1",String(li.x)),e.setAttribute("y1",String(li.y)),e.setAttribute("x2",String(gs.x)),e.setAttribute("y2",String(gs.y)),i.style.display="block",i.style.transform=`translate(${gs.x}px, ${gs.y}px)`,i.style.zIndex=String(Math.max(1,1e6-Math.round(pi.sub2(_n,o).length()*100))),!0)}function es(){let i=vt(),e=Ft();it.forEach(t=>{let{tag:s,element:n,stem:o}=t,r=!1;if(i&&e){let a=i.getWorldTransform();kn.set(s.position.x,s.position.y,s.position.z),s.inModelFrame||Cn.transformPoint(kn,kn),a.transformPoint(kn,ri),s.normal&&(gt.set(s.normal.x,s.normal.y,s.normal.z),s.inModelFrame||Cn.transformVector(gt,gt),a.transformVector(gt,gt)),(!s.normal||gt.lengthSq()===0)&>.copy(x.UP),r=bl(n,o,ri,gt,e),t.spot=r?(t.spot??new x).copy(ri):null}r||(n.style.display="none",o.style.display="none")}),Iu(),qu(),Ln()}function Fu(i){let e=it.get(i)?.element;e&&(e.classList.remove("pointed"),e.offsetWidth,e.classList.add("pointed"))}var at=null,Dt=[],ci=new x,xs=new x,hi=new x;function _l(i){at=i;let e=i?.pairs.length??0;for(;Dt.length>e;){let t=Dt.pop();t.element.remove(),t.link.remove()}for(;Dt.length<e;){let t=document.createElement("div");t.className="pin";let s=document.createElementNS("http://www.w3.org/2000/svg","line");s.classList.add("link"),Kt.appendChild(t),Jt.insertBefore(s,Jt.firstChild),Dt.push({element:t,link:s})}Dt.forEach((t,s)=>{t.element.textContent=String(s+1)}),kl(),Ml(),es()}function kl(){se.element.classList.toggle("pin-ghost",!!at&&!Ge),se.element.classList.toggle("measure-ghost",Ge),se.disc.textContent=at&&!Ge?String(at.pairs.length+1):""}function Ml(){let i=new Set(at?.pairs.map(e=>e.tagId));it.forEach((e,t)=>{e.element.classList.toggle("matched",i.has(t)),e.stem.classList.toggle("matched",i.has(t)),e.element.classList.toggle("selected",at?.selected===t)})}function bs(i,e){return pi.sub2(e,i.entity.getPosition()).dot(i.entity.forward)>i.nearClip}function Sl(i,e,t){return bs(t,e)?(t.worldToScreen(e,xs),i.style.display="block",i.style.transform=`translate(${xs.x}px, ${xs.y}px)`,!0):!1}function ye(i){return i.style.display="none",!0}function Iu(){let i=vt(),e=Ft();Dt.forEach((t,s)=>{let n=at?.pairs[s];if(!n||!i||!e){ye(t.element),ye(t.link);return}if(i.getWorldTransform().transformPoint(ci.set(n.target.x,n.target.y,n.target.z),ci),!Sl(t.element,ci,e)){ye(t.element),ye(t.link);return}let o=it.get(n.tagId)?.spot;if(!o||!bs(e,o)){ye(t.link);return}e.worldToScreen(o,hi),t.link.style.display="",t.link.setAttribute("x1",String(hi.x)),t.link.setAttribute("y1",String(hi.y)),t.link.setAttribute("x2",String(xs.x)),t.link.setAttribute("y2",String(xs.y))})}var ts=null,Ge=!1,Cl=[],Pl=[],Pn=[],Re={line:document.createElementNS("http://www.w3.org/2000/svg","line"),label:document.createElement("div")};Re.line.classList.add("measure","rubber");Re.label.className="measure-label rubber";function Vu(i){i!==Ge&&(Ge=i,kl(),_s(i))}function Ou(i){ts=i;let e=i?.points.length??0,t=Math.max(0,e-1);di(Cl,e,()=>{let s=document.createElement("div");return s.className="measure-point",Kt.appendChild(s)}),di(Pl,t,()=>{let s=document.createElementNS("http://www.w3.org/2000/svg","line");return s.classList.add("measure"),Jt.appendChild(s)}),di(Pn,t,()=>{let s=document.createElement("div");return s.className="measure-label",Kt.appendChild(s)}),Pn.forEach((s,n)=>{s.textContent=`${(i?.distances[n]??0).toFixed(2)} m`}),Re.line.parentNode||(Jt.appendChild(Re.line),Kt.appendChild(Re.label)),es()}function di(i,e,t){for(;i.length>e;)i.pop().remove();for(;i.length<e;)i.push(t())}var Bu=[],Nu=[],vs=new x,Mn=new x;function Ll(i){let e=vt();return!e||!ts?[]:ts.points.map((t,s)=>{let n=Bu[s]??=new x;return e.getWorldTransform().transformPoint(n.set(t.x,t.y,t.z),n),bs(i,n)?i.worldToScreen(n,Nu[s]??=new x):null})}function El(i,e,t){i.style.display="",i.setAttribute("x1",String(e.x)),i.setAttribute("y1",String(e.y)),i.setAttribute("x2",String(t.x)),i.setAttribute("y2",String(t.y))}function fi(i,e,t){i.style.display="block",i.style.transform=`translate(${e}px, ${t}px) translate(-50%, -50%)`}function qu(){let i=Ft(),e=i?Ll(i):[];Cl.forEach((t,s)=>{let n=e[s];n?fi(t,n.x,n.y):ye(t)}),Pl.forEach((t,s)=>{let n=e[s],o=e[s+1];n&&o?(El(t,n,o),fi(Pn[s],(n.x+o.x)/2,(n.y+o.y)/2)):(ye(t),ye(Pn[s]))})}function $u(i){let e=Ft(),t=vt(),s=ts?.points[ts.points.length-1];if(!i||!e||!t||!s||!bs(e,i)){ye(Re.line),ye(Re.label);return}if(t.getWorldTransform().transformPoint(vs.set(s.x,s.y,s.z),vs),!bs(e,vs)){ye(Re.line),ye(Re.label);return}let n=t.getWorldTransform().getScale(new x).x,o=vs.distance(i)/n/(Cn.getScale(new x).x||1),r=e.worldToScreen(vs,new x);e.worldToScreen(i,Mn),El(Re.line,r,Mn),Re.label.textContent=`${o.toFixed(2)} m`,fi(Re.label,(r.x+Mn.x)/2,(r.y+Mn.y)/2)}async function Rl(){let i=Ft();if(!be?.state.loaded||!i)return null;let e=be.app.graphicsDevice.canvas,t=Math.min(1,800/e.clientWidth,600/e.clientHeight),s=Math.max(1,Math.round(e.clientWidth*t)),n=Math.max(1,Math.round(e.clientHeight*t)),o=await be.captureFrame({width:s,height:n}),r=document.createElement("canvas");r.width=s,r.height=n;let a=r.getContext("2d"),l=Uint8ClampedArray.from(atob(o.data),h=>h.charCodeAt(0));a.putImageData(new ImageData(l,s,n),0,0);let c=Ll(i).map(h=>h&&{x:h.x*t,y:h.y*t});return a.lineWidth=3,a.strokeStyle=ml,c.forEach((h,d)=>{let u=c[d-1];u&&h&&(a.beginPath(),a.moveTo(u.x,u.y),a.lineTo(h.x,h.y),a.stroke())}),c.forEach(h=>{h&&(a.beginPath(),a.arc(h.x,h.y,6,0,Math.PI*2),a.fillStyle=ml,a.fill(),a.lineWidth=2,a.strokeStyle="#fff",a.stroke())}),a.font="bold 13px sans-serif",a.textAlign="center",a.textBaseline="middle",c.forEach((h,d)=>{let u=c[d-1];if(u&&h){let p=`${(ts?.distances[d-1]??0).toFixed(2)} m`,g=(u.x+h.x)/2,m=(u.y+h.y)/2,f=a.measureText(p).width+16;a.fillStyle="rgba(0, 0, 0, 0.78)",a.beginPath(),a.roundRect(g-f/2,m-12,f,24,9),a.fill(),a.fillStyle="#fff",a.fillText(p,g,m+1)}}),r.toDataURL("image/jpeg",.85)}var ml="#FFB103";window.__splatViewer={viewer:()=>be,picker:()=>zt,CentresPicker:ms,load:gl,setTags:wl,setCalibration:_l,markers:it,pins:Dt,placeTags:es,snapshot:Rl};xe({type:"ready"});
|
|
File without changes
|