@woosh/meep-engine 2.86.6 → 2.87.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.
- package/build/meep.cjs +24 -19
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +24 -19
- package/package.json +1 -1
- package/src/engine/ecs/EntityManager.d.ts.map +1 -1
- package/src/engine/ecs/EntityManager.js +17 -3
- 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;
|
|
58342
58335
|
|
|
58343
|
-
|
|
58336
|
+
for (let y = 0; y < tile_resolution_y; y++) {
|
|
58344
58337
|
|
|
58345
|
-
|
|
58338
|
+
const tY = y < tile_resolution_y - 1 ? time_size.y : (total_size.y - time_size.y * y);
|
|
58346
58339
|
|
|
58347
|
-
|
|
58340
|
+
for (let x = 0; x < tile_resolution_x; x++) {
|
|
58341
|
+
|
|
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
|
}
|
|
@@ -71710,6 +71702,14 @@ class EntityManager {
|
|
|
71710
71702
|
*/
|
|
71711
71703
|
fixedUpdateStepSize = 0.015;
|
|
71712
71704
|
|
|
71705
|
+
/**
|
|
71706
|
+
* How long can any given system run it's fixedUpdate, per simulation update
|
|
71707
|
+
* This is value allows us to avoid cases where fixedUpdate takes longer that its time step and causes a runaway freeze
|
|
71708
|
+
* In milliseconds
|
|
71709
|
+
* @type {number}
|
|
71710
|
+
*/
|
|
71711
|
+
fixedUpdatePerSystemExecutionTimeLimit = 15;
|
|
71712
|
+
|
|
71713
71713
|
/**
|
|
71714
71714
|
*
|
|
71715
71715
|
* @type {EntityComponentDataset}
|
|
@@ -71931,6 +71931,7 @@ class EntityManager {
|
|
|
71931
71931
|
return null;
|
|
71932
71932
|
}
|
|
71933
71933
|
|
|
71934
|
+
|
|
71934
71935
|
/**
|
|
71935
71936
|
* Advance simulation forward by a specified amount of time
|
|
71936
71937
|
* @param {number} timeDelta in seconds
|
|
@@ -71960,7 +71961,7 @@ class EntityManager {
|
|
|
71960
71961
|
if (system.fixedUpdate !== noop) {
|
|
71961
71962
|
let accumulated_time = accumulatedTime.get(system) + timeDelta;
|
|
71962
71963
|
|
|
71963
|
-
|
|
71964
|
+
const t0 = performance.now();
|
|
71964
71965
|
while (accumulated_time >= fixed_step) {
|
|
71965
71966
|
|
|
71966
71967
|
try {
|
|
@@ -71969,6 +71970,10 @@ class EntityManager {
|
|
|
71969
71970
|
}
|
|
71970
71971
|
|
|
71971
71972
|
accumulated_time -= fixed_step;
|
|
71973
|
+
|
|
71974
|
+
if (performance.now() - t0 > this.fixedUpdatePerSystemExecutionTimeLimit) {
|
|
71975
|
+
break;
|
|
71976
|
+
}
|
|
71972
71977
|
}
|
|
71973
71978
|
|
|
71974
71979
|
// record whatever remains
|
|
@@ -72046,9 +72051,9 @@ class EntityManager {
|
|
|
72046
72051
|
}
|
|
72047
72052
|
|
|
72048
72053
|
// Link EntityManager
|
|
72049
|
-
if(system.entityManager === null){
|
|
72054
|
+
if (system.entityManager === null) {
|
|
72050
72055
|
system.entityManager = this;
|
|
72051
|
-
}else if(system.entityManager !== this){
|
|
72056
|
+
} else if (system.entityManager !== this) {
|
|
72052
72057
|
throw new Error(`System is bound to another EntityManager`);
|
|
72053
72058
|
}
|
|
72054
72059
|
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityManager.js"],"names":[],"mappings":";;;wBAkBU,MAAM;;;;;;iCAWN,MAAM;;;;;;;;;AAWhB;IAEI;;;OAGG;IACH,kBAFU,iCAAQ,CAEL;IAEb;;;OAGG;IACH,gCAFU,iCAAQ,CAES;IAE3B;;;OAGG;IACH,0BAFU,cAAc,EAAE,CAEL;IAErB;;OAEG;IACH;;;QAGI;;WAEG;qBADO,uCAAc;;MAI1B;IAEF;;;OAGG;IACH,OAFU,kBAAkB,CAEO;IAEnC;;;;OAIG;IACH,gDAA2C;IAE3C;;;;OAIG;IACH,qBAFU,MAAM,CAEY;IAE5B;;;OAGG;IACH,gCAAe;IAEf;;;;OAIG;IACH,uCAAsC;IAEtC;;;OAGG;IACH,6BA8EC;IAED,sBAcC;IAED;;;OAGG;IACH,uBAFa,OAAO,CAuBnB;IAED;;;;;OAKG;IACH,qDAsBC;IAED;;;;OAIG;IACH,qCAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,6CAcC;IAED;;;;;OAKG;IACH,wCAHW,MAAM,GACJ,IAAI,aAAS,CAezB;
|
|
1
|
+
{"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityManager.js"],"names":[],"mappings":";;;wBAkBU,MAAM;;;;;;iCAWN,MAAM;;;;;;;;;AAWhB;IAEI;;;OAGG;IACH,kBAFU,iCAAQ,CAEL;IAEb;;;OAGG;IACH,gCAFU,iCAAQ,CAES;IAE3B;;;OAGG;IACH,0BAFU,cAAc,EAAE,CAEL;IAErB;;OAEG;IACH;;;QAGI;;WAEG;qBADO,uCAAc;;MAI1B;IAEF;;;OAGG;IACH,OAFU,kBAAkB,CAEO;IAEnC;;;;OAIG;IACH,gDAA2C;IAE3C;;;;OAIG;IACH,qBAFU,MAAM,CAEY;IAE5B;;;;;OAKG;IACH,wCAFU,MAAM,CAE4B;IAE5C;;;OAGG;IACH,gCAAe;IAEf;;;;OAIG;IACH,uCAAsC;IAEtC;;;OAGG;IACH,6BA8EC;IAED,sBAcC;IAED;;;OAGG;IACH,uBAFa,OAAO,CAuBnB;IAED;;;;;OAKG;IACH,qDAsBC;IAED;;;;OAIG;IACH,qCAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,6CAcC;IAED;;;;;OAKG;IACH,wCAHW,MAAM,GACJ,IAAI,aAAS,CAezB;IAGD;;;OAGG;IACH,oBAFW,MAAM,QAkEhB;IAED;;;;;OAKG;IACH,iEA0EC;IAED;;;;OAIG;IACH,uDAFa,QAAQ,OAAO,CAAC,CAyC5B;IAED;;;;;OAKG;IACH,mBA6BC;IAED;;;;;OAKG;IACH,oBAwCC;IAED;;;;OAIG;IACH,gEAwEC;IAED;;;;OAIG;IACH,mCAFa,wCAAgB,CA0B5B;IAED;;;;;OAKG;IACH,8DAFa,wCAAgB,CAsB5B;IAED;;;;OAIG;IACH,iEAkEC;CACJ;uBApyBsD,aAAa;+BADrC,qBAAqB;mBALjC,oCAAoC"}
|
|
@@ -91,6 +91,14 @@ export class EntityManager {
|
|
|
91
91
|
*/
|
|
92
92
|
fixedUpdateStepSize = 0.015;
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* How long can any given system run it's fixedUpdate, per simulation update
|
|
96
|
+
* This is value allows us to avoid cases where fixedUpdate takes longer that its time step and causes a runaway freeze
|
|
97
|
+
* In milliseconds
|
|
98
|
+
* @type {number}
|
|
99
|
+
*/
|
|
100
|
+
fixedUpdatePerSystemExecutionTimeLimit = 15;
|
|
101
|
+
|
|
94
102
|
/**
|
|
95
103
|
*
|
|
96
104
|
* @type {EntityComponentDataset}
|
|
@@ -312,6 +320,7 @@ export class EntityManager {
|
|
|
312
320
|
return null;
|
|
313
321
|
}
|
|
314
322
|
|
|
323
|
+
|
|
315
324
|
/**
|
|
316
325
|
* Advance simulation forward by a specified amount of time
|
|
317
326
|
* @param {number} timeDelta in seconds
|
|
@@ -347,7 +356,7 @@ export class EntityManager {
|
|
|
347
356
|
if (system.fixedUpdate !== noop) {
|
|
348
357
|
let accumulated_time = accumulatedTime.get(system) + timeDelta;
|
|
349
358
|
|
|
350
|
-
|
|
359
|
+
const t0 = performance.now();
|
|
351
360
|
while (accumulated_time >= fixed_step) {
|
|
352
361
|
|
|
353
362
|
try {
|
|
@@ -357,6 +366,11 @@ export class EntityManager {
|
|
|
357
366
|
}
|
|
358
367
|
|
|
359
368
|
accumulated_time -= fixed_step;
|
|
369
|
+
|
|
370
|
+
if (performance.now() - t0 > this.fixedUpdatePerSystemExecutionTimeLimit) {
|
|
371
|
+
console.warn(`.fixedUpdate of system '${computeSystemName(system)}' is falling behind current clock due to slow execution. Retardation is done to avoid severe performance impact.`);
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
360
374
|
}
|
|
361
375
|
|
|
362
376
|
// record whatever remains
|
|
@@ -438,9 +452,9 @@ export class EntityManager {
|
|
|
438
452
|
}
|
|
439
453
|
|
|
440
454
|
// Link EntityManager
|
|
441
|
-
if(system.entityManager === null){
|
|
455
|
+
if (system.entityManager === null) {
|
|
442
456
|
system.entityManager = this;
|
|
443
|
-
}else if(system.entityManager !== this){
|
|
457
|
+
} else if (system.entityManager !== this) {
|
|
444
458
|
throw new Error(`System is bound to another EntityManager`);
|
|
445
459
|
}
|
|
446
460
|
|
|
@@ -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
|
}
|