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
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jax
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.0.5
5
+ version: 0.0.0.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Colin MacKenzie IV
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-21 00:00:00 -04:00
13
+ date: 2011-05-28 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -216,6 +216,10 @@ files:
216
216
  - builtin/shaders/paraboloid/manifest.yml
217
217
  - builtin/shaders/paraboloid/material.js
218
218
  - builtin/shaders/paraboloid/vertex.ejs
219
+ - builtin/shaders/picking/common.ejs
220
+ - builtin/shaders/picking/fragment.ejs
221
+ - builtin/shaders/picking/material.js
222
+ - builtin/shaders/picking/vertex.ejs
219
223
  - builtin/shaders/shadow_map/common.ejs
220
224
  - builtin/shaders/shadow_map/fragment.ejs
221
225
  - builtin/shaders/shadow_map/manifest.yml
@@ -429,14 +433,18 @@ files:
429
433
  - spec/example_app/app/controllers/courthouse_controller.js
430
434
  - spec/example_app/app/controllers/lighting_controller.js
431
435
  - spec/example_app/app/controllers/noise_controller.js
436
+ - spec/example_app/app/controllers/picking_controller.js
432
437
  - spec/example_app/app/controllers/shadows_controller.js
433
438
  - spec/example_app/app/controllers/textures_controller.js
434
439
  - spec/example_app/app/helpers/application_helper.js
435
440
  - spec/example_app/app/helpers/noise_helper.js
441
+ - spec/example_app/app/helpers/picking_helper.js
436
442
  - spec/example_app/app/helpers/textures_helper.js
443
+ - spec/example_app/app/models/blob.js
437
444
  - spec/example_app/app/models/character.js
438
445
  - spec/example_app/app/models/door.js
439
446
  - spec/example_app/app/models/scene.js
447
+ - spec/example_app/app/resources/blobs/default.yml
440
448
  - spec/example_app/app/resources/characters/judge.yml
441
449
  - spec/example_app/app/resources/doors/courthouse_door.yml
442
450
  - spec/example_app/app/resources/light_sources/directional_light.yml
@@ -456,6 +464,7 @@ files:
456
464
  - spec/example_app/app/views/courthouse/index.js
457
465
  - spec/example_app/app/views/lighting/index.js
458
466
  - spec/example_app/app/views/noise/index.js
467
+ - spec/example_app/app/views/picking/index.js
459
468
  - spec/example_app/app/views/shadows/index.js
460
469
  - spec/example_app/app/views/textures/index.js
461
470
  - spec/example_app/config/application.rb
@@ -469,9 +478,12 @@ files:
469
478
  - spec/example_app/public/webgl_not_supported.html
470
479
  - spec/example_app/script/jax
471
480
  - spec/example_app/spec/javascripts/controllers/noise_controller_spec.js
481
+ - spec/example_app/spec/javascripts/controllers/picking_controller_spec.js
472
482
  - spec/example_app/spec/javascripts/controllers/textures_controller_spec.js
473
483
  - spec/example_app/spec/javascripts/helpers/application_helper_spec.js
474
484
  - spec/example_app/spec/javascripts/helpers/noise_helper_spec.js
485
+ - spec/example_app/spec/javascripts/helpers/picking_helper_spec.js
486
+ - spec/example_app/spec/javascripts/models/blob_spec.js
475
487
  - spec/example_app/spec/javascripts/resources/directional_light_spec.js
476
488
  - spec/example_app/spec/javascripts/resources/point_light_spec.js
477
489
  - spec/example_app/spec/javascripts/resources/spot_light_spec.js
@@ -524,6 +536,7 @@ files:
524
536
  - spec/javascripts/shaders/lighting_spec.js
525
537
  - spec/javascripts/shaders/normal_map_spec.js
526
538
  - spec/javascripts/shaders/paraboloid_spec.js
539
+ - spec/javascripts/shaders/preprocessor_spec.js
527
540
  - spec/javascripts/shaders/shadow_map_spec.js
528
541
  - spec/javascripts/shaders/texture_spec.js
529
542
  - spec/javascripts/support/jasmine.yml
@@ -547,7 +560,6 @@ files:
547
560
  - src/jax/builtin/meshes/torus.js
548
561
  - src/jax/compatibility.js
549
562
  - src/jax/context.js
550
- - src/jax/controller.js
551
563
  - src/jax/core.js
552
564
  - src/jax/core/math.js
553
565
  - src/jax/core/matrix_stack.js
@@ -555,17 +567,18 @@ files:
555
567
  - src/jax/events.js
556
568
  - src/jax/geometry.js
557
569
  - src/jax/geometry/plane.js
558
- - src/jax/helper.js
559
- - src/jax/model.js
570
+ - src/jax/mvc/controller.js
571
+ - src/jax/mvc/helper.js
572
+ - src/jax/mvc/model.js
573
+ - src/jax/mvc/route_set.js
574
+ - src/jax/mvc/view.js
575
+ - src/jax/mvc/view_manager.js
560
576
  - src/jax/noise.js
