# HG changeset patch # User Eugen Sawin # Date 1301701339 -7200 # Node ID 287fcb0e8f602b174b9764708740cbde487e8e57 # Parent 12bb629d22b37ab6eccbfded6edc9e108397fc3b Don't remember, must sleep. diff -r 12bb629d22b3 -r 287fcb0e8f60 scripts/machine.js --- a/scripts/machine.js Sat Apr 02 00:31:54 2011 +0200 +++ b/scripts/machine.js Sat Apr 02 01:42:19 2011 +0200 @@ -1,5 +1,5 @@ var machine; -var render; +var renderer; function main() { @@ -13,7 +13,7 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.enable(gl.DEPTH_TEST); machine = new Machine(object); - render = new Render(context); + renderer = new Renderer(context); update(); } @@ -21,7 +21,8 @@ { requestAnimFrame(update); //machine.scene.rotation *= 1.003; - render.draw(machine.scene); + machine.update(new Date().getTime()); + renderer.update(machine.scene); } function resize() @@ -40,13 +41,13 @@ context.viewport.height = height; } -function Render(context) +function Renderer(context) { this.context = context; this.gl = context.gl; this.matrixStack = []; } -Render.prototype.draw = function(scene) +Renderer.prototype.update = function(scene) { var gl = this.context.gl; var viewport = this.context.viewport; @@ -79,13 +80,13 @@ if (this.next) this.next.draw(scene); } -Render.prototype.pushMatrix = function(matrix) +Renderer.prototype.pushMatrix = function(matrix) { var copy = mat4.create(); mat4.set(matrix, copy); this.matrixStack.push(copy); } -Render.prototype.popMatrix = function() +Renderer.prototype.popMatrix = function() { if (this.matrixStack.length > 0) return this.matrixStack.pop(); } @@ -93,10 +94,16 @@ function Machine(scene) { this.scene = scene; + this.lastUpdate = 0; } -Machine.prototype.draw = function(render) +Machine.prototype.update = function(time) { - render.draw(this.scene); + if (this.lastUpdate != 0) + { + var diff = time - lastUpdate; + + } + this.lastUpdate = time; } function Context(canvas)