React Three Fiber - Infinite Scroll Carousel which has latency #3013
Unanswered
KILLIAN-LEBRAS
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hii Everyone 😁
For context I am a beginner developer, currently working on a portfolio. On one page I have an infinite slider with deformation effects, so I decided to do it with React three Fiber + Drei.
So I have a carousel, in which I declare an instance of Lenis to be able to retrieve a smooth virtual scroll (scrollDelta, scrollOffset), which allow me to define the position of my projects on the carousel (I took inspiration from existing things to be able to move projects and give an infinite look)
I calculate the position and I pass the position, the scrollOffset and the scrollDelta as parameters to my project components which are plane extensions (of Drei) in order to manage their position and add anmations on the shaders to the scroll
First I went through ScrollControl, but I had a lot of things that I didn't have control over, and problems with the moving part and I was advised to do that "from scratch" to be able to have the full control
The problem is that even the simple change of position of my elements creates a small latent, and when I try to add shader animations that's where it really gets messy with a latency which creates glitch effects. . while the advantage I had with scrollcontrols was that it wasn't too slow..
`
import { useRef, useState, useEffect, useMemo, useCallback } from 'react';
import { useFrame, useThree, extend } from '@react-three/fiber';
import { Plane, useTexture } from '@react-three/drei';
import Lenis from '@studio-freight/lenis';
//Effet Lerp
import { lerp } from 'three/src/math/MathUtils';
extend({ Plane });
function Project({ index, scale, position, widthGap, scrollOffset, scrollDelta, ...props }) {
}
function Carousel({ ProjectWidth, ProjectHeight, gap, permanentProject }) {
}
`
I tried some things, an approach without using useState but which did not work at all, i also for example tried to remove Lenis thinking that it was the problem and doing a home scroll, but without success, so I'm asking here if you don't have any clues. improvement of my method and ways to overcome this problem
thanks in advance ! good day to all
Beta Was this translation helpful? Give feedback.
All reactions