Question about code in chapter 8: Everything Goes Gray


#1

Hey Chris,
I was working on the turn function in chapter 8 and I added the function.
Then, I put ‘turn();’ in the requestAnimationFrame(animate) line and it went gray.

Code:
function animate() {
requestAnimationFrame(animate);
walk();
turn();
acrobatics();
renderer.render(scene, camera);
}
animate();

Turn Function:

function turn() {
if (isMovingRight) direction = Math.PI/2;
if (isMovingLeft) direction = -Math.PI/2;
if (isMovingForward) direction = Math.PI;
if (isMovingBack) direction = 0;
if (!isWalking()) direction = 0;

avatar.rotation.y = direction;
}

Thanks,
Jakin


#2

That code looks correct to me. So there must be an issue somewhere else in the code. Is it possible to share the entire project as described in the welcome post?

Also, if you haven’t already, be sure to check in the JavaScript console. The cause of the problem may already be showing up there.

-Chris