Skip to content

Commit a2c2c9a

Browse files
authored
ensure pan target appears and disappears correctly (#3354)
1 parent 747695b commit a2c2c9a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/model-viewer/src/three-components/SmoothControls.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -647,15 +647,16 @@ export class SmoothControls extends EventDispatcher {
647647
}
648648

649649
private recenter(pointer: Pointer) {
650+
const {scene} = this;
651+
(scene.element as any)[$panElement].style.opacity = 0;
652+
650653
if (!this.enablePan ||
651654
Math.abs(pointer.clientX - this.startPointerPosition.clientX) >
652655
TAP_DISTANCE ||
653656
Math.abs(pointer.clientY - this.startPointerPosition.clientY) >
654657
TAP_DISTANCE) {
655658
return;
656659
}
657-
const {scene} = this;
658-
(scene.element as any)[$panElement].style.opacity = 0;
659660

660661
const hit = scene.positionAndNormalFromPoint(
661662
scene.getNDC(pointer.clientX, pointer.clientY));
@@ -673,15 +674,17 @@ export class SmoothControls extends EventDispatcher {
673674
}
674675

675676
private resetRadius() {
677+
const {scene} = this;
678+
(scene.element as any)[$panElement].style.opacity = 0;
679+
676680
if (!this.enablePan || this.panPerPixel === 0) {
677681
return;
678682
}
679-
const {scene} = this;
680-
(scene.element as any)[$panElement].style.opacity = 0;
681683

682684
const hit = scene.positionAndNormalFromPoint(vector2.set(0, 0));
683-
if (hit == null)
685+
if (hit == null) {
684686
return;
687+
}
685688

686689
scene.target.worldToLocal(hit.position);
687690
const goalTarget = scene.getTarget();
@@ -767,7 +770,7 @@ export class SmoothControls extends EventDispatcher {
767770
null :
768771
this.touchModeZoom;
769772
this.touchDecided = true;
770-
if (this.enablePan) {
773+
if (this.enablePan && this.touchMode != null) {
771774
this.initializePan();
772775
const x = 0.5 * (targetTouches[0].clientX + targetTouches[1].clientX);
773776
const y = 0.5 * (targetTouches[0].clientY + targetTouches[1].clientY);

0 commit comments

Comments
 (0)