(perspective grid that might be useful to illustrate what I mean) I’ve been trying to create what I’d describe as a "dynamic perspective infinite marquee". Specifically I’m using this video as a reference.
Screenshot of it attached.
Any help would be massively appreciated.
I’ve been pulling my hair out trying to adapt this codepen, which has a similar outcome, but all my attempts to turn it into an infinite scroll instead of working from the mouse’s x-axis have failed.
The transform in the previous link does give a similar effect (added so I can link the codepen):
.left-3d {
position: absolute;
transform-origin: right center;
transform: rotateY(100deg);
top: 0;
bottom: 0;
right: 100%;
}
#left {
transform: translateX(0%);
}
#center {
transform: translateX(-100%);
}
.right-3d {
position: absolute;
transform-origin: left center;
transform: rotateY(-100deg);
top: 0;
bottom: 0;
left: 100%;
}
#right {
transform: translateX(-200%);
}
So far I’ve been using vanilla html/css/js. Someone mentioned to me this effect would be easy to replicate in Three.js/R3F but I don’t know where to start on that.
Any help would be massively appreciated!
EDIT: Apologies for any faux pas in this question, I’m very new to this
2
Answers
here i made small infinite scroll example and i think you can a little adapt it and use:
small infinite y scroll example on codepen (no rendering on canvas)
the main idea of this realization of infinite scroll is using:
mod(yScroll+elementCenter.x, parentElement.width) – elementCenter.x
to set element position
this script calculate each element x center position which must be scrolled and save it as css variable so css can calculate value for translateX
Also it set scroll from wheel event and add some behaviour when element is going to jump from end to start or vice versa (element become transparent before jump, (if 1/4 width of element is out of bounds it become transparent))
small infinite y scroll example on codepen (no rendering on canvas)
CSS is pretty good at 3d so this snippet gives a pure CSS method.
First the ‘room’ is drawn. This consists of 3 walls with the two side walls at 90 degrees to the back wall. This snippet makes them all an equal size.
The ‘observer’ is placed using the perspective CSS property, you can change that plus the size of the walls as you wish.
The images are then drawn as background images on each wall. The fairly common way of creating an infinite marquee on each – having two copies and moving the strip by just 50% of its width, so giving a continuous flow – is used.
Each wall positions its after pseudo element which has this strip of images slightly differently so to start with the left wall shows the first image, the back wall the second and the right all the third.
Then as they move the images look as though they are going through 90degrees to the next wall.
You will want to play with the sizing and the number of images to suit your particular use case.