1.1 --- a/scripts/cube.js Wed Apr 27 00:45:37 2011 +0200
1.2 +++ b/scripts/cube.js Wed Apr 27 02:04:45 2011 +0200
1.3 @@ -1,9 +1,30 @@
1.4 +function Node(position, rotation, geometry)
1.5 +{
1.6 + this.pos = position;
1.7 + this.rot = rotation;
1.8 + this.geometry = geometry;
1.9 + this.children = [];
1.10 +}
1.11 +Node.prototype.update = function(time)
1.12 +{
1.13 + // this.right = [1, 0, 0];
1.14 + // this.up = [0, 1, 0];
1.15 + // this.target = [0, 0, -1];
1.16 + // var x = vec3.dot([1, 0, 0], this.pos);
1.17 + // var y = vec3.dot([0, 1, 0], this.pos);
1.18 + // var z = vec3.dot([0, 0, -1], this.pos);
1.19 + // this.matrix = mat4.create([this.right[0], this.up[0], -this.target[0], 0,
1.20 + // this.right[1], this.up[1], -this.target[1], 0,
1.21 + // this.right[2], this.up[2], -this.target[2], 0,
1.22 + // -x, -y, z, 1]);
1.23 + for (var id in this.children) this.children[id].update(time);
1.24 +}
1.25 +
1.26 +
1.27 function Cube(size, context)
1.28 {
1.29 var gl = context.gl;
1.30 - this.size = size || 1;
1.31 - this.rotation = {'x': 0.0, 'y': 0.0, 'z': 0.0};
1.32 -
1.33 + this.size = size || 1;
1.34 this.positionBuffer = gl.createBuffer();
1.35 gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer);
1.36 var vertices = [