Three JS Camera.lookAt Animation

by fungus1487

HTML

<div id="canvas"></div>
<script src="https://raw.github.com/mrdoob/three.js/master/build/three.js"></script>
<script src="https://raw.github.com/mrdoob/stats.js/master/build/stats.min.js"></script>
<script src="https://raw.github.com/sole/tween.js/master/build/tween.min.js"></script>

CSS

* {
    margin:0;
    padding:0;
}
#canvas {
    width:300px;
    height:280px;
    margin:40px auto;
    border:1px solid #000;
}

JavaScript

// Set the scene
var domEl = document.getElementById('canvas');
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, domEl.offsetWidth / domEl.offsetHeight, 0.1, 100);
var renderer = new THREE.WebGLRenderer();
renderer.setSize(domEl.offsetWidth, domEl.offsetHeight);
domEl.appendChild(renderer.domElement);

// Create the board
var board = new THREE.Mesh(new THREE.PlaneGeometry(9.5, 9.5), new THREE.MeshBasicMaterial({
    color: 0xff0000
}));
board.position.set(0, 0, -0.01);
scene.add(board);

// Create objects
var objs = [];

function createObject(row, col) {
    var geom = new THREE.PlaneGeometry(1, 1.25);
    var obj = new THREE.Mesh(geom, new THREE.MeshBasicMaterial({
        color: 0x00ff00
    }));

    // Calculate x position
    var width = geom.width; // Object width
    var spaceWidth = .5; // Space between objects
    var totalWidth = (width * 6) + (spaceWidth * 7); // Total width of objects plus spaces
    obj.position.x = -(totalWidth / 2) + // Offset from center 0
    (col * width) + // Add obj widths
    ((col + 1) * spaceWidth) + // Add object spaces
    (width / 2); // Offset half object width

    // Calculate y position
    var height = geom.height; // Object height
    var spaceHeight = .5;
    var totalHeight = (height * 3) + (spaceHeight * 4); // Total height of objects plus spaces
    obj.position.y = -(totalHeight / 2) + // Offset from center 0
    (row * height) + // Add object height
    ((row + 1) * spaceHeight) + // Add object spaces
    (height / 2); // Offset half object height
    return obj;
}

// Create objects
objs.push(createObject(0, 0));
objs.push(createObject(0, 1));
objs.push(createObject(0, 2));
objs.push(createObject(0, 3));
objs.push(createObject(0, 4));
objs.push(createObject(0, 5));
objs.push(createObject(1, 0));
objs.push(createObject(1, 1));
objs.push(createObject(1, 2));
objs.push(createObject(1, 3));
objs.push(createObject(1, 4));
objs.push(createObject(1, 5));
objs.push(createObject(2,...