examples/3d/js/camera.js
function() {
    var hand = game.player.hand;
    var steps = game.player.steps;
    var scaleFactor = this.scale * 6;

    // Calculate the position of each hand relative to the steps taken.
    var xScale = Math.cos(steps * 2);
    var yScale = Math.sin(steps * 4);
    var bobX = xScale * scaleFactor;
    var bobY = yScale * scaleFactor;
    var x = (canvas.width - (hand.width * this.scale) + scaleFactor) + bobX;
    var y = (canvas.height - (hand.height * this.scale) + scaleFactor) + bobY;
    var w = hand.width * this.scale;
    var h = hand.height * this.scale;

    ctx.drawImage(hand.image, x, y, w, h);
  }
function() {
    var hand = game.player.hand;
    var steps = game.player.steps;
    var scaleFactor = this.scale * 6;

    // Calculate the position of each hand relative to the steps taken.
    var xScale = Math.cos(steps * 2);
    var yScale = Math.sin(steps * 4);
    var bobX = xScale * scaleFactor;
    var bobY = yScale * scaleFactor;
    var x = (canvas.width - (hand.width * this.scale) + scaleFactor) + bobX;
    var y = (canvas.height - (hand.height * this.scale) + scaleFactor) + bobY;
    var w = hand.width * this.scale;
    var h = hand.height * this.scale;

    ctx.drawImage(hand.image, x, y, w, h);
  }
function ( ) { var hand = game . player . hand ; var steps = game . player . steps ; var scaleFactor = this . scale * 6 ; // Calculate the position of each hand relative to the steps taken. var xScale = Math . cos ( steps * 2 ) ; var yScale = Math . sin ( steps * 4 ) ; var bobX = xScale * scaleFactor ; var bobY = yScale * scaleFactor ; var x = ( canvas . width - ( hand . width * this . scale ) + scaleFactor ) + bobX ; var y = ( canvas . height - ( hand . height * this . scale ) + scaleFactor ) + bobY ; var w = hand . width * this . scale ; var h = hand . height * this . scale ; ctx . drawImage ( hand . image , x , y , w , h ) ; }
Draw the hand holding the gun and implement a "bobbing" to simulate walking.
Draw the hand holding the gun and implement a bobbing to simulate walking .