jax 2.0.4 → 2.0.5
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.
- data/CHANGELOG +18 -0
- data/Rakefile +2 -2
- data/lib/assets/javascripts/jax/{application.js.erb → application.js} +0 -4
- data/lib/assets/javascripts/jax/core.js +1 -1
- data/lib/assets/javascripts/jax/core/base.js.erb +4 -0
- data/lib/assets/javascripts/jax/core/glMatrix_ext/vec3.js +22 -0
- data/lib/assets/javascripts/jax/core/matrix_stack.js +1 -1
- data/lib/assets/javascripts/jax/mvc/model.js +18 -0
- data/lib/assets/javascripts/jax/vendor/{glMatrix.js → gl-matrix.js} +1 -1
- data/lib/assets/javascripts/jax/webgl.js +1 -1
- data/lib/assets/javascripts/jax/webgl/camera.js +24 -39
- data/lib/assets/javascripts/jax/webgl/scene/light_source.js +58 -29
- data/lib/jax/version.rb +1 -1
- data/spec/javascripts/jax/core/utils_spec.js +9 -0
- data/spec/javascripts/jax/webgl/camera_spec.js +25 -0
- data/spec/javascripts/jax/webgl/lighting_spec.js +17 -0
- data/spec/javascripts/vendor/gl_matrix_spec.js +90 -0
- data/vendor/assets/javascripts/gl-matrix-pdoc.js +705 -0
- data/vendor/assets/javascripts/gl-matrix.js +1924 -0
- metadata +48 -45
- data/vendor/assets/javascripts/glMatrix.js +0 -1772
@@ -1,6 +1,23 @@
|
|
1
1
|
describe("LightManager", function() {
|
2
2
|
var mgr;
|
3
3
|
|
4
|
+
describe("when a light resource is defined with shadowcasting disabled", function() {
|
5
|
+
beforeEach(function() {
|
6
|
+
LightSource.addResources({"__test_shadowcast_disabled":{
|
7
|
+
shadowcaster:!1,enabled:!0,
|
8
|
+
position:{x:-20,y:0,z:0},
|
9
|
+
type:"POINT_LIGHT",
|
10
|
+
attenuation:{constant:0,linear:1,quadratic:0},
|
11
|
+
color:{ambient:{red:.15,green:.15,blue:.15,alpha:1},
|
12
|
+
diffuse:{red:.33,green:.1843137254901961,blue:.12679738562091503,alpha:1},
|
13
|
+
specular:{red:0,green:0,blue:0,alpha:0}}}});
|
14
|
+
});
|
15
|
+
|
16
|
+
it("should not be a shadow caster", function() {
|
17
|
+
expect(LightSource.find("__test_shadowcast_disabled").isShadowCaster()).toBeFalsy();
|
18
|
+
});
|
19
|
+
});
|
20
|
+
|
4
21
|
describe("when more than 1 light source is active", function() {
|
5
22
|
beforeEach(function() {
|
6
23
|
mgr = new Jax.Scene.LightManager();
|
@@ -0,0 +1,90 @@
|
|
1
|
+
// This file is here to ease transition from glMatrix v0.9.5 to v1.1, which
|
2
|
+
// seems to introduce some bugs. (Or rather, fixes to bugs, which break Jax.)
|
3
|
+
// May as well keep it for future-proofing though.
|
4
|
+
|
5
|
+
describe("glMatrix", function() {
|
6
|
+
var camera;
|
7
|
+
beforeEach(function() {
|
8
|
+
camera = new Jax.Camera();
|
9
|
+
|
10
|
+
// perform a translation so we can test it hasn't been broken
|
11
|
+
camera.move(10);
|
12
|
+
|
13
|
+
// sanity checks
|
14
|
+
expect(camera.getViewVector()).toEqualVector([0,0,-1]);
|
15
|
+
expect(camera.getUpVector()).toEqualVector([0,1,0]);
|
16
|
+
expect(camera.getRightVector()).toEqualVector([1,0,0]);
|
17
|
+
});
|
18
|
+
|
19
|
+
describe("yawing 90 deg", function() {
|
20
|
+
beforeEach(function() { camera.yaw(Math.deg2rad(90)); });
|
21
|
+
|
22
|
+
it("should be facing 'right'", function() {
|
23
|
+
expect(camera.getViewVector()).toEqualVector([-1,0,0]);
|
24
|
+
});
|
25
|
+
|
26
|
+
it("should have up vector 'up'", function() {
|
27
|
+
expect(camera.getUpVector()).toEqualVector([0,1,0]);
|
28
|
+
});
|
29
|
+
|
30
|
+
it("should have right vector 'forward'", function() {
|
31
|
+
expect(camera.getRightVector()).toEqualVector([0,0,-1]);
|
32
|
+
});
|
33
|
+
|
34
|
+
it("should produce expected quat", function() {
|
35
|
+
expect(camera.rotation).toEqualVector([0,0.707106,0,0.707106]);
|
36
|
+
});
|
37
|
+
|
38
|
+
it("should produce expected mat4", function() {
|
39
|
+
expect(camera.getTransformationMatrix()).toEqualVector([0,0,-1,0,0,1,0,0,1,0,0,0,0,0,-10,1]);
|
40
|
+
});
|
41
|
+
});
|
42
|
+
|
43
|
+
describe("pitching 90 deg", function() {
|
44
|
+
beforeEach(function() { camera.pitch(Math.deg2rad(90)); });
|
45
|
+
|
46
|
+
it("should be facing 'up'", function() {
|
47
|
+
expect(camera.getViewVector()).toEqualVector([0,1,0]);
|
48
|
+
});
|
49
|
+
|
50
|
+
it("should have up vector 'forward'", function() {
|
51
|
+
expect(camera.getUpVector()).toEqualVector([0,0,1]);
|
52
|
+
});
|
53
|
+
|
54
|
+
it("should have right vector 'right'", function() {
|
55
|
+
expect(camera.getRightVector()).toEqualVector([1,0,0]);
|
56
|
+
});
|
57
|
+
|
58
|
+
it("should produce expected quat", function() {
|
59
|
+
expect(camera.rotation).toEqualVector([0.707106,0,0,0.707106]);
|
60
|
+
});
|
61
|
+
|
62
|
+
it("should produce expected mat4", function() {
|
63
|
+
expect(camera.getTransformationMatrix()).toEqualVector([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,-10,1]);
|
64
|
+
});
|
65
|
+
});
|
66
|
+
|
67
|
+
describe("rolling 90 deg", function() {
|
68
|
+
beforeEach(function() { camera.roll(Math.deg2rad(90)); });
|
69
|
+
|
70
|
+
it("should be facing 'forward'", function() {
|
71
|
+
expect(camera.getViewVector()).toEqualVector([0,0,-1]);
|
72
|
+
});
|
73
|
+
|
74
|
+
it("should have up vector 'left'", function() {
|
75
|
+
expect(camera.getUpVector()).toEqualVector([1,0,0]);
|
76
|
+
});
|
77
|
+
|
78
|
+
it("should have right vector 'down'", function() {
|
79
|
+
expect(camera.getRightVector()).toEqualVector([0,-1,0]);
|
80
|
+
});
|
81
|
+
|
82
|
+
it("should produce expected quat", function() {
|
83
|
+
expect(camera.rotation).toEqualVector([0,0,-0.707106,0.707106]);
|
84
|
+
});
|
85
|
+
|
86
|
+
it("should produce expected mat4", function() {
|
87
|
+
expect(camera.getTransformationMatrix()).toEqualVector([0,-1,0,0,1,0,0,0,0,0,1,0,0,0,-10,1]);
|
88
|
+
});
|
89
|
+
});
|
90
|
+
});
|
@@ -0,0 +1,705 @@
|
|
1
|
+
/**
|
2
|
+
* vec3
|
3
|
+
* 3 Dimensional Vector
|
4
|
+
**/
|
5
|
+
;
|
6
|
+
|
7
|
+
/**
|
8
|
+
* vec3.create([vec]) -> vec3
|
9
|
+
* - vec (vec3): optional vec3 containing values to initialize with
|
10
|
+
*
|
11
|
+
* Creates a new instance of a vec3 using the default array type
|
12
|
+
* Any javascript array containing at least 3 numeric elements can serve as a vec3
|
13
|
+
*
|
14
|
+
* Returns:
|
15
|
+
* New vec3
|
16
|
+
**/
|
17
|
+
;
|
18
|
+
|
19
|
+
/**
|
20
|
+
* vec3.set(vec, dest) -> vec3
|
21
|
+
* - vec (vec3) : vec3 containing values to copy
|
22
|
+
* - dest (vec3) : vec3 receiving copied values
|
23
|
+
*
|
24
|
+
* Copies the values of one vec3 to another
|
25
|
+
*
|
26
|
+
* Returns:
|
27
|
+
* dest
|
28
|
+
**/
|
29
|
+
;
|
30
|
+
|
31
|
+
/**
|
32
|
+
* vec3.add(vec, vec2[, dest]) -> vec3
|
33
|
+
* - vec (vec3) : first operand
|
34
|
+
* - vec2 (vec3) : second operand
|
35
|
+
* - dest (vec3) : optional vec3 receiving operation result. If not specified, result is written to +vec+.
|
36
|
+
*
|
37
|
+
* Performs a vector addition
|
38
|
+
*
|
39
|
+
* Returns:
|
40
|
+
* dest if specified, vec otherwise
|
41
|
+
**/
|
42
|
+
;
|
43
|
+
|
44
|
+
/**
|
45
|
+
* vec3.subtract(vec, vec2[, dest]) -> vec3
|
46
|
+
* - vec (vec3) : first operand
|
47
|
+
* - vec2 (vec3) : second operand
|
48
|
+
* - dest (vec3) : optional vec3 receiving operation result. If not specified, result is written to +vec+.
|
49
|
+
*
|
50
|
+
* Performs a vector subtraction
|
51
|
+
*
|
52
|
+
* Returns:
|
53
|
+
* dest if specified, vec otherwise
|
54
|
+
**/
|
55
|
+
;
|
56
|
+
|
57
|
+
/**
|
58
|
+
* vec3.negate(vec[, dest]) -> vec3
|
59
|
+
* - vec (vec3) : vec3 to negate
|
60
|
+
* - dest (vec3) : optional vec3 receiving operation result. If not specified, result is written to +vec+.
|
61
|
+
*
|
62
|
+
* Negates the components of a vec3
|
63
|
+
*
|
64
|
+
* Returns:
|
65
|
+
* dest if specified, vec otherwise
|
66
|
+
**/
|
67
|
+
;
|
68
|
+
|
69
|
+
/**
|
70
|
+
* vec3.scale(vec, val[, dest]) -> vec3
|
71
|
+
* - vec (vec3) : vec3 to scale
|
72
|
+
* - val (Number) : numeric value to scale by
|
73
|
+
* - dest (vec3) : optional vec3 receiving operation result. If not specified, result is written to +vec+.
|
74
|
+
*
|
75
|
+
* Multiplies the components of a vec3 by a scalar value
|
76
|
+
*
|
77
|
+
* Returns:
|
78
|
+
* dest if specified, vec otherwise
|
79
|
+
**/
|
80
|
+
;
|
81
|
+
|
82
|
+
/**
|
83
|
+
* vec3.normalize(vec[, dest]) -> vec3
|
84
|
+
* - vec (vec3) : vec3 to normalize
|
85
|
+
* - dest (vec3) : optional vec3 receiving operation result. If not specified, result is written to +vec+.
|
86
|
+
*
|
87
|
+
* Generates a unit vector of the same direction as the provided vec3
|
88
|
+
* If vector length is 0, returns [0, 0, 0]
|
89
|
+
*
|
90
|
+
* Returns:
|
91
|
+
* dest if specified, vec otherwise
|
92
|
+
**/
|
93
|
+
;
|
94
|
+
|
95
|
+
/**
|
96
|
+
* vec3.cross(vec, vec2[, dest]) -> vec3
|
97
|
+
* - vec (vec3) : first operand
|
98
|
+
* - vec2 (vec3) : second operand
|
99
|
+
* - dest (vec3) : optional vec3 receiving operation result. If not specified, result is written to +vec+.
|
100
|
+
*
|
101
|
+
* Generates the cross product of two vec3s
|
102
|
+
*
|
103
|
+
* Returns:
|
104
|
+
* dest if specified, vec otherwise
|
105
|
+
**/
|
106
|
+
;
|
107
|
+
|
108
|
+
/**
|
109
|
+
* vec3.length(vec) -> Number
|
110
|
+
* - vec (vec3) : vec3 to calculate length of
|
111
|
+
*
|
112
|
+
* Caclulates the length of a vec3
|
113
|
+
*
|
114
|
+
* Returns:
|
115
|
+
* Length of vec
|
116
|
+
**/
|
117
|
+
;
|
118
|
+
|
119
|
+
/**
|
120
|
+
* vec3.dot(vec, vec2) -> Number
|
121
|
+
* - vec (vec3) : first operand
|
122
|
+
* - vec2 (vec3) : second operand
|
123
|
+
*
|
124
|
+
* Caclulates the dot product of two vec3s
|
125
|
+
*
|
126
|
+
* Returns:
|
127
|
+
* Dot product of vec and vec2
|
128
|
+
**/
|
129
|
+
;
|
130
|
+
|
131
|
+
/**
|
132
|
+
* vec3.direction(vec, vec2[, dest]) -> vec3
|
133
|
+
* - vec (vec3) : origin vec3
|
134
|
+
* - vec2 (vec3) : vec3 to point to
|
135
|
+
* - dest (vec3) : optional vec3 receiving operation result. If not specified, result is written to +vec+.
|
136
|
+
*
|
137
|
+
* Generates a unit vector pointing from one vector to another
|
138
|
+
*
|
139
|
+
* Returns:
|
140
|
+
* dest if specified, vec otherwise
|
141
|
+
**/
|
142
|
+
;
|
143
|
+
|
144
|
+
/**
|
145
|
+
* vec3.lerp(vec, vec2, lerp[, dest]) -> vec3
|
146
|
+
* - vec (vec3) : first vector
|
147
|
+
* - vec2 (vec3) : second vector
|
148
|
+
* - lerp (Number) : interpolation amount between the two inputs
|
149
|
+
* - dest (vec3) : optional vec3 receiving operation result. If not specified, result is written to +vec+.
|
150
|
+
*
|
151
|
+
* Performs a linear interpolation between two vec3
|
152
|
+
*
|
153
|
+
* Returns:
|
154
|
+
* dest if specified, vec otherwise
|
155
|
+
**/
|
156
|
+
;
|
157
|
+
|
158
|
+
/**
|
159
|
+
* vec3.str(vec) -> String
|
160
|
+
* - vec (vec3) : vec3 to represent as a string
|
161
|
+
*
|
162
|
+
* Returns a string representation of a vector
|
163
|
+
*
|
164
|
+
* Returns:
|
165
|
+
* string representation of vec
|
166
|
+
**/
|
167
|
+
;
|
168
|
+
|
169
|
+
/**
|
170
|
+
* mat3
|
171
|
+
* 3x3 Matrix
|
172
|
+
**/
|
173
|
+
;
|
174
|
+
|
175
|
+
/**
|
176
|
+
* mat3.create([mat]) -> mat3
|
177
|
+
* - mat (mat3) : optional mat3 containing values to initialize with
|
178
|
+
*
|
179
|
+
* Creates a new instance of a mat3 using the default array type
|
180
|
+
* Any javascript array containing at least 9 numeric elements can serve as a mat3
|
181
|
+
*
|
182
|
+
* Returns:
|
183
|
+
* New mat3
|
184
|
+
**/
|
185
|
+
;
|
186
|
+
|
187
|
+
/**
|
188
|
+
* mat3.set(mat, dest) -> mat3
|
189
|
+
* - mat (mat3) : mat3 containing values to copy
|
190
|
+
* - dest (mat3) : mat3 receiving copied values
|
191
|
+
*
|
192
|
+
* Copies the values of one mat3 to another
|
193
|
+
*
|
194
|
+
* Returns:
|
195
|
+
* dest
|
196
|
+
**/
|
197
|
+
;
|
198
|
+
|
199
|
+
/**
|
200
|
+
* mat3.identity(dest) -> mat3
|
201
|
+
* - dest (mat3) : mat3 to set
|
202
|
+
*
|
203
|
+
* Sets a mat3 to an identity matrix
|
204
|
+
*
|
205
|
+
* Returns:
|
206
|
+
* dest
|
207
|
+
**/
|
208
|
+
;
|
209
|
+
|
210
|
+
/**
|
211
|
+
* mat3.transpose(mat[, dest]) -> mat3
|
212
|
+
* - mat (mat3) : mat3 to transpose
|
213
|
+
* - dest (mat3) : optional mat3 receiving operation result. If not specified, result is written to +mat+.
|
214
|
+
*
|
215
|
+
* Transposes a mat3 (flips the values over the diagonal)
|
216
|
+
*
|
217
|
+
* Returns:
|
218
|
+
* dest if specified, mat otherwise
|
219
|
+
**/
|
220
|
+
;
|
221
|
+
|
222
|
+
/**
|
223
|
+
* mat3.toMat4(mat[, dest]) -> mat4
|
224
|
+
* - mat (mat3) : mat3 containing values to copy
|
225
|
+
* - dest (mat4) : optional mat4 receiving operation result. If not specified, result is written to a new mat4.
|
226
|
+
*
|
227
|
+
* Copies the elements of a mat3 into the upper 3x3 elements of a mat4
|
228
|
+
*
|
229
|
+
* Returns:
|
230
|
+
* dest if specified, a new mat4 otherwise
|
231
|
+
**/
|
232
|
+
;
|
233
|
+
|
234
|
+
/**
|
235
|
+
* mat3.str(mat) -> String
|
236
|
+
* - mat (mat3) : mat3 to represent as a string
|
237
|
+
*
|
238
|
+
* Returns a string representation of a mat3
|
239
|
+
*
|
240
|
+
* Returns:
|
241
|
+
* string representation of mat
|
242
|
+
**/
|
243
|
+
;
|
244
|
+
|
245
|
+
/**
|
246
|
+
* mat4
|
247
|
+
* 4x4 Matrix
|
248
|
+
**/
|
249
|
+
;
|
250
|
+
|
251
|
+
/**
|
252
|
+
* mat4.create([mat]) -> mat4
|
253
|
+
* - mat (mat4) : optional mat4 containing values to initialize with
|
254
|
+
*
|
255
|
+
* Creates a new instance of a mat4 using the default array type
|
256
|
+
* Any javascript array containing at least 16 numeric elements can serve as a mat4
|
257
|
+
*
|
258
|
+
* Returns:
|
259
|
+
* New mat4
|
260
|
+
**/
|
261
|
+
;
|
262
|
+
|
263
|
+
/**
|
264
|
+
* mat4.set(mat, dest) -> mat4
|
265
|
+
* - mat (mat4) : mat4 containing values to copy
|
266
|
+
* - dest (mat4) : mat4 receiving copied values
|
267
|
+
*
|
268
|
+
* Copies the values of one mat4 to another
|
269
|
+
*
|
270
|
+
* Returns:
|
271
|
+
* dest
|
272
|
+
**/
|
273
|
+
;
|
274
|
+
|
275
|
+
/**
|
276
|
+
* mat4.identity(dest) -> mat4
|
277
|
+
* - dest (mat4) : mat4 to set
|
278
|
+
*
|
279
|
+
* Sets a mat4 to an identity matrix
|
280
|
+
*
|
281
|
+
* Returns:
|
282
|
+
* dest
|
283
|
+
**/
|
284
|
+
;
|
285
|
+
|
286
|
+
/**
|
287
|
+
* mat4.transpose(mat[, dest]) -> mat4
|
288
|
+
* - mat (mat4) : mat4 to transpose
|
289
|
+
* - dest (mat4) : optional mat4 receiving operation result. If not specified, result is written to +mat+.
|
290
|
+
*
|
291
|
+
* Transposes a mat4 (flips the values over the diagonal)
|
292
|
+
*
|
293
|
+
* Returns:
|
294
|
+
* dest is specified, mat otherwise
|
295
|
+
**/
|
296
|
+
;
|
297
|
+
|
298
|
+
/**
|
299
|
+
* mat4.determinant(mat) -> mat4
|
300
|
+
* - mat (mat4) : mat4 to calculate determinant of
|
301
|
+
*
|
302
|
+
* Calculates the determinant of a mat4
|
303
|
+
*
|
304
|
+
* Returns:
|
305
|
+
* determinant of mat
|
306
|
+
**/
|
307
|
+
;
|
308
|
+
|
309
|
+
/**
|
310
|
+
* mat4.inverse(mat[, dest]) -> mat4
|
311
|
+
* - mat (mat4) : mat4 to calculate inverse of
|
312
|
+
* - dest (mat4) : optional mat4 receiving inverse matrix. If not specified, result is written to +mat+.
|
313
|
+
*
|
314
|
+
* Calculates the inverse matrix of a mat4
|
315
|
+
*
|
316
|
+
* Returns:
|
317
|
+
* dest is specified, mat otherwise
|
318
|
+
**/
|
319
|
+
;
|
320
|
+
|
321
|
+
/**
|
322
|
+
* mat4.toRotationMat(mat[, dest]) -> mat4
|
323
|
+
* - mat (mat4) : mat4 containing values to copy
|
324
|
+
* - dest (mat4) : optional mat4 receiving copied values. If not specified, result is written to +mat+.
|
325
|
+
*
|
326
|
+
* Copies the upper 3x3 elements of a mat4 into another mat4
|
327
|
+
*
|
328
|
+
* Returns:
|
329
|
+
* dest is specified, a new mat4 otherwise
|
330
|
+
**/
|
331
|
+
;
|
332
|
+
|
333
|
+
/**
|
334
|
+
* mat4.toMat3(mat[, dest]) -> mat3
|
335
|
+
* - mat (mat4) : mat4 containing values to copy
|
336
|
+
* - dest (mat3) : optional mat3 receiving copied values. If not specified, a new mat3 is created.
|
337
|
+
*
|
338
|
+
* Copies the upper 3x3 elements of a mat4 into a mat3
|
339
|
+
*
|
340
|
+
* Returns:
|
341
|
+
* dest is specified, a new mat3 otherwise
|
342
|
+
**/
|
343
|
+
;
|
344
|
+
|
345
|
+
/**
|
346
|
+
* mat4.toInverseMat3(mat[, dest]) -> mat3
|
347
|
+
* - mat (mat4) : mat4 containing values to invert and copy
|
348
|
+
* - dest (mat3) : optional mat3 receiving values
|
349
|
+
*
|
350
|
+
* Calculates the inverse of the upper 3x3 elements of a mat4 and copies the result into a mat3
|
351
|
+
* The resulting matrix is useful for calculating transformed normals
|
352
|
+
*
|
353
|
+
* Returns:
|
354
|
+
* dest is specified, a new mat3 otherwise
|
355
|
+
**/
|
356
|
+
;
|
357
|
+
|
358
|
+
/**
|
359
|
+
* mat4.multiply(mat, mat2[, dest]) -> mat4
|
360
|
+
* - mat (mat4) : first operand
|
361
|
+
* - mat2 (mat4) : second operand
|
362
|
+
* - dest (mat4) : optional mat4 receiving operation result. If not specified, result is written to +mat+.
|
363
|
+
*
|
364
|
+
* Performs a matrix multiplication
|
365
|
+
*
|
366
|
+
* Returns:
|
367
|
+
* dest if specified, mat otherwise
|
368
|
+
**/
|
369
|
+
;
|
370
|
+
|
371
|
+
/**
|
372
|
+
* mat4.multiplyVec3(mat, vec[, dest]) -> vec3
|
373
|
+
* - mat (mat4) : mat4 to transform the vector with
|
374
|
+
* - vec (vec3) : vec3 to transform
|
375
|
+
* - dest (vec3) : optional vec3 receiving operation result. If not specified, result is written to +vec+.
|
376
|
+
*
|
377
|
+
* Transforms a vec3 with the given matrix
|
378
|
+
* 4th vector component is implicitly '1'
|
379
|
+
*
|
380
|
+
* Returns:
|
381
|
+
* dest if specified, vec3 otherwise
|
382
|
+
**/
|
383
|
+
;
|
384
|
+
|
385
|
+
/**
|
386
|
+
* mat4.multiplyVec4(mat, vec[, dest]) -> vec4
|
387
|
+
* - mat (mat4) : mat4 to transform the vector with
|
388
|
+
* - vec (vec4) : vec4 to transform
|
389
|
+
* - dest (vec4) : optional vec4 receiving operation result. If not specified, result is written to +vec+.
|
390
|
+
*
|
391
|
+
* Transforms a vec4 with the given matrix
|
392
|
+
*
|
393
|
+
* Returns:
|
394
|
+
* dest if specified, vec otherwise
|
395
|
+
**/
|
396
|
+
;
|
397
|
+
|
398
|
+
/**
|
399
|
+
* mat4.translate(mat, vec[, dest]) -> mat4
|
400
|
+
* - mat (mat4) : mat4 to translate
|
401
|
+
* - vec (vec3) : vec3 specifying the translation
|
402
|
+
* - dest (mat4) : optional mat4 receiving operation result. If not specified, result is written to +mat+.
|
403
|
+
*
|
404
|
+
* Translates a matrix by the given vector
|
405
|
+
*
|
406
|
+
* Returns:
|
407
|
+
* dest if specified, mat otherwise
|
408
|
+
**/
|
409
|
+
;
|
410
|
+
|
411
|
+
/**
|
412
|
+
* mat4.scale(mat, vec[, dest]) -> mat4
|
413
|
+
* - mat (mat4) : mat4 to scale
|
414
|
+
* - vec (vec3) : vec3 specifying the scale for each axis
|
415
|
+
* - dest (mat4) : optional mat4 receiving operation result. If not specified, result is written to +mat+.
|
416
|
+
*
|
417
|
+
* Scales a matrix by the given vector
|
418
|
+
*
|
419
|
+
* Returns:
|
420
|
+
* dest if specified, mat otherwise
|
421
|
+
**/
|
422
|
+
;
|
423
|
+
|
424
|
+
/**
|
425
|
+
* mat4.rotate(mat, angle, axis[, dest]) -> mat4
|
426
|
+
* - mat (mat4) : mat4 to rotate
|
427
|
+
* - angle (Number) : angle (in radians) to rotate
|
428
|
+
* - axis (vec3) : vec3 representing the axis to rotate around
|
429
|
+
* - dest (mat4) : optional mat4 receiving operation result. If not specified, result is written to +mat+.
|
430
|
+
*
|
431
|
+
* Rotates a matrix by the given angle around the specified axis
|
432
|
+
* If rotating around a primary axis (X,Y,Z) one of the specialized rotation functions should be used instead for performance
|
433
|
+
*
|
434
|
+
* Returns:
|
435
|
+
* dest if specified, mat otherwise
|
436
|
+
**/
|
437
|
+
;
|
438
|
+
|
439
|
+
/**
|
440
|
+
* mat4.rotateX(mat, angle[, dest]) -> mat4
|
441
|
+
* - mat (mat4) : mat4 to rotate
|
442
|
+
* - angle (Number) : angle (in radians) to rotate
|
443
|
+
* - dest (mat4) : optional mat4 receiving operation result. If not specified, result is written to +mat+.
|
444
|
+
*
|
445
|
+
* Rotates a matrix by the given angle around the X axis
|
446
|
+
*
|
447
|
+
* Returns:
|
448
|
+
* dest if specified, mat otherwise
|
449
|
+
**/
|
450
|
+
;
|
451
|
+
|
452
|
+
/**
|
453
|
+
* mat4.rotateY(mat, angle[, dest]) -> mat4
|
454
|
+
* - mat (mat4) : mat4 to rotate
|
455
|
+
* - angle (Number) : angle (in radians) to rotate
|
456
|
+
* - dest (mat4) : optional mat4 receiving operation result. If not specified, result is written to +mat+.
|
457
|
+
*
|
458
|
+
* Rotates a matrix by the given angle around the Y axis
|
459
|
+
*
|
460
|
+
* Returns:
|
461
|
+
* dest if specified, mat otherwise
|
462
|
+
**/
|
463
|
+
;
|
464
|
+
|
465
|
+
/**
|
466
|
+
* mat4.rotateZ(mat, angle[, dest]) -> mat4
|
467
|
+
* - mat (mat4) : mat4 to rotate
|
468
|
+
* - angle (Number) : angle (in radians) to rotate
|
469
|
+
* - dest (mat4) : optional mat4 receiving operation result. If not specified, result is written to +mat+.
|
470
|
+
*
|
471
|
+
* Rotates a matrix by the given angle around the Z axis
|
472
|
+
*
|
473
|
+
* Returns:
|
474
|
+
* dest if specified, mat otherwise
|
475
|
+
**/
|
476
|
+
;
|
477
|
+
|
478
|
+
/**
|
479
|
+
* mat4.frustum(left, right, bottom, top, near, far[, dest]) -> mat4
|
480
|
+
* - left (Number) : scalar, left bounds of the frustum
|
481
|
+
* - right (Number) : scalar, right bounds of the frustum
|
482
|
+
* - bottom (Number) : scalar, bottom bounds of the frustum
|
483
|
+
* - top (Number) : scalar, top bounds of the frustum
|
484
|
+
* - near (Number) : scalar, near bounds of the frustum
|
485
|
+
* - far (Number) : scalar, far bounds of the frustum
|
486
|
+
* - dest (mat4) : optional mat4 frustum matrix will be written into. If not specified, a new mat4 is created.
|
487
|
+
*
|
488
|
+
* Generates a frustum matrix with the given bounds
|
489
|
+
*
|
490
|
+
* Returns:
|
491
|
+
* dest if specified, a new mat4 otherwise
|
492
|
+
**/
|
493
|
+
;
|
494
|
+
|
495
|
+
/**
|
496
|
+
* mat4.perspective(fovy, aspect, near, far[, dest]) -> mat4
|
497
|
+
* - fovy (Number) : scalar, vertical field of view
|
498
|
+
* - aspect (Number) : scalar, aspect ratio. Typically viewport width/height
|
499
|
+
* - near (Number) : scalar, near bounds of the frustum
|
500
|
+
* - far (Number) : scalar, far bounds of the frustum
|
501
|
+
* - dest (mat4) : optional mat4 the frustum matrix will be written into. If not specified, a new mat4 is created.
|
502
|
+
*
|
503
|
+
* Generates a perspective projection matrix with the given bounds
|
504
|
+
*
|
505
|
+
* Returns:
|
506
|
+
* dest if specified, a new mat4 otherwise
|
507
|
+
**/
|
508
|
+
;
|
509
|
+
|
510
|
+
/**
|
511
|
+
* mat4.ortho(left, right, bottom, top, near, far[, dest]) -> mat4
|
512
|
+
* - left (Number) : scalar, left bounds of the frustum
|
513
|
+
* - right (Number) : scalar, right bounds of the frustum
|
514
|
+
* - bottom (Number) : scalar, bottom bounds of the frustum
|
515
|
+
* - top (Number) : scalar, top bounds of the frustum
|
516
|
+
* - near (Number) : scalar, near bounds of the frustum
|
517
|
+
* - far (Number) : scalar, far bounds of the frustum
|
518
|
+
* - dest (mat4) : optional mat4 the frustum matrix will be written into. If not specified, a new mat4 is created.
|
519
|
+
*
|
520
|
+
* Generates a orthogonal projection matrix with the given bounds
|
521
|
+
*
|
522
|
+
* Returns:
|
523
|
+
* dest if specified, a new mat4 otherwise
|
524
|
+
**/
|
525
|
+
;
|
526
|
+
|
527
|
+
/**
|
528
|
+
* mat4.lookAt(eye, center, up[, dest]) -> mat4
|
529
|
+
* - eye (vec3) : position of the viewer
|
530
|
+
* - center (vec3) : the point the viewer is looking at
|
531
|
+
* - up (vec3) : vec3 pointing "up"
|
532
|
+
* - dest (mat4) : optional mat4 the frustum matrix will be written into. If not specified, a new mat4 is created.
|
533
|
+
*
|
534
|
+
* Generates a look-at matrix with the given eye position, focal point, and up axis
|
535
|
+
*
|
536
|
+
* Returns:
|
537
|
+
* dest if specified, a new mat4 otherwise
|
538
|
+
**/
|
539
|
+
;
|
540
|
+
|
541
|
+
/**
|
542
|
+
* mat4.str(mat) -> String
|
543
|
+
* - mat (mat4) : mat4 to represent as a string
|
544
|
+
*
|
545
|
+
* Returns a string representation of a mat4
|
546
|
+
*
|
547
|
+
* Returns:
|
548
|
+
* string representation of mat
|
549
|
+
**/
|
550
|
+
;
|
551
|
+
|
552
|
+
/**
|
553
|
+
* quat4
|
554
|
+
* Quaternions
|
555
|
+
**/
|
556
|
+
;
|
557
|
+
|
558
|
+
/**
|
559
|
+
* quat4.create([quat]) -> quat4
|
560
|
+
* - quat (quat4) : optional quat4 containing values to initialize with
|
561
|
+
*
|
562
|
+
* Creates a new instance of a quat4 using the default array type
|
563
|
+
* Any javascript array containing at least 4 numeric elements can serve as a quat4
|
564
|
+
*
|
565
|
+
* Returns:
|
566
|
+
* New quat4
|
567
|
+
**/
|
568
|
+
;
|
569
|
+
|
570
|
+
/**
|
571
|
+
* quat4.set(quat, dest) -> quat4
|
572
|
+
* - quat (quat4) : quat4 containing values to copy
|
573
|
+
* - dest (quat4) : quat4 receiving copied values
|
574
|
+
*
|
575
|
+
* Copies the values of one quat4 to another
|
576
|
+
*
|
577
|
+
* Returns:
|
578
|
+
* dest
|
579
|
+
**/
|
580
|
+
;
|
581
|
+
|
582
|
+
/**
|
583
|
+
* quat4.calculateW(quat[, dest]) -> quat4
|
584
|
+
* - quat (quat4) : quat4 to calculate W component of
|
585
|
+
* - dest (quat4) : optional quat4 receiving calculated values. If not specified, result is written to quat.
|
586
|
+
*
|
587
|
+
* Calculates the W component of a quat4 from the X, Y, and Z components.
|
588
|
+
* Assumes that quaternion is 1 unit in length.
|
589
|
+
* Any existing W component will be ignored.
|
590
|
+
*
|
591
|
+
* Returns:
|
592
|
+
* dest if specified, quat otherwise
|
593
|
+
**/
|
594
|
+
;
|
595
|
+
|
596
|
+
/**
|
597
|
+
* quat4.inverse(quat[, dest]) -> quat4
|
598
|
+
* - quat (quat4) : quat4 to calculate inverse of
|
599
|
+
* - dest (quat4) : optional quat4 receiving calculated values. If not specified, result is written to quat.
|
600
|
+
*
|
601
|
+
* Calculates the inverse of a quat4
|
602
|
+
*
|
603
|
+
* Returns:
|
604
|
+
* dest if specified, quat otherwise
|
605
|
+
**/
|
606
|
+
;
|
607
|
+
|
608
|
+
/**
|
609
|
+
* quat4.length(quat) -> quat4
|
610
|
+
* - quat (quat4) : quat4 to calculate length of
|
611
|
+
*
|
612
|
+
* Calculates the length of a quat4
|
613
|
+
*
|
614
|
+
* Returns:
|
615
|
+
* Length of quat
|
616
|
+
**/
|
617
|
+
;
|
618
|
+
|
619
|
+
/**
|
620
|
+
* quat4.normalize(quat[, dest]) -> quat4
|
621
|
+
* - quat (quat4) : quat4 to normalize
|
622
|
+
* - dest (quat4) : optional quat4 receiving calculated values. If not specified, result is written to quat.
|
623
|
+
*
|
624
|
+
* Generates a unit quaternion of the same direction as the provided quat4
|
625
|
+
* If quaternion length is 0, returns [0, 0, 0, 0]
|
626
|
+
*
|
627
|
+
* Returns:
|
628
|
+
* dest if specified, quat otherwise
|
629
|
+
**/
|
630
|
+
;
|
631
|
+
|
632
|
+
/**
|
633
|
+
* quat4.multiply(quat, quat2[, dest]) -> quat4
|
634
|
+
* - quat (quat4) : first operand
|
635
|
+
* - quat2 (quat4) : second operand
|
636
|
+
* - dest (quat4) : optional quat4 receiving calculated values. If not specified, result is written to quat.
|
637
|
+
*
|
638
|
+
* Performs a quaternion multiplication
|
639
|
+
*
|
640
|
+
* Returns:
|
641
|
+
* dest if specified, quat otherwise
|
642
|
+
**/
|
643
|
+
;
|
644
|
+
|
645
|
+
/**
|
646
|
+
* quat4.multiplyVec3(quat, vec[, dest]) -> vec3
|
647
|
+
* - quat (quat4) : quat4 to transform the vector with
|
648
|
+
* - vec (vec3) : vec3 to transform
|
649
|
+
* - dest (vec3) : optional vec3 receiving calculated values. If not specified, result is written to +vec+.
|
650
|
+
*
|
651
|
+
* Transforms a vec3 with the given quaternion
|
652
|
+
*
|
653
|
+
* Returns:
|
654
|
+
* dest if specified, vec otherwise
|
655
|
+
**/
|
656
|
+
;
|
657
|
+
|
658
|
+
/**
|
659
|
+
* quat4.toMat3(quat[, dest]) -> mat3
|
660
|
+
* - quat (quat4) : quat4 to create matrix from
|
661
|
+
* - dest (mat3) : optional mat3 receiving operation result. If not specified, a new mat3 is created.
|
662
|
+
*
|
663
|
+
* Calculates a 3x3 matrix from the given quat4
|
664
|
+
*
|
665
|
+
* Returns:
|
666
|
+
* dest if specified, a new mat3 otherwise
|
667
|
+
**/
|
668
|
+
;
|
669
|
+
|
670
|
+
/**
|
671
|
+
* quat4.toMat4(quat[, dest]) -> mat4
|
672
|
+
* - quat (quat4) : quat4 to create matrix from
|
673
|
+
* - dest (mat4) : optional mat4 receiving calculated values. If not specified, a new mat4 is created.
|
674
|
+
*
|
675
|
+
* Calculates a 4x4 matrix from the given quat4
|
676
|
+
*
|
677
|
+
* Returns:
|
678
|
+
* dest if specified, a new mat4 otherwise
|
679
|
+
**/
|
680
|
+
;
|
681
|
+
|
682
|
+
/**
|
683
|
+
* quat4.slerp(quat, quat2, lerp[, dest]) -> quat4
|
684
|
+
* - quat (quat4) : first quarternion
|
685
|
+
* - quat2 (quat4) : second quaternion
|
686
|
+
* - lerp (Number) : interpolation amount between the two inputs
|
687
|
+
* - dest (quat4) : optional quat4 receiving calculated values. If not specified, result is written to +quat+.
|
688
|
+
*
|
689
|
+
* Performs a spherical linear interpolation between two quat4
|
690
|
+
*
|
691
|
+
* Returns:
|
692
|
+
* dest if specified, quat otherwise
|
693
|
+
**/
|
694
|
+
;
|
695
|
+
|
696
|
+
/**
|
697
|
+
* quat4.str(quat) -> String
|
698
|
+
* - quat (quat4) : quat4 to represent as a string
|
699
|
+
*
|
700
|
+
* Returns a string representation of a quaternion
|
701
|
+
*
|
702
|
+
* Returns:
|
703
|
+
* string representation of quat
|
704
|
+
**/
|
705
|
+
;
|