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

fix: some tweenjs animations not triggering #4736

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion viewer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cognite/reveal",
"version": "4.17.0",
"version": "4.17.1",
"description": "WebGL based 3D viewer for CAD and point clouds processed in Cognite Data Fusion.",
"homepage": "https://github.com/cognitedata/reveal/tree/master/viewer",
"repository": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default class Image360VisualTestFixture extends StreamingVisualTestFixtur
function animateTransition() {
const from = { t: 0 };
const to = { t: 1 };
const anim = new TWEEN.Tween(from)
const tween = new TWEEN.Tween(from)
.to(to, 1000)
.onUpdate(() => {
const animatedPosition = new THREE.Vector3().lerpVectors(translationFrom, translationTo, from.t);
Expand All @@ -170,9 +170,10 @@ export default class Image360VisualTestFixture extends StreamingVisualTestFixtur
})
.easing(num => TWEEN.Easing.Quintic.InOut(num))
.start(TWEEN.now());
TWEEN.add(tween);

anim.onComplete(() => {
anim.stop();
tween.onComplete(() => {
tween.stop();
clearInterval(renderTrigger);
camera.position.copy(translationTo);
const cameraForward = camera.getWorldDirection(new THREE.Vector3());
Expand Down
10 changes: 8 additions & 2 deletions viewer/packages/api/src/api-helpers/Image360ApiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ export class Image360ApiHelper {
})
.easing(num => TWEEN.Easing.Quintic.InOut(num))
.start(TWEEN.now());
TWEEN.add(tween);

return new Promise(resolve => {
tween.onComplete(() => {
Expand All @@ -420,6 +421,7 @@ export class Image360ApiHelper {
.delay(delay)
.easing(num => TWEEN.Easing.Quintic.InOut(num))
.start(TWEEN.now());
TWEEN.add(tween);

return new Promise(resolve => {
tween.onComplete(() => {
Expand Down Expand Up @@ -608,7 +610,7 @@ function moveCameraPositionTo(manager: FlexibleCameraManager, position: Vector3,
const tempPosition = new Vector3();
manager.controls.temporarilyDisableKeyboard = true;

new TWEEN.Tween(from)
const tween = new TWEEN.Tween(from)
.to(to, duration)
.onUpdate(() => {
tempPosition.set(from.x, from.y, from.z);
Expand All @@ -624,13 +626,15 @@ function moveCameraPositionTo(manager: FlexibleCameraManager, position: Vector3,
manager.controls.temporarilyDisableKeyboard = false;
})
.start(TWEEN.now());

TWEEN.add(tween);
}

function tweenCameraToDefaultFov(manager: FlexibleCameraManager, duration: number): void {
const from = { fov: manager.controls.fov };
const to = { fov: manager.controls.options.defaultFov };
const delay = duration * 0.25;
new TWEEN.Tween(from)
const tween = new TWEEN.Tween(from)
.to(to, duration * 0.5)
.onUpdate(() => {
manager.controls.setFov(from.fov);
Expand All @@ -641,4 +645,6 @@ function tweenCameraToDefaultFov(manager: FlexibleCameraManager, duration: numbe
.delay(delay)
.easing(num => TWEEN.Easing.Quintic.InOut(num))
.start(TWEEN.now());

TWEEN.add(tween);
}
2 changes: 2 additions & 0 deletions viewer/packages/camera-manager/src/Flexible/moveCamera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ export function moveCameraTargetTo(manager: FlexibleCameraManager, target: Vecto
removeEventListeners();
})
.start(TWEEN.now());

TWEEN.add(tween);
}

function createTweenAnimationWithStop<T extends Record<string, any>>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export class StationaryCameraManager implements CameraManager {
})
.easing(num => TWEEN.Easing.Quintic.InOut(num))
.start(TWEEN.now());
TWEEN.add(tween);

return new Promise(resolve => {
tween.onComplete(() => {
Expand Down
Loading