@carbonenginejs/runtime-utils 0.1.1 → 0.1.3

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 (104) hide show
  1. package/LICENSE +21 -21
  2. package/NOTICE +23 -23
  3. package/README.md +69 -69
  4. package/THIRD-PARTY-NOTICES.md +64 -64
  5. package/docs/README.md +74 -73
  6. package/docs/architecture.md +101 -101
  7. package/docs/concepts/foundation-consolidation.md +85 -85
  8. package/docs/concepts/model-lifecycle.md +111 -0
  9. package/docs/const-kb.md +85 -87
  10. package/docs/core-types/DECORATOR-TODOS.md +25 -25
  11. package/docs/core-types/README.md +229 -168
  12. package/docs/reference/api.md +105 -102
  13. package/docs/reference/classes/README.md +135 -135
  14. package/package.json +139 -139
  15. package/src/arrays.js +5 -5
  16. package/src/audio/audioFormats.js +34 -34
  17. package/src/audio/index.js +1 -1
  18. package/src/box3.js +331 -331
  19. package/src/bytes.js +56 -56
  20. package/src/compression.js +56 -56
  21. package/src/constants/index.js +7 -7
  22. package/src/constants/trinity.js +13 -13
  23. package/src/constants.js +15 -15
  24. package/src/curve.js +79 -79
  25. package/src/d3d/dxgiFormats.js +46 -46
  26. package/src/d3d/index.js +2 -2
  27. package/src/d3d/primitiveTopology.js +11 -11
  28. package/src/document/CjsCarbonDocument.js +212 -212
  29. package/src/document/CjsClassRegistry.js +373 -373
  30. package/src/document/CjsDocumentDehydrator.js +142 -142
  31. package/src/document/CjsDocumentHydrator.js +156 -156
  32. package/src/document/CjsStructRegistry.js +348 -348
  33. package/src/document/hydrationAdapter.js +129 -129
  34. package/src/document/index.js +6 -6
  35. package/src/errors/CjsError.js +286 -286
  36. package/src/errors/index.js +5 -5
  37. package/src/geometry/box.js +22 -22
  38. package/src/geometry/cylinder.js +22 -22
  39. package/src/geometry/helpers/earcut.js +1 -1
  40. package/src/geometry/helpers/misc.js +3 -3
  41. package/src/geometry/index.js +8 -8
  42. package/src/geometry/json.js +67 -67
  43. package/src/geometry/lathe.js +44 -44
  44. package/src/geometry/plane.js +14 -14
  45. package/src/geometry/shape.js +4 -4
  46. package/src/geometry/sphere.js +24 -24
  47. package/src/geometry/torus.js +14 -14
  48. package/src/graphics/colorSpaces.js +22 -22
  49. package/src/graphics/index.js +4 -4
  50. package/src/graphics/pixelFormats.js +158 -158
  51. package/src/graphics/textureDimensions.js +22 -22
  52. package/src/graphics/trinityEnums.js +87 -87
  53. package/src/index.js +62 -62
  54. package/src/is.js +108 -46
  55. package/src/json.js +23 -23
  56. package/src/lifecycle/CjsLifecycleState.js +77 -77
  57. package/src/lifecycle/index.js +1 -1
  58. package/src/lne3.js +70 -70
  59. package/src/lookup.js +48 -48
  60. package/src/mat3.js +51 -51
  61. package/src/mat4.js +699 -699
  62. package/src/math/index.js +25 -25
  63. package/src/math/scalar.js +63 -63
  64. package/src/media/index.js +1 -1
  65. package/src/media/mediaTypes.js +50 -50
  66. package/src/mesh.js +424 -424
  67. package/src/model/CjsEventEmitter.js +333 -333
  68. package/src/model/CjsModel.js +1589 -1544
  69. package/src/model/CjsModelState.js +72 -72
  70. package/src/model/index.js +4 -4
  71. package/src/model/sourceRecordUtils.js +54 -54
  72. package/src/noise.js +310 -310
  73. package/src/num.js +827 -827
  74. package/src/object.js +39 -39
  75. package/src/path.js +53 -53
  76. package/src/pln.js +125 -125
  77. package/src/pool.js +9 -9
  78. package/src/quat.js +144 -144
  79. package/src/ray3.js +188 -188
  80. package/src/renderContext/formats.js +145 -145
  81. package/src/renderContext/index.js +5 -5
  82. package/src/renderContext/presentation.js +125 -125
  83. package/src/renderContext/resources.js +27 -27
  84. package/src/renderContext/upscaling.js +22 -22
  85. package/src/renderContext/window.js +20 -20
  86. package/src/runtime/CjsRuntimeState.js +50 -50
  87. package/src/schema/CjsSchema.js +555 -318
  88. package/src/schema/index.js +4 -4
  89. package/src/shader/index.js +1 -1
  90. package/src/shader/shaderStages.js +37 -37
  91. package/src/sph3.js +181 -181
  92. package/src/tangent.js +288 -288
  93. package/src/text.js +40 -40
  94. package/src/tri3.js +98 -98
  95. package/src/types/carbonTypes.js +635 -635
  96. package/src/types/index.js +2 -2
  97. package/src/utils.js +58 -58
  98. package/src/validation.js +46 -46
  99. package/src/vec2.js +229 -229
  100. package/src/vec3.js +1188 -1172
  101. package/src/vec4.js +347 -347
  102. package/src/vertex.js +108 -108
  103. package/src/webgpu/index.js +1 -1
  104. package/src/webgpu/textureFormats.js +121 -121
package/src/is.js CHANGED
@@ -1,5 +1,5 @@
1
-
2
- import { equals } from "./num.js";
1
+
2
+ import { equals } from "./num.js";
3
3
 
4
4
 
5
5
  const toString = Object.prototype.toString;
@@ -34,15 +34,15 @@ export function isSet(o)
34
34
  return !!(o && o instanceof Set);
35
35
  }
36
36
 
37
- /**
38
- * Checks if an object is iterable
39
- * @param {*} a
40
- * @returns {boolean}
41
- */
42
- export function isIterable(a)
43
- {
44
- return a !== null && a !== undefined && typeof a[Symbol.iterator] === "function";
45
- }
37
+ /**
38
+ * Checks if an object is iterable
39
+ * @param {*} a
40
+ * @returns {boolean}
41
+ */
42
+ export function isIterable(a)
43
+ {
44
+ return a !== null && a !== undefined && typeof a[Symbol.iterator] === "function";
45
+ }
46
46
 
47
47
  /**
48
48
  * Checks if a value is an array
@@ -53,14 +53,14 @@ export const isArray = Array.isArray;
53
53
 
54
54
  /**
55
55
  * Checks if a value is an array or a typed array
56
- * @param {*} a
57
- * @param {number} [minLength=0]
58
- * @returns {Boolean}
59
- */
60
- export function isArrayLike(a, minLength = 0)
61
- {
62
- return !!(a && (isArray(a) || isTyped(a)) && a.length >= minLength);
63
- }
56
+ * @param {*} a
57
+ * @param {number} [minLength=0]
58
+ * @returns {Boolean}
59
+ */
60
+ export function isArrayLike(a, minLength = 0)
61
+ {
62
+ return !!(a && (isArray(a) || isTyped(a)) && a.length >= minLength);
63
+ }
64
64
 
65
65
  /**
66
66
  * Checks if a function is async
@@ -88,9 +88,9 @@ export function isBoolean(a)
88
88
  * @param {*} a
89
89
  * @returns {Boolean}
90
90
  */
91
- export function isCanvas(a)
92
- {
93
- return typeof HTMLCanvasElement !== "undefined" && a instanceof HTMLCanvasElement;
91
+ export function isCanvas(a)
92
+ {
93
+ return typeof HTMLCanvasElement !== "undefined" && a instanceof HTMLCanvasElement;
94
94
  }
95
95
 
96
96
  /**
@@ -123,9 +123,9 @@ export function isDescriptor(a)
123
123
  * Checks if a value is a valid sof DNA string
124
124
  * @param {*} a
125
125
  */
126
- export function isDNA(a)
127
- {
128
- return isString(a) && /^[\w-]+:[\w-]+:[\w-]+$/.test(a);
126
+ export function isDNA(a)
127
+ {
128
+ return isString(a) && /^[\w-]+:[\w-]+:[\w-]+$/.test(a);
129
129
  }
130
130
 
131
131
  /**
@@ -133,9 +133,9 @@ export function isDNA(a)
133
133
  * @param {*} a
134
134
  * @returns {Boolean}
135
135
  */
136
- export function isError(a)
137
- {
138
- return !!(a && (a instanceof Error || a.constructor?.__category === "Error"));
136
+ export function isError(a)
137
+ {
138
+ return !!(a && (a instanceof Error || a.constructor?.__category === "Error"));
139
139
  }
140
140
 
141
141
  /**
@@ -148,6 +148,68 @@ export function isNumber(a)
148
148
  return isTag(a, "[object Number]");
149
149
  }
150
150
 
151
+ /**
152
+ * Checks if a value fits a signed 8-bit integer.
153
+ * @param {*} value
154
+ * @returns {Boolean}
155
+ */
156
+ export function isInt8(value)
157
+ {
158
+ return Number.isInteger(value) && value >= -0x80 && value <= 0x7f;
159
+ }
160
+
161
+ /**
162
+ * Checks if a value fits an unsigned 8-bit integer.
163
+ * @param {*} value
164
+ * @returns {Boolean}
165
+ */
166
+ export function isUint8(value)
167
+ {
168
+ return Number.isInteger(value) && value >= 0 && value <= 0xff;
169
+ }
170
+
171
+ /**
172
+ * Checks if a value fits a signed 16-bit integer.
173
+ * @param {*} value
174
+ * @returns {Boolean}
175
+ */
176
+ export function isInt16(value)
177
+ {
178
+ return Number.isInteger(value) && value >= -0x8000 && value <= 0x7fff;
179
+ }
180
+
181
+ /**
182
+ * Checks if a value fits an unsigned 16-bit integer.
183
+ * @param {*} value
184
+ * @returns {Boolean}
185
+ */
186
+ export function isUint16(value)
187
+ {
188
+ return Number.isInteger(value) && value >= 0 && value <= 0xffff;
189
+ }
190
+
191
+ /**
192
+ * Checks if a value fits a signed 32-bit integer.
193
+ * @param {*} value
194
+ * @returns {Boolean}
195
+ */
196
+ export function isInt32(value)
197
+ {
198
+ return Number.isInteger(value)
199
+ && value >= -0x80000000
200
+ && value <= 0x7fffffff;
201
+ }
202
+
203
+ /**
204
+ * Checks if a value fits an unsigned 32-bit integer.
205
+ * @param {*} value
206
+ * @returns {Boolean}
207
+ */
208
+ export function isUint32(value)
209
+ {
210
+ return Number.isInteger(value) && value >= 0 && value <= 0xffffffff;
211
+ }
212
+
151
213
  /**
152
214
  * Checks if a value is a function
153
215
  * @param {*} a
@@ -452,7 +514,7 @@ export function isPrimaryEqual(a, b)
452
514
  {
453
515
  if (a === b) return true;
454
516
 
455
- return isNumber(a) && isNumber(b) ? equals(a, b) : false;
517
+ return isNumber(a) && isNumber(b) ? equals(a, b) : false;
456
518
  }
457
519
 
458
520
  /**
@@ -490,12 +552,12 @@ export function isDateEqual(a, b)
490
552
  * @param {String|Boolean|Number|Array|TypedArray} b
491
553
  * @returns {boolean}
492
554
  */
493
- export function isEqual(a, b)
494
- {
555
+ export function isEqual(a, b)
556
+ {
495
557
  if (a === b) return true;
496
558
 
497
559
  // allow "almost" equal numbers
498
- if (isNumber(a)) return isNumber(b) ? equals(a, b) : false;
560
+ if (isNumber(a)) return isNumber(b) ? equals(a, b) : false;
499
561
  //if(isDate(a))) return isDate(b) ? isEqual(a, b) : false;
500
562
  if (isVector(a)) return isVector(b) ? isVectorEqual(a, b) : false;
501
563
  if (!isObjectObject(a) || !isObjectObject(b)) return false;
@@ -507,18 +569,18 @@ export function isEqual(a, b)
507
569
 
508
570
  if (aKeys.length !== bKeys.length) return false;
509
571
 
510
- for (let i = 0; i < aKeys.length; i++)
511
- {
512
- let key = aKeys[i];
513
- if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
514
- if (!isEqual(a[key], b[key])) return false;
572
+ for (let i = 0; i < aKeys.length; i++)
573
+ {
574
+ let key = aKeys[i];
575
+ if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
576
+ if (!isEqual(a[key], b[key])) return false;
515
577
  }
516
-
517
- return true;
518
- }
519
-
520
- // Neutral runtime-utils spellings preserve the established core predicates.
521
- export const isNullish = isNoU;
522
- export const isPlainObject = isPlain;
523
- export const isPromiseLike = isPromise;
524
- export const isTypedArray = isTyped;
578
+
579
+ return true;
580
+ }
581
+
582
+ // Neutral runtime-utils spellings preserve the established core predicates.
583
+ export const isNullish = isNoU;
584
+ export const isPlainObject = isPlain;
585
+ export const isPromiseLike = isPromise;
586
+ export const isTypedArray = isTyped;
package/src/json.js CHANGED
@@ -1,23 +1,23 @@
1
- import { decodeUtf8, encodeUtf8 } from "./text.js";
2
-
3
- /** Encodes JSON with explicit indentation and trailing-newline behavior. */
4
- export function encodeJson(value, options = {})
5
- {
6
- const space = options.space ?? 2;
7
- const text = JSON.stringify(value, options.replacer ?? null, space);
8
-
9
- if (text === undefined)
10
- {
11
- throw new TypeError("JSON input is not serializable as a top-level value.");
12
- }
13
-
14
- return encodeUtf8(options.trailingNewline === false ? text : `${text}\n`);
15
- }
16
-
17
- /** Decodes JSON from a string or UTF-8 byte input. */
18
- export function decodeJson(value, options = {})
19
- {
20
- const text = typeof value === "string" ? value : decodeUtf8(value, options);
21
-
22
- return JSON.parse(text, options.reviver);
23
- }
1
+ import { decodeUtf8, encodeUtf8 } from "./text.js";
2
+
3
+ /** Encodes JSON with explicit indentation and trailing-newline behavior. */
4
+ export function encodeJson(value, options = {})
5
+ {
6
+ const space = options.space ?? 2;
7
+ const text = JSON.stringify(value, options.replacer ?? null, space);
8
+
9
+ if (text === undefined)
10
+ {
11
+ throw new TypeError("JSON input is not serializable as a top-level value.");
12
+ }
13
+
14
+ return encodeUtf8(options.trailingNewline === false ? text : `${text}\n`);
15
+ }
16
+
17
+ /** Decodes JSON from a string or UTF-8 byte input. */
18
+ export function decodeJson(value, options = {})
19
+ {
20
+ const text = typeof value === "string" ? value : decodeUtf8(value, options);
21
+
22
+ return JSON.parse(text, options.reviver);
23
+ }
@@ -1,77 +1,77 @@
1
- import { ensureRuntimeState, getRuntimeState } from "../runtime/CjsRuntimeState.js";
2
-
3
- export const CJS_LIFECYCLE = Object.freeze({
4
- ALIVE: "alive",
5
- DESTROY_PENDING: "destroyPending",
6
- DESTROYING: "destroying",
7
- DESTROYED: "destroyed"
8
- });
9
-
10
- /** Inspectable lifecycle state shared by participating runtime objects. */
11
- export class CjsLifecycleState
12
- {
13
-
14
- status = CJS_LIFECYCLE.ALIVE;
15
-
16
- Is(status)
17
- {
18
- return this.status === status;
19
- }
20
-
21
- IsAlive()
22
- {
23
- return this.Is(CJS_LIFECYCLE.ALIVE);
24
- }
25
-
26
- IsAvailable()
27
- {
28
- return this.IsAlive();
29
- }
30
-
31
- }
32
-
33
- /**
34
- * Installs shared, non-enumerable lifecycle state on an object.
35
- *
36
- * @param {object|Function} target
37
- * @returns {CjsLifecycleState}
38
- */
39
- export function initializeLifecycleState(target)
40
- {
41
- const state = ensureRuntimeState(target);
42
- if (Object.prototype.hasOwnProperty.call(state, "lifecycle"))
43
- {
44
- if (!(state.lifecycle instanceof CjsLifecycleState))
45
- {
46
- throw new TypeError("Existing __state.lifecycle must be a CjsLifecycleState.");
47
- }
48
- return state.lifecycle;
49
- }
50
-
51
- const lifecycle = new CjsLifecycleState();
52
- Object.defineProperty(state, "lifecycle", {
53
- value: lifecycle,
54
- enumerable: true,
55
- configurable: false,
56
- writable: false
57
- });
58
- return lifecycle;
59
- }
60
-
61
- /**
62
- * Gets lifecycle state without enrolling the target in lifecycle management.
63
- *
64
- * An absent state means the target is ordinarily alive and unmanaged.
65
- *
66
- * @param {object|Function} target
67
- * @returns {CjsLifecycleState|null}
68
- */
69
- export function getLifecycleState(target)
70
- {
71
- const lifecycle = getRuntimeState(target)?.lifecycle ?? null;
72
- if (lifecycle !== null && !(lifecycle instanceof CjsLifecycleState))
73
- {
74
- throw new TypeError("Existing __state.lifecycle must be a CjsLifecycleState.");
75
- }
76
- return lifecycle;
77
- }
1
+ import { ensureRuntimeState, getRuntimeState } from "../runtime/CjsRuntimeState.js";
2
+
3
+ export const CJS_LIFECYCLE = Object.freeze({
4
+ ALIVE: "alive",
5
+ DESTROY_PENDING: "destroyPending",
6
+ DESTROYING: "destroying",
7
+ DESTROYED: "destroyed"
8
+ });
9
+
10
+ /** Inspectable lifecycle state shared by participating runtime objects. */
11
+ export class CjsLifecycleState
12
+ {
13
+
14
+ status = CJS_LIFECYCLE.ALIVE;
15
+
16
+ Is(status)
17
+ {
18
+ return this.status === status;
19
+ }
20
+
21
+ IsAlive()
22
+ {
23
+ return this.Is(CJS_LIFECYCLE.ALIVE);
24
+ }
25
+
26
+ IsAvailable()
27
+ {
28
+ return this.IsAlive();
29
+ }
30
+
31
+ }
32
+
33
+ /**
34
+ * Installs shared, non-enumerable lifecycle state on an object.
35
+ *
36
+ * @param {object|Function} target
37
+ * @returns {CjsLifecycleState}
38
+ */
39
+ export function initializeLifecycleState(target)
40
+ {
41
+ const state = ensureRuntimeState(target);
42
+ if (Object.prototype.hasOwnProperty.call(state, "lifecycle"))
43
+ {
44
+ if (!(state.lifecycle instanceof CjsLifecycleState))
45
+ {
46
+ throw new TypeError("Existing __state.lifecycle must be a CjsLifecycleState.");
47
+ }
48
+ return state.lifecycle;
49
+ }
50
+
51
+ const lifecycle = new CjsLifecycleState();
52
+ Object.defineProperty(state, "lifecycle", {
53
+ value: lifecycle,
54
+ enumerable: true,
55
+ configurable: false,
56
+ writable: false
57
+ });
58
+ return lifecycle;
59
+ }
60
+
61
+ /**
62
+ * Gets lifecycle state without enrolling the target in lifecycle management.
63
+ *
64
+ * An absent state means the target is ordinarily alive and unmanaged.
65
+ *
66
+ * @param {object|Function} target
67
+ * @returns {CjsLifecycleState|null}
68
+ */
69
+ export function getLifecycleState(target)
70
+ {
71
+ const lifecycle = getRuntimeState(target)?.lifecycle ?? null;
72
+ if (lifecycle !== null && !(lifecycle instanceof CjsLifecycleState))
73
+ {
74
+ throw new TypeError("Existing __state.lifecycle must be a CjsLifecycleState.");
75
+ }
76
+ return lifecycle;
77
+ }
@@ -1 +1 @@
1
- export * from "./CjsLifecycleState.js";
1
+ export * from "./CjsLifecycleState.js";
package/src/lne3.js CHANGED
@@ -90,9 +90,9 @@ lne3.closestPointToPointParameter = function(a, point, clampToLine)
90
90
  startEnd[1] = a[4] - a[1];
91
91
  startEnd[2] = a[5] - a[2];
92
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;
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
96
 
97
97
  vec3.unalloc(startP);
98
98
  vec3.unalloc(startEnd);
@@ -186,7 +186,7 @@ lne3.equalsStartEnd = box3.equalsBounds;
186
186
  * @param {lne3} b
187
187
  * @returns {boolean}
188
188
  */
189
- lne3.exactEquals = box3.exactEquals;
189
+ lne3.exactEquals = box3.exactEquals;
190
190
 
191
191
  /**
192
192
  * Checks for exact equality between a lne3 and components
@@ -271,13 +271,13 @@ lne3.getCenter = function(out, a)
271
271
  * @param {boolean} clampToLine - optional setting to clamp the result to a line segment
272
272
  * @returns {vec3} out - receiving vec3
273
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;
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
281
  };
282
282
 
283
283
  /**
@@ -327,8 +327,8 @@ lne3.intersectsNormalConstant = function(a, n, c)
327
327
  startSign = (n[0] * a[0] + n[1] * a[1] + n[2] * a[2]) + c,
328
328
  endSign = (n[0] * a[3] + n[1] * a[4] + n[2] * a[5]) + c;
329
329
 
330
- return startSign === 0 || endSign === 0 ||
331
- (startSign < 0 && endSign > 0) || (endSign < 0 && startSign > 0);
330
+ return startSign === 0 || endSign === 0 ||
331
+ (startSign < 0 && endSign > 0) || (endSign < 0 && startSign > 0);
332
332
  };
333
333
 
334
334
  /**
@@ -417,27 +417,27 @@ lne3.setEnd = box3.setMaxBounds;
417
417
  * @param {mat4} m
418
418
  * @returns {lne3} out
419
419
  */
420
- lne3.transformMat4 = function(out, a, m)
421
- {
420
+ lne3.transformMat4 = function(out, a, m)
421
+ {
422
422
  let ax = a[0],
423
423
  ay = a[1],
424
424
  az = a[2],
425
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;
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
441
 
442
442
  return out;
443
443
  };
@@ -450,48 +450,48 @@ lne3.transformMat4 = function(out, a, m)
450
450
  * @param {vec3} v
451
451
  * @returns {lne3} out
452
452
  */
453
- lne3.translate = function(out, a, v)
454
- {
453
+ lne3.translate = function(out, a, v)
454
+ {
455
455
  out[0] = a[0] + v[0];
456
456
  out[1] = a[1] + v[1];
457
457
  out[2] = a[2] + v[2];
458
458
  out[3] = a[3] + v[0];
459
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;
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;