@woosh/meep-engine 2.111.7 → 2.111.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 (27) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +45 -43
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +45 -43
  5. package/package.json +1 -1
  6. package/src/core/collection/array/typed/compute_binary_data_type_from_typed_array.d.ts +8 -0
  7. package/src/core/collection/array/typed/compute_binary_data_type_from_typed_array.d.ts.map +1 -0
  8. package/src/core/collection/array/typed/compute_binary_data_type_from_typed_array.js +39 -0
  9. package/src/core/collection/array/typed/isTypedArray.d.ts +4 -3
  10. package/src/core/collection/array/typed/isTypedArray.d.ts.map +1 -1
  11. package/src/core/collection/array/typed/isTypedArray.js +4 -5
  12. package/src/core/collection/array/typed/typedArrayToDataType.d.ts +3 -5
  13. package/src/core/collection/array/typed/typedArrayToDataType.d.ts.map +1 -1
  14. package/src/core/collection/array/typed/typedArrayToDataType.js +3 -31
  15. package/src/core/collection/array/typed/uint_array_for_count.d.ts +3 -3
  16. package/src/core/collection/array/typed/uint_array_for_count.d.ts.map +1 -1
  17. package/src/core/collection/array/typed/uint_array_for_count.js +7 -7
  18. package/src/engine/graphics/geometry/AttributeSpec.d.ts.map +1 -1
  19. package/src/engine/graphics/geometry/AttributeSpec.js +48 -29
  20. package/src/engine/graphics/geometry/VertexDataSpec.d.ts.map +1 -1
  21. package/src/engine/graphics/geometry/VertexDataSpec.js +13 -6
  22. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.d.ts.map +1 -1
  23. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +4 -2
  24. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
  25. package/src/engine/graphics/texture/sampler/Sampler2D.js +4 -2
  26. package/src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.d.ts.map +1 -1
  27. package/src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js +6 -4
@@ -25,8 +25,9 @@ function isArrayEqualStrict(a, b) {
25
25
  }
26
26
 
27
27
  /**
28
- *
29
- * @param o
28
+ * Checks whether supplied argument is a TypedArray instance, such as Flaot32Array
29
+ * @template T
30
+ * @param {T} o
30
31
  * @returns {boolean}
31
32
  */
