@spatial-elements/core 1.0.0-beta.13 → 1.0.0-beta.15
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/catalog/CarouselSectionSurfaces.d.ts.map +1 -1
- package/dist/catalog/CarouselSectionSurfaces.js +8 -2
- package/dist/catalog/CarouselSectionSurfaces.js.map +1 -1
- package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
- package/dist/catalog/CatalogSpatialElementLayer.js +12 -4
- package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
- package/dist/catalog/SourceDomMotion.d.ts.map +1 -1
- package/dist/catalog/SourceDomMotion.js +2 -3
- package/dist/catalog/SourceDomMotion.js.map +1 -1
- package/dist/catalog/carouselRenderClip.d.ts +4 -0
- package/dist/catalog/carouselRenderClip.d.ts.map +1 -0
- package/dist/catalog/carouselRenderClip.js +15 -0
- package/dist/catalog/carouselRenderClip.js.map +1 -0
- package/dist/spatial-element/SpatialElementDockController.d.ts +5 -3
- package/dist/spatial-element/SpatialElementDockController.d.ts.map +1 -1
- package/dist/spatial-element/SpatialElementDockController.js +41 -30
- package/dist/spatial-element/SpatialElementDockController.js.map +1 -1
- package/dist/spatial-element/SpatialElementPaneController.d.ts +4 -4
- package/dist/spatial-element/SpatialElementPaneController.d.ts.map +1 -1
- package/dist/spatial-element/SpatialElementPaneController.js +46 -20
- package/dist/spatial-element/SpatialElementPaneController.js.map +1 -1
- package/dist/spatial-element/responsiveLayout.d.ts.map +1 -1
- package/dist/spatial-element/responsiveLayout.js +4 -2
- package/dist/spatial-element/responsiveLayout.js.map +1 -1
- package/dist/spatial-element/spatialElementDock.d.ts +1 -1
- package/dist/spatial-element/spatialElementDock.d.ts.map +1 -1
- package/dist/spatial-element/spatialElementDock.js +2 -2
- package/dist/spatial-element/spatialElementDock.js.map +1 -1
- package/dist/stage/DetailWheelGesture.d.ts +17 -2
- package/dist/stage/DetailWheelGesture.d.ts.map +1 -1
- package/dist/stage/DetailWheelGesture.js +45 -7
- package/dist/stage/DetailWheelGesture.js.map +1 -1
- package/dist/stage/HeldSceneCapture.d.ts +15 -0
- package/dist/stage/HeldSceneCapture.d.ts.map +1 -0
- package/dist/stage/HeldSceneCapture.js +48 -0
- package/dist/stage/HeldSceneCapture.js.map +1 -0
- package/dist/stage/MinimapController.d.ts +2 -0
- package/dist/stage/MinimapController.d.ts.map +1 -1
- package/dist/stage/MinimapController.js +23 -3
- package/dist/stage/MinimapController.js.map +1 -1
- package/dist/stage/PanelPresentationController.d.ts +5 -0
- package/dist/stage/PanelPresentationController.d.ts.map +1 -1
- package/dist/stage/PanelPresentationController.js +74 -30
- package/dist/stage/PanelPresentationController.js.map +1 -1
- package/dist/stage/SpaceMouseAdapter.js +8 -6
- package/dist/stage/SpaceMouseAdapter.js.map +1 -1
- package/dist/stage/SpatialElementInteractionController.d.ts +27 -2
- package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -1
- package/dist/stage/SpatialElementInteractionController.js +272 -56
- package/dist/stage/SpatialElementInteractionController.js.map +1 -1
- package/dist/stage/StageExperience.d.ts.map +1 -1
- package/dist/stage/StageExperience.js +17 -17
- package/dist/stage/StageExperience.js.map +1 -1
- package/dist/stage/StageRenderPipeline.d.ts +1 -0
- package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
- package/dist/stage/StageRenderPipeline.js +15 -8
- package/dist/stage/StageRenderPipeline.js.map +1 -1
- package/dist/stage/TrackpadGesture.d.ts +17 -0
- package/dist/stage/TrackpadGesture.d.ts.map +1 -0
- package/dist/stage/TrackpadGesture.js +39 -0
- package/dist/stage/TrackpadGesture.js.map +1 -0
- package/dist/stage/cssProjection.d.ts +3 -1
- package/dist/stage/cssProjection.d.ts.map +1 -1
- package/dist/stage/cssProjection.js +8 -3
- package/dist/stage/cssProjection.js.map +1 -1
- package/dist/stage/rendererState.d.ts.map +1 -1
- package/dist/stage/rendererState.js +24 -9
- package/dist/stage/rendererState.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpatialElementInteractionController.d.ts","sourceRoot":"","sources":["../../src/stage/SpatialElementInteractionController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAelC,OAAO,KAAK,EAAqB,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAK5F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"SpatialElementInteractionController.d.ts","sourceRoot":"","sources":["../../src/stage/SpatialElementInteractionController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAelC,OAAO,KAAK,EAAqB,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAK5F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAI3E,MAAM,WAAW,8BAA8B;IAC9C,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,yBAAyB,EAAE,eAAe,KAAK,IAAI,CAAC;IAC7F,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAChC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,WAAW,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,IAAI,IAAI,CAAC;IACtB,gBAAgB,IAAI,IAAI,CAAC;IACzB,YAAY,IAAI;QACf,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,MAAM,CAAC;QAC1C,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC;QAC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,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAexD,aAAa,CAAC,KAAK,EAAE,OAAO;IAS5B,OAAO,CAAC,gBAAgB;IAKxB,0BAA0B;IAgB1B,kBAAkB;IAalB,sBAAsB;IAUtB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;IAalC,OAAO,CAAC,cAAc;IAOtB,6EAA6E;IAC7E,OAAO,CAAC,iBAAiB;IAqBzB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,SAAoC;IAQ5E,IAAI,cAAc,WAGjB;IACD,IAAI,QAAQ,4CAEX;IAED,IAAI,kBAAkB,WAErB;IAED,IAAI,gBAAgB,WAEnB;IAED,IAAI,qBAAqB,kBAExB;IAED,IAAI,qBAAqB,kBAExB;IAED,IAAI,mBAAmB,YAEtB;IAED,IAAI,UAAU,YAEb;IAED,IAAI,sBAAsB,YAEzB;IAED,IAAI,OAAO;;;;MAEV;IAED,IAAI,gBAAgB,YAEnB;IAED,IAAI,eAAe,YAElB;IAED,IAAI,uBAAuB,uBAE1B;IAED,IAAI,uBAAuB,uBAE1B;CACD"}
|
|
@@ -9,20 +9,32 @@ import { dampAndSnap } from './damping.js';
|
|
|
9
9
|
import { getInteractionGuidance, MODEL_INPUT_EVENT } from './interactionGuidance.js';
|
|
10
10
|
import { ModelPointerPreview } from './ModelPointerPreview.js';
|
|
11
11
|
import { resolveDetailGestureOwner } from '../spatial-element/spatialElementMedia.js';
|
|
12
|
-
import { DetailWheelGesture } from './DetailWheelGesture.js';
|
|
12
|
+
import { DetailWheelGesture, DETAIL_WHEEL_IDLE_MS } from './DetailWheelGesture.js';
|
|
13
|
+
import { TrackpadGesture } from './TrackpadGesture.js';
|
|
13
14
|
import { getPanelFocusOpacity, getPanelFocusProgress, getPanelFocusFromProgress } from './panelFocusMath.js';
|
|
14
15
|
/** Owns user navigation state; consumes the facade clock and never creates a RAF loop. */
|
|
15
16
|
export class SpatialElementInteractionController {
|
|
16
17
|
ports;
|
|
17
18
|
disposed = false;
|
|
18
19
|
wheelGesture = new DetailWheelGesture();
|
|
20
|
+
lastWheelTime = -Infinity;
|
|
21
|
+
lastWheelCtrlKey = false;
|
|
22
|
+
cancelledWheelUntil = -Infinity;
|
|
23
|
+
cancelledWheelCtrlKey = false;
|
|
19
24
|
pinch;
|
|
20
25
|
zoomAnchor;
|
|
26
|
+
tap;
|
|
21
27
|
zoomScroll;
|
|
22
28
|
previousZoomFocus = 0;
|
|
29
|
+
trackpadGesture = new TrackpadGesture();
|
|
23
30
|
fullscreen = false;
|
|
31
|
+
_viewportCentering = 0;
|
|
32
|
+
_viewStartCentering = 0;
|
|
33
|
+
_viewEndCentering = 0;
|
|
34
|
+
get viewportCentering() { return this._viewportCentering; }
|
|
24
35
|
setFullscreen(fullscreen) {
|
|
25
36
|
this.fullscreen = fullscreen;
|
|
37
|
+
this.cancelledWheelUntil = -Infinity;
|
|
26
38
|
this.wheelGesture.reset();
|
|
27
39
|
this.clearWheelZoom();
|
|
28
40
|
this._viewResetActive = false;
|
|
@@ -74,6 +86,10 @@ export class SpatialElementInteractionController {
|
|
|
74
86
|
});
|
|
75
87
|
}
|
|
76
88
|
releasePage() {
|
|
89
|
+
this.trackpadGesture.reset();
|
|
90
|
+
this.lastWheelTime = this.cancelledWheelUntil = -Infinity;
|
|
91
|
+
this._viewportCentering = 0;
|
|
92
|
+
this.tap = undefined;
|
|
77
93
|
this.wheelGesture.reset();
|
|
78
94
|
this.endPinch();
|
|
79
95
|
this.zoomScroll = undefined;
|
|
@@ -111,6 +127,20 @@ export class SpatialElementInteractionController {
|
|
|
111
127
|
this._focusRestDistance = rest;
|
|
112
128
|
this._focusCloseDistance = close;
|
|
113
129
|
}
|
|
130
|
+
/** Keep pending navigation in the new fitted range without initiating page reveal. */
|
|
131
|
+
rebaseViewportZoom(previousMin, previousMax) {
|
|
132
|
+
if (!this._controls)
|
|
133
|
+
return;
|
|
134
|
+
const remap = (distance) => THREE.MathUtils.lerp(this._controls.maxDistance, this._controls.minDistance, THREE.MathUtils.clamp((previousMax - distance) /
|
|
135
|
+
Math.max(previousMax - previousMin, 0.001), 0, 1));
|
|
136
|
+
if (this._wheelZoomTargetDistance !== undefined)
|
|
137
|
+
this._wheelZoomTargetDistance = remap(this._wheelZoomTargetDistance);
|
|
138
|
+
if (this._zoomResetTargetDistance !== undefined)
|
|
139
|
+
this._zoomResetTargetDistance = remap(this._zoomResetTargetDistance);
|
|
140
|
+
if (this._zoomResetStartDistance !== undefined)
|
|
141
|
+
this._zoomResetStartDistance = remap(this._zoomResetStartDistance);
|
|
142
|
+
this.previousZoomFocus = this.getRevealFocus();
|
|
143
|
+
}
|
|
114
144
|
stopViewReset() {
|
|
115
145
|
this._viewResetActive = false;
|
|
116
146
|
}
|
|
@@ -125,6 +155,10 @@ export class SpatialElementInteractionController {
|
|
|
125
155
|
_pointerNdc = new THREE.Vector2();
|
|
126
156
|
_wheelZoomDirection = new THREE.Vector3();
|
|
127
157
|
_wheelZoomForward = new THREE.Vector3();
|
|
158
|
+
zoomAnchorPlane = new THREE.Plane();
|
|
159
|
+
zoomAnchorNormal = new THREE.Vector3();
|
|
160
|
+
zoomAnchorIntersection = new THREE.Vector3();
|
|
161
|
+
zoomAnchorShift = new THREE.Vector3();
|
|
128
162
|
_controlsChange = () => this.requestRender();
|
|
129
163
|
_pointer = { x: 0, y: 0, active: false };
|
|
130
164
|
_modelPickTargets = [];
|
|
@@ -158,6 +192,7 @@ export class SpatialElementInteractionController {
|
|
|
158
192
|
_zoomResetStartDistance;
|
|
159
193
|
_zoomResetScrollDistance = 0;
|
|
160
194
|
_wheelZoomTargetDistance;
|
|
195
|
+
_wheelZoomOut = false;
|
|
161
196
|
_initialCameraPosition = new THREE.Vector3();
|
|
162
197
|
_initialControlsTarget = new THREE.Vector3();
|
|
163
198
|
_initialCameraFov = 45;
|
|
@@ -168,20 +203,70 @@ export class SpatialElementInteractionController {
|
|
|
168
203
|
_viewResetStartFov = 45;
|
|
169
204
|
_viewResetElapsed = 0;
|
|
170
205
|
_viewResetDuration = 0;
|
|
206
|
+
_viewEndPosition = new THREE.Vector3();
|
|
207
|
+
_viewEndTarget = new THREE.Vector3();
|
|
208
|
+
_viewEndFov = 45;
|
|
171
209
|
resetView() {
|
|
172
210
|
if (!this._controls || !this._initialViewCaptured)
|
|
173
211
|
return;
|
|
212
|
+
this._viewEndCentering = 0;
|
|
213
|
+
this._viewEndPosition.copy(this._initialCameraPosition);
|
|
214
|
+
this._viewEndTarget.copy(this._initialControlsTarget);
|
|
215
|
+
this._viewEndFov = this._initialCameraFov;
|
|
216
|
+
this.startViewAnimation();
|
|
217
|
+
}
|
|
218
|
+
startViewAnimation() {
|
|
219
|
+
if (!this._controls)
|
|
220
|
+
return;
|
|
174
221
|
this.guidance.interact();
|
|
222
|
+
// A click supersedes the previous wheel burst, including hardware/trackpad
|
|
223
|
+
// inertia delivered after pointerup. A fresh burst still interrupts normally.
|
|
224
|
+
if (performance.now() - this.lastWheelTime < DETAIL_WHEEL_IDLE_MS) {
|
|
225
|
+
this.cancelledWheelUntil = this.lastWheelTime + DETAIL_WHEEL_IDLE_MS;
|
|
226
|
+
this.cancelledWheelCtrlKey = this.lastWheelCtrlKey;
|
|
227
|
+
}
|
|
228
|
+
this.wheelGesture.reset();
|
|
175
229
|
this.clearWheelZoom();
|
|
176
230
|
this.clearZoomReset();
|
|
177
231
|
this._viewResetStartCameraPosition.copy(this.camera.position);
|
|
178
232
|
this._viewResetStartControlsTarget.copy(this._controls.target);
|
|
179
233
|
this._viewResetStartFov = this.camera.fov;
|
|
234
|
+
this._viewStartCentering = this._viewportCentering;
|
|
180
235
|
this._viewResetElapsed = 0;
|
|
181
236
|
this._viewResetDuration = getViewResetDuration(this.getZoomFocusFactor());
|
|
182
237
|
this._viewResetActive = true;
|
|
183
238
|
this.requestRender();
|
|
184
239
|
}
|
|
240
|
+
/** A tap reaches the shared UI/minimap endpoint; another tap restores the fitted view. */
|
|
241
|
+
toggleEnlargedView() {
|
|
242
|
+
if (!this._controls || !this._initialViewCaptured)
|
|
243
|
+
return;
|
|
244
|
+
if (this.getEffectiveCameraDistance() < this._controls.maxDistance - 0.001) {
|
|
245
|
+
this.resetView();
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
this.normalizeCameraFovForOrbitControls();
|
|
249
|
+
// The camera focus is eased; solve its clearance endpoint rather than
|
|
250
|
+
// zooming all the way to the minimum distance or starting a second UI clock.
|
|
251
|
+
if (!this.ports.readGeometry().detail?.split && window.scrollY > 0 && !this.zoomScroll) {
|
|
252
|
+
this.zoomScroll = { focus: this.getRevealFocus(), scrollY: window.scrollY,
|
|
253
|
+
uiProgress: getPanelFocusProgress(this.getUiFocus(this.getZoomFocusFactor())) };
|
|
254
|
+
}
|
|
255
|
+
let near = this._controls.minDistance, far = this._controls.maxDistance;
|
|
256
|
+
for (let i = 0; i < 32; i++) {
|
|
257
|
+
const distance = (near + far) / 2;
|
|
258
|
+
const focus = getCameraZoomFocus(distance, this._initialCameraFov, this._initialCameraFov, this._focusCloseDistance, this._focusRestDistance);
|
|
259
|
+
if (this.getUiFocus(focus, distance) >= 0.96)
|
|
260
|
+
near = distance;
|
|
261
|
+
else
|
|
262
|
+
far = distance;
|
|
263
|
+
}
|
|
264
|
+
this._viewEndTarget.copy(this._initialControlsTarget);
|
|
265
|
+
this._viewEndPosition.copy(this.camera.position).sub(this._controls.target).setLength(near).add(this._viewEndTarget);
|
|
266
|
+
this._viewEndFov = this._initialCameraFov;
|
|
267
|
+
this._viewEndCentering = 1;
|
|
268
|
+
this.startViewAnimation();
|
|
269
|
+
}
|
|
185
270
|
createControls() {
|
|
186
271
|
const controls = new OrbitControls(this.camera, this.backgroundCanvas);
|
|
187
272
|
controls.enableDamping = true;
|
|
@@ -342,8 +427,15 @@ export class SpatialElementInteractionController {
|
|
|
342
427
|
this._controls = recreateOrbitControlsForExternalNavigation(this._controls, () => this.createControls());
|
|
343
428
|
}
|
|
344
429
|
handlePointerMove(event) {
|
|
430
|
+
// A remaining finger resumes Orbit rotation. Do not keep pulling its old
|
|
431
|
+
// two-finger anchor back into place while that rotation is being applied.
|
|
432
|
+
if (event.pointerType === 'touch' && !this.pinch && this._interactionPointers.size === 1)
|
|
433
|
+
this.clearWheelZoom();
|
|
434
|
+
if (this.tap?.id === event.pointerId && Math.hypot(event.clientX - this.tap.x, event.clientY - this.tap.y) >= 6)
|
|
435
|
+
this.tap = undefined;
|
|
345
436
|
const start = this._interactionPointers.get(event.pointerId);
|
|
346
437
|
if (start && Math.hypot(event.clientX - start.x, event.clientY - start.y) >= 6) {
|
|
438
|
+
this.cancelledWheelUntil = -Infinity;
|
|
347
439
|
this.guidance.interact();
|
|
348
440
|
}
|
|
349
441
|
if (event.pointerType !== 'mouse') {
|
|
@@ -369,6 +461,12 @@ export class SpatialElementInteractionController {
|
|
|
369
461
|
}
|
|
370
462
|
}
|
|
371
463
|
handlePointerDown(event) {
|
|
464
|
+
this.tap = undefined;
|
|
465
|
+
if (!this.fullscreen && this.ports.readGeometry().detail?.media === 'minimap' &&
|
|
466
|
+
this._interactionPointers.size === 0 && (event.button === 0 || event.pointerType === 'touch') &&
|
|
467
|
+
this.hitTestModel(event.clientX, event.clientY, event.target, true)) {
|
|
468
|
+
this.tap = { id: event.pointerId, x: event.clientX, y: event.clientY, time: performance.now() };
|
|
469
|
+
}
|
|
372
470
|
if (event.pointerType !== 'mouse')
|
|
373
471
|
this.clearPointerHover();
|
|
374
472
|
// Once a model gesture owns contact, a second finger may land outside its
|
|
@@ -390,6 +488,8 @@ export class SpatialElementInteractionController {
|
|
|
390
488
|
this.requestRender();
|
|
391
489
|
}
|
|
392
490
|
handlePointerUp(event) {
|
|
491
|
+
const tap = this.tap;
|
|
492
|
+
this.tap = undefined;
|
|
393
493
|
this._interactionPointers.delete(event.pointerId);
|
|
394
494
|
this._modelInteractionActive = this._interactionPointers.size > 0;
|
|
395
495
|
if (event.pointerType !== 'mouse')
|
|
@@ -399,11 +499,18 @@ export class SpatialElementInteractionController {
|
|
|
399
499
|
this.hitTestModel(event.clientX, event.clientY, event.target));
|
|
400
500
|
this.notifyModelInput();
|
|
401
501
|
this.updateControlsAvailability();
|
|
502
|
+
// The down event already picked the geometry. A moving/damped camera can
|
|
503
|
+
// move that surface away before release; that does not cancel a stationary tap.
|
|
504
|
+
if (tap?.id === event.pointerId && event.type === 'pointerup' && performance.now() - tap.time < 500 &&
|
|
505
|
+
Math.hypot(event.clientX - tap.x, event.clientY - tap.y) < 6)
|
|
506
|
+
this.toggleEnlargedView();
|
|
402
507
|
this.requestRender();
|
|
403
508
|
}
|
|
404
509
|
handleTouchStart(event) {
|
|
405
510
|
if (event.touches?.length >= 2 && !this.pinch) {
|
|
406
|
-
|
|
511
|
+
this.cancelledWheelUntil = -Infinity;
|
|
512
|
+
this.tap = undefined;
|
|
513
|
+
const a = event.touches[0], b = event.touches[1];
|
|
407
514
|
const x = (a.clientX + b.clientX) / 2, y = (a.clientY + b.clientY) / 2;
|
|
408
515
|
if (this.isPinchArea(x, y)) {
|
|
409
516
|
// Orbit keeps pointer bookkeeping for seamless one-finger rotation,
|
|
@@ -411,8 +518,11 @@ export class SpatialElementInteractionController {
|
|
|
411
518
|
this.pinch = { distance: Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY),
|
|
412
519
|
zoom: this._controls.enableZoom, pan: this._controls.enablePan };
|
|
413
520
|
this._controls.enableZoom = this._controls.enablePan = false;
|
|
521
|
+
this.wheelGesture.reset();
|
|
414
522
|
this.clearWheelZoom();
|
|
415
|
-
|
|
523
|
+
// Match Orbit's screen-space pan plane through its target. Surface
|
|
524
|
+
// picking is reserved for mouse zoom, which has no moving touch anchor.
|
|
525
|
+
this.captureZoomAnchor(x, y, false);
|
|
416
526
|
event.preventDefault();
|
|
417
527
|
event.stopImmediatePropagation();
|
|
418
528
|
return;
|
|
@@ -425,19 +535,30 @@ export class SpatialElementInteractionController {
|
|
|
425
535
|
}
|
|
426
536
|
}
|
|
427
537
|
handleTouchMove(event) {
|
|
428
|
-
if (!this.pinch || event.touches.length < 2)
|
|
538
|
+
if (!this.pinch || event.touches.length < 2 || !this.canInteract)
|
|
429
539
|
return;
|
|
430
|
-
const [
|
|
540
|
+
const a = event.touches[0], b = event.touches[1];
|
|
541
|
+
const x = (a.clientX + b.clientX) / 2, y = (a.clientY + b.clientY) / 2;
|
|
431
542
|
const distance = Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY);
|
|
432
543
|
event.preventDefault();
|
|
433
544
|
event.stopImmediatePropagation();
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
545
|
+
this.guidance.interact();
|
|
546
|
+
this.clearZoomReset();
|
|
547
|
+
this._viewResetActive = false;
|
|
548
|
+
if (!this.zoomAnchor)
|
|
549
|
+
this.captureZoomAnchor(x, y, false);
|
|
550
|
+
// Keep the same world point under the moving midpoint. Compensation runs
|
|
551
|
+
// after scroll/projection updates, so even pan without dolly stays stable.
|
|
552
|
+
if (this.pinch.pan)
|
|
553
|
+
this.zoomAnchor.client.set(x, y);
|
|
554
|
+
this.zoomAnchor.until = performance.now() + DETAIL_WHEEL_IDLE_MS;
|
|
555
|
+
if (this.pinch.zoom && distance !== this.pinch.distance) {
|
|
556
|
+
// Normalized wheel curve: doubling finger distance halves camera distance.
|
|
557
|
+
const delta = Math.log(Math.max(distance, 1) / Math.max(this.pinch.distance, 1)) * 100 / Math.log(0.95);
|
|
558
|
+
this.queueDolly(delta, x, y, true);
|
|
559
|
+
}
|
|
440
560
|
this.pinch.distance = distance;
|
|
561
|
+
this.requestRender();
|
|
441
562
|
}
|
|
442
563
|
handleTouchEnd(event) {
|
|
443
564
|
if (event.touches.length < 2)
|
|
@@ -472,21 +593,78 @@ export class SpatialElementInteractionController {
|
|
|
472
593
|
this.requestRender();
|
|
473
594
|
}
|
|
474
595
|
handleWheel(event) {
|
|
596
|
+
if (!this._controls || !this.canInteract || (event.deltaY === 0 && event.deltaX === 0))
|
|
597
|
+
return;
|
|
598
|
+
const now = performance.now();
|
|
599
|
+
const detail = this.ports.readGeometry().detail;
|
|
600
|
+
let modelHit;
|
|
601
|
+
// Only swallow the cancelled spatial gesture. The separate 3XL content
|
|
602
|
+
// region and a changed pinch modifier represent independent new input.
|
|
603
|
+
if (now < this.cancelledWheelUntil && Boolean(event.ctrlKey) === this.cancelledWheelCtrlKey &&
|
|
604
|
+
(!detail?.split || (modelHit = this.hitTestModel(event.clientX, event.clientY, event.target)))) {
|
|
605
|
+
this.cancelledWheelUntil = now + DETAIL_WHEEL_IDLE_MS;
|
|
606
|
+
event.preventDefault();
|
|
607
|
+
event.stopImmediatePropagation();
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
this.cancelledWheelUntil = -Infinity;
|
|
611
|
+
this.lastWheelTime = now;
|
|
612
|
+
this.lastWheelCtrlKey = Boolean(event.ctrlKey);
|
|
475
613
|
const pinch = event.ctrlKey && this.isPinchArea(event.clientX, event.clientY);
|
|
476
|
-
const
|
|
477
|
-
this.setModelHover(
|
|
614
|
+
const model = pinch || (modelHit ?? this.hitTestModel(event.clientX, event.clientY, event.target));
|
|
615
|
+
this.setModelHover(model);
|
|
478
616
|
this.updateControlsAvailability();
|
|
479
|
-
|
|
480
|
-
|
|
617
|
+
const panelProgress = detail?.media === 'minimap' ?
|
|
618
|
+
getPanelFocusProgress(detail.uiFocus ?? this.getUiFocus(this.getZoomFocusFactor())) : 0;
|
|
619
|
+
const clearingUi = panelProgress > 0;
|
|
620
|
+
// Once panels start clearing, wheel navigation also owns the empty stage.
|
|
621
|
+
// Keep visible HTML and the separate 3XL content region independently usable.
|
|
622
|
+
const hit = model || (clearingUi && !detail?.split && this.stageViewportVisible &&
|
|
623
|
+
event.target === this.backgroundCanvas && this.isPinchArea(event.clientX, event.clientY) &&
|
|
624
|
+
!this.isPointerOccludedByHtml(event.clientX, event.clientY));
|
|
481
625
|
const atOverview = !this.fullscreen && this.getEffectiveCameraDistance() >= this._controls.maxDistance - 0.001;
|
|
482
|
-
const
|
|
626
|
+
const dx = event.deltaX || 0;
|
|
627
|
+
// A horizontally started gesture can pan once the content has fully
|
|
628
|
+
// cleared. Fullscreen and the separate 3XL stage own their empty background
|
|
629
|
+
// too, even at the overview distance; visible HTML remains independently usable.
|
|
630
|
+
const panMode = this.fullscreen || detail?.split || panelProgress >= 1;
|
|
631
|
+
const canPan = Boolean(panMode && hit && this._controls.enablePan);
|
|
632
|
+
const trackpad = this.trackpadGesture.resolve(now, event, canPan);
|
|
633
|
+
const panGesture = trackpad === 'pan';
|
|
634
|
+
const wantsPan = panGesture && canPan;
|
|
635
|
+
if (event.deltaY === 0 && !wantsPan)
|
|
636
|
+
return;
|
|
637
|
+
const separateArea = this.fullscreen || detail?.split;
|
|
638
|
+
if (separateArea || panGesture)
|
|
639
|
+
this.wheelGesture.reset();
|
|
640
|
+
const owner = panGesture ? (wantsPan ? 'zoom' : 'scroll') : separateArea ? (hit ? 'zoom' : 'scroll') :
|
|
641
|
+
this.wheelGesture.resolve(performance.now(), hit, event.deltaY > 0, atOverview, pinch, clearingUi, {
|
|
642
|
+
deltaX: dx, deltaY: event.deltaY, deltaMode: event.deltaMode,
|
|
643
|
+
momentum: event.momentum
|
|
644
|
+
});
|
|
483
645
|
if (owner === 'scroll') {
|
|
484
|
-
|
|
646
|
+
if (!separateArea)
|
|
647
|
+
this._viewResetActive = false;
|
|
648
|
+
this.clearWheelZoom();
|
|
485
649
|
// Let the browser scroll, but never let OrbitControls consume this burst.
|
|
486
650
|
this._controls.enabled = false;
|
|
487
651
|
this.requestRender();
|
|
488
652
|
return;
|
|
489
653
|
}
|
|
654
|
+
if (wantsPan) {
|
|
655
|
+
event.preventDefault();
|
|
656
|
+
event.stopImmediatePropagation();
|
|
657
|
+
this.guidance.interact();
|
|
658
|
+
this.clearWheelZoom();
|
|
659
|
+
this.clearZoomReset();
|
|
660
|
+
this._viewResetActive = false;
|
|
661
|
+
this.captureZoomAnchor(event.clientX, event.clientY, false);
|
|
662
|
+
this.zoomAnchor.client.set(event.clientX - dx, event.clientY - event.deltaY);
|
|
663
|
+
this.compensateZoomAnchor();
|
|
664
|
+
this.zoomAnchor = undefined;
|
|
665
|
+
this.requestRender();
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
490
668
|
if (event.deltaY !== 0)
|
|
491
669
|
this.guidance.interact();
|
|
492
670
|
// OrbitControls applies wheel dolly immediately even when rotation damping is
|
|
@@ -494,20 +672,36 @@ export class SpatialElementInteractionController {
|
|
|
494
672
|
// advance from one shared damped camera distance instead.
|
|
495
673
|
event.preventDefault();
|
|
496
674
|
event.stopImmediatePropagation();
|
|
675
|
+
this.queueDolly(normalizeWheelZoomDelta(event.deltaY, event.deltaMode, event.ctrlKey), event.clientX, event.clientY);
|
|
676
|
+
}
|
|
677
|
+
queueDolly(deltaY, x, y, touch = false) {
|
|
678
|
+
if (!this._controls)
|
|
679
|
+
return;
|
|
497
680
|
this.normalizeCameraFovForOrbitControls();
|
|
498
681
|
this.clearZoomReset();
|
|
499
682
|
this._viewResetActive = false;
|
|
500
|
-
const deltaY = normalizeWheelZoomDelta(event.deltaY, event.deltaMode, event.ctrlKey);
|
|
501
683
|
const currentDistance = this.camera.position.distanceTo(this._controls.target);
|
|
502
684
|
const previousTargetDistance = this._wheelZoomTargetDistance ?? currentDistance;
|
|
503
685
|
const targetDistance = getWheelZoomTargetDistance(previousTargetDistance, deltaY, this._controls.zoomSpeed, this._controls.minDistance, this._controls.maxDistance);
|
|
504
686
|
this._wheelZoomTargetDistance =
|
|
505
687
|
Math.abs(targetDistance - currentDistance) > 0.0001 ? targetDistance : undefined;
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
this.
|
|
509
|
-
this.
|
|
510
|
-
|
|
688
|
+
// Mouse zoom-out returns to the fitted centre; a touch gesture keeps its
|
|
689
|
+
// freely movable anchor in either direction, including the damped tail.
|
|
690
|
+
this._wheelZoomOut = deltaY > 0 && !touch;
|
|
691
|
+
if (this._wheelZoomOut) {
|
|
692
|
+
// Outward dolly converges on the authored centre, regardless of cursor
|
|
693
|
+
// movement since zoom-in. Do not anchor it to another off-centre point.
|
|
694
|
+
this.zoomAnchor = undefined;
|
|
695
|
+
this.requestRender();
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
// A different pointer position chooses a new world point. Moving the old
|
|
699
|
+
// point to a new screen position would pan the model along with the mouse.
|
|
700
|
+
if (!this.zoomAnchor || (!touch && (performance.now() >= this.zoomAnchor.until ||
|
|
701
|
+
Math.hypot(this.zoomAnchor.client.x - x, this.zoomAnchor.client.y - y) > 0.5)))
|
|
702
|
+
this.captureZoomAnchor(x, y, !touch);
|
|
703
|
+
this.zoomAnchor.until = performance.now() + DETAIL_WHEEL_IDLE_MS;
|
|
704
|
+
this.setPointerNdc(x, y);
|
|
511
705
|
this._wheelZoomDirection
|
|
512
706
|
.set(this._pointerNdc.x, this._pointerNdc.y, 1)
|
|
513
707
|
.unproject(this.camera)
|
|
@@ -518,19 +712,19 @@ export class SpatialElementInteractionController {
|
|
|
518
712
|
setPointerNdc(x, y) {
|
|
519
713
|
this._pointerNdc.set(x / Math.max(window.innerWidth, 1) * 2 - 1, 1 - y / Math.max(window.innerHeight, 1) * 2);
|
|
520
714
|
}
|
|
521
|
-
captureZoomAnchor(x, y) {
|
|
715
|
+
captureZoomAnchor(x, y, pickSurface = true) {
|
|
522
716
|
this.updateStageCameraProjection();
|
|
523
717
|
this.camera.updateMatrixWorld(true);
|
|
524
718
|
this.setPointerNdc(x, y);
|
|
525
719
|
this._raycaster.setFromCamera(this._pointerNdc, this.camera);
|
|
526
720
|
const point = new THREE.Vector3();
|
|
527
|
-
const hits = this._raycaster.intersectObjects(this._modelPickTargets, false);
|
|
528
|
-
const plane =
|
|
529
|
-
if (hits
|
|
721
|
+
const hits = pickSurface ? this._raycaster.intersectObjects(this._modelPickTargets, false) : undefined;
|
|
722
|
+
const plane = this.zoomAnchorPlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.zoomAnchorNormal), this._controls.target);
|
|
723
|
+
if (hits?.length)
|
|
530
724
|
point.copy(hits[0].point);
|
|
531
725
|
else if (!this._raycaster.ray.intersectPlane(plane, point))
|
|
532
726
|
point.copy(this._controls.target);
|
|
533
|
-
this.zoomAnchor = { point, client: new THREE.Vector2(x, y), until: performance.now() +
|
|
727
|
+
this.zoomAnchor = { point, client: new THREE.Vector2(x, y), until: performance.now() + DETAIL_WHEEL_IDLE_MS };
|
|
534
728
|
}
|
|
535
729
|
/** Run after the scroll-dependent projection has changed, before rendering. */
|
|
536
730
|
compensateZoomAnchor() {
|
|
@@ -544,17 +738,19 @@ export class SpatialElementInteractionController {
|
|
|
544
738
|
this.camera.updateMatrixWorld(true);
|
|
545
739
|
this.setPointerNdc(anchor.client.x, anchor.client.y);
|
|
546
740
|
this._raycaster.setFromCamera(this._pointerNdc, this.camera);
|
|
547
|
-
const plane =
|
|
548
|
-
const intersection = this._raycaster.ray.intersectPlane(plane,
|
|
741
|
+
const plane = this.zoomAnchorPlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.zoomAnchorNormal), anchor.point);
|
|
742
|
+
const intersection = this._raycaster.ray.intersectPlane(plane, this.zoomAnchorIntersection);
|
|
549
743
|
if (!intersection)
|
|
550
744
|
return;
|
|
551
|
-
const shift = anchor.point
|
|
745
|
+
const shift = this.zoomAnchorShift.copy(anchor.point).sub(intersection);
|
|
552
746
|
this.camera.position.add(shift);
|
|
553
747
|
this._controls.target.add(shift);
|
|
554
748
|
this.camera.updateMatrixWorld(true);
|
|
749
|
+
if (!this.pinch && this._wheelZoomTargetDistance === undefined)
|
|
750
|
+
this.zoomAnchor = undefined;
|
|
555
751
|
}
|
|
556
752
|
requestScrollZoomReset(scrollDelta) {
|
|
557
|
-
if (!this._controls || this.fullscreen)
|
|
753
|
+
if (!this._controls || this.fullscreen || this._viewResetActive || this.ports.readGeometry().detail?.split)
|
|
558
754
|
return;
|
|
559
755
|
if (this.pinch || this._interactionPointers.size > 1 ||
|
|
560
756
|
(this._wheelZoomTargetDistance !== undefined && this.wheelGesture.zooming(performance.now())))
|
|
@@ -582,6 +778,7 @@ export class SpatialElementInteractionController {
|
|
|
582
778
|
const currentDistance = this.camera.position.distanceTo(this._controls.target);
|
|
583
779
|
const targetDistance = THREE.MathUtils.clamp(this._zoomResetTargetDistance, this._controls.minDistance, this._controls.maxDistance);
|
|
584
780
|
const nextDistance = THREE.MathUtils.damp(currentDistance, targetDistance, ZOOM_RESET_DAMPING, delta);
|
|
781
|
+
this.restoreStageAlignment(currentDistance, nextDistance);
|
|
585
782
|
this.setCameraDistance(nextDistance);
|
|
586
783
|
this.camera.fov = THREE.MathUtils.damp(this.camera.fov, this._initialCameraFov, ZOOM_RESET_DAMPING, delta);
|
|
587
784
|
this.camera.updateProjectionMatrix();
|
|
@@ -591,6 +788,7 @@ export class SpatialElementInteractionController {
|
|
|
591
788
|
this.camera.fov = this._initialCameraFov;
|
|
592
789
|
this.camera.updateProjectionMatrix();
|
|
593
790
|
if (targetDistance >= this._controls.maxDistance - 0.001) {
|
|
791
|
+
this._viewportCentering = 0;
|
|
594
792
|
this.clearZoomReset();
|
|
595
793
|
}
|
|
596
794
|
else {
|
|
@@ -602,20 +800,21 @@ export class SpatialElementInteractionController {
|
|
|
602
800
|
applyViewReset(delta) {
|
|
603
801
|
if (!this._controls || !this._viewResetActive || !this._initialViewCaptured)
|
|
604
802
|
return;
|
|
605
|
-
this._viewResetElapsed += Math.max(delta, 0);
|
|
803
|
+
this._viewResetElapsed += this.reducedMotion?.matches ? this._viewResetDuration : Math.max(delta, 0);
|
|
606
804
|
const interpolation = getViewResetInterpolation(this._viewResetElapsed, this._viewResetDuration);
|
|
805
|
+
this._viewportCentering = THREE.MathUtils.lerp(this._viewStartCentering, this._viewEndCentering, interpolation);
|
|
607
806
|
this.camera.position
|
|
608
807
|
.copy(this._viewResetStartCameraPosition)
|
|
609
|
-
.lerp(this.
|
|
808
|
+
.lerp(this._viewEndPosition, interpolation);
|
|
610
809
|
this._controls.target
|
|
611
810
|
.copy(this._viewResetStartControlsTarget)
|
|
612
|
-
.lerp(this.
|
|
613
|
-
this.camera.fov = THREE.MathUtils.lerp(this._viewResetStartFov, this.
|
|
811
|
+
.lerp(this._viewEndTarget, interpolation);
|
|
812
|
+
this.camera.fov = THREE.MathUtils.lerp(this._viewResetStartFov, this._viewEndFov, interpolation);
|
|
614
813
|
this.camera.updateProjectionMatrix();
|
|
615
814
|
if (interpolation >= 1) {
|
|
616
|
-
this.camera.position.copy(this.
|
|
617
|
-
this._controls.target.copy(this.
|
|
618
|
-
this.camera.fov = this.
|
|
815
|
+
this.camera.position.copy(this._viewEndPosition);
|
|
816
|
+
this._controls.target.copy(this._viewEndTarget);
|
|
817
|
+
this.camera.fov = this._viewEndFov;
|
|
619
818
|
this.camera.updateProjectionMatrix();
|
|
620
819
|
this._viewResetActive = false;
|
|
621
820
|
}
|
|
@@ -638,17 +837,32 @@ export class SpatialElementInteractionController {
|
|
|
638
837
|
const targetDistance = THREE.MathUtils.clamp(this._wheelZoomTargetDistance, this._controls.minDistance, this._controls.maxDistance);
|
|
639
838
|
const nextDistance = dampAndSnap(currentDistance, targetDistance, WHEEL_ZOOM_DAMPING, delta, 0.001);
|
|
640
839
|
const radiusDelta = currentDistance - nextDistance;
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
.
|
|
646
|
-
.
|
|
840
|
+
if (this._wheelZoomOut) {
|
|
841
|
+
this.restoreStageAlignment(currentDistance, nextDistance);
|
|
842
|
+
const direction = this._wheelZoomForward.copy(this.camera.position).sub(this._controls.target).normalize();
|
|
843
|
+
const remaining = this._controls.maxDistance - currentDistance;
|
|
844
|
+
const progress = remaining > 0.0001 ? THREE.MathUtils.clamp((nextDistance - currentDistance) / remaining, 0, 1) : 1;
|
|
845
|
+
this._controls.target.lerp(this._initialControlsTarget, progress);
|
|
846
|
+
this.camera.position.copy(this._controls.target).addScaledVector(direction, nextDistance);
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
this.camera.position.addScaledVector(this._wheelZoomDirection, radiusDelta);
|
|
850
|
+
this.camera.updateMatrixWorld(true);
|
|
851
|
+
this.camera.getWorldDirection(this._wheelZoomForward);
|
|
852
|
+
this._controls.target.copy(this.camera.position).addScaledVector(this._wheelZoomForward, nextDistance);
|
|
853
|
+
}
|
|
647
854
|
this._controls.update();
|
|
648
855
|
if (nextDistance === targetDistance)
|
|
649
856
|
this._wheelZoomTargetDistance = undefined;
|
|
650
857
|
return this._wheelZoomTargetDistance !== undefined;
|
|
651
858
|
}
|
|
859
|
+
restoreStageAlignment(current, next) {
|
|
860
|
+
if (!this._controls || next < current)
|
|
861
|
+
return;
|
|
862
|
+
const remaining = this._controls.maxDistance - current;
|
|
863
|
+
this._viewportCentering *= remaining > 0.0001
|
|
864
|
+
? THREE.MathUtils.clamp((this._controls.maxDistance - next) / remaining, 0, 1) : 0;
|
|
865
|
+
}
|
|
652
866
|
setCameraDistance(distance) {
|
|
653
867
|
if (!this._controls)
|
|
654
868
|
return;
|
|
@@ -686,6 +900,7 @@ export class SpatialElementInteractionController {
|
|
|
686
900
|
this.camera.updateProjectionMatrix();
|
|
687
901
|
}
|
|
688
902
|
handlePointerLeave() {
|
|
903
|
+
this.tap = undefined;
|
|
689
904
|
this.endPinch();
|
|
690
905
|
this.zoomAnchor = undefined;
|
|
691
906
|
this.preview.clear();
|
|
@@ -702,13 +917,13 @@ export class SpatialElementInteractionController {
|
|
|
702
917
|
this.updateControlsAvailability();
|
|
703
918
|
this.requestRender();
|
|
704
919
|
}
|
|
705
|
-
hitTestModel(clientX, clientY, target) {
|
|
920
|
+
hitTestModel(clientX, clientY, target, exact = false) {
|
|
706
921
|
// Fullscreen owns the canvas, including its empty background. UI events
|
|
707
922
|
// never reach this gate as canvas input; no geometry or DOM picking is needed.
|
|
708
|
-
if (this.fullscreen)
|
|
923
|
+
if (this.fullscreen && !exact)
|
|
709
924
|
return this.canInteract && this.stageViewportVisible && target === this.backgroundCanvas;
|
|
710
925
|
const detail = this.ports.readGeometry().detail;
|
|
711
|
-
if (detail && (detail.split || detail.paneHidden)) {
|
|
926
|
+
if (!exact && detail && (detail.split || detail.paneHidden)) {
|
|
712
927
|
if (!this.canInteract || !this.stageViewportVisible)
|
|
713
928
|
return false;
|
|
714
929
|
return resolveDetailGestureOwner({ ...detail, clientX, modelHit: false,
|
|
@@ -717,16 +932,17 @@ export class SpatialElementInteractionController {
|
|
|
717
932
|
}
|
|
718
933
|
if (!this.canInteract ||
|
|
719
934
|
!this.stageViewportVisible ||
|
|
720
|
-
clientX < this.viewportFrame.x ||
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
935
|
+
(!exact && (clientX < this.viewportFrame.x ||
|
|
936
|
+
clientX > this.viewportFrame.x + this.viewportFrame.z ||
|
|
937
|
+
clientY < this.viewportFrame.y ||
|
|
938
|
+
clientY > this.viewportFrame.y + this.viewportFrame.w)) ||
|
|
724
939
|
!this._modelPickTargets.length ||
|
|
725
940
|
isStageUiTarget(target) ||
|
|
726
941
|
this.isPointerOccludedByHtml(clientX, clientY)) {
|
|
727
942
|
return false;
|
|
728
943
|
}
|
|
729
944
|
this.updateStageCameraProjection();
|
|
945
|
+
this.camera.updateMatrixWorld();
|
|
730
946
|
this._pointerNdc.set((clientX / window.innerWidth) * 2 - 1, -(clientY / window.innerHeight) * 2 + 1);
|
|
731
947
|
this._raycaster.setFromCamera(this._pointerNdc, this.camera);
|
|
732
948
|
// This is a boolean interaction gate, not a nearest-surface query. Do not
|
|
@@ -817,11 +1033,11 @@ export class SpatialElementInteractionController {
|
|
|
817
1033
|
this.preview.advance(this.camera, delta, this.reducedMotion?.matches);
|
|
818
1034
|
return { controls: controls || preview, wheel };
|
|
819
1035
|
}
|
|
820
|
-
getRevealFocus() {
|
|
1036
|
+
getRevealFocus(distance = this.getEffectiveCameraDistance()) {
|
|
821
1037
|
// Start at the fitted distance, before the later UI-clearance phase. The
|
|
822
1038
|
// first 35% of inward dolly reveals the whole stage without a second clock.
|
|
823
1039
|
const maxDistance = this._controls.maxDistance;
|
|
824
|
-
return THREE.MathUtils.clamp((maxDistance -
|
|
1040
|
+
return THREE.MathUtils.clamp((maxDistance - distance) /
|
|
825
1041
|
Math.max(maxDistance * 0.35, 0.001), 0, 1);
|
|
826
1042
|
}
|
|
827
1043
|
/** Couple document reveal and UI clearance to one camera-driven timeline. */
|
|
@@ -848,11 +1064,11 @@ export class SpatialElementInteractionController {
|
|
|
848
1064
|
this.zoomScroll = undefined;
|
|
849
1065
|
this.previousZoomFocus = focus;
|
|
850
1066
|
}
|
|
851
|
-
getUiFocus(cameraFocus) {
|
|
1067
|
+
getUiFocus(cameraFocus, distance = this.getEffectiveCameraDistance()) {
|
|
852
1068
|
const normal = getStageUiFocus(cameraFocus);
|
|
853
1069
|
if (!this.zoomScroll || this.ports.readGeometry().detail?.split)
|
|
854
1070
|
return normal;
|
|
855
|
-
const progress = THREE.MathUtils.clamp((this.getRevealFocus() - this.zoomScroll.focus) /
|
|
1071
|
+
const progress = THREE.MathUtils.clamp((this.getRevealFocus(distance) - this.zoomScroll.focus) /
|
|
856
1072
|
Math.max(1 - this.zoomScroll.focus, 0.001), 0, 1);
|
|
857
1073
|
return Math.max(normal, getPanelFocusFromProgress(THREE.MathUtils.lerp(this.zoomScroll.uiProgress, 1, progress)));
|
|
858
1074
|
}
|