 Once again, this is part of a series. There should be an annotation on the screen to the full playlist. I really see a new video every week, so if you're watching the playlist and you get to a video that's marked private, that's due to the fact that I haven't published it yet. Next Friday there will be a new one published. And we've been working with 3js, a library that allows you to create 3d objects and scenes in HTML5 with ease. So far we've done things like creating a simple plane and creating a simple cube with a camera on a scene. And we've rotated the camera and objects by putting in numeric values. But really when it comes to rotating stuff, especially working with 3d stuff, you're going to have to know a little bit as far as you don't necessarily have to do the math, because the code is going to do the math for you, but how things work. For example, right now we have this cube, oddly long-shaped cube, and the camera looking at it. This is the code for it here. It's the same code we were working with last week, but I copied it to a new file called camera rotate. And as you can see, for the cube rotation, I set it to 0.5, and the rotation of the camera I set to 0.75, or 0.7. I don't even really need that zero there, but originally I had a 0.75, which I believe is pretty close to 45 degrees of rotation. So how do we get exactly or as close as possible with the computer to get to 45 degrees? Well, we need a little bit of math using pi. If you're familiar with mirror at all with geometry and math, you've heard of pi, pi, 3.14, really long decimal point value. And of course that has to do with, you know, calculating the circumference of a circle, or the curvature of a circle. And since we're working with rotation, we're working with, you know, circles in a way. So how do we get 45 degrees? Well, it's actually really simple. As we want 45, and how do we get that in degrees? Well, we are going to take that number and times it by whatever the value of, we're going to use JavaScript math, pi. So that puts in the value of pi to whatever decimal point JavaScript can handle pi down to. So you don't have to write out pi, the value of pi each time. And we're going to divide that by 180, because we're basically 180 is turning around. So we want that half circle there and then we can use negative numbers to do the other half. So 180 degrees, so pi divided by 180 degrees times. So that would basically get you one degree and you multiply that by 45 to get degrees you want. So when I do that, hit F5, you know, as it moved a little bit, because when I put 0.75, it was rounded a little bit. Now, what is the value of 45 times whatever pi divided by 180 is? So again, pi divided by 180 should give us one degree. And then multiplying that by 45 will give us a 45 degrees. Let's see what that value is. And we don't have to do the math. We'll let JavaScript do the math for us. We're going to say alert. And we're going to put that mathematical equation of 45 times the output of pi divided by 180. So when we start up our page, we'll get an alert page and it says here 45 degrees is actually 0.7853981633974483. So my rounding of 0.75 was relatively close. So we'll remove that alert so we don't get that every time we start our page up. Let's say we wanted to go 15 degrees. We can just change that to 15, save the file, refresh the page, and we rotated 15 degrees. And of course this is on the x-axis, so it will be rotating us up and down looking straight on. So if we want to point the camera more up, we can say 65 degrees. And the cube is down off the page now. We can't see it. Oh, that would be why. I do that sometimes by accident when I type fast, which I am doing. I really should slow down my typing. There it is when I'm doing tutorials. So that's rotating the camera, but of course the same exact thing applies to any other object. So we can come down here to rotate our cube. And if we rotate it at 0, our cube is straight on. The camera isn't rotated left or right. It's only rotated up and down now. So straight on, that's why we can't see the sides at all. And if we were to take this value of 45 times pi divided by 180, we just rotated the cube 45 degrees. If we wanted to rotate it 46 degrees, we can rotate it 46 degrees or 54 degrees. And of course, we're enabling this at time of render. So like when we load the page, it runs the script. Later on, we'll create functions that will actually probably next week, we'll create a function that animates that that basically a little more advanced, but it's going to have to take some time calculations to get the animation right. And it will basically look at the time, see the time that has passed, take the time that has passed, and then turn it so many degrees based on how much time has passed since the last loop. And that way if the machine runs slow, it should theoretically jump to the position it should be. So it might make things jerky, but the cube will still get to where it's supposed to be at the time it's supposed to be rather than running slow. It will run jerky, depending on what you're doing with the game. It's better. It runs jerky than slow in just thinking from like game concept. That's why with games networking, you don't use TCP, you use UDP because it just will catch up to where it's supposed to be. Yes, that's a whole other topic. Anyway, that is how you find and rotate things certain degrees. Obviously, you can even put decimal points in here. I'm sure that would be very small degrees. But again, pi is 3.14, blah, blah, blah, blah. And when you divide it by 180, that will give you one degree and you multiply that by whatever big number of degrees you want. And that will give you, you know, you can keep going around in a circle. You can do more than 360. I suppose it would just rotate it beyond that. And of course, you can go negative numbers as well. So actually let's do that. Let's set this back to 45. So that's 45 degrees. But it rotated, you know, that way. If we wanted to rotate it the other way, I'm assuming I haven't. There we go. So now it's rotated the other way. So instead of rotating one way, it rotated the other way. And that's it for this tutorial. I hope you're enjoying these tutorials. Again, we're working on very basic stuff in 3D. And we'll get into more complex stuff in the future. But really with 3JS, it really makes everything really simple. And again, way down the line, we'll be creating stuff, scenes and objects in Blender, and then importing them into our web applications. So therefore you can create, you know, your models and animations in Blender and then share it with the world through their web browser without them having to download anything other than having a modern browser. And again, we'll be able to run on mobile devices if mobile devices fast enough to run that script. And it has hardware support. All depends. But that's a hardware issue, not a software issue, regardless of what OS you have. If you have a modern browser, you should be able to get your code working there. Anyway, again, part of a series should be an annotation to the full playlist. I hope you're enjoying this playlist. Again, working with very basic stuff, but getting into more complex stuff further down the line. And I thank you for watching. I hope that you visit my website filmsbychris.com. That's Chris the K. There should be a link in the description. I also am going to try to remember to upload all these different codes to my website so you can go and view them there and look at the source code there. So thanks again for watching. And I hope that you have a great day.