32
33
  function isTypedArray(o) {
@@ -48926,6 +48927,40 @@ function compute_typed_array_constructor_from_data_type(dt) {
48926
48927
  return r;
48927
48928
  }
48928
48929
 
48930
+ /**
48931
+ *
48932
+ * @param {*} array
48933
+ * @returns {BinaryDataType}
48934
+ */
48935
+ function compute_binary_data_type_from_typed_array(array) {
48936
+
48937
+ const ctor = Object.getPrototypeOf(array).constructor;
48938
+
48939
+ switch (ctor) {
48940
+ case Uint8Array:
48941
+ case Uint8ClampedArray:
48942
+ return BinaryDataType.Uint8;
48943
+ case Uint16Array:
48944
+ return BinaryDataType.Uint16;
48945
+ case Uint32Array:
48946
+ return BinaryDataType.Uint32;
48947
+
48948
+ case Int8Array:
48949
+ return BinaryDataType.Int8;
48950
+ case Int16Array:
48951
+ return BinaryDataType.Int16;
48952
+ case Int32Array:
48953
+ return BinaryDataType.Int32;
48954
+
48955
+ case Float32Array:
48956
+ return BinaryDataType.Float32;
48957
+ case Float64Array:
48958
+ return BinaryDataType.Float64;
48959
+ default:
48960
+ throw new Error(`unsupported constructor type ${ctor.name}`);
48961
+ }
48962
+ }
48963
+
48929
48964
  //
48930
48965
 
48931
48966
  /**
@@ -49000,39 +49035,6 @@ function is_typed_array_equals(a, b) {
49000
49035
  return isArrayEqualStrict(a_proxy, b_proxy);
49001
49036
  }
49002
49037
 
49003
- /**
49004
- *
49005
- * @param {*} v
49006
- * @returns {BinaryDataType}
49007
- */
49008
- function typedArrayToDataType(v) {
49009
- const ctor = Object.getPrototypeOf(v).constructor;
49010
-
49011
- switch (ctor) {
49012
- case Uint8Array:
49013
- case Uint8ClampedArray:
49014
- return BinaryDataType.Uint8;
49015
- case Uint16Array:
49016
- return BinaryDataType.Uint16;
49017
- case Uint32Array:
49018
- return BinaryDataType.Uint32;
49019
-
49020
- case Int8Array:
49021
- return BinaryDataType.Int8;
49022
- case Int16Array:
49023
- return BinaryDataType.Int16;
49024
- case Int32Array:
49025
- return BinaryDataType.Int32;
49026
-
49027
- case Float32Array:
49028
- return BinaryDataType.Float32;
49029
- case Float64Array:
49030
- return BinaryDataType.Float64;
49031
- default:
49032
- throw new Error('unsupported constructor type');
49033
- }
49034
- }
49035
-
49036
49038
  /**
49037
49039
  * Based on code from reddit https://www.reddit.com/r/javascript/comments/jxa8x/bicubic_interpolation/
49038
49040
  * @param {number} t ratio
@@ -49999,7 +50001,7 @@ class Sampler2D {
49999
50001
  height: this.height,
50000
50002
  width: this.width,
50001
50003
  itemSize: this.itemSize,
50002
- type: typedArrayToDataType(this.data),
50004
+ type: compute_binary_data_type_from_typed_array(this.data),
50003
50005
  data: encoded
50004
50006
  }
50005
50007
  }
@@ -59791,19 +59793,19 @@ function array_swap_one(array, index0, index1) {
59791
59793
 
59792
59794
  /**
59793
59795
  *
59794
- * @param {number} count
59795
- * @returns {function}
59796
+ * @param {number} max_value maximum value to be contained in the array
59797
+ * @returns {function} constructor
59796
59798
  */
59797
- function UintArrayForCount(count) {
59799
+ function UintArrayForCount(max_value) {
59798
59800
 
59799
- if (count <= 256) {
59801
+ if (max_value <= 256) {
59800
59802
  return Uint8Array;
59801
- } else if (count <= 65536) {
59803
+ } else if (max_value <= 65536) {
59802
59804
  return Uint16Array;
59803
- } else if (count <= 4294967295) {
59805
+ } else if (max_value <= 4294967295) {
59804
59806
  return Uint32Array;
59805
59807
  } else {
59806
- throw new Error(`Unsupported size ${count}`)
59808
+ throw new Error(`Unsupported size ${max_value}`)
59807
59809
  }
59808
59810
  }
59809
59811
 
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.111.7",
8
+ "version": "2.111.8",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -0,0 +1,8 @@
1
+ /**
2
+ *
3
+ * @param {*} array
4
+ * @returns {BinaryDataType}
5
+ */
6
+ export function compute_binary_data_type_from_typed_array(array: any): BinaryDataType;
7
+ import { BinaryDataType } from "../../../binary/type/BinaryDataType.js";
8
+ //# sourceMappingURL=compute_binary_data_type_from_typed_array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute_binary_data_type_from_typed_array.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/compute_binary_data_type_from_typed_array.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,uEAFa,cAAc,CAgC1B;+BArC8B,wCAAwC"}
@@ -0,0 +1,39 @@
1
+ import { assert } from "../../../assert.js";
2
+ import { BinaryDataType } from "../../../binary/type/BinaryDataType.js";
3
+
4
+ /**
5
+ *
6
+ * @param {*} array
7
+ * @returns {BinaryDataType}
8
+ */
9
+ export function compute_binary_data_type_from_typed_array(array) {
10
+ assert.notNull(array, 'array');
11
+ assert.isObject(array, 'array');
12
+ assert.isArrayLike(array, 'array');
13
+
14
+ const ctor = Object.getPrototypeOf(array).constructor;
15
+
16
+ switch (ctor) {
17
+ case Uint8Array:
18
+ case Uint8ClampedArray:
19
+ return BinaryDataType.Uint8;
20
+ case Uint16Array:
21
+ return BinaryDataType.Uint16;
22
+ case Uint32Array:
23
+ return BinaryDataType.Uint32;
24
+
25
+ case Int8Array:
26
+ return BinaryDataType.Int8;
27
+ case Int16Array:
28
+ return BinaryDataType.Int16;
29
+ case Int32Array:
30
+ return BinaryDataType.Int32;
31
+
32
+ case Float32Array:
33
+ return BinaryDataType.Float32;
34
+ case Float64Array:
35
+ return BinaryDataType.Float64;
36
+ default:
37
+ throw new Error(`unsupported constructor type ${ctor.name}`);
38
+ }
39
+ }
@@ -1,7 +1,8 @@
1
1
  /**
2
- *
3
- * @param o
2
+ * Checks whether supplied argument is a TypedArray instance, such as Flaot32Array
3
+ * @template T
4
+ * @param {T} o
4
5
  * @returns {boolean}
5
6
  */
6
- export function isTypedArray(o: any): boolean;
7
+ export function isTypedArray<T>(o: T): boolean;
7
8
  //# sourceMappingURL=isTypedArray.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isTypedArray.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/isTypedArray.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,sCAFa,OAAO,CAcnB"}
1
+ {"version":3,"file":"isTypedArray.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/isTypedArray.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,uCAFa,OAAO,CAcnB"}
@@ -1,9 +1,10 @@
1
1
  /**
2
- *
3
- * @param o
2
+ * Checks whether supplied argument is a TypedArray instance, such as Flaot32Array
3
+ * @template T
4
+ * @param {T} o
4
5
  * @returns {boolean}
5
6
  */
6
- function isTypedArray(o) {
7
+ export function isTypedArray(o) {
7
8
  return (
8
9
  o instanceof Int8Array ||
9
10
  o instanceof Uint8Array ||
@@ -16,5 +17,3 @@ function isTypedArray(o) {
16
17
  o instanceof Float64Array
17
18
  );
18
19
  }
19
-
20
- export { isTypedArray };
@@ -1,8 +1,6 @@
1
1
  /**
2
- *
3
- * @param {*} v
4
- * @returns {BinaryDataType}
2
+ * @deprecated renamed to {@link compute_binary_data_type_from_typed_array}
5
3
  */
6
- export function typedArrayToDataType(v: any): BinaryDataType;
7
- import { BinaryDataType } from "../../../binary/type/BinaryDataType.js";
4
+ export const typedArrayToDataType: typeof compute_binary_data_type_from_typed_array;
5
+ import { compute_binary_data_type_from_typed_array } from "./compute_binary_data_type_from_typed_array.js";
8
6
  //# sourceMappingURL=typedArrayToDataType.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typedArrayToDataType.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/typedArrayToDataType.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,8CAFa,cAAc,CA4B1B;+BAjC8B,wCAAwC"}
1
+ {"version":3,"file":"typedArrayToDataType.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/typedArrayToDataType.js"],"names":[],"mappings":"AAEA;;GAEG;AACH,oFAA6E;0DALnB,gDAAgD"}
@@ -1,34 +1,6 @@
1
- import { BinaryDataType } from "../../../binary/type/BinaryDataType.js";
1
+ import { compute_binary_data_type_from_typed_array } from "./compute_binary_data_type_from_typed_array.js";
2
2
 
3
3
  /**
4
- *
5
- * @param {*} v
6
- * @returns {BinaryDataType}
4
+ * @deprecated renamed to {@link compute_binary_data_type_from_typed_array}
7
5
  */
8
- export function typedArrayToDataType(v) {
9
- const ctor = Object.getPrototypeOf(v).constructor;
10
-
11
- switch (ctor) {
12
- case Uint8Array:
13
- case Uint8ClampedArray:
14
- return BinaryDataType.Uint8;
15
- case Uint16Array:
16
- return BinaryDataType.Uint16;
17
- case Uint32Array:
18
- return BinaryDataType.Uint32;
19
-
20
- case Int8Array:
21
- return BinaryDataType.Int8;
22
- case Int16Array:
23
- return BinaryDataType.Int16;
24
- case Int32Array:
25
- return BinaryDataType.Int32;
26
-
27
- case Float32Array:
28
- return BinaryDataType.Float32;
29
- case Float64Array:
30
- return BinaryDataType.Float64;
31
- default:
32
- throw new Error('unsupported constructor type');
33
- }
34
- }
6
+ export const typedArrayToDataType = compute_binary_data_type_from_typed_array
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  *
3
- * @param {number} count
4
- * @returns {function}
3
+ * @param {number} max_value maximum value to be contained in the array
4
+ * @returns {function} constructor
5
5
  */
6
- export function UintArrayForCount(count: number): Function;
6
+ export function UintArrayForCount(max_value: number): Function;
7
7
  //# sourceMappingURL=uint_array_for_count.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uint_array_for_count.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/uint_array_for_count.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,yCAHW,MAAM,YAchB"}
1
+ {"version":3,"file":"uint_array_for_count.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/uint_array_for_count.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,6CAHW,MAAM,YAchB"}
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  *
3
- * @param {number} count
4
- * @returns {function}
3
+ * @param {number} max_value maximum value to be contained in the array
4
+ * @returns {function} constructor
5
5
  */
6
- export function UintArrayForCount(count) {
6
+ export function UintArrayForCount(max_value) {
7
7
 
8
- if (count <= 256) {
8
+ if (max_value <= 256) {
9
9
  return Uint8Array;
10
- } else if (count <= 65536) {
10
+ } else if (max_value <= 65536) {
11
11
  return Uint16Array;
12
- } else if (count <= 4294967295) {
12
+ } else if (max_value <= 4294967295) {
13
13
  return Uint32Array;
14
14
  } else {
15
- throw new Error(`Unsupported size ${count}`)
15
+ throw new Error(`Unsupported size ${max_value}`)
16
16
  }
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AttributeSpec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/geometry/AttributeSpec.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IA+BI,uCAMC;IA0DD;;;;;OAKG;IACH,iBAJW,aAAa,KACb,aAAa,GACZ,MAAM,CAIjB;IArGG;;;OAGG;IACH,MAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,MAFU,cAAc,CAEM;IAE9B;;;;;OAKG;IACH,UAFU,MAAM,CAEH;IAEb;;;;;OAKG;IACH,YAFU,OAAO,CAEE;IAWvB;;;;;aAoBC;IAED;;;;;MAOC;IAED,eAEC;IAED;;;;OAIG;IACH,cAHW,aAAa,GACX,OAAO,CAQnB;IAED;;;OAGG;IACH,eAFa,MAAM,CAIlB;IAaL;;;OAGG;IACH,0BAFU,OAAO,CAEsB;CANtC;+BAhH8B,6CAA6C"}
1
+ {"version":3,"file":"AttributeSpec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/geometry/AttributeSpec.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IA+BI,uCAMC;IA6ED;;;;;OAKG;IACH,iBAJW,aAAa,KACb,aAAa,GACZ,MAAM,CAIjB;IAxHD;;;OAGG;IACH,MAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,MAFU,cAAc,CAEM;IAE9B;;;;;OAKG;IACH,UAFU,MAAM,CAEH;IAEb;;;;;OAKG;IACH,YAFU,OAAO,CAEE;IAWnB;;;;;aAoBC;IAED;;;;;MAOC;IAED,eAEC;IAED;;;;OAIG;IACH,cAHW,aAAa,GACX,OAAO,CAQnB;IAED;;;OAGG;IACH,YAFW,aAAa,QAOvB;IAED,uBAMC;IAED;;;OAGG;IACH,eAFa,MAAM,CAIlB;IAaL;;;OAGG;IACH,0BAFU,OAAO,CAEsB;CANtC;+BAnI8B,6CAA6C"}
@@ -9,33 +9,33 @@ import { computeStringHash } from "../../../core/primitives/strings/computeStrin
9
9
  */
10
10
  export class AttributeSpec {
11
11
 
12
- /**
13
- * Typically unique within a given set, used to identify the attribute
14
- * @type {string}
15
- */
16
- name = "";
17
-
18
- /**
19
- * How the attribute is stored in memory and interpreted
20
- * @type {BinaryDataType}
21
- */
22
- type = BinaryDataType.Float32;
23
-
24
- /**
25
- * How many elements the attribute uses. This is cardinality of a vector.
26
- * 1 means the attribute is a scalar
27
- * must be greater or equal to 1
28
- * @type {number}
29
- */
30
- itemSize = 1;
31
-
32
- /**
33
- * Normalized values will be automatically converted to float32 in the shader
34
- * This gives good optimization opportunities for things like normal vectors
35
- * Applies to integer types only
36
- * @type {boolean}
37
- */
38
- normalized = false;
12
+ /**
13
+ * Typically unique within a given set, used to identify the attribute
14
+ * @type {string}
15
+ */
16
+ name = "";
17
+
18
+ /**
19
+ * How the attribute is stored in memory and interpreted
20
+ * @type {BinaryDataType}
21
+ */
22
+ type = BinaryDataType.Float32;
23
+
24
+ /**
25
+ * How many elements the attribute uses. This is cardinality of a vector.
26
+ * 1 means the attribute is a scalar
27
+ * must be greater or equal to 1
28
+ * @type {number}
29
+ */
30
+ itemSize = 1;
31
+
32
+ /**
33
+ * Normalized values will be automatically converted to float32 in the shader
34
+ * This gives good optimization opportunities for things like normal vectors
35
+ * Applies to integer types only
36
+ * @type {boolean}
37
+ */
38
+ normalized = false;
39
39
 
40
40
 
41
41
  static fromJSON(j) {
@@ -96,14 +96,33 @@ export class AttributeSpec {
96
96
 
97
97
  /**
98
98
  *
99
- * @returns {number}
99
+ * @param {AttributeSpec} other
100
+ */
101
+ copy(other) {
102
+ this.type = other.type;
103
+ this.name = other.name;
104
+ this.itemSize = other.itemSize;
105
+ this.normalized = other.normalized;
106
+ }
107
+
108
+ clone() {
109
+ const r = new AttributeSpec();
110
+
111
+ r.copy(this);
112
+
113
+ return r;
114
+ }
115
+
116
+ /**
117
+ * How much space a single attribute value takes up
118
+ * @returns {number} in bytes
100
119
  */
101
120
  getByteSize() {
102
121
  return this.itemSize * DataTypeByteSizes[this.type];
103
122
  }
104
123
 
105
124
  /**
106
- *
125
+ * Sorting comparator
107
126
  * @param {AttributeSpec} a
108
127
  * @param {AttributeSpec} b
109
128
  * @return {number}
@@ -1 +1 @@
1
- {"version":3,"file":"VertexDataSpec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/geometry/VertexDataSpec.js"],"names":[],"mappings":"AAYA;;;GAGG;AACH;IAeI;;;;OAIG;IACH,2BAHW,aAAa,GACX,cAAc,CAQ1B;IAxBD;;;OAGG;IACH,YAFU,aAAa,EAAE,CAET;IAsBhB;;;;OAIG;IACH,yBAHW,MAAM,GACL,aAAa,GAAC,SAAS,CAgBlC;IAED;;;OAGG;IACH,8BAFW,MAAM,GADJ,MAAM,CAiBlB;IAED;;;OAGG;IACH,oBAFW,aAAa,EAAE,QAOzB;IAED;;;;OAIG;IACH,eAHW,aAAa,GACZ,cAAc,CAkBzB;IAED;;;OAGG;IACH,0BAFW,aAAa,EAAE,QAQzB;IAED,cAMC;IAED;;;;OAIG;IACH,cAHW,cAAc,GACZ,OAAO,CAQnB;IAED,sBAEC;IAED,eAMC;IAED;;MAIC;IAED;;aAkBC;IAED;;;OAGG;IACH,eAFa,MAAM,CAelB;IAIL;;;OAGG;IACH,2BAFU,OAAO,CAEwB;;CAPxC;8BA5M6B,oBAAoB"}
1
+ {"version":3,"file":"VertexDataSpec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/geometry/VertexDataSpec.js"],"names":[],"mappings":"AAYA;;;GAGG;AACH;IAeI;;;;OAIG;IACH,2BAHW,aAAa,GACX,cAAc,CAQ1B;IAxBD;;;OAGG;IACH,YAFU,aAAa,EAAE,CAET;IAsBhB;;;;OAIG;IACH,yBAHW,MAAM,GACL,aAAa,GAAC,SAAS,CAgBlC;IAED;;;OAGG;IACH,8BAFW,MAAM,GADJ,MAAM,CAiBlB;IAED;;;OAGG;IACH,oBAFW,aAAa,EAAE,QAOzB;IAED;;;;OAIG;IACH,eAHW,aAAa,GACZ,cAAc,CAkBzB;IAED;;;OAGG;IACH,0BAFW,aAAa,EAAE,QAQzB;IAED,cAMC;IAED;;;;OAIG;IACH,cAHW,cAAc,GACZ,OAAO,CAQnB;IAED,sBASC;IAED,eAMC;IAED;;MAIC;IAED;;aAkBC;IAED;;;OAGG;IACH,eAFa,MAAM,CAelB;IAIL;;;OAGG;IACH,2BAFU,OAAO,CAEwB;;CAPxC;8BAnN6B,oBAAoB"}
@@ -8,7 +8,7 @@ import { AttributeSpec } from "./AttributeSpec.js";
8
8
  * @readonly
9
9
  * @type {number}
10
10
  */
11
- const DEFAULT_HASH = 1234567;
11
+ const RESERVED_HASH = 1234567;
12
12
 
13
13
  /**
14
14
  * Describes a set of data attributes. A good analogy would be "all data associated with geometry vertex"
@@ -27,7 +27,7 @@ export class VertexDataSpec {
27
27
  * @type {number}
28
28
  * @private
29
29
  */
30
- #hash = DEFAULT_HASH;
30
+ #hash = RESERVED_HASH;
31
31
 
32
32
  /**
33
33
  *
@@ -111,7 +111,7 @@ export class VertexDataSpec {
111
111
  this.attributes.push(attribute);
112
112
 
113
113
  // reset hash
114
- this.#hash = DEFAULT_HASH;
114
+ this.#hash = RESERVED_HASH;
115
115
 
116
116
  //for chaining, return self
117
117
  return this;
@@ -134,7 +134,7 @@ export class VertexDataSpec {
134
134
  this.attributes.splice(0, count);
135
135
 
136
136
  // reset hash to trigger hash update
137
- this.#hash = DEFAULT_HASH;
137
+ this.#hash = RESERVED_HASH;
138
138
  }
139
139
 
140
140
  /**
@@ -151,11 +151,18 @@ export class VertexDataSpec {
151
151
  }
152
152
 
153
153
  computeHash() {
154
- return computeHashArray(this.attributes, invokeObjectHash);
154
+ const hash_value = computeHashArray(this.attributes, invokeObjectHash);
155
+
156
+ if (hash_value === RESERVED_HASH) {
157
+ // collision with reserved hash, replace
158
+ return 0;
159
+ }
160
+
161
+ return hash_value;
155
162
  }
156
163
 
157
164
  hash() {
158
- if (this.#hash === DEFAULT_HASH) {
165
+ if (this.#hash === RESERVED_HASH) {
159
166
  this.#hash = this.computeHash();
160
167
  }
161
168
 
@@ -1 +1 @@
1
- {"version":3,"file":"MaterialOptimizationContext.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/material/optimization/MaterialOptimizationContext.js"],"names":[],"mappings":"AAgXA;IAEQ;;;OAGG;IACH,UAFU,MAAM,OAAO,EAAE,CAEP;IAElB;;;OAGG;IACH,QAFU,MAAM,IAAI,EAAE,CAEN;IAGhB;;;OAGG;IACH,SAFU,IAAI,MAAM,EAAC,SAAS,CAAC,CAEP;IAExB;;;OAGG;IACH,YAFU,SAAS,CAEC;IAGxB;;;OAGG;IACH,sBAFW,kBAAkB,EAAE,QAkE9B;IAED;;;OAGG;IACH,gCAFW,kBAAkB,EAAE,QAmE9B;IAED;;;OAGG;IACH,kCAFW,kBAAkB,QA4E5B;IAED;;;OAGG;IACH,cAFW,MAAM,IAAI,QAUpB;IAED;;;OAGG;IACH,iCAMC;IAED;;OAEG;IACH,eAwIC;IAED;;;OAGG;IACH,6BAFY,IAAI,MAAM,EAAE,iBAAiB,CAAC,CAyBzC;IAED;;;;OAIG;IACH,0CAHW,MAAM,cAAc,OACpB,kBAAkB,QA+C5B;CACJ;;0BAIS,MAAM;;0BAx0BU,oCAAoC;mCAK3B,yBAAyB;4BAzBrD,OAAO"}
1
+ {"version":3,"file":"MaterialOptimizationContext.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/material/optimization/MaterialOptimizationContext.js"],"names":[],"mappings":"AAkXA;IAEQ;;;OAGG;IACH,UAFU,MAAM,OAAO,EAAE,CAEP;IAElB;;;OAGG;IACH,QAFU,MAAM,IAAI,EAAE,CAEN;IAGhB;;;OAGG;IACH,SAFU,IAAI,MAAM,EAAC,SAAS,CAAC,CAEP;IAExB;;;OAGG;IACH,YAFU,SAAS,CAEC;IAGxB;;;OAGG;IACH,sBAFW,kBAAkB,EAAE,QAkE9B;IAED;;;OAGG;IACH,gCAFW,kBAAkB,EAAE,QAmE9B;IAED;;;OAGG;IACH,kCAFW,kBAAkB,QA4E5B;IAED;;;OAGG;IACH,cAFW,MAAM,IAAI,QAUpB;IAED;;;OAGG;IACH,iCAMC;IAED;;OAEG;IACH,eAwIC;IAED;;;OAGG;IACH,6BAFY,IAAI,MAAM,EAAE,iBAAiB,CAAC,CAyBzC;IAED;;;;OAIG;IACH,0CAHW,MAAM,cAAc,OACpB,kBAAkB,QA+C5B;CACJ;;0BAIS,MAAM;;0BAx0BU,oCAAoC;mCAK3B,yBAAyB;4BA3BrD,OAAO"}
@@ -12,7 +12,9 @@ import {
12
12
  compute_typed_array_constructor_from_data_type
13
13
  } from "../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
14
14
  import { array_push_if_unique } from "../../../../core/collection/array/array_push_if_unique.js";
15
- import { typedArrayToDataType } from "../../../../core/collection/array/typed/typedArrayToDataType.js";
15
+ import {
16
+ compute_binary_data_type_from_typed_array
17
+ } from "../../../../core/collection/array/typed/compute_binary_data_type_from_typed_array.js";
16
18
  import { collectIteratorValueToArray } from "../../../../core/collection/collectIteratorValueToArray.js";
17
19
  import { HashMap } from "../../../../core/collection/map/HashMap.js";
18
20
  import AABB2 from "../../../../core/geom/AABB2.js";
@@ -791,7 +793,7 @@ export class MaterialOptimizationContext {
791
793
  //build new textures
792
794
  for (const [name, sampler] of this.atlases) {
793
795
 
794
- const sampler_data_type = typedArrayToDataType(sampler.data);
796
+ const sampler_data_type = compute_binary_data_type_from_typed_array(sampler.data);
795
797
 
796
798
  const format = channelCountToThreeTextureFormat(sampler.itemSize);
797
799
  const type = computeThreeTextureTypeFromDataType(sampler_data_type);
@@ -1 +1 @@
1
- {"version":3,"file":"Sampler2D.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/Sampler2D.js"],"names":[],"mappings":"AAeA;;;;GAIG;AACH;IAk8BI;;;;;;OAMG;IACH,6DAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,sDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,uDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,uDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,qDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,sDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,sDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,wDAFY,SAAS,CAKpB;IAED;;;;;;OAMG;IACH,wDAFY,SAAS,CAKpB;IA3iCD;;;;;;;OAOG;IACH,mBANW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,iBAAiB,GAAC,UAAU,GAAC,WAAW,GAAC,WAAW,GAAC,SAAS,GAAC,UAAU,GAAC,UAAU,GAAC,YAAY,GAAC,YAAY,aACzI,MAAM,UACN,MAAM,WACN,MAAM,EAmDhB;IA7BG;;;OAGG;IACH,cAAkB;IAElB;;;OAGG;IACH,eAAoB;IAEpB;;;OAGG;IACH,iBAAwB;IAExB;;;OAGG;IACH,MA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,QAUpC;IAED;;;;;;OAMG;IACH,eALW,MAAM,KACN,MAAM,WACN,MAAM,GACJ,MAAM,CAalB;IAED;;;;;OAKG;IACH,QAJW,MAAM,KACN,MAAM,UACN,MAAM,EAAE,QAalB;IAED;;;;;OAKG;IACH,SAJW,MAAM,KACN,MAAM,QACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,QAapC;IAED;;;;;;OAMG;IACH,UALW,MAAM,KACN,MAAM,WACN,2BAAuB,OAajC;IAED;;;;;OAKG;IACH,eAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;OAIG;IACH,mBAHW,MAAM,yBAUhB;IAED;;;;;;;;;OASG;IACH,aARW,SAAS,qHAoDnB;IAGD;;;;;;;OAOG;IACH,oEA8BC;IAED;;;;OAIG;IACH,2BAHW,MAAM,SACN,MAAM,QAYhB;IAED;;;;;;;OAOG;IACH,iEAFW,aAAc,QAqCxB;IAED;;;;;;OAMG;IACH,gBALW,MAAM,KACN,MAAM,WACN,MAAM,SACN,MAAM,QAqBhB;IAED;;;;;OAKG;IACH,OAJW,MAAM,KACN,MAAM,SACN,MAAM,EAAE,GAAC,YAAY,QAe/B;IAED;;;;;;;OAOG;IACH,wBALW,MAAM,WACN,MAAM,UACN,MAAM,sBAyBhB;IAED;;;;;OAKG;IACH,UAJW,MAAM,KACN,MAAM,iBACN,OAAO,QAyDjB;IAED;;;OAGG;IACH,mBAFY,MAAM,CAYjB;IAED;;;;OAIG;IACH,cAHW,SAAS,GACR,OAAO,CAYlB;IAED;;;OAGG;IACH,QAFY,MAAM,CAYjB;IAGD;;OAEG;IACH,SAFa,SAAS,CAerB;IAED;;;;;;MAUC;IAED;;;;;;aAwBC;IAgHL;;;OAGG;IACH,sBAFU,OAAO,CAEc;CAN9B;;kBAUS,MAAM"}
1
+ {"version":3,"file":"Sampler2D.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/Sampler2D.js"],"names":[],"mappings":"AAiBA;;;;GAI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,MAAM,QAYhB;IAED;;;;;;;OAOG;IACH,iEAFW,aAAc,QAqCxB;IAED;;;;;;OAMG;IACH,gBALW,MAAM,KACN,MAAM,WACN,MAAM,SACN,MAAM,QAqBhB;IAED;;;;;OAKG;IACH,OAJW,MAAM,KACN,MAAM,SACN,MAAM,EAAE,GAAC,YAAY,QAe/B;IAED;;;;;;;OAOG;IACH,wBALW,MAAM,WACN,MAAM,UACN,MAAM,sBAyBhB;IAED;;;;;OAKG;IACH,UAJW,MAAM,KACN,MAAM,iBACN,OAAO,QAyDjB;IAED;;;OAGG;IACH,mBAFY,MAAM,CAYjB;IAED;;;;OAIG;IACH,cAHW,SAAS,GACR,OAAO,CAYlB;IAED;;;OAGG;IACH,QAFY,MAAM,CAYjB;IAGD;;OAEG;IACH,SAFa,SAAS,CAerB;IAED;;;;;;MAUC;IAED;;;;;;aAwBC;IAgHL;;;OAGG;IACH,sBAFU,OAAO,CAEc;CAN9B;;kBAUS,MAAM"}
@@ -3,8 +3,10 @@ import { Base64 } from "../../../../core/binary/Base64.js";
3
3
  import {
4
4
  compute_typed_array_constructor_from_data_type
5
5
  } from "../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
6
+ import {
7
+ compute_binary_data_type_from_typed_array
8
+ } from "../../../../core/collection/array/typed/compute_binary_data_type_from_typed_array.js";
6
9
  import { is_typed_array_equals } from "../../../../core/collection/array/typed/is_typed_array_equals.js";
7
- import { typedArrayToDataType } from "../../../../core/collection/array/typed/typedArrayToDataType.js";
8
10
  import { clamp } from "../../../../core/math/clamp.js";
9
11
  import { lerp } from "../../../../core/math/lerp.js";
10
12
  import { max2 } from "../../../../core/math/max2.js";
@@ -949,7 +951,7 @@ export class Sampler2D {
949
951
  height: this.height,
950
952
  width: this.width,
951
953
  itemSize: this.itemSize,
952
- type: typedArrayToDataType(this.data),
954
+ type: compute_binary_data_type_from_typed_array(this.data),
953
955
  data: encoded
954
956
  }
955
957
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sampler2d_compute_texel_value_conversion_scale_to_uint8.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js"],"names":[],"mappings":"AAQA;;;;GAIG;AACH;YAFsB,MAAM;WAAS,MAAM;EAqC1C"}
1
+ {"version":3,"file":"sampler2d_compute_texel_value_conversion_scale_to_uint8.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js"],"names":[],"mappings":"AAUA;;;;GAIG;AACH;YAFsB,MAAM;WAAS,MAAM;EAqC1C"}
@@ -1,8 +1,10 @@
1
1
  import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
2
- import { min2 } from "../../../../core/math/min2.js";
3
- import { max2 } from "../../../../core/math/max2.js";
2
+ import {
3
+ compute_binary_data_type_from_typed_array
4
+ } from "../../../../core/collection/array/typed/compute_binary_data_type_from_typed_array.js";
4
5
  import { isTypedArray } from "../../../../core/collection/array/typed/isTypedArray.js";
5
- import { typedArrayToDataType } from "../../../../core/collection/array/typed/typedArrayToDataType.js";
6
+ import { max2 } from "../../../../core/math/max2.js";
7
+ import { min2 } from "../../../../core/math/min2.js";
6
8
  import { sampler2d_channel_compute_max } from "./sampler2d_channel_compute_max.js";
7
9
  import { sampler2d_channel_compute_min } from "./sampler2d_channel_compute_min.js";
8
10
 
@@ -16,7 +18,7 @@ export function sampler2d_compute_texel_value_conversion_scale_to_uint8(sampler)
16
18
  let dataType;
17
19
 
18
20
  if (isTypedArray(sampler.data)) {
19
- dataType = typedArrayToDataType(sampler.data);
21
+ dataType = compute_binary_data_type_from_typed_array(sampler.data);
20
22
  } else {
21
23
  // plain numeric array
22
24
  dataType = BinaryDataType.Float32;