@adatechnology/game-fluids 0.2.3 → 0.3.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/dist/index.d.ts +4 -0
- package/dist/index.global.js +24 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2530,7 +2530,7 @@ function createCpuSimulator(field, layout, profileOf, options) {
|
|
|
2530
2530
|
if (lastRow < 0) return;
|
|
2531
2531
|
const profile = profileOf();
|
|
2532
2532
|
const rainScale = 1 - options.weather().rain;
|
|
2533
|
-
const seconds = dryingSeconds * rainScale;
|
|
2533
|
+
const seconds = dryingSeconds * rainScale * (options.weather().drying ?? 1);
|
|
2534
2534
|
for (let row = firstRow; row <= lastRow; row++) {
|
|
2535
2535
|
const offset = row * width;
|
|
2536
2536
|
for (let column = firstColumn; column <= lastColumn; column++) {
|
|
@@ -2658,6 +2658,7 @@ function updateDrags(drags, context, layout, launch, dt) {
|
|
|
2658
2658
|
// src/film/film.ts
|
|
2659
2659
|
var DEFAULT_STEP_RATE = 180;
|
|
2660
2660
|
var DEFAULT_MAX_STEPS = 6;
|
|
2661
|
+
var WASH_BELOW_DRYNESS = 0.5;
|
|
2661
2662
|
function createFilm(options) {
|
|
2662
2663
|
const { layout, random } = options;
|
|
2663
2664
|
const cellCount = layout.width * layout.height;
|
|
@@ -2668,7 +2669,7 @@ function createFilm(options) {
|
|
|
2668
2669
|
dryness: new Float32Array(cellCount),
|
|
2669
2670
|
dampness: new Float32Array(cellCount)
|
|
2670
2671
|
};
|
|
2671
|
-
let weatherState = { rain: 0 };
|
|
2672
|
+
let weatherState = { rain: 0, drying: 1 };
|
|
2672
2673
|
let currentProfile = options.profile;
|
|
2673
2674
|
const context = { field, random, profile: () => currentProfile };
|
|
2674
2675
|
const drops = createDropPool(layout, context);
|
|
@@ -2706,9 +2707,29 @@ function createFilm(options) {
|
|
|
2706
2707
|
simulator.advance({ dt, dryingSeconds });
|
|
2707
2708
|
},
|
|
2708
2709
|
setWeather(weather) {
|
|
2709
|
-
weatherState = {
|
|
2710
|
+
weatherState = {
|
|
2711
|
+
rain: Math.min(1, Math.max(0, weather.rain ?? weatherState.rain)),
|
|
2712
|
+
drying: Math.max(0, weather.drying ?? weatherState.drying ?? 1)
|
|
2713
|
+
};
|
|
2710
2714
|
},
|
|
2711
2715
|
weather: () => ({ ...weatherState }),
|
|
2716
|
+
wash(maxDryness = WASH_BELOW_DRYNESS) {
|
|
2717
|
+
simulator.refreshBounds();
|
|
2718
|
+
const { firstRow, lastRow, firstColumn, lastColumn } = simulator.bounds;
|
|
2719
|
+
let cleared = 0;
|
|
2720
|
+
for (let row = firstRow; row <= lastRow; row++) {
|
|
2721
|
+
for (let column = firstColumn; column <= lastColumn; column++) {
|
|
2722
|
+
const index = row * layout.width + column;
|
|
2723
|
+
if (field.thickness[index] > 0 && field.dryness[index] < maxDryness) {
|
|
2724
|
+
field.thickness[index] = 0;
|
|
2725
|
+
field.dryness[index] = 0;
|
|
2726
|
+
field.dampness[index] = 0;
|
|
2727
|
+
cleared++;
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
return cleared;
|
|
2732
|
+
},
|
|
2712
2733
|
clear() {
|
|
2713
2734
|
field.thickness.fill(0);
|
|
2714
2735
|
field.dryness.fill(0);
|