@playcanvas/supersplat-viewer 1.36.0 → 1.36.1
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 +1 -1
- package/public/index.css +2 -4
- package/public/index.js +193 -86
- package/public/index.js.map +1 -1
package/package.json
CHANGED
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
|
@@ -83843,7 +83843,7 @@ const importSettings = (settings) => {
|
|
|
83843
83843
|
return result;
|
|
83844
83844
|
};
|
|
83845
83845
|
|
|
83846
|
-
var version = "1.36.
|
|
83846
|
+
var version = "1.36.1";
|
|
83847
83847
|
|
|
83848
83848
|
class Tooltip {
|
|
83849
83849
|
register;
|
|
@@ -84008,6 +84008,58 @@ const initAnnotationControls = (viewer, root) => {
|
|
|
84008
84008
|
};
|
|
84009
84009
|
};
|
|
84010
84010
|
|
|
84011
|
+
/**
|
|
84012
|
+
* Displacement-based inputs (mouse, touch, wheel, pinch) return accumulated
|
|
84013
|
+
* pixel offsets that already scale with frame time. This factor converts
|
|
84014
|
+
* rate-based speed constants (tuned for degrees-per-second) to work with
|
|
84015
|
+
* per-frame displacements, making them frame-rate-independent.
|
|
84016
|
+
*/
|
|
84017
|
+
const DISPLACEMENT_SCALE = 1 / 60;
|
|
84018
|
+
/** Maximum accumulated touch movement (px) to still count as a tap. */
|
|
84019
|
+
const TAP_EPSILON = 15;
|
|
84020
|
+
const tmpHalfSize = new Vec3();
|
|
84021
|
+
/**
|
|
84022
|
+
* Converts screen-space pixel deltas to a world-space pan vector at the
|
|
84023
|
+
* given depth.
|
|
84024
|
+
*
|
|
84025
|
+
* @param camera - The camera component.
|
|
84026
|
+
* @param dx - Horizontal pixel delta.
|
|
84027
|
+
* @param dy - Vertical pixel delta.
|
|
84028
|
+
* @param dz - Depth (world-space) at which to project the delta.
|
|
84029
|
+
* @param out - Optional output vector.
|
|
84030
|
+
* @returns The pan vector in world space.
|
|
84031
|
+
*/
|
|
84032
|
+
const screenToWorld = (camera, dx, dy, dz, out = new Vec3()) => {
|
|
84033
|
+
const { system, fov, aspectRatio, horizontalFov, projection, orthoHeight } = camera;
|
|
84034
|
+
const { width, height } = system.app.graphicsDevice.clientRect;
|
|
84035
|
+
out.set(-(dx / width) * 2, (dy / height) * 2, 0);
|
|
84036
|
+
const halfSize = tmpHalfSize.set(0, 0, 0);
|
|
84037
|
+
if (projection === PROJECTION_PERSPECTIVE) {
|
|
84038
|
+
const halfSlice = dz * Math.tan(0.5 * fov * math.DEG_TO_RAD);
|
|
84039
|
+
if (horizontalFov) {
|
|
84040
|
+
halfSize.set(halfSlice, halfSlice / aspectRatio, 0);
|
|
84041
|
+
}
|
|
84042
|
+
else {
|
|
84043
|
+
halfSize.set(halfSlice * aspectRatio, halfSlice, 0);
|
|
84044
|
+
}
|
|
84045
|
+
}
|
|
84046
|
+
else {
|
|
84047
|
+
halfSize.set(orthoHeight * aspectRatio, orthoHeight, 0);
|
|
84048
|
+
}
|
|
84049
|
+
out.mul(halfSize);
|
|
84050
|
+
return out;
|
|
84051
|
+
};
|
|
84052
|
+
/**
|
|
84053
|
+
* The orbit camera and the fly camera disagree on the sign of the z-axis
|
|
84054
|
+
* for forward motion. Apply this when emitting a forward/back z-component
|
|
84055
|
+
* so the same wheel-style delta drives both cameras correctly.
|
|
84056
|
+
*
|
|
84057
|
+
* @param mode - The current camera mode.
|
|
84058
|
+
* @param z - The raw forward/back z-component.
|
|
84059
|
+
* @returns The z-component flipped for orbit mode, unchanged otherwise.
|
|
84060
|
+
*/
|
|
84061
|
+
const flipZForOrbit = (mode, z) => (mode === 'orbit' ? -z : z);
|
|
84062
|
+
|
|
84011
84063
|
const vec$1 = new Vec3();
|
|
84012
84064
|
/**
|
|
84013
84065
|
* A script for creating interactive 3D annotations in a scene. Each annotation consists of:
|
|
@@ -84083,8 +84135,9 @@ class Annotation extends Script {
|
|
|
84083
84135
|
}
|
|
84084
84136
|
/**
|
|
84085
84137
|
* 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
|
|
84138
|
+
* prerender callback, and also directly from revealTooltip to ensure the tooltip is
|
|
84139
|
+
* positioned correctly even when the camera hasn't moved (e.g. annotations sharing the same
|
|
84140
|
+
* camera pose).
|
|
84088
84141
|
* @private
|
|
84089
84142
|
*/
|
|
84090
84143
|
_update() {
|
|
@@ -84112,16 +84165,33 @@ class Annotation extends Script {
|
|
|
84112
84165
|
this.hotspotDom.classList.toggle('sse-occluded', occluded);
|
|
84113
84166
|
}
|
|
84114
84167
|
/**
|
|
84168
|
+
* Make this the annotation whose tooltip shows. The tooltip itself waits for the camera to
|
|
84169
|
+
* near the end of its move here, when `Annotations` calls `revealTooltip`, rather than
|
|
84170
|
+
* chasing the hotspot across the screen during the flight.
|
|
84115
84171
|
* @private
|
|
84116
84172
|
*/
|
|
84117
84173
|
showTooltip() {
|
|
84118
84174
|
const ctx = this.context;
|
|
84119
84175
|
ctx.activeAnnotation = this;
|
|
84120
|
-
ctx.
|
|
84121
|
-
ctx.textDom.textContent = this.text;
|
|
84122
|
-
ctx.tooltipDom.classList.add('sse-visible');
|
|
84176
|
+
ctx.revealed = false;
|
|
84123
84177
|
this.hotspotDom.classList.add('sse-active');
|
|
84124
|
-
|
|
84178
|
+
}
|
|
84179
|
+
/**
|
|
84180
|
+
* Show the tooltip beside this annotation, the camera being at or nearly at rest.
|
|
84181
|
+
* @private
|
|
84182
|
+
*/
|
|
84183
|
+
revealTooltip() {
|
|
84184
|
+
const ctx = this.context;
|
|
84185
|
+
ctx.revealed = true;
|
|
84186
|
+
if (ctx.tooltipOwner !== this) {
|
|
84187
|
+
// taken over only now, so the tooltip fades out with the previous annotation's text,
|
|
84188
|
+
// beside its hotspot; and with no side yet, rather than the one it left it on
|
|
84189
|
+
ctx.tooltipOwner = this;
|
|
84190
|
+
ctx.titleDom.textContent = this.title;
|
|
84191
|
+
ctx.textDom.textContent = this.text;
|
|
84192
|
+
ctx.tooltipDom.classList.remove('sse-arrow-left', 'sse-arrow-right');
|
|
84193
|
+
}
|
|
84194
|
+
// the camera may be still, so no prerender may follow
|
|
84125
84195
|
this._update();
|
|
84126
84196
|
}
|
|
84127
84197
|
/**
|
|
@@ -84139,7 +84209,7 @@ class Annotation extends Script {
|
|
|
84139
84209
|
*/
|
|
84140
84210
|
_hideElements() {
|
|
84141
84211
|
this.hotspotDom.style.display = 'none';
|
|
84142
|
-
if (this.context.
|
|
84212
|
+
if (this.context.tooltipOwner === this) {
|
|
84143
84213
|
this.context.tooltipDom.classList.remove('sse-visible');
|
|
84144
84214
|
}
|
|
84145
84215
|
}
|
|
@@ -84158,28 +84228,43 @@ class Annotation extends Script {
|
|
|
84158
84228
|
// nearer hotspots draw over farther ones
|
|
84159
84229
|
hotspot.style.zIndex = String(Math.round(100000 / (1 + distance)));
|
|
84160
84230
|
const ctx = this.context;
|
|
84161
|
-
if (ctx.
|
|
84231
|
+
if (ctx.tooltipOwner !== this) {
|
|
84162
84232
|
return;
|
|
84163
84233
|
}
|
|
84164
|
-
//
|
|
84234
|
+
// Shown while this annotation is selected and revealed, clamped to the canvas when the
|
|
84235
|
+
// hotspot is beyond it, so moving the camera yourself does not lose it. Hidden, it fades
|
|
84236
|
+
// out, moving with the hotspot at the offset it last had rather than standing still while
|
|
84237
|
+
// the camera moves on
|
|
84165
84238
|
const tooltip = ctx.tooltipDom;
|
|
84166
|
-
|
|
84167
|
-
|
|
84239
|
+
const vw = ctx.canvas.clientWidth;
|
|
84240
|
+
const vh = ctx.canvas.clientHeight;
|
|
84241
|
+
const onCanvas = screenPos.x >= 0 && screenPos.x <= vw && screenPos.y >= 0 && screenPos.y <= vh;
|
|
84242
|
+
if (ctx.activeAnnotation !== this || !ctx.revealed) {
|
|
84243
|
+
tooltip.classList.remove('sse-visible');
|
|
84244
|
+
const offset = ctx.tooltipOffset;
|
|
84245
|
+
if (offset) {
|
|
84246
|
+
tooltip.style.transform = `translate(${screenPos.x + offset.x}px, ${screenPos.y + offset.y}px)`;
|
|
84247
|
+
}
|
|
84248
|
+
return;
|
|
84249
|
+
}
|
|
84250
|
+
// Position tooltip, clamped to the canvas (screenPos is in canvas pixels). Measured
|
|
84251
|
+
// before it is shown, which also lets a tooltip that was empty, and so not displayed,
|
|
84252
|
+
// fade in rather than appear at once
|
|
84168
84253
|
const margin = 8;
|
|
84169
84254
|
const arrowOffset = 24;
|
|
84170
84255
|
const tw = tooltip.offsetWidth;
|
|
84171
84256
|
const th = tooltip.offsetHeight;
|
|
84172
|
-
|
|
84173
|
-
|
|
84174
|
-
//
|
|
84175
|
-
|
|
84176
|
-
|
|
84177
|
-
let flipped =
|
|
84178
|
-
|
|
84179
|
-
|
|
84180
|
-
left = screenPos.x - arrowOffset - tw;
|
|
84181
|
-
flipped = true;
|
|
84257
|
+
// Beside the hotspot, vertically centered, on the side it is already on: changing sides
|
|
84258
|
+
// jumps it across the hotspot, so it does only when it no longer fits there and does on
|
|
84259
|
+
// the other side. With no side yet, the right unless that overflows
|
|
84260
|
+
const onRight = screenPos.x + arrowOffset;
|
|
84261
|
+
const onLeft = screenPos.x - arrowOffset - tw;
|
|
84262
|
+
let flipped = tooltip.classList.contains('sse-arrow-left');
|
|
84263
|
+
if (flipped ? onLeft < margin && onRight + tw <= vw - margin : onRight + tw > vw - margin) {
|
|
84264
|
+
flipped = !flipped;
|
|
84182
84265
|
}
|
|
84266
|
+
let left = flipped ? onLeft : onRight;
|
|
84267
|
+
let top = screenPos.y - th / 2;
|
|
84183
84268
|
// Clamp horizontal
|
|
84184
84269
|
left = Math.max(margin, Math.min(left, vw - tw - margin));
|
|
84185
84270
|
// Clamp vertical
|
|
@@ -84190,6 +84275,8 @@ class Annotation extends Script {
|
|
|
84190
84275
|
tooltip.classList.toggle('sse-arrow-right', !flipped);
|
|
84191
84276
|
tooltip.classList.toggle('sse-arrow-left', flipped);
|
|
84192
84277
|
tooltip.style.transform = `translate(${left}px, ${top}px)`;
|
|
84278
|
+
tooltip.classList.add('sse-visible');
|
|
84279
|
+
ctx.tooltipOffset = onCanvas ? { x: left - screenPos.x, y: top - screenPos.y } : null;
|
|
84193
84280
|
}
|
|
84194
84281
|
}
|
|
84195
84282
|
/**
|
|
@@ -84208,6 +84295,15 @@ class AnnotationContext {
|
|
|
84208
84295
|
titleDom;
|
|
84209
84296
|
textDom;
|
|
84210
84297
|
activeAnnotation = null;
|
|
84298
|
+
// whether the active annotation's tooltip has been revealed: it hides for each camera
|
|
84299
|
+
// transition, the move to the annotation among them, until the transition nearly ends
|
|
84300
|
+
revealed = false;
|
|
84301
|
+
// the annotation the tooltip belongs to: the active one once revealed, until then the one
|
|
84302
|
+
// before it, beside whose hotspot it fades out. And its offset from that hotspot when it
|
|
84303
|
+
// last showed, which it keeps while fading; null when it last showed clamped to the canvas
|
|
84304
|
+
// with the hotspot beyond it, since it is not beside the hotspot, and then it fades in place
|
|
84305
|
+
tooltipOwner = null;
|
|
84306
|
+
tooltipOffset = null;
|
|
84211
84307
|
constructor(canvas, camera, parentDom) {
|
|
84212
84308
|
this.parentDom = parentDom;
|
|
84213
84309
|
this.canvas = canvas;
|
|
@@ -84238,6 +84334,10 @@ const OCCLUDING_OPACITY = 0.5;
|
|
|
84238
84334
|
const OCCLUSION_TOLERANCE = 0.1;
|
|
84239
84335
|
// the hotspot's radius in css pixels: the opacity in front is averaged over its whole disc
|
|
84240
84336
|
const HOTSPOT_RADIUS = 13;
|
|
84337
|
+
// the selected annotation's tooltip starts fading in once the camera has eased this far along
|
|
84338
|
+
// a transition, its move there among them: the move settles slowly, so waiting for it to stop
|
|
84339
|
+
// shows the tooltip well after the camera looks to have arrived
|
|
84340
|
+
const REVEAL_PROGRESS = 0.9;
|
|
84241
84341
|
// Built-in hotspot and panel presentation. Selection and camera navigation belong to the viewer.
|
|
84242
84342
|
class Annotations {
|
|
84243
84343
|
parentDom;
|
|
@@ -84245,7 +84345,7 @@ class Annotations {
|
|
|
84245
84345
|
subscriptions;
|
|
84246
84346
|
removeClick;
|
|
84247
84347
|
removeOcclusion;
|
|
84248
|
-
constructor(viewer, root, camera, getPicker) {
|
|
84348
|
+
constructor(viewer, root, camera, getPicker, getCameraProgress) {
|
|
84249
84349
|
const { app, state, events, annotations } = viewer;
|
|
84250
84350
|
const parentDom = document.createElement('div');
|
|
84251
84351
|
parentDom.className = 'sse-annotations';
|
|
@@ -84282,7 +84382,7 @@ class Annotations {
|
|
|
84282
84382
|
// bumped on every camera move, so a test that resolves after the camera moved again is
|
|
84283
84383
|
// discarded rather than applied to a pose it was not taken from
|
|
84284
84384
|
let pose = 0;
|
|
84285
|
-
const
|
|
84385
|
+
const lastWorld = new Mat4();
|
|
84286
84386
|
const lastProjection = new Mat4();
|
|
84287
84387
|
const testOcclusion = async () => {
|
|
84288
84388
|
settleTimer = null;
|
|
@@ -84321,12 +84421,43 @@ class Annotations {
|
|
|
84321
84421
|
clearTimeout(settleTimer);
|
|
84322
84422
|
settleTimer = setTimeout(testOcclusion, SETTLE_MS);
|
|
84323
84423
|
};
|
|
84324
|
-
//
|
|
84424
|
+
// A new camera transition (a reset, say): the tooltip hides until it nearly ends, as on
|
|
84425
|
+
// the move to an annotation. Checked after the camera update but before the frame
|
|
84426
|
+
// renders, so the tooltip is not laid out for the transition's first frame
|
|
84427
|
+
let lastProgress = 1;
|
|
84428
|
+
const onFrameRender = () => {
|
|
84429
|
+
const progress = getCameraProgress();
|
|
84430
|
+
if (progress < lastProgress)
|
|
84431
|
+
context.revealed = false;
|
|
84432
|
+
lastProgress = progress;
|
|
84433
|
+
};
|
|
84434
|
+
app.on('framerender', onFrameRender);
|
|
84435
|
+
// after each frame, since the hotspots' screen positions are updated in prerender. The
|
|
84436
|
+
// camera entity's transform rather than its view matrix, which the engine refreshes only
|
|
84437
|
+
// for frames that render: the viewer skips a frame whose camera moved too little to see,
|
|
84438
|
+
// and a stale view matrix would pass for a camera at rest
|
|
84325
84439
|
const onFrameEnd = () => {
|
|
84326
|
-
const
|
|
84327
|
-
|
|
84440
|
+
const world = camera.getWorldTransform();
|
|
84441
|
+
const { projectionMatrix } = camera.camera;
|
|
84442
|
+
const still = lastWorld.equals(world) && lastProjection.equals(projectionMatrix);
|
|
84443
|
+
const progress = getCameraProgress();
|
|
84444
|
+
// Show the selected annotation's tooltip once the camera is nearly there with the
|
|
84445
|
+
// hotspot on the canvas, fading in as the camera lands, or once the camera is at rest.
|
|
84446
|
+
// A hotspot that ends beyond the canvas gets its tooltip at rest, clamped to the edge,
|
|
84447
|
+
// rather than one that shows and then hides again as the hotspot slides off
|
|
84448
|
+
const { activeAnnotation } = context;
|
|
84449
|
+
const screen = activeAnnotation?.screen;
|
|
84450
|
+
const onCanvas = screen &&
|
|
84451
|
+
screen.x >= 0 &&
|
|
84452
|
+
screen.x <= canvas.clientWidth &&
|
|
84453
|
+
screen.y >= 0 &&
|
|
84454
|
+
screen.y <= canvas.clientHeight;
|
|
84455
|
+
if (activeAnnotation && !context.revealed && (still || (progress >= REVEAL_PROGRESS && onCanvas))) {
|
|
84456
|
+
activeAnnotation.revealTooltip();
|
|
84457
|
+
}
|
|
84458
|
+
if (still)
|
|
84328
84459
|
return;
|
|
84329
|
-
|
|
84460
|
+
lastWorld.copy(world);
|
|
84330
84461
|
lastProjection.copy(projectionMatrix);
|
|
84331
84462
|
pose++;
|
|
84332
84463
|
scheduleOcclusion();
|
|
@@ -84352,6 +84483,7 @@ class Annotations {
|
|
|
84352
84483
|
destroyed = true;
|
|
84353
84484
|
if (settleTimer)
|
|
84354
84485
|
clearTimeout(settleTimer);
|
|
84486
|
+
app.off('framerender', onFrameRender);
|
|
84355
84487
|
app.off('frameend', onFrameEnd);
|
|
84356
84488
|
gsplatSystem.off('frame:ready', onFrameReady);
|
|
84357
84489
|
};
|
|
@@ -84379,12 +84511,32 @@ class Annotations {
|
|
|
84379
84511
|
events.on('gamingControls:changed', update)
|
|
84380
84512
|
];
|
|
84381
84513
|
update();
|
|
84514
|
+
// A click deselects, but a drag ends in a click too, so releasing an orbit would close
|
|
84515
|
+
// the tooltip. A press that moved farther than a tap may is a drag, as the navigation
|
|
84516
|
+
// clicks count it
|
|
84517
|
+
let pressMovement = 0;
|
|
84518
|
+
const onPointerDown = () => {
|
|
84519
|
+
pressMovement = 0;
|
|
84520
|
+
};
|
|
84521
|
+
const onPointerMove = (event) => {
|
|
84522
|
+
if (event.buttons)
|
|
84523
|
+
pressMovement += Math.abs(event.movementX) + Math.abs(event.movementY);
|
|
84524
|
+
};
|
|
84382
84525
|
const onClick = () => {
|
|
84383
|
-
|
|
84526
|
+
// consumed, so a later click from the keyboard is not taken for the drag
|
|
84527
|
+
const dragged = pressMovement >= TAP_EPSILON;
|
|
84528
|
+
pressMovement = 0;
|
|
84529
|
+
if (!dragged && state.loaded && state.selectedAnnotation !== null)
|
|
84384
84530
|
viewer.selectAnnotation(null);
|
|
84385
84531
|
};
|
|
84532
|
+
root.addEventListener('pointerdown', onPointerDown);
|
|
84533
|
+
root.addEventListener('pointermove', onPointerMove);
|
|
84386
84534
|
root.addEventListener('click', onClick);
|
|
84387
|
-
this.removeClick = () =>
|
|
84535
|
+
this.removeClick = () => {
|
|
84536
|
+
root.removeEventListener('pointerdown', onPointerDown);
|
|
84537
|
+
root.removeEventListener('pointermove', onPointerMove);
|
|
84538
|
+
root.removeEventListener('click', onClick);
|
|
84539
|
+
};
|
|
84388
84540
|
}
|
|
84389
84541
|
destroy() {
|
|
84390
84542
|
for (const subscription of this.subscriptions)
|
|
@@ -85069,8 +85221,9 @@ const getGpuName = (device) => {
|
|
|
85069
85221
|
// document, screen) and cancels pending timers. Listeners on the subtree's own elements are
|
|
85070
85222
|
// released with the elements.
|
|
85071
85223
|
// `getPicker` returns the viewer's picker once the scene has loaded, for the annotation
|
|
85072
|
-
// occlusion test
|
|
85073
|
-
|
|
85224
|
+
// occlusion test; `getCameraProgress` how far the camera's current move has eased, 1 when there
|
|
85225
|
+
// is none, for the annotation tooltip's timing
|
|
85226
|
+
const initUI = (global, viewer, getPicker, getCameraProgress) => {
|
|
85074
85227
|
const { root, localize } = global;
|
|
85075
85228
|
const { events, state } = viewer;
|
|
85076
85229
|
const disposers = [];
|
|
@@ -85434,7 +85587,7 @@ const initUI = (global, viewer, getPicker) => {
|
|
|
85434
85587
|
disposers.push(initJoystick(viewer, root));
|
|
85435
85588
|
disposers.push(initAnnotationControls(viewer, root));
|
|
85436
85589
|
if (viewer.annotations.length > 0) {
|
|
85437
|
-
const annotations = new Annotations(viewer, root, global.camera, getPicker);
|
|
85590
|
+
const annotations = new Annotations(viewer, root, global.camera, getPicker, getCameraProgress);
|
|
85438
85591
|
disposers.push(() => annotations.destroy());
|
|
85439
85592
|
}
|
|
85440
85593
|
// tooltips
|
|
@@ -87434,6 +87587,9 @@ class CameraManager {
|
|
|
87434
87587
|
// mutating `camera` and/or `state.cameraMode` to make the change
|
|
87435
87588
|
// visible instantly.
|
|
87436
87589
|
snap;
|
|
87590
|
+
// How far the current transition has eased toward its destination, from 0 to 1; 1 when
|
|
87591
|
+
// there is none. The annotations time their tooltip to the camera's arrival with it.
|
|
87592
|
+
transitionProgress;
|
|
87437
87593
|
// Attach (or clear) collision after construction. The viewer reveals the scene without
|
|
87438
87594
|
// waiting for collision data, which can be larger than the splats themselves, so this
|
|
87439
87595
|
// arrives late. It re-tests whether walk mode is allowed, which gates the walk toggle
|
|
@@ -87527,6 +87683,7 @@ class CameraManager {
|
|
|
87527
87683
|
transitionEase = ease;
|
|
87528
87684
|
transitionTurnEase = turnEase;
|
|
87529
87685
|
};
|
|
87686
|
+
this.transitionProgress = () => (transitionTimer < 1 ? transitionEase(transitionTimer) : 1);
|
|
87530
87687
|
this.setCollision = (value) => {
|
|
87531
87688
|
controllers.fly.collision = value;
|
|
87532
87689
|
controllers.walk.collision = value;
|
|
@@ -89911,58 +90068,6 @@ class ModeShortcuts {
|
|
|
89911
90068
|
}
|
|
89912
90069
|
}
|
|
89913
90070
|
|
|
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
90071
|
const tmpV$4 = new Vec3();
|
|
89967
90072
|
const canTargetFly = (global) => global.state.cameraMode === 'fly' && !(global.state.inputMode === 'desktop' && global.state.gamingControls);
|
|
89968
90073
|
// Mirror gaming-controls speed modifiers: shift = run/boost, ctrl = crawl/slow.
|
|
@@ -98349,7 +98454,9 @@ const createViewer = async (options) => {
|
|
|
98349
98454
|
destroy: () => viewer.destroy()
|
|
98350
98455
|
};
|
|
98351
98456
|
// The built-in controls use the same handle returned to an embedding host.
|
|
98352
|
-
const disposeUI = config.ui
|
|
98457
|
+
const disposeUI = config.ui
|
|
98458
|
+
? initUI(global, handle, () => viewer.picker, () => viewer.cameraManager?.transitionProgress() ?? 1)
|
|
98459
|
+
: null;
|
|
98353
98460
|
viewer.onDestroy(() => {
|
|
98354
98461
|
destroyed = true;
|
|
98355
98462
|
});
|