By Developers, For Developers

Historical errata for 3D Game Programming for Kids

PDF PgPaper PgTypeDescriptionFixed onComments
16ERROR

You may want to double check where it says to use ‘Ctrl+Shift+J’ to open the javascript console. On my mac, I dont think I changed any keys, I use ‘Option + Command + j’ to toggle open and close on Chrome.

2013-02-14Thanks for the correction -- it will be fixed in the next update.
13ERROR

instead of clock = new THREE.Clock(); shouldn’t it be:
var clock = new THREE.Clock(); (at least for consistency?)

2013-02-14Good eye. I'm trying to avoid var, let, and globals discussion, but I do want to be consistent. Fix will be included in the first update. \n \nThanks!
16TYPO

Command+Shift+J does not start the JavaScript Console on a Mac.
This does: Option+Command+J
The correct shortcut is given in the Chrome top menu bar, View-Developer-JavaScript Console. You could also just click the menu item.

2013-02-14Thanks for the correction -- it will be fixed in the next update.
106TYPO

Reference to makeTree changed.“Next, find where makeTree() is defined.” should be “makeTreeAt()”.

2013-02-17Good eye, thanks. The fix will be included in the next update.
107SUGGEST

The first collisions/collisions.html extract shows the case statements for keyDown and keyUp for the arrow left key. This is a little confusing because these two case statements appear in two different functions. Maybe just the first case statement was meant to be shown.

2013-02-17Yup, the other was from the keyup handler later. It'll be fixed in the next update. Thanks!
89ERROR

Firstly, I assume that our avatar is ‘looking at us’.
Given that the right hand is placed to the left of the avatar as we look at it (right_hand.position.set(–150,0,0);)
When ‘up’ is pressed we are moving forward (marker.position.z decreases)
Then physically our avatar should have rotated 180 degrees

Thus I believe the turn function should reflect this.
\tif (is_moving_forward) direction = Math.PI;
\tif (is_moving_back) direction = 0;

I accept that for your example it does not matter, but the problem comes to light when some facial features are added to the avatar. The avatar will point in the correct direction when moving left or right but appear to walk backwards when moving up or down.

2013-04-22Ooh, good catch. I believe that you are correct. I'll review and revise -- hopefully before the next update.
121ERROR

When following the code examples of adding a shadow I find that the shadow is displayed behind the doughnut (perpendicular to the ground). To replicate the image shown on page 121 I had to rotate the ground on the x axis:
ground.rotation.x = -Math.PI/2;

2013-03-14Good catch. \n \nThat must have worked in the past without the rotation because the images themselves did not have the ground rotation. No matter, the rotation is definitely required with the current libraries, so I've updated the code. \n \nThanks!
125ERROR

In the first reference to solar_system/above.html, the animate function, missing first line of function to request animation frame - requestAnimationFrame(animate);

2013-04-25Yikes! I messed up some code references in the manuscript. Should be fixed for the next beta. Much thanks for the find!
135TYPO

Elapsed time in Chapter 13 is referenced as a variable called t. From page 135 in Chapter 14 the variable changes to the better expressed name - time.

2013-03-11Agreed. I've switched to a more expressive name in chapter 13.
129SUGGEST

Sorry I am being pedantic!
In the keydown listener function there the keydown code is logged to the console only if its not ‘E’ (only one else statement) rather than if ‘A’ else if ‘E’ else log(code). Maybe not worth logging at all.

2013-08-09
39ERROR

I put the page number that is printed on the page in the PDF… It’s “page” 39, or per Preview, page 51 of 186. In either event, it’s right after adding the code to create the function, makeTreeAt(). Your text, describing what should happen after you enter this code, does not reflect what the code actually does… Your text states “If you entered all that code correctly, you will see the player object move off the screen and that there is a huge forest of four trees”. The code /does/ create the four trees. But, there is nothing to automatically move the player off of the page ex human involvement right? Or are you assuming that we are starting from some base implementation with automated (i.e. - non-keyboard driven) movement? Could just be my problem! :-)

2013-03-07Yikes! I think that text was referring to an earlier narrative. Thanks for the catch!
39SUGGEST

This is a generic suggestion across most of the examples that I have been working through. Understanding that this is a book “for Kids”, you want to balance the amount of math that is required to do this…. :-)

