@adatechnology/game-fluids-three 0.2.3 → 0.3.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/dist/index.d.ts +14 -0
- package/dist/index.global.js +909 -233
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +29 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1283,6 +1283,19 @@ var FilmGrid = class {
|
|
|
1283
1283
|
this.pending = this.union(this.pending, rect);
|
|
1284
1284
|
return this.takePending();
|
|
1285
1285
|
}
|
|
1286
|
+
/** Clears the cells less than `maxDryness` dry and sends the rectangle that held them up with the next update. Returns how many it cleared. */
|
|
1287
|
+
wash(maxDryness) {
|
|
1288
|
+
const cleared = this.film.wash(maxDryness);
|
|
1289
|
+
if (cleared > 0) {
|
|
1290
|
+
const bounds = this.film.simulator.bounds;
|
|
1291
|
+
if (bounds.lastRow >= 0) {
|
|
1292
|
+
const rect = { firstRow: bounds.firstRow, lastRow: bounds.lastRow, firstColumn: bounds.firstColumn, lastColumn: bounds.lastColumn };
|
|
1293
|
+
this.encode(rect);
|
|
1294
|
+
this.pending = this.union(this.pending, rect);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
return cleared;
|
|
1298
|
+
}
|
|
1286
1299
|
takePending() {
|
|
1287
1300
|
const rect = this.pending;
|
|
1288
1301
|
this.pending = null;
|
|
@@ -1354,6 +1367,7 @@ var DEFAULT_MAX_STAGING = 16;
|
|
|
1354
1367
|
var DEFAULT_GRID_METRES = 2;
|
|
1355
1368
|
var DEFAULT_CELL = 0.0125;
|
|
1356
1369
|
var BAKE_RANGE_FACTOR = 1.25;
|
|
1370
|
+
var DEFAULT_WASHABLE = ["blood", "old_blood"];
|
|
1357
1371
|
var EDGE_MARGIN = 0.35;
|
|
1358
1372
|
var FLOOR_REACH = 0.3;
|
|
1359
1373
|
var DROP_HEIGHT = 2.5;
|
|
@@ -1379,6 +1393,7 @@ var FilmManager = class {
|
|
|
1379
1393
|
__publicField(this, "staging", /* @__PURE__ */ new Map());
|
|
1380
1394
|
__publicField(this, "now");
|
|
1381
1395
|
__publicField(this, "rain", 0);
|
|
1396
|
+
__publicField(this, "drying", 1);
|
|
1382
1397
|
__publicField(this, "time", 0);
|
|
1383
1398
|
__publicField(this, "bakedCount", 0);
|
|
1384
1399
|
__publicField(this, "last", { grids: 0, drops: 0, wetCells: 0, simMs: 0, starved: 0, baked: 0, uploadedTexels: 0 });
|
|
@@ -1398,7 +1413,18 @@ var FilmManager = class {
|
|
|
1398
1413
|
}
|
|
1399
1414
|
setWeather(weather) {
|
|
1400
1415
|
this.rain = Math.min(1, Math.max(0, weather.rain));
|
|
1401
|
-
|
|
1416
|
+
if (weather.drying !== void 0) this.drying = Math.max(0, weather.drying);
|
|
1417
|
+
for (const grid of this.grids) grid.film.setWeather({ rain: this.rain, drying: this.drying });
|
|
1418
|
+
}
|
|
1419
|
+
/**
|
|
1420
|
+
* Rain washes the fresh stain away (the visor's `ZG.wipe` with mode "chuva"): in the grids of the washable liquids (default blood and old blood), the
|
|
1421
|
+
* cells that are less than `maxDryness` dry (default 0.5) are cleared. Returns how many cells it cleared.
|
|
1422
|
+
*/
|
|
1423
|
+
wash(maxDryness) {
|
|
1424
|
+
const washable = this.options.washable ?? DEFAULT_WASHABLE;
|
|
1425
|
+
let cleared = 0;
|
|
1426
|
+
for (const grid of this.grids) if (washable.includes(grid.profile.id)) cleared += grid.wash(maxDryness);
|
|
1427
|
+
return cleared;
|
|
1402
1428
|
}
|
|
1403
1429
|
/** Throws a drop of a liquid: it lands in the grid under it (made on the spot) and leaves the impact splash. Null when it is out of range or has no surface. */
|
|
1404
1430
|
launch(request) {
|
|
@@ -1429,7 +1455,7 @@ var FilmManager = class {
|
|
|
1429
1455
|
const layout = layoutFromSurfaces({ ...found, center: point, columns: this.columns(), rows: this.columns(), cellSize: this.options.cellSize ?? DEFAULT_CELL });
|
|
1430
1456
|
if (this.grids.length >= (this.options.maxGrids ?? DEFAULT_MAX_GRIDS)) this.evict(point);
|
|
1431
1457
|
const grid = new FilmGrid(this.THREE, { layout, profile, random: this.options.random, center: point, ...tint ? { tint } : {}, ...this.options.base === void 0 ? {} : { base: this.options.base } });
|
|
1432
|
-
grid.film.setWeather({ rain: this.rain });
|
|
1458
|
+
grid.film.setWeather({ rain: this.rain, drying: this.drying });
|
|
1433
1459
|
this.grids.push(grid);
|
|
1434
1460
|
this.group.add(grid.group);
|
|
1435
1461
|
return grid;
|
|
@@ -1668,6 +1694,7 @@ function createFilmBridge(options) {
|
|
|
1668
1694
|
return landed;
|
|
1669
1695
|
},
|
|
1670
1696
|
setWeather: (weather) => manager.setWeather(weather),
|
|
1697
|
+
wash: (maxDryness) => manager.wash(maxDryness),
|
|
1671
1698
|
update(dt) {
|
|
1672
1699
|
if (leaks.size === 0) return;
|
|
1673
1700
|
const streams = new Map(fluids.streams().map((stream) => [stream.id, stream]));
|