Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: animation abort controller #2

Open
Link2Twenty opened this issue Apr 10, 2023 · 1 comment
Open

Feature request: animation abort controller #2

Link2Twenty opened this issue Apr 10, 2023 · 1 comment

Comments

@Link2Twenty
Copy link

Hi, when animation a camera position I would love to have an abort controller support so I can relinquish camera control to the user if they start trying to move the view.

Currently I use my own camera moving scripts and do this

const controller = new AbortController();
const canvas = scene.getEngine().getRenderingCanvas();

const onFocus = () => controller.abort();

canvas?.addEventListener('focus', onFocus);
canvas?.addEventListener('wheel', onFocus);

// move camera
await Promise.all([
  animateCameraTo(camera, scene, controller.signal),
  animateCameraTo({ ...camTarget, prop: 'target', duration: 500 }, scene, controller.signal),
]);

canvas?.removeEventListener('focus', onFocus);
canvas?.removeEventListener('wheel', onFocus);

and I think it would be a great addition to the run function.

@Dok11
Copy link
Owner

Dok11 commented Apr 18, 2023

You can save result of animation and stop them when it need.

this.pointAnimatables = EasyPropAnimation.run(camera, {
  target: newTarget,
  transition: 'all 1s linear',
});

private stopPointAnimation(): void {
  this.pointAnimatables?.forEach((animatable) => animatable.stop());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants