diff -r 130cff40c734 -r 9df7034275e8 scripts/cube.js --- a/scripts/cube.js Wed Apr 27 00:45:37 2011 +0200 +++ b/scripts/cube.js Wed Apr 27 02:04:45 2011 +0200 @@ -1,9 +1,30 @@ +function Node(position, rotation, geometry) +{ + this.pos = position; + this.rot = rotation; + this.geometry = geometry; + this.children = []; +} +Node.prototype.update = function(time) +{ + // this.right = [1, 0, 0]; + // this.up = [0, 1, 0]; + // this.target = [0, 0, -1]; + // var x = vec3.dot([1, 0, 0], this.pos); + // var y = vec3.dot([0, 1, 0], this.pos); + // var z = vec3.dot([0, 0, -1], this.pos); + // this.matrix = mat4.create([this.right[0], this.up[0], -this.target[0], 0, + // this.right[1], this.up[1], -this.target[1], 0, + // this.right[2], this.up[2], -this.target[2], 0, + // -x, -y, z, 1]); + for (var id in this.children) this.children[id].update(time); +} + + function Cube(size, context) { var gl = context.gl; - this.size = size || 1; - this.rotation = {'x': 0.0, 'y': 0.0, 'z': 0.0}; - + this.size = size || 1; this.positionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer); var vertices = [