@woosh/meep-engine 2.46.35 → 2.47.1

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 (22) hide show
  1. package/build/meep.cjs +112 -86
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +112 -86
  4. package/package.json +3 -2
  5. package/src/core/geom/3d/plane/orient3d_fast.js +2 -2
  6. package/src/core/model/node-graph/NodeGraph.js +4 -0
  7. package/src/core/model/node-graph/node/NodeDescription.js +55 -4
  8. package/src/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +4 -2
  9. package/src/engine/graphics/micron/prototypeVirtualGeometry.js +2 -2
  10. package/src/engine/graphics/texture/sampler/Sampler2D.js +8 -82
  11. package/src/engine/graphics/texture/sampler/Sampler2D.spec.js +0 -37
  12. package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.js +2 -2
  13. package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +2 -2
  14. package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_max.js +51 -0
  15. package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_max.spec.js +40 -0
  16. package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min.js +51 -0
  17. package/src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js +4 -2
  18. package/src/engine/graphics/texture/sampler/{sampler2D_scale_down_linear.js → sampler2d_scale_down_linear.js} +1 -1
  19. package/src/engine/graphics/texture/sampler/{downsampleSample2D.spec.js → sampler2d_scale_down_linear.spec.js} +2 -2
  20. package/src/engine/graphics/texture/sampler/{sample2d_write_to_canvas_raw.js → sampler2d_write_to_canvas_raw.js} +5 -1
  21. package/src/engine/graphics/texture/sampler/scaleSampler2D.js +2 -2
  22. package/src/engine/input/ecs/util/TerrainCameraTargetSampler.js +2 -2
package/build/meep.cjs CHANGED
@@ -48167,6 +48167,10 @@ class Sampler2D {
48167
48167
  throw new Error("data was undefined");
48168
48168
  }
48169
48169
 
48170
+ if (data.length < width * height * itemSize) {
48171
+ throw new Error(`Buffer underflow, data.length(=${data.length}) is too small. Expected at least ${width * height * itemSize}`);
48172
+ }
48173
+
48170
48174
  /**
48171
48175
  *
48172
48176
  * @type {Number}
@@ -48204,51 +48208,12 @@ class Sampler2D {
48204
48208
  }
48205
48209
 
48206
48210
  /**
48211
+ * @deprecated
48207
48212
  * @param {number} [channel=0]
48208
48213
  * @returns {{x: number, index: number, y: number, value: number}}
48209
48214
  */
48210
48215
  computeMax(channel = 0) {
48211
- const itemSize = this.itemSize;
48212
-
48213
- assert.typeOf(channel, "number", "channel");
48214
- assert.ok(channel >= 0, `channel must be >= 0, was ${channel}`);
48215
- assert.ok(channel < itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
48216
-
48217
- const data = this.data;
48218
-
48219
- const l = data.length;
48220
-
48221
- if (l === 0) {
48222
- //no data
48223
- return undefined;
48224
- }
48225
-
48226
- let bestValue = data[channel];
48227
- let bestIndex = channel;
48228
-
48229
- for (let i = channel + itemSize; i < l; i += itemSize) {
48230
- const value = data[i];
48231
-
48232
- if (bestValue < value) {
48233
- bestValue = value;
48234
- bestIndex = i;
48235
- }
48236
-
48237
- }
48238
-
48239
- const width = this.width;
48240
-
48241
- const itemIndex = (bestIndex / this.itemSize) | 0;
48242
-
48243
- const x = itemIndex % width;
48244
- const y = (itemIndex / width) | 0;
48245
-
48246
- return {
48247
- index: bestIndex,
48248
- value: bestValue,
48249
- x,
48250
- y
48251
- };
48216
+ throw new Error("deprecated, use sampler2d_channel_compute_max");
48252
48217
  }
48253
48218
 
48254
48219
  /**
@@ -48301,51 +48266,12 @@ class Sampler2D {
48301
48266
  }
48302
48267
 
48303
48268
  /**
48269
+ * @deprecated
48304
48270
  * @param {number} [channel=0]
48305
48271
  * @returns {{x: number, index: number, y: number, value: number}}
48306
48272
  */
48307
48273
  computeMin(channel = 0) {
48308
- const itemSize = this.itemSize;
48309
-
48310
- assert.typeOf(channel, "number", "channel");
48311
- assert.ok(channel >= 0, `channel must be >= 0, was ${channel}`);
48312
- assert.ok(channel < itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
48313
-
48314
- const data = this.data;
48315
-
48316
- const l = data.length;
48317
-
48318
- if (l === 0) {
48319
- //no data
48320
- return undefined;
48321
- }
48322
-
48323
- let bestValue = data[channel];
48324
- let bestIndex = channel;
48325
-
48326
- for (let i = channel + itemSize; i < l; i += itemSize) {
48327
- const value = data[i];
48328
-
48329
- if (bestValue > value) {
48330
- bestValue = value;
48331
- bestIndex = i;
48332
- }
48333
-
48334
- }
48335
-
48336
- const width = this.width;
48337
-
48338
- const itemIndex = (bestIndex / this.itemSize) | 0;
48339
-
48340
- const x = itemIndex % width;
48341
- const y = (itemIndex / width) | 0;
48342
-
48343
- return {
48344
- index: bestIndex,
48345
- value: bestValue,
48346
- x,
48347
- y
48348
- };
48274
+ throw new Error("deprecated, use sampler2d_channel_compute_min");
48349
48275
  }
48350
48276
 
48351
48277
  /**
@@ -54836,7 +54762,7 @@ class ObservedString extends String {
54836
54762
  * @param {Sampler2D} input
54837
54763
  * @param {Sampler2D} output
54838
54764
  */
54839
- function sampler2D_scale_down_linear(input, output) {
54765
+ function sampler2d_scale_down_linear(input, output) {
54840
54766
  assert.notEqual(input, undefined, 'input is undefined');
54841
54767
  assert.notEqual(output, undefined, 'output is undefined');
54842
54768
 
@@ -55049,7 +54975,7 @@ function scaleSampler2D(input, output) {
55049
54975
  // downscaling
55050
54976
  if (Number.isInteger(sourceWidth / targetWidth) && Number.isInteger(sourceHeight / targetHeight)) {
55051
54977
  // dimensions are multiples of source/target
55052
- sampler2D_scale_down_linear(input, output);
54978
+ sampler2d_scale_down_linear(input, output);
55053
54979
  } else {
55054
54980
  // generic downsample
55055
54981
  genericResampleSampler2D(input, output);
@@ -65565,6 +65491,106 @@ WorkerBuilder.prototype.build = function () {
65565
65491
  return proxy;
65566
65492
  };
65567
65493
 
65494
+ /**
65495
+ *
65496
+ * @param {Sampler2D} sampler
65497
+ * @param {number} [channel=0]
65498
+ * @returns {undefined|{x: number, index:number, y: number, value: number}}
65499
+ */
65500
+ function sampler2d_channel_compute_max(sampler, channel=0){
65501
+ const itemSize = sampler.itemSize;
65502
+
65503
+ assert.isNumber(channel, "channel");
65504
+ assert.isNonNegativeInteger(channel , 'channel');
65505
+ assert.lessThan(channel, itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
65506
+
65507
+ const data = sampler.data;
65508
+
65509
+ const l = data.length;
65510
+
65511
+ if (l === 0) {
65512
+ //no data
65513
+ return undefined;
65514
+ }
65515
+
65516
+ let bestValue = data[channel];
65517
+ let bestIndex = channel;
65518
+
65519
+ for (let i = channel + itemSize; i < l; i += itemSize) {
65520
+ const value = data[i];
65521
+
65522
+ if (bestValue < value) {
65523
+ bestValue = value;
65524
+ bestIndex = i;
65525
+ }
65526
+
65527
+ }
65528
+
65529
+ const width = this.width;
65530
+
65531
+ const itemIndex = (bestIndex / itemSize) | 0;
65532
+
65533
+ const x = itemIndex % width;
65534
+ const y = (itemIndex / width) | 0;
65535
+
65536
+ return {
65537
+ index: bestIndex,
65538
+ value: bestValue,
65539
+ x,
65540
+ y
65541
+ };
65542
+ }
65543
+
65544
+ /**
65545
+ *
65546
+ * @param {Sampler2D} sampler
65547
+ * @param {number} [channel=0]
65548
+ * @returns {undefined|{x: number, index:number, y: number, value: number}}
65549
+ */
65550
+ function sampler2d_channel_compute_min(sampler, channel=0){
65551
+ const itemSize = sampler.itemSize;
65552
+
65553
+ assert.isNumber(channel, "channel");
65554
+ assert.isNonNegativeInteger(channel , 'channel');
65555
+ assert.lessThan(channel, itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
65556
+
65557
+ const data = sampler.data;
65558
+
65559
+ const l = data.length;
65560
+
65561
+ if (l === 0) {
65562
+ //no data
65563
+ return undefined;
65564
+ }
65565
+
65566
+ let bestValue = data[channel];
65567
+ let bestIndex = channel;
65568
+
65569
+ for (let i = channel + itemSize; i < l; i += itemSize) {
65570
+ const value = data[i];
65571
+
65572
+ if (bestValue > value) {
65573
+ bestValue = value;
65574
+ bestIndex = i;
65575
+ }
65576
+
65577
+ }
65578
+
65579
+ const width = this.width;
65580
+
65581
+ const itemIndex = (bestIndex / itemSize) | 0;
65582
+
65583
+ const x = itemIndex % width;
65584
+ const y = (itemIndex / width) | 0;
65585
+
65586
+ return {
65587
+ index: bestIndex,
65588
+ value: bestValue,
65589
+ x,
65590
+ y
65591
+ };
65592
+ }
65593
+
65568
65594
  /**
65569
65595
  *
65570
65596
  * @return {WorkerProxy}
@@ -65592,8 +65618,8 @@ function makeTerrainWorkerProxy() {
65592
65618
 
65593
65619
  useSampler(function (sampler) {
65594
65620
 
65595
- const min = sampler.computeMin();
65596
- const max = sampler.computeMax();
65621
+ const min = sampler2d_channel_compute_min(sampler);
65622
+ const max = sampler2d_channel_compute_max(sampler);
65597
65623
 
65598
65624
  resolve({
65599
65625
  min: min.value,