@woosh/meep-engine 2.46.36 → 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.
- package/build/meep.cjs +108 -86
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +108 -86
- package/package.json +3 -2
- package/src/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +4 -2
- package/src/engine/graphics/micron/prototypeVirtualGeometry.js +2 -2
- package/src/engine/graphics/texture/sampler/Sampler2D.js +4 -82
- package/src/engine/graphics/texture/sampler/Sampler2D.spec.js +0 -37
- package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.js +2 -2
- package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +2 -2
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_max.js +51 -0
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_max.spec.js +40 -0
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min.js +51 -0
- package/src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js +4 -2
- package/src/engine/graphics/texture/sampler/{sampler2D_scale_down_linear.js → sampler2d_scale_down_linear.js} +1 -1
- package/src/engine/graphics/texture/sampler/{downsampleSample2D.spec.js → sampler2d_scale_down_linear.spec.js} +2 -2
- package/src/engine/graphics/texture/sampler/{sample2d_write_to_canvas_raw.js → sampler2d_write_to_canvas_raw.js} +5 -1
- package/src/engine/graphics/texture/sampler/scaleSampler2D.js +2 -2
- package/src/engine/input/ecs/util/TerrainCameraTargetSampler.js +2 -2
package/build/meep.cjs
CHANGED
|
@@ -48208,51 +48208,12 @@ class Sampler2D {
|
|
|
48208
48208
|
}
|
|
48209
48209
|
|
|
48210
48210
|
/**
|
|
48211
|
+
* @deprecated
|
|
48211
48212
|
* @param {number} [channel=0]
|
|
48212
48213
|
* @returns {{x: number, index: number, y: number, value: number}}
|
|
48213
48214
|
*/
|
|
48214
48215
|
computeMax(channel = 0) {
|
|
48215
|
-
|
|
48216
|
-
|
|
48217
|
-
assert.isNumber(channel, "channel");
|
|
48218
|
-
assert.isNonNegativeInteger(channel , 'channel');
|
|
48219
|
-
assert.lessThan(channel, itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
|
|
48220
|
-
|
|
48221
|
-
const data = this.data;
|
|
48222
|
-
|
|
48223
|
-
const l = data.length;
|
|
48224
|
-
|
|
48225
|
-
if (l === 0) {
|
|
48226
|
-
//no data
|
|
48227
|
-
return undefined;
|
|
48228
|
-
}
|
|
48229
|
-
|
|
48230
|
-
let bestValue = data[channel];
|
|
48231
|
-
let bestIndex = channel;
|
|
48232
|
-
|
|
48233
|
-
for (let i = channel + itemSize; i < l; i += itemSize) {
|
|
48234
|
-
const value = data[i];
|
|
48235
|
-
|
|
48236
|
-
if (bestValue < value) {
|
|
48237
|
-
bestValue = value;
|
|
48238
|
-
bestIndex = i;
|
|
48239
|
-
}
|
|
48240
|
-
|
|
48241
|
-
}
|
|
48242
|
-
|
|
48243
|
-
const width = this.width;
|
|
48244
|
-
|
|
48245
|
-
const itemIndex = (bestIndex / this.itemSize) | 0;
|
|
48246
|
-
|
|
48247
|
-
const x = itemIndex % width;
|
|
48248
|
-
const y = (itemIndex / width) | 0;
|
|
48249
|
-
|
|
48250
|
-
return {
|
|
48251
|
-
index: bestIndex,
|
|
48252
|
-
value: bestValue,
|
|
48253
|
-
x,
|
|
48254
|
-
y
|
|
48255
|
-
};
|
|
48216
|
+
throw new Error("deprecated, use sampler2d_channel_compute_max");
|
|
48256
48217
|
}
|
|
48257
48218
|
|
|
48258
48219
|
/**
|
|
@@ -48305,51 +48266,12 @@ class Sampler2D {
|
|
|
48305
48266
|
}
|
|
48306
48267
|
|
|
48307
48268
|
/**
|
|
48269
|
+
* @deprecated
|
|
48308
48270
|
* @param {number} [channel=0]
|
|
48309
48271
|
* @returns {{x: number, index: number, y: number, value: number}}
|
|
48310
48272
|
*/
|
|
48311
48273
|
computeMin(channel = 0) {
|
|
48312
|
-
|
|
48313
|
-
|
|
48314
|
-
assert.typeOf(channel, "number", "channel");
|
|
48315
|
-
assert.ok(channel >= 0, `channel must be >= 0, was ${channel}`);
|
|
48316
|
-
assert.ok(channel < itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
|
|
48317
|
-
|
|
48318
|
-
const data = this.data;
|
|
48319
|
-
|
|
48320
|
-
const l = data.length;
|
|
48321
|
-
|
|
48322
|
-
if (l === 0) {
|
|
48323
|
-
//no data
|
|
48324
|
-
return undefined;
|
|
48325
|
-
}
|
|
48326
|
-
|
|
48327
|
-
let bestValue = data[channel];
|
|
48328
|
-
let bestIndex = channel;
|
|
48329
|
-
|
|
48330
|
-
for (let i = channel + itemSize; i < l; i += itemSize) {
|
|
48331
|
-
const value = data[i];
|
|
48332
|
-
|
|
48333
|
-
if (bestValue > value) {
|
|
48334
|
-
bestValue = value;
|
|
48335
|
-
bestIndex = i;
|
|
48336
|
-
}
|
|
48337
|
-
|
|
48338
|
-
}
|
|
48339
|
-
|
|
48340
|
-
const width = this.width;
|
|
48341
|
-
|
|
48342
|
-
const itemIndex = (bestIndex / this.itemSize) | 0;
|
|
48343
|
-
|
|
48344
|
-
const x = itemIndex % width;
|
|
48345
|
-
const y = (itemIndex / width) | 0;
|
|
48346
|
-
|
|
48347
|
-
return {
|
|
48348
|
-
index: bestIndex,
|
|
48349
|
-
value: bestValue,
|
|
48350
|
-
x,
|
|
48351
|
-
y
|
|
48352
|
-
};
|
|
48274
|
+
throw new Error("deprecated, use sampler2d_channel_compute_min");
|
|
48353
48275
|
}
|
|
48354
48276
|
|
|
48355
48277
|
/**
|
|
@@ -54840,7 +54762,7 @@ class ObservedString extends String {
|
|
|
54840
54762
|
* @param {Sampler2D} input
|
|
54841
54763
|
* @param {Sampler2D} output
|
|
54842
54764
|
*/
|
|
54843
|
-
function
|
|
54765
|
+
function sampler2d_scale_down_linear(input, output) {
|
|
54844
54766
|
assert.notEqual(input, undefined, 'input is undefined');
|
|
54845
54767
|
assert.notEqual(output, undefined, 'output is undefined');
|
|
54846
54768
|
|
|
@@ -55053,7 +54975,7 @@ function scaleSampler2D(input, output) {
|
|
|
55053
54975
|
// downscaling
|
|
55054
54976
|
if (Number.isInteger(sourceWidth / targetWidth) && Number.isInteger(sourceHeight / targetHeight)) {
|
|
55055
54977
|
// dimensions are multiples of source/target
|
|
55056
|
-
|
|
54978
|
+
sampler2d_scale_down_linear(input, output);
|
|
55057
54979
|
} else {
|
|
55058
54980
|
// generic downsample
|
|
55059
54981
|
genericResampleSampler2D(input, output);
|
|
@@ -65569,6 +65491,106 @@ WorkerBuilder.prototype.build = function () {
|
|
|
65569
65491
|
return proxy;
|
|
65570
65492
|
};
|
|
65571
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
|
+
|
|
65572
65594
|
/**
|
|
65573
65595
|
*
|
|
65574
65596
|
* @return {WorkerProxy}
|
|
@@ -65596,8 +65618,8 @@ function makeTerrainWorkerProxy() {
|
|
|
65596
65618
|
|
|
65597
65619
|
useSampler(function (sampler) {
|
|
65598
65620
|
|
|
65599
|
-
const min = sampler
|
|
65600
|
-
const max = sampler
|
|
65621
|
+
const min = sampler2d_channel_compute_min(sampler);
|
|
65622
|
+
const max = sampler2d_channel_compute_max(sampler);
|
|
65601
65623
|
|
|
65602
65624
|
resolve({
|
|
65603
65625
|
min: min.value,
|