561
577
  - src/jax/prototype/class.js
562
578
  - src/jax/prototype/core.js
563
579
  - src/jax/prototype/extensions.js
564
- - src/jax/route_set.js
565
580
  - src/jax/vendor/ejs.js
566
581
  - src/jax/vendor/glMatrix.js
567
- - src/jax/view.js
568
- - src/jax/view_manager.js
569
582
  - src/jax/webgl.js
570
583
  - src/jax/webgl/camera.js
571
584
  - src/jax/webgl/core.js
@@ -676,7 +689,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
676
689
  requirements:
677
690
  - - ">="
678
691
  - !ruby/object:Gem::Version
679
- hash: -852676475953651161
692
+ hash: 3001490309694748403
680
693
  segments:
681
694
  - 0
682
695
  version: "0"
@@ -685,7 +698,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
685
698
  requirements:
686
699
  - - ">="
687
700
  - !ruby/object:Gem::Version
688
- hash: -852676475953651161
701
+ hash: 3001490309694748403
689
702
  segments:
690
703
  - 0
691
704
  version: "0"
@@ -703,14 +716,18 @@ test_files:
703
716
  - spec/example_app/app/controllers/courthouse_controller.js
704
717
  - spec/example_app/app/controllers/lighting_controller.js
705
718
  - spec/example_app/app/controllers/noise_controller.js
719
+ - spec/example_app/app/controllers/picking_controller.js
706
720
  - spec/example_app/app/controllers/shadows_controller.js
707
721
  - spec/example_app/app/controllers/textures_controller.js
708
722
  - spec/example_app/app/helpers/application_helper.js
709
723
  - spec/example_app/app/helpers/noise_helper.js
724
+ - spec/example_app/app/helpers/picking_helper.js
710
725
  - spec/example_app/app/helpers/textures_helper.js
726
+ - spec/example_app/app/models/blob.js
711
727
  - spec/example_app/app/models/character.js
712
728
  - spec/example_app/app/models/door.js
713
729
  - spec/example_app/app/models/scene.js
730
+ - spec/example_app/app/resources/blobs/default.yml
714
731
  - spec/example_app/app/resources/characters/judge.yml
715
732
  - spec/example_app/app/resources/doors/courthouse_door.yml
716
733
  - spec/example_app/app/resources/light_sources/directional_light.yml
@@ -730,6 +747,7 @@ test_files:
730
747
  - spec/example_app/app/views/courthouse/index.js
731
748
  - spec/example_app/app/views/lighting/index.js
732
749
  - spec/example_app/app/views/noise/index.js
750
+ - spec/example_app/app/views/picking/index.js
733
751
  - spec/example_app/app/views/shadows/index.js
734
752
  - spec/example_app/app/views/textures/index.js
735
753
  - spec/example_app/config/application.rb
@@ -743,9 +761,12 @@ test_files:
743
761
  - spec/example_app/public/webgl_not_supported.html
744
762
  - spec/example_app/script/jax
745
763
  - spec/example_app/spec/javascripts/controllers/noise_controller_spec.js
764
+ - spec/example_app/spec/javascripts/controllers/picking_controller_spec.js
746
765
  - spec/example_app/spec/javascripts/controllers/textures_controller_spec.js
747
766
  - spec/example_app/spec/javascripts/helpers/application_helper_spec.js
748
767
  - spec/example_app/spec/javascripts/helpers/noise_helper_spec.js
768
+ - spec/example_app/spec/javascripts/helpers/picking_helper_spec.js
769
+ - spec/example_app/spec/javascripts/models/blob_spec.js
749
770
  - spec/example_app/spec/javascripts/resources/directional_light_spec.js
750
771
  - spec/example_app/spec/javascripts/resources/point_light_spec.js
751
772
  - spec/example_app/spec/javascripts/resources/spot_light_spec.js
@@ -798,6 +819,7 @@ test_files:
798
819
  - spec/javascripts/shaders/lighting_spec.js
799
820
  - spec/javascripts/shaders/normal_map_spec.js
800
821
  - spec/javascripts/shaders/paraboloid_spec.js
822
+ - spec/javascripts/shaders/preprocessor_spec.js
801
823
  - spec/javascripts/shaders/shadow_map_spec.js
802
824
  - spec/javascripts/shaders/texture_spec.js
803
825
  - spec/javascripts/support/jasmine.yml
data/src/jax/helper.js DELETED
@@ -1,8 +0,0 @@
1
- Jax.Helper = {
2
- instances: [],
3
-
4
- create: function(methods) {
5
- Jax.Helper.instances.push(methods);
6
- return methods;
7
- }
8
- };
data/src/jax/model.js DELETED
@@ -1,163 +0,0 @@
1
- /**
2
- * class Jax.Model
3
- *
4
- **/
5
- (function() {
6
- function initProperties(self, data) {
7
- // to make sure sub-properties of data are standalone objects, so that the original data can't be tainted
8
- data = Jax.Util.normalizeOptions(data, {});
9
-
10
- var attribute;
11
-
12
- if (data) {
13
- for (attribute in data) {
14
- switch(attribute) {
15
- case 'position': self.camera.setPosition(Jax.Util.vectorize(data[attribute])); break;
16
- case 'direction': self.camera.orient(Jax.Util.vectorize(data[attribute])); break;
17
- case 'mesh':
18
- if (data[attribute].isKindOf(Jax.Mesh)) self.mesh = data[attribute];
19
- else throw new Error("Unexpected value for mesh:\n\n"+JSON.stringify(data[attribute]));
20
- break;
21
- default:
22
- self[attribute] = data[attribute];
23
- }
24
- }
25
- }
26
- }
27
-
28
- Jax.Model = (function() {
29
- return Jax.Class.create({
30
- initialize: function(data) {
31
- this.camera = new Jax.Camera();
32
-
33
- initProperties(this, Jax.Model.default_properties);
34
- if (this._klass && this._klass.resources)
35
- initProperties(this, this._klass.resources['default']);
36
- initProperties(this, data);
37
-
38
- if (this.after_initialize) this.after_initialize();
39
- },
40
-
41
- isShadowCaster: function() { return this.shadow_caster; },
42
-
43
- /**
44
- * Jax.Model#render(context) -> undefined
45
- *
46
- * Renders this model with the given context. If the model doesn't have a mesh,
47
- * nothing is rendered.
48
- **/
49
- render: function(context, options) {
50
- if (this.mesh)
51
- {
52
- var self = this;
53
- context.pushMatrix(function() {
54
- context.multModelMatrix(self.camera.getModelViewMatrix());
55
- self.mesh.render(context, options);
56
- });
57
- }
58
- },
59
-
60
- getBoundingCube: function() {
61
- if (!this.mesh.built) this.mesh.rebuild();
62
- return this.mesh.bounds;
63
- },
64
-
65
- getBoundingSphereRadius: function() {
66
- var b = this.getBoundingCube();
67
- return Math.max(b.width, Math.max(b.height, b.depth));
68
- },
69
-
70
- dispose: function() {
71
- if (this.mesh)
72
- this.mesh.dispose();
73
- },
74
-
75
- isLit: function() {
76
- return this.lit;
77
- },
78
-
79
- /**
80
- * Jax.Model#inspect() -> String
81
- *
82
- * Returns the JSON representation of the attributes in this model.
83
- * Function definitions are not included.
84
- *
85
- **/
86
- inspect: function() {
87
- result = {};
88
- for (var i in this)
89
- if (!Object.isFunction(this[i]) && i != "_klass")
90
- result[i] = this[i];
91
- return JSON.stringify(result);
92
- }
93
- });
94
- })();
95
-
96
- var model_class_methods = {
97
- /**
98
- * Jax.Model.find(id) -> Jax.Model
99
- * - id (String): the unique identifier of the model to be found
100
- *
101
- * Finds the resource with the specified name, instantiates its model and returns it.
102
- *
103
- * Note that this is a class method of the model in question, and not of Jax.Model itself.
104
- *
105
- * For example, this would be correct:
106
- *
107
- * Character.find('bad_guy')
108
- *
109
- * while this would be *incorrect*:
110
- *
111
- * Jax.Model.find('bad_guy')
112
- *
113
- **/
114
- find: function(id) {
115
- for (var resource_id in this.resources) {
116
- if (id == resource_id)
117
- return new this(this.resources[id]);
118
- }
119
- throw new Error("Resource '"+id+"' not found!");
120
- },
121
-
122
- /**
123
- * Jax.Model.addResources(resources) -> undefined
124
- * - resources (Object): the resources to be added
125
- *
126
- * Adds the resources to the specified model. These resources can then be found using
127
- * Jax.Model.find(id).
128
- *
129
- * Note that this is a class method of the model in question, and not of Jax.Model itself.
130
- *
131
- * For example, this would be correct:
132
- *
133
- * Character.addResources({'bad_guy': {...}})
134
- *
135
- * while this would be *incorrect*:
136
- *
137
- * Jax.Model.addResources({'bad_guy': {...}})
138
- *
139
- **/
140
- addResources: function(resources) {
141
- this.resources = this.resources || {};
142
- for (var id in resources)
143
- if (this.resources[id]) throw new Error("Duplicate resource ID: "+id);
144
- else this.resources[id] = resources[id];
145
- }
146
- };
147
-
148
- Jax.Model.default_properties = {
149
- lit: true,
150
- shadow_caster: true
151
- };
152
-
153
- Jax.Model.create = function(superclass, inner) {
154
- var klass;
155
- if (inner) klass = Jax.Class.create(superclass, inner);
156
- else klass = Jax.Class.create(Jax.Model, superclass);
157
-
158
- klass.addMethods({_klass:klass});
159
-
160
- Object.extend(klass, model_class_methods);
161
- return klass;
162
- };
163
- })();