lecodes-cli 0.1.5 → 0.1.7

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 (81) hide show
  1. package/dist/index.js +300 -149
  2. package/package.json +5 -3
  3. package/runtime/sdk/animate/animate.ts +238 -0
  4. package/runtime/sdk/animate/bezier.ts +138 -0
  5. package/runtime/sdk/animate/easings.ts +126 -0
  6. package/runtime/sdk/core/color.ts +66 -0
  7. package/runtime/sdk/core/events.ts +38 -0
  8. package/runtime/sdk/core/registry.ts +23 -0
  9. package/runtime/sdk/g2/Camera2D.ts +73 -0
  10. package/runtime/sdk/g2/Node2D.ts +104 -0
  11. package/runtime/sdk/g2/Scene2D.ts +73 -0
  12. package/runtime/sdk/g2/Sprite.ts +164 -0
  13. package/runtime/sdk/g2/Texture2D.ts +37 -0
  14. package/runtime/sdk/g2/Tilemap.ts +41 -0
  15. package/runtime/sdk/g2/loop.ts +22 -0
  16. package/runtime/sdk/gl/Body.ts +101 -0
  17. package/runtime/sdk/gl/Camera.ts +40 -0
  18. package/runtime/sdk/gl/Geometry.ts +218 -0
  19. package/runtime/sdk/gl/Light.ts +37 -0
  20. package/runtime/sdk/gl/Material.ts +124 -0
  21. package/runtime/sdk/gl/Mesh.ts +123 -0
  22. package/runtime/sdk/gl/Node.ts +307 -0
  23. package/runtime/sdk/gl/Noise.ts +30 -0
  24. package/runtime/sdk/gl/Particles.ts +185 -0
  25. package/runtime/sdk/gl/Plane.ts +53 -0
  26. package/runtime/sdk/gl/Ray.ts +16 -0
  27. package/runtime/sdk/gl/Scene.ts +179 -0
  28. package/runtime/sdk/gl/Texture.ts +35 -0
  29. package/runtime/sdk/gl/controls.ts +95 -0
  30. package/runtime/sdk/gl/state.ts +6 -0
  31. package/runtime/sdk/gl/touch.ts +56 -0
  32. package/runtime/sdk/inject.ts +72 -0
  33. package/runtime/sdk/math/Mathf.ts +118 -0
  34. package/runtime/sdk/math/mat4.ts +278 -0
  35. package/runtime/sdk/math/quat.ts +232 -0
  36. package/runtime/sdk/math/vec.ts +255 -0
  37. package/runtime/sdk/plugins/qr.ts +36 -0
  38. package/runtime/sdk/runtime/device.ts +33 -0
  39. package/runtime/sdk/runtime/fetch.ts +71 -0
  40. package/runtime/sdk/runtime/files.ts +23 -0
  41. package/runtime/sdk/runtime/input.ts +12 -0
  42. package/runtime/sdk/runtime/media.ts +111 -0
  43. package/runtime/sdk/runtime/misc.ts +12 -0
  44. package/runtime/sdk/runtime/net.ts +36 -0
  45. package/runtime/sdk/runtime/storage.ts +13 -0
  46. package/runtime/sdk/runtime/touch.ts +44 -0
  47. package/runtime/sdk/ui/UI.ts +19 -0
  48. package/runtime/sdk/ui/UIButton.ts +84 -0
  49. package/runtime/sdk/ui/UIContainer.ts +100 -0
  50. package/runtime/sdk/ui/UIImage.ts +68 -0
  51. package/runtime/sdk/ui/UIInput.ts +78 -0
  52. package/runtime/sdk/ui/UINode.ts +342 -0
  53. package/runtime/sdk/ui/UIScreen.ts +122 -0
  54. package/runtime/sdk/ui/UIScrollable.ts +70 -0
  55. package/runtime/sdk/ui/UISpacer.ts +14 -0
  56. package/runtime/sdk/ui/UIText.ts +40 -0
  57. package/runtime/sdk/ui/UIVideo.ts +38 -0
  58. package/runtime/sdk/ui/UIVirtualizedList.ts +222 -0
  59. package/runtime/sdk/ui/UIWidget.ts +97 -0
  60. package/runtime/sdk/ui/fonts.ts +10 -0
  61. package/runtime/sdk/ui/router.ts +73 -0
  62. package/runtime/gl-matrix/common.js +0 -54
  63. package/runtime/gl-matrix/header.js +0 -12
  64. package/runtime/gl-matrix/index.js +0 -11
  65. package/runtime/gl-matrix/mat2.js +0 -425
  66. package/runtime/gl-matrix/mat2d.js +0 -476
  67. package/runtime/gl-matrix/mat3.js +0 -765
  68. package/runtime/gl-matrix/mat4.js +0 -1947
  69. package/runtime/gl-matrix/quat.js +0 -737
  70. package/runtime/gl-matrix/quat2.js +0 -822
  71. package/runtime/gl-matrix/vec2.js +0 -620
  72. package/runtime/gl-matrix/vec3.js +0 -791
  73. package/runtime/gl-matrix/vec4.js +0 -652
  74. package/runtime/worker/animate.js +0 -304
  75. package/runtime/worker/chunk-4ZN32GYS.js +0 -34
  76. package/runtime/worker/chunk-G5ZA3LKB.js +0 -52
  77. package/runtime/worker/chunk-MI3UXE5H.js +0 -1395
  78. package/runtime/worker/creator.js +0 -930
  79. package/runtime/worker/globals.js +0 -208
  80. package/runtime/worker/ui.js +0 -763
  81. package/runtime/worker/utils.js +0 -16
@@ -1,652 +0,0 @@
1
- import * as glMatrix from "./common.js";
2
-
3
- /**
4
- * 4 Dimensional Vector
5
- * @module vec4
6
- */
7
-
8
- /**
9
- * Creates a new, empty vec4
10
- *
11
- * @returns {vec4} a new 4D vector
12
- */
13
- export function create() {
14
- var out = new Float32Array(4);
15
- return out;
16
- }
17
-
18
- /**
19
- * Creates a new vec4 initialized with values from an existing vector
20
- *
21
- * @param {ReadonlyVec4} a vector to clone
22
- * @returns {vec4} a new 4D vector
23
- */
24
- export function clone(a) {
25
- var out = new Float32Array(4);
26
- out[0] = a[0];
27
- out[1] = a[1];
28
- out[2] = a[2];
29
- out[3] = a[3];
30
- return out;
31
- }
32
-
33
- /**
34
- * Creates a new vec4 initialized with the given values
35
- *
36
- * @param {Number} x X component
37
- * @param {Number} y Y component
38
- * @param {Number} z Z component
39
- * @param {Number} w W component
40
- * @returns {vec4} a new 4D vector
41
- */
42
- export function fromValues(x, y, z, w) {
43
- var out = new Float32Array(4);
44
- out[0] = x;
45
- out[1] = y;
46
- out[2] = z;
47
- out[3] = w;
48
- return out;
49
- }
50
-
51
- /**
52
- * Copy the values from one vec4 to another
53
- *
54
- * @param {vec4} out the receiving vector
55
- * @param {ReadonlyVec4} a the source vector
56
- * @returns {vec4} out
57
- */
58
- export function copy(out, a) {
59
- out[0] = a[0];
60
- out[1] = a[1];
61
- out[2] = a[2];
62
- out[3] = a[3];
63
- return out;
64
- }
65
-
66
- /**
67
- * Set the components of a vec4 to the given values
68
- *
69
- * @param {vec4} out the receiving vector
70
- * @param {Number} x X component
71
- * @param {Number} y Y component
72
- * @param {Number} z Z component
73
- * @param {Number} w W component
74
- * @returns {vec4} out
75
- */
76
- export function set(out, x, y, z, w) {
77
- out[0] = x;
78
- out[1] = y;
79
- out[2] = z;
80
- out[3] = w;
81
- return out;
82
- }
83
-
84
- /**
85
- * Adds two vec4's
86
- *
87
- * @param {vec4} out the receiving vector
88
- * @param {ReadonlyVec4} a the first operand
89
- * @param {ReadonlyVec4} b the second operand
90
- * @returns {vec4} out
91
- */
92
- export function add(out, a, b) {
93
- out[0] = a[0] + b[0];
94
- out[1] = a[1] + b[1];
95
- out[2] = a[2] + b[2];
96
- out[3] = a[3] + b[3];
97
- return out;
98
- }
99
-
100
- /**
101
- * Subtracts vector b from vector a
102
- *
103
- * @param {vec4} out the receiving vector
104
- * @param {ReadonlyVec4} a the first operand
105
- * @param {ReadonlyVec4} b the second operand
106
- * @returns {vec4} out
107
- */
108
- export function subtract(out, a, b) {
109
- out[0] = a[0] - b[0];
110
- out[1] = a[1] - b[1];
111
- out[2] = a[2] - b[2];
112
- out[3] = a[3] - b[3];
113
- return out;
114
- }
115
-
116
- /**
117
- * Multiplies two vec4's
118
- *
119
- * @param {vec4} out the receiving vector
120
- * @param {ReadonlyVec4} a the first operand
121
- * @param {ReadonlyVec4} b the second operand
122
- * @returns {vec4} out
123
- */
124
- export function multiply(out, a, b) {
125
- out[0] = a[0] * b[0];
126
- out[1] = a[1] * b[1];
127
- out[2] = a[2] * b[2];
128
- out[3] = a[3] * b[3];
129
- return out;
130
- }
131
-
132
- /**
133
- * Divides two vec4's
134
- *
135
- * @param {vec4} out the receiving vector
136
- * @param {ReadonlyVec4} a the first operand
137
- * @param {ReadonlyVec4} b the second operand
138
- * @returns {vec4} out
139
- */
140
- export function divide(out, a, b) {
141
- out[0] = a[0] / b[0];
142
- out[1] = a[1] / b[1];
143
- out[2] = a[2] / b[2];
144
- out[3] = a[3] / b[3];
145
- return out;
146
- }
147
-
148
- /**
149
- * Math.ceil the components of a vec4
150
- *
151
- * @param {vec4} out the receiving vector
152
- * @param {ReadonlyVec4} a vector to ceil
153
- * @returns {vec4} out
154
- */
155
- export function ceil(out, a) {
156
- out[0] = Math.ceil(a[0]);
157
- out[1] = Math.ceil(a[1]);
158
- out[2] = Math.ceil(a[2]);
159
- out[3] = Math.ceil(a[3]);
160
- return out;
161
- }
162
-
163
- /**
164
- * Math.floor the components of a vec4
165
- *
166
- * @param {vec4} out the receiving vector
167
- * @param {ReadonlyVec4} a vector to floor
168
- * @returns {vec4} out
169
- */
170
- export function floor(out, a) {
171
- out[0] = Math.floor(a[0]);
172
- out[1] = Math.floor(a[1]);
173
- out[2] = Math.floor(a[2]);
174
- out[3] = Math.floor(a[3]);
175
- return out;
176
- }
177
-
178
- /**
179
- * Returns the minimum of two vec4's
180
- *
181
- * @param {vec4} out the receiving vector
182
- * @param {ReadonlyVec4} a the first operand
183
- * @param {ReadonlyVec4} b the second operand
184
- * @returns {vec4} out
185
- */
186
- export function min(out, a, b) {
187
- out[0] = Math.min(a[0], b[0]);
188
- out[1] = Math.min(a[1], b[1]);
189
- out[2] = Math.min(a[2], b[2]);
190
- out[3] = Math.min(a[3], b[3]);
191
- return out;
192
- }
193
-
194
- /**
195
- * Returns the maximum of two vec4's
196
- *
197
- * @param {vec4} out the receiving vector
198
- * @param {ReadonlyVec4} a the first operand
199
- * @param {ReadonlyVec4} b the second operand
200
- * @returns {vec4} out
201
- */
202
- export function max(out, a, b) {
203
- out[0] = Math.max(a[0], b[0]);
204
- out[1] = Math.max(a[1], b[1]);
205
- out[2] = Math.max(a[2], b[2]);
206
- out[3] = Math.max(a[3], b[3]);
207
- return out;
208
- }
209
-
210
- /**
211
- * symmetric round the components of a vec4
212
- *
213
- * @param {vec4} out the receiving vector
214
- * @param {ReadonlyVec4} a vector to round
215
- * @returns {vec4} out
216
- */
217
- export function round(out, a) {
218
- out[0] = glMatrix.round(a[0]);
219
- out[1] = glMatrix.round(a[1]);
220
- out[2] = glMatrix.round(a[2]);
221
- out[3] = glMatrix.round(a[3]);
222
- return out;
223
- }
224
-
225
- /**
226
- * Scales a vec4 by a scalar number
227
- *
228
- * @param {vec4} out the receiving vector
229
- * @param {ReadonlyVec4} a the vector to scale
230
- * @param {Number} b amount to scale the vector by
231
- * @returns {vec4} out
232
- */
233
- export function scale(out, a, b) {
234
- out[0] = a[0] * b;
235
- out[1] = a[1] * b;
236
- out[2] = a[2] * b;
237
- out[3] = a[3] * b;
238
- return out;
239
- }
240
-
241
- /**
242
- * Adds two vec4's after scaling the second operand by a scalar value
243
- *
244
- * @param {vec4} out the receiving vector
245
- * @param {ReadonlyVec4} a the first operand
246
- * @param {ReadonlyVec4} b the second operand
247
- * @param {Number} scale the amount to scale b by before adding
248
- * @returns {vec4} out
249
- */
250
- export function scaleAndAdd(out, a, b, scale) {
251
- out[0] = a[0] + b[0] * scale;
252
- out[1] = a[1] + b[1] * scale;
253
- out[2] = a[2] + b[2] * scale;
254
- out[3] = a[3] + b[3] * scale;
255
- return out;
256
- }
257
-
258
- /**
259
- * Calculates the euclidian distance between two vec4's
260
- *
261
- * @param {ReadonlyVec4} a the first operand
262
- * @param {ReadonlyVec4} b the second operand
263
- * @returns {Number} distance between a and b
264
- */
265
- export function distance(a, b) {
266
- var x = b[0] - a[0];
267
- var y = b[1] - a[1];
268
- var z = b[2] - a[2];
269
- var w = b[3] - a[3];
270
- return Math.sqrt(x * x + y * y + z * z + w * w);
271
- }
272
-
273
- /**
274
- * Calculates the squared euclidian distance between two vec4's
275
- *
276
- * @param {ReadonlyVec4} a the first operand
277
- * @param {ReadonlyVec4} b the second operand
278
- * @returns {Number} squared distance between a and b
279
- */
280
- export function squaredDistance(a, b) {
281
- var x = b[0] - a[0];
282
- var y = b[1] - a[1];
283
- var z = b[2] - a[2];
284
- var w = b[3] - a[3];
285
- return x * x + y * y + z * z + w * w;
286
- }
287
-
288
- /**
289
- * Calculates the length of a vec4
290
- *
291
- * @param {ReadonlyVec4} a vector to calculate length of
292
- * @returns {Number} length of a
293
- */
294
- export function length(a) {
295
- var x = a[0];
296
- var y = a[1];
297
- var z = a[2];
298
- var w = a[3];
299
- return Math.sqrt(x * x + y * y + z * z + w * w);
300
- }
301
-
302
- /**
303
- * Calculates the squared length of a vec4
304
- *
305
- * @param {ReadonlyVec4} a vector to calculate squared length of
306
- * @returns {Number} squared length of a
307
- */
308
- export function squaredLength(a) {
309
- var x = a[0];
310
- var y = a[1];
311
- var z = a[2];
312
- var w = a[3];
313
- return x * x + y * y + z * z + w * w;
314
- }
315
-
316
- /**
317
- * Negates the components of a vec4
318
- *
319
- * @param {vec4} out the receiving vector
320
- * @param {ReadonlyVec4} a vector to negate
321
- * @returns {vec4} out
322
- */
323
- export function negate(out, a) {
324
- out[0] = -a[0];
325
- out[1] = -a[1];
326
- out[2] = -a[2];
327
- out[3] = -a[3];
328
- return out;
329
- }
330
-
331
- /**
332
- * Returns the inverse of the components of a vec4
333
- *
334
- * @param {vec4} out the receiving vector
335
- * @param {ReadonlyVec4} a vector to invert
336
- * @returns {vec4} out
337
- */
338
- export function inverse(out, a) {
339
- out[0] = 1.0 / a[0];
340
- out[1] = 1.0 / a[1];
341
- out[2] = 1.0 / a[2];
342
- out[3] = 1.0 / a[3];
343
- return out;
344
- }
345
-
346
- /**
347
- * Normalize a vec4
348
- *
349
- * @param {vec4} out the receiving vector
350
- * @param {ReadonlyVec4} a vector to normalize
351
- * @returns {vec4} out
352
- */
353
- export function normalize(out, a) {
354
- var x = a[0];
355
- var y = a[1];
356
- var z = a[2];
357
- var w = a[3];
358
- var len = x * x + y * y + z * z + w * w;
359
- if (len > 0) {
360
- len = 1 / Math.sqrt(len);
361
- }
362
- out[0] = x * len;
363
- out[1] = y * len;
364
- out[2] = z * len;
365
- out[3] = w * len;
366
- return out;
367
- }
368
-
369
- /**
370
- * Calculates the dot product of two vec4's
371
- *
372
- * @param {ReadonlyVec4} a the first operand
373
- * @param {ReadonlyVec4} b the second operand
374
- * @returns {Number} dot product of a and b
375
- */
376
- export function dot(a, b) {
377
- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
378
- }
379
-
380
- /**
381
- * Returns the cross-product of three vectors in a 4-dimensional space
382
- *
383
- * @param {ReadonlyVec4} out the receiving vector
384
- * @param {ReadonlyVec4} u the first vector
385
- * @param {ReadonlyVec4} v the second vector
386
- * @param {ReadonlyVec4} w the third vector
387
- * @returns {vec4} result
388
- */
389
- export function cross(out, u, v, w) {
390
- var A = v[0] * w[1] - v[1] * w[0],
391
- B = v[0] * w[2] - v[2] * w[0],
392
- C = v[0] * w[3] - v[3] * w[0],
393
- D = v[1] * w[2] - v[2] * w[1],
394
- E = v[1] * w[3] - v[3] * w[1],
395
- F = v[2] * w[3] - v[3] * w[2];
396
- var G = u[0];
397
- var H = u[1];
398
- var I = u[2];
399
- var J = u[3];
400
- out[0] = H * F - I * E + J * D;
401
- out[1] = -(G * F) + I * C - J * B;
402
- out[2] = G * E - H * C + J * A;
403
- out[3] = -(G * D) + H * B - I * A;
404
- return out;
405
- }
406
-
407
- /**
408
- * Performs a linear interpolation between two vec4's
409
- *
410
- * @param {vec4} out the receiving vector
411
- * @param {ReadonlyVec4} a the first operand
412
- * @param {ReadonlyVec4} b the second operand
413
- * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
414
- * @returns {vec4} out
415
- */
416
- export function lerp(out, a, b, t) {
417
- var ax = a[0];
418
- var ay = a[1];
419
- var az = a[2];
420
- var aw = a[3];
421
- out[0] = ax + t * (b[0] - ax);
422
- out[1] = ay + t * (b[1] - ay);
423
- out[2] = az + t * (b[2] - az);
424
- out[3] = aw + t * (b[3] - aw);
425
- return out;
426
- }
427
-
428
- /**
429
- * Generates a random vector with the given scale
430
- *
431
- * @param {vec4} out the receiving vector
432
- * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned
433
- * @returns {vec4} out
434
- */
435
- export function random(out, scale) {
436
- scale = scale === undefined ? 1.0 : scale;
437
-
438
- // Marsaglia, George. Choosing a Point from the Surface of a
439
- // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646.
440
- // http://projecteuclid.org/euclid.aoms/1177692644;
441
- var v1, v2, v3, v4;
442
- var s1, s2;
443
- var rand;
444
- rand = glMatrix.RANDOM();
445
- v1 = rand * 2 - 1;
446
- v2 = (4 * glMatrix.RANDOM() - 2) * Math.sqrt(rand * -rand + rand);
447
- s1 = v1 * v1 + v2 * v2;
448
- rand = glMatrix.RANDOM();
449
- v3 = rand * 2 - 1;
450
- v4 = (4 * glMatrix.RANDOM() - 2) * Math.sqrt(rand * -rand + rand);
451
- s2 = v3 * v3 + v4 * v4;
452
- var d = Math.sqrt((1 - s1) / s2);
453
- out[0] = scale * v1;
454
- out[1] = scale * v2;
455
- out[2] = scale * v3 * d;
456
- out[3] = scale * v4 * d;
457
- return out;
458
- }
459
-
460
- /**
461
- * Transforms the vec4 with a mat4.
462
- *
463
- * @param {vec4} out the receiving vector
464
- * @param {ReadonlyVec4} a the vector to transform
465
- * @param {ReadonlyMat4} m matrix to transform with
466
- * @returns {vec4} out
467
- */
468
- export function transformMat4(out, a, m) {
469
- var x = a[0],
470
- y = a[1],
471
- z = a[2],
472
- w = a[3];
473
- out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
474
- out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
475
- out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
476
- out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
477
- return out;
478
- }
479
-
480
- /**
481
- * Transforms the vec4 with a quat
482
- *
483
- * @param {vec4} out the receiving vector
484
- * @param {ReadonlyVec4} a the vector to transform
485
- * @param {ReadonlyQuat} q normalized quaternion to transform with
486
- * @returns {vec4} out
487
- */
488
- export function transformQuat(out, a, q) {
489
- // Fast Vector Rotation using Quaternions by Robert Eisele
490
- // https://raw.org/proof/vector-rotation-using-quaternions/
491
-
492
- var qx = q[0],
493
- qy = q[1],
494
- qz = q[2],
495
- qw = q[3];
496
- var vx = a[0],
497
- vy = a[1],
498
- vz = a[2];
499
-
500
- // t = q x v
501
- var tx = qy * vz - qz * vy;
502
- var ty = qz * vx - qx * vz;
503
- var tz = qx * vy - qy * vx;
504
-
505
- // t = 2t
506
- tx = tx + tx;
507
- ty = ty + ty;
508
- tz = tz + tz;
509
-
510
- // v + w t + q x t
511
- out[0] = vx + qw * tx + qy * tz - qz * ty;
512
- out[1] = vy + qw * ty + qz * tx - qx * tz;
513
- out[2] = vz + qw * tz + qx * ty - qy * tx;
514
- out[3] = a[3];
515
- return out;
516
- }
517
-
518
- /**
519
- * Set the components of a vec4 to zero
520
- *
521
- * @param {vec4} out the receiving vector
522
- * @returns {vec4} out
523
- */
524
- export function zero(out) {
525
- out[0] = 0.0;
526
- out[1] = 0.0;
527
- out[2] = 0.0;
528
- out[3] = 0.0;
529
- return out;
530
- }
531
-
532
- /**
533
- * Returns a string representation of a vector
534
- *
535
- * @param {ReadonlyVec4} a vector to represent as a string
536
- * @returns {String} string representation of the vector
537
- */
538
- export function str(a) {
539
- return "vec4(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")";
540
- }
541
-
542
- /**
543
- * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
544
- *
545
- * @param {ReadonlyVec4} a The first vector.
546
- * @param {ReadonlyVec4} b The second vector.
547
- * @returns {Boolean} True if the vectors are equal, false otherwise.
548
- */
549
- export function exactEquals(a, b) {
550
- return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
551
- }
552
-
553
- /**
554
- * Returns whether or not the vectors have approximately the same elements in the same position.
555
- *
556
- * @param {ReadonlyVec4} a The first vector.
557
- * @param {ReadonlyVec4} b The second vector.
558
- * @returns {Boolean} True if the vectors are equal, false otherwise.
559
- */
560
- export function equals(a, b) {
561
- var a0 = a[0],
562
- a1 = a[1],
563
- a2 = a[2],
564
- a3 = a[3];
565
- var b0 = b[0],
566
- b1 = b[1],
567
- b2 = b[2],
568
- b3 = b[3];
569
- return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3));
570
- }
571
-
572
- /**
573
- * Alias for {@link vec4.subtract}
574
- * @function
575
- */
576
- export var sub = subtract;
577
-
578
- /**
579
- * Alias for {@link vec4.multiply}
580
- * @function
581
- */
582
- export var mul = multiply;
583
-
584
- /**
585
- * Alias for {@link vec4.divide}
586
- * @function
587
- */
588
- export var div = divide;
589
-
590
- /**
591
- * Alias for {@link vec4.distance}
592
- * @function
593
- */
594
- export var dist = distance;
595
-
596
- /**
597
- * Alias for {@link vec4.squaredDistance}
598
- * @function
599
- */
600
- export var sqrDist = squaredDistance;
601
-
602
- /**
603
- * Alias for {@link vec4.length}
604
- * @function
605
- */
606
- export var len = length;
607
-
608
- /**
609
- * Alias for {@link vec4.squaredLength}
610
- * @function
611
- */
612
- export var sqrLen = squaredLength;
613
-
614
- /**
615
- * Perform some operation over an array of vec4s.
616
- *
617
- * @param {Array} a the array of vectors to iterate over
618
- * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed
619
- * @param {Number} offset Number of elements to skip at the beginning of the array
620
- * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array
621
- * @param {Function} fn Function to call for each vector in the array
622
- * @param {Object} [arg] additional argument to pass to fn
623
- * @returns {Array} a
624
- * @function
625
- */
626
- export function forEach (a, stride, offset, count, fn, arg) {
627
- var vec = new Float32Array(4)
628
- var i, l;
629
- if (!stride) {
630
- stride = 4;
631
- }
632
- if (!offset) {
633
- offset = 0;
634
- }
635
- if (count) {
636
- l = Math.min(count * stride + offset, a.length);
637
- } else {
638
- l = a.length;
639
- }
640
- for (i = offset; i < l; i += stride) {
641
- vec[0] = a[i];
642
- vec[1] = a[i + 1];
643
- vec[2] = a[i + 2];
644
- vec[3] = a[i + 3];
645
- fn(vec, vec, arg);
646
- a[i] = vec[0];
647
- a[i + 1] = vec[1];
648
- a[i + 2] = vec[2];
649
- a[i + 3] = vec[3];
650
- }
651
- return a;
652
- };