@carbonenginejs/runtime-utils 0.1.0

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 (101) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +23 -0
  3. package/README.md +56 -0
  4. package/THIRD-PARTY-NOTICES.md +38 -0
  5. package/docs/README.md +81 -0
  6. package/docs/architecture.md +101 -0
  7. package/docs/concepts/foundation-consolidation.md +86 -0
  8. package/docs/const-kb.md +92 -0
  9. package/docs/core-types/DECORATOR-TODOS.md +25 -0
  10. package/docs/core-types/README.md +203 -0
  11. package/docs/reference/api.md +70 -0
  12. package/docs/reference/classes/README.md +115 -0
  13. package/package.json +132 -0
  14. package/src/arrays.js +5 -0
  15. package/src/audio/audioFormats.js +34 -0
  16. package/src/audio/index.js +1 -0
  17. package/src/box3.js +1385 -0
  18. package/src/bytes.js +56 -0
  19. package/src/compression.js +56 -0
  20. package/src/constants/index.js +6 -0
  21. package/src/constants.js +15 -0
  22. package/src/curve.js +419 -0
  23. package/src/d3d/dxgiFormats.js +46 -0
  24. package/src/d3d/index.js +2 -0
  25. package/src/d3d/primitiveTopology.js +11 -0
  26. package/src/document/CjsCarbonDocument.js +212 -0
  27. package/src/document/CjsClassRegistry.js +373 -0
  28. package/src/document/CjsDocumentDehydrator.js +142 -0
  29. package/src/document/CjsDocumentHydrator.js +156 -0
  30. package/src/document/CjsStructRegistry.js +348 -0
  31. package/src/document/hydrationAdapter.js +129 -0
  32. package/src/document/index.js +6 -0
  33. package/src/geometry/box.js +137 -0
  34. package/src/geometry/cylinder.js +244 -0
  35. package/src/geometry/helpers/LICENSE +15 -0
  36. package/src/geometry/helpers/earcut.js +766 -0
  37. package/src/geometry/helpers/misc.js +103 -0
  38. package/src/geometry/index.js +8 -0
  39. package/src/geometry/json.js +165 -0
  40. package/src/geometry/lathe.js +172 -0
  41. package/src/geometry/octahedron.js +0 -0
  42. package/src/geometry/plane.js +81 -0
  43. package/src/geometry/shape.js +95 -0
  44. package/src/geometry/sphere.js +123 -0
  45. package/src/geometry/torus.js +96 -0
  46. package/src/graphics/colorSpaces.js +22 -0
  47. package/src/graphics/index.js +4 -0
  48. package/src/graphics/pixelFormats.js +158 -0
  49. package/src/graphics/textureDimensions.js +22 -0
  50. package/src/graphics/trinityEnums.js +87 -0
  51. package/src/index.js +58 -0
  52. package/src/is.js +524 -0
  53. package/src/json.js +23 -0
  54. package/src/lifecycle/CjsLifecycleState.js +77 -0
  55. package/src/lifecycle/index.js +1 -0
  56. package/src/lne3.js +497 -0
  57. package/src/lookup.js +48 -0
  58. package/src/mat3.js +131 -0
  59. package/src/mat4.js +699 -0
  60. package/src/math/index.js +25 -0
  61. package/src/math/scalar.js +63 -0
  62. package/src/media/index.js +1 -0
  63. package/src/media/mediaTypes.js +50 -0
  64. package/src/mesh.js +394 -0
  65. package/src/model/CjsEventEmitter.js +333 -0
  66. package/src/model/CjsModel.js +1544 -0
  67. package/src/model/CjsModelState.js +72 -0
  68. package/src/model/index.js +4 -0
  69. package/src/model/sourceRecordUtils.js +54 -0
  70. package/src/noise.js +310 -0
  71. package/src/num.js +827 -0
  72. package/src/path.js +21 -0
  73. package/src/pln.js +762 -0
  74. package/src/pool.js +160 -0
  75. package/src/quat.js +144 -0
  76. package/src/ray3.js +1085 -0
  77. package/src/renderContext/formats.js +145 -0
  78. package/src/renderContext/index.js +5 -0
  79. package/src/renderContext/presentation.js +125 -0
  80. package/src/renderContext/resources.js +27 -0
  81. package/src/renderContext/upscaling.js +22 -0
  82. package/src/renderContext/window.js +20 -0
  83. package/src/runtime/CjsRuntimeState.js +50 -0
  84. package/src/schema/CjsSchema.js +1009 -0
  85. package/src/schema/index.js +17 -0
  86. package/src/shader/index.js +1 -0
  87. package/src/shader/shaderStages.js +37 -0
  88. package/src/sph3.js +754 -0
  89. package/src/tangent.js +288 -0
  90. package/src/text.js +40 -0
  91. package/src/tri3.js +650 -0
  92. package/src/types/carbonTypes.js +635 -0
  93. package/src/types/index.js +2 -0
  94. package/src/utils.js +58 -0
  95. package/src/validation.js +46 -0
  96. package/src/vec2.js +229 -0
  97. package/src/vec3.js +1172 -0
  98. package/src/vec4.js +347 -0
  99. package/src/vertex.js +108 -0
  100. package/src/webgpu/index.js +1 -0
  101. package/src/webgpu/textureFormats.js +121 -0
package/src/lne3.js ADDED
@@ -0,0 +1,497 @@
1
+ import { vec3 } from "./vec3.js";
2
+ import { box3 } from "./box3.js";
3
+ import { pool } from "./pool.js";
4
+
5
+ /**
6
+ * 3D Line
7
+ * @typedef {Float32Array} lne3
8
+ */
9
+ export const lne3 = {};
10
+
11
+ /**
12
+ * Allocates a pooled lne3
13
+ * @returns {Float32Array|lne3}
14
+ */
15
+ lne3.alloc = function()
16
+ {
17
+ return pool.allocF32(6);
18
+ };
19
+
20
+ /**
21
+ * Unallocates a pooled lne3
22
+ * @param {Float32Array|lne3} a
23
+ */
24
+ lne3.unalloc = function(a)
25
+ {
26
+ pool.freeType(a);
27
+ };
28
+
29
+ /**
30
+ * Line3 End methods
31
+ *
32
+ * @param {lne3} a
33
+ * @returns {TypedArray}
34
+ */
35
+ lne3.$end = function (a)
36
+ {
37
+ return a.subarray(3, 6);
38
+ };
39
+
40
+ /**
41
+ * Line3 start helper methods
42
+ *
43
+ * @param {lne3} a
44
+ * @returns {TypedArray}
45
+ */
46
+ lne3.$start = function (a)
47
+ {
48
+ return a.subarray(0, 3);
49
+ };
50
+
51
+ /**
52
+ * Clones a lne3
53
+ *
54
+ * @param {lne3} a
55
+ * @returns {lne3}
56
+ */
57
+ lne3.clone = function (a)
58
+ {
59
+ let out = new Float32Array(6);
60
+ out[0] = a[0];
61
+ out[1] = a[1];
62
+ out[2] = a[2];
63
+ out[3] = a[3];
64
+ out[4] = a[4];
65
+ out[5] = a[5];
66
+ return out;
67
+ };
68
+
69
+ /**
70
+ * Returns a point parameter based on the closest point as projected on the line segment.
71
+ * If clamp to line is true, then the returned value will be between 0 and 1
72
+ *
73
+ * @author three.js authors (converted)
74
+ * @param {vec3} a - source lne3
75
+ * @param {vec3} point - point to compare
76
+ * @param {boolean} clampToLine - optional setting to clamp the result to the lne3
77
+ * @returns {number} - closest point parameter
78
+ */
79
+ lne3.closestPointToPointParameter = function(a, point, clampToLine)
80
+ {
81
+ const
82
+ startP = vec3.alloc(),
83
+ startEnd = vec3.alloc();
84
+
85
+ startP[0] = point[0] - a[0];
86
+ startP[1] = point[1] - a[1];
87
+ startP[2] = point[2] - a[2];
88
+
89
+ startEnd[0] = a[3] - a[0];
90
+ startEnd[1] = a[4] - a[1];
91
+ startEnd[2] = a[5] - a[2];
92
+
93
+ let startEnd2 = startEnd[0] * startEnd[0] + startEnd[1] * startEnd[1] + startEnd[2] * startEnd[2],
94
+ startEnd_startP = startEnd[0] * startP[0] + startEnd[1] * startP[1] + startEnd[2] * startP[2],
95
+ t = startEnd2 === 0 ? 0 : startEnd_startP / startEnd2;
96
+
97
+ vec3.unalloc(startP);
98
+ vec3.unalloc(startEnd);
99
+
100
+ if (clampToLine) t = Math.max(0, Math.min(1, t));
101
+ return t;
102
+
103
+ };
104
+
105
+ /**
106
+ * Copies the values from one lne3 into another
107
+ *
108
+ * @param {lne3} out
109
+ * @param {lne3} a
110
+ * @returns {lne3} out
111
+ */
112
+ lne3.copy = function (out, a)
113
+ {
114
+ out[0] = a[0];
115
+ out[1] = a[1];
116
+ out[2] = a[2];
117
+ out[3] = a[3];
118
+ out[4] = a[4];
119
+ out[5] = a[5];
120
+ return out;
121
+ };
122
+
123
+ /**
124
+ * Copies the start component from one lne3 into another
125
+ *
126
+ * @param {lne3} out
127
+ * @param {lne3} a
128
+ * @returns {lne3} out
129
+ */
130
+ lne3.copyStart = function (out, a)
131
+ {
132
+ out[0] = a[0];
133
+ out[1] = a[1];
134
+ out[2] = a[2];
135
+ return out;
136
+ };
137
+
138
+ /**
139
+ * Copies the end component from one lne3 into another
140
+ *
141
+ * @param {lne3} out
142
+ * @param {lne3} a
143
+ * @returns {lne3} out
144
+ */
145
+ lne3.copyEnd =function (out, a)
146
+ {
147
+ out[3] = a[3];
148
+ out[4] = a[4];
149
+ out[5] = a[5];
150
+ return out;
151
+ };
152
+
153
+ /**
154
+ * Creates a lne3
155
+ *
156
+ * @returns {lne3}
157
+ */
158
+ lne3.create = function ()
159
+ {
160
+ return new Float32Array(6);
161
+ };
162
+
163
+ /**
164
+ * Checks two lne3's for equality
165
+ *
166
+ * @param {lne3} a
167
+ * @param {lne3} b
168
+ * @returns {boolean}
169
+ */
170
+ lne3.equals = box3.equals;
171
+
172
+ /**
173
+ * Checks a lne3 against it's components for equality
174
+ *
175
+ * @param {lne3} a
176
+ * @param {vec3} min
177
+ * @param {vec3} max
178
+ * @returns {boolean}
179
+ */
180
+ lne3.equalsStartEnd = box3.equalsBounds;
181
+
182
+ /**
183
+ * Checks for box3 exact equality
184
+ *
185
+ * @param {lne3} a
186
+ * @param {lne3} b
187
+ * @returns {boolean}
188
+ */
189
+ lne3.exactEquals = box3.exactEquals;
190
+
191
+ /**
192
+ * Checks for exact equality between a lne3 and components
193
+ *
194
+ * @param {lne3} a
195
+ * @param {vec3} min
196
+ * @param {vec3} max
197
+ * @returns {boolean}
198
+ */
199
+ lne3.exactEqualsStartEnd = box3.exactEqualsBounds;
200
+
201
+ /**
202
+ * Sets a lne3 from an array at an optional offset
203
+ *
204
+ * @param {lne3} out
205
+ * @param {Array} arr
206
+ * @param {number} [index=0]
207
+ * @returns {lne3}
208
+ */
209
+ lne3.fromArray = box3.fromArray;
210
+
211
+ /**
212
+ * Sets a line from start and end components
213
+ *
214
+ * @param {lne3} out
215
+ * @param {vec3} start
216
+ * @param {vec3} end
217
+ * @returns {lne3} out
218
+ */
219
+ lne3.fromStartEnd = box3.fromBounds;
220
+
221
+ /**
222
+ * Returns a vector at a certain position along a lne3
223
+ *
224
+ * @author three.js authors (converted)
225
+ * @param {vec3} out - receiving vec3
226
+ * @param {lne3} a - source lne3
227
+ * @param {number} t - Float representing the start (0) and end (1) of the line
228
+ * @returns {vec3} [out] - receiving vec3
229
+ */
230
+ lne3.get = function(out, a, t)
231
+ {
232
+ if (t < 0 || t > 1)
233
+ {
234
+ out[0] = 0;
235
+ out[1] = 0;
236
+ out[2] = 0;
237
+ throw new Error("Normalization error");
238
+ }
239
+ else
240
+ {
241
+ out[0] = (a[3] - a[0]) * t + a[0];
242
+ out[1] = (a[4] - a[1]) * t + a[1];
243
+ out[2] = (a[5] - a[2]) * t + a[2];
244
+ }
245
+ return out;
246
+ };
247
+
248
+ /**
249
+ * Sets a vec3 from the lne3's center
250
+ *
251
+ * @param {vec3} out - receiving vec3
252
+ * @param {lne3} a - source lne3
253
+ * @returns {vec3} out - receiving vec3
254
+ */
255
+ lne3.getCenter = function(out, a)
256
+ {
257
+ out[0] = (a[0] + a[3]) * 0.5;
258
+ out[1] = (a[1] + a[4]) * 0.5;
259
+ out[2] = (a[2] + a[5]) * 0.5;
260
+ return out;
261
+ };
262
+
263
+ /**
264
+ * Returns the closets point on a lne3 to a given point.
265
+ * - If clamp to line is true, then the returned value will be clamped to the line segment.
266
+ *
267
+ * @author three.js authors (converted)
268
+ * @param {vec3} out - receiving vec3
269
+ * @param {lne3} a - source lne3
270
+ * @param {vec3} point - point to compare
271
+ * @param {boolean} clampToLine - optional setting to clamp the result to a line segment
272
+ * @returns {vec3} out - receiving vec3
273
+ */
274
+ lne3.getClosestPointToPoint = function(out, a, point, clampToLine)
275
+ {
276
+ const t = lne3.closestPointToPointParameter(a, point, clampToLine);
277
+ out[0] = (a[3] - a[0]) * t + a[0];
278
+ out[1] = (a[4] - a[1]) * t + a[1];
279
+ out[2] = (a[5] - a[2]) * t + a[2];
280
+ return out;
281
+ };
282
+
283
+ /**
284
+ * Gets the end component of a lne3
285
+ *
286
+ * @param {vec3} out
287
+ * @param {lne3} a
288
+ * @returns {vec3} out
289
+ */
290
+ lne3.getEnd = box3.getMax;
291
+
292
+ /**
293
+ * Gets a lne3's delta
294
+ *
295
+ * @param {vec3} out - receiving vec3
296
+ * @param {lne3} a - source lne3
297
+ * @returns {vec3} out - receiving vec3
298
+ */
299
+ lne3.getDelta = function(out, a)
300
+ {
301
+ out[0] = a[3] - a[0];
302
+ out[1] = a[4] - a[1];
303
+ out[2] = a[5] - a[2];
304
+ return out;
305
+ };
306
+
307
+ /**
308
+ * Gets the start component of a lne3
309
+ *
310
+ * @param {vec3} out
311
+ * @param {lne3} a
312
+ * @returns {vec3} out
313
+ */
314
+ lne3.getStart = box3.getMin;
315
+
316
+ /**
317
+ * Checks for intersection with a plane's components
318
+ *
319
+ * @param {lne3} a - receiving lne3
320
+ * @param {vec3} n - plane normal
321
+ * @param {number} c - plane constant
322
+ * @returns {boolean}
323
+ */
324
+ lne3.intersectsNormalConstant = function(a, n, c)
325
+ {
326
+ const
327
+ startSign = (n[0] * a[0] + n[1] * a[1] + n[2] * a[2]) + c,
328
+ endSign = (n[0] * a[3] + n[1] * a[4] + n[2] * a[5]) + c;
329
+
330
+ return startSign === 0 || endSign === 0 ||
331
+ (startSign < 0 && endSign > 0) || (endSign < 0 && startSign > 0);
332
+ };
333
+
334
+ /**
335
+ * Gets the length of the line
336
+ *
337
+ * @param {lne3} a - source lne3
338
+ * @returns {number} - distance
339
+ */
340
+ lne3.length = function(a)
341
+ {
342
+ let x = a[0] - a[3],
343
+ y = a[1] - a[4],
344
+ z = a[2] - a[5];
345
+
346
+ return Math.sqrt(x * x + y * y + z * z);
347
+ };
348
+
349
+ /**
350
+ * Sets a lne3 from values
351
+ *
352
+ * @param out - Receiving lne3
353
+ * @param sX
354
+ * @param sY
355
+ * @param sZ
356
+ * @param eX
357
+ * @param eY
358
+ * @param eZ
359
+ * @returns {lne3}
360
+ */
361
+ lne3.set = box3.set;
362
+
363
+ /**
364
+ * Gets the squared length of the lne3
365
+ *
366
+ * @param {lne3} a - source line
367
+ * @returns {number} - squared distance
368
+ */
369
+ lne3.squaredLength = function(a)
370
+ {
371
+ let x = a[0] - a[3],
372
+ y = a[1] - a[4],
373
+ z = a[2] - a[5];
374
+
375
+ return x * x + y * y + z * z;
376
+ };
377
+
378
+ /**
379
+ * Sets an array from the lne3
380
+ *
381
+ * @param {lne3} a
382
+ * @param {Array} arr
383
+ * @param {number} [index]
384
+ * @returns {lne3} a
385
+ */
386
+ lne3.toArray = box3.toArray;
387
+
388
+ /**
389
+ * Sets a start and end vector from a lne3
390
+ *
391
+ * @param {lne3} a
392
+ * @param {vec3} start
393
+ * @param {vec3} end
394
+ * @returns {lne3} a
395
+ */
396
+ lne3.toStartEnd = box3.toBounds;
397
+
398
+ /**
399
+ * Sets the line start from a vector
400
+ * @param {lne3} out
401
+ * @param {vec3} v
402
+ */
403
+ lne3.setStart = box3.setMinBounds;
404
+
405
+ /**
406
+ * Sets the line end from a vector
407
+ * @param {lne3} out
408
+ * @param {vec3} v
409
+ */
410
+ lne3.setEnd = box3.setMaxBounds;
411
+
412
+ /**
413
+ * Transforms a lne3 by a mat4
414
+ *
415
+ * @param {lne3} out
416
+ * @param {lne3} a
417
+ * @param {mat4} m
418
+ * @returns {lne3} out
419
+ */
420
+ lne3.transformMat4 = function(out, a, m)
421
+ {
422
+ let ax = a[0],
423
+ ay = a[1],
424
+ az = a[2],
425
+ bx = a[3],
426
+ by = a[4],
427
+ bz = a[5],
428
+ aw = m[3] * ax + m[7] * ay + m[11] * az + m[15],
429
+ bw = m[3] * bx + m[7] * by + m[11] * bz + m[15];
430
+
431
+ aw = aw || 1;
432
+ bw = bw || 1;
433
+
434
+ out[0] = (m[0] * ax + m[4] * ay + m[8] * az + m[12]) / aw;
435
+ out[1] = (m[1] * ax + m[5] * ay + m[9] * az + m[13]) / aw;
436
+ out[2] = (m[2] * ax + m[6] * ay + m[10] * az + m[14]) / aw;
437
+
438
+ out[3] = (m[0] * bx + m[4] * by + m[8] * bz + m[12]) / bw;
439
+ out[4] = (m[1] * bx + m[5] * by + m[9] * bz + m[13]) / bw;
440
+ out[5] = (m[2] * bx + m[6] * by + m[10] * bz + m[14]) / bw;
441
+
442
+ return out;
443
+ };
444
+
445
+ /**
446
+ * Translates a lne3
447
+ *
448
+ * @param {lne3} out
449
+ * @param {lne3} a
450
+ * @param {vec3} v
451
+ * @returns {lne3} out
452
+ */
453
+ lne3.translate = function(out, a, v)
454
+ {
455
+ out[0] = a[0] + v[0];
456
+ out[1] = a[1] + v[1];
457
+ out[2] = a[2] + v[2];
458
+ out[3] = a[3] + v[0];
459
+ out[4] = a[4] + v[1];
460
+ out[5] = a[5] + v[2];
461
+ return out;
462
+ };
463
+
464
+ export const {
465
+ alloc,
466
+ unalloc,
467
+ $end,
468
+ $start,
469
+ clone,
470
+ closestPointToPointParameter,
471
+ copy,
472
+ copyStart,
473
+ copyEnd,
474
+ create,
475
+ equals,
476
+ equalsStartEnd,
477
+ exactEquals,
478
+ exactEqualsStartEnd,
479
+ fromArray,
480
+ fromStartEnd,
481
+ get,
482
+ getCenter,
483
+ getClosestPointToPoint,
484
+ getEnd,
485
+ getDelta,
486
+ getStart,
487
+ intersectsNormalConstant,
488
+ length,
489
+ set,
490
+ squaredLength,
491
+ toArray,
492
+ toStartEnd,
493
+ setStart,
494
+ setEnd,
495
+ transformMat4,
496
+ translate
497
+ } = lne3;
package/src/lookup.js ADDED
@@ -0,0 +1,48 @@
1
+ /** Compares string representations by stable Unicode code-unit order. */
2
+ export function compareCodeUnits(left, right)
3
+ {
4
+ const a = String(left);
5
+ const b = String(right);
6
+
7
+ return a < b ? -1 : a > b ? 1 : 0;
8
+ }
9
+
10
+ /** Returns a new string array in stable Unicode code-unit order. */
11
+ export function sortStrings(values)
12
+ {
13
+ return Array.from(values, String).sort(compareCodeUnits);
14
+ }
15
+
16
+ /** Builds a Map and rejects duplicate keys instead of silently overwriting. */
17
+ export function indexBy(values, keySelector, options = {})
18
+ {
19
+ if (typeof keySelector !== "function")
20
+ {
21
+ throw new TypeError("indexBy keySelector must be a function.");
22
+ }
23
+
24
+ const result = new Map();
25
+ const label = options.label ?? "value";
26
+ let index = 0;
27
+
28
+ for (const value of values)
29
+ {
30
+ const key = keySelector(value, index++);
31
+
32
+ if (result.has(key))
33
+ {
34
+ throw new Error(`Duplicate ${label} key ${formatKey(key)}.`);
35
+ }
36
+
37
+ result.set(key, value);
38
+ }
39
+
40
+ return result;
41
+ }
42
+
43
+ function formatKey(value)
44
+ {
45
+ const json = JSON.stringify(value);
46
+
47
+ return json === undefined ? String(value) : json;
48
+ }
package/src/mat3.js ADDED
@@ -0,0 +1,131 @@
1
+ import * as glMat3 from "gl-matrix/esm/mat3.js";
2
+ import { pool } from "./pool.js";
3
+
4
+ const mat3 = { ...glMat3 };
5
+
6
+ export { mat3 };
7
+
8
+ /**
9
+ * Allocates a pooled mat3
10
+ * @returns {Float32Array|mat3}
11
+ */
12
+ mat3.alloc = function()
13
+ {
14
+ return pool.allocF32(9);
15
+ };
16
+
17
+ /**
18
+ * Unallocates a pooled mat3
19
+ * @param {mat3|Float32Array} a
20
+ */
21
+ mat3.unalloc = function(a)
22
+ {
23
+ pool.freeType(a);
24
+ };
25
+
26
+ /**
27
+ * Sets a mat3 from an array at an option offset
28
+ *
29
+ * @param {mat3} out
30
+ * @param {Array} arr
31
+ * @param {number} [offset=0]
32
+ * @returns {mat3} out
33
+ */
34
+ mat3.fromArray = function(out, arr, offset = 0)
35
+ {
36
+ out[0] = arr[offset];
37
+ out[1] = arr[offset + 1];
38
+ out[2] = arr[offset + 2];
39
+ out[3] = arr[offset + 3];
40
+ out[4] = arr[offset + 4];
41
+ out[5] = arr[offset + 5];
42
+ out[6] = arr[offset + 6];
43
+ out[7] = arr[offset + 7];
44
+ out[8] = arr[offset + 8];
45
+ return out;
46
+ };
47
+
48
+ /**
49
+ * Sets a mat3 from an array at an option offset
50
+ *
51
+ * @param {mat3} out
52
+ * @param {Array} arr
53
+ * @param {number} [index=0]
54
+ * @returns {mat3} out
55
+ */
56
+ mat3.setArray = function(out, arr, index = 0)
57
+ {
58
+ out[0] = arr[index];
59
+ out[1] = arr[index + 1];
60
+ out[2] = arr[index + 2];
61
+ out[3] = arr[index + 3];
62
+ out[4] = arr[index + 4];
63
+ out[5] = arr[index + 5];
64
+ out[6] = arr[index + 6];
65
+ out[7] = arr[index + 7];
66
+ out[8] = arr[index + 8];
67
+ return out;
68
+ };
69
+
70
+ /**
71
+ * Sets an array at an optional offset
72
+ *
73
+ * @param {mat3} a
74
+ * @param {Array} arr
75
+ * @param {number} [index=0]
76
+ * @returns {mat3} a
77
+ */
78
+ mat3.toArray = function(a, arr, index = 0)
79
+ {
80
+ arr[index] = a[0];
81
+ arr[index + 1] = a[1];
82
+ arr[index + 2] = a[2];
83
+ arr[index + 3] = a[3];
84
+ arr[index + 4] = a[4];
85
+ arr[index + 5] = a[5];
86
+ arr[index + 6] = a[6];
87
+ arr[index + 7] = a[7];
88
+ arr[index + 8] = a[8];
89
+ return a;
90
+ };
91
+
92
+ export const {
93
+ add,
94
+ adjoint,
95
+ clone,
96
+ copy,
97
+ create,
98
+ determinant,
99
+ equals,
100
+ exactEquals,
101
+ frob,
102
+ fromMat2d,
103
+ fromMat4,
104
+ fromQuat,
105
+ fromRotation,
106
+ fromScaling,
107
+ fromTranslation,
108
+ fromValues,
109
+ identity,
110
+ invert,
111
+ mul,
112
+ multiply,
113
+ multiplyScalar,
114
+ multiplyScalarAndAdd,
115
+ normalFromMat4,
116
+ projection,
117
+ rotate,
118
+ scale,
119
+ set,
120
+ str,
121
+ sub,
122
+ subtract,
123
+ translate,
124
+ transpose,
125
+ alloc,
126
+ unalloc,
127
+ fromArray,
128
+ setArray,
129
+ toArray
130
+ } = mat3;
131
+