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

question. in react, on initial loading, want to use both zooming and rotating. #68

Open
ctxwing opened this issue May 14, 2023 · 2 comments
Labels
❓ Question Asking question about @egjs/view3d

Comments

@ctxwing
Copy link

ctxwing commented May 14, 2023

question. in react, on initial loading,
want to use both zooming and rotating.
a little bounging in zoom and rotate too.
say for this as showup effect.
for examle,
say on first load,set zoom 0.7, rotate -20 degree..
during 300 ms, want apply both zooming to 1.1 and( ) rotating to 5.
then biunce back to zoom 1.0 and rotation 0.

any good way to do this?
I really appreciate if you give me a hit.
thanks in advance.

@WoodNeck
Copy link
Member

Hello @ctxwing
You can set initial zoom and camera angles with our options (initialZoom, yaw, pitch, pivot)

After when View3D's ready event is triggered, which means your 3D model is loaded, you can apply animations with view3d.camera.reset().
You can use easing functions for the bouncing effect.
I didn't test the below script, but here's a rough way to how.

import View3D, { Pose } from "@egjs/view3d"

const view3D = new View3D(el, {
  initialZoom: 0.7,
  yaw: -20
})

function easeOutBack(x: number): number {
  const c1 = 1.70158;
  const c3 = c1 + 1;

  return 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2);
}

view3D.on("ready", async () => {
  // new pose to change
  await camera.reset(300, easeOutBack, new Pose(0, 0, 1));
});

@ctxwing
Copy link
Author

ctxwing commented May 19, 2023

@WoodNeck .
sorry for late responding.. thats awesome.. thanks . I will try to appy. thanks again

@malangfox malangfox added the ❓ Question Asking question about @egjs/view3d label May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ Question Asking question about @egjs/view3d
Projects
None yet
Development

No branches or pull requests

3 participants