@woosh/meep-engine 2.47.41 → 2.48.0

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 (92) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +44161 -44112
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +44162 -44112
  5. package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +3 -3
  6. package/editor/view/node-graph/NodeGraphView.js +1 -1
  7. package/package.json +1 -1
  8. package/samples/terrain/editor.js +4 -4
  9. package/src/core/{collection/table/DataType.js → binary/type/BinaryDataType.js} +1 -1
  10. package/src/core/binary/type/DataType2TypedArrayConstructorMapping.js +34 -0
  11. package/src/core/binary/type/DataTypeByteSizes.js +37 -0
  12. package/src/core/binary/type/DataTypeIndices.js +17 -0
  13. package/src/core/{collection/table → binary/type}/computeDataTypeByIndex.js +1 -1
  14. package/src/core/binary/type/dataTypeFromTypedArray.js +31 -0
  15. package/src/core/collection/array/typedArrayToDataType.js +10 -10
  16. package/src/core/collection/table/RowFirstTable.js +1 -1
  17. package/src/core/collection/table/RowFirstTable.spec.js +16 -16
  18. package/src/core/collection/table/RowFirstTableSpec.js +9 -9
  19. package/src/core/collection/table/deserializeRowFirstTable.js +1 -1
  20. package/src/core/collection/table/serializeRowFirstTable.js +1 -1
  21. package/src/core/geom/3d/matrix/MATRIX_4_IDENTITY.js +2 -1
  22. package/src/core/geom/3d/matrix/m4_multiply.js +67 -0
  23. package/src/core/geom/Quaternion.js +0 -85
  24. package/src/core/graph/SquareMatrix.js +3 -3
  25. package/src/core/graph/SquareMatrix.spec.js +5 -5
  26. package/src/core/graph/eigen/eigen.spec.js +2 -2
  27. package/src/core/graph/graph_k_means_cluster.js +2 -2
  28. package/src/core/graph/graph_laplacian_matrix.js +3 -3
  29. package/src/core/model/node-graph/json/deserializeNodeGraphFromJSON.js +16 -5
  30. package/src/core/model/node-graph/node/NodeDescription.js +1 -1
  31. package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
  32. package/src/engine/ecs/foliage/InstancedFoliage.js +4 -4
  33. package/src/engine/ecs/fow/FogOfWar.js +4 -4
  34. package/src/engine/ecs/terrain/ecs/PromiseSamplerHeight.js +1 -1
  35. package/src/engine/ecs/transform/Transform.d.ts +2 -0
  36. package/src/engine/ecs/transform/Transform.js +51 -58
  37. package/src/engine/ecs/transform/Transform.spec.js +22 -0
  38. package/src/engine/graphics/ecs/light/binding/three/applyRotation.js +1 -1
  39. package/src/engine/graphics/ecs/mesh/applyTransformToThreeObject.js +3 -1
  40. package/src/engine/graphics/ecs/mesh-v2/allocate_transform_m4.js +3 -12
  41. package/src/engine/graphics/geometry/AttributeSpec.js +5 -5
  42. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +8 -8
  43. package/src/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +4 -4
  44. package/src/engine/graphics/micron/build/compute_micron_buffer_array_constructor.js +7 -7
  45. package/src/engine/graphics/micron/build/fill_patch_geometry_data.js +6 -6
  46. package/src/engine/graphics/micron/build/hierarchy/merge_patches.js +4 -4
  47. package/src/engine/graphics/micron/format/micron_build_proxy_geometry.js +1 -1
  48. package/src/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.spec.js +2 -2
  49. package/src/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
  50. package/src/engine/graphics/micron/format/serialization/deserialize_patch.js +2 -2
  51. package/src/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
  52. package/src/engine/graphics/micron/format/serialization/serialize_patch.js +1 -1
  53. package/src/engine/graphics/micron/render/instanced/AttributeDataTexture.js +1 -1
  54. package/src/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +2 -2
  55. package/src/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
  56. package/src/engine/graphics/particles/node-based/codegen/modules/FunctionParameterSpecification.js +2 -2
  57. package/src/engine/graphics/particles/node-based/codegen/modules/FunctionSignature.js +2 -2
  58. package/src/engine/graphics/particles/particular/engine/MovingBoundingBox.js +4 -4
  59. package/src/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +13 -13
  60. package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +1 -1
  61. package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +3 -3
  62. package/src/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +8 -8
  63. package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +1 -1
  64. package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
  65. package/src/engine/graphics/render/forward_plus/data/TextureBackedMemoryRegion.js +5 -5
  66. package/src/engine/graphics/render/forward_plus/data/computeDataType.js +10 -10
  67. package/src/engine/graphics/render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js +11 -11
  68. package/src/engine/graphics/render/forward_plus/data/computeThreeTextureTypeFromDataType.js +11 -11
  69. package/src/engine/graphics/render/frame_graph/TextureDescriptor.js +4 -4
  70. package/src/engine/graphics/render/frame_graph/sample/meep-v1/ColorDepthPass.js +3 -3
  71. package/src/engine/graphics/texture/atlas/TextureAtlas.js +5 -5
  72. package/src/engine/graphics/texture/normalized_internal_format.js +5 -5
  73. package/src/engine/graphics/texture/sampler/Sampler2D.js +25 -51
  74. package/src/engine/graphics/texture/sampler/sampler2DToFloat32Texture.js +2 -2
  75. package/src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js +3 -3
  76. package/src/engine/graphics/texture/sampler/{TextureBinaryBufferSerializer.js → serialization/TextureBinaryBufferSerializer.js} +17 -46
  77. package/src/engine/graphics/texture/sampler/{TextureBinaryBufferSerializer.spec.js → serialization/TextureBinaryBufferSerializer.spec.js} +2 -2
  78. package/src/engine/graphics/trail/TemporalPath.js +3 -3
  79. package/src/engine/graphics/trail/x/ribbon_attributes_spec.js +18 -18
  80. package/src/engine/navigation/ecs/components/Path.js +5 -5
  81. package/src/generation/example/grid/configureMirGrid.js +6 -6
  82. package/src/generation/filtering/numeric/process/computeCellFilterGradient.spec.js +10 -10
  83. package/src/generation/grid/layers/GridDataLayer.js +4 -4
  84. package/src/generation/placement/action/GridCellActionPlaceTags.spec.js +2 -2
  85. package/src/generation/rules/CellMatcherContainsTag.spec.js +2 -2
  86. package/src/generation/rules/cell/GridPatternMatcher.spec.js +8 -8
  87. package/src/view/elements/image/HTMLElementCacheKey.js +111 -2
  88. package/src/view/elements/image/ImageView.js +1 -1
  89. package/src/view/elements/video/VideoView.js +1 -1
  90. package/src/core/collection/table/DataType2TypedArrayConstructorMapping.js +0 -34
  91. package/src/core/collection/table/DataTypeByteSizes.js +0 -37
  92. package/src/core/collection/table/DataTypeIndices.js +0 -17
