jax 2.0.8 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,3 +19,15 @@ rvm:
19
19
  # - sh -e /etc/init.d/xvfb start
20
20
 
21
21
  env: "SKIP_WEBGL=1 "
22
+
23
+ # JRuby and RBX are not yet officially supported,
24
+ # until failing dependencies work properly or are
25
+ # no longer depended upon.
26
+ matrix:
27
+ allow_failures:
28
+ - rvm: jruby-18mode
29
+ - rvm: jruby-19mode
30
+ - rvm: jruby-head
31
+ - rvm: rbx-18mode
32
+ - rvm: rbx-19mode
33
+
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ * 2.0.9 *
2
+
3
+ * Resolved issue #59: Jax.Mesh.Cube should update its data when any of its faces change
4
+
5
+
6
+
1
7
  * 2.0.8 *
2
8
 
3
9
  * Resolved issue #55: bin/jax should not fail within spaced paths
@@ -30,26 +30,40 @@ Jax.Mesh.Cube = Jax.Class.create(Jax.Mesh, {
30
30
  this.draw_mode = GL_TRIANGLES;
31
31
  $super(options);
32
32
 
33
+ var self = this;
34
+ /* TODO for performance, only update data that has actually changed */
35
+ var dispose = function() { self.dispose(); };
36
+ var refresh = function() { self.dispose(); };
33
37
  var w = options.width, h = options.height, d = options.depth;
34
- this.sides = {};
38
+ this.left = new Jax.Model({mesh: new Jax.Mesh.Quad(d, h)});
39
+ this.left.camera.reorient([-1,0,0], [-w/2,0,0]);
40
+ this.left.mesh.addEventListener("color_changed", dispose);
41
+ this.left.camera.addEventListener("updated", refresh);
35
42
 
36
- this.sides.left = new Jax.Model({mesh: new Jax.Mesh.Quad(d, h)});
37
- this.sides.left.camera.reorient([-1,0,0], [-w/2,0,0]);
43
+ this.right = new Jax.Model({mesh: new Jax.Mesh.Quad(d, h)});
44
+ this.right.camera.reorient([1,0,0], [w/2,0,0]);
45
+ this.right.mesh.addEventListener("color_changed", dispose);
46
+ this.right.camera.addEventListener("updated", refresh);
38
47
 
39
- this.sides.right = new Jax.Model({mesh: new Jax.Mesh.Quad(d, h)});
40
- this.sides.right.camera.reorient([1,0,0], [w/2,0,0]);
48
+ this.front = new Jax.Model({mesh: new Jax.Mesh.Quad(w, h)});
49
+ this.front.camera.reorient([0,0,1], [0,0,d/2]);
50
+ this.front.mesh.addEventListener("color_changed", dispose);
51
+ this.front.camera.addEventListener("updated", refresh);
41
52
 
42
- this.sides.front = new Jax.Model({mesh: new Jax.Mesh.Quad(w, h)});
43
- this.sides.front.camera.reorient([0,0,1], [0,0,d/2]);
53
+ this.back = new Jax.Model({mesh: new Jax.Mesh.Quad(w, h)});
54
+ this.back.camera.reorient([0,0,-1], [0,0,-d/2]);
55
+ this.back.mesh.addEventListener("color_changed", dispose);
56
+ this.back.camera.addEventListener("updated", refresh);
44
57
 
45
- this.sides.back = new Jax.Model({mesh: new Jax.Mesh.Quad(w, h)});
46
- this.sides.back.camera.reorient([0,0,-1], [0,0,-d/2]);
58
+ this.top = new Jax.Model({mesh: new Jax.Mesh.Quad(w, d)});
59
+ this.top.camera.reorient([0,1,0], [0,h/2,0]);
60
+ this.top.mesh.addEventListener("color_changed", dispose);
61
+ this.top.camera.addEventListener("updated", refresh);
47
62
 
48
- this.sides.top = new Jax.Model({mesh: new Jax.Mesh.Quad(w, d)});
49
- this.sides.top.camera.reorient([0,1,0], [0,h/2,0]);
50
-
51
- this.sides.bottom = new Jax.Model({mesh: new Jax.Mesh.Quad(w, d)});
52
- this.sides.bottom.camera.reorient([0,-1,0], [0,-h/2,0]);
63
+ this.bottom = new Jax.Model({mesh: new Jax.Mesh.Quad(w, d)});
64
+ this.bottom.camera.reorient([0,-1,0], [0,-h/2,0]);
65
+ this.bottom.mesh.addEventListener("color_changed", dispose);
66
+ this.bottom.camera.addEventListener("updated", refresh);
53
67
  },
54
68
 
55
69
  init: function(verts, colors, texes, norms) {
@@ -57,11 +71,13 @@ Jax.Mesh.Cube = Jax.Class.create(Jax.Mesh, {
57
71
  // local transformation, which includes the position offset and direction.
58
72
 
59
73
  var matrix;
60
- for (var i in this.sides)
74
+ var sides = ['left', 'right', 'top', 'bottom', 'front', 'back'];
75
+ for (var i = 0; i < sides.length; i++)
61
76
  {
62
77
  var qverts = [], qcolor = [], qtex = [], qnorm = [];
63
- this.sides[i].mesh.init(qverts, qcolor, qtex, qnorm, []);
64
- matrix = this.sides[i].camera.getTransformationMatrix();
78
+ this[sides[i]].mesh.init(qverts, qcolor, qtex, qnorm, []);
79
+ qcolor = this[sides[i]].mesh.getColorBuffer().js;
80
+ matrix = this[sides[i]].camera.getTransformationMatrix();
65
81
 
66
82
  // unfortunately quads are rendered in triangle strips; we need to translate that
67
83
  // into triangles, because there's no support at this time for ending one triangle
@@ -221,6 +221,22 @@
221
221
  return this.lit;
222
222
  },
223
223
 
224
+ /**
225
+ * Jax.Mesh#setColor(r, g, b, a) -> Jax.Model
226
+ * Jax.Mesh#setColor(colors) -> Jax.Model
227
+ *
228
+ * Sets the color to the specified RGBA color, or an array containing
229
+ * RGBA colors. This is method simply delegated into `this.mesh`.
230
+ *
231
+ * Returns itself.
232
+ *
233
+ **/
234
+ setColor: function(a, b, c, d) {
235
+ if (arguments.length > 1) this.mesh.setColor(a, b, c, d);
236
+ else this.mesh.setColor(a);
237
+ return this;
238
+ },
239
+
224
240
  /**
225
241
  * Jax.Model#inspect() -> String
226
242
  *
@@ -1,12 +1,13 @@
1
1
  //= require "jax/webgl/core"
2
+ //= require "jax/webgl/core/events"
2
3
  //= require_self
3
4
  //= require "jax/webgl/mesh/tangent_space"
4
5
  //= require "jax/webgl/mesh/support"
5
6
  //= require "jax/webgl/mesh/normals"
6
7
 
7
-
8
8
  /**
9
9
  * class Jax.Mesh
10
+ * includes Jax.Events.Methods
10
11
  *
11
12
  * Example:
12
13
  *
@@ -217,6 +218,7 @@ Jax.Mesh = (function() {
217
218
  }
218
219
 
219
220
  colorBuffer.refresh();
221
+ this.fireEvent('color_changed');
220
222
  return this;
221
223
  },
222
224
 
@@ -438,3 +440,5 @@ Jax.Mesh = (function() {
438
440
  }
439
441
  });
440
442
  })();
443
+
444
+ Jax.Mesh.addMethods(Jax.Events.Methods);
@@ -2,7 +2,7 @@ module Jax
2
2
  module Version
3
3
  MAJOR = 2
4
4
  MINOR = 0
5
- PATCH = 8
5
+ PATCH = 9
6
6
  BUILD = nil
7
7
  STRING = BUILD ? [MAJOR, MINOR, PATCH, BUILD].join(".") : [MAJOR, MINOR, PATCH].join(".")
8
8
  end
@@ -63,10 +63,19 @@ beforeEach(function() {
63
63
  }
64
64
 
65
65
  this.addMatchers({
66
- toBePlaying: function(expectedSong) {
67
- var player = this.actual;
68
- return player.currentlyPlayingSong === expectedSong
69
- && player.isPlaying;
66
+ toIncludeSubset: function(subset) {
67
+ for (var i = 0; i < this.actual.length; i++) {
68
+ if (i+subset.length >= this.actual.length) return false;
69
+
70
+ var found = true;
71
+ for (var j = 0; j < subset.length; j++) {
72
+ if (this.actual[i+j] != subset[j])
73
+ found = false;
74
+ }
75
+ if (found) return true;
76
+ }
77
+
78
+ return false;
70
79
  },
71
80
 
72
81
  toBeKindOf: function(expectedKlass) {
@@ -0,0 +1,39 @@
1
+ describe "Cube", ->
2
+ cube = null
3
+ verts = colors = texes = norms = null
4
+
5
+ beforeEach ->
6
+ [verts, colors, texes, norms] = [[], [], [], []]
7
+ cube = new Jax.Mesh.Cube()
8
+
9
+ it "should build successfully", ->
10
+ cube.init verts, colors, texes, norms
11
+
12
+ it "should default all colors to white", ->
13
+ cube.init verts, colors, texes, norms
14
+ expect(colors).toEqualVector [
15
+ 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, # side 1
16
+ 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, # side 2
17
+ 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, # side 3
18
+ 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, # side 4
19
+ 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, # side 5
20
+ 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, # side 6
21
+ ]
22
+
23
+ it "should allow altering of face color prior to build", ->
24
+ cube.left.setColor 1, 0, 0, 1
25
+ colors = cube.getColorBuffer().js;
26
+ expect(colors).toIncludeSubset([1, 0, 0, 1]);
27
+
28
+ it "should allow altering of face color after build", ->
29
+ cube.getColorBuffer();
30
+ cube.left.setColor 1, 0, 0, 1
31
+ colors = cube.getColorBuffer().js;
32
+ expect(colors).toIncludeSubset([1, 0, 0, 1]);
33
+
34
+ describe "when a side has been changed", ->
35
+ it "should update its vertices", ->
36
+ cube.getColorBuffer();
37
+ cube.left.camera.setPosition([10, 10, 10]);
38
+ expect(cube.getVertexBuffer().js).toIncludeSubset([10, 9.5, 9.5]);
39
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jax
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-29 00:00:00.000000000Z
12
+ date: 2012-05-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &2160774320 !ruby/object:Gem::Requirement
16
+ requirement: &2157372880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2160774320
24
+ version_requirements: *2157372880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jquery-rails
27
- requirement: &2160773480 !ruby/object:Gem::Requirement
27
+ requirement: &2157372260 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2160773480
35
+ version_requirements: *2157372260
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jasmine
38
- requirement: &2160772640 !ruby/object:Gem::Requirement
38
+ requirement: &2157371460 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2160772640
46
+ version_requirements: *2157371460
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rest-client
49
- requirement: &2160771880 !ruby/object:Gem::Requirement
49
+ requirement: &2157370820 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '1'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2160771880
57
+ version_requirements: *2157370820
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &2160770860 !ruby/object:Gem::Requirement
60
+ requirement: &2157370220 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '2'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2160770860
68
+ version_requirements: *2157370220
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: coffee-rails
71
- requirement: &2160769880 !ruby/object:Gem::Requirement
71
+ requirement: &2157369640 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '3'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2160769880
79
+ version_requirements: *2157369640
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: coderay
82
- requirement: &2160769080 !ruby/object:Gem::Requirement
82
+ requirement: &2157369060 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '1'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2160769080
90
+ version_requirements: *2157369060
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: sqlite3
93
- requirement: &2160768260 !ruby/object:Gem::Requirement
93
+ requirement: &2157368500 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '1'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2160768260
101
+ version_requirements: *2157368500
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: sass-rails
104
- requirement: &2160767460 !ruby/object:Gem::Requirement
104
+ requirement: &2157367880 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '3'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2160767460
112
+ version_requirements: *2157367880
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: uglifier
115
- requirement: &2160766660 !ruby/object:Gem::Requirement
115
+ requirement: &2157361040 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '1'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2160766660
123
+ version_requirements: *2157361040
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: genspec
126
- requirement: &2160765580 !ruby/object:Gem::Requirement
126
+ requirement: &2157360200 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *2160765580
134
+ version_requirements: *2157360200
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: selenium-webdriver
137
- requirement: &2160764460 !ruby/object:Gem::Requirement
137
+ requirement: &2157358480 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ~>
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '2'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *2160764460
145
+ version_requirements: *2157358480
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: fakeweb
148
- requirement: &2160763400 !ruby/object:Gem::Requirement
148
+ requirement: &2157357660 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ~>
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '1.3'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *2160763400
156
+ version_requirements: *2157357660
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: ansi
159
- requirement: &2160762780 !ruby/object:Gem::Requirement
159
+ requirement: &2157357120 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: '0'
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *2160762780
167
+ version_requirements: *2157357120
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: cucumber-rails
170
- requirement: &2160761760 !ruby/object:Gem::Requirement
170
+ requirement: &2157356060 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ~>
@@ -175,10 +175,10 @@ dependencies:
175
175
  version: '1'
176
176
  type: :development
177
177
  prerelease: false
178
- version_requirements: *2160761760
178
+ version_requirements: *2157356060
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: RedCloth
181
- requirement: &2160760580 !ruby/object:Gem::Requirement
181
+ requirement: &2157355120 !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements:
184
184
  - - ~>
@@ -186,10 +186,10 @@ dependencies:
186
186
  version: '4.2'
187
187
  type: :development
188
188
  prerelease: false
189
- version_requirements: *2160760580
189
+ version_requirements: *2157355120
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: w3c_validators
192
- requirement: &2160759660 !ruby/object:Gem::Requirement
192
+ requirement: &2157354260 !ruby/object:Gem::Requirement
193
193
  none: false
194
194
  requirements:
195
195
  - - ~>
@@ -197,10 +197,10 @@ dependencies:
197
197
  version: '1.2'
198
198
  type: :development
199
199
  prerelease: false
200
- version_requirements: *2160759660
200
+ version_requirements: *2157354260
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: treetop
203
- requirement: &2160758760 !ruby/object:Gem::Requirement
203
+ requirement: &2157353660 !ruby/object:Gem::Requirement
204
204
  none: false
205
205
  requirements:
206
206
  - - ~>
@@ -208,10 +208,10 @@ dependencies:
208
208
  version: 1.4.9
209
209
  type: :development
210
210
  prerelease: false
211
- version_requirements: *2160758760
211
+ version_requirements: *2157353660
212
212
  - !ruby/object:Gem::Dependency
213
213
  name: bluecloth
214
- requirement: &2160757900 !ruby/object:Gem::Requirement
214
+ requirement: &2157353000 !ruby/object:Gem::Requirement
215
215
  none: false
216
216
  requirements:
217
217
  - - ~>
@@ -219,7 +219,7 @@ dependencies:
219
219
  version: 2.0.11
220
220
  type: :development
221
221
  prerelease: false
222
- version_requirements: *2160757900
222
+ version_requirements: *2157353000
223
223
  description: ! "\n Framework for creating rich WebGL-enabled applications using
224
224
  JavaScript and Ruby.\n Can be used stand-alone to create static JavaScript documents,
225
225
  or integrated\n seamlessly with Ruby on Rails to build dynamic WebGL applications.\n
@@ -468,7 +468,7 @@ files:
468
468
  - spec/javascripts/helpers/jasmine_webgl_helper.js
469
469
  - spec/javascripts/helpers/jax_spec_environment_helper.js
470
470
  - spec/javascripts/helpers/jax_spec_helper.js
471
- - spec/javascripts/jax/builtin/meshes/cube_spec.js
471
+ - spec/javascripts/jax/builtin/meshes/cube_spec.js.coffee
472
472
  - spec/javascripts/jax/builtin/meshes/plane_spec.js
473
473
  - spec/javascripts/jax/builtin/meshes/quad_spec.js
474
474
  - spec/javascripts/jax/builtin/meshes/sphere_spec.js
@@ -648,7 +648,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
648
648
  version: '0'
649
649
  segments:
650
650
  - 0
651
- hash: -3461560233530444624
651
+ hash: 2869810087449141519
652
652
  required_rubygems_version: !ruby/object:Gem::Requirement
653
653
  none: false
654
654
  requirements:
@@ -657,7 +657,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
657
657
  version: '0'
658
658
  segments:
659
659
  - 0
660
- hash: -3461560233530444624
660
+ hash: 2869810087449141519
661
661
  requirements: []
662
662
  rubyforge_project: jax
663
663
  rubygems_version: 1.8.10
@@ -717,7 +717,7 @@ test_files:
717
717
  - spec/javascripts/helpers/jasmine_webgl_helper.js
718
718
  - spec/javascripts/helpers/jax_spec_environment_helper.js
719
719
  - spec/javascripts/helpers/jax_spec_helper.js
720
- - spec/javascripts/jax/builtin/meshes/cube_spec.js
720
+ - spec/javascripts/jax/builtin/meshes/cube_spec.js.coffee
721
721
  - spec/javascripts/jax/builtin/meshes/plane_spec.js
722
722
  - spec/javascripts/jax/builtin/meshes/quad_spec.js
723
723
  - spec/javascripts/jax/builtin/meshes/sphere_spec.js
@@ -1,10 +0,0 @@
1
- describe("Cube", function() {
2
- var cube;
3
-
4
- beforeEach(function() { cube = new Jax.Mesh.Cube() });
5
-
6
- it("should build successfully", function() {
7
- var verts = [], colors = [], texes = [], norms = [];
8
- cube.init(verts, colors, texes, norms);
9
- });
10
- });