@woosh/meep-engine 2.118.2 → 2.118.4

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 (56) hide show
  1. package/build/meep.cjs +116 -110
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +116 -110
  4. package/package.json +5 -5
  5. package/src/core/binary/EndianType.d.ts +3 -0
  6. package/src/core/binary/EndianType.d.ts.map +1 -1
  7. package/src/core/binary/EndianType.js +2 -1
  8. package/src/core/binary/uint8_to_float.d.ts.map +1 -1
  9. package/src/core/binary/uint8_to_float.js +5 -0
  10. package/src/core/collection/queue/Deque.d.ts.map +1 -1
  11. package/src/core/collection/queue/Deque.js +32 -32
  12. package/src/core/collection/table/RowFirstTable.d.ts.map +1 -1
  13. package/src/core/collection/table/RowFirstTable.js +2 -0
  14. package/src/core/color/Color.js +3 -3
  15. package/src/core/color/kelvin/rgb_to_kelvin.d.ts.map +1 -1
  16. package/src/core/color/kelvin/rgb_to_kelvin.js +16 -7
  17. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map +1 -0
  18. package/src/core/geom/Vector3.d.ts.map +1 -1
  19. package/src/core/geom/Vector3.js +5 -19
  20. package/src/core/geom/packing/computeBoundingSphereOfSpheres.js +1 -1
  21. package/src/core/math/compute_legendre_polynomial.d.ts +1 -1
  22. package/src/core/math/compute_legendre_polynomial.d.ts.map +1 -1
  23. package/src/core/math/compute_legendre_polynomial.js +6 -1
  24. package/src/core/math/max3.d.ts.map +1 -1
  25. package/src/core/math/max3.js +4 -0
  26. package/src/core/math/solveQuadratic.d.ts.map +1 -1
  27. package/src/core/math/solveQuadratic.js +5 -1
  28. package/src/core/primitives/boolean/compareBooleans.js +2 -0
  29. package/src/core/primitives/boolean/computeBooleanHash.d.ts +7 -0
  30. package/src/core/primitives/boolean/computeBooleanHash.d.ts.map +1 -0
  31. package/src/core/primitives/boolean/computeBooleanHash.js +8 -0
  32. package/src/core/primitives/numbers/computeHashFloat.d.ts.map +1 -1
  33. package/src/core/primitives/numbers/computeHashFloat.js +4 -2
  34. package/src/engine/animation/async/TimeSeries.d.ts +5 -1
  35. package/src/engine/animation/async/TimeSeries.d.ts.map +1 -1
  36. package/src/engine/animation/async/TimeSeries.js +14 -2
  37. package/src/engine/asset/loaders/material/computeTextureHash.d.ts.map +1 -1
  38. package/src/engine/asset/loaders/material/computeTextureHash.js +5 -0
  39. package/src/engine/ecs/gui/position/ViewportPosition.d.ts +0 -5
  40. package/src/engine/ecs/gui/position/ViewportPosition.d.ts.map +1 -1
  41. package/src/engine/ecs/gui/position/ViewportPosition.js +42 -53
  42. package/src/engine/ecs/speaker/VoiceSystem.d.ts +2 -3
  43. package/src/engine/ecs/speaker/VoiceSystem.d.ts.map +1 -1
  44. package/src/engine/graphics/canvas/computeHtmlCanvasElementHash.d.ts +7 -0
  45. package/src/engine/graphics/canvas/computeHtmlCanvasElementHash.d.ts.map +1 -0
  46. package/src/engine/graphics/canvas/computeHtmlCanvasElementHash.js +12 -0
  47. package/src/engine/graphics/canvas/computeImageCanvasEquality.js +3 -1
  48. package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.js +2 -2
  49. package/src/engine/graphics/texture/html_canvas_to_rendering_context2d_cached.d.ts +7 -0
  50. package/src/engine/graphics/texture/html_canvas_to_rendering_context2d_cached.d.ts.map +1 -0
  51. package/src/engine/graphics/texture/html_canvas_to_rendering_context2d_cached.js +20 -0
  52. package/src/engine/graphics/texture/html_canvas_to_sampler2d.d.ts.map +1 -1
  53. package/src/engine/graphics/texture/html_canvas_to_sampler2d.js +2 -11
  54. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map +0 -1
  55. /package/src/core/{geometry → geom}/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts +0 -0
  56. /package/src/core/{geometry → geom}/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js +0 -0
@@ -1765,6 +1765,12 @@ function lerp$1(a, b, fraction) {
1765
1765
  return (b - a) * fraction + a;
1766
1766
  }
1767
1767
 
1768
+ /**
1769
+ * equal to `Math.pow(2,32) - 1`
1770
+ * @type {number}
1771
+ */
1772
+ const UINT32_MAX = 4294967295;
1773
+
1768
1774
  /**
1769
1775
  *
1770
1776
  * @param {number} v
@@ -1772,12 +1778,12 @@ function lerp$1(a, b, fraction) {
1772
1778
  */