Most of your code snippets use hard coded, absolute placement of objects rather than calculating dynamically the positions. For example, when you write your code to create a tree, you make a cylinder of size 50, a top of 150, and then place the top on at a y-offset of 175.

My suggestion would be to change the examples to use variables and then calculate the offsets required:

top.position.y = cylinderSize + topSize/2; // or some such

I’ve been converting my examples to their formulaic equivalents just so I can play with sizing of my designs as I go, as well as forcing myself to think through how to do this in a more genericized way….

Just a suggestion!

2013-08-09That's a good suggestion and one that I have been wondering about. I do not have a good feel for how easy it is for the very new programmer to process the concept of variables like that, so I have been sticking with concrete numbers. To be sure, if I were coding this myself, I would definitely use your approach. \n \nI'm going to keep this open and revisit in a week or so... \n--- \n \nI'm still on the fence about this, but I left it as is. Mostly, the kids in our focus groups were able to follow along without the need to explain the indirection. We may want to revisit this for the 2nd edition though.
17SUGGEST

When I opened the console the first time there were tons of error messages, even when the code was correct. It takes a while to realize one is looking at a log history. It might make sense to mention this and/or to click the button to clear the log before typing in the “bad” code in the exercise.

2013-03-07Thanks! I hadn't thought about that. Added a note.
24OK

Below the diagram explaining the x/y coordinate system the first line of code should read:
var right_hand = new ….
rather than
var right_hand_shape = new ….

2013-03-14I _think_ that the code is correct as-is. The right_hand_shape is the geometry that is used in the right_hand on the next line. \n \nI may have a go at re-working the code a bit to make this less confusing.
147ERROR

The launchFruit() function at the bottom of page 147. I find the order of setting the LinearVelocity and rotation of the fruit, then adding it to the scene important.
The shown order - velocity, rotation and scene leads to unmoving squashed fruit. Rotation, then scene, then velocity works.
fruit.rotation.x = Math.PI/2;
scene.add(fruit);
fruit.setLinearVelocity(new THREE.Vector3(–100,0,0));

2013-04-29Ah, good catch. I think I had that elsewhere, but forgot to correct here. Should be fixed in the next beta.
178TYPO

Constructing New Objects section, discussing creating objects,
“…function if itcreates new objects.” should read “…function when they create new objects”

2013-03-07Not sure how that even got past the old spell checker. Thanks!
35SUGGEST

In the key event listener you might mention what event.preventDefault() is good for.

2013-03-17Heh. Ya know, it's probably not worth the explanation. I really don't want to get into return false, preventDefault, stopImmediatePropagation, etc. Since it is not *really* necessary, I removed it from the code. \n \nThanks for saving the kids :)
55SUGGEST

In the example under “Understanding Simple Functions” you use double quotes e.g. logMessage(hello(“Mom”), log);
Any reason? Seems to work with single quotes you used previously equally well.

2013-04-22Single and double quotes mean the same thing in JavaScript. In other languages that I use, they do different things, so I sometimes switch between the two in my JavaScript code, depending on what other language I am using earlier in the day. \n \nI will try to use single quotes throughout to cut down on the confusion. Thanks for the find! \n \nFixed for the next beta.
57ERROR

When removing the curly brace at the end of the hello function I am getting a different error message: the error marker is at the opening curly brace of the hello function and the message is “unmatched }”.

2013-04-22Thanks! I grabbed that screen capture from an earlier version of ICE. The code editor has improved the error messages some. I've updated it and the correct images should be in the next beta.
82SUGGEST

The listing following the statement “JavaScript can open browser alert dialogs” doesn’t open an alert box. Either I misunderstood what the author meant or the listing doesn’t seem appropriate.

2013-05-02Uh... I have no idea how that code listing got in there :) \n \nMuch thanks for the report. Should be fixed in the next Beta!
86ERROR

It seems the code shown for the turn function is incomplete. Apart from setting the variable direction it is not apparent where the variable is used. In the following text (in 8.2) there is mention of setting rotation.y which is not shown in the code.

2013-05-02Yup, that code snippet got chopped off early. Should be fixed in the next beta. Much thanks for the report!
2SUGGEST

Coding with the ICE Code Editor tip. Although the ICE editor is available offline, I find the references to the third party scripts are not available (e.g. Three.js) - giving the error message Failed to load resource.

2013-06-16I have this fixed in the beta version: http://gamingjs.com/ice-beta/. \n \nI worried this wasn't even possible, but got lucky when I converted the editor to Dart. The not-too-gory details: http://japhr.blogspot.com/2013/06/appcache-serendipity-with-dart-assist.html
11TYPO

PlaneGeometry. The plane image shown on page 11 does not match the code example. The rotation needs to be something similar to ground.rotation.set(5,0,0); Additionally, the ground.rotation.set statement is missing from the final code block on the same page.

2013-06-19
25TYPO

Continuity. Page 25 describes the right_hand variable. On page 26 the variable changes its name to r_hand (You may call this shorthand? :) )

2013-06-19
26TYPO

When explaining the x-axis for the hands it makes reference to changing the position by reversing the sign. However in the following pages (#28-31) the sign switches between positive and negative.

2013-06-19
67SUGGEST

A call to event.preventDefault() sneaks into the keydown addEventListener method for the first time without explanation (the statement is not included in the code block of the same method call on page 50).

2013-06-16Thanks. I believe that I finally tracked down and eliminated the last of the event.preventDafaults today. No need to inflict that ugliness on unsuspecting kids.
80SUGGEST

Suggestion whilst explaining conditionals - Maybe a tip about equals (assignment) and double equals (equality test).

2013-06-16I have since added a brief explanation about this earlier in Chapter 4. Still, this seems like a good idea and I have also included a Tip in Chapter 7. Thanks!
123ERROR

The bottom right hand tree never bears fruit. (Due to it being the first tree in the trees array). I find that the first line of the checkForTreasure function
if (!tree_with_treasure) return;
will prevent position 0 in the array from being checked. Maybe
if (tree_with_treasure==undefined) return;
would be better.

2013-06-19Wow. Good catch on that one. I saw it shake and assumed it was OK. Thanks!
87TYPO

The turn function, forward/backward direction statements do not match table on page 85. ditto in the code in the turn function on pages 90/108/121.

2013-06-19
112TYPO

When the timeout expires on the console, an uncaught type error occurs: Cannot call method ‘stop’ of undefined. The Game Over! message is not shown.

2013-08-06This is fixed in the beta version of ICE: http://gamingjs.com/ice-beta/. I will promote this to production in the next week or so.
112ERROR

Pressing ? for the scoreboard does not bring up the help message. I assume that ‘?’ refers to ASCII value 63. In fact, when I add an
alert(event.keyCode);
statement to my keyDown function I cannot get an alert for just ‘?’. This is due me requiring two key presses to achieve a ‘?’ - the shift key (16) and then a separate key press for ‘/’ (191).

2013-06-16Actually, I think this was caused by the event.preventDefaults scattered throughout the code. Once those are removed it should work. I may add a handler for the '/' (191) as well. I've seen my son try to press that for the question mark. \n \nAnyway, I think this is fixed for new readers.
114TYPO

Extra parentheses when explaining the Math.sin() function “…the value of Math.sin()() sets a timeout…”. A similar problem on Page 194 when explaining Math.random() function “…number comes from Math.Random()()…” and on page 237 resetItems() “…the definition of resetItems()() should come after…”

2013-06-19
117SUGGEST

Suggestion - Specify that the newly created animateFruit function should be called from the end of the scorePoints function i.e.

function scorePoints() {
scoreboard.addPoints(10);
Sounds.bubble.play();
animateFruit();
}

2013-06-19
95TYPO

Adding html in the

section. An error marker appears in the left hand column of the

tag and the line of following tag. e.g. a red error box appears on lines 1 and 2. The error tool
tip reads
Expected an identifier and instead saw ‘<’.
Missing “;” before statement

These errors do not appear to prohibit any code running.

2013-06-19
106ERROR

In The Code So Far section, The anitAlias property in the canvas renderer is new! i.e.
var renderer = new THREE.CanvasRenderer({antialias:true});

2013-06-16Removed from everywhere. I don't think it has an effect on CanvasRenders (so I'm not sure how it snuck in there). It makes WebGL a little nicer, but not enough to warrant an explanation for kids. So it's gone. Thanks!
118SUGGEST

Maybe this suggestion is more an exercise for the reader but my avatar felt a little sluggish. I refactored the keyDown method, changing the literal ‘5’ references into a variable named speed. I settled on the value 25.

2013-06-19
135SUGGEST

When explaining the PerspectiveCamera (distance and position), The field of view variable has also changed from 75 to 45.

2013-06-19
137ERROR

The animate function shown on page 137 requires requestAnimationFrame(animate); statement.

2013-06-19
158TYPO

“Congratulations! You have written your very first game in JavaScript.” Is this statement still true now Chapter 11 has been added? Maybe “..very first physics based game…” or even …platform game…

2013-06-19
159SUGGEST

Adding Simple Graphics section, Point (3) - “No other changes are needed.” when explaining the addPlayer() and launchFruit(). Superfluous?

2013-06-19
160SUGGEST

Challenge: Game Reset
Although technically it doesn’t matter (because the keyboard is not case sensitive) I offer this suggestion to try and avoid some confusion. When adding a keyboard handler for reset, I believe it would be more correct to say “…when the R key…” rather than “…when the r key…” as R=ASCII value 82 and r=ASCII value 114.

2013-08-09Yup. Fixed.
160TYPO

Challenge Game Reset. Comparing my attempted solution with yours in The Code So Far, I would not have got the player.__dirtyPosition statement at this stage in the book (The excellent explanation doesn’t come till the next chapter). (And to be pernickety :) - the second condition check on game_over boolean is unnecessary).

2013-06-19Agreed. I added a note about maybe trying that after more physics chapters.
181SUGGEST

Maybe its just personal preference but I prefer the score mesh to be invisible (I find that the blue wire frame square looks odd when the table has been tilted). Thus I would recommend changing the score variable within the addGoal() function to

var score = new Physijs.ConvexMesh(
new THREE.PlaneGeometry(20, 20),
new THREE.MeshNormalMaterial({visible:false})
);

2013-06-19
221TYPO

First paragraph on page 221 “…So if we are slooking for the river function…” Hmmm… :)

2013-06-20
230TYPO

Resetting the Game section. The code snippet shown below the statement “Below addRaft() lets add the following” goes on to show other functions rather than the startGame() function.

2013-06-20
220SUGGEST

Getting started. After starting a 3D Starter Project (with Physics) and following the setting the camera instruction, the renderer needs to be changed from the default Canvas to WebGL.

2013-06-20
240SUGGEST

In the final The Code So Far section, the pause=false statement is missing out of startGame() function. This prevents the raft from moving onRestart(). Also, (not as important but for consistency) the scoreboard.message(’’); appears in the startGame() function on Page 234, as scoreboard.clearMessage() on Page 237 but does not in the Code So Far section.

2013-06-20
240SUGGEST

The Code So Far section has set the gravity to a more realistic –5, rather than the default –100. This slight change is not mentioned previously in the chapter.

2013-06-20
236TYPO

When making reference to adding three lines for a time bonus “We do this by adding the last three lines shown below…”, the code that follows is a repeat of the checkForGameOver() function . The context of the subsequent paragraph challenges the reader to attempt the time bonus problem (i.e. “Can you do it?”)

2013-06-20
142SUGGEST

At the end of chapter 13, What’s next, it states that “..we are not going to continue working on this project. Instead…” and Chapter 14 is phases of the moon and starts by making a copy :)

2013-06-19
149TYPO

In the Phases of the Moon, The Code So Far section the intensity of the sun’s point light has been increased from 5 to 10.

2013-06-19
111TYPO

Looks like a formatting instruction crept into the text here:
“To keep score in this game, we are going to need something new&emdash;a
scoreboard.”

2013-07-10Thanks! I think we've got that (and others) fixed now in B5.
51SUGGEST

The chapter speaks about keydown events and event listeners.
But we are doing this in the ice environment.

I’m not sure how to get the program to work since it seems the ice environment is capturing the keyboard events and not sharing.

Could you add a tip for this?

(Having fun writing programs with my 10yr old son)
Thanks,

2013-08-09You need to click the “Hide Code” button to get this to work. Updated to make that a little more obvious in the text.
157ERROR

The code of Tilt-a-Board does not work. I tried it locally and it is not working.
“Uncaught Error: SecurityError: DOM Exception 18 ” in chrome

SecurityError: The operation is insecure.
[Parar en este error] \t

this._worker = new Worker( Physijs.scripts.worker || ‘physijs_worker.js’ ); in firefox

2013-08-25The physics stuff will not work when run locally. It uses web workers whose operation is governed by the same-origin policy. If you run it with file:// URLs, you get those security violations because you'd be violating that policy. \n \nI do not believe that the tilt-a-game works on Firefox. I'm not sure if it's a WebGL problem or a Physics problem, but it often crashes Firefox on me. That's one of the reasons that the book only supports Chrome :) \n \nThe code definitely runs in Chrome in ICE on the gamingjs.com site (just copied and pasted the full version). It should work when hosted on another site as well. See the last chapter for info on how to do that.
8471ERROR

Footnote 1 reads:
“Without parentheses, multiplication is done first, then division. Remember the “order of operations” from your math class!"

It should be:
“…multiplication is done first, then addition…”

71SUGGEST

Surely the correction of the footnote as published, is in fact incorrect? From my recollection of basic mathematics the order of operations is “Brackets, Of, Multiplication, Division, Addition, and Subtraction”. If the rules haven not changed, then your original footnote is correct and did not need correcting.

120ERROR

WebGL may not work properly with Chrome 36. Seeing errors like:

Error creating WebGL context.
Uncaught TypeError: Cannot read property ‘getExtension’ of null

May need to manually modify this version of Three.js to remove the experimental part of experimental-webgl (or check for both).

2014-06-18This appears to be a temporary Chrome-on-Linux thing: http://japhr.blogspot.com/2014/05/webgl-in-chrome-36-linux-is-not-working.html \n \nNo need to address at this time.
64SUGGEST

There is no indication in the text that curly braces need to be added around the conditional blocks when adding the is_moving_* booleans.

32TYPO

“Just like we did at the end of Chapter 1 . . . we start by changing the very last line of the code” but in chapter 1 the code was just placed before the last line.

50TYPO

“Back in Chapter 3 . . ., on page 25, we used a function to avoid having to repeat the same process for creating a tree”. Should be Chapter 4.

91TYPO

Reported from the forums (forums.pragprog.com/forums/284/topics/12871): Just replacing the 2 lines of the code for the OrthographicCamera is not sufficient. The renderer also needs to be modified to be WebGLRenderer. It wasn’t clear that the renderer needed to be replaced and explicitly stated as it was in chapter 18, Getting Started section.

The previous section in the chapter does tell the reader to enable the WebGL renderer so, if the reader is following along closely, this should just work. Still, this seems reasonable -- especially if readers are just skipping around and trying new things...
1805SUGGEST

The “PDF” page number above is actually a kindle sentence number. The section is “Listing Things” in chapter 7.

You may wish to mention the push method here since it is used later on in the book (Chapter 10 Collisions) without any explanation in chapter 10.

Also, for chapter 10, there is a lot of items introduced without much explanation. I am able to understand the material without much trouble, but I think a young or inexperienced programmer might easily get lost. One example is when the detectCollisions function creates a vector3 object without any explanation of what a vector is or why it is being created.

2325ERROR

PDF Page is kindle reference. In Chapter 11, Fruit Hunt, Jumping for Points section, there is a sentence which reads, “Now we add the jump function that the case statement calls.”

There is no case statement in the code.

100TYPO

"So let’s add a second

156ERROR

Bottom third of the page:
“So gameStep() is processed every 16.67 milliseconds, which may seem very
frequent. In computers, though, that is not very frequent. The animation will
get updated at least sixteen times, and probably a lot more, during those
1000 milliseconds.”

Isn’t it rather: “… will get updated at least sixty times …”?

150 SUGGEST

uncomment the addBall() call page 150
uncomment the call to addBall() page 151

SiteERROR

I lost my whole project

63ERROR

When I try doing the Math.sin(clock.getElaspedTime()5) 50; it doesn’t move until I release the key and also the arms don’t move and the only way I can move them is replacing it with position = -position.

3ERROR

For some odd reason I have follow all the steps of Chapter 1. Project: Creating Simple Shapes (Page 3). But it won’t load the sphere!
If someone could tell me how to fix this or if I need something that would be greatly appreciated.
(P.S: I am using Google Chrome.)

Categories: