Skip to content
Discussion options

You must be logged in to vote

Instead of using the images directly through destructuring, keep them in the image array and track the current image and the last image.

  const [currentIndex, setCurrentIndex] = useState(0); // index of the image you'll transition to
  const [lastIndex, setLastIndex] = useState(0); // index of the image you'll transition away from
  const images = useLoader(
    THREE.TextureLoader,
    imageData.map((v) => v.image)
  ); // all the images

Use the 'uProgress' value to do the transition effect.

  useFrame(() => {
    ref.current.uTime = clock.getElapsedTime(); // animates the waves
    ref.current.uProgress += (1 - ref.current.uProgress) * 0.1;  // animates the transition
  });

Then, eac…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@noahtrotman
Comment options

@mwmwmw
Comment options

@noahtrotman
Comment options

@mwmwmw
Comment options

@noahtrotman
Comment options

Answer selected by noahtrotman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants