@woosh/meep-engine 2.33.36 → 2.33.37

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 (52) hide show
  1. package/core/collection/HashMap.js +19 -12
  2. package/core/collection/table/RowFirstTable.js +13 -8
  3. package/core/collection/table/RowFirstTableSpec.js +6 -0
  4. package/core/color/Color.js +5 -9
  5. package/core/color/ColorUtils.js +4 -150
  6. package/core/color/YCbCr_to_rgb_uint24.js +20 -0
  7. package/core/color/hsv2rgb.js +54 -0
  8. package/core/color/int2rgb.js +12 -0
  9. package/core/color/parseHex.js +18 -0
  10. package/core/color/rgb2hex.js +16 -0
  11. package/core/color/rgb2hsv.js +47 -0
  12. package/core/color/rgb2uint24.js +17 -0
  13. package/core/color/rgb_to_YCbCr_uint24.js +18 -0
  14. package/core/geom/3d/aabb/compute_aabb_from_points.js +28 -0
  15. package/core/geom/3d/plane/orient3d_fast.js +45 -0
  16. package/core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js +5 -0
  17. package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +177 -0
  18. package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.spec.js +66 -0
  19. package/core/geom/3d/tetrahedra/compute_circumsphere.js +271 -0
  20. package/core/geom/3d/tetrahedra/compute_delaunay_tetrahedral_mesh.js +199 -0
  21. package/core/geom/3d/tetrahedra/compute_delaunay_tetrahedral_mesh.spec.js +5 -0
  22. package/core/geom/3d/tetrahedra/point_in_tetrahedron_circumsphere.js +77 -0
  23. package/core/geom/3d/tetrahedra/tetrahedron_contains_point.js +25 -0
  24. package/core/geom/Quaternion.js +4 -0
  25. package/core/math/hash/murmur3_32.js +39 -0
  26. package/core/process/undo/ActionProcessor.d.ts +2 -0
  27. package/core/process/undo/ActionProcessor.js +8 -0
  28. package/editor/tools/FoliagePaintTool.js +1 -1
  29. package/editor/tools/GridPaintTool.js +1 -1
  30. package/engine/ecs/foliage/InstancedFoliage.js +45 -0
  31. package/engine/ecs/foliage/ecs/InstancedMeshLayer.js +4 -0
  32. package/engine/ecs/storage/BinaryBufferSerializer.js +48 -38
  33. package/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -1
  34. package/engine/ecs/terrain/ecs/splat/SplatMapOptimizerDebugger.js +1 -1
  35. package/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
  36. package/engine/graphics/GraphicsEngine.js +7 -0
  37. package/engine/graphics/ecs/mesh/Mesh.js +2 -2
  38. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +13 -0
  39. package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +339 -314
  40. package/engine/graphics/micron/render/v1/VGThreeRenderer.js +6 -2
  41. package/engine/graphics/particles/node-based/rendering/billboard/ParticleBillboardShader.js +1 -1
  42. package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +100 -55
  43. package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +6 -1
  44. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +1 -0
  45. package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +1 -1
  46. package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +17 -4
  47. package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
  48. package/engine/graphics/render/visibility/VisibilityComputer.js +8 -7
  49. package/engine/graphics/shaders/TerrainShader.js +5 -5
  50. package/engine/graphics/shadows/testShadowMapRendering.js +192 -0
  51. package/package.json +2 -1
  52. package/view/elements/ColorPickerView.js +2 -1
@@ -57,8 +57,9 @@ export class HashMap {
57
57
  capacity = DEFAULT_INITIAL_CAPACITY,
58
58
  loadFactor = DEFAULT_LOAD_FACTOR
59
59
  } = {}) {
60
- assert.typeOf(keyHashFunction, 'function', 'keyHashFunction');
61
- assert.typeOf(keyEqualityFunction, 'function', 'keyEqualityFunction');
60
+
61
+ assert.isFunction(keyHashFunction, 'keyHashFunction');
62
+ assert.isFunction(keyEqualityFunction, 'keyEqualityFunction');
62
63
 
63
64
  /**
64
65
  *
@@ -77,6 +78,10 @@ export class HashMap {
77
78
  */
78
79
  this.records = [];
79
80
 
81
+ /**
82
+ *
83
+ * @type {number}
84
+ */
80
85
  this.size = 0;
81
86
 
82
87
 
@@ -245,21 +250,23 @@ export class HashMap {
245
250
  const bucket_index = this.__compute_bucket_index(raw_hash);
246
251
  const bucket = this.records[bucket_index];
247
252
 
248
- if (bucket === undefined) {
249
- return undefined;
250
- }
253
+ if (bucket !== undefined) {
251
254
 
252
- const bucketSize = bucket.length;
255
+ const bucketSize = bucket.length;
253
256
 
254
- //check if key already exists
255
- for (let i = 0; i < bucketSize; i++) {
256
- const entry = bucket[i];
257
+ //check if key already exists
258
+ for (let i = 0; i < bucketSize; i++) {
259
+ const entry = bucket[i];
257
260
 
258
- const entryKey = entry.key;
259
- if (entryKey === key || this.keyEqualityFunction(entryKey, key)) {
261
+ const entryKey = entry.key;
260
262
 
261
- return entry.value;
263
+ if (entryKey === key || this.keyEqualityFunction(entryKey, key)) {
264
+
265
+ return entry.value;
266
+
267
+ }
262
268
  }
269
+
263
270
  }
264
271
 
265
272
  //not found
@@ -6,8 +6,6 @@
6
6
  import { assert } from "../../assert.js";
7
7
  import Signal from "../../events/signal/Signal.js";
8
8
  import { max2 } from "../../math/max2.js";
9
- import { RowFirstTableSpec } from "./RowFirstTableSpec.js";
10
-
11
9
 
12
10
  /**
13
11
  *
@@ -15,9 +13,9 @@ import { RowFirstTableSpec } from "./RowFirstTableSpec.js";
15
13
  * @constructor
16
14
  */
17
15
  function RowFirstTable(spec) {
18
- assert.notEqual(spec, undefined, 'spec is undefined');
19
- assert.notEqual(spec, null, 'spec is null');
20
- assert.ok(spec instanceof RowFirstTableSpec, 'spec is not an instance of RowFirstTableSpec');
16
+ assert.defined(spec, 'spec');
17
+ assert.notNull(spec, 'spec');
18
+ assert.equal(spec.isRowFirstTableSpec, true, 'spec.isRowFirstTableSpec !== true');
21
19
 
22
20
  /**
23
21
  *
@@ -81,6 +79,10 @@ RowFirstTable.prototype.initialize = function () {
81
79
  this.writeRowMethod = spec.writeRowMethod;
82
80
  };
83
81
 
82
+ /**
83
+ *
84
+ * @returns {number}
85
+ */
84
86
  RowFirstTable.prototype.hash = function () {
85
87
  // to keep hash calculation fast, do a fixed number evenly spaced taps inside the data table
86
88
 
@@ -97,7 +99,7 @@ RowFirstTable.prototype.hash = function () {
97
99
 
98
100
  const dataView = this.dataView;
99
101
 
100
- let result = 0;
102
+ let result = byteLength;
101
103
 
102
104
  for (let i = 0; i < step_count; i++) {
103
105
  const address = i * step_size * 4;
@@ -285,7 +287,7 @@ RowFirstTable.prototype.addRow = function (values) {
285
287
 
286
288
  this.writeRowMethod(this.dataView, this.bytesPerRecord * rowIndex, values);
287
289
 
288
- this.on.added.dispatch(rowIndex, values);
290
+ this.on.added.send2(rowIndex, values);
289
291
  };
290
292
 
291
293
  /**
@@ -311,7 +313,7 @@ RowFirstTable.prototype.addRows = function (count, valueSupplier) {
311
313
 
312
314
  function addOneSignaling(index) {
313
315
  addOneSilent(index);
314
- onAdded.dispatch(index, row);
316
+ onAdded.send2(index, row);
315
317
  }
316
318
 
317
319
  function addOneSilent(i) {
@@ -432,6 +434,9 @@ RowFirstTable.prototype.toRowArray = function () {
432
434
 
433
435
  };
434
436
 
437
+ /**
438
+ * Print the table to console
439
+ */
435
440
  RowFirstTable.prototype.printToConsole = function () {
436
441
  const rows = this.toRowArray();
437
442
 
@@ -237,6 +237,12 @@ RowFirstTableSpec.prototype.equals = function (other) {
237
237
  return isArrayEqualStrict(this.types, other.types);
238
238
  };
239
239
 
240
+ /**
241
+ * @readonly
242
+ * @type {boolean}
243
+ */
244
+ RowFirstTableSpec.prototype.isRowFirstTableSpec = true;
245
+
240
246
 
241
247
  const cache = new Cache({
242
248
  keyHashFunction: computeStringHash
@@ -1,12 +1,14 @@
1
1
  import { assert } from "../assert.js";
2
2
  import Signal from "../events/signal/Signal.js";
3
- import { parseColor, rgb2hsv } from "./ColorUtils.js";
3
+ import { parseColor } from "./ColorUtils.js";
4
4
  import { clamp } from "../math/clamp.js";
5
5
  import { min2 } from "../math/min2.js";
6
6
  import { max2 } from "../math/max2.js";
7
7
  import { min3 } from "../math/min3.js";
8
8
  import { computeHashIntegerArray } from "../collection/array/computeHashIntegerArray.js";
9
9
  import { computeHashFloat } from "../math/hash/computeHashFloat.js";
10
+ import { rgb2hsv } from "./rgb2hsv.js";
11
+ import { rgb2uint24 } from "./rgb2uint24.js";
10
12
 
11
13
  class Color {
12
14
  /**
@@ -273,14 +275,8 @@ class Color {
273
275
  * @returns {number}
274
276
  */
275
277
  toUint() {
276
- const r = Math.round(this.r * 255);
277
- const g = Math.round(this.g * 255);
278
- const b = Math.round(this.b * 255);
279
-
280
- return (b & 0xFF)
281
- | (g & 0xFF) << 8
282
- | (r & 0xFF) << 16
283
- ;
278
+
279
+ return rgb2uint24(this.r, this.g, this.b);
284
280
  }
285
281
 
286
282
  /**
@@ -2,149 +2,9 @@
2
2
  * Created by Alex on 02/05/2016.
3
3
  */
4
4
 
5
- import { clamp } from "../math/clamp.js";
5
+ import { hsv2rgb } from "./hsv2rgb.js";
6
+ import { parseHex } from "./parseHex.js";
6
7
 
7
- /**
8
- *
9
- * @param {number} h from 0 to 1
10
- * @param {number} s from 0 to 1
11
- * @param {number} v from 0 to 1
12
- * @returns {{r: number, g: number, b: number}}
13
- */
14
- function hsv2rgb(h, s, v) {
15
-
16
- let _h = h % 1;
17
-
18
- if (_h < 0) {
19
- _h = h + 1;
20
- }
21
-
22
- const _s = clamp(s, 0, 1);
23
- const _v = clamp(v, 0, 1);
24
-
25
- let r, g, b, i, f, p, q, t;
26
-
27
- i = Math.floor(h * 6);
28
- f = _h * 6 - i;
29
- p = _v * (1 - _s);
30
- q = _v * (1 - f * _s);
31
- t = _v * (1 - (1 - f) * _s);
32
- switch (i % 6) {
33
- case 0:
34
- r = _v, g = t, b = p;
35
- break;
36
- case 1:
37
- r = q, g = _v, b = p;
38
- break;
39
- case 2:
40
- r = p, g = _v, b = t;
41
- break;
42
- case 3:
43
- r = p, g = q, b = _v;
44
- break;
45
- case 4:
46
- r = t, g = p, b = _v;
47
- break;
48
- case 5:
49
- r = _v, g = p, b = q;
50
- break;
51
- }
52
- return {
53
- r: Math.round(r * 255),
54
- g: Math.round(g * 255),
55
- b: Math.round(b * 255)
56
- };
57
- }
58
-
59
- /**
60
- *
61
- * @param {number} r 0 to 255
62
- * @param {number} g 0 to 255
63
- * @param {number} b 0 to 255
64
- * @returns {{h: number, s: number, v: number}}
65
- */
66
- export function rgb2hsv(r, g, b) {
67
-
68
- r /= 255;
69
- g /= 255;
70
- b /= 255;
71
-
72
-
73
- const max = Math.max(r, g, b);
74
- const min = Math.min(r, g, b);
75
-
76
- var h, s, v = max;
77
-
78
- var d = max - min;
79
-
80
- s = max === 0 ? 0 : d / max;
81
-
82
- if (max === min) {
83
- h = 0; // achromatic
84
- } else {
85
- switch (max) {
86
- case r:
87
- h = (g - b) / d + (g < b ? 6 : 0);
88
- break;
89
- case g:
90
- h = (b - r) / d + 2;
91
- break;
92
- case b:
93
- h = (r - g) / d + 4;
94
- break;
95
- }
96
-
97
- h /= 6;
98
- }
99
-
100
- return {
101
- h,
102
- s,
103
- v
104
- };
105
- }
106
-
107
- /**
108
- *
109
- * @param {string} hex
110
- * @returns {{r: Number, g: Number, b: Number}} rgb
111
- */
112
- function parseHex(hex) {
113
- function hex2dec(v) {
114
- return parseInt(v, 16)
115
- }
116
-
117
- return {
118
- r: hex2dec(hex.slice(1, 3)),
119
- g: hex2dec(hex.slice(3, 5)),
120
- b: hex2dec(hex.slice(5))
121
- };
122
- }
123
-
124
-
125
- /**
126
- *
127
- * @param r
128
- * @param g
129
- * @param b
130
- * @returns {string}
131
- */
132
- function rgb2hex(r, g, b) {
133
- function dec2hex(c) {
134
- const hex = c.toString(16);
135
- return hex.length === 1 ? "0" + hex : hex;
136
- }
137
-
138
- return dec2hex(r) + dec2hex(g) + dec2hex(b);
139
- }
140
-
141
- function int2rgb(value) {
142
- return {
143
- r: (value >> 16) & 255,
144
- g: (value >> 8) & 255,
145
- b: (value) & 255
146
- }
147
- }
148
8
 
149
9
  const rgbRegEx = /rgb\(([0-9]+),\s*([0-9]+),\s*([0-9]+)\)/;
150
10
  const hsvRegEx = /hsv\(([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?)\)/;
@@ -152,7 +12,7 @@ const hsvRegEx = /hsv\(([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+
152
12
  /**
153
13
  *
154
14
  * @param {string|number} c
155
- * @returns {number[]} Numeric array, values are in Uint range
15
+ * @returns {number[]} Numeric array, values are in Uint8 range (0...255)
156
16
  */
157
17
  export function parseColor(c) {
158
18
 
@@ -194,7 +54,7 @@ export function parseColor(c) {
194
54
  } else {
195
55
  throw new Error(`Failed to decode color string '${c}' `);
196
56
  }
197
- } else if(type_of_code === 'number'){
57
+ } else if (type_of_code === 'number') {
198
58
 
199
59
  result[0] = c >> 16;
200
60
  result[1] = (c >> 8) & 0xFF;
@@ -207,9 +67,3 @@ export function parseColor(c) {
207
67
  return result;
208
68
  }
209
69
 
210
- export {
211
- hsv2rgb,
212
- parseHex,
213
- rgb2hex,
214
- int2rgb
215
- };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @see https://en.wikipedia.org/wiki/YUV
3
+ * @param {number} Y
4
+ * @param {number} Cb
5
+ * @param {number} Cr
6
+ * @returns {number}
7
+ */
8
+ export function YCbCr_to_rgb_uint24(Y, Cb, Cr) {
9
+ const _Cr = Cr - 128;
10
+ const _Cb = Cb - 128;
11
+
12
+ const r = Y + _Cr + (_Cr >> 2) + (_Cr >> 3) + (_Cr >> 5);
13
+ const g = Y - ((_Cb >> 2) + (_Cb >> 4) + (_Cb >> 5)) - ((_Cr >> 1) + (_Cr >> 3) + (_Cr >> 4) + (_Cr >> 5));
14
+ const b = Y + _Cb + (_Cb >> 1) + (_Cb >> 2) + (_Cb >> 6);
15
+
16
+ return (b & 0xFF)
17
+ | (g & 0xFF) << 8
18
+ | (r & 0xFF) << 16
19
+ ;
20
+ }
@@ -0,0 +1,54 @@
1
+ import { clamp } from "../math/clamp.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number} h from 0 to 1
6
+ * @param {number} s from 0 to 1
7
+ * @param {number} v from 0 to 1
8
+ * @returns {{r: number, g: number, b: number}}
9
+ */
10
+ export function hsv2rgb(h, s, v) {
11
+
12
+ let _h = h % 1;
13
+
14
+ if (_h < 0) {
15
+ _h = h + 1;
16
+ }
17
+
18
+ const _s = clamp(s, 0, 1);
19
+ const _v = clamp(v, 0, 1);
20
+
21
+ let r, g, b, i, f, p, q, t;
22
+
23
+ i = Math.floor(h * 6);
24
+ f = _h * 6 - i;
25
+ p = _v * (1 - _s);
26
+ q = _v * (1 - f * _s);
27
+ t = _v * (1 - (1 - f) * _s);
28
+ switch (i % 6) {
29
+ case 0:
30
+ r = _v, g = t, b = p;
31
+ break;
32
+ case 1:
33
+ r = q, g = _v, b = p;
34
+ break;
35
+ case 2:
36
+ r = p, g = _v, b = t;
37
+ break;
38
+ case 3:
39
+ r = p, g = q, b = _v;
40
+ break;
41
+ case 4:
42
+ r = t, g = p, b = _v;
43
+ break;
44
+ case 5:
45
+ r = _v, g = p, b = q;
46
+ break;
47
+ }
48
+ return {
49
+ r: Math.round(r * 255),
50
+ g: Math.round(g * 255),
51
+ b: Math.round(b * 255)
52
+ };
53
+ }
54
+
@@ -0,0 +1,12 @@
1
+ /**
2
+ *
3
+ * @param {number} value
4
+ * @returns {{r: number, b: number, g: number}}
5
+ */
6
+ export function int2rgb(value) {
7
+ return {
8
+ r: (value >> 16) & 255,
9
+ g: (value >> 8) & 255,
10
+ b: (value) & 255
11
+ }
12
+ }
@@ -0,0 +1,18 @@
1
+ function hex2dec(v) {
2
+ return parseInt(v, 16)
3
+ }
4
+
5
+ /**
6
+ *
7
+ * @param {string} hex
8
+ * @returns {{r: Number, g: Number, b: Number}} rgb
9
+ */
10
+ export function parseHex(hex) {
11
+
12
+
13
+ return {
14
+ r: hex2dec(hex.slice(1, 3)),
15
+ g: hex2dec(hex.slice(3, 5)),
16
+ b: hex2dec(hex.slice(5))
17
+ };
18
+ }
@@ -0,0 +1,16 @@
1
+ function dec2hex(c) {
2
+ const hex = c.toString(16);
3
+ return hex.length === 1 ? "0" + hex : hex;
4
+ }
5
+
6
+ /**
7
+ *
8
+ * @param {number} r
9
+ * @param {number} g
10
+ * @param {number} b
11
+ * @returns {string}
12
+ */
13
+ export function rgb2hex(r, g, b) {
14
+
15
+ return dec2hex(r) + dec2hex(g) + dec2hex(b);
16
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ *
3
+ * @param {number} r 0 to 255
4
+ * @param {number} g 0 to 255
5
+ * @param {number} b 0 to 255
6
+ * @returns {{h: number, s: number, v: number}}
7
+ */
8
+ export function rgb2hsv(r, g, b) {
9
+
10
+ r /= 255;
11
+ g /= 255;
12
+ b /= 255;
13
+
14
+
15
+ const max = Math.max(r, g, b);
16
+ const min = Math.min(r, g, b);
17
+
18
+ var h, s, v = max;
19
+
20
+ var d = max - min;
21
+
22
+ s = max === 0 ? 0 : d / max;
23
+
24
+ if (max === min) {
25
+ h = 0; // achromatic
26
+ } else {
27
+ switch (max) {
28
+ case r:
29
+ h = (g - b) / d + (g < b ? 6 : 0);
30
+ break;
31
+ case g:
32
+ h = (b - r) / d + 2;
33
+ break;
34
+ case b:
35
+ h = (r - g) / d + 4;
36
+ break;
37
+ }
38
+
39
+ h /= 6;
40
+ }
41
+
42
+ return {
43
+ h,
44
+ s,
45
+ v
46
+ };
47
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ *
3
+ * @param {number} r
4
+ * @param {number} g
5
+ * @param {number} b
6
+ * @returns {number}
7
+ */
8
+ export function rgb2uint24(r,g,b){
9
+ const _r = Math.round(r * 255);
10
+ const _g = Math.round(g * 255);
11
+ const _b = Math.round(b * 255);
12
+
13
+ return (_b & 0xFF)
14
+ | (_g & 0xFF) << 8
15
+ | (_r & 0xFF) << 16
16
+ ;
17
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ *
3
+ * @see https://en.wikipedia.org/wiki/YUV
4
+ * @param {number} r
5
+ * @param {number} g
6
+ * @param {number} b
7
+ * @returns {number}
8
+ */
9
+ export function rgb_to_YCbCr_uint24(r, g, b) {
10
+ const Y = 0.299 * r + 0.587 * g + 0.114 * b;
11
+ const Cb = -0.169 * r - 0.331 * g + 0.499 * b + 128;
12
+ const Cr = 0.499 * g - 0.418 * g - 0.0813 * b + 128;
13
+
14
+ return (Cr & 0xFF)
15
+ | (Cb & 0xFF) << 8
16
+ | (Y & 0xFF) << 16
17
+ ;
18
+ }
@@ -0,0 +1,28 @@
1
+ import { min2 } from "../../../math/min2.js";
2
+ import { max2 } from "../../../math/max2.js";
3
+
4
+ /**
5
+ *
6
+ * @param {number[]} result
7
+ * @param {number[]} input
8
+ * @param {number} input_count
9
+ * @param {number} d number of dimensions
10
+ */
11
+ export function compute_aabb_from_points(result, input, input_count, d) {
12
+ let i = 0;
13
+ let j = 0;
14
+
15
+ for (; i < d; i++) {
16
+ result[i] = Infinity;
17
+ result[i + d] = -Infinity;
18
+ }
19
+
20
+ for (i = 0; i < input_count; i++) {
21
+ for (j = 0; j < d; j++) {
22
+ const v = input[j];
23
+
24
+ result[j] = min2(result[j], v);
25
+ result[j + d] = max2(result[j + d], v);
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Return a positive value if the point pd lies below the
3
+ * plane passing through pa, pb, and pc; "below" is defined so
4
+ * that pa, pb, and pc appear in counterclockwise order when
5
+ * viewed from above the plane. Returns a negative value if
6
+ * pd lies above the plane. Returns zero if the points are
7
+ * coplanar. The result is also a rough approximation of six
8
+ * times the signed volume of the tetrahedron defined by the
9
+ * four points.
10
+ *
11
+ * NOTE: ported from http://www.cs.cmu.edu/afs/cs/project/quake/public/code/predicates.c
12
+ *
13
+ * @param {number[]} points
14
+ * @param {number} a index of point a
15
+ * @param {number} b index of point b
16
+ * @param {number} c index of point c
17
+ * @param {number} d index of point d
18
+ * @returns {number}
19
+ */
20
+ export function orient3d_fast(points, a, b, c, d) {
21
+ const a3 = a * 3;
22
+ const d3 = d * 3;
23
+
24
+ const adx = points[a3] - points[d3];
25
+
26
+ const b3 = b * 3;
27
+
28
+ const bdx = points[b3] - points[d3];
29
+
30
+ const c3 = c * 3;
31
+
32
+ const cdx = points[c3] - points[d3];
33
+
34
+ const ady = points[a3 + 1] - points[d3 + 1];
35
+ const bdy = points[b3 + 1] - points[d3 + 1];
36
+ const cdy = points[c3 + 1] - points[d3 + 1];
37
+
38
+ const adz = points[a3 + 2] - points[d3 + 2];
39
+ const bdz = points[b3 + 2] - points[d3 + 2];
40
+ const cdz = points[c3 + 2] - points[d3 + 2];
41
+
42
+ return adx * (bdy * cdz - bdz * cdy)
43
+ + bdx * (cdy * adz - cdz * ady)
44
+ + cdx * (ady * bdz - adz * bdy);
45
+ }
@@ -24,7 +24,12 @@ export function plane_three_computeConvex3PlaneIntersection(result, result_offse
24
24
  }
25
25
 
26
26
  /**
27
+ * Given 3 planes, compute point of their intersection.
28
+ * This only works when the planes are "convex", that is - no two planes are parallel.
29
+ * Simply put - intersection must exist to be found.
30
+ *
27
31
  * NOTE: Based on Intersection of 3 planes, Graphics Gems 1 pg 305
32
+ *
28
33
  * @param {Float32Array|number[]|vec3} result
29
34
  * @param {number} result_offset
30
35
  * @param {number} a_normal_x