Skip to content

Commit 33b8d43

Browse files
authored
consistent interpolationDecay for synthetic interaction (#3449)
1 parent 0e28c7b commit 33b8d43

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

packages/model-viewer/src/features/controls.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ const $lastSpherical = Symbol('lastSpherical');
231231
const $jumpCamera = Symbol('jumpCamera');
232232
const $initialized = Symbol('initialized');
233233
const $maintainThetaPhi = Symbol('maintainThetaPhi');
234-
const $setInterpolationDecay = Symbol('setInterpolationDecay');
235234

236235
const $syncCameraOrbit = Symbol('syncCameraOrbit');
237236
const $syncFieldOfView = Symbol('syncFieldOfView');
@@ -477,6 +476,7 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
477476
super.updated(changedProperties);
478477

479478
const controls = this[$controls];
479+
const scene = this[$scene];
480480
const input = this[$userInputElement];
481481

482482
if (changedProperties.has('cameraControls')) {
@@ -507,7 +507,7 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
507507
}
508508

509509
if (changedProperties.has('bounds')) {
510-
this[$scene].tightBounds = this.bounds === 'tight';
510+
scene.tightBounds = this.bounds === 'tight';
511511
}
512512

513513
if (changedProperties.has('interactionPrompt') ||
@@ -537,13 +537,14 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
537537
}
538538

539539
if (changedProperties.has('interpolationDecay')) {
540-
this[$setInterpolationDecay](this.interpolationDecay);
540+
controls.setDamperDecayTime(this.interpolationDecay);
541+
scene.setTargetDamperDecayTime(this.interpolationDecay);
541542
}
542543

543544
if (this[$jumpCamera] === true) {
544545
Promise.resolve().then(() => {
545546
controls.jumpToGoal();
546-
this[$scene].jumpToGoal();
547+
scene.jumpToGoal();
547548
this[$jumpCamera] = false;
548549
});
549550
}
@@ -617,7 +618,6 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
617618
const moveTouches = () => {
618619
// cancel interaction if user interacts
619620
if (this[$controls].isUserChange) {
620-
this[$setInterpolationDecay](this.interpolationDecay);
621621
for (const fingerElement of this[$fingerAnimatedContainers]) {
622622
fingerElement.style.opacity = '0';
623623
}
@@ -630,14 +630,12 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
630630
position.x = xy[i].x(time);
631631
position.y = xy[i].y(time);
632632
}
633-
this[$setInterpolationDecay](0);
634633
dispatchTouches('pointermove');
635634

636635
if (time < 1) {
637636
requestAnimationFrame(moveTouches);
638637
} else {
639638
dispatchTouches('pointerup');
640-
this[$setInterpolationDecay](this.interpolationDecay);
641639
document.removeEventListener('visibilitychange', onVisibilityChange);
642640
}
643641
};
@@ -781,11 +779,6 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
781779
this[$promptElementVisibleTime] = Infinity;
782780
}
783781

784-
[$setInterpolationDecay](decay: number) {
785-
this[$controls].setDamperDecayTime(decay);
786-
this[$scene].setTargetDamperDecayTime(decay);
787-
}
788-
789782
/**
790783
* Updates the camera's near and far planes to enclose the scene when
791784
* orbiting at the supplied radius.

0 commit comments

Comments
 (0)