@woosh/meep-engine 2.86.6 → 2.86.7
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 +8 -16
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +8 -16
- package/package.json +1 -1
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts.map +1 -1
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +8 -16
- package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.js +12 -7
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +21 -8
package/build/meep.module.js
CHANGED
|
@@ -58329,25 +58329,20 @@ class TerrainTileManager {
|
|
|
58329
58329
|
|
|
58330
58330
|
const tiles = this.tiles;
|
|
58331
58331
|
|
|
58332
|
-
const self = this;
|
|
58333
|
-
|
|
58334
|
-
function ensureBuilt(x, y) {
|
|
58335
|
-
return function (resolve) {
|
|
58336
|
-
self.obtain(x, y).then(resolve);
|
|
58337
|
-
}
|
|
58338
|
-
}
|
|
58339
|
-
|
|
58340
58332
|
//populate tiles
|
|
58341
|
-
|
|
58333
|
+
const tile_resolution_y = gridSize.y;
|
|
58334
|
+
const tile_resolution_x = gridSize.x;
|
|
58335
|
+
|
|
58336
|
+
for (let y = 0; y < tile_resolution_y; y++) {
|
|
58342
58337
|
|
|
58343
|
-
const tY = y <
|
|
58338
|
+
const tY = y < tile_resolution_y - 1 ? time_size.y : (total_size.y - time_size.y * y);
|
|
58344
58339
|
|
|
58345
|
-
for (let x = 0; x <
|
|
58340
|
+
for (let x = 0; x < tile_resolution_x; x++) {
|
|
58346
58341
|
|
|
58347
|
-
const tX = x <
|
|
58342
|
+
const tX = x < tile_resolution_x - 1 ? time_size.x : (total_size.x - time_size.x * x);
|
|
58348
58343
|
|
|
58349
58344
|
const tile = new TerrainTile();
|
|
58350
|
-
const index = y *
|
|
58345
|
+
const index = y * tile_resolution_x + x;
|
|
58351
58346
|
tiles[index] = tile;
|
|
58352
58347
|
|
|
58353
58348
|
this.assignTileMaterial(tile);
|
|
@@ -58362,9 +58357,6 @@ class TerrainTileManager {
|
|
|
58362
58357
|
tile.setInitialHeightBounds(this.heightRange.min, this.heightRange.max);
|
|
58363
58358
|
tile.computeBoundingBox();
|
|
58364
58359
|
|
|
58365
|
-
//hook for building
|
|
58366
|
-
tile.ensureBuilt = ensureBuilt(x, y);
|
|
58367
|
-
|
|
58368
58360
|
tile.external_bvh.link(this.bvh, index);
|
|
58369
58361
|
}
|
|
58370
58362
|
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TerrainTileManager.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/terrain/tiles/TerrainTileManager.js"],"names":[],"mappings":";AA+BA;IA6DI;;;;;OAKG;IACH,wCAJW,OAAO,EA8BjB;IA5FD;;;OAGG;IACH,OAFU,WAAW,EAAE,CAEZ;IAEX;;;MAGE;IAEF;;;OAGG;IACH,UAFU,OAAO,CAEc;IAE/B;;;OAGG;IACH,WAFU,OAAO,CAEa;IAC9B;;;OAGG;IACH,YAFU,eAAe,CAEW;IAEpC;;;OAGG;IACH,OAFU,OAAO,CAES;IAG1B;;;;OAIG;IACH,oBAAmC;IAEnC;;;OAGG;IACH,cAFU,GAAG,CAEG;IAEhB;;;OAGG;IACH,aAFU,eAAe,CAEe;IAExC;;;OAGG;IACH,yBAFU,OAAO,CAEe;IAqB5B,6BAA2C;IAG3C;;;OAGG;IACH,yBAA8B;IAQlC,iCAWC;IAED,8BAEC;IAED;;;;OAIG;IACH,2BAHW,MAAM,cACN,MAAM,QA8BhB;IAED,mBAIC;IAED;;;OAGG;IACH,yBAFW,WAAW,QAerB;IAED;;;;OAIG;IACH,6CASC;IAED,qBAmBC;IAED;;OAEG;IACH,gBAIC;IAED;;;;;;OAMG;IACH,qBALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAuBhB;IAGD;;;;;;;OAOG;IACH,oCANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,WAAW,EAAE,CAgCzB;IAED,
|
|
1
|
+
{"version":3,"file":"TerrainTileManager.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/terrain/tiles/TerrainTileManager.js"],"names":[],"mappings":";AA+BA;IA6DI;;;;;OAKG;IACH,wCAJW,OAAO,EA8BjB;IA5FD;;;OAGG;IACH,OAFU,WAAW,EAAE,CAEZ;IAEX;;;MAGE;IAEF;;;OAGG;IACH,UAFU,OAAO,CAEc;IAE/B;;;OAGG;IACH,WAFU,OAAO,CAEa;IAC9B;;;OAGG;IACH,YAFU,eAAe,CAEW;IAEpC;;;OAGG;IACH,OAFU,OAAO,CAES;IAG1B;;;;OAIG;IACH,oBAAmC;IAEnC;;;OAGG;IACH,cAFU,GAAG,CAEG;IAEhB;;;OAGG;IACH,aAFU,eAAe,CAEe;IAExC;;;OAGG;IACH,yBAFU,OAAO,CAEe;IAqB5B,6BAA2C;IAG3C;;;OAGG;IACH,yBAA8B;IAQlC,iCAWC;IAED,8BAEC;IAED;;;;OAIG;IACH,2BAHW,MAAM,cACN,MAAM,QA8BhB;IAED,mBAIC;IAED;;;OAGG;IACH,yBAFW,WAAW,QAerB;IAED;;;;OAIG;IACH,6CASC;IAED,qBAmBC;IAED;;OAEG;IACH,gBAIC;IAED;;;;;;OAMG;IACH,qBALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAuBhB;IAGD;;;;;;;OAOG;IACH,oCANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,WAAW,EAAE,CAgCzB;IAED,wBA6CC;IAED;;;;;OAKG;IACH,oBAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;OAKG;IACH,UAJW,MAAM,KACN,MAAM,GACJ,WAAW,GAAC,SAAS,CAiBjC;IAED;;;;;OAKG;IACH,wBAJW,MAAM,KACN,MAAM,GACJ,WAAW,CAavB;IAED;;;;;OAKG;IACH,4BAJW,MAAM,KACN,MAAM,GACL,WAAW,GAAC,SAAS,CAahC;IAED;;;;;OAKG;IACH,+BAJW,MAAM,KACN,MAAM,GACJ,QAAQ,WAAW,CAAC,CAYhC;IAED;;;;;;OAMG;IACH,UALW,MAAM,KACN,MAAM,GACJ,QAAQ,WAAW,CAAC,CA4BhC;IAED;;;OAGG;IACH,cAFW,WAAW,QAcrB;IAED,gBASC;IAED;;;;;;OAMG;IACH,cAJW,MAAM,KACN,MAAM,QACN,WAAW,QAsCrB;IAED;;;;;;;;;;OAUG;IACH,yBATW,aAAa,WACb,MAAM,WACN,MAAM,WACN,MAAM,cACN,MAAM,cACN,MAAM,cACN,MAAM,GACJ,OAAO,CAuDnB;IAED;;;;;;OAMG;IACH,kCALW,aAAa,KACb,MAAM,KACN,MAAM,GACL,OAAO,CAOlB;IAED;;;;;;OAMG;IACH,SALW,MAAM,KACN,MAAM,6CA6DhB;CACJ;wBAvrBuB,kBAAkB;mBAVvB,0CAA0C;oBAGzC,kCAAkC;4BAG1B,2CAA2C;oBAVnD,mCAAmC;gCAQvB,mDAAmD;0BAGzD,yCAAyC;8BALrC,2CAA2C"}
|
|
@@ -331,25 +331,20 @@ class TerrainTileManager {
|
|
|
331
331
|
|
|
332
332
|
const tiles = this.tiles;
|
|
333
333
|
|
|
334
|
-
const self = this;
|
|
335
|
-
|
|
336
|
-
function ensureBuilt(x, y) {
|
|
337
|
-
return function (resolve) {
|
|
338
|
-
self.obtain(x, y).then(resolve);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
334
|
//populate tiles
|
|
343
|
-
|
|
335
|
+
const tile_resolution_y = gridSize.y;
|
|
336
|
+
const tile_resolution_x = gridSize.x;
|
|
337
|
+
|
|
338
|
+
for (let y = 0; y < tile_resolution_y; y++) {
|
|
344
339
|
|
|
345
|
-
const tY = y <
|
|
340
|
+
const tY = y < tile_resolution_y - 1 ? time_size.y : (total_size.y - time_size.y * y);
|
|
346
341
|
|
|
347
|
-
for (let x = 0; x <
|
|
342
|
+
for (let x = 0; x < tile_resolution_x; x++) {
|
|
348
343
|
|
|
349
|
-
const tX = x <
|
|
344
|
+
const tX = x < tile_resolution_x - 1 ? time_size.x : (total_size.x - time_size.x * x);
|
|
350
345
|
|
|
351
346
|
const tile = new TerrainTile();
|
|
352
|
-
const index = y *
|
|
347
|
+
const index = y * tile_resolution_x + x;
|
|
353
348
|
tiles[index] = tile;
|
|
354
349
|
|
|
355
350
|
this.assignTileMaterial(tile);
|
|
@@ -364,9 +359,6 @@ class TerrainTileManager {
|
|
|
364
359
|
tile.setInitialHeightBounds(this.heightRange.min, this.heightRange.max);
|
|
365
360
|
tile.computeBoundingBox();
|
|
366
361
|
|
|
367
|
-
//hook for building
|
|
368
|
-
tile.ensureBuilt = ensureBuilt(x, y);
|
|
369
|
-
|
|
370
362
|
tile.external_bvh.link(this.bvh, index);
|
|
371
363
|
}
|
|
372
364
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampler2d_blur_gaussian.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sampler2d_blur_gaussian.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.js"],"names":[],"mappings":"AAiCA;;;;;;GAMG;AACH,gDALW,SAAS,SACT,SAAS,QACT,MAAM,YACN,MAAM,QAqFhB;0BAxHyB,iBAAiB"}
|
|
@@ -9,14 +9,16 @@ let temp_data = new Float64Array(1);
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
11
11
|
* @param {number} sample_count
|
|
12
|
+
* @param {number} sigma
|
|
12
13
|
* @param {Float32Array} kernel
|
|
13
14
|
*/
|
|
14
|
-
function build_kernel(sample_count, kernel) {
|
|
15
|
-
|
|
15
|
+
function build_kernel(sample_count, sigma, kernel) {
|
|
16
|
+
|
|
17
|
+
const half_width = (sample_count - 1) * 0.5;
|
|
16
18
|
|
|
17
19
|
let kernel_power_sum = 0;
|
|
18
20
|
for (let i = 0; i < sample_count; i++) {
|
|
19
|
-
const local = i -
|
|
21
|
+
const local = i - half_width;
|
|
20
22
|
|
|
21
23
|
const power = gaussian(sigma, local);
|
|
22
24
|
kernel[i] = power;
|
|
@@ -38,11 +40,12 @@ function build_kernel(sample_count, kernel) {
|
|
|
38
40
|
*/
|
|
39
41
|
export function sampler2d_blur_gaussian(output, input, size, quality = 1) {
|
|
40
42
|
|
|
43
|
+
const sigma = size * 3;
|
|
41
44
|
const sample_count = max2(3, makeNextOdd(Math.round(size * quality)));
|
|
42
45
|
|
|
43
46
|
const kernel = new Float32Array(sample_count);
|
|
44
47
|
|
|
45
|
-
build_kernel(sample_count, kernel);
|
|
48
|
+
build_kernel(sample_count, sigma, kernel);
|
|
46
49
|
|
|
47
50
|
const width = input.width;
|
|
48
51
|
const height = input.height;
|
|
@@ -57,8 +60,8 @@ export function sampler2d_blur_gaussian(output, input, size, quality = 1) {
|
|
|
57
60
|
let target = new Sampler2D(temp_data, channel_count, width, height);
|
|
58
61
|
|
|
59
62
|
const half_samples = (sample_count - 1) * 0.5;
|
|
60
|
-
const local_u_scale =
|
|
61
|
-
const local_v_scale =
|
|
63
|
+
const local_u_scale = size / (sample_count - 1);
|
|
64
|
+
const local_v_scale = size / (sample_count - 1);
|
|
62
65
|
|
|
63
66
|
const sample = new Float64Array(channel_count);
|
|
64
67
|
|
|
@@ -90,6 +93,8 @@ export function sampler2d_blur_gaussian(output, input, size, quality = 1) {
|
|
|
90
93
|
source = target;
|
|
91
94
|
target = output;
|
|
92
95
|
|
|
96
|
+
// typed_array_copy(source.data, target.data);
|
|
97
|
+
|
|
93
98
|
// vertical pass
|
|
94
99
|
for (let y = 0; y < height; y++) {
|
|
95
100
|
for (let x = 0; x < width; x++) {
|
|
@@ -99,7 +104,7 @@ export function sampler2d_blur_gaussian(output, input, size, quality = 1) {
|
|
|
99
104
|
|
|
100
105
|
const local_y = iy - half_samples;
|
|
101
106
|
|
|
102
|
-
const sample_y =
|
|
107
|
+
const sample_y = y + local_y * local_v_scale;
|
|
103
108
|
|
|
104
109
|
const power = kernel[iy];
|
|
105
110
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellFilterGaussianBlur.d.ts","sourceRoot":"","sources":["../../../../../../src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CellFilterGaussianBlur.d.ts","sourceRoot":"","sources":["../../../../../../src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js"],"names":[],"mappings":"AA6DA;IA8EI;;;;;;;OAOG;IACH,oBANW,UAAU,KACV,MAAM,KACN,MAAM,YACN,MAAM,GACJ,sBAAsB,CAkBlC;IAlGG,kBAAkB;IAClB,kBAAkB;IAElB,gBAAiB;IACjB,gBAAiB;IAEjB;;;OAGG;IACH,QAFU,UAAU,CAEF;IAElB,eAAe;IACf,eAAe;IAEf;;;;OAIG;IACH,iBAAkB;IAElB;;;;OAIG;IACH,6BAA6B;IAE7B;;;;OAIG;IACH,iCAAiC;IAEjC;;;;OAIG;IACH,wBAAwB;IAExB;;;;OAIG;IACH,wBAAwB;IAG5B,uCAoBC;IA6BD,0DA8CC;CACJ;2BAhN0B,qBAAqB"}
|
|
@@ -13,12 +13,16 @@ import { CellFilter } from "../../CellFilter.js";
|
|
|
13
13
|
* @param {number} sigma_y
|
|
14
14
|
* @return {number}
|
|
15
15
|
*/
|
|
16
|
-
function buildKernel(
|
|
16
|
+
function buildKernel(
|
|
17
|
+
result,
|
|
18
|
+
samplesX, samplesY,
|
|
19
|
+
sigma_x, sigma_y
|
|
20
|
+
) {
|
|
17
21
|
assert.isNonNegativeInteger(samplesX, 'samplesX');
|
|
18
22
|
assert.isNonNegativeInteger(samplesY, 'samplesY');
|
|
19
23
|
|
|
20
|
-
const half_samples_x = samplesX * 0.5;
|
|
21
|
-
const half_samples_y = samplesY * 0.5;
|
|
24
|
+
const half_samples_x = (samplesX - 1) * 0.5;
|
|
25
|
+
const half_samples_y = (samplesY - 1) * 0.5;
|
|
22
26
|
|
|
23
27
|
let powerTotal = 0;
|
|
24
28
|
let ix, iy;
|
|
@@ -45,7 +49,14 @@ function buildKernel(result, samplesX, samplesY, sigma_x, sigma_y) {
|
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
const inv_total_power = 1 / powerTotal;
|
|
53
|
+
|
|
54
|
+
// normalize kernel
|
|
55
|
+
for (let i = 0; i < samplesX * samplesY; i++) {
|
|
56
|
+
result[i] *= inv_total_power;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return 1;
|
|
49
60
|
}
|
|
50
61
|
|
|
51
62
|
export class CellFilterGaussianBlur extends CellFilter {
|
|
@@ -117,9 +128,6 @@ export class CellFilterGaussianBlur extends CellFilter {
|
|
|
117
128
|
// initialize kernel
|
|
118
129
|
this.__kernel_total_power = buildKernel(this.__kernel, this.samples_x, this.samples_y, this.sigma_x, this.sigma_y);
|
|
119
130
|
|
|
120
|
-
// store inverse, to be able to use multiply instead of division in execution
|
|
121
|
-
this.__inv_kernel_total_power = 1 / this.__kernel_total_power;
|
|
122
|
-
|
|
123
131
|
|
|
124
132
|
// precompute scaling for the sampling(execute) stage
|
|
125
133
|
this.__local_u_scale = this.size_x / (this.samples_x - 1);
|
|
@@ -148,6 +156,10 @@ export class CellFilterGaussianBlur extends CellFilter {
|
|
|
148
156
|
r.size_x = x;
|
|
149
157
|
r.size_y = y;
|
|
150
158
|
|
|
159
|
+
// sigma should scale with radius
|
|
160
|
+
r.sigma_x = x * 3;
|
|
161
|
+
r.sigma_y = y * 3;
|
|
162
|
+
|
|
151
163
|
return r;
|
|
152
164
|
}
|
|
153
165
|
|
|
@@ -195,6 +207,7 @@ export class CellFilterGaussianBlur extends CellFilter {
|
|
|
195
207
|
}
|
|
196
208
|
}
|
|
197
209
|
|
|
198
|
-
|
|
210
|
+
// note that the kernel is already normalized, so we don't need to do anything special here
|
|
211
|
+
return sum;
|
|
199
212
|
}
|
|
200
213
|
}
|