1773
1779
  function computeHashFloat(v) {
1774
1780
  //we break the number up into fractional and whole parts
1775
- const whole = v | 0;
1781
+ const whole = v >> 0;
1776
1782
 
1777
1783
  const fraction = v - whole;
1778
1784
 
1779
1785
  //fractional part is scaled up into int32 range, this inexact method, as it will produce 0 hash for values below a certain threshold
1780
- const fractionHash = fraction * 1367130550;
1786
+ const fractionHash = fraction * UINT32_MAX;
1781
1787
 
1782
1788
  //take XOR of both parts
1783
1789
  return fractionHash ^ whole;
@@ -2122,10 +2128,8 @@ function v3_slerp(
2122
2128
 
2123
2129
  /**
2124
2130
  * @author Alex Goldring
2125
- * @copyright Alex Goldring 2015
2131
+ * @copyright Alex Goldring 2015-2024
2126
2132
  */
2127
-
2128
-
2129
2133
  let Vector3$1 = class Vector3 {
2130
2134
  /**
2131
2135
  *
@@ -3015,7 +3019,7 @@ let Vector3$1 = class Vector3 {
3015
3019
  * @deprecated use dedicated method directly instead
3016
3020
  */
3017
3021
  fromBinaryBufferFloat32_EqualityEncoded(buffer) {
3018
- throw new Error('deprecated, use v3_binary_equality_decode')
3022
+ throw new Error('deprecated, use v3_binary_equality_decode')
3019
3023
  }
3020
3024
 
3021
3025
  hash() {
@@ -3176,19 +3180,7 @@ Vector3$1.prototype.isVector3 = true;
3176
3180
  * @readonly
3177
3181
  * @type {string}
3178
3182
  */
3179
- Vector3$1.typeName = "Vector3";
3180
-
3181
- /**
3182
- * @deprecated use {@link v3_dot} directly instead
3183
- * @param {number} x0
3184
- * @param {number} y0
3185
- * @param {number} z0
3186
- * @param {number} x1
3187
- * @param {number} y1
3188
- * @param {number} z1
3189
- * @returns {number}
3190
- */
3191
- Vector3$1._dot = v3_dot;
3183
+ Vector3$1.typeName = "Vector3";
3192
3184
 
3193
3185
  const scratch_v3_a = new Vector3$1();
3194
3186
  const scratch_v3_b = new Vector3$1();
@@ -50299,6 +50291,7 @@ function float_to_uint8(v) {
50299
50291
  * @returns {number}
50300
50292
  */
50301
50293
  function uint8_to_float(v) {
50294
+
50302
50295
  return v / 255;
50303
50296
  }
50304
50297
 
@@ -51201,18 +51194,28 @@ const context_cache = new WeakMap();
51201
51194
  /**
51202
51195
  *
51203
51196
  * @param {HTMLCanvasElement} canvas
51204
- * @returns {Sampler2D}
51197
+ * @returns {CanvasRenderingContext2D}
51205
51198
  */
51206
- function html_canvas_to_sampler2d(canvas) {
51207
- const width = canvas.width;
51208
- const height = canvas.height;
51209
-
51199
+ function html_canvas_to_rendering_context2d_cached(canvas) {
51210
51200
  let context = context_cache.get(canvas);
51211
51201
 
51212
51202
  if (context === undefined) {
51213
51203
  context = canvas.getContext("2d");
51214
51204
  context_cache.set(canvas, context);
51215
51205
  }
51206
+ return context;
51207
+ }
51208
+
51209
+ /**
51210
+ *
51211
+ * @param {HTMLCanvasElement} canvas
51212
+ * @returns {Sampler2D}
51213
+ */
51214
+ function html_canvas_to_sampler2d(canvas) {
51215
+ const width = canvas.width;
51216
+ const height = canvas.height;
51217
+
51218
+ const context = html_canvas_to_rendering_context2d_cached(canvas);
51216
51219
 
51217
51220
  const imageData = context.getImageData(0, 0, width, height);
51218
51221
 
@@ -52057,12 +52060,6 @@ class TerrainPreview {
52057
52060
  }
52058
52061
  }
52059
52062
 
52060
- /**
52061
- * equal to `Math.pow(2,32) - 1`
52062
- * @type {number}
52063
- */
52064
- const UINT32_MAX = 4294967295;
52065
-
52066
52063
  /**
52067
52064
  * This is essentially a {@link memcopy} implementation for ArrayBuffers
52068
52065
  * NOTE: allocates light-weight typed arrays under the hood, so beware of potential GC implications. Generally not an issue, unless you're copying very large number of very small arrays, consider alternatives such as {@link array_copy} instead
@@ -53919,9 +53916,9 @@ class Color {
53919
53916
 
53920
53917
  /**
53921
53918
  *
53922
- * @param {number} r
53923
- * @param {number} g
53924
- * @param {number} b
53919
+ * @param {number} r [0..255]
53920
+ * @param {number} g [0..255]
53921
+ * @param {number} b [0..255]
53925
53922
  */
53926
53923
  setRGBUint8(r, g, b) {
53927
53924
  this.setRGB(
@@ -55308,13 +55305,17 @@ function v3_morton_encode_bounded(x, y, z, bounds) {
55308
55305
  function max3(a, b, c) {
55309
55306
 
55310
55307
  let v = a;
55308
+
55311
55309
  if (v < b) {
55312
55310
  v = b;
55313
55311
  }
55312
+
55314
55313
  if (v < c) {
55315
55314
  v = c;
55316
55315
  }
55316
+
55317
55317
  return v;
55318
+
55318
55319
  }
55319
55320
 
55320
55321
  /**
@@ -76449,6 +76450,17 @@ function murmur3_32(key, seed) {
76449
76450
  return h1 >>> 0;
76450
76451
  }
76451
76452
 
76453
+ /**
76454
+ *
76455
+ * @param {HTMLCanvasElement} canvas
76456
+ * @returns {number}
76457
+ */
76458
+ function computeHtmlCanvasElementHash(canvas) {
76459
+ const sampler = html_canvas_to_sampler2d(canvas);
76460
+
76461
+ return sampler.hash();
76462
+ }
76463
+
76452
76464
  /**
76453
76465
  * Guards against cases where ImageBitmap doesn't exist
76454
76466
  * @param {*} image
@@ -76693,6 +76705,10 @@ function computeImageDataHash(image) {
76693
76705
 
76694
76706
  result = computeStringHash(image.src);
76695
76707
 
76708
+ }else if(image instanceof HTMLCanvasElement) {
76709
+
76710
+ result = computeHtmlCanvasElementHash(image);
76711
+
76696
76712
  }
76697
76713
 
76698
76714
  let width = 0;
@@ -85291,6 +85307,13 @@ const STATUS_FULL = 0;
85291
85307
  const STATUS_EMPTY = 1;
85292
85308
  const STATUS_NORMAL = 2;
85293
85309
 
85310
+ /**
85311
+ * When growing underlying array, how much to grow by. This is a multiplier.
85312
+ * Must be greater than 1
85313
+ * @type {number}
85314
+ */
85315
+ const GROWTH_FACTOR = 2;
85316
+
85294
85317
  const EMPTY_ARRAY = new Array(0);
85295
85318
 
85296
85319
  /**
@@ -85307,14 +85330,16 @@ class Deque {
85307
85330
  * @private
85308
85331
  */
85309
85332
  #data = EMPTY_ARRAY;
85333
+
85310
85334
  /**
85311
- *
85335
+ * Index of the front of the queue inside the internal data array
85312
85336
  * @type {number}
85313
85337
  * @private
85314
85338
  */
85315
85339
  #head = 0;
85340
+
85316
85341
  /**
85317
- *
85342
+ * Index of the back of the queue inside the internal data array
85318
85343
  * @type {number}
85319
85344
  * @private
85320
85345
  */
@@ -85396,7 +85421,7 @@ class Deque {
85396
85421
  }
85397
85422
 
85398
85423
  // double existing length
85399
- let new_length = length * 2;
85424
+ let new_length = length * GROWTH_FACTOR;
85400
85425
 
85401
85426
  if (new_length > UINT32_MAX) {
85402
85427
  // clamp to max uint32 value
@@ -85469,41 +85494,23 @@ class Deque {
85469
85494
  /**
85470
85495
  *
85471
85496
  * @param {number} current
85472
- * @param {boolean} shift_front should we shift elements before the removed element or after?
85473
85497
  * @private
85474
85498
  */
85475
- #remove_internal(current, shift_front) {
85499
+ #remove_internal_shift_backward(current) {
85476
85500
  let cursor = current;
85477
85501
 
85478
- if (shift_front) {
85479
-
85480
- // shift towards tail
85481
-
85482
- const head = this.#head;
85502
+ // shift towards head, this has a better data access pattern than shifting the other way as we're going through the data in forward sequence
85483
85503
 
85484
- while (cursor !== head) {
85485
- const next = this.#circular_previous_position(cursor);
85486
- this.#data[cursor] = this.#data[next];
85487
- cursor = next;
85488
- }
85489
-
85490
- this.#head = this.#circular_next_position(head);
85491
-
85492
- } else {
85493
-
85494
- // shift towards head
85495
-
85496
- const tail = this.#tail;
85504
+ const tail = this.#tail;
85497
85505
 
85498
- while (cursor !== tail) {
85499
- const next = this.#circular_next_position(cursor);
85500
- this.#data[cursor] = this.#data[next];
85501
- cursor = next;
85502
- }
85506
+ while (cursor !== tail) {
85507
+ const next = this.#circular_next_position(cursor);
85508
+ this.#data[cursor] = this.#data[next];
85509
+ cursor = next;
85510
+ }
85503
85511
 
85504
- this.#tail = this.#circular_previous_position(tail);
85512
+ this.#tail = this.#circular_previous_position(tail);
85505
85513
 
85506
- }
85507
85514
 
85508
85515
  // fill in slot of last moved element
85509
85516
  this.#data[cursor] = undefined;
@@ -85523,7 +85530,7 @@ class Deque {
85523
85530
  return false;
85524
85531
  }
85525
85532
 
85526
- this.#remove_internal(i, true);
85533
+ this.#remove_internal_shift_backward(i);
85527
85534
 
85528
85535
  return true;
85529
85536
  }
@@ -85685,12 +85692,21 @@ class Deque {
85685
85692
  Stack methods
85686
85693
  */
85687
85694
 
85695
+ /**
85696
+ * Stack operation. Alias of {@link Deque.prototype.getFirst}
85697
+ */
85688
85698
  Deque.prototype.peek = Deque.prototype.getFirst;
85699
+ /**
85700
+ * Stack operation. Alias of {@link Deque.prototype.addFirst}
85701
+ */
85689
85702
  Deque.prototype.push = Deque.prototype.addFirst;
85703
+ /**
85704
+ * Stack operation. Alias of {@link Deque.prototype.removeFirst}
85705
+ */
85690
85706
  Deque.prototype.pop = Deque.prototype.removeFirst;
85691
85707
 
85692
85708
  /**
85693
- * Standard queue method
85709
+ * Alias of {@link Deque.prototype.addLast}
85694
85710
  */
85695
85711
  Deque.prototype.add = Deque.prototype.addLast;
85696
85712
 
@@ -103210,59 +103226,49 @@ GUIElement.serializable = true;
103210
103226
 
103211
103227
  class ViewportPosition {
103212
103228
  /**
103213
- *
103214
- * @constructor
103229
+ * Clip-scale position, on-screen values are in range of 0 to 1
103230
+ * @type {Vector2}
103215
103231
  */
103216
- constructor(options) {
103217
- /**
103218
- * Clip-scale position, on-screen values are in range of 0 to 1
103219
- * @type {Vector2}
103220
- */
103221
- this.position = new Vector2();
103222
-
103223
- /**
103224
- * Fixed offset in pixels
103225
- * @type {Vector2}
103226
- */
103227
- this.offset = new Vector2();
103228
- /**
103229
- * ranges from 0..1 in both X and Y, controls anchor point of element positioning
103230
- * @type {Vector2}
103231
- */
103232
- this.anchor = new Vector2(0, 0);
103232
+ position = new Vector2();
103233
103233
 
103234
+ /**
103235
+ * Fixed offset in pixels
103236
+ * @type {Vector2}
103237
+ */
103238
+ offset = new Vector2();
103239
+ /**
103240
+ * ranges from 0..1 in both X and Y, controls anchor point of element positioning
103241
+ * @type {Vector2}
103242
+ */
103243
+ anchor = new Vector2(0, 0);
103234
103244
 
103235
- /**
103236
- * Makes display element avoid overlap with GUI elements
103237
- * @see GUIElement
103238
- * @type {boolean}
103239
- */
103240
- this.resolveGuiCollisions = false;
103241
103245
 
103242
- /**
103243
- * How far should the HUD stay away from the edge if it's sticky
103244
- * @see stickToScreenEdge
103245
- * @type {number}
103246
- */
103247
- this.screenEdgeWidth = 10;
103246
+ /**
103247
+ * Makes display element avoid overlap with GUI elements
103248
+ * @see GUIElement
103249
+ * @type {boolean}
103250
+ */
103251
+ resolveGuiCollisions = false;
103248
103252
 
103253
+ /**
103254
+ * How far should the HUD stay away from the edge if it's sticky
103255
+ * @see stickToScreenEdge
103256
+ * @type {number}
103257
+ */
103258
+ screenEdgeWidth = 10;
103249
103259
 
103250
- /**
103251
- * Controls whenever or not HUD should remain on the screen when it gets to the edge
103252
- * @type {boolean}
103253
- */
103254
- this.stickToScreenEdge = false;
103255
103260
 
103256
- /**
103257
- * Can be used to enable and disable positioning
103258
- * @type {ObservedBoolean}
103259
- */
103260
- this.enabled = new ObservedBoolean(true);
103261
+ /**
103262
+ * Controls whenever or not HUD should remain on the screen when it gets to the edge
103263
+ * @type {boolean}
103264
+ */
103265
+ stickToScreenEdge = false;
103261
103266
 
103262
- if (options !== undefined) {
103263
- this.fromJSON(options);
103264
- }
103265
- }
103267
+ /**
103268
+ * Can be used to enable and disable positioning
103269
+ * @type {ObservedBoolean}
103270
+ */
103271
+ enabled = new ObservedBoolean(true);
103266
103272
 
103267
103273
  /**
103268
103274
  *
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.118.2",
8
+ "version": "2.118.4",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -42,8 +42,8 @@
42
42
  "dependencies": {
43
43
  "gl-matrix": "3.4.3",
44
44
  "opentype.js": "1.3.3",
45
- "robust-predicates": "3.0.2",
46
- "pako": "2.0.3"
45
+ "pako": "2.0.3",
46
+ "robust-predicates": "3.0.2"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "three": ">=0.135.0"
@@ -58,10 +58,10 @@
58
58
  "@babel/preset-env": "7.22.15",
59
59
  "@rollup/plugin-commonjs": "25.0.2",
60
60
  "@rollup/plugin-node-resolve": "15.1.0",
61
- "@rollup/plugin-terser": "0.4.3",
62
61
  "@rollup/plugin-strip": "3.0.2",
63
- "@types/three": "^0.135.0",
62
+ "@rollup/plugin-terser": "0.4.3",
64
63
  "@types/jest": "29.5.12",
64
+ "@types/three": "^0.135.0",
65
65
  "babel-jest": "29.5.0",
66
66
  "jest": "29.6.4",
67
67
  "jest-environment-jsdom": "29.6.4",
@@ -1,3 +1,6 @@
1
+ /**
2
+ * The values are based on the endianness flag of {@link DataView } methods
3
+ */
1
4
  export type EndianType = boolean;
2
5
  export namespace EndianType {
3
6
  let BigEndian: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"EndianType.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/EndianType.js"],"names":[],"mappings":"yBAEU,OAAO"}
1
+ {"version":3,"file":"EndianType.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/EndianType.js"],"names":[],"mappings":";;;yBAGU,OAAO"}
@@ -1,5 +1,6 @@
1
1
  /**
2
- *
2
+ * The values are based on the endianness flag of {@link DataView} methods
3
+ * @readonly
3
4
  * @enum {boolean}
4
5
  */
5
6
  export const EndianType = {
@@ -1 +1 @@
1
- {"version":3,"file":"uint8_to_float.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/uint8_to_float.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kCAHW,MAAM,GACJ,MAAM,CAIlB"}
1
+ {"version":3,"file":"uint8_to_float.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/uint8_to_float.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,kCAHW,MAAM,GACJ,MAAM,CAOlB"}
@@ -1,8 +1,13 @@
1
+ import { assert } from "../assert.js";
2
+
1
3
  /**
2
4
  *
3
5
  * @param {number} v
4
6
  * @returns {number}
5
7
  */
6
8
  export function uint8_to_float(v) {
9
+ assert.lessThanOrEqual(v, 255);
10
+ assert.greaterThanOrEqual(v, 0);
11
+
7
12
  return v / 255;
8
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Deque.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/queue/Deque.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH;IA8BI;;;OAGG;IACH,uBAFW,MAAM,EAUhB;IAuFD;;;OAGG;IACH,WAFY,OAAO,CAIlB;IAED,cAeC;IAED;;;OAGG;IACH,QAFa,MAAM,CAalB;IA+CD;;;;OAIG;IACH,UAHW,CAAC,GACC,OAAO,CAYnB;IA4BD;;;;OAIG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,YAFW,CAAC,QAOX;IAED;;;OAGG;IACH,eAFa,CAAC,GAAC,SAAS,CAQvB;IAED;;;OAGG;IACH,YAFa,CAAC,GAAC,SAAS,CAIvB;IAED;;;OAGG;IACH,WAFW,CAAC,QAOX;IAED;;;OAGG;IACH,cAFa,CAAC,CASb;IAGD;;;OAGG;IACH,WAFa,CAAC,GAAC,SAAS,CAKvB;IAED;;;;OAIG;IACH,yBAHW,MAAM,GACJ,CAAC,GAAC,SAAS,CAmBvB;IAED;;;;;OAKG;IACH,iBAJW,CAAC,EAAE,kBACH,MAAM,GACJ,CAAC,EAAE,CAUf;IAoBL,gBAAoB;IACpB,uBAAoB;IACpB,eAAmB;IAEnB;;OAEG;IACH,sBAAmB;IAzBf;;;OAGG;IACH,qBAFa,UAAU,CAAC,EAAC,IAAI,CAAC,CAS7B;;CACJ"}
1
+ {"version":3,"file":"Deque.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/queue/Deque.js"],"names":[],"mappings":"AAqBA;;;GAGG;AACH;IAgCI;;;OAGG;IACH,uBAFW,MAAM,EAUhB;IAuFD;;;OAGG;IACH,WAFY,OAAO,CAIlB;IAED,cAeC;IAED;;;OAGG;IACH,QAFa,MAAM,CAalB;IA6BD;;;;OAIG;IACH,UAHW,CAAC,GACC,OAAO,CAYnB;IA4BD;;;;OAIG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,YAFW,CAAC,QAOX;IAED;;;OAGG;IACH,eAFa,CAAC,GAAC,SAAS,CAQvB;IAED;;;OAGG;IACH,YAFa,CAAC,GAAC,SAAS,CAIvB;IAED;;;OAGG;IACH,WAFW,CAAC,QAOX;IAED;;;OAGG;IACH,cAFa,CAAC,CASb;IAGD;;;OAGG;IACH,WAFa,CAAC,GAAC,SAAS,CAKvB;IAED;;;;OAIG;IACH,yBAHW,MAAM,GACJ,CAAC,GAAC,SAAS,CAmBvB;IAED;;;;;OAKG;IACH,iBAJW,CAAC,EAAE,kBACH,MAAM,GACJ,CAAC,EAAE,CAUf;IAoBL;;OAEG;IACH,gBAAoB;IACpB;;OAEG;IACH,uBAAoB;IACpB;;OAEG;IACH,eAAmB;IAEnB;;OAEG;IACH,sBAAmB;IAlCf;;;OAGG;IACH,qBAFa,UAAU,CAAC,EAAC,IAAI,CAAC,CAS7B;;CACJ"}
@@ -10,6 +10,13 @@ const STATUS_FULL = 0;
10
10
  const STATUS_EMPTY = 1;
11
11
  const STATUS_NORMAL = 2;
12
12
 
13
+ /**
14
+ * When growing underlying array, how much to grow by. This is a multiplier.
15
+ * Must be greater than 1
16
+ * @type {number}
17
+ */
18
+ const GROWTH_FACTOR = 2;
19
+
13
20
  const EMPTY_ARRAY = new Array(0);
14
21
 
15
22
  /**
@@ -26,14 +33,16 @@ export class Deque {
26
33
  * @private
27
34
  */
28
35
  #data = EMPTY_ARRAY;
36
+
29
37
  /**
30
- *
38
+ * Index of the front of the queue inside the internal data array
31
39
  * @type {number}
32
40
  * @private
33
41
  */
34
42
  #head = 0;
43
+
35
44
  /**
36
- *
45
+ * Index of the back of the queue inside the internal data array
37
46
  * @type {number}
38
47
  * @private
39
48
  */
@@ -117,7 +126,7 @@ export class Deque {
117
126
  }
118
127
 
119
128
  // double existing length
120
- let new_length = length * 2;
129
+ let new_length = length * GROWTH_FACTOR;
121
130
 
122
131
  if (new_length > UINT32_MAX) {
123
132
  // clamp to max uint32 value
@@ -190,41 +199,23 @@ export class Deque {
190
199
  /**
191
200
  *
192
201
  * @param {number} current
193
- * @param {boolean} shift_front should we shift elements before the removed element or after?
194
202
  * @private
195
203
  */
196
- #remove_internal(current, shift_front) {
204
+ #remove_internal_shift_backward(current) {
197
205
  let cursor = current;
198
206
 
199
- if (shift_front) {
200
-
201
- // shift towards tail
202
-
203
- const head = this.#head;
204
-
205
- while (cursor !== head) {
206
- const next = this.#circular_previous_position(cursor);
207
- this.#data[cursor] = this.#data[next];
208
- cursor = next;
209
- }
210
-
211
- this.#head = this.#circular_next_position(head);
212
-
213
- } else {
214
-
215
- // shift towards head
207
+ // shift towards head, this has a better data access pattern than shifting the other way as we're going through the data in forward sequence
216
208
 
217
- const tail = this.#tail;
209
+ const tail = this.#tail;
218
210
 
219
- while (cursor !== tail) {
220
- const next = this.#circular_next_position(cursor);
221
- this.#data[cursor] = this.#data[next];
222
- cursor = next;
223
- }
211
+ while (cursor !== tail) {
212
+ const next = this.#circular_next_position(cursor);
213
+ this.#data[cursor] = this.#data[next];
214
+ cursor = next;
215
+ }
224
216
 
225
- this.#tail = this.#circular_previous_position(tail);
217
+ this.#tail = this.#circular_previous_position(tail);
226
218
 
227
- }
228
219
 
229
220
  // fill in slot of last moved element
230
221
  this.#data[cursor] = undefined;
@@ -244,7 +235,7 @@ export class Deque {
244
235
  return false;
245
236
  }
246
237
 
247
- this.#remove_internal(i, true);
238
+ this.#remove_internal_shift_backward(i);
248
239
 
249
240
  return true;
250
241
  }
@@ -407,11 +398,20 @@ export class Deque {
407
398
  Stack methods
408
399
  */
409
400
 
401
+ /**
402
+ * Stack operation. Alias of {@link Deque.prototype.getFirst}
403
+ */
410
404
  Deque.prototype.peek = Deque.prototype.getFirst;
405
+ /**
406
+ * Stack operation. Alias of {@link Deque.prototype.addFirst}
407
+ */
411
408
  Deque.prototype.push = Deque.prototype.addFirst;
409
+ /**
410
+ * Stack operation. Alias of {@link Deque.prototype.removeFirst}
411
+ */
412
412
  Deque.prototype.pop = Deque.prototype.removeFirst;
413
413
 
414
414
  /**
415
- * Standard queue method
415
+ * Alias of {@link Deque.prototype.addLast}
416
416
  */
417
417
  Deque.prototype.add = Deque.prototype.addLast;
@@ -1 +1 @@
1
- {"version":3,"file":"RowFirstTable.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/table/RowFirstTable.js"],"names":[],"mappings":"AA+BA;;;;GAIG;AACH;IACI;;;;;OAKG;IACH,oDAHW,OAAO,EAiDjB;IAzCG;;;OAGG;IACH,wBAAgB;IAEhB;;;OAGG;IACH,MAFU,WAAW,CAE4D;IAEjF;;;OAGG;IACH,QAFU,MAAM,CAED;IAEf;;;OAGG;IACH,UAFU,MAAM,CAEgB;IAEhC;;;OAGG;IACH,UAFU,QAAQ,CAEqB;IAEvC;;;OAGG;IACH,IAFU;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAOxB;IAIL;;;OAGG;IACH,8BAEC;IAED;;;OAGG;IACH,6BAEC;IAED;;;OAGG;IACH,4BAFqB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAIrD;IAED;;;OAGG;IACH,6BAFqB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAIrD;IAGD;;;;OAIG;IACH,uDAMC;IAED;;;OAGG;IACH,QAFa,MAAM,CA+BlB;IAED;;;OAGG;IACH,sBAFW,MAAM,QAgDhB;IAED;;OAEG;IACH,aAEC;IAED;;;OAGG;IACH,kBAFW,MAAM,QAsBhB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,gBACN,MAAM,SACN,MAAM,QAmBhB;IAED;;;;;OAKG;IACH,yBAJW,MAAM,gBACN,MAAM,GACJ,MAAM,CAmBlB;IAED;;;;OAIG;IACH,kBAHW,MAAM,aACN,MAAM,QAyBhB;IAED;;;;;;OAMG;IACH,kBAHW,MAAM,aACN,MAAM,QAwBhB;IAED;;;;;OAKG;IACH,kBAFY,MAAM,CAYjB;IAED;;;;OAIG;IACH,eAHW,MAAO,MAAM,CAAC,GACZ,MAAM,CAUlB;IAED;;;;OAIG;IACH,eAHW,MAAM,4BA8ChB;IAED;;;;OAIG;IACH,gBAHW,MAAM,UACN,MAAM,QAwBhB;IAED;;;;OAIG;IACH,YAFW,aAAa,QAmBvB;IAED;;;OAGG;IACH,cAHW,aAAa,GACX,OAAO,CAmCnB;IAED;;;;;OAKG;IACH,eAJW,MAAM,WACN,MAAM,EAAE,GACN,MAAM,EAAE,CAUpB;IAED;;;;OAIG;IACH,gBAHW,MAAM,UACN,MAAM,EAAE,QAUlB;IAED;;OAEG;IACH,qBA4BC;IAED;;OAEG;IACH,cAIC;IAED;;;OAGG;IACH,iBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,cAFa,MAAM,EAAE,EAAE,CAetB;IAED;;OAEG;IACH,uBAIC;IAED;;OAEG;IACH,mBAEC;IAGL;;OAEG;IACH,gBAtHe,MAAM,WACN,MAAM,EAAE,KACN,MAAM,EAAE,CAoHK;IAC9B;;OAEG;IACH,gBA1Ge,MAAM,UACN,MAAM,EAAE,UAyGO;CAT7B;mBAhpBkB,+BAA+B"}
1
+ {"version":3,"file":"RowFirstTable.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/table/RowFirstTable.js"],"names":[],"mappings":"AA+BA;;;;GAIG;AACH;IACI;;;;;OAKG;IACH,oDAHW,OAAO,EAiDjB;IAzCG;;;OAGG;IACH,wBAAgB;IAEhB;;;OAGG;IACH,MAFU,WAAW,CAE4D;IAEjF;;;OAGG;IACH,QAFU,MAAM,CAED;IAEf;;;OAGG;IACH,UAFU,MAAM,CAEgB;IAEhC;;;OAGG;IACH,UAFU,QAAQ,CAEqB;IAEvC;;;OAGG;IACH,IAFU;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAOxB;IAIL;;;OAGG;IACH,8BAEC;IAED;;;OAGG;IACH,6BAEC;IAED;;;OAGG;IACH,4BAFqB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAIrD;IAED;;;OAGG;IACH,6BAFqB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAIrD;IAGD;;;;OAIG;IACH,uDAMC;IAED;;;OAGG;IACH,QAFa,MAAM,CA+BlB;IAED;;;OAGG;IACH,sBAFW,MAAM,QAgDhB;IAED;;OAEG;IACH,aAEC;IAED;;;OAGG;IACH,kBAFW,MAAM,QAsBhB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,gBACN,MAAM,SACN,MAAM,QAmBhB;IAED;;;;;OAKG;IACH,yBAJW,MAAM,gBACN,MAAM,GACJ,MAAM,CAmBlB;IAED;;;;OAIG;IACH,kBAHW,MAAM,aACN,MAAM,QAyBhB;IAED;;;;;;OAMG;IACH,kBAHW,MAAM,aACN,MAAM,QAwBhB;IAED;;;;;OAKG;IACH,kBAFY,MAAM,CAYjB;IAED;;;;OAIG;IACH,eAHW,MAAO,MAAM,CAAC,GACZ,MAAM,CAYlB;IAED;;;;OAIG;IACH,eAHW,MAAM,4BA8ChB;IAED;;;;OAIG;IACH,gBAHW,MAAM,UACN,MAAM,QAwBhB;IAED;;;;OAIG;IACH,YAFW,aAAa,QAmBvB;IAED;;;OAGG;IACH,cAHW,aAAa,GACX,OAAO,CAmCnB;IAED;;;;;OAKG;IACH,eAJW,MAAM,WACN,MAAM,EAAE,GACN,MAAM,EAAE,CAUpB;IAED;;;;OAIG;IACH,gBAHW,MAAM,UACN,MAAM,EAAE,QAUlB;IAED;;OAEG;IACH,qBA4BC;IAED;;OAEG;IACH,cAIC;IAED;;;OAGG;IACH,iBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,cAFa,MAAM,EAAE,EAAE,CAetB;IAED;;OAEG;IACH,uBAIC;IAED;;OAEG;IACH,mBAEC;IAGL;;OAEG;IACH,gBAtHe,MAAM,WACN,MAAM,EAAE,KACN,MAAM,EAAE,CAoHK;IAC9B;;OAEG;IACH,gBA1Ge,MAAM,UACN,MAAM,EAAE,UAyGO;CAT7B;mBAlpBkB,+BAA+B"}
@@ -390,6 +390,8 @@ export class RowFirstTable {
390
390
  * @returns {number} index of newly added row
391
391
  */
392
392
  addRow(values) {
393
+ assert.isArrayLike(values, 'values');
394
+
393
395
  const rowIndex = this.createEmptyRow();
394
396
 
395
397
  this.spec.writeRowMethod(this.dataView, this.spec.bytesPerRecord * rowIndex, values);
@@ -152,9 +152,9 @@ export class Color {
152
152
 
153
153
  /**
154
154
  *
155
- * @param {number} r
156
- * @param {number} g
157
- * @param {number} b
155
+ * @param {number} r [0..255]
156
+ * @param {number} g [0..255]
157
+ * @param {number} b [0..255]
158
158
  */
159
159
  setRGBUint8(r, g, b) {
160
160
  this.setRGB(
@@ -1 +1 @@
1
- {"version":3,"file":"rgb_to_kelvin.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/kelvin/rgb_to_kelvin.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,qCAHW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC;IAAC,CAAC,EAAC,MAAM,CAAC;IAAA,CAAC,EAAC,MAAM,CAAC;IAAA,CAAC,EAAC,MAAM,CAAA;CAAC,iBACvD,MAAM,UAyBhB"}
1
+ {"version":3,"file":"rgb_to_kelvin.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/kelvin/rgb_to_kelvin.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,qCAHW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC;IAAC,CAAC,EAAC,MAAM,CAAC;IAAA,CAAC,EAAC,MAAM,CAAC;IAAA,CAAC,EAAC,MAAM,CAAA;CAAC,iBACvD,MAAM,UAkChB"}
@@ -13,16 +13,25 @@ export function rgb_to_kelvin(input, input_offset = 0) {
13
13
  const g = input[input_offset + 1];
14
14
  const b = input[input_offset + 2];
15
15
 
16
+ const blue_red_ratio = b / r;
17
+
16
18
  // use solver to reverse function, slow but hey - it works
17
- var temperature;
18
- var epsilon=0.4;
19
- var minTemperature = 1000;
20
- var maxTemperature = 40000;
19
+ let temperature;
20
+
21
+ const epsilon = 0.4;
22
+
23
+ let minTemperature = 1000;
24
+ let maxTemperature = 40000;
21
25
 
22
26
  while (maxTemperature - minTemperature > epsilon) {
23
- temperature = (maxTemperature + minTemperature) / 2;
24
- kelvin_to_rgb(scratch_rgb,0,temperature);
25
- if ((scratch_rgb[2] / scratch_rgb[0]) >= (b / r)) {
27
+
28
+ temperature = (maxTemperature + minTemperature) * 0.5;
29
+
30
+ kelvin_to_rgb(scratch_rgb, 0, temperature);
31
+
32
+ const br = scratch_rgb[2] / scratch_rgb[0];
33
+
34
+ if (br >= blue_red_ratio) {
26
35
  maxTemperature = temperature;
27
36
  } else {
28
37
  minTemperature = temperature;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tetrahedral_mesh_find_tets_attached_to_vertex.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,sEANW,MAAM,EAAE,iBACR,MAAM,uCAEN,MAAM,GACJ,MAAM,CAyBlB"}