3D Game Programming
// You don't need to type this in: varhead_shape =newTHREE.SphereGeometry(100); The var keyword declares new things in JavaScrip ...
At first we’re not done with the game. Then, some time later, we are. If we wrote code where it says, // do some work here, that ...
10 - 9.5; // 0.5 23 - 46; // -23 84 + -42; // 42 So it even works with negative numbers. Remember this; negative numbers will be ...
What happens without the parentheses? Can you guess why?^1 Geometry We’re working on 3D game concepts in this book, which means ...
In JavaScript, pi is called Math.PI. So 360° would be 2*Math.PI. A handy conversion table follows: Degrees Radians JavaScript 0° ...
Strings Strings in JavaScript are kind of boring. You can really only join two strings into larger strings. What is interesting ...
// false the_opposite_of_the_opposite; // true We won’t use Booleans directly like this very often. We’ll usually see compar- is ...
Code in ICE, Check in the Console The code in the rest of this chapter is too large for the JavaScript console, so add it in ICE ...
Running Code Only If Something Is True Sometimes we want to skip over code entirely. For these times, we use the if keyword. Jus ...
7.5 Listing Things At times it’s quite handy to be able to describe a list of things. In JavaScript, lists are made with square ...
GREAT: Star Wars GREAT: The Empire Strikes Back GREAT: Indiana Jones and the Raiders of the Lost Ark We’ll see lists again in so ...
CHAPTER 8 Project: Turning Our Avatar We’re nearly finished animating our avatar. In Chapter 4, Project: Moving Avatars, on page ...
Next write the function turn(). JavaScript doesn’t care where you put this function, but since we call it after walk() in the an ...
That is an incredible amount of JavaScript 3D programming. You have done very well to make it this far, but we can do more. Firs ...
Spinning the avatar around this pole is what it means to rotate the avatar around the y-axis. Don’t Forget About avatar.rotation ...
The Tween library animates changes between a start and end. Here we want to animate starting with one rotation and moving to an ...
then tell the Tween that we want to rotate to the new Y rotation passed to the spinAvatar() function. Every time the animation r ...
CHAPTER 9 What’s All That Other Code? When we create a new project from the 3Dstarter template, there is a lot of code already i ...
<body> <h1>Hello!</h1> <p> You can make<b>bold</b>words, <i>italic</i>words, eve ...
JavaScript doesn’t have to come from other locations. For most of this book, we’re coding inside an HTML web page. 9.3 Setting t ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf