@spatial-elements/core 1.0.0-beta.13 → 1.0.0-beta.14
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/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/stage/DetailWheelGesture.d.ts +3 -1
- package/dist/stage/DetailWheelGesture.d.ts.map +1 -1
- package/dist/stage/DetailWheelGesture.js +9 -6
- 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/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 +24 -2
- package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -1
- package/dist/stage/SpatialElementInteractionController.js +226 -56
- package/dist/stage/SpatialElementInteractionController.js.map +1 -1
- package/dist/stage/StageExperience.d.ts.map +1 -1
- package/dist/stage/StageExperience.js +5 -2
- 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/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;AAG3E,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;QACxB,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC;QACnB,MAAM,CAAC,EAAE;YAAE,KAAK,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC;YAAC,KAAK,EAAE,OAAO,CAAC;YAAC,UAAU,EAAE,OAAO,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,UAAU,CAAC,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAClJ,CAAC;CACF;AACD,0FAA0F;AAC1F,qBAAa,mCAAmC;
|
|
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;AAG3E,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;IAC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sB;IAkBtB,kBAAkB;IAiBlB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,EAAE,KAAK,UAAQ;IA6CxF,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,30 @@ 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
13
|
import { getPanelFocusOpacity, getPanelFocusProgress, getPanelFocusFromProgress } from './panelFocusMath.js';
|
|
14
14
|
/** Owns user navigation state; consumes the facade clock and never creates a RAF loop. */
|
|
15
15
|
export class SpatialElementInteractionController {
|
|
16
16
|
ports;
|
|
17
17
|
disposed = false;
|
|
18
18
|
wheelGesture = new DetailWheelGesture();
|
|
19
|
+
lastWheelTime = -Infinity;
|
|
20
|
+
lastWheelCtrlKey = false;
|
|
21
|
+
cancelledWheelUntil = -Infinity;
|
|
22
|
+
cancelledWheelCtrlKey = false;
|
|
19
23
|
pinch;
|
|
20
24
|
zoomAnchor;
|
|
25
|
+
tap;
|
|
21
26
|
zoomScroll;
|
|
22
27
|
previousZoomFocus = 0;
|
|
23
28
|
fullscreen = false;
|
|
29
|
+
_viewportCentering = 0;
|
|
30
|
+
_viewStartCentering = 0;
|
|
31
|
+
_viewEndCentering = 0;
|
|
32
|
+
get viewportCentering() { return this._viewportCentering; }
|
|
24
33
|
setFullscreen(fullscreen) {
|
|
25
34
|
this.fullscreen = fullscreen;
|
|
35
|
+
this.cancelledWheelUntil = -Infinity;
|
|
26
36
|
this.wheelGesture.reset();
|
|
27
37
|
this.clearWheelZoom();
|
|
28
38
|
this._viewResetActive = false;
|
|
@@ -74,6 +84,9 @@ export class SpatialElementInteractionController {
|
|
|
74
84
|
});
|
|
75
85
|
}
|
|
76
86
|
releasePage() {
|
|
87
|
+
this.lastWheelTime = this.cancelledWheelUntil = -Infinity;
|
|
88
|
+
this._viewportCentering = 0;
|
|
89
|
+
this.tap = undefined;
|
|
77
90
|
this.wheelGesture.reset();
|
|
78
91
|
this.endPinch();
|
|
79
92
|
this.zoomScroll = undefined;
|
|
@@ -125,6 +138,10 @@ export class SpatialElementInteractionController {
|
|
|
125
138
|
_pointerNdc = new THREE.Vector2();
|
|
126
139
|
_wheelZoomDirection = new THREE.Vector3();
|
|
127
140
|
_wheelZoomForward = new THREE.Vector3();
|
|
141
|
+
zoomAnchorPlane = new THREE.Plane();
|
|
142
|
+
zoomAnchorNormal = new THREE.Vector3();
|
|
143
|
+
zoomAnchorIntersection = new THREE.Vector3();
|
|
144
|
+
zoomAnchorShift = new THREE.Vector3();
|
|
128
145
|
_controlsChange = () => this.requestRender();
|
|
129
146
|
_pointer = { x: 0, y: 0, active: false };
|
|
130
147
|
_modelPickTargets = [];
|
|
@@ -158,6 +175,7 @@ export class SpatialElementInteractionController {
|
|
|
158
175
|
_zoomResetStartDistance;
|
|
159
176
|
_zoomResetScrollDistance = 0;
|
|
160
177
|
_wheelZoomTargetDistance;
|
|
178
|
+
_wheelZoomOut = false;
|
|
161
179
|
_initialCameraPosition = new THREE.Vector3();
|
|
162
180
|
_initialControlsTarget = new THREE.Vector3();
|
|
163
181
|
_initialCameraFov = 45;
|
|
@@ -168,20 +186,70 @@ export class SpatialElementInteractionController {
|
|
|
168
186
|
_viewResetStartFov = 45;
|
|
169
187
|
_viewResetElapsed = 0;
|
|
170
188
|
_viewResetDuration = 0;
|
|
189
|
+
_viewEndPosition = new THREE.Vector3();
|
|
190
|
+
_viewEndTarget = new THREE.Vector3();
|
|
191
|
+
_viewEndFov = 45;
|
|
171
192
|
resetView() {
|
|
172
193
|
if (!this._controls || !this._initialViewCaptured)
|
|
173
194
|
return;
|
|
195
|
+
this._viewEndCentering = 0;
|
|
196
|
+
this._viewEndPosition.copy(this._initialCameraPosition);
|
|
197
|
+
this._viewEndTarget.copy(this._initialControlsTarget);
|
|
198
|
+
this._viewEndFov = this._initialCameraFov;
|
|
199
|
+
this.startViewAnimation();
|
|
200
|
+
}
|
|
201
|
+
startViewAnimation() {
|
|
202
|
+
if (!this._controls)
|
|
203
|
+
return;
|
|
174
204
|
this.guidance.interact();
|
|
205
|
+
// A click supersedes the previous wheel burst, including hardware/trackpad
|
|
206
|
+
// inertia delivered after pointerup. A fresh burst still interrupts normally.
|
|
207
|
+
if (performance.now() - this.lastWheelTime < DETAIL_WHEEL_IDLE_MS) {
|
|
208
|
+
this.cancelledWheelUntil = this.lastWheelTime + DETAIL_WHEEL_IDLE_MS;
|
|
209
|
+
this.cancelledWheelCtrlKey = this.lastWheelCtrlKey;
|
|
210
|
+
}
|
|
211
|
+
this.wheelGesture.reset();
|
|
175
212
|
this.clearWheelZoom();
|
|
176
213
|
this.clearZoomReset();
|
|
177
214
|
this._viewResetStartCameraPosition.copy(this.camera.position);
|
|
178
215
|
this._viewResetStartControlsTarget.copy(this._controls.target);
|
|
179
216
|
this._viewResetStartFov = this.camera.fov;
|
|
217
|
+
this._viewStartCentering = this._viewportCentering;
|
|
180
218
|
this._viewResetElapsed = 0;
|
|
181
219
|
this._viewResetDuration = getViewResetDuration(this.getZoomFocusFactor());
|
|
182
220
|
this._viewResetActive = true;
|
|
183
221
|
this.requestRender();
|
|
184
222
|
}
|
|
223
|
+
/** A tap reaches the shared UI/minimap endpoint; another tap restores the fitted view. */
|
|
224
|
+
toggleEnlargedView() {
|
|
225
|
+
if (!this._controls || !this._initialViewCaptured)
|
|
226
|
+
return;
|
|
227
|
+
if (this.getEffectiveCameraDistance() < this._controls.maxDistance - 0.001) {
|
|
228
|
+
this.resetView();
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
this.normalizeCameraFovForOrbitControls();
|
|
232
|
+
// The camera focus is eased; solve its clearance endpoint rather than
|
|
233
|
+
// zooming all the way to the minimum distance or starting a second UI clock.
|
|
234
|
+
if (!this.ports.readGeometry().detail?.split && window.scrollY > 0 && !this.zoomScroll) {
|
|
235
|
+
this.zoomScroll = { focus: this.getRevealFocus(), scrollY: window.scrollY,
|
|
236
|
+
uiProgress: getPanelFocusProgress(this.getUiFocus(this.getZoomFocusFactor())) };
|
|
237
|
+
}
|
|
238
|
+
let near = this._controls.minDistance, far = this._controls.maxDistance;
|
|
239
|
+
for (let i = 0; i < 32; i++) {
|
|
240
|
+
const distance = (near + far) / 2;
|
|
241
|
+
const focus = getCameraZoomFocus(distance, this._initialCameraFov, this._initialCameraFov, this._focusCloseDistance, this._focusRestDistance);
|
|
242
|
+
if (this.getUiFocus(focus, distance) >= 0.96)
|
|
243
|
+
near = distance;
|
|
244
|
+
else
|
|
245
|
+
far = distance;
|
|
246
|
+
}
|
|
247
|
+
this._viewEndTarget.copy(this._initialControlsTarget);
|
|
248
|
+
this._viewEndPosition.copy(this.camera.position).sub(this._controls.target).setLength(near).add(this._viewEndTarget);
|
|
249
|
+
this._viewEndFov = this._initialCameraFov;
|
|
250
|
+
this._viewEndCentering = 1;
|
|
251
|
+
this.startViewAnimation();
|
|
252
|
+
}
|
|
185
253
|
createControls() {
|
|
186
254
|
const controls = new OrbitControls(this.camera, this.backgroundCanvas);
|
|
187
255
|
controls.enableDamping = true;
|
|
@@ -342,8 +410,15 @@ export class SpatialElementInteractionController {
|
|
|
342
410
|
this._controls = recreateOrbitControlsForExternalNavigation(this._controls, () => this.createControls());
|
|
343
411
|
}
|
|
344
412
|
handlePointerMove(event) {
|
|
413
|
+
// A remaining finger resumes Orbit rotation. Do not keep pulling its old
|
|
414
|
+
// two-finger anchor back into place while that rotation is being applied.
|
|
415
|
+
if (event.pointerType === 'touch' && !this.pinch && this._interactionPointers.size === 1)
|
|
416
|
+
this.clearWheelZoom();
|
|
417
|
+
if (this.tap?.id === event.pointerId && Math.hypot(event.clientX - this.tap.x, event.clientY - this.tap.y) >= 6)
|
|
418
|
+
this.tap = undefined;
|
|
345
419
|
const start = this._interactionPointers.get(event.pointerId);
|
|
346
420
|
if (start && Math.hypot(event.clientX - start.x, event.clientY - start.y) >= 6) {
|
|
421
|
+
this.cancelledWheelUntil = -Infinity;
|
|
347
422
|
this.guidance.interact();
|
|
348
423
|
}
|
|
349
424
|
if (event.pointerType !== 'mouse') {
|
|
@@ -369,6 +444,12 @@ export class SpatialElementInteractionController {
|
|
|
369
444
|
}
|
|
370
445
|
}
|
|
371
446
|
handlePointerDown(event) {
|
|
447
|
+
this.tap = undefined;
|
|
448
|
+
if (!this.fullscreen && this.ports.readGeometry().detail?.media === 'minimap' &&
|
|
449
|
+
this._interactionPointers.size === 0 && (event.button === 0 || event.pointerType === 'touch') &&
|
|
450
|
+
this.hitTestModel(event.clientX, event.clientY, event.target, true)) {
|
|
451
|
+
this.tap = { id: event.pointerId, x: event.clientX, y: event.clientY, time: performance.now() };
|
|
452
|
+
}
|
|
372
453
|
if (event.pointerType !== 'mouse')
|
|
373
454
|
this.clearPointerHover();
|
|
374
455
|
// Once a model gesture owns contact, a second finger may land outside its
|
|
@@ -390,6 +471,8 @@ export class SpatialElementInteractionController {
|
|
|
390
471
|
this.requestRender();
|
|
391
472
|
}
|
|
392
473
|
handlePointerUp(event) {
|
|
474
|
+
const tap = this.tap;
|
|
475
|
+
this.tap = undefined;
|
|
393
476
|
this._interactionPointers.delete(event.pointerId);
|
|
394
477
|
this._modelInteractionActive = this._interactionPointers.size > 0;
|
|
395
478
|
if (event.pointerType !== 'mouse')
|
|
@@ -399,11 +482,18 @@ export class SpatialElementInteractionController {
|
|
|
399
482
|
this.hitTestModel(event.clientX, event.clientY, event.target));
|
|
400
483
|
this.notifyModelInput();
|
|
401
484
|
this.updateControlsAvailability();
|
|
485
|
+
// The down event already picked the geometry. A moving/damped camera can
|
|
486
|
+
// move that surface away before release; that does not cancel a stationary tap.
|
|
487
|
+
if (tap?.id === event.pointerId && event.type === 'pointerup' && performance.now() - tap.time < 500 &&
|
|
488
|
+
Math.hypot(event.clientX - tap.x, event.clientY - tap.y) < 6)
|
|
489
|
+
this.toggleEnlargedView();
|
|
402
490
|
this.requestRender();
|
|
403
491
|
}
|
|
404
492
|
handleTouchStart(event) {
|
|
405
493
|
if (event.touches?.length >= 2 && !this.pinch) {
|
|
406
|
-
|
|
494
|
+
this.cancelledWheelUntil = -Infinity;
|
|
495
|
+
this.tap = undefined;
|
|
496
|
+
const a = event.touches[0], b = event.touches[1];
|
|
407
497
|
const x = (a.clientX + b.clientX) / 2, y = (a.clientY + b.clientY) / 2;
|
|
408
498
|
if (this.isPinchArea(x, y)) {
|
|
409
499
|
// Orbit keeps pointer bookkeeping for seamless one-finger rotation,
|
|
@@ -411,8 +501,11 @@ export class SpatialElementInteractionController {
|
|
|
411
501
|
this.pinch = { distance: Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY),
|
|
412
502
|
zoom: this._controls.enableZoom, pan: this._controls.enablePan };
|
|
413
503
|
this._controls.enableZoom = this._controls.enablePan = false;
|
|
504
|
+
this.wheelGesture.reset();
|
|
414
505
|
this.clearWheelZoom();
|
|
415
|
-
|
|
506
|
+
// Match Orbit's screen-space pan plane through its target. Surface
|
|
507
|
+
// picking is reserved for mouse zoom, which has no moving touch anchor.
|
|
508
|
+
this.captureZoomAnchor(x, y, false);
|
|
416
509
|
event.preventDefault();
|
|
417
510
|
event.stopImmediatePropagation();
|
|
418
511
|
return;
|
|
@@ -425,19 +518,30 @@ export class SpatialElementInteractionController {
|
|
|
425
518
|
}
|
|
426
519
|
}
|
|
427
520
|
handleTouchMove(event) {
|
|
428
|
-
if (!this.pinch || event.touches.length < 2)
|
|
521
|
+
if (!this.pinch || event.touches.length < 2 || !this.canInteract)
|
|
429
522
|
return;
|
|
430
|
-
const [
|
|
523
|
+
const a = event.touches[0], b = event.touches[1];
|
|
524
|
+
const x = (a.clientX + b.clientX) / 2, y = (a.clientY + b.clientY) / 2;
|
|
431
525
|
const distance = Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY);
|
|
432
526
|
event.preventDefault();
|
|
433
527
|
event.stopImmediatePropagation();
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
528
|
+
this.guidance.interact();
|
|
529
|
+
this.clearZoomReset();
|
|
530
|
+
this._viewResetActive = false;
|
|
531
|
+
if (!this.zoomAnchor)
|
|
532
|
+
this.captureZoomAnchor(x, y, false);
|
|
533
|
+
// Keep the same world point under the moving midpoint. Compensation runs
|
|
534
|
+
// after scroll/projection updates, so even pan without dolly stays stable.
|
|
535
|
+
if (this.pinch.pan)
|
|
536
|
+
this.zoomAnchor.client.set(x, y);
|
|
537
|
+
this.zoomAnchor.until = performance.now() + DETAIL_WHEEL_IDLE_MS;
|
|
538
|
+
if (this.pinch.zoom && distance !== this.pinch.distance) {
|
|
539
|
+
// Normalized wheel curve: doubling finger distance halves camera distance.
|
|
540
|
+
const delta = Math.log(Math.max(distance, 1) / Math.max(this.pinch.distance, 1)) * 100 / Math.log(0.95);
|
|
541
|
+
this.queueDolly(delta, x, y, true);
|
|
542
|
+
}
|
|
440
543
|
this.pinch.distance = distance;
|
|
544
|
+
this.requestRender();
|
|
441
545
|
}
|
|
442
546
|
handleTouchEnd(event) {
|
|
443
547
|
if (event.touches.length < 2)
|
|
@@ -472,16 +576,44 @@ export class SpatialElementInteractionController {
|
|
|
472
576
|
this.requestRender();
|
|
473
577
|
}
|
|
474
578
|
handleWheel(event) {
|
|
475
|
-
const pinch = event.ctrlKey && this.isPinchArea(event.clientX, event.clientY);
|
|
476
|
-
const hit = pinch || this.hitTestModel(event.clientX, event.clientY, event.target);
|
|
477
|
-
this.setModelHover(hit);
|
|
478
|
-
this.updateControlsAvailability();
|
|
479
579
|
if (!this._controls || !this.canInteract || event.deltaY === 0)
|
|
480
580
|
return;
|
|
581
|
+
const now = performance.now();
|
|
582
|
+
const detail = this.ports.readGeometry().detail;
|
|
583
|
+
let modelHit;
|
|
584
|
+
// Only swallow the cancelled spatial gesture. The separate 3XL content
|
|
585
|
+
// region and a changed pinch modifier represent independent new input.
|
|
586
|
+
if (now < this.cancelledWheelUntil && Boolean(event.ctrlKey) === this.cancelledWheelCtrlKey &&
|
|
587
|
+
(!detail?.split || (modelHit = this.hitTestModel(event.clientX, event.clientY, event.target)))) {
|
|
588
|
+
this.cancelledWheelUntil = now + DETAIL_WHEEL_IDLE_MS;
|
|
589
|
+
event.preventDefault();
|
|
590
|
+
event.stopImmediatePropagation();
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
this.cancelledWheelUntil = -Infinity;
|
|
594
|
+
this.lastWheelTime = now;
|
|
595
|
+
this.lastWheelCtrlKey = Boolean(event.ctrlKey);
|
|
596
|
+
const pinch = event.ctrlKey && this.isPinchArea(event.clientX, event.clientY);
|
|
597
|
+
const model = pinch || (modelHit ?? this.hitTestModel(event.clientX, event.clientY, event.target));
|
|
598
|
+
this.setModelHover(model);
|
|
599
|
+
this.updateControlsAvailability();
|
|
600
|
+
const clearingUi = detail?.media === 'minimap' &&
|
|
601
|
+
getPanelFocusProgress(detail.uiFocus ?? this.getUiFocus(this.getZoomFocusFactor())) > 0;
|
|
602
|
+
// Once panels start clearing, wheel navigation also owns the empty stage.
|
|
603
|
+
// Keep visible HTML and the separate 3XL content region independently usable.
|
|
604
|
+
const hit = model || (clearingUi && !detail?.split && this.stageViewportVisible &&
|
|
605
|
+
event.target === this.backgroundCanvas && this.isPinchArea(event.clientX, event.clientY) &&
|
|
606
|
+
!this.isPointerOccludedByHtml(event.clientX, event.clientY));
|
|
481
607
|
const atOverview = !this.fullscreen && this.getEffectiveCameraDistance() >= this._controls.maxDistance - 0.001;
|
|
482
|
-
const
|
|
608
|
+
const separateArea = this.fullscreen || detail?.split;
|
|
609
|
+
if (separateArea)
|
|
610
|
+
this.wheelGesture.reset();
|
|
611
|
+
const owner = separateArea ? (hit ? 'zoom' : 'scroll') :
|
|
612
|
+
this.wheelGesture.resolve(performance.now(), hit, event.deltaY > 0, atOverview, pinch, clearingUi);
|
|
483
613
|
if (owner === 'scroll') {
|
|
484
|
-
|
|
614
|
+
if (!separateArea)
|
|
615
|
+
this._viewResetActive = false;
|
|
616
|
+
this.clearWheelZoom();
|
|
485
617
|
// Let the browser scroll, but never let OrbitControls consume this burst.
|
|
486
618
|
this._controls.enabled = false;
|
|
487
619
|
this.requestRender();
|
|
@@ -494,20 +626,36 @@ export class SpatialElementInteractionController {
|
|
|
494
626
|
// advance from one shared damped camera distance instead.
|
|
495
627
|
event.preventDefault();
|
|
496
628
|
event.stopImmediatePropagation();
|
|
629
|
+
this.queueDolly(normalizeWheelZoomDelta(event.deltaY, event.deltaMode, event.ctrlKey), event.clientX, event.clientY);
|
|
630
|
+
}
|
|
631
|
+
queueDolly(deltaY, x, y, touch = false) {
|
|
632
|
+
if (!this._controls)
|
|
633
|
+
return;
|
|
497
634
|
this.normalizeCameraFovForOrbitControls();
|
|
498
635
|
this.clearZoomReset();
|
|
499
636
|
this._viewResetActive = false;
|
|
500
|
-
const deltaY = normalizeWheelZoomDelta(event.deltaY, event.deltaMode, event.ctrlKey);
|
|
501
637
|
const currentDistance = this.camera.position.distanceTo(this._controls.target);
|
|
502
638
|
const previousTargetDistance = this._wheelZoomTargetDistance ?? currentDistance;
|
|
503
639
|
const targetDistance = getWheelZoomTargetDistance(previousTargetDistance, deltaY, this._controls.zoomSpeed, this._controls.minDistance, this._controls.maxDistance);
|
|
504
640
|
this._wheelZoomTargetDistance =
|
|
505
641
|
Math.abs(targetDistance - currentDistance) > 0.0001 ? targetDistance : undefined;
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
this.
|
|
509
|
-
this.
|
|
510
|
-
|
|
642
|
+
// Mouse zoom-out returns to the fitted centre; a touch gesture keeps its
|
|
643
|
+
// freely movable anchor in either direction, including the damped tail.
|
|
644
|
+
this._wheelZoomOut = deltaY > 0 && !touch;
|
|
645
|
+
if (this._wheelZoomOut) {
|
|
646
|
+
// Outward dolly converges on the authored centre, regardless of cursor
|
|
647
|
+
// movement since zoom-in. Do not anchor it to another off-centre point.
|
|
648
|
+
this.zoomAnchor = undefined;
|
|
649
|
+
this.requestRender();
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
// A different pointer position chooses a new world point. Moving the old
|
|
653
|
+
// point to a new screen position would pan the model along with the mouse.
|
|
654
|
+
if (!this.zoomAnchor || (!touch && (performance.now() >= this.zoomAnchor.until ||
|
|
655
|
+
Math.hypot(this.zoomAnchor.client.x - x, this.zoomAnchor.client.y - y) > 0.5)))
|
|
656
|
+
this.captureZoomAnchor(x, y, !touch);
|
|
657
|
+
this.zoomAnchor.until = performance.now() + DETAIL_WHEEL_IDLE_MS;
|
|
658
|
+
this.setPointerNdc(x, y);
|
|
511
659
|
this._wheelZoomDirection
|
|
512
660
|
.set(this._pointerNdc.x, this._pointerNdc.y, 1)
|
|
513
661
|
.unproject(this.camera)
|
|
@@ -518,19 +666,19 @@ export class SpatialElementInteractionController {
|
|
|
518
666
|
setPointerNdc(x, y) {
|
|
519
667
|
this._pointerNdc.set(x / Math.max(window.innerWidth, 1) * 2 - 1, 1 - y / Math.max(window.innerHeight, 1) * 2);
|
|
520
668
|
}
|
|
521
|
-
captureZoomAnchor(x, y) {
|
|
669
|
+
captureZoomAnchor(x, y, pickSurface = true) {
|
|
522
670
|
this.updateStageCameraProjection();
|
|
523
671
|
this.camera.updateMatrixWorld(true);
|
|
524
672
|
this.setPointerNdc(x, y);
|
|
525
673
|
this._raycaster.setFromCamera(this._pointerNdc, this.camera);
|
|
526
674
|
const point = new THREE.Vector3();
|
|
527
|
-
const hits = this._raycaster.intersectObjects(this._modelPickTargets, false);
|
|
528
|
-
const plane =
|
|
529
|
-
if (hits
|
|
675
|
+
const hits = pickSurface ? this._raycaster.intersectObjects(this._modelPickTargets, false) : undefined;
|
|
676
|
+
const plane = this.zoomAnchorPlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.zoomAnchorNormal), this._controls.target);
|
|
677
|
+
if (hits?.length)
|
|
530
678
|
point.copy(hits[0].point);
|
|
531
679
|
else if (!this._raycaster.ray.intersectPlane(plane, point))
|
|
532
680
|
point.copy(this._controls.target);
|
|
533
|
-
this.zoomAnchor = { point, client: new THREE.Vector2(x, y), until: performance.now() +
|
|
681
|
+
this.zoomAnchor = { point, client: new THREE.Vector2(x, y), until: performance.now() + DETAIL_WHEEL_IDLE_MS };
|
|
534
682
|
}
|
|
535
683
|
/** Run after the scroll-dependent projection has changed, before rendering. */
|
|
536
684
|
compensateZoomAnchor() {
|
|
@@ -544,17 +692,19 @@ export class SpatialElementInteractionController {
|
|
|
544
692
|
this.camera.updateMatrixWorld(true);
|
|
545
693
|
this.setPointerNdc(anchor.client.x, anchor.client.y);
|
|
546
694
|
this._raycaster.setFromCamera(this._pointerNdc, this.camera);
|
|
547
|
-
const plane =
|
|
548
|
-
const intersection = this._raycaster.ray.intersectPlane(plane,
|
|
695
|
+
const plane = this.zoomAnchorPlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.zoomAnchorNormal), anchor.point);
|
|
696
|
+
const intersection = this._raycaster.ray.intersectPlane(plane, this.zoomAnchorIntersection);
|
|
549
697
|
if (!intersection)
|
|
550
698
|
return;
|
|
551
|
-
const shift = anchor.point
|
|
699
|
+
const shift = this.zoomAnchorShift.copy(anchor.point).sub(intersection);
|
|
552
700
|
this.camera.position.add(shift);
|
|
553
701
|
this._controls.target.add(shift);
|
|
554
702
|
this.camera.updateMatrixWorld(true);
|
|
703
|
+
if (!this.pinch && this._wheelZoomTargetDistance === undefined)
|
|
704
|
+
this.zoomAnchor = undefined;
|
|
555
705
|
}
|
|
556
706
|
requestScrollZoomReset(scrollDelta) {
|
|
557
|
-
if (!this._controls || this.fullscreen)
|
|
707
|
+
if (!this._controls || this.fullscreen || this._viewResetActive || this.ports.readGeometry().detail?.split)
|
|
558
708
|
return;
|
|
559
709
|
if (this.pinch || this._interactionPointers.size > 1 ||
|
|
560
710
|
(this._wheelZoomTargetDistance !== undefined && this.wheelGesture.zooming(performance.now())))
|
|
@@ -582,6 +732,7 @@ export class SpatialElementInteractionController {
|
|
|
582
732
|
const currentDistance = this.camera.position.distanceTo(this._controls.target);
|
|
583
733
|
const targetDistance = THREE.MathUtils.clamp(this._zoomResetTargetDistance, this._controls.minDistance, this._controls.maxDistance);
|
|
584
734
|
const nextDistance = THREE.MathUtils.damp(currentDistance, targetDistance, ZOOM_RESET_DAMPING, delta);
|
|
735
|
+
this.restoreStageAlignment(currentDistance, nextDistance);
|
|
585
736
|
this.setCameraDistance(nextDistance);
|
|
586
737
|
this.camera.fov = THREE.MathUtils.damp(this.camera.fov, this._initialCameraFov, ZOOM_RESET_DAMPING, delta);
|
|
587
738
|
this.camera.updateProjectionMatrix();
|
|
@@ -591,6 +742,7 @@ export class SpatialElementInteractionController {
|
|
|
591
742
|
this.camera.fov = this._initialCameraFov;
|
|
592
743
|
this.camera.updateProjectionMatrix();
|
|
593
744
|
if (targetDistance >= this._controls.maxDistance - 0.001) {
|
|
745
|
+
this._viewportCentering = 0;
|
|
594
746
|
this.clearZoomReset();
|
|
595
747
|
}
|
|
596
748
|
else {
|
|
@@ -602,20 +754,21 @@ export class SpatialElementInteractionController {
|
|
|
602
754
|
applyViewReset(delta) {
|
|
603
755
|
if (!this._controls || !this._viewResetActive || !this._initialViewCaptured)
|
|
604
756
|
return;
|
|
605
|
-
this._viewResetElapsed += Math.max(delta, 0);
|
|
757
|
+
this._viewResetElapsed += this.reducedMotion?.matches ? this._viewResetDuration : Math.max(delta, 0);
|
|
606
758
|
const interpolation = getViewResetInterpolation(this._viewResetElapsed, this._viewResetDuration);
|
|
759
|
+
this._viewportCentering = THREE.MathUtils.lerp(this._viewStartCentering, this._viewEndCentering, interpolation);
|
|
607
760
|
this.camera.position
|
|
608
761
|
.copy(this._viewResetStartCameraPosition)
|
|
609
|
-
.lerp(this.
|
|
762
|
+
.lerp(this._viewEndPosition, interpolation);
|
|
610
763
|
this._controls.target
|
|
611
764
|
.copy(this._viewResetStartControlsTarget)
|
|
612
|
-
.lerp(this.
|
|
613
|
-
this.camera.fov = THREE.MathUtils.lerp(this._viewResetStartFov, this.
|
|
765
|
+
.lerp(this._viewEndTarget, interpolation);
|
|
766
|
+
this.camera.fov = THREE.MathUtils.lerp(this._viewResetStartFov, this._viewEndFov, interpolation);
|
|
614
767
|
this.camera.updateProjectionMatrix();
|
|
615
768
|
if (interpolation >= 1) {
|
|
616
|
-
this.camera.position.copy(this.
|
|
617
|
-
this._controls.target.copy(this.
|
|
618
|
-
this.camera.fov = this.
|
|
769
|
+
this.camera.position.copy(this._viewEndPosition);
|
|
770
|
+
this._controls.target.copy(this._viewEndTarget);
|
|
771
|
+
this.camera.fov = this._viewEndFov;
|
|
619
772
|
this.camera.updateProjectionMatrix();
|
|
620
773
|
this._viewResetActive = false;
|
|
621
774
|
}
|
|
@@ -638,17 +791,32 @@ export class SpatialElementInteractionController {
|
|
|
638
791
|
const targetDistance = THREE.MathUtils.clamp(this._wheelZoomTargetDistance, this._controls.minDistance, this._controls.maxDistance);
|
|
639
792
|
const nextDistance = dampAndSnap(currentDistance, targetDistance, WHEEL_ZOOM_DAMPING, delta, 0.001);
|
|
640
793
|
const radiusDelta = currentDistance - nextDistance;
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
.
|
|
646
|
-
.
|
|
794
|
+
if (this._wheelZoomOut) {
|
|
795
|
+
this.restoreStageAlignment(currentDistance, nextDistance);
|
|
796
|
+
const direction = this._wheelZoomForward.copy(this.camera.position).sub(this._controls.target).normalize();
|
|
797
|
+
const remaining = this._controls.maxDistance - currentDistance;
|
|
798
|
+
const progress = remaining > 0.0001 ? THREE.MathUtils.clamp((nextDistance - currentDistance) / remaining, 0, 1) : 1;
|
|
799
|
+
this._controls.target.lerp(this._initialControlsTarget, progress);
|
|
800
|
+
this.camera.position.copy(this._controls.target).addScaledVector(direction, nextDistance);
|
|
801
|
+
}
|
|
802
|
+
else {
|
|
803
|
+
this.camera.position.addScaledVector(this._wheelZoomDirection, radiusDelta);
|
|
804
|
+
this.camera.updateMatrixWorld(true);
|
|
805
|
+
this.camera.getWorldDirection(this._wheelZoomForward);
|
|
806
|
+
this._controls.target.copy(this.camera.position).addScaledVector(this._wheelZoomForward, nextDistance);
|
|
807
|
+
}
|
|
647
808
|
this._controls.update();
|
|
648
809
|
if (nextDistance === targetDistance)
|
|
649
810
|
this._wheelZoomTargetDistance = undefined;
|
|
650
811
|
return this._wheelZoomTargetDistance !== undefined;
|
|
651
812
|
}
|
|
813
|
+
restoreStageAlignment(current, next) {
|
|
814
|
+
if (!this._controls || next < current)
|
|
815
|
+
return;
|
|
816
|
+
const remaining = this._controls.maxDistance - current;
|
|
817
|
+
this._viewportCentering *= remaining > 0.0001
|
|
818
|
+
? THREE.MathUtils.clamp((this._controls.maxDistance - next) / remaining, 0, 1) : 0;
|
|
819
|
+
}
|
|
652
820
|
setCameraDistance(distance) {
|
|
653
821
|
if (!this._controls)
|
|
654
822
|
return;
|
|
@@ -686,6 +854,7 @@ export class SpatialElementInteractionController {
|
|
|
686
854
|
this.camera.updateProjectionMatrix();
|
|
687
855
|
}
|
|
688
856
|
handlePointerLeave() {
|
|
857
|
+
this.tap = undefined;
|
|
689
858
|
this.endPinch();
|
|
690
859
|
this.zoomAnchor = undefined;
|
|
691
860
|
this.preview.clear();
|
|
@@ -702,13 +871,13 @@ export class SpatialElementInteractionController {
|
|
|
702
871
|
this.updateControlsAvailability();
|
|
703
872
|
this.requestRender();
|
|
704
873
|
}
|
|
705
|
-
hitTestModel(clientX, clientY, target) {
|
|
874
|
+
hitTestModel(clientX, clientY, target, exact = false) {
|
|
706
875
|
// Fullscreen owns the canvas, including its empty background. UI events
|
|
707
876
|
// never reach this gate as canvas input; no geometry or DOM picking is needed.
|
|
708
|
-
if (this.fullscreen)
|
|
877
|
+
if (this.fullscreen && !exact)
|
|
709
878
|
return this.canInteract && this.stageViewportVisible && target === this.backgroundCanvas;
|
|
710
879
|
const detail = this.ports.readGeometry().detail;
|
|
711
|
-
if (detail && (detail.split || detail.paneHidden)) {
|
|
880
|
+
if (!exact && detail && (detail.split || detail.paneHidden)) {
|
|
712
881
|
if (!this.canInteract || !this.stageViewportVisible)
|
|
713
882
|
return false;
|
|
714
883
|
return resolveDetailGestureOwner({ ...detail, clientX, modelHit: false,
|
|
@@ -717,16 +886,17 @@ export class SpatialElementInteractionController {
|
|
|
717
886
|
}
|
|
718
887
|
if (!this.canInteract ||
|
|
719
888
|
!this.stageViewportVisible ||
|
|
720
|
-
clientX < this.viewportFrame.x ||
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
889
|
+
(!exact && (clientX < this.viewportFrame.x ||
|
|
890
|
+
clientX > this.viewportFrame.x + this.viewportFrame.z ||
|
|
891
|
+
clientY < this.viewportFrame.y ||
|
|
892
|
+
clientY > this.viewportFrame.y + this.viewportFrame.w)) ||
|
|
724
893
|
!this._modelPickTargets.length ||
|
|
725
894
|
isStageUiTarget(target) ||
|
|
726
895
|
this.isPointerOccludedByHtml(clientX, clientY)) {
|
|
727
896
|
return false;
|
|
728
897
|
}
|
|
729
898
|
this.updateStageCameraProjection();
|
|
899
|
+
this.camera.updateMatrixWorld();
|
|
730
900
|
this._pointerNdc.set((clientX / window.innerWidth) * 2 - 1, -(clientY / window.innerHeight) * 2 + 1);
|
|
731
901
|
this._raycaster.setFromCamera(this._pointerNdc, this.camera);
|
|
732
902
|
// This is a boolean interaction gate, not a nearest-surface query. Do not
|
|
@@ -817,11 +987,11 @@ export class SpatialElementInteractionController {
|
|
|
817
987
|
this.preview.advance(this.camera, delta, this.reducedMotion?.matches);
|
|
818
988
|
return { controls: controls || preview, wheel };
|
|
819
989
|
}
|
|
820
|
-
getRevealFocus() {
|
|
990
|
+
getRevealFocus(distance = this.getEffectiveCameraDistance()) {
|
|
821
991
|
// Start at the fitted distance, before the later UI-clearance phase. The
|
|
822
992
|
// first 35% of inward dolly reveals the whole stage without a second clock.
|
|
823
993
|
const maxDistance = this._controls.maxDistance;
|
|
824
|
-
return THREE.MathUtils.clamp((maxDistance -
|
|
994
|
+
return THREE.MathUtils.clamp((maxDistance - distance) /
|
|
825
995
|
Math.max(maxDistance * 0.35, 0.001), 0, 1);
|
|
826
996
|
}
|
|
827
997
|
/** Couple document reveal and UI clearance to one camera-driven timeline. */
|
|
@@ -848,11 +1018,11 @@ export class SpatialElementInteractionController {
|
|
|
848
1018
|
this.zoomScroll = undefined;
|
|
849
1019
|
this.previousZoomFocus = focus;
|
|
850
1020
|
}
|
|
851
|
-
getUiFocus(cameraFocus) {
|
|
1021
|
+
getUiFocus(cameraFocus, distance = this.getEffectiveCameraDistance()) {
|
|
852
1022
|
const normal = getStageUiFocus(cameraFocus);
|
|
853
1023
|
if (!this.zoomScroll || this.ports.readGeometry().detail?.split)
|
|
854
1024
|
return normal;
|
|
855
|
-
const progress = THREE.MathUtils.clamp((this.getRevealFocus() - this.zoomScroll.focus) /
|
|
1025
|
+
const progress = THREE.MathUtils.clamp((this.getRevealFocus(distance) - this.zoomScroll.focus) /
|
|
856
1026
|
Math.max(1 - this.zoomScroll.focus, 0.001), 0, 1);
|
|
857
1027
|
return Math.max(normal, getPanelFocusFromProgress(THREE.MathUtils.lerp(this.zoomScroll.uiProgress, 1, progress)));
|
|
858
1028
|
}
|