@playcanvas/supersplat-viewer 1.36.0 → 1.36.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/viewer.css +2 -4
- package/dist/viewer.js +194 -87
- package/dist/viewer.js.map +1 -1
- package/package.json +2 -2
- package/public/index.css +2 -4
- package/public/index.js +200 -89
- package/public/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcanvas/supersplat-viewer",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.2",
|
|
4
4
|
"author": "PlayCanvas <support@playcanvas.com>",
|
|
5
5
|
"homepage": "https://github.com/playcanvas/supersplat-viewer#readme",
|
|
6
6
|
"description": "Viewer for https://superspl.at",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"concurrently": "9.2.4",
|
|
68
68
|
"eslint": "9.39.5",
|
|
69
69
|
"globals": "17.12.0",
|
|
70
|
-
"playcanvas": "2.22.
|
|
70
|
+
"playcanvas": "2.22.6",
|
|
71
71
|
"postcss": "8.5.28",
|
|
72
72
|
"prettier": "3.9.9",
|
|
73
73
|
"publint": "0.3.24",
|
package/public/index.css
CHANGED
|
@@ -893,14 +893,12 @@
|
|
|
893
893
|
overflow-wrap: break-word;
|
|
894
894
|
visibility: hidden;
|
|
895
895
|
opacity: 0;
|
|
896
|
-
|
|
897
|
-
transition: visibility 0s 0.2s, opacity 0.2s ease-out, translate 0.2s ease-out;
|
|
896
|
+
transition: visibility 0s 0.2s, opacity 0.2s ease-out;
|
|
898
897
|
}
|
|
899
898
|
.sse-viewer .sse-annotations > .sse-annotation.sse-visible {
|
|
900
899
|
visibility: visible;
|
|
901
900
|
opacity: 1;
|
|
902
|
-
|
|
903
|
-
transition: opacity 0.2s ease-out, translate 0.2s ease-out;
|
|
901
|
+
transition: opacity 0.2s ease-out;
|
|
904
902
|
}
|
|
905
903
|
.sse-viewer .sse-annotations > .sse-annotation > .sse-annotation-title {
|
|
906
904
|
font-size: 13px;
|
package/public/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const TRACEID_GPU_TIMINGS = "GpuTimings";
|
|
2
2
|
|
|
3
|
-
const version$1 = "2.22.
|
|
4
|
-
const revision = "
|
|
3
|
+
const version$1 = "2.22.6";
|
|
4
|
+
const revision = "dfcc50f";
|
|
5
5
|
function extend(target, ex) {
|
|
6
6
|
for (const prop in ex) {
|
|
7
7
|
const copy = ex[prop];
|
|
@@ -26507,12 +26507,16 @@ class Layer {
|
|
|
26507
26507
|
addMeshInstances(meshInstances, skipShadowCasters) {
|
|
26508
26508
|
const destMeshInstances = this.meshInstances;
|
|
26509
26509
|
const destMeshInstancesSet = this.meshInstancesSet;
|
|
26510
|
+
_tempMaterials.clear();
|
|
26510
26511
|
for (let i = 0; i < meshInstances.length; i++) {
|
|
26511
26512
|
const mi = meshInstances[i];
|
|
26512
26513
|
if (!destMeshInstancesSet.has(mi)) {
|
|
26513
26514
|
destMeshInstances.push(mi);
|
|
26514
26515
|
destMeshInstancesSet.add(mi);
|
|
26515
|
-
|
|
26516
|
+
const mat = mi.material;
|
|
26517
|
+
if (mat) {
|
|
26518
|
+
_tempMaterials.add(mat);
|
|
26519
|
+
}
|
|
26516
26520
|
}
|
|
26517
26521
|
}
|
|
26518
26522
|
if (!skipShadowCasters) {
|
|
@@ -83843,7 +83847,7 @@ const importSettings = (settings) => {
|
|
|
83843
83847
|
return result;
|
|
83844
83848
|
};
|
|
83845
83849
|
|
|
83846
|
-
var version = "1.36.
|
|
83850
|
+
var version = "1.36.2";
|
|
83847
83851
|
|
|
83848
83852
|
class Tooltip {
|
|
83849
83853
|
register;
|
|
@@ -84008,6 +84012,58 @@ const initAnnotationControls = (viewer, root) => {
|
|
|
84008
84012
|
};
|
|
84009
84013
|
};
|
|
84010
84014
|
|
|
84015
|
+
/**
|
|
84016
|
+
* Displacement-based inputs (mouse, touch, wheel, pinch) return accumulated
|
|
84017
|
+
* pixel offsets that already scale with frame time. This factor converts
|
|
84018
|
+
* rate-based speed constants (tuned for degrees-per-second) to work with
|
|
84019
|
+
* per-frame displacements, making them frame-rate-independent.
|
|
84020
|
+
*/
|
|
84021
|
+
const DISPLACEMENT_SCALE = 1 / 60;
|
|
84022
|
+
/** Maximum accumulated touch movement (px) to still count as a tap. */
|
|
84023
|
+
const TAP_EPSILON = 15;
|
|
84024
|
+
const tmpHalfSize = new Vec3();
|
|
84025
|
+
/**
|
|
84026
|
+
* Converts screen-space pixel deltas to a world-space pan vector at the
|
|
84027
|
+
* given depth.
|
|
84028
|
+
*
|
|
84029
|
+
* @param camera - The camera component.
|
|
84030
|
+
* @param dx - Horizontal pixel delta.
|
|
84031
|
+
* @param dy - Vertical pixel delta.
|
|
84032
|
+
* @param dz - Depth (world-space) at which to project the delta.
|
|
84033
|
+
* @param out - Optional output vector.
|
|
84034
|
+
* @returns The pan vector in world space.
|
|
84035
|
+
*/
|
|
84036
|
+
const screenToWorld = (camera, dx, dy, dz, out = new Vec3()) => {
|
|
84037
|
+
const { system, fov, aspectRatio, horizontalFov, projection, orthoHeight } = camera;
|
|
84038
|
+
const { width, height } = system.app.graphicsDevice.clientRect;
|
|
84039
|
+
out.set(-(dx / width) * 2, (dy / height) * 2, 0);
|
|
84040
|
+
const halfSize = tmpHalfSize.set(0, 0, 0);
|
|
84041
|
+
if (projection === PROJECTION_PERSPECTIVE) {
|
|
84042
|
+
const halfSlice = dz * Math.tan(0.5 * fov * math.DEG_TO_RAD);
|
|
84043
|
+
if (horizontalFov) {
|
|
84044
|
+
halfSize.set(halfSlice, halfSlice / aspectRatio, 0);
|
|
84045
|
+
}
|
|
84046
|
+
else {
|
|
84047
|
+
halfSize.set(halfSlice * aspectRatio, halfSlice, 0);
|
|
84048
|
+
}
|
|
84049
|
+
}
|
|
84050
|
+
else {
|
|
84051
|
+
halfSize.set(orthoHeight * aspectRatio, orthoHeight, 0);
|
|
84052
|
+
}
|
|
84053
|
+
out.mul(halfSize);
|
|
84054
|
+
return out;
|
|
84055
|
+
};
|
|
84056
|
+
/**
|
|
84057
|
+
* The orbit camera and the fly camera disagree on the sign of the z-axis
|
|
84058
|
+
* for forward motion. Apply this when emitting a forward/back z-component
|
|
84059
|
+
* so the same wheel-style delta drives both cameras correctly.
|
|
84060
|
+
*
|
|
84061
|
+
* @param mode - The current camera mode.
|
|
84062
|
+
* @param z - The raw forward/back z-component.
|
|
84063
|
+
* @returns The z-component flipped for orbit mode, unchanged otherwise.
|
|
84064
|
+
*/
|
|
84065
|
+
const flipZForOrbit = (mode, z) => (mode === 'orbit' ? -z : z);
|
|
84066
|
+
|
|
84011
84067
|
const vec$1 = new Vec3();
|
|
84012
84068
|
/**
|
|
84013
84069
|
* A script for creating interactive 3D annotations in a scene. Each annotation consists of:
|
|
@@ -84083,8 +84139,9 @@ class Annotation extends Script {
|
|
|
84083
84139
|
}
|
|
84084
84140
|
/**
|
|
84085
84141
|
* Update the screen-space elements for this annotation. Called each frame from the
|
|
84086
|
-
* prerender callback, and also directly from
|
|
84087
|
-
* correctly even when the camera hasn't moved (e.g. annotations sharing the same
|
|
84142
|
+
* prerender callback, and also directly from revealTooltip to ensure the tooltip is
|
|
84143
|
+
* positioned correctly even when the camera hasn't moved (e.g. annotations sharing the same
|
|
84144
|
+
* camera pose).
|
|
84088
84145
|
* @private
|
|
84089
84146
|
*/
|
|
84090
84147
|
_update() {
|
|
@@ -84112,16 +84169,33 @@ class Annotation extends Script {
|
|
|
84112
84169
|
this.hotspotDom.classList.toggle('sse-occluded', occluded);
|
|
84113
84170
|
}
|
|
84114
84171
|
/**
|
|
84172
|
+
* Make this the annotation whose tooltip shows. The tooltip itself waits for the camera to
|
|
84173
|
+
* near the end of its move here, when `Annotations` calls `revealTooltip`, rather than
|
|
84174
|
+
* chasing the hotspot across the screen during the flight.
|
|
84115
84175
|
* @private
|
|
84116
84176
|
*/
|
|
84117
84177
|
showTooltip() {
|
|
84118
84178
|
const ctx = this.context;
|
|
84119
84179
|
ctx.activeAnnotation = this;
|
|
84120
|
-
ctx.
|
|
84121
|
-
ctx.textDom.textContent = this.text;
|
|
84122
|
-
ctx.tooltipDom.classList.add('sse-visible');
|
|
84180
|
+
ctx.revealed = false;
|
|
84123
84181
|
this.hotspotDom.classList.add('sse-active');
|
|
84124
|
-
|
|
84182
|
+
}
|
|
84183
|
+
/**
|
|
84184
|
+
* Show the tooltip beside this annotation, the camera being at or nearly at rest.
|
|
84185
|
+
* @private
|
|
84186
|
+
*/
|
|
84187
|
+
revealTooltip() {
|
|
84188
|
+
const ctx = this.context;
|
|
84189
|
+
ctx.revealed = true;
|
|
84190
|
+
if (ctx.tooltipOwner !== this) {
|
|
84191
|
+
// taken over only now, so the tooltip fades out with the previous annotation's text,
|
|
84192
|
+
// beside its hotspot; and with no side yet, rather than the one it left it on
|
|
84193
|
+
ctx.tooltipOwner = this;
|
|
84194
|
+
ctx.titleDom.textContent = this.title;
|
|
84195
|
+
ctx.textDom.textContent = this.text;
|
|
84196
|
+
ctx.tooltipDom.classList.remove('sse-arrow-left', 'sse-arrow-right');
|
|
84197
|
+
}
|
|
84198
|
+
// the camera may be still, so no prerender may follow
|
|
84125
84199
|
this._update();
|
|
84126
84200
|
}
|
|
84127
84201
|
/**
|
|
@@ -84139,7 +84213,7 @@ class Annotation extends Script {
|
|
|
84139
84213
|
*/
|
|
84140
84214
|
_hideElements() {
|
|
84141
84215
|
this.hotspotDom.style.display = 'none';
|
|
84142
|
-
if (this.context.
|
|
84216
|
+
if (this.context.tooltipOwner === this) {
|
|
84143
84217
|
this.context.tooltipDom.classList.remove('sse-visible');
|
|
84144
84218
|
}
|
|
84145
84219
|
}
|
|
@@ -84158,28 +84232,43 @@ class Annotation extends Script {
|
|
|
84158
84232
|
// nearer hotspots draw over farther ones
|
|
84159
84233
|
hotspot.style.zIndex = String(Math.round(100000 / (1 + distance)));
|
|
84160
84234
|
const ctx = this.context;
|
|
84161
|
-
if (ctx.
|
|
84235
|
+
if (ctx.tooltipOwner !== this) {
|
|
84162
84236
|
return;
|
|
84163
84237
|
}
|
|
84164
|
-
//
|
|
84238
|
+
// Shown while this annotation is selected and revealed, clamped to the canvas when the
|
|
84239
|
+
// hotspot is beyond it, so moving the camera yourself does not lose it. Hidden, it fades
|
|
84240
|
+
// out, moving with the hotspot at the offset it last had rather than standing still while
|
|
84241
|
+
// the camera moves on
|
|
84165
84242
|
const tooltip = ctx.tooltipDom;
|
|
84166
|
-
|
|
84167
|
-
|
|
84243
|
+
const vw = ctx.canvas.clientWidth;
|
|
84244
|
+
const vh = ctx.canvas.clientHeight;
|
|
84245
|
+
const onCanvas = screenPos.x >= 0 && screenPos.x <= vw && screenPos.y >= 0 && screenPos.y <= vh;
|
|
84246
|
+
if (ctx.activeAnnotation !== this || !ctx.revealed) {
|
|
84247
|
+
tooltip.classList.remove('sse-visible');
|
|
84248
|
+
const offset = ctx.tooltipOffset;
|
|
84249
|
+
if (offset) {
|
|
84250
|
+
tooltip.style.transform = `translate(${screenPos.x + offset.x}px, ${screenPos.y + offset.y}px)`;
|
|
84251
|
+
}
|
|
84252
|
+
return;
|
|
84253
|
+
}
|
|
84254
|
+
// Position tooltip, clamped to the canvas (screenPos is in canvas pixels). Measured
|
|
84255
|
+
// before it is shown, which also lets a tooltip that was empty, and so not displayed,
|
|
84256
|
+
// fade in rather than appear at once
|
|
84168
84257
|
const margin = 8;
|
|
84169
84258
|
const arrowOffset = 24;
|
|
84170
84259
|
const tw = tooltip.offsetWidth;
|
|
84171
84260
|
const th = tooltip.offsetHeight;
|
|
84172
|
-
|
|
84173
|
-
|
|
84174
|
-
//
|
|
84175
|
-
|
|
84176
|
-
|
|
84177
|
-
let flipped =
|
|
84178
|
-
|
|
84179
|
-
|
|
84180
|
-
left = screenPos.x - arrowOffset - tw;
|
|
84181
|
-
flipped = true;
|
|
84261
|
+
// Beside the hotspot, vertically centered, on the side it is already on: changing sides
|
|
84262
|
+
// jumps it across the hotspot, so it does only when it no longer fits there and does on
|
|
84263
|
+
// the other side. With no side yet, the right unless that overflows
|
|
84264
|
+
const onRight = screenPos.x + arrowOffset;
|
|
84265
|
+
const onLeft = screenPos.x - arrowOffset - tw;
|
|
84266
|
+
let flipped = tooltip.classList.contains('sse-arrow-left');
|
|
84267
|
+
if (flipped ? onLeft < margin && onRight + tw <= vw - margin : onRight + tw > vw - margin) {
|
|
84268
|
+
flipped = !flipped;
|
|
84182
84269
|
}
|
|
84270
|
+
let left = flipped ? onLeft : onRight;
|
|
84271
|
+
let top = screenPos.y - th / 2;
|
|
84183
84272
|
// Clamp horizontal
|
|
84184
84273
|
left = Math.max(margin, Math.min(left, vw - tw - margin));
|
|
84185
84274
|
// Clamp vertical
|
|
@@ -84190,6 +84279,8 @@ class Annotation extends Script {
|
|
|
84190
84279
|
tooltip.classList.toggle('sse-arrow-right', !flipped);
|
|
84191
84280
|
tooltip.classList.toggle('sse-arrow-left', flipped);
|
|
84192
84281
|
tooltip.style.transform = `translate(${left}px, ${top}px)`;
|
|
84282
|
+
tooltip.classList.add('sse-visible');
|
|
84283
|
+
ctx.tooltipOffset = onCanvas ? { x: left - screenPos.x, y: top - screenPos.y } : null;
|
|
84193
84284
|
}
|
|
84194
84285
|
}
|
|
84195
84286
|
/**
|
|
@@ -84208,6 +84299,15 @@ class AnnotationContext {
|
|
|
84208
84299
|
titleDom;
|
|
84209
84300
|
textDom;
|
|
84210
84301
|
activeAnnotation = null;
|
|
84302
|
+
// whether the active annotation's tooltip has been revealed: it hides for each camera
|
|
84303
|
+
// transition, the move to the annotation among them, until the transition nearly ends
|
|
84304
|
+
revealed = false;
|
|
84305
|
+
// the annotation the tooltip belongs to: the active one once revealed, until then the one
|
|
84306
|
+
// before it, beside whose hotspot it fades out. And its offset from that hotspot when it
|
|
84307
|
+
// last showed, which it keeps while fading; null when it last showed clamped to the canvas
|
|
84308
|
+
// with the hotspot beyond it, since it is not beside the hotspot, and then it fades in place
|
|
84309
|
+
tooltipOwner = null;
|
|
84310
|
+
tooltipOffset = null;
|
|
84211
84311
|
constructor(canvas, camera, parentDom) {
|
|
84212
84312
|
this.parentDom = parentDom;
|
|
84213
84313
|
this.canvas = canvas;
|
|
@@ -84238,6 +84338,10 @@ const OCCLUDING_OPACITY = 0.5;
|
|
|
84238
84338
|
const OCCLUSION_TOLERANCE = 0.1;
|
|
84239
84339
|
// the hotspot's radius in css pixels: the opacity in front is averaged over its whole disc
|
|
84240
84340
|
const HOTSPOT_RADIUS = 13;
|
|
84341
|
+
// the selected annotation's tooltip starts fading in once the camera has eased this far along
|
|
84342
|
+
// a transition, its move there among them: the move settles slowly, so waiting for it to stop
|
|
84343
|
+
// shows the tooltip well after the camera looks to have arrived
|
|
84344
|
+
const REVEAL_PROGRESS = 0.9;
|
|
84241
84345
|
// Built-in hotspot and panel presentation. Selection and camera navigation belong to the viewer.
|
|
84242
84346
|
class Annotations {
|
|
84243
84347
|
parentDom;
|
|
@@ -84245,7 +84349,7 @@ class Annotations {
|
|
|
84245
84349
|
subscriptions;
|
|
84246
84350
|
removeClick;
|
|
84247
84351
|
removeOcclusion;
|
|
84248
|
-
constructor(viewer, root, camera, getPicker) {
|
|
84352
|
+
constructor(viewer, root, camera, getPicker, getCameraProgress) {
|
|
84249
84353
|
const { app, state, events, annotations } = viewer;
|
|
84250
84354
|
const parentDom = document.createElement('div');
|
|
84251
84355
|
parentDom.className = 'sse-annotations';
|
|
@@ -84282,7 +84386,7 @@ class Annotations {
|
|
|
84282
84386
|
// bumped on every camera move, so a test that resolves after the camera moved again is
|
|
84283
84387
|
// discarded rather than applied to a pose it was not taken from
|
|
84284
84388
|
let pose = 0;
|
|
84285
|
-
const
|
|
84389
|
+
const lastWorld = new Mat4();
|
|
84286
84390
|
const lastProjection = new Mat4();
|
|
84287
84391
|
const testOcclusion = async () => {
|
|
84288
84392
|
settleTimer = null;
|
|
@@ -84321,12 +84425,43 @@ class Annotations {
|
|
|
84321
84425
|
clearTimeout(settleTimer);
|
|
84322
84426
|
settleTimer = setTimeout(testOcclusion, SETTLE_MS);
|
|
84323
84427
|
};
|
|
84324
|
-
//
|
|
84428
|
+
// A new camera transition (a reset, say): the tooltip hides until it nearly ends, as on
|
|
84429
|
+
// the move to an annotation. Checked after the camera update but before the frame
|
|
84430
|
+
// renders, so the tooltip is not laid out for the transition's first frame
|
|
84431
|
+
let lastProgress = 1;
|
|
84432
|
+
const onFrameRender = () => {
|
|
84433
|
+
const progress = getCameraProgress();
|
|
84434
|
+
if (progress < lastProgress)
|
|
84435
|
+
context.revealed = false;
|
|
84436
|
+
lastProgress = progress;
|
|
84437
|
+
};
|
|
84438
|
+
app.on('framerender', onFrameRender);
|
|
84439
|
+
// after each frame, since the hotspots' screen positions are updated in prerender. The
|
|
84440
|
+
// camera entity's transform rather than its view matrix, which the engine refreshes only
|
|
84441
|
+
// for frames that render: the viewer skips a frame whose camera moved too little to see,
|
|
84442
|
+
// and a stale view matrix would pass for a camera at rest
|
|
84325
84443
|
const onFrameEnd = () => {
|
|
84326
|
-
const
|
|
84327
|
-
|
|
84444
|
+
const world = camera.getWorldTransform();
|
|
84445
|
+
const { projectionMatrix } = camera.camera;
|
|
84446
|
+
const still = lastWorld.equals(world) && lastProjection.equals(projectionMatrix);
|
|
84447
|
+
const progress = getCameraProgress();
|
|
84448
|
+
// Show the selected annotation's tooltip once the camera is nearly there with the
|
|
84449
|
+
// hotspot on the canvas, fading in as the camera lands, or once the camera is at rest.
|
|
84450
|
+
// A hotspot that ends beyond the canvas gets its tooltip at rest, clamped to the edge,
|
|
84451
|
+
// rather than one that shows and then hides again as the hotspot slides off
|
|
84452
|
+
const { activeAnnotation } = context;
|
|
84453
|
+
const screen = activeAnnotation?.screen;
|
|
84454
|
+
const onCanvas = screen &&
|
|
84455
|
+
screen.x >= 0 &&
|
|
84456
|
+
screen.x <= canvas.clientWidth &&
|
|
84457
|
+
screen.y >= 0 &&
|
|
84458
|
+
screen.y <= canvas.clientHeight;
|
|
84459
|
+
if (activeAnnotation && !context.revealed && (still || (progress >= REVEAL_PROGRESS && onCanvas))) {
|
|
84460
|
+
activeAnnotation.revealTooltip();
|
|
84461
|
+
}
|
|
84462
|
+
if (still)
|
|
84328
84463
|
return;
|
|
84329
|
-
|
|
84464
|
+
lastWorld.copy(world);
|
|
84330
84465
|
lastProjection.copy(projectionMatrix);
|
|
84331
84466
|
pose++;
|
|
84332
84467
|
scheduleOcclusion();
|
|
@@ -84352,6 +84487,7 @@ class Annotations {
|
|
|
84352
84487
|
destroyed = true;
|
|
84353
84488
|
if (settleTimer)
|
|
84354
84489
|
clearTimeout(settleTimer);
|
|
84490
|
+
app.off('framerender', onFrameRender);
|
|
84355
84491
|
app.off('frameend', onFrameEnd);
|
|
84356
84492
|
gsplatSystem.off('frame:ready', onFrameReady);
|
|
84357
84493
|
};
|
|
@@ -84379,12 +84515,32 @@ class Annotations {
|
|
|
84379
84515
|
events.on('gamingControls:changed', update)
|
|
84380
84516
|
];
|
|
84381
84517
|
update();
|
|
84518
|
+
// A click deselects, but a drag ends in a click too, so releasing an orbit would close
|
|
84519
|
+
// the tooltip. A press that moved farther than a tap may is a drag, as the navigation
|
|
84520
|
+
// clicks count it
|
|
84521
|
+
let pressMovement = 0;
|
|
84522
|
+
const onPointerDown = () => {
|
|
84523
|
+
pressMovement = 0;
|
|
84524
|
+
};
|
|
84525
|
+
const onPointerMove = (event) => {
|
|
84526
|
+
if (event.buttons)
|
|
84527
|
+
pressMovement += Math.abs(event.movementX) + Math.abs(event.movementY);
|
|
84528
|
+
};
|
|
84382
84529
|
const onClick = () => {
|
|
84383
|
-
|
|
84530
|
+
// consumed, so a later click from the keyboard is not taken for the drag
|
|
84531
|
+
const dragged = pressMovement >= TAP_EPSILON;
|
|
84532
|
+
pressMovement = 0;
|
|
84533
|
+
if (!dragged && state.loaded && state.selectedAnnotation !== null)
|
|
84384
84534
|
viewer.selectAnnotation(null);
|
|
84385
84535
|
};
|
|
84536
|
+
root.addEventListener('pointerdown', onPointerDown);
|
|
84537
|
+
root.addEventListener('pointermove', onPointerMove);
|
|
84386
84538
|
root.addEventListener('click', onClick);
|
|
84387
|
-
this.removeClick = () =>
|
|
84539
|
+
this.removeClick = () => {
|
|
84540
|
+
root.removeEventListener('pointerdown', onPointerDown);
|
|
84541
|
+
root.removeEventListener('pointermove', onPointerMove);
|
|
84542
|
+
root.removeEventListener('click', onClick);
|
|
84543
|
+
};
|
|
84388
84544
|
}
|
|
84389
84545
|
destroy() {
|
|
84390
84546
|
for (const subscription of this.subscriptions)
|
|
@@ -85069,8 +85225,9 @@ const getGpuName = (device) => {
|
|
|
85069
85225
|
// document, screen) and cancels pending timers. Listeners on the subtree's own elements are
|
|
85070
85226
|
// released with the elements.
|
|
85071
85227
|
// `getPicker` returns the viewer's picker once the scene has loaded, for the annotation
|
|
85072
|
-
// occlusion test
|
|
85073
|
-
|
|
85228
|
+
// occlusion test; `getCameraProgress` how far the camera's current move has eased, 1 when there
|
|
85229
|
+
// is none, for the annotation tooltip's timing
|
|
85230
|
+
const initUI = (global, viewer, getPicker, getCameraProgress) => {
|
|
85074
85231
|
const { root, localize } = global;
|
|
85075
85232
|
const { events, state } = viewer;
|
|
85076
85233
|
const disposers = [];
|
|
@@ -85434,7 +85591,7 @@ const initUI = (global, viewer, getPicker) => {
|
|
|
85434
85591
|
disposers.push(initJoystick(viewer, root));
|
|
85435
85592
|
disposers.push(initAnnotationControls(viewer, root));
|
|
85436
85593
|
if (viewer.annotations.length > 0) {
|
|
85437
|
-
const annotations = new Annotations(viewer, root, global.camera, getPicker);
|
|
85594
|
+
const annotations = new Annotations(viewer, root, global.camera, getPicker, getCameraProgress);
|
|
85438
85595
|
disposers.push(() => annotations.destroy());
|
|
85439
85596
|
}
|
|
85440
85597
|
// tooltips
|
|
@@ -87434,6 +87591,9 @@ class CameraManager {
|
|
|
87434
87591
|
// mutating `camera` and/or `state.cameraMode` to make the change
|
|
87435
87592
|
// visible instantly.
|
|
87436
87593
|
snap;
|
|
87594
|
+
// How far the current transition has eased toward its destination, from 0 to 1; 1 when
|
|
87595
|
+
// there is none. The annotations time their tooltip to the camera's arrival with it.
|
|
87596
|
+
transitionProgress;
|
|
87437
87597
|
// Attach (or clear) collision after construction. The viewer reveals the scene without
|
|
87438
87598
|
// waiting for collision data, which can be larger than the splats themselves, so this
|
|
87439
87599
|
// arrives late. It re-tests whether walk mode is allowed, which gates the walk toggle
|
|
@@ -87527,6 +87687,7 @@ class CameraManager {
|
|
|
87527
87687
|
transitionEase = ease;
|
|
87528
87688
|
transitionTurnEase = turnEase;
|
|
87529
87689
|
};
|
|
87690
|
+
this.transitionProgress = () => (transitionTimer < 1 ? transitionEase(transitionTimer) : 1);
|
|
87530
87691
|
this.setCollision = (value) => {
|
|
87531
87692
|
controllers.fly.collision = value;
|
|
87532
87693
|
controllers.walk.collision = value;
|
|
@@ -89911,58 +90072,6 @@ class ModeShortcuts {
|
|
|
89911
90072
|
}
|
|
89912
90073
|
}
|
|
89913
90074
|
|
|
89914
|
-
/**
|
|
89915
|
-
* Displacement-based inputs (mouse, touch, wheel, pinch) return accumulated
|
|
89916
|
-
* pixel offsets that already scale with frame time. This factor converts
|
|
89917
|
-
* rate-based speed constants (tuned for degrees-per-second) to work with
|
|
89918
|
-
* per-frame displacements, making them frame-rate-independent.
|
|
89919
|
-
*/
|
|
89920
|
-
const DISPLACEMENT_SCALE = 1 / 60;
|
|
89921
|
-
/** Maximum accumulated touch movement (px) to still count as a tap. */
|
|
89922
|
-
const TAP_EPSILON = 15;
|
|
89923
|
-
const tmpHalfSize = new Vec3();
|
|
89924
|
-
/**
|
|
89925
|
-
* Converts screen-space pixel deltas to a world-space pan vector at the
|
|
89926
|
-
* given depth.
|
|
89927
|
-
*
|
|
89928
|
-
* @param camera - The camera component.
|
|
89929
|
-
* @param dx - Horizontal pixel delta.
|
|
89930
|
-
* @param dy - Vertical pixel delta.
|
|
89931
|
-
* @param dz - Depth (world-space) at which to project the delta.
|
|
89932
|
-
* @param out - Optional output vector.
|
|
89933
|
-
* @returns The pan vector in world space.
|
|
89934
|
-
*/
|
|
89935
|
-
const screenToWorld = (camera, dx, dy, dz, out = new Vec3()) => {
|
|
89936
|
-
const { system, fov, aspectRatio, horizontalFov, projection, orthoHeight } = camera;
|
|
89937
|
-
const { width, height } = system.app.graphicsDevice.clientRect;
|
|
89938
|
-
out.set(-(dx / width) * 2, (dy / height) * 2, 0);
|
|
89939
|
-
const halfSize = tmpHalfSize.set(0, 0, 0);
|
|
89940
|
-
if (projection === PROJECTION_PERSPECTIVE) {
|
|
89941
|
-
const halfSlice = dz * Math.tan(0.5 * fov * math.DEG_TO_RAD);
|
|
89942
|
-
if (horizontalFov) {
|
|
89943
|
-
halfSize.set(halfSlice, halfSlice / aspectRatio, 0);
|
|
89944
|
-
}
|
|
89945
|
-
else {
|
|
89946
|
-
halfSize.set(halfSlice * aspectRatio, halfSlice, 0);
|
|
89947
|
-
}
|
|
89948
|
-
}
|
|
89949
|
-
else {
|
|
89950
|
-
halfSize.set(orthoHeight * aspectRatio, orthoHeight, 0);
|
|
89951
|
-
}
|
|
89952
|
-
out.mul(halfSize);
|
|
89953
|
-
return out;
|
|
89954
|
-
};
|
|
89955
|
-
/**
|
|
89956
|
-
* The orbit camera and the fly camera disagree on the sign of the z-axis
|
|
89957
|
-
* for forward motion. Apply this when emitting a forward/back z-component
|
|
89958
|
-
* so the same wheel-style delta drives both cameras correctly.
|
|
89959
|
-
*
|
|
89960
|
-
* @param mode - The current camera mode.
|
|
89961
|
-
* @param z - The raw forward/back z-component.
|
|
89962
|
-
* @returns The z-component flipped for orbit mode, unchanged otherwise.
|
|
89963
|
-
*/
|
|
89964
|
-
const flipZForOrbit = (mode, z) => (mode === 'orbit' ? -z : z);
|
|
89965
|
-
|
|
89966
90075
|
const tmpV$4 = new Vec3();
|
|
89967
90076
|
const canTargetFly = (global) => global.state.cameraMode === 'fly' && !(global.state.inputMode === 'desktop' && global.state.gamingControls);
|
|
89968
90077
|
// Mirror gaming-controls speed modifiers: shift = run/boost, ctrl = crawl/slow.
|
|
@@ -98349,7 +98458,9 @@ const createViewer = async (options) => {
|
|
|
98349
98458
|
destroy: () => viewer.destroy()
|
|
98350
98459
|
};
|
|
98351
98460
|
// The built-in controls use the same handle returned to an embedding host.
|
|
98352
|
-
const disposeUI = config.ui
|
|
98461
|
+
const disposeUI = config.ui
|
|
98462
|
+
? initUI(global, handle, () => viewer.picker, () => viewer.cameraManager?.transitionProgress() ?? 1)
|
|
98463
|
+
: null;
|
|
98353
98464
|
viewer.onDestroy(() => {
|
|
98354
98465
|
destroyed = true;
|
|
98355
98466
|
});
|