JavaScript
var camera, scene, renderer, controls;
var one, two, three;
init();
animate();
var mat1, mat2, axis;
function debugaxis(axisLength){
//Shorten the vertex function
function v(x,y,z){
return new THREE.Vector3(x,y,z);
}
//Create axis (point1, point2, colour)
function createAxis(p1, p2, color){
var line, lineGeometry = new THREE.Geometry(),
lineMat = new THREE.LineBasicMaterial({color: color, lineWidth: 1});
lineGeometry.vertices.push(p1, p2);
line = new THREE.Line(lineGeometry, lineMat);
scene.add(line);
}
createAxis(v(-axisLength, 0, 0), v(axisLength, 0, 0), 0xFF0000);
createAxis(v(0, -axisLength, 0), v(0, axisLength, 0), 0x00FF00);
createAxis(v(0, 0, -axisLength), v(0, 0, axisLength), 0x0000FF);
};
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 5000 );
camera.position.z = 1000;
scene.add( camera );
var geometry = new THREE.CubeGeometry( 50, 50, 50 );
var material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true });
one = new THREE.Mesh( geometry, material);
one.position.set(50,0,0);
one.matrixAutoUpdate = false;
one.updateMatrix();
scene.add(one);
material = new THREE.MeshBasicMaterial( { color: 0x0000ff, wireframe: true });
two = new THREE.Mesh( geometry, material);
two.position.set(0, 200, 0);
two.matrixAutoUpdate = false;
two.updateMatrix();
scene.add(two);
mat1 = new THREE.Matrix4();
axis = new THREE.Vector3();
axis.sub(two.position, one.position);
axis.crossSelf(new THREE.Vector3(1,0,0));
axis.normalize();
mat1.makeRotationAxis(axis, 0.005);
material = new THREE.MeshBasicMaterial( { color: 0xff00ff, wireframe: true });
three = new THREE.Mesh( geometry, material);
three.position.set(0, 100, 0);
three.matrixAutoUpdate =...