@woosh/meep-engine 2.128.5 → 2.128.8

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 (28) hide show
  1. package/package.json +1 -1
  2. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts +8 -0
  3. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts.map +1 -1
  4. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +9 -1
  5. package/src/core/cache/Cache.d.ts +7 -1
  6. package/src/core/cache/Cache.d.ts.map +1 -1
  7. package/src/core/cache/Cache.js +26 -13
  8. package/src/core/collection/array/array_shuffle.d.ts +3 -3
  9. package/src/core/collection/array/array_shuffle.d.ts.map +1 -1
  10. package/src/core/collection/array/array_shuffle.js +2 -2
  11. package/src/core/collection/array/array_swap.d.ts +13 -0
  12. package/src/core/collection/array/array_swap.d.ts.map +1 -1
  13. package/src/core/collection/array/array_swap.js +17 -0
  14. package/src/core/collection/array/array_swap_one.d.ts +3 -0
  15. package/src/core/collection/array/array_swap_one.d.ts.map +1 -1
  16. package/src/core/collection/array/array_swap_one.js +3 -0
  17. package/src/engine/graphics/render/frame_graph/RenderGraph.d.ts.map +1 -1
  18. package/src/engine/graphics/render/frame_graph/RenderGraph.js +0 -1
  19. package/src/engine/graphics/render/frame_graph/backend/void/VoidRenderContext.d.ts +1 -1
  20. package/src/engine/graphics/render/frame_graph/backend/void/VoidRenderContext.js +1 -1
  21. package/src/engine/graphics/render/frame_graph/resource/ResourceDescriptor.d.ts +6 -0
  22. package/src/engine/graphics/render/frame_graph/resource/ResourceDescriptor.d.ts.map +1 -1
  23. package/src/engine/graphics/render/frame_graph/resource/ResourceDescriptor.js +10 -0
  24. package/src/engine/reference/v2/Reference.d.ts +5 -1
  25. package/src/engine/reference/v2/Reference.d.ts.map +1 -1
  26. package/src/engine/reference/v2/Reference.js +24 -0
  27. package/src/view/common/VirtualListView.d.ts +1 -1
  28. package/src/view/common/VirtualListView.d.ts.map +1 -1
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Pure JavaScript game engine. Fully featured and production ready.",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.128.5",
8
+ "version": "2.128.8",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -14,6 +14,14 @@ export const BVH_BINARY_NODE_SIZE: number;
14
14
  * @type {number}
15
15
  */
16
16
  export const BVH_LEAF_NODE_SIZE: number;
17
+ /**
18
+ * Memory-efficient LBVH implementation.
19
+ * LBVH is fast to build, is quite fast to query and has good memory usage due to implicit addressing.
20
+ * LBVH is static, so it's not suitable for dynamic usecases, if your usecase requires updates to the BVH - use {@link BVH} instead, which is a fully dynamic BVH implementation.
21
+ *
22
+ * @see https://en.wikipedia.org/wiki/Bounding_volume_hierarchy
23
+ * @see BVH
24
+ */
17
25
  export class BinaryUint32BVH {
18
26
  /**
19
27
  *
@@ -1 +1 @@
1
- {"version":3,"file":"BinaryUint32BVH.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/binary/2/BinaryUint32BVH.js"],"names":[],"mappings":"AAUA;;;GAGG;AACH,gCAFU,MAAM,CAEmB;AAEnC;;;;GAIG;AACH,mCAFU,MAAM,CAEsB;AACtC;;;GAGG;AACH,iCAFU,MAAM,CAEoB;AAiDpC;IACI;;;;OAIG;IACH,sBAAc;IAEd;;;;OAIG;IACH,gCAAe;IAEf;;;;OAIG;IACH,+BAAc;IAEd;;;;OAIG;IACH,4BAAwB;IAExB;;;;OAIG;IACH,0BAAsB;IA0CtB;;;OAGG;IACH,2BAOC;IAED,wBAEC;IAnDD;;;OAGG;IACH,oBAFa,MAAM,CAIlB;IAED,2BAEC;IAED,gCAEC;IAED,8BAEC;IAED;;;OAGG;IACH,uBAFa,MAAM,CAIlB;IAED,4BAEC;IAED,0BAEC;IAmBD;;;;OAIG;IACH,2BAHW,MAAM,GACJ,MAAM,CAalB;IAED,6BASC;IAED;;;OAGG;IACH,oBAFW,MAAM,QAgBhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,GACL,MAAM,CASjB;IAED;;;;;;;;;;OAUG;IACH,mBATW,MAAM,WACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAoChB;IAED;;;;;OAKG;IACH,oBAJW,MAAM,eACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,QAIhB;IAED;;;;OAIG;IACH,4BAHW,MAAM,GACJ,MAAM,CAQlB;IAED,qCAoBC;IAED;;;OAGG;IACH,oBAFW,MAAM,EAAE,QAqElB;IAED;;;;;OAKG;IACH,sBAUC;IAED;;OAEG;IACH,cAsEC;CACJ"}
1
+ {"version":3,"file":"BinaryUint32BVH.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/binary/2/BinaryUint32BVH.js"],"names":[],"mappings":"AAUA;;;GAGG;AACH,gCAFU,MAAM,CAEmB;AAEnC;;;;GAIG;AACH,mCAFU,MAAM,CAEsB;AACtC;;;GAGG;AACH,iCAFU,MAAM,CAEoB;AAiDpC;;;;;;;GAOG;AACH;IACI;;;;OAIG;IACH,sBAAc;IAEd;;;;OAIG;IACH,gCAAe;IAEf;;;;OAIG;IACH,+BAAc;IAEd;;;;OAIG;IACH,4BAAwB;IAExB;;;;OAIG;IACH,0BAAsB;IA0CtB;;;OAGG;IACH,2BAOC;IAED,wBAEC;IAnDD;;;OAGG;IACH,oBAFa,MAAM,CAIlB;IAED,2BAEC;IAED,gCAEC;IAED,8BAEC;IAED;;;OAGG;IACH,uBAFa,MAAM,CAIlB;IAED,4BAEC;IAED,0BAEC;IAmBD;;;;OAIG;IACH,2BAHW,MAAM,GACJ,MAAM,CAalB;IAED,6BASC;IAED;;;OAGG;IACH,oBAFW,MAAM,QAgBhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,GACL,MAAM,CASjB;IAED;;;;;;;;;;OAUG;IACH,mBATW,MAAM,WACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAoChB;IAED;;;;;OAKG;IACH,oBAJW,MAAM,eACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,QAIhB;IAED;;;;OAIG;IACH,4BAHW,MAAM,GACJ,MAAM,CAQlB;IAED,qCAoBC;IAED;;;OAGG;IACH,oBAFW,MAAM,EAAE,QAqElB;IAED;;;;;OAKG;IACH,sBAUC;IAED;;OAEG;IACH,cAsEC;CACJ"}
@@ -73,6 +73,14 @@ function build_morton(data, address, bounds) {
73
73
 
74
74
  const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
75
75
 
76
+ /**
77
+ * Memory-efficient LBVH implementation.
78
+ * LBVH is fast to build, is quite fast to query and has good memory usage due to implicit addressing.
79
+ * LBVH is static, so it's not suitable for dynamic usecases, if your usecase requires updates to the BVH - use {@link BVH} instead, which is a fully dynamic BVH implementation.
80
+ *
81
+ * @see https://en.wikipedia.org/wiki/Bounding_volume_hierarchy
82
+ * @see BVH
83
+ */
76
84
  export class BinaryUint32BVH {
77
85
  /**
78
86
  *
@@ -423,7 +431,7 @@ export class BinaryUint32BVH {
423
431
  let level = Math.floor(Math.log(binary_node_count) / Math.log(2));
424
432
 
425
433
  let i, offset, level_node_count;
426
- //NOTE: building first level separately allows to avoid some switching logic needed to determine what is the type of lower level node
434
+ //NOTE: building the first level separately allows us to avoid some switching logic needed to determine what is the type of lower level node
427
435
  //build one level above leaf nodes
428
436
  level_node_count = Math.pow(2, level);
429
437
  offset = (level_node_count - 1) * BVH_BINARY_NODE_SIZE;
@@ -1,6 +1,11 @@
1
1
  import Signal from "../events/signal/Signal";
2
2
 
3
- export class Cache<K, V> extends Map<K,V>{
3
+ interface Hashable {
4
+ hash(): number
5
+ equals(other: any): boolean
6
+ }
7
+
8
+ export class Cache<K extends Hashable, V> extends Map<K,V>{
4
9
  constructor({
5
10
  maxWeight,
6
11
  keyWeigher,
@@ -19,6 +24,7 @@ export class Cache<K, V> extends Map<K,V>{
19
24
 
20
25
  readonly onEvicted: Signal<K, V>
21
26
  readonly onRemoved: Signal<K, V>
27
+ readonly onSet: Signal<K, V>
22
28
 
23
29
  readonly weight: number
24
30
 
@@ -1 +1 @@
1
- {"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../../../src/core/cache/Cache.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IASI;;;;;;;;OAQG;IACH,sGARW,MAAM,EA2FhB;IAzDG;;;;OAIG;IACH,mBAA4B;IAE5B;;;;OAIG;IACH,qBAAgC;IAEhC;;;;OAIG;IACH,gBAAmB;IACnB;;;;OAIG;IACH,eAAkB;IAGlB;;;;OAIG;IACH,aAIE;IAEF;;;;OAIG;IACH,WAFU,OAAO,GAAG,EAAC,KAAK,CAAC,CAEE;IAE7B;;;OAGG;IACH,WAFU,OAAO,GAAG,EAAC,KAAK,CAAC,CAEE;IAE7B;;;OAGG;IACH,OAFU,OAAO,GAAG,EAAC,KAAK,CAAC,CAEF;IAG7B;;;;;OAKG;IACH,kBAyBC;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;OAEG;IACH,+BAEC;IAED;;;OAGG;IACH,qBAEC;IAED;;;OAGG;IACH,2BAeC;IAED,wBAEC;IAED;;;;OAIG;IACH,wBAaC;IAED;;;;;;OAMG;IACH,yBAHW,GAAG,GACD,OAAO,CAgCnB;IAED;;;;;OAKG;IACH,6BAUC;IAED;;;OAGG;IACH,sBAFa,aAAa,GAAG,EAAC,KAAK,CAAC,GAAC,IAAI,CAIxC;IAED;;;OAGG;IACH,YAFa,OAAO,CAkBnB;IAED;;;OAGG;IACH,+BAFW,MAAM,QAWhB;IAED;;;;OAIG;IACH,SAHW,GAAG,SACH,KAAK,QAwEf;IAED;;;;OAIG;IACH,cAHW,GAAG,GACD,OAAO,CAInB;IAED;;;;OAIG;IACH,SAHW,GAAG,GACD,KAAK,GAAC,IAAI,CAYtB;IAGD;;;;;;OAMG;IACH,kBALW,GAAG,kBACM,GAAG,KAAE,KAAK,0BAElB,KAAK,CAchB;IAED;;;;OAIG;IACH,wBAqBC;IAED;;;;OAIG;IACH,YAHW,GAAG,GACD,OAAO,CAgBnB;IAED;;;;;OAKG;IACH,kBAHW,GAAG,GACD,OAAO,CAanB;IAED;;OAEG;IACH,cAcC;IAED;;;OAGG;IACH,aAOC;IAED;;;;;OAKG;IACH,wCAFa,OAAO,CAMnB;IAGL;;;OAGG;IACH,6CAAmB;IAEnB;;;OAGG;IACH,+BA5FiB,OAAO,CA4FF;IAEtB;;;OAGG;IACH,4BA9KiB,OAAO,CA8KL;;CAlBlB;mBAzjBkB,4BAA4B;6BAKlB,mBAAmB"}
1
+ {"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../../../src/core/cache/Cache.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAgBI;;;;;;;;;;OAUG;IACH,sGARW,MAAM,EA2FhB;IAzDG;;;;OAIG;IACH,mBAA4B;IAE5B;;;;OAIG;IACH,qBAAgC;IAEhC;;;;OAIG;IACH,gBAAmB;IACnB;;;;OAIG;IACH,eAAkB;IAGlB;;;;OAIG;IACH,aAIE;IAEF;;;;OAIG;IACH,WAFU,OAAO,GAAG,EAAC,KAAK,CAAC,CAEE;IAE7B;;;OAGG;IACH,WAFU,OAAO,GAAG,EAAC,KAAK,CAAC,CAEE;IAE7B;;;OAGG;IACH,OAFU,OAAO,GAAG,EAAC,KAAK,CAAC,CAEF;IAG7B;;;;;OAKG;IACH,kBAyBC;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;OAEG;IACH,+BAEC;IAED;;;;;OAKG;IACH,qBAEC;IAED;;;OAGG;IACH,2BAeC;IAED,wBAEC;IAED;;;;OAIG;IACH,wBAaC;IAED;;;;;;OAMG;IACH,yBAHW,GAAG,GACD,OAAO,CAgCnB;IAED;;;;;OAKG;IACH,6BAUC;IAED;;;OAGG;IACH,sBAFa,aAAa,GAAG,EAAC,KAAK,CAAC,GAAC,IAAI,CAIxC;IAED;;;OAGG;IACH,YAFa,OAAO,CAkBnB;IAED;;;OAGG;IACH,gCAFW,MAAM,QAWhB;IAED;;;;OAIG;IACH,SAHW,GAAG,SACH,KAAK,QAwEf;IAED;;;;OAIG;IACH,cAHW,GAAG,GACD,OAAO,CAInB;IAED;;;;OAIG;IACH,SAHW,GAAG,GACD,KAAK,GAAC,IAAI,CAYtB;IAGD;;;;;;OAMG;IACH,kBALW,GAAG,kBACM,GAAG,KAAE,KAAK,0BAElB,KAAK,CAchB;IAED;;;;OAIG;IACH,wBAqBC;IAED;;;;OAIG;IACH,YAHW,GAAG,GACD,OAAO,CAgBnB;IAED;;;;;OAKG;IACH,kBAHW,GAAG,GACD,OAAO,CAanB;IAED;;;;OAIG;IACH,cAcC;IAED;;;OAGG;IACH,aAOC;IAED;;;;;OAKG;IACH,wCAFa,OAAO,CAMnB;IAGL;;;OAGG;IACH,6CAAmB;IAEnB;;;OAGG;IACH,+BA9FiB,OAAO,CA8FF;IAEtB;;;OAGG;IACH,4BAhLiB,OAAO,CAgLL;;CAlBlB;mBAtkBkB,4BAA4B;6BAKlB,mBAAmB"}
@@ -29,7 +29,14 @@ import { CacheElement } from "./CacheElement.js";
29
29
  * @copyright Company Named Limited (c) 2025
30
30
  */
31
31
  export class Cache {
32
+
33
+ /**
34
+ * How much "weight" can the cache hold before it starts evicting elements
35
+ * @type {number}
36
+ * @private
37
+ */
32
38
  #maxWeight = Number.POSITIVE_INFINITY;
39
+
33
40
  /**
34
41
  *
35
42
  * @type {number}
@@ -38,6 +45,8 @@ export class Cache {
38
45
  #weight = 0;
39
46
 
40
47
  /**
48
+ * Note: setting {@link maxWeight} to 0 is pointless, as the cache will not be able to hold even a single element.
49
+ *
41
50
  * @param {number} [maxWeight=Number.POSITIVE_INFINITY] capacity of the cache, measure in "weight"; The weight is computed by summing key and value weights.
42
51
  * @param {function(key:Key):number} [keyWeigher= key=>0] function to compute weight of a key
43
52
  * @param {function(value:Value):number} [valueWeigher= value=>1] function to compute weight of a value
@@ -180,7 +189,9 @@ export class Cache {
180
189
  }
181
190
 
182
191
  /**
183
- * Total weight of all elements currently in the cache
192
+ * Total weight of all elements currently in the cache.
193
+ * This is guaranteed to be less than or equal to {@link maxWeight}
194
+ *
184
195
  * @returns {number}
185
196
  */
186
197
  get weight() {
@@ -188,7 +199,7 @@ export class Cache {
188
199
  }
189
200
 
190
201
  /**
191
- * Will cause evictions if current weight is smaller than what we're setting
202
+ * Will cause evictions if the current weight is greater than what we're setting
192
203
  * @param {number} weight
193
204
  */
194
205
  set maxWeight(weight) {
@@ -234,7 +245,7 @@ export class Cache {
234
245
 
235
246
  /**
236
247
  * Useful when working with wrapped value types, where contents can change and affect overall weight
237
- * Instead of re-inserting element, we can just update weights
248
+ * Instead of re-inserting the element, we can just update weights
238
249
  * NOTE: this method may trigger eviction
239
250
  * @param {Key} key
240
251
  * @returns {boolean} true when weight successfully updated, false if element was not found in cache
@@ -299,7 +310,7 @@ export class Cache {
299
310
 
300
311
  /**
301
312
  * Evicts a single element from the cache
302
- * @returns {boolean} true if element was evicted, false otherwise
313
+ * @returns {boolean} true if an element was evicted, false otherwise
303
314
  */
304
315
  evictOne() {
305
316
  //find a victim
@@ -320,14 +331,14 @@ export class Cache {
320
331
  }
321
332
 
322
333
  /**
323
- * Drop data until weight reduces lower or equal to requested weight
324
- * @param {number} targetWeight
334
+ * Drop data until the weight reduces to lower or equal to the requested weight
335
+ * @param {number} target_weight
325
336
  */
326
- evictUntilWeight(targetWeight) {
327
- assert.isNumber(targetWeight, 'targetWeight');
328
- assert.notNaN(targetWeight, 'targetWeight');
337
+ evictUntilWeight(target_weight) {
338
+ assert.isNumber(target_weight, 'target_weight');
339
+ assert.notNaN(target_weight, 'target_weight');
329
340
 
330
- const target = Math.max(targetWeight, 0);
341
+ const target = Math.max(target_weight, 0);
331
342
 
332
343
  while (this.#weight > target) {
333
344
  this.evictOne();
@@ -355,7 +366,7 @@ export class Cache {
355
366
 
356
367
  if (weightTarget < 0) {
357
368
  // Special case
358
- // element does not fit into cache, attempting to insert it forcibly would result in a full flush and overflow
369
+ // element does not fit into the cache, attempting to insert it forcibly would result in a full flush and overflow
359
370
  return;
360
371
  }
361
372
 
@@ -512,7 +523,7 @@ export class Cache {
512
523
  * Remove without triggering {@link #onRemoved}
513
524
  * NOTE: please be sure you understand what you're doing when you use this method
514
525
  * @param {Key} key
515
- * @returns {boolean} true if element was removed, false otherwise
526
+ * @returns {boolean} true if the element was removed, false otherwise
516
527
  */
517
528
  silentRemove(key) {
518
529
  const element = this.data.get(key);
@@ -528,7 +539,9 @@ export class Cache {
528
539
  }
529
540
 
530
541
  /**
531
- * Remove all elements from the cache
542
+ * Remove all elements from the cache.
543
+ * Triggers {@link #onRemoved} for each removed element.
544
+ *
532
545
  */
533
546
  clear() {
534
547
  /**
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Randomly re-orders items in-place
3
3
  * @template T
4
- * @param {function} random
5
- * @param {T[]} array
4
+ * @param {function():number} random random number generator; can use Math.random. Must return a value between 0 and 1
5
+ * @param {T[]} array what to shuffle
6
6
  */
7
- export function array_shuffle<T>(random: Function, array: T[]): void;
7
+ export function array_shuffle<T>(random: () => number, array: T[]): void;
8
8
  //# sourceMappingURL=array_shuffle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"array_shuffle.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_shuffle.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,qEAYC"}
1
+ {"version":3,"file":"array_shuffle.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_shuffle.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,+CAHsB,MAAM,oBAe3B"}
@@ -4,8 +4,8 @@ import { array_swap_one } from "./array_swap_one.js";
4
4
  /**
5
5
  * Randomly re-orders items in-place
6
6
  * @template T
7
- * @param {function} random
8
- * @param {T[]} array
7
+ * @param {function():number} random random number generator; can use Math.random. Must return a value between 0 and 1
8
+ * @param {T[]} array what to shuffle
9
9
  */
10
10
  export function array_shuffle(random, array) {
11
11
  const n = array.length;
@@ -1,10 +1,23 @@
1
1
  /**
2
+ * Swap two sections between arrays, can be used to move elements in the same array
2
3
  * @template T
3
4
  * @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array|Uint32Array|Float32Array} a
4
5
  * @param {number} a_offset
5
6
  * @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array|Uint32Array|Float32Array} b
6
7
  * @param {number} b_offset
7
8
  * @param {number} length How many elements should be moved
9
+ * @returns {void}
10
+ *
11
+ * @example
12
+ * const array = [1, 2, 3, 4, 5];
13
+ * array_swap(array, 0, array, 2, 1); // array === [4, 2, 3, 1, 5]
14
+ * @example
15
+ * const array_a = ["hello", "world"];
16
+ * const array_b = ["foo", "bar"];
17
+ * array_swap(array_a, 1, array_b, 0, 1); // array_a === ["hello", "foo"], array_b === ["world", "bar"]
18
+ * @example
19
+ * const array = [1, 2, 3, 4, 5];
20
+ * array_swap(array, 0, array, 2, 2); // array === [3, 4, 1, 2, 5]
8
21
  */
9
22
  export function array_swap<T>(a: any, a_offset: number, b: any, b_offset: number, length: number): void;
10
23
  //# sourceMappingURL=array_swap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"array_swap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_swap.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,gDALW,MAAM,oBAEN,MAAM,UACN,MAAM,QAkBhB"}
1
+ {"version":3,"file":"array_swap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_swap.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,gDAjBW,MAAM,oBAEN,MAAM,UACN,MAAM,GACJ,IAAI,CA+BhB"}
@@ -1,16 +1,33 @@
1
+ import { assert } from "../../assert.js";
2
+
1
3
  /**
4
+ * Swap two sections between arrays, can be used to move elements in the same array
2
5
  * @template T
3
6
  * @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array|Uint32Array|Float32Array} a
4
7
  * @param {number} a_offset
5
8
  * @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array|Uint32Array|Float32Array} b
6
9
  * @param {number} b_offset
7
10
  * @param {number} length How many elements should be moved
11
+ * @returns {void}
12
+ *
13
+ * @example
14
+ * const array = [1, 2, 3, 4, 5];
15
+ * array_swap(array, 0, array, 2, 1); // array === [4, 2, 3, 1, 5]
16
+ * @example
17
+ * const array_a = ["hello", "world"];
18
+ * const array_b = ["foo", "bar"];
19
+ * array_swap(array_a, 1, array_b, 0, 1); // array_a === ["hello", "foo"], array_b === ["world", "bar"]
20
+ * @example
21
+ * const array = [1, 2, 3, 4, 5];
22
+ * array_swap(array, 0, array, 2, 2); // array === [3, 4, 1, 2, 5]
8
23
  */
9
24
  export function array_swap(
10
25
  a, a_offset,
11
26
  b, b_offset,
12
27
  length
13
28
  ) {
29
+ assert.isNonNegativeInteger(a_offset, 'a_offset');
30
+ assert.isNonNegativeInteger(b_offset, 'b_offset');
14
31
 
15
32
  for (let k = 0; k < length; k++) {
16
33
  const i = a_offset + k;
@@ -1,8 +1,11 @@
1
1
  /**
2
+ * Swaps two elements in the array
2
3
  * @template T
3
4
  * @param {T[]} array
4
5
  * @param {number} index0
5
6
  * @param {number} index1
7
+ * @returns {void}
8
+ * @see array_swap
6
9
  */
7
10
  export function array_swap_one<T>(array: T[], index0: number, index1: number): void;
8
11
  //# sourceMappingURL=array_swap_one.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"array_swap_one.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_swap_one.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,sDAHW,MAAM,UACN,MAAM,QAWhB"}
1
+ {"version":3,"file":"array_swap_one.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_swap_one.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,sDALW,MAAM,UACN,MAAM,GACJ,IAAI,CAYhB"}
@@ -1,10 +1,13 @@
1
1
  import { assert } from "../../assert.js";
2
2
 
3
3
  /**
4
+ * Swaps two elements in the array
4
5
  * @template T
5
6
  * @param {T[]} array
6
7
  * @param {number} index0
7
8
  * @param {number} index1
9
+ * @returns {void}
10
+ * @see array_swap
8
11
  */
9
12
  export function array_swap_one(array, index0, index1) {
10
13
  assert.isArrayLike(array, 'array');
@@ -1 +1 @@
1
- {"version":3,"file":"RenderGraph.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/frame_graph/RenderGraph.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH;IA6BI;;;OAGG;IACH,mBAFW,MAAM,EAOhB;IArCD;;;;OAIG;IACH,MAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,qBAAkB;IAElB;;;;OAIG;IACH,yBAAsB;IAEtB;;;;OAIG;IACH,4BAAyB;IAazB;;;;OAIG;IACH,qBAHW,MAAM,sBAahB;IAED;;;;OAIG;IACH,oBAHW,MAAM,qBAmBhB;IAED;;;;OAIG;IACH,qBAHW,MAAM,KAKhB;IAED;;;;;OAKG;IACH,2BAJW,MAAM,oBAEJ,MAAM,CAWlB;IAED;;;;;OAKG;IACH,6BAYC;IAED;;;;;;OAMG;IACH,4BAeC;IAED;;;;OAIG;IACH,wBAHW,MAAM,GACJ,MAAM,CAkBlB;IAED;;;;;;OAMG;IACH,2BALW,MAAM,wDAGJ,MAAM,CAUlB;IAED;;;OAGG;IACH,4BAHa,OAAO,CAQnB;IAED;;;;;;;OAOG;IACH,eALW,MAAM,4BAGJ,iBAAiB,CA2B7B;IAED;;;;;;OAMG;IACH,iEAFa,OAAO,CAQnB;IAED,gBA6FC;IAED;;;OAGG;IACH,uCA2CC;IAED;;;;;;;OAOG;IACH;gBAFqB,EAAE;mBAAa,EAAE;MA2DrC;IAED;;;;;OAKG;IACH,eAFY,MAAM,CAiEjB;IAGL;;;OAGG;IACH,wBAFU,OAAO,CAEkB;CANlC;8BAvjB6B,oBAAoB;6BACrB,mBAAmB;kCAJd,wBAAwB"}
1
+ {"version":3,"file":"RenderGraph.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/frame_graph/RenderGraph.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH;IA6BI;;;OAGG;IACH,mBAFW,MAAM,EAOhB;IArCD;;;;OAIG;IACH,MAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,qBAAkB;IAElB;;;;OAIG;IACH,yBAAsB;IAEtB;;;;OAIG;IACH,4BAAyB;IAazB;;;;OAIG;IACH,qBAHW,MAAM,sBAahB;IAED;;;;OAIG;IACH,oBAHW,MAAM,qBAmBhB;IAED;;;;OAIG;IACH,qBAHW,MAAM,KAKhB;IAED;;;;;OAKG;IACH,2BAJW,MAAM,oBAEJ,MAAM,CAWlB;IAED;;;;;OAKG;IACH,6BAYC;IAED;;;;;;OAMG;IACH,4BAeC;IAED;;;;OAIG;IACH,wBAHW,MAAM,GACJ,MAAM,CAkBlB;IAED;;;;;;OAMG;IACH,2BALW,MAAM,wDAGJ,MAAM,CAUlB;IAED;;;OAGG;IACH,4BAHa,OAAO,CAQnB;IAED;;;;;;;OAOG;IACH,eALW,MAAM,4BAGJ,iBAAiB,CA2B7B;IAED;;;;;;OAMG;IACH,iEAFa,OAAO,CAQnB;IAED,gBA6FC;IAED;;;OAGG;IACH,uCA2CC;IAED;;;;;;;OAOG;IACH;gBAFqB,EAAE;mBAAa,EAAE;MA2DrC;IAED;;;;;OAKG;IACH,eAFY,MAAM,CAgEjB;IAGL;;;OAGG;IACH,wBAFU,OAAO,CAEkB;CANlC;8BAtjB6B,oBAAoB;6BACrB,mBAAmB;kCAJd,wBAAwB"}
@@ -565,7 +565,6 @@ export class RenderGraph {
565
565
  out.dedent();
566
566
  out.add("} [color=olivedrab3]");
567
567
  }
568
- // -- Clusters:
569
568
  out.dedent();
570
569
  out.add("}");
571
570
  return out.build();
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Doesn't actually do anything, but works as a valid rendering context
3
- * Mainly used for testing
3
+ * Mainly useful for testing
4
4
  */
5
5
  export class VoidRenderContext extends IRenderContext {
6
6
  static INSTANCE: VoidRenderContext;
@@ -2,7 +2,7 @@ import { IRenderContext } from "../../IRenderContext.js";
2
2
 
3
3
  /**
4
4
  * Doesn't actually do anything, but works as a valid rendering context
5
- * Mainly used for testing
5
+ * Mainly useful for testing
6
6
  */
7
7
  export class VoidRenderContext extends IRenderContext {
8
8
  createResource(descriptor) {
@@ -20,6 +20,12 @@ export class ResourceDescriptor {
20
20
  * @returns {boolean}
21
21
  */
22
22
  equals<T>(other: T): boolean;
23
+ /**
24
+ *
25
+ * @param {ResourceDescriptor} other
26
+ * @return {number}
27
+ */
28
+ compare(other: ResourceDescriptor): number;
23
29
  toString(): string;
24
30
  }
25
31
  //# sourceMappingURL=ResourceDescriptor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ResourceDescriptor.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/render/frame_graph/resource/ResourceDescriptor.js"],"names":[],"mappings":"AAAA;;GAEG;AACH;IAEI;;;;OAIG;IACH,mBAEC;IAED;;;OAGG;IACH,oCAEC;IAGD,eAEC;IAED;;;;OAIG;IACH,qBAFa,OAAO,CAInB;IAED,mBAEC;CACJ"}
1
+ {"version":3,"file":"ResourceDescriptor.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/render/frame_graph/resource/ResourceDescriptor.js"],"names":[],"mappings":"AAAA;;GAEG;AACH;IAEI;;;;OAIG;IACH,mBAEC;IAED;;;OAGG;IACH,oCAEC;IAGD,eAEC;IAED;;;;OAIG;IACH,qBAFa,OAAO,CAInB;IAGD;;;;OAIG;IACH,eAHW,kBAAkB,GACjB,MAAM,CAIjB;IAED,mBAEC;CACJ"}
@@ -34,6 +34,16 @@ export class ResourceDescriptor {
34
34
  return this.type === other.type;
35
35
  }
36
36
 
37
+
38
+ /**
39
+ *
40
+ * @param {ResourceDescriptor} other
41
+ * @return {number}
42
+ */
43
+ compare(other) {
44
+ return this.type.localeCompare(other.type);
45
+ }
46
+
37
47
  toString(){
38
48
  return this.type;
39
49
  }
@@ -1,7 +1,7 @@
1
1
  import Signal from "../../../core/events/signal/Signal";
2
2
 
3
3
  export class Reference<T> {
4
- readonly onReleased: Signal<Reference<T>, T>
4
+ readonly onReleased: Signal<this, T>
5
5
 
6
6
  readonly bound: boolean
7
7
 
@@ -10,4 +10,8 @@ export class Reference<T> {
10
10
  release(): void
11
11
 
12
12
  bind(v: T): void
13
+
14
+ static from<X>(x: X): Reference<X>
15
+
16
+ static readonly NULL: Readonly<Reference<any>>
13
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Reference.d.ts","sourceRoot":"","sources":["../../../../../src/engine/reference/v2/Reference.js"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH;IAwBI,qBAEC;IAED;;;OAGG;IACH,gEAEC;IAED;;;OAGG;IACH,YAFW,CAAC,QAcX;IAED;;;OAGG;IACH,YAFa,CAAC,CAIb;IAED;;;OAGG;IACH,gBAcC;;CACJ;;cAKS,wBAAmB;;mBAlGV,uCAAuC"}
1
+ {"version":3,"file":"Reference.d.ts","sourceRoot":"","sources":["../../../../../src/engine/reference/v2/Reference.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH;IAoCI;;;;;;;;OAQG;IACH,mCAMC;IA3BD,qBAEC;IAED;;;OAGG;IACH,gEAEC;IAmBD;;;OAGG;IACH,YAFW,CAAC,QAcX;IAED;;;OAGG;IACH,YAFa,CAAC,CAIb;IAED;;;OAGG;IACH,gBAcC;;CACJ;;cAKS,wBAAmB;;mBA1HV,uCAAuC"}
@@ -8,6 +8,13 @@ import Signal from "../../../core/events/signal/Signal.js";
8
8
  * // do work with texture
9
9
  * ref.release(); // we're done with the resource, texture_system will be notified
10
10
  * // now ref.getValue() === null, reference is no longer valid
11
+ * @example
12
+ * const ref: Reference<Texture> = Reference.from(texture);
13
+ * ref.onReleased.add((this_ref:Reference<Texture>, texture:Texture) => {
14
+ * // cleanup memory when the reference is released
15
+ * texture.dispose();
16
+ * });
17
+ * // pass the reference to some other system for use
11
18
  * @template T
12
19
  */
13
20
  export class Reference {
@@ -46,6 +53,23 @@ export class Reference {
46
53
  return this.#onReleased;
47
54
  }
48
55
 
56
+ /**
57
+ * Produces a new instance of a bound reference with a given value.
58
+ * Same as calling {@link bind} on a new instance.
59
+ *
60
+ * @template X
61
+ * @param {X} x
62
+ * @return {Reference<X>}
63
+ * @see bind
64
+ */
65
+ static from(x){
66
+ const r = new Reference();
67
+
68
+ r.bind(x);
69
+
70
+ return r;
71
+ }
72
+
49
73
  /**
50
74
  *
51
75
  * @param {T} value
@@ -48,7 +48,7 @@ declare class VirtualListView extends View<HTMLElement> {
48
48
  * @private
49
49
  */
50
50
  private __alignment_vertical;
51
- __index_cache: Cache<any, any>;
51
+ __index_cache: Cache<import("../../core/cache/Cache.js").Hashable, any>;
52
52
  __throttledUpdate: Function;
53
53
  __handleElementAdded(el: any, index: any): void;
54
54
  __handleElementRemoved(el: any, index: any): void;
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualListView.d.ts","sourceRoot":"","sources":["../../../../src/view/common/VirtualListView.js"],"names":[],"mappings":";;;;;;AAgBA;IACI;;;;;;;;;;OAUG;IACH,gHARW,MAAM,EAoGhB;IA/EG,cAAgB;IAahB,YAAkB;IAclB,yBAA+B;IAE/B,mCAAkC;IAElC,6BAA8B;IAC9B,4BAA6B;IAE7B,iCAAoC;IAEpC;;;;OAIG;IACH,oBAA2B;IAE3B;;;;OAIG;IACH,uBAAiC;IAEjC;;;;OAIG;IACH,0BAAuC;IAEvC;;;;OAIG;IACH,6BAA6C;IAG7C,+BAIE;IAGF,4BAAyD;IAS7D,gDASC;IAED,kDAOC;IAGD,eA4EC;IAED,qCAmBC;IAED;;;;;OAKG;IACH,kCAIC;IAED,gCAKC;IAED,oBAMC;CAeJ;iBAlRgB,YAAY;iBAPZ,oCAAoC;sBAD/B,2BAA2B"}
1
+ {"version":3,"file":"VirtualListView.d.ts","sourceRoot":"","sources":["../../../../src/view/common/VirtualListView.js"],"names":[],"mappings":";;;;;;AAgBA;IACI;;;;;;;;;;OAUG;IACH,gHARW,MAAM,EAoGhB;IA/EG,cAAgB;IAahB,YAAkB;IAclB,yBAA+B;IAE/B,mCAAkC;IAElC,6BAA8B;IAC9B,4BAA6B;IAE7B,iCAAoC;IAEpC;;;;OAIG;IACH,oBAA2B;IAE3B;;;;OAIG;IACH,uBAAiC;IAEjC;;;;OAIG;IACH,0BAAuC;IAEvC;;;;OAIG;IACH,6BAA6C;IAG7C,wEAIE;IAGF,4BAAyD;IAS7D,gDASC;IAED,kDAOC;IAGD,eA4EC;IAED,qCAmBC;IAED;;;;;OAKG;IACH,kCAIC;IAED,gCAKC;IAED,oBAMC;CAeJ;iBAlRgB,YAAY;iBAPZ,oCAAoC;sBAD/B,2BAA2B"}