@@ -3,12 +3,12 @@ import { computeCellFilterGradient } from "./computeCellFilterGradient.js";
3
3
  import { CellFilterCellMatcher } from "../../CellFilterCellMatcher.js";
4
4
  import { CellMatcherLayerBitMaskTest } from "../../../rules/CellMatcherLayerBitMaskTest.js";
5
5
  import { GridDataLayer } from "../../../grid/layers/GridDataLayer.js";
6
- import { DataType } from "../../../../core/collection/table/DataType.js";
6
+ import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
7
7
 
8
8
  test('computeCellFilterGradient center', () => {
9
9
 
10
10
  const grid = new GridData();
11
- const layer = GridDataLayer.from('a', DataType.Uint32);
11
+ const layer = GridDataLayer.from('a', BinaryDataType.Uint32);
12
12
 
13
13
  grid.addLayer(layer);
14
14
  grid.resize(3, 3);
@@ -40,7 +40,7 @@ test('computeCellFilterGradient center', () => {
40
40
  test('computeCellFilterGradient top', () => {
41
41
 
42
42
  const grid = new GridData();
43
- const layer = GridDataLayer.from('a', DataType.Uint32);
43
+ const layer = GridDataLayer.from('a', BinaryDataType.Uint32);
44
44
 
45
45
  grid.addLayer(layer);
46
46
  grid.resize(3, 3);
@@ -70,7 +70,7 @@ test('computeCellFilterGradient top', () => {
70
70
  test('computeCellFilterGradient bottom', () => {
71
71
 
72
72
  const grid = new GridData();
73
- const layer = GridDataLayer.from('a', DataType.Uint32);
73
+ const layer = GridDataLayer.from('a', BinaryDataType.Uint32);
74
74
 
75
75
  grid.addLayer(layer);
76
76
  grid.resize(3, 3);
@@ -101,7 +101,7 @@ test('computeCellFilterGradient bottom', () => {
101
101
  test('computeCellFilterGradient left', () => {
102
102
 
103
103
  const grid = new GridData();
104
- const layer = GridDataLayer.from('a', DataType.Uint32);
104
+ const layer = GridDataLayer.from('a', BinaryDataType.Uint32);
105
105
 
106
106
  grid.addLayer(layer);
107
107
  grid.resize(3, 3);
@@ -132,7 +132,7 @@ test('computeCellFilterGradient left', () => {
132
132
  test('computeCellFilterGradient right', () => {
133
133
 
134
134
  const grid = new GridData();
135
- const layer = GridDataLayer.from('a', DataType.Uint32);
135
+ const layer = GridDataLayer.from('a', BinaryDataType.Uint32);
136
136
 
137
137
  grid.addLayer(layer);
138
138
  grid.resize(3, 3);
@@ -163,7 +163,7 @@ test('computeCellFilterGradient right', () => {
163
163
  test('computeCellFilterGradient top left', () => {
164
164
 
165
165
  const grid = new GridData();
166
- const layer = GridDataLayer.from('a', DataType.Uint32);
166
+ const layer = GridDataLayer.from('a', BinaryDataType.Uint32);
167
167
  grid.addLayer(layer);
168
168
  grid.resize(3, 3);
169
169
 
@@ -194,7 +194,7 @@ test('computeCellFilterGradient top left', () => {
194
194
  test('computeCellFilterGradient top right', () => {
195
195
 
196
196
  const grid = new GridData();
197
- const layer = GridDataLayer.from('a', DataType.Uint32);
197
+ const layer = GridDataLayer.from('a', BinaryDataType.Uint32);
198
198
 
199
199
  grid.addLayer(layer);
200
200
  grid.resize(3, 3);
@@ -226,7 +226,7 @@ test('computeCellFilterGradient top right', () => {
226
226
  test('computeCellFilterGradient bottom left', () => {
227
227
 
228
228
  const grid = new GridData();
229
- const layer = GridDataLayer.from('a', DataType.Uint32);
229
+ const layer = GridDataLayer.from('a', BinaryDataType.Uint32);
230
230
 
231
231
  grid.addLayer(layer);
232
232
  grid.resize(3, 3);
@@ -258,7 +258,7 @@ test('computeCellFilterGradient bottom left', () => {
258
258
  test('computeCellFilterGradient bottom right', () => {
259
259
 
260
260
  const grid = new GridData();
261
- const layer = GridDataLayer.from('a', DataType.Uint32);
261
+ const layer = GridDataLayer.from('a', BinaryDataType.Uint32);
262
262
 
263
263
  grid.addLayer(layer);
264
264
  grid.resize(3, 3);
@@ -1,9 +1,9 @@
1
1
  import Vector2 from "../../../core/geom/Vector2.js";
2
2
  import { assert } from "../../../core/assert.js";
3
- import { DataType } from "../../../core/collection/table/DataType.js";
3
+ import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
4
4
  import {
5
5
  DataType2TypedArrayConstructorMapping
6
- } from "../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
6
+ } from "../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
7
7
  import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
8
8
 
9
9
  export class GridDataLayer {
@@ -36,13 +36,13 @@ export class GridDataLayer {
36
36
  /**
37
37
  *
38
38
  * @param {string} id
39
- * @param {DataType} type
39
+ * @param {BinaryDataType} type
40
40
  * @param {number} [resolution=1]
41
41
  * @returns {GridDataLayer}
42
42
  */
43
43
  static from(id, type, resolution = 1) {
44
44
  assert.typeOf(id, 'string', 'id');
45
- assert.enum(type, DataType, 'type');
45
+ assert.enum(type, BinaryDataType, 'type');
46
46
  assert.isNumber(resolution, 'resolution');
47
47
 
48
48
  const TypedArrayConstructor = DataType2TypedArrayConstructorMapping[type];
@@ -1,12 +1,12 @@
1
1
  import { GridData } from "../../grid/GridData.js";
2
2
  import { GridCellActionPlaceTags } from "./GridCellActionPlaceTags.js";
3
3
  import { GridDataLayer } from "../../grid/layers/GridDataLayer.js";
4
- import { DataType } from "../../../core/collection/table/DataType.js";
4
+ import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
5
5
 
6
6
  test('write a single 1x1 set of tags', () => {
7
7
  const data = new GridData();
8
8
 
9
- const layer = GridDataLayer.from('a', DataType.Uint32);
9
+ const layer = GridDataLayer.from('a', BinaryDataType.Uint32);
10
10
 
11
11
  data.addLayer(layer);
12
12
 
@@ -1,12 +1,12 @@
1
1
  import { CellMatcherLayerBitMaskTest } from "./CellMatcherLayerBitMaskTest.js";
2
2
  import { GridData } from "../grid/GridData.js";
3
3
  import { GridDataLayer } from "../grid/layers/GridDataLayer.js";
4
- import { DataType } from "../../core/collection/table/DataType.js";
4
+ import { BinaryDataType } from "../../core/binary/type/BinaryDataType.js";
5
5
 
6
6
  test('correct match of a single tag', () => {
7
7
  const data = new GridData();
8
8
 
9
- const layer = GridDataLayer.from('a', DataType.Uint32);
9
+ const layer = GridDataLayer.from('a', BinaryDataType.Uint32);
10
10
  data.addLayer(layer)
11
11
  data.resize(1, 1);
12
12
 
@@ -2,7 +2,7 @@ import { CellMatcherGridPattern } from "./CellMatcherGridPattern.js";
2
2
  import { GridData } from "../../grid/GridData.js";
3
3
  import { CellMatcherLayerBitMaskTest } from "../CellMatcherLayerBitMaskTest.js";
4
4
  import { GridDataLayer } from "../../grid/layers/GridDataLayer.js";
5
- import { DataType } from "../../../core/collection/table/DataType.js";
5
+ import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
6
6
  import { GridPatternMatcherCell } from "./GridPatternMatcherCell.js";
7
7
  import { CellMatcherNot } from "../logic/CellMatcherNot.js";
8
8
 
@@ -34,7 +34,7 @@ test('exact single point match', () => {
34
34
  pattern.addRule(0, 0, CellMatcherLayerBitMaskTest.from(1, 'a'));
35
35
 
36
36
  const data = new GridData();
37
- const tagLayer = GridDataLayer.from('a', DataType.Uint32);
37
+ const tagLayer = GridDataLayer.from('a', BinaryDataType.Uint32);
38
38
 
39
39
  data.addLayer(tagLayer);
40
40
 
@@ -66,7 +66,7 @@ test('match 2-cell horizontal positive line with every rotation', () => {
66
66
  ]);
67
67
 
68
68
  const data = new GridData();
69
- const tagLayer = GridDataLayer.from('a', DataType.Uint32);
69
+ const tagLayer = GridDataLayer.from('a', BinaryDataType.Uint32);
70
70
 
71
71
  data.addLayer(tagLayer);
72
72
 
@@ -102,7 +102,7 @@ test('match 2-cell horizontal negative line with every rotation', () => {
102
102
  ]);
103
103
 
104
104
  const data = new GridData();
105
- const tagLayer = GridDataLayer.from('a', DataType.Uint32);
105
+ const tagLayer = GridDataLayer.from('a', BinaryDataType.Uint32);
106
106
 
107
107
  data.addLayer(tagLayer);
108
108
 
@@ -138,7 +138,7 @@ test('match 2-cell vertical positive line with every rotation', () => {
138
138
  ]);
139
139
 
140
140
  const data = new GridData();
141
- const tagLayer = GridDataLayer.from('a', DataType.Uint32);
141
+ const tagLayer = GridDataLayer.from('a', BinaryDataType.Uint32);
142
142
 
143
143
  data.addLayer(tagLayer);
144
144
 
@@ -174,7 +174,7 @@ test('match 2-cell vertical negative line with every rotation', () => {
174
174
  ]);
175
175
 
176
176
  const data = new GridData();
177
- const tagLayer = GridDataLayer.from('a', DataType.Uint32);
177
+ const tagLayer = GridDataLayer.from('a', BinaryDataType.Uint32);
178
178
 
179
179
  data.addLayer(tagLayer);
180
180
 
@@ -212,7 +212,7 @@ test('match 2x2-cell with every rotation', () => {
212
212
  ]);
213
213
 
214
214
  const data = new GridData();
215
- const tagLayer = GridDataLayer.from('a', DataType.Uint32);
215
+ const tagLayer = GridDataLayer.from('a', BinaryDataType.Uint32);
216
216
 
217
217
  data.addLayer(tagLayer);
218
218
 
@@ -250,7 +250,7 @@ test('match 2x2-cell with every rotation on 4x4 field', () => {
250
250
  ]);
251
251
 
252
252
  const data = new GridData();
253
- const tagLayer = GridDataLayer.from('a', DataType.Uint32);
253
+ const tagLayer = GridDataLayer.from('a', BinaryDataType.Uint32);
254
254
 
255
255
  data.addLayer(tagLayer);
256
256
 
@@ -15,6 +15,37 @@ function computeStringPairHash(pair) {
15
15
  );
16
16
  }
17
17
 
18
+ /**
19
+ *
20
+ * @param {KeyValuePair<string, string>} a
21
+ * @param {KeyValuePair<string, string>} b
22
+ * @returns
23
+ */
24
+ function byKey(a, b) {
25
+ const a_key = a.key;
26
+ const b_key = b.key;
27
+
28
+ if (a_key === b_key) {
29
+ return 0;
30
+ }
31
+
32
+ const a_key_type = typeof a_key;
33
+ const b_key_type = typeof b_key;
34
+
35
+ const type_diff = a_key_type.localeCompare(b_key_type);
36
+
37
+ if (type_diff !== 0) {
38
+ return type_diff;
39
+ }
40
+
41
+ if (a_key_type !== "string") {
42
+ // unexpected types
43
+ return 0;
44
+ }
45
+
46
+ return a_key.localeCompare(b_key);
47
+ }
48
+
18
49
  export class HTMLElementCacheKey {
19
50
 
20
51
  constructor() {
@@ -36,6 +67,84 @@ export class HTMLElementCacheKey {
36
67
  * @type {string}
37
68
  */
38
69
  this.tag = "";
70
+
71
+ /**
72
+ *
73
+ * @type {number}
74
+ * @private
75
+ */
76
+ this.__hash = -1;
77
+ }
78
+
79
+ /**
80
+ *
81
+ * @param {string} name
82
+ * @param {string} value
83
+ */
84
+ setAttribute(name, value) {
85
+
86
+ const existing = this.#getAttributeContainer(name);
87
+
88
+ if (existing !== undefined) {
89
+ if (existing.value === value) {
90
+ // no change
91
+ return;
92
+ }
93
+
94
+ existing.value = value;
95
+ } else {
96
+ this.attributes.push(new KeyValuePair(name, value));
97
+ }
98
+
99
+ this.update();
100
+ }
101
+
102
+ /**
103
+ *
104
+ * @param {string} name
105
+ * @returns {string|null}
106
+ */
107
+ getAttribute(name) {
108
+ const container = this.#getAttributeContainer(name);
109
+
110
+ if (container === undefined) {
111
+ return null;
112
+ }
113
+
114
+ return container.value;
115
+ }
116
+
117
+ /**
118
+ *
119
+ * @param {string} name
120
+ * @returns {undefined|KeyValuePair}
121
+ */
122
+ #getAttributeContainer(name) {
123
+ const attributes = this.attributes;
124
+
125
+ const attribute_count = attributes.length;
126
+ for (let i = 0; i < attribute_count; i++) {
127
+ const attribute = attributes[i];
128
+
129
+ if (attribute.key === name) {
130
+ return attribute;
131
+ }
132
+ }
133
+ // not found
134
+ return undefined;
135
+ }
136
+
137
+ /**
138
+ * Required for equality and hash to work consistently
139
+ */
140
+ #sort() {
141
+ this.attributes.sort(byKey);
142
+ this.style.sort(byKey);
143
+ }
144
+
145
+ update() {
146
+ this.#sort();
147
+ this.#updateHash();
39
148
  }
40
149
 
41
150
  toJSON() {
@@ -125,11 +234,11 @@ export class HTMLElementCacheKey {
125
234
 
126
235
  this.attributes.splice(i, this.attributes.length - i);
127
236
 
128
- this.updateHash();
237
+ this.update();
129
238
  }
130
239
 
131
240
 
132
- updateHash() {
241
+ #updateHash() {
133
242
  //compute style hash
134
243
  const styleHash = computeHashArray(this.style, computeStringPairHash);
135
244
 
@@ -90,7 +90,7 @@ class ImageView extends View {
90
90
  cacheKey.attributes.push(attribute);
91
91
  }
92
92
 
93
- cacheKey.updateHash();
93
+ cacheKey.update();
94
94
 
95
95
 
96
96
  this.el = obtainImageElement(cacheKey);
@@ -98,7 +98,7 @@ export class VideoView extends View {
98
98
  cacheKey.attributes.push(attribute);
99
99
  }
100
100
 
101
- cacheKey.updateHash();
101
+ cacheKey.update();
102
102
 
103
103
 
104
104
  this.el = obtainElement(cacheKey);
@@ -1,34 +0,0 @@
1
- import { DataType } from "./DataType.js";
2
-
3
-
4
- /**
5
- * Mapping from {@DataType} to TypedArray constructors
6
- * @enum {function}
7
- */
8
- export const DataType2TypedArrayConstructorMapping = {
9
- [DataType.Uint8]: Uint8Array,
10
- [DataType.Uint16]: Uint16Array,
11
- [DataType.Uint32]: Uint32Array,
12
- [DataType.Int8]: Int8Array,
13
- [DataType.Int16]: Int16Array,
14
- [DataType.Int32]: Int32Array,
15
- // No float16 array type, using uint16 as a backing instead
16
- [DataType.Float16]: Uint16Array,
17
- [DataType.Float32]: Float32Array,
18
- [DataType.Float64]: Float64Array,
19
- };
20
-
21
- /**
22
- *
23
- * @param {DataType} dt
24
- * @returns {constructor|function}
25
- */
26
- export function compute_typed_array_constructor_from_data_type(dt) {
27
- const r = DataType2TypedArrayConstructorMapping[dt];
28
-
29
- if (r === undefined) {
30
- throw new Error(`Unsupported data type '${dt}'`);
31
- }
32
-
33
- return r;
34
- }
@@ -1,37 +0,0 @@
1
- import { DataType } from "./DataType.js";
2
-
3
- /**
4
- * @readonly
5
- * @enum {number}
6
- */
7
- export const DataTypeByteSizes = {
8
- [DataType.Uint8]: 1,
9
- [DataType.Uint16]: 2,
10
- [DataType.Uint32]: 4,
11
- [DataType.Uint64]: 8,
12
-
13
- [DataType.Int8]: 1,
14
- [DataType.Int16]: 2,
15
- [DataType.Int32]: 4,
16
- [DataType.Int64]: 8,
17
-
18
- [DataType.Float16]: 2,
19
- [DataType.Float32]: 4,
20
- [DataType.Float64]: 8
21
- };
22
-
23
-
24
- /**
25
- *
26
- * @param {DataType} type
27
- * @return {number}
28
- */
29
- export function dataTypeByteSize(type) {
30
- const size = DataTypeByteSizes[type];
31
-
32
- if (size === undefined) {
33
- throw new Error(`Unsupported type '${type}'`);
34
- }
35
-
36
- return size;
37
- }
@@ -1,17 +0,0 @@
1
- import { DataType } from "./DataType.js";
2
-
3
- /***
4
- *
5
- * @enum {number}
6
- */
7
- export const DataTypeIndices = {
8
- [DataType.Uint8]: 0,
9
- [DataType.Uint16]: 1,
10
- [DataType.Uint32]: 2,
11
- [DataType.Int8]: 3,
12
- [DataType.Int16]: 4,
13
- [DataType.Int32]: 5,
14
- [DataType.Float32]: 6,
15
- [DataType.Float64]: 7,
16
- [DataType.Float16]: 8
17
- };