jax 0.0.0.5 → 0.0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. data/CHANGELOG +26 -1
  2. data/Rakefile +3 -1
  3. data/builtin/shaders/picking/common.ejs +2 -0
  4. data/builtin/shaders/picking/fragment.ejs +4 -0
  5. data/builtin/shaders/picking/material.js +14 -0
  6. data/builtin/shaders/picking/vertex.ejs +24 -0
  7. data/lib/jax/generators/app/templates/public/javascripts/jax.js +289 -681
  8. data/lib/jax/generators/app/templates/spec/javascripts/support/spec_layout.html.erb +55 -2
  9. data/lib/jax/generators/shader/templates/common.ejs.tt +2 -2
  10. data/lib/jax/packager/sprockets_template.rb +1 -4
  11. data/lib/jax/routes.rb +3 -0
  12. data/lib/jax/version.rb +1 -1
  13. data/spec/example_app/app/controllers/noise_controller.js +37 -5
  14. data/spec/example_app/app/controllers/picking_controller.js +32 -0
  15. data/spec/example_app/app/helpers/picking_helper.js +3 -0
  16. data/spec/example_app/app/models/blob.js +38 -0
  17. data/spec/example_app/app/resources/blobs/default.yml +2 -0
  18. data/spec/example_app/app/resources/materials/blob.yml +2 -2
  19. data/spec/example_app/app/shaders/blob/common.ejs +8 -13
  20. data/spec/example_app/app/shaders/blob/fragment.ejs +1 -1
  21. data/spec/example_app/app/shaders/blob/material.js +15 -12
  22. data/spec/example_app/app/shaders/blob/vertex.ejs +33 -8
  23. data/spec/example_app/app/views/picking/index.js +4 -0
  24. data/spec/example_app/config/routes.rb +1 -0
  25. data/spec/example_app/spec/javascripts/controllers/picking_controller_spec.js +11 -0
  26. data/spec/example_app/spec/javascripts/helpers/picking_helper_spec.js +12 -0
  27. data/spec/example_app/spec/javascripts/models/blob_spec.js +11 -0
  28. data/spec/example_app/spec/javascripts/support/spec_layout.html.erb +40 -2
  29. data/spec/javascripts/jax/model_spec.js +10 -0
  30. data/spec/javascripts/jax/world_spec.js +74 -1
  31. data/spec/javascripts/shaders/preprocessor_spec.js +35 -0
  32. data/src/constants.yml +1 -1
  33. data/src/jax.js +30 -8
  34. data/src/jax/anim_frame.js +6 -2
  35. data/src/jax/builtin/meshes/cube.js +22 -1
  36. data/src/jax/builtin/meshes/plane.js +27 -0
  37. data/src/jax/builtin/meshes/quad.js +7 -1
  38. data/src/jax/builtin/meshes/sphere.js +20 -1
  39. data/src/jax/builtin/meshes/teapot.js +10 -0
  40. data/src/jax/builtin/meshes/torus.js +18 -0
  41. data/src/jax/compatibility.js +165 -2
  42. data/src/jax/context.js +176 -9
  43. data/src/jax/core.js +6 -3
  44. data/src/jax/core/math.js +18 -3
  45. data/src/jax/core/matrix_stack.js +4 -3
  46. data/src/jax/core/util.js +15 -0
  47. data/src/jax/events.js +67 -12
  48. data/src/jax/geometry.js +5 -1
  49. data/src/jax/geometry/plane.js +59 -5
  50. data/src/jax/{controller.js → mvc/controller.js} +38 -0
  51. data/src/jax/mvc/helper.js +35 -0
  52. data/src/jax/mvc/model.js +301 -0
  53. data/src/jax/{route_set.js → mvc/route_set.js} +0 -0
  54. data/src/jax/{view.js → mvc/view.js} +6 -0
  55. data/src/jax/{view_manager.js → mvc/view_manager.js} +1 -0
  56. data/src/jax/noise.js +13 -0
  57. data/src/jax/prototype/class.js +3 -0
  58. data/src/jax/prototype/extensions.js +26 -8
  59. data/src/jax/webgl/camera.js +6 -6
  60. data/src/jax/webgl/core/framebuffer.js +4 -4
  61. data/src/jax/webgl/material.js +16 -0
  62. data/src/jax/webgl/mesh.js +19 -4
  63. data/src/jax/webgl/scene/light_manager.js +8 -0
  64. data/src/jax/webgl/scene/light_source.js +3 -3
  65. data/src/jax/webgl/shader.js +4 -2
  66. data/src/jax/webgl/shader_chain.js +1 -0
  67. data/src/jax/webgl/world.js +157 -6
  68. data/vendor/glmatrix/glMatrix.js +365 -408
  69. metadata +32 -10
  70. data/src/jax/helper.js +0 -8
  71. data/src/jax/model.js +0 -163
@@ -1,4 +1,28 @@
1
1
  /* Defines constants, functions, etc. that may exist in one browser but not in another */
2
+ /**
3
+ * Jax.Compatibility
4
+ * Contains values used for cross-browser compatibility.
5
+ **/
6
+ Jax.Compatibility = (function() {
7
+ var offsetTop = 1;
8
+ var offsetLeft = 1;
9
+
10
+ return {
11
+ /**
12
+ * Jax.Compatibility.offsetTop -> Number
13
+ * Some browsers have different values for +offsetTop+. Jax must track these
14
+ * changes in order to ensure that the reported mouse coordinates are accurate.
15
+ **/
16
+ offsetTop: offsetTop,
17
+
18
+ /**
19
+ * Jax.Compatibility.offsetLeft -> Number
20
+ * Some browsers have different values for +offsetLeft+. Jax must track these
21
+ * changes in order to ensure that the reported mouse coordinates are accurate.
22
+ **/
23
+ offsetLeft: offsetLeft,
24
+ };
25
+ })();
2
26
 
3
27
  /*
4
28
  Object.keys defined only in the newest browsers. If they're going to fail, let them fail due to HTML5 incompatibility
@@ -13,10 +37,149 @@ if (!Object.keys) {
13
37
  };
14
38
  }
15
39
 
40
+ /**
41
+ * Array#clear() -> Array
42
+ * Removes all objects from this array and returns itself, now empty.
43
+ **/
44
+ Array.prototype.clear = Array.prototype.clear || function() {
45
+ this.splice(0, this.length);
46
+ return this;
47
+ };
48
+
16
49
 
17
50
  /* KeyEvent in Firefox contains various keyCode constants, but they are missing in Chrome. */
18
51
  if (typeof(KeyEvent) == "undefined") {
19
- // KeyEvent constants taken from Firefox 3.6
52
+ /**
53
+ * Global.KeyEvent
54
+ *
55
+ * By default, Firefox defines a global +KeyEvent+ namespace containing character codes
56
+ * for use with keyboard events. These are very useful for comparison with +event.keyCode+,
57
+ * but are not supported by other browsers.
58
+ *
59
+ * In the event that a browser other than Firefox is used, Jax defines a fake +KeyEvent+
60
+ * namespace to be used in its place. The constants contained within are taken from
61
+ * Firefox 3.6, with the addition of the boolean +fake+, which is always true unless
62
+ * the client is using Firefox.
63
+ *
64
+ * The individual values of the following constants may be different from one client to another:
65
+ *
66
+ * KeyEvent.DOM_VK_CANCEL
67
+ * KeyEvent.DOM_VK_HELP
68
+ * KeyEvent.DOM_VK_BACK_SPACE
69
+ * KeyEvent.DOM_VK_TAB
70
+ * KeyEvent.DOM_VK_CLEAR
71
+ * KeyEvent.DOM_VK_RETURN
72
+ * KeyEvent.DOM_VK_ENTER
73
+ * KeyEvent.DOM_VK_SHIFT
74
+ * KeyEvent.DOM_VK_CONTROL
75
+ * KeyEvent.DOM_VK_ALT
76
+ * KeyEvent.DOM_VK_PAUSE
77
+ * KeyEvent.DOM_VK_CAPS_LOCK
78
+ * KeyEvent.DOM_VK_ESCAPE
79
+ * KeyEvent.DOM_VK_SPACE
80
+ * KeyEvent.DOM_VK_PAGE_UP
81
+ * KeyEvent.DOM_VK_PAGE_DOWN
82
+ * KeyEvent.DOM_VK_END
83
+ * KeyEvent.DOM_VK_HOME
84
+ * KeyEvent.DOM_VK_LEFT
85
+ * KeyEvent.DOM_VK_UP
86
+ * KeyEvent.DOM_VK_RIGHT
87
+ * KeyEvent.DOM_VK_DOWN
88
+ * KeyEvent.DOM_VK_PRINTSCREEN
89
+ * KeyEvent.DOM_VK_INSERT
90
+ * KeyEvent.DOM_VK_DELETE
91
+ * KeyEvent.DOM_VK_0
92
+ * KeyEvent.DOM_VK_1
93
+ * KeyEvent.DOM_VK_2
94
+ * KeyEvent.DOM_VK_3
95
+ * KeyEvent.DOM_VK_4
96
+ * KeyEvent.DOM_VK_5
97
+ * KeyEvent.DOM_VK_6
98
+ * KeyEvent.DOM_VK_7
99
+ * KeyEvent.DOM_VK_8
100
+ * KeyEvent.DOM_VK_9
101
+ * KeyEvent.DOM_VK_SEMICOLON
102
+ * KeyEvent.DOM_VK_EQUALS
103
+ * KeyEvent.DOM_VK_A
104
+ * KeyEvent.DOM_VK_B
105
+ * KeyEvent.DOM_VK_C
106
+ * KeyEvent.DOM_VK_D
107
+ * KeyEvent.DOM_VK_E
108
+ * KeyEvent.DOM_VK_F
109
+ * KeyEvent.DOM_VK_G
110
+ * KeyEvent.DOM_VK_H
111
+ * KeyEvent.DOM_VK_I
112
+ * KeyEvent.DOM_VK_J
113
+ * KeyEvent.DOM_VK_K
114
+ * KeyEvent.DOM_VK_L
115
+ * KeyEvent.DOM_VK_M
116
+ * KeyEvent.DOM_VK_N
117
+ * KeyEvent.DOM_VK_O
118
+ * KeyEvent.DOM_VK_P
119
+ * KeyEvent.DOM_VK_Q
120
+ * KeyEvent.DOM_VK_R
121
+ * KeyEvent.DOM_VK_S
122
+ * KeyEvent.DOM_VK_T
123
+ * KeyEvent.DOM_VK_U
124
+ * KeyEvent.DOM_VK_V
125
+ * KeyEvent.DOM_VK_W
126
+ * KeyEvent.DOM_VK_X
127
+ * KeyEvent.DOM_VK_Y
128
+ * KeyEvent.DOM_VK_Z
129
+ * KeyEvent.DOM_VK_CONTEXT_MENU
130
+ * KeyEvent.DOM_VK_NUMPAD0
131
+ * KeyEvent.DOM_VK_NUMPAD1
132
+ * KeyEvent.DOM_VK_NUMPAD2
133
+ * KeyEvent.DOM_VK_NUMPAD3
134
+ * KeyEvent.DOM_VK_NUMPAD4
135
+ * KeyEvent.DOM_VK_NUMPAD5
136
+ * KeyEvent.DOM_VK_NUMPAD6
137
+ * KeyEvent.DOM_VK_NUMPAD7
138
+ * KeyEvent.DOM_VK_NUMPAD8
139
+ * KeyEvent.DOM_VK_NUMPAD9
140
+ * KeyEvent.DOM_VK_MULTIPLY
141
+ * KeyEvent.DOM_VK_ADD
142
+ * KeyEvent.DOM_VK_SEPARATOR
143
+ * KeyEvent.DOM_VK_SUBTRACT
144
+ * KeyEvent.DOM_VK_DECIMAL
145
+ * KeyEvent.DOM_VK_DIVIDE
146
+ * KeyEvent.DOM_VK_F1
147
+ * KeyEvent.DOM_VK_F2
148
+ * KeyEvent.DOM_VK_F3
149
+ * KeyEvent.DOM_VK_F4
150
+ * KeyEvent.DOM_VK_F5
151
+ * KeyEvent.DOM_VK_F6
152
+ * KeyEvent.DOM_VK_F7
153
+ * KeyEvent.DOM_VK_F8
154
+ * KeyEvent.DOM_VK_F9
155
+ * KeyEvent.DOM_VK_F10
156
+ * KeyEvent.DOM_VK_F11
157
+ * KeyEvent.DOM_VK_F12
158
+ * KeyEvent.DOM_VK_F13
159
+ * KeyEvent.DOM_VK_F14
160
+ * KeyEvent.DOM_VK_F15
161
+ * KeyEvent.DOM_VK_F16
162
+ * KeyEvent.DOM_VK_F17
163
+ * KeyEvent.DOM_VK_F18
164
+ * KeyEvent.DOM_VK_F19
165
+ * KeyEvent.DOM_VK_F20
166
+ * KeyEvent.DOM_VK_F21
167
+ * KeyEvent.DOM_VK_F22
168
+ * KeyEvent.DOM_VK_F23
169
+ * KeyEvent.DOM_VK_F24
170
+ * KeyEvent.DOM_VK_NUM_LOCK
171
+ * KeyEvent.DOM_VK_SCROLL_LOCK
172
+ * KeyEvent.DOM_VK_COMMA
173
+ * KeyEvent.DOM_VK_PERIOD
174
+ * KeyEvent.DOM_VK_SLASH
175
+ * KeyEvent.DOM_VK_BACK_QUOTE
176
+ * KeyEvent.DOM_VK_OPEN_BRACKET
177
+ * KeyEvent.DOM_VK_BACK_SLASH
178
+ * KeyEvent.DOM_VK_CLOSE_BRACKET
179
+ * KeyEvent.DOM_VK_QUOTE
180
+ * KeyEvent.DOM_VK_META
181
+ *
182
+ **/
20
183
  KeyEvent = {
21
184
  fake: true,
22
185
  DOM_VK_CANCEL : 3,
@@ -137,4 +300,4 @@ if (typeof(KeyEvent) == "undefined") {
137
300
  };
138
301
 
139
302
  /* TODO handle special cases -- see http://www.javascripter.net/faq/keycodes.htm */
140
- }
303
+ }
data/src/jax/context.js CHANGED
@@ -32,12 +32,47 @@ Jax.Context = (function() {
32
32
  if (!self.gl) throw new Error("WebGL could not be initialized!");
33
33
  }
34
34
 
35
+ function updateFramerate(self) {
36
+ var current_render_start = Jax.uptime;
37
+ if (!self.last_render_start) self.last_render_start = Jax.uptime;
38
+ var time_to_render_this_frame = current_render_start - self.last_render_start;
39
+
40
+ self.time_to_render = (self.time_to_render || 0) * self.framerate_sample_ratio
41
+ + time_to_render_this_frame * (1 - self.framerate_sample_ratio);
42
+
43
+ // frames per second = 1 second divided by time to render; time is currently in ms so 1sec = 1000ms
44
+ self.framerate = self.frames_per_second = 1.0 / self.time_to_render;
45
+ self.last_render_start = current_render_start;
46
+ }
47
+
48
+ function updateUpdateRate(self) {
49
+ var current_update_start = Jax.uptime;
50
+ if (!self.last_update_start) self.last_update_start = current_update_start;
51
+ var time_to_update_this_frame = current_update_start - self.last_update_start;
52
+
53
+ if (self.calculateUpdateRate) {
54
+ self.time_to_update = (self.time_to_update || 0) * self.framerate_sample_ratio
55
+ + time_to_update_this_frame * (1 - self.framerate_sample_ratio);
56
+
57
+ // update rate = seconds / time
58
+ self.updates_per_second = 1.0 / self.time_to_update;
59
+ }
60
+
61
+ // in order to avoid recalculating the above for updates, we'll return the timechange
62
+ // to be used in subsequent updates.
63
+ var timechange = current_update_start - self.last_update_start;
64
+ self.last_update_start = current_update_start;
65
+ return timechange;
66
+ }
67
+
35
68
  function startRendering(self) {
36
69
  function render() {
70
+ if (self.calculateFramerate) updateFramerate(self);
37
71
  if (self.current_view) {
38
- reloadMatrices(self);
39
- self.glViewport(0, 0, self.canvas.width, self.canvas.height);
72
+ self.prepare();
40
73
  self.current_view.render();
74
+ var len = self.afterRenderFuncs.length;
75
+ for (var i = 0; i < len; i++) self.afterRenderFuncs[i].call(self);
41
76
  self.render_interval = requestAnimFrame(render, self.canvas);
42
77
  }
43
78
  else {
@@ -55,12 +90,11 @@ Jax.Context = (function() {
55
90
 
56
91
  function startUpdating(self) {
57
92
  function updateFunc() {
58
- if (!self.lastUpdate) self.lastUpdate = new Date();
59
- var now = new Date();
60
- var timechange = (now - self.lastUpdate) / 1000.0;
61
- self.lastUpdate = now;
93
+ var timechange = updateUpdateRate(self);
62
94
 
63
95
  self.update(timechange);
96
+ var len = self.afterUpdateFuncs.length;
97
+ for (var i = 0; i < len; i++) self.afterUpdateFuncs[i].call(self);
64
98
  self.update_interval = setTimeout(updateFunc, Jax.update_speed);
65
99
  }
66
100
  updateFunc();
@@ -86,7 +120,7 @@ Jax.Context = (function() {
86
120
  function reloadMatrices(self) {
87
121
  self.matrix_stack.reset(); // reset depth
88
122
  self.matrix_stack.loadModelMatrix(Jax.IDENTITY_MATRIX);
89
- self.matrix_stack.loadViewMatrix(self.player.camera.getModelViewMatrix());
123
+ self.matrix_stack.loadViewMatrix(self.player.camera.getTransformationMatrix());
90
124
  self.matrix_stack.loadProjectionMatrix(self.player.camera.getProjectionMatrix());
91
125
  }
92
126
 
@@ -111,18 +145,100 @@ Jax.Context = (function() {
111
145
  this.player.camera.perspective({width:canvas.width, height:canvas.height});
112
146
  this.matrix_stack = new Jax.MatrixStack();
113
147
  this.current_pass = Jax.Scene.AMBIENT_PASS;
148
+ this.afterRenderFuncs = [];
149
+ this.afterUpdateFuncs = [];
150
+ this.framerate = 0;
151
+ this.frames_per_second = 0;
152
+ this.updates_per_second = 0;
153
+
154
+ /**
155
+ * Jax.Context#framerate_sample_ratio -> Number
156
+ *
157
+ * A number between 0 and 1, to be used in updates to frames per second and updates per second.
158
+ *
159
+ * Setting this to a high value will produce "smoother" results; they will change less frequently,
160
+ * but it will take longer to get initial results. High values are better for testing framerate
161
+ * over the long term, while lower values are better for testing small disruptions in framerate
162
+ * (such as garbage collection).
163
+ *
164
+ * Defaults to 0.9.
165
+ **/
166
+ this.framerate_sample_ratio = 0.9;
114
167
 
115
168
  startUpdating(this);
116
169
  if (Jax.routes.isRouted("/"))
117
170
  this.redirectTo("/");
118
171
  },
119
172
 
173
+ /**
174
+ * Jax.Context#getFramesPerSecond() -> Number
175
+ * The average number of frames rendered in one second.
176
+ *
177
+ * Implicitly enables calculation of frames-per-second, which is initially disabled by default
178
+ * to improve performance.
179
+ **/
180
+ getFramesPerSecond: function() { this.calculateFramerate = true; return this.frames_per_second; },
181
+
182
+ /**
183
+ * Jax.Context#getUpdatesPerSecond() -> Number
184
+ * The average number of updates performed in one second. See also Jax.Context#getFramesPerSecond().
185
+ *
186
+ * Implicitly enables calculation of updates-per-second, which is initially disabled by default
187
+ * to improve performance.
188
+ **/
189
+ getUpdatesPerSecond: function() { this.calculateUpdateRate = true; return this.updates_per_second; },
190
+
191
+ /**
192
+ * Jax.Context#disableFrameSpeedCalculations() -> Jax.Context
193
+ * Disables calculation of frames-per-second. Note that this calculation is disabled by default
194
+ * to improve performance, so you should only need to call this if you've previously called
195
+ * Jax.Context#getUpdatesPerSecond().
196
+ **/
197
+ disableFrameSpeedCalculations: function() { this.calculateFramerate = false; },
198
+
199
+ /**
200
+ * Jax.Context#disableUpdateSpeedCalculations() -> Jax.Context
201
+ * Disables calculation of updates-per-second. Note that this calculation is disabled by default
202
+ * to improve performance, so you should only need to call this if you've previously called
203
+ * Jax.Context#getUpdatesPerSecond().
204
+ **/
205
+ disableUpdateSpeedCalculations: function() { this.caclulateUpdateRate = false; },
206
+
207
+ /**
208
+ * Jax.Context#afterRender(func) -> Jax.Context
209
+ *
210
+ * Registers the specified function to be called immediately after every render pass.
211
+ * Returns this context.
212
+ *
213
+ * When the function is called, its +this+ object is set to the context itself.
214
+ **/
215
+ afterRender: function(func) {
216
+ this.afterRenderFuncs.push(func);
217
+ },
218
+
219
+ /**
220
+ * Jax.Context#afterUpdate(func) -> Jax.Context
221
+ *
222
+ * Registers the specified function to be called immediately after every update pass.
223
+ * Returns this context.
224
+ *
225
+ * When the function is called, its +this+ object is set to the context itself.
226
+ **/
227
+ afterUpdate: function(func) {
228
+ this.afterUpdateFuncs.push(func);
229
+ },
230
+
231
+ /**
232
+ * Jax.Context#hasStencil() -> Boolean
233
+ *
234
+ * Returns true if this context supports stencil operations.
235
+ **/
120
236
  hasStencil: function() {
121
237
  return !!this.gl.stencil;
122
238
  },
123
239
 
124
240
  /**
125
- * Jax.Context#redirectTo(path) -> Controller
241
+ * Jax.Context#redirectTo(path) -> Jax.Controller
126
242
  * - path (String): the path to redirect to
127
243
  *
128
244
  * Redirects to the specified route, and then returns the Jax.Controller that
@@ -147,10 +263,36 @@ Jax.Context = (function() {
147
263
  return this.current_controller;
148
264
  },
149
265
 
266
+ /**
267
+ * Jax.Context#prepare() -> Jax.Context
268
+ *
269
+ * Loads the matrices from +player.camera+ into the matrix stack, then
270
+ * sets up the viewport. This should be run prior to rendering anything.
271
+ * This is done automatically when the context has a View associated
272
+ * with it, but if there is no View then the render process will be
273
+ * halted, leaving it up to you to prepare the canvas explicitly.
274
+ **/
275
+ prepare: function() {
276
+ reloadMatrices(this);
277
+ this.glViewport(0, 0, this.canvas.width, this.canvas.height);
278
+ },
279
+
280
+ /**
281
+ * Jax.Context#update(timechange) -> Jax.Context
282
+ * - timechange (Number): the amount of time, in seconds, since the previous update
283
+ *
284
+ * Automatically called over time, this function will trigger an update
285
+ * of all controllers and objects attached to this context.
286
+ *
287
+ * You can programmatically trigger updates to these objects by calling
288
+ * this method directly. Doing this is useful for constructing consistent
289
+ * test cases.
290
+ **/
150
291
  update: function(timechange) {
151
292
  if (this.current_controller && this.current_controller.update)
152
293
  this.current_controller.update(timechange);
153
294
  this.world.update(timechange);
295
+ return this;
154
296
  },
155
297
 
156
298
  /**
@@ -186,11 +328,30 @@ Jax.Context = (function() {
186
328
  isDisposed: function() {
187
329
  return !!this.disposed;
188
330
  },
189
-
331
+
332
+ /**
333
+ * Jax.Context#pushMatrix(yield_to) -> Jax.Context
334
+ * - yield_to (Function): a function to be called
335
+ *
336
+ * Pushes a new level onto the matrix stack and then calls the given function.
337
+ * After the function completes, the matrix stack is reverted back to its
338
+ * original state, effectively undoing any modifications made to the matrices
339
+ * in the meantime.
340
+ *
341
+ * Example:
342
+ *
343
+ * context.pushMatrix(function() {
344
+ * context.loadModelMatrix(Jax.IDENTITY_MATRIX);
345
+ * context.multViewMatrix(this.camera.getTransformationMatrix());
346
+ * // do some rendering
347
+ * });
348
+ * // matrix is restored to its previous state
349
+ **/
190
350
  pushMatrix: function(yield_to) {
191
351
  this.matrix_stack.push();
192
352
  yield_to();
193
353
  this.matrix_stack.pop();
354
+ return this;
194
355
  },
195
356
 
196
357
  /**
@@ -245,6 +406,12 @@ Jax.Context = (function() {
245
406
  /* set up matrix stack delegation */
246
407
  klass.delegate(/^(get|load|mult)(.*)Matrix$/).into("matrix_stack");
247
408
 
409
+ /** alias of: Jax.Context#getFramesPerSecond
410
+ * Jax.Context#getFramerate() -> Number
411
+ * The average numebr of frames rendered in one second.
412
+ **/
413
+ klass.prototype.getFramerate = klass.prototype.getFramesPerSecond;
414
+
248
415
  return klass;
249
416
  })();
250
417
 
data/src/jax/core.js CHANGED
@@ -5,9 +5,12 @@
5
5
  //= require "core/util"
6
6
  //= require "core/matrix_stack"
7
7
 
8
- // a global debugAssert method that will do nothing in production, and fail if expr is false
9
- // in any other run mode. If msg is given, an error with that message is raised. Otherwise,
10
- // a more generic error is raised.
8
+ /**
9
+ * Global#debugAssert(expr[, msg]) -> undefined
10
+ * a global debugAssert method that will do nothing in production, and fail if expr is false
11
+ * in any other run mode. If msg is given, an error with that message is raised. Otherwise,
12
+ * a more generic error is raised.
13
+ **/
11
14
  window.debugAssert = function(expr, msg) {
12
15
  if (Jax.environment != "production" && !expr)
13
16
  {