Syntax Video
this website is insane (stack explained)
LANDO
A couple days ago, this Lando Norris website dropped and everybody is freaking out about it. It's just got this really cool 3D animation which is like eight layers deep, some really cool scroll effects on it. Uh when you hover over everything, the divs are non-standard shapes. The more time you spend on this website, the more you realize there's just so many nifty little parts. So, of course, I downloaded all 75,000 lines of code and dug through it, and I found so many neat approaches. So, I'm going to break down how they did it, what technology they used, and and ideally how you can build something like this yourself. All right, let's start with this like scene right here. So, this is 3JS 3D canvas. And the more I looked into the code, the more I realized like there's seven or eight different layers here at play. So, let's break it down. So, at the very basic, there is just an image of Lando, right?
3D Helmet Effect
And as you move your cursor around, you'll see he's kind of moving around just a little bit. Um, and it gives a subtle 3D effect, and that's using something called depth maps. Um, so depth maps are pretty cool. You can generate them with like a special camera, but AI is also really good at it. So, here I I built a little demo, and it will take this image and try to estimate what is of depth. So here here look at this thing. The white stuff is closer whereas the darker stuff is further away. And then you can throw that into a 3D canvas and like you can really exaggerate it. Like it can it [laughter] can be pretty crazy here, right? Um but normally what you do, and this is what they're doing at Lando, is you just give it a little bit of a subtle thing to it and then you move it around like that. And that's a really cool um effect. And it actually works like pretty well. like even if you go to the things in the background, um it can find like the leaves on the tree.
So that's a depth map that they have over top of him. Um but there's also an alpha map which is just for punching out the photo of him. And then there is a roughness map. And a roughness map is when light hits it, uh how does it reflect, you know? So, the white is going to be uh absorb the colors really well and then the darker colors are going to reflect the light a little well. And you can hardly see it as you move around, but it's just very subtle.
And of course, on top of that, they are rendering out the helmet. They're rendering out the 3D view of this helmet. And they actually have a second image of him with a slightly darker um let me show you. I think it's called like shadow. There we go. There's a slightly darker shadow underneath here to make it look like when he has the the helmet on. On top of that, they are rendering out the helmet and then deciding what they show.
Blob Masking
It's just being masked on and off via custom shaders. And it's using some sort of custom shader that makes these blobs. Um not explicitly sure if it's this one or not, but this is kind of the idea. Um where it's like a fluid cursor. as you move it, depending on how fast you move it and and what angle you move it, it will generate these blobs. Um, and then you can mask out the different parts while showing it. So, pretty nifty thing on the 3D. But let's go a little bit further and look on the on track page here. Um, and they have this custom rendering of this helmet. This is really cool. So, the helmet is also done in 3JS, which is rendered out in 3D. Um, and this is this is what the helmet is.
I downloaded it. It's a what a glTF file. Um, and it's just this just a blank model that you have here. And you can kind of spin it around. Then each of the helmets that he has, cuz there's several different helmets, all have their designs um up as a map. So you see here's like one of the ones with the monster energy design on top of it. Uh here's another one. It's actually kind of cool to to see this. So it's all designed in flat. Um, and then 3JS will apply that to the model. But that's not it. That's just that's just one part of it, right? There's also this base color on here. So, all of them have this little McLaren um and Android on the visor. There also is maps for which parts of the helmet are metallic. Um, there's a normal map. And this one is really cool. So, as you scroll, you're going to see how the light hits this black part of the visor right here. And it obviously the buttons don't the
3D Helmet Rendering
buttons reflect differently than the actual visor. And that's because of this map right here, the roughness map. So something that is black in the roughness map, this is the visor, is going to reflect light quite a bit. And things that are gray and and and more towards the white side are not going to reflect light very much. So you can see that they're reflecting light a little different. There's then the buttons are you're saying which parts are metallic and how they reflect light. There's just so much to it and then as you scroll the whole thing kind of spins around. I thought this was really cool cuz like the Apple website does a lot of stuff like this but often Apple will just render out a video and and they'll just scrub that video back and forth as you're scrolling. No, no. This is this is an actually like a 3D model that is spinning around and having seven or eight different maps and mats applied to it. Scrolling on this website is entirely implemented in JavaScript. So,
Scrolling
normally I'm a scrolljacking hater because it's so frustrating to visit a website that takes over your scroll. But this one's using a library called leanest which does a pretty good job at it and it feels fairly natural. and allows you to do things like like go sideways or position sticky things when they come in. There are browser APIs of scroll driven animations along with things like position sticky to allow you to do this. However, they're not it's not in Firefox yet. And I'm assuming that's why they didn't use this. So, that still works. You can still press spacebar. You can still search for words on here and it will jump to where they are on the page. So, it actually feels pretty good. It uses a library called Lenus which are simply just updating inline style values. So it's not using web animations API or anything like that. And surprisingly it's actually using jQuery and a library called tram which was last updated 9 years ago. And
Animations
I don't know what the reason for that is. I'm assuming they've used it for probably many websites and they have a whole bunch of code that's written in it. that is simply just updating inline style values and it actually works pretty well and is pretty butter smooth. I'll talk about performance in just a sec. Now, as you scroll down to the helmet section, they got these really interesting shapes and then as you hover over each of the helmets, you see an actual photo of them wearing it. And if you scroll all the way to the bottom, you see this really cool shape. So, these are doing these are being done with CSS masking. So, if I were to inspect element on one of these, you'll see there's a mask URL, which is just an SVG of that shape and they go ahead and make a mask of it. So, if we turn those off, you see it's just a regular square, and then by adding it, it just simply just punches those values out. The helmets are done in very much the same way. However, there are several different masks. And then this little
Non-standard Div Shapes
animation that is done here when you hover over top of it uses a clip path mask instead of an explicit SVG file mask. So here we go. Clip path ellipse. And then you hover over top of it and the ellipse will simply just grow and mask off the image that's on top of it. For text effects, there's this really cool effect when you hover over top of these elements and the text will go up and down. This is just a regular CSS transition where the each single letter is wrapped in a span and they animate up. In fact, we did coming up on the syntax YouTube channel. Make sure you subscribe um implement our own version of this. So basically we just wrap every single letter in a span and then we transition the uh or so we transition the transform value up 100% and then we put a transition delay on every single letter that increases by I don't know 0.1 milliseconds or something like that every single time you hover over top of
Text Effects
it. Pretty cool little effect. I love seeing that on websites. Transitioning from page to page is actually really cool. So when I click on one of these, you'll see let's let me show you that again. That's really cool. So it just throws up this whole screen loader and then in the background it loads the page and then it will mask out that loader on its way out so you can see the new page in there. I love that effect. I think we're going to have to build that one as well. Um, unfortunately, this is not using the page transition API and it's simply just when you click on a link, it's going to load everything in the background and it's going to swap out as it puts up that curtain, it's swapping out the document um, HTML and then once it's done, it will animate itself back on out. And you can see in the dev tools here, page uh, page start, page transition, and it shows how long it takes to transition from page to page.
Page Transitions
I'm assuming there's some sort of timeout in there as well should it take too long. But there's no React framework, nothing like that in here. It's simply just a bunch of vanilla JavaScript and what we saw earlier, a little bit of jQuery for that animation. When we head over to this on the track page here, you'll see that there's these like little cool every single race that he has, there's a track and it's just being highlighted over and over again.
Custom Drawn Animations
So, I was like looking like how are they how are they doing that? You know, is that a video file? It's actually done in 3D canvas, but it was designed with a tool called Rive. Um, and I guess Rive is I'm not familiar with this, but Rive is a 3D design tool that will allow you to export your designs and interactions to multiple platforms. One of those platforms being done in Wom um, which can then be piped into a 3D canvas. So I downloaded the riv binaries. So they compile to these binaries and I ran them on this riv. website and you can see that like this is this is one circuits.
Or circuits. And you can just change between all the different tracks but then there's also like these different states. Hover off, hover on, you can change Miami. Um, there's some pretty cool stuff in here. And all the nifty animations on here, like this one as well. These little I don't know what you call these.
These little flowers that pop up over the NASCAR helmet. They are also done in this this riv format. So, it's just like I guess a way to design in a 3D program and get them onto your website. On the homepage, his signature is also done like that as well. So I'm normally I would do this with like an SVG and then you will do like an offset path on the SVG but in this case they are simply just painting it in depending on how far in you are scrolled and you can kind of scrub it back and forth with your scroll wheel. Now let's talk about performance.
Signature Draw
Performance
Normally websites like these are a little bit chuggy. And normally, I'm sure there's a bunch of people in the comments right now being like, "What a waste of CPU space. I can hardly it freezes my Android from 40 years ago." These kind types of websites are generally pretty aggressive on using system resources. So, I was like, "This actually feels kind of buttery. Pretty feels pretty good." It's maybe one of the best feeling websites I've seen that are just so over the top like this. So, if you go into your dev tools and you open up and you type FPS, you can open up a frames per second meter and then you just scroll the website and it will tell you how many frames a second you're getting. This thing is getting it's almost impossible to get it to drop a frame. You know, maybe if we do something like like switch the pages, you'll see a couple There we go. You see a couple drop frames as it was doing that initial render. That's usually pretty normal. But like this whole
thing, I'm just crazy scrolling all over it and I'm unable to get it to drop a frame. Granted, I have a pretty fast M1 Mac computer, but that's pretty rare for me to see a website like this that does not drop frames like that and and maintains to be so buttery. Now, how did they do this, right? I think it's it's a couple reason. First of all, there's no drop shadows on anything. I used to throw drop shadows on everything and that it overlaps things and it it gets expensive to calculate those because you have to calculate what is behind it.
This is a very flat design. Um there's not a lot of filters, not a lot of blurring, not a lot of gradients, not a lot of position absolute. They try to stay away from a lot of that. Most of the animations that I see them do are done with just straight up transform, which is the best thing you can do for performance when you're doing animations. if you're animating like a font size or you're trying to animate like top left, bottom right, those things can start getting a little bit chuggy. So, if you can keep everything to just using straight up transforms, you're usually going to be in pretty good shape. And this is a very good example of that. Now, Easter eggs, couple cool things. First of all, dev tools, look at the console log. Get ready for it. Get ready for it. Boom.
Easter Eggs
Lando Norris in the console log. You can actually color your console logs if you want to. You just click through to that. You can see in here the console log, you do percent C and then everywhere you want to color change and then you pass the color as the second argument along with the the actual font and font weight. I thought that was a pretty neat Easter egg. The loader itself says load Norris, which I thought was a nice little hat tip. It's obviously the designers of this spent quite a bit of time. Lastly, the very coolest thing, go to the website and hit your F1
Quote it with credit and a link. Quoting Syntax