Skip to content

Instantly share code, notes, and snippets.

@robksawyer
Created August 24, 2020 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save robksawyer/58d35d7efcbc972f234e2bbfd180dda7 to your computer and use it in GitHub Desktop.
Save robksawyer/58d35d7efcbc972f234e2bbfd180dda7 to your computer and use it in GitHub Desktop.
React Three Fiber organic movement snippet
// main sphere rotates following the mouse position
useFrame(({ clock, mouse }) => {
main.current.rotation.z = clock.getElapsedTime();
main.current.rotation.y = THREE.MathUtils.lerp(
main.current.rotation.y,
mouse.x * Math.PI,
0.1
);
main.current.rotation.x = THREE.MathUtils.lerp(
main.current.rotation.x,
mouse.y * Math.PI,
0.1
);
});
@robksawyer
Copy link
Author

useFrame(({ clock, mouse }) => {
    group.rotation.y = THREE.MathUtils.lerp(
      group.rotation.y,
      mouse.x / Math.PI,
      0.1
    )
    group.rotation.x = THREE.MathUtils.lerp(
      group.rotation.x,
      mouse.y / Math.PI,
      0.1
    )
  })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment