@adatechnology/game-fluids-three 0.4.7 → 0.4.8
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.global.js +241 -50
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.global.js
CHANGED
|
@@ -38,6 +38,84 @@ var GameFluidsThree = (() => {
|
|
|
38
38
|
tinted: () => tinted
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
+
// ../game-contracts/dist/index.js
|
|
42
|
+
var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
|
|
43
|
+
var DEFERRED_QUEUE_ID = {
|
|
44
|
+
DESTRUCTION_EVENTS: "destruction.events",
|
|
45
|
+
BREACH_PAINT: "floorplan.breach-paint",
|
|
46
|
+
AUDIO_VOICES: "audio.voices",
|
|
47
|
+
VEHICLE_CREASE: "vehicles.crease"
|
|
48
|
+
};
|
|
49
|
+
var DEFERRED_PRIORITY = {
|
|
50
|
+
[DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS]: { priority: 300, phase: "present" },
|
|
51
|
+
[DEFERRED_QUEUE_ID.BREACH_PAINT]: { priority: 250, phase: "present" },
|
|
52
|
+
[DEFERRED_QUEUE_ID.AUDIO_VOICES]: { priority: 200, phase: "idle", reserveMs: 1 },
|
|
53
|
+
[DEFERRED_QUEUE_ID.VEHICLE_CREASE]: { priority: 100, phase: "idle" }
|
|
54
|
+
};
|
|
55
|
+
var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
|
|
56
|
+
var warnedKeys = () => {
|
|
57
|
+
const holder = globalThis;
|
|
58
|
+
return holder[WARNED_KEY] ?? (holder[WARNED_KEY] = /* @__PURE__ */ new Set());
|
|
59
|
+
};
|
|
60
|
+
var isProduction = () => {
|
|
61
|
+
try {
|
|
62
|
+
return process.env.NODE_ENV === "production";
|
|
63
|
+
} catch {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var isQuiet = () => globalThis.__GAME_KIT_QUIET__ === true;
|
|
68
|
+
var warnOnce = (key, message) => {
|
|
69
|
+
if (isQuiet() || isProduction()) return;
|
|
70
|
+
const seen = warnedKeys();
|
|
71
|
+
if (seen.has(key)) return;
|
|
72
|
+
seen.add(key);
|
|
73
|
+
console.warn(`[game-kit] ${message}`);
|
|
74
|
+
};
|
|
75
|
+
var KIT_ORIGIN_KEY = "kitOrigin";
|
|
76
|
+
function markKitOrigin(object, origin) {
|
|
77
|
+
const node = object;
|
|
78
|
+
node.userData = node.userData ?? {};
|
|
79
|
+
node.userData[KIT_ORIGIN_KEY] = { ...origin };
|
|
80
|
+
return object;
|
|
81
|
+
}
|
|
82
|
+
var SURFACE_IDS = ["concrete", "asphalt", "wood", "tile", "dirt", "grass", "gravel", "sand", "metal", "water", "glass", "carpet"];
|
|
83
|
+
var GAIT_IDS = ["walk", "run"];
|
|
84
|
+
var LANDING_IDS = ["light", "heavy"];
|
|
85
|
+
var BODY_SOUND_IDS = [
|
|
86
|
+
"jump",
|
|
87
|
+
"cloth_rustle",
|
|
88
|
+
"body_fall",
|
|
89
|
+
"fall_damage",
|
|
90
|
+
"player_hurt",
|
|
91
|
+
"player_breath_run",
|
|
92
|
+
"player_death",
|
|
93
|
+
"bite",
|
|
94
|
+
"grab",
|
|
95
|
+
"punch_swing",
|
|
96
|
+
"punch_hit_body",
|
|
97
|
+
"punch_hit_face",
|
|
98
|
+
"punch_hit_object",
|
|
99
|
+
"kick_swing",
|
|
100
|
+
"kick_hit",
|
|
101
|
+
"kick_hit_object",
|
|
102
|
+
"shove_two_hands",
|
|
103
|
+
"knife_swing",
|
|
104
|
+
"knife_stab",
|
|
105
|
+
"knife_slash",
|
|
106
|
+
"knife_hit_object",
|
|
107
|
+
"blunt_swing",
|
|
108
|
+
"blunt_hit",
|
|
109
|
+
"blunt_hit_object",
|
|
110
|
+
"axe_swing",
|
|
111
|
+
"axe_chop",
|
|
112
|
+
"axe_hit_object"
|
|
113
|
+
];
|
|
114
|
+
var footstepSoundId = (surface, gait) => `footstep_${surface}_${gait}`;
|
|
115
|
+
var FOOTSTEP_SOUND_IDS = SURFACE_IDS.flatMap((surface) => GAIT_IDS.map((gait) => footstepSoundId(surface, gait)));
|
|
116
|
+
var LAND_SOUND_IDS = SURFACE_IDS.flatMap((surface) => LANDING_IDS.map((landing) => `land_${surface}_${landing}`));
|
|
117
|
+
var BODY_FOLEY_IDS = [...FOOTSTEP_SOUND_IDS, ...LAND_SOUND_IDS, ...BODY_SOUND_IDS];
|
|
118
|
+
|
|
41
119
|
// ../game-vfx/dist/index.js
|
|
42
120
|
var __defProp2 = Object.defineProperty;
|
|
43
121
|
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -2532,22 +2610,22 @@ var GameFluidsThree = (() => {
|
|
|
2532
2610
|
)
|
|
2533
2611
|
]
|
|
2534
2612
|
};
|
|
2535
|
-
function normalized(
|
|
2536
|
-
const length2 = Math.sqrt(
|
|
2613
|
+
function normalized(vector2) {
|
|
2614
|
+
const length2 = Math.sqrt(vector2[0] * vector2[0] + vector2[1] * vector2[1] + vector2[2] * vector2[2]) || 1;
|
|
2537
2615
|
const inverse = 1 / length2;
|
|
2538
|
-
return [
|
|
2616
|
+
return [vector2[0] * inverse, vector2[1] * inverse, vector2[2] * inverse];
|
|
2539
2617
|
}
|
|
2540
|
-
function plus(
|
|
2541
|
-
return [
|
|
2618
|
+
function plus(vector2, x, y, z) {
|
|
2619
|
+
return [vector2[0] + x, vector2[1] + y, vector2[2] + z];
|
|
2542
2620
|
}
|
|
2543
|
-
function scaledBy(
|
|
2544
|
-
return [
|
|
2621
|
+
function scaledBy(vector2, factor) {
|
|
2622
|
+
return [vector2[0] * factor, vector2[1] * factor, vector2[2] * factor];
|
|
2545
2623
|
}
|
|
2546
|
-
function plusScaled(
|
|
2547
|
-
return [
|
|
2624
|
+
function plusScaled(vector2, direction, factor) {
|
|
2625
|
+
return [vector2[0] + direction[0] * factor, vector2[1] + direction[1] * factor, vector2[2] + direction[2] * factor];
|
|
2548
2626
|
}
|
|
2549
|
-
function negated(
|
|
2550
|
-
return [-
|
|
2627
|
+
function negated(vector2) {
|
|
2628
|
+
return [-vector2[0], -vector2[1], -vector2[2]];
|
|
2551
2629
|
}
|
|
2552
2630
|
var FRAME_DUST = normalized([0, -0.3, 1]);
|
|
2553
2631
|
var SPLINTER_DIRECTION = normalized([0, 0.3, 1]);
|
|
@@ -3850,9 +3928,32 @@ var GameFluidsThree = (() => {
|
|
|
3850
3928
|
/** The leak caught fire (an incendiary or tracer round, a spark, a fire near): the page's whole sequence, the fire running along the pool to the tank and the blast. */
|
|
3851
3929
|
aliasOf(FUEL_LEAK, "vehicle_leak_ignited", {})
|
|
3852
3930
|
];
|
|
3931
|
+
var vector = [variable("vx"), variable("vy"), variable("vz")];
|
|
3932
|
+
var range = (name) => [variable(name), variable(name)];
|
|
3933
|
+
var singleParticle = (id, system) => ({
|
|
3934
|
+
id,
|
|
3935
|
+
pageId: `particle:${id}`,
|
|
3936
|
+
team: "world",
|
|
3937
|
+
budget: { particles: 1, lights: 0 },
|
|
3938
|
+
loop: 1e-3,
|
|
3939
|
+
timeline: [
|
|
3940
|
+
spawn(system, {
|
|
3941
|
+
p: [0, 0, 0],
|
|
3942
|
+
v: vector,
|
|
3943
|
+
life: range("life"),
|
|
3944
|
+
size: range("size"),
|
|
3945
|
+
grow: variable("grow"),
|
|
3946
|
+
c0: variable("color"),
|
|
3947
|
+
a: variable("alpha"),
|
|
3948
|
+
g: variable("gravity"),
|
|
3949
|
+
drag: variable("drag")
|
|
3950
|
+
})
|
|
3951
|
+
]
|
|
3952
|
+
});
|
|
3953
|
+
var SINGLE_PARTICLE_EFFECTS = [singleParticle("particle_puff", "normal"), singleParticle("particle_glow", "add"), singleParticle("particle_streak", "streak")];
|
|
3853
3954
|
var ALL_EFFECTS = [BLOOD_HIT, HEADSHOT, DISMEMBER, BLOATER_CLOUD, SCREAMER_SHRIEK, CORPSE_DECAY, REANIMATION, EYES_IN_FOG, MUZZLE_FLASH, IMPACT_BY_MATERIAL, PENETRATION, CASINGS_AND_MAGAZINE, MOLOTOV, GRENADE, EXPLOSIVE_BARREL, SHOPFRONT_GLASS, DOOR_STAGES, BUILDING_COLLAPSE, BLOCK_WALL, METAL_DOOR_EFFECT, IRON_RAILING, WOODEN_FENCE, HIT_POINT_BREAKAGE, PRESSURE_CYLINDERS, BUILDING_FIRE, RAIN_AND_PUDDLES, FOG_AND_ASH, SCRAPING_SPARKS, ENGINE_SMOKE, FUEL_LEAK, CAR_EXPLOSION, WINDSHIELD, HEADLIGHTS_IN_RAIN, DAMAGE_AND_BITE, INFECTION_PHASES, PANIC, BLOATER_BLINDNESS, CAMPFIRE, COUGH_AND_BREATH];
|
|
3854
3955
|
var WORKSHOP_EFFECTS = Object.fromEntries(ALL_EFFECTS.map((effect) => [effect.id, effect]));
|
|
3855
|
-
var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries([...EVENT_EFFECTS, ...VIEWMODEL_EFFECTS, ...VEHICLE_EFFECTS].map((effect) => [effect.id, effect])) };
|
|
3956
|
+
var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries([...EVENT_EFFECTS, ...VIEWMODEL_EFFECTS, ...VEHICLE_EFFECTS, ...SINGLE_PARTICLE_EFFECTS].map((effect) => [effect.id, effect])) };
|
|
3856
3957
|
var TABLE = {
|
|
3857
3958
|
concrete: { dust: 9078138, chip: 7236195, spark: 2 },
|
|
3858
3959
|
metal: { dust: 0, chip: 0, spark: 18 },
|
|
@@ -4522,8 +4623,8 @@ var GameFluidsThree = (() => {
|
|
|
4522
4623
|
var UP12 = [0, 1, 0];
|
|
4523
4624
|
var ZERO = [0, 0, 0];
|
|
4524
4625
|
var FULL_TURN_DRAWN = 6.283;
|
|
4525
|
-
function scaledSizes(
|
|
4526
|
-
return [
|
|
4626
|
+
function scaledSizes(range22, factor) {
|
|
4627
|
+
return [range22[0] * Math.sqrt(factor), range22[1] * Math.sqrt(factor)];
|
|
4527
4628
|
}
|
|
4528
4629
|
function fireEmit(engine, key, dt, centre, radius, factor, options = {}) {
|
|
4529
4630
|
const wind = options.wind ?? ZERO;
|
|
@@ -6377,9 +6478,9 @@ var GameFluidsThree = (() => {
|
|
|
6377
6478
|
var TWO_PI_ROUNDED = 6.2832;
|
|
6378
6479
|
var WIDE_CONE = 3.1;
|
|
6379
6480
|
var UP13 = [0, 1, 0];
|
|
6380
|
-
function drawRange(random,
|
|
6381
|
-
if (Array.isArray(
|
|
6382
|
-
return
|
|
6481
|
+
function drawRange(random, range22) {
|
|
6482
|
+
if (Array.isArray(range22)) return random.between(range22[0], range22[1]);
|
|
6483
|
+
return range22 || 0;
|
|
6383
6484
|
}
|
|
6384
6485
|
function randomUnit(random, out) {
|
|
6385
6486
|
const up = random.next() * 2 - 1;
|
|
@@ -7146,13 +7247,13 @@ var GameFluidsThree = (() => {
|
|
|
7146
7247
|
return [origin[0] + cos2 * x + sin2 * z, origin[1] + point[1] - anchor[1], origin[2] - sin2 * x + cos2 * z];
|
|
7147
7248
|
}
|
|
7148
7249
|
/** A direction or velocity of the recipe's space in the world. */
|
|
7149
|
-
turn(
|
|
7250
|
+
turn(vector2) {
|
|
7150
7251
|
const placement = this.placement;
|
|
7151
|
-
if (!placement) return
|
|
7152
|
-
if (placement.orientation) return rotate(placement.orientation,
|
|
7252
|
+
if (!placement) return vector2;
|
|
7253
|
+
if (placement.orientation) return rotate(placement.orientation, vector2);
|
|
7153
7254
|
const cos2 = Math.cos(placement.yaw);
|
|
7154
7255
|
const sin2 = Math.sin(placement.yaw);
|
|
7155
|
-
return [cos2 *
|
|
7256
|
+
return [cos2 * vector2[0] + sin2 * vector2[2], vector2[1], -sin2 * vector2[0] + cos2 * vector2[2]];
|
|
7156
7257
|
}
|
|
7157
7258
|
placed(options) {
|
|
7158
7259
|
if (!this.placement) return options;
|
|
@@ -7513,16 +7614,22 @@ var GameFluidsThree = (() => {
|
|
|
7513
7614
|
};
|
|
7514
7615
|
}
|
|
7515
7616
|
|
|
7516
|
-
// ../game-
|
|
7517
|
-
var
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7617
|
+
// ../game-render-three/dist/index.js
|
|
7618
|
+
var DEFAULT_ANGLE = Math.PI / 3;
|
|
7619
|
+
var LIGHT_PRIORITY = {
|
|
7620
|
+
blast: 900,
|
|
7621
|
+
rocket: 800,
|
|
7622
|
+
muzzle: 750,
|
|
7623
|
+
fire: 600,
|
|
7624
|
+
flare: 500,
|
|
7625
|
+
headlight: 400,
|
|
7626
|
+
weaponLight: 400,
|
|
7627
|
+
lamp: 200,
|
|
7628
|
+
street: 150
|
|
7629
|
+
};
|
|
7630
|
+
var EFFECT_STEP_SECONDS = 1 / 50;
|
|
7524
7631
|
|
|
7525
|
-
// ../game-vfx-three/dist/
|
|
7632
|
+
// ../game-vfx-three/dist/chunk-ALDCQ5RH.js
|
|
7526
7633
|
var GLOW_VERTEX = `attribute vec4 aP;attribute vec4 aC;varying vec2 vU;varying vec4 vC;
|
|
7527
7634
|
void main(){vec3 R=vec3(viewMatrix[0][0],viewMatrix[1][0],viewMatrix[2][0]);vec3 Up=vec3(viewMatrix[0][1],viewMatrix[1][1],viewMatrix[2][1]);
|
|
7528
7635
|
vec3 wp=aP.xyz+(R*position.x+Up*position.y)*aP.w;vU=position.xy;vC=aC;gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.);}`;
|
|
@@ -7801,8 +7908,26 @@ void main(){
|
|
|
7801
7908
|
}
|
|
7802
7909
|
};
|
|
7803
7910
|
}
|
|
7804
|
-
|
|
7911
|
+
var LIGHT_ON_THRESHOLD = 0.05;
|
|
7912
|
+
var FIRE_COLOR = 16742954;
|
|
7913
|
+
var FIRE_DECAY = 2;
|
|
7914
|
+
var BLAST_DECAY = 2;
|
|
7915
|
+
function followEntry(budget, handles, index, entry, request) {
|
|
7916
|
+
const handle = handles[index] ?? null;
|
|
7917
|
+
if (entry.intensity <= LIGHT_ON_THRESHOLD) {
|
|
7918
|
+
handle?.release({ fadeMs: 0 });
|
|
7919
|
+
handles[index] = null;
|
|
7920
|
+
return;
|
|
7921
|
+
}
|
|
7922
|
+
if (handle?.alive) {
|
|
7923
|
+
handle.update({ color: request.color, intensity: request.intensity, distance: request.distance, position: request.position });
|
|
7924
|
+
return;
|
|
7925
|
+
}
|
|
7926
|
+
handles[index] = budget.acquire(request);
|
|
7927
|
+
}
|
|
7928
|
+
function createLightLayer(THREE, pool, scale2, budget) {
|
|
7805
7929
|
const group = new THREE.Group();
|
|
7930
|
+
if (budget) return createBudgetedLightLayer(group, pool, scale2, budget);
|
|
7806
7931
|
const blast = pool.blast.map(() => {
|
|
7807
7932
|
const light = new THREE.PointLight(16752720, 0, 30, 2);
|
|
7808
7933
|
light.position.set(0, -50, 0);
|
|
@@ -7841,6 +7966,30 @@ void main(){
|
|
|
7841
7966
|
}
|
|
7842
7967
|
};
|
|
7843
7968
|
}
|
|
7969
|
+
function createBudgetedLightLayer(group, pool, scale2, budget) {
|
|
7970
|
+
const blast = pool.blast.map(() => null);
|
|
7971
|
+
const fire = pool.fire.map(() => null);
|
|
7972
|
+
return {
|
|
7973
|
+
group,
|
|
7974
|
+
sync() {
|
|
7975
|
+
let lit = 0;
|
|
7976
|
+
pool.blast.forEach((entry, index) => {
|
|
7977
|
+
const request = { owner: "vfx.blast", priority: LIGHT_PRIORITY.blast, urgent: true, color: entry.color, intensity: entry.intensity * scale2, distance: entry.distance, decay: BLAST_DECAY, position: [entry.x, entry.y, entry.z] };
|
|
7978
|
+
followEntry(budget, blast, index, entry, request);
|
|
7979
|
+
if (entry.intensity > LIGHT_ON_THRESHOLD) lit++;
|
|
7980
|
+
});
|
|
7981
|
+
pool.fire.forEach((entry, index) => {
|
|
7982
|
+
const request = { owner: "vfx.fire", priority: LIGHT_PRIORITY.fire, color: FIRE_COLOR, intensity: entry.intensity * scale2, distance: entry.distance, decay: FIRE_DECAY, position: [entry.x, entry.y, entry.z] };
|
|
7983
|
+
followEntry(budget, fire, index, entry, request);
|
|
7984
|
+
if (entry.intensity > LIGHT_ON_THRESHOLD) lit++;
|
|
7985
|
+
});
|
|
7986
|
+
return lit;
|
|
7987
|
+
},
|
|
7988
|
+
dispose() {
|
|
7989
|
+
for (const handle of [...blast, ...fire]) handle?.release({ fadeMs: 0 });
|
|
7990
|
+
}
|
|
7991
|
+
};
|
|
7992
|
+
}
|
|
7844
7993
|
var SCORCH_SEED = 5;
|
|
7845
7994
|
var TEXTURE_SIZE = 256;
|
|
7846
7995
|
var FULL_TURN = Math.PI * 2;
|
|
@@ -7974,6 +8123,7 @@ void main(){
|
|
|
7974
8123
|
group.add(mesh2);
|
|
7975
8124
|
return mesh2;
|
|
7976
8125
|
}
|
|
8126
|
+
let probeGeometry;
|
|
7977
8127
|
const groundMarks = [];
|
|
7978
8128
|
const spareGeometries = [];
|
|
7979
8129
|
const blood = [];
|
|
@@ -8079,6 +8229,15 @@ void main(){
|
|
|
8079
8229
|
rockMesh();
|
|
8080
8230
|
plateMesh();
|
|
8081
8231
|
},
|
|
8232
|
+
probes() {
|
|
8233
|
+
probeGeometry ?? (probeGeometry = new THREE.PlaneGeometry(1e-3, 1e-3).rotateX(-Math.PI / 2));
|
|
8234
|
+
return [...scorchMaterials, dirtMaterial].map((material) => {
|
|
8235
|
+
const mesh2 = new THREE.Mesh(probeGeometry, material);
|
|
8236
|
+
mesh2.receiveShadow = true;
|
|
8237
|
+
mesh2.frustumCulled = false;
|
|
8238
|
+
return mesh2;
|
|
8239
|
+
});
|
|
8240
|
+
},
|
|
8082
8241
|
update(dt) {
|
|
8083
8242
|
for (let index = 0; index < blood.length; index++) {
|
|
8084
8243
|
const drawn = blood[index];
|
|
@@ -8091,6 +8250,7 @@ void main(){
|
|
|
8091
8250
|
dispose() {
|
|
8092
8251
|
clearMarks();
|
|
8093
8252
|
for (const mesh2 of [instanced.blood, instanced.rock, instanced.plate]) mesh2?.dispose();
|
|
8253
|
+
probeGeometry?.dispose();
|
|
8094
8254
|
for (const item of owned) item.dispose();
|
|
8095
8255
|
}
|
|
8096
8256
|
};
|
|
@@ -8666,7 +8826,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8666
8826
|
}
|
|
8667
8827
|
};
|
|
8668
8828
|
}
|
|
8669
|
-
function createWorkshopLayers(THREE, engine, pointScale, lightScale) {
|
|
8829
|
+
function createWorkshopLayers(THREE, engine, pointScale, lightScale, budget) {
|
|
8670
8830
|
const group = new THREE.Group();
|
|
8671
8831
|
group.name = "workshop";
|
|
8672
8832
|
const layers = [
|
|
@@ -8681,15 +8841,30 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8681
8841
|
for (const layer2 of layers) group.add(layer2.object);
|
|
8682
8842
|
const meshes = createMeshLayer(THREE, engine.meshes);
|
|
8683
8843
|
group.add(meshes.group);
|
|
8684
|
-
const
|
|
8685
|
-
const fireLights = engine.lights.fire.map(() => new THREE.PointLight(FIRE_LIGHT_COLOR, 0, FIRE_LIGHT_DISTANCE));
|
|
8686
|
-
for (const light of [...flashLights, ...fireLights]) group.add(light);
|
|
8844
|
+
const lights = budget ? budgetedLights(engine, lightScale, budget) : legacyLights(THREE, engine, lightScale, group);
|
|
8687
8845
|
return {
|
|
8688
8846
|
group,
|
|
8689
8847
|
sync() {
|
|
8690
8848
|
let drawCalls = 0;
|
|
8691
8849
|
for (const layer2 of layers) if (layer2.sync()) drawCalls++;
|
|
8692
8850
|
drawCalls += meshes.sync();
|
|
8851
|
+
lights.sync();
|
|
8852
|
+
return drawCalls;
|
|
8853
|
+
},
|
|
8854
|
+
dispose() {
|
|
8855
|
+
for (const layer2 of layers) layer2.dispose();
|
|
8856
|
+
meshes.dispose();
|
|
8857
|
+
lights.dispose();
|
|
8858
|
+
group.clear();
|
|
8859
|
+
}
|
|
8860
|
+
};
|
|
8861
|
+
}
|
|
8862
|
+
function legacyLights(THREE, engine, lightScale, group) {
|
|
8863
|
+
const flashLights = engine.lights.lights.map(() => new THREE.PointLight(16760944, 0, 14));
|
|
8864
|
+
const fireLights = engine.lights.fire.map(() => new THREE.PointLight(FIRE_LIGHT_COLOR, 0, FIRE_LIGHT_DISTANCE));
|
|
8865
|
+
for (const light of [...flashLights, ...fireLights]) group.add(light);
|
|
8866
|
+
return {
|
|
8867
|
+
sync() {
|
|
8693
8868
|
engine.lights.lights.forEach((source, index) => {
|
|
8694
8869
|
const light = flashLights[index];
|
|
8695
8870
|
light.position.set(source.x, source.y, source.z);
|
|
@@ -8702,12 +8877,27 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8702
8877
|
light.position.set(source.x, source.y, source.z);
|
|
8703
8878
|
light.intensity = source.intensity * lightScale;
|
|
8704
8879
|
});
|
|
8705
|
-
return drawCalls;
|
|
8706
8880
|
},
|
|
8707
8881
|
dispose() {
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8882
|
+
}
|
|
8883
|
+
};
|
|
8884
|
+
}
|
|
8885
|
+
function budgetedLights(engine, lightScale, budget) {
|
|
8886
|
+
const flash2 = engine.lights.lights.map(() => null);
|
|
8887
|
+
const fire = engine.lights.fire.map(() => null);
|
|
8888
|
+
return {
|
|
8889
|
+
sync() {
|
|
8890
|
+
engine.lights.lights.forEach((source, index) => {
|
|
8891
|
+
const request = { owner: "vfx.workshop", priority: LIGHT_PRIORITY.blast, urgent: true, color: source.color, intensity: source.intensity * lightScale, distance: source.distance, position: [source.x, source.y, source.z] };
|
|
8892
|
+
followEntry(budget, flash2, index, source, request);
|
|
8893
|
+
});
|
|
8894
|
+
engine.lights.fire.forEach((source, index) => {
|
|
8895
|
+
const request = { owner: "vfx.workshop", priority: LIGHT_PRIORITY.fire, color: FIRE_LIGHT_COLOR, intensity: source.intensity * lightScale, distance: FIRE_LIGHT_DISTANCE, position: [source.x, source.y, source.z] };
|
|
8896
|
+
followEntry(budget, fire, index, source, request);
|
|
8897
|
+
});
|
|
8898
|
+
},
|
|
8899
|
+
dispose() {
|
|
8900
|
+
for (const handle of [...flash2, ...fire]) handle?.release({ fadeMs: 0 });
|
|
8711
8901
|
}
|
|
8712
8902
|
};
|
|
8713
8903
|
}
|
|
@@ -8765,7 +8955,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8765
8955
|
const chunks = createChunkLayer(THREE, pools.chunks, { rock: rockGeometry, plate: plateGeometry }, colorOfChunk);
|
|
8766
8956
|
const shocks = createShockLayer(THREE, pools.shocks);
|
|
8767
8957
|
const sprites = createSpriteLayer(THREE, world.sprites(), options.pointScale ?? 700);
|
|
8768
|
-
const lights = createLightLayer(THREE, pools.lights, options.lightScale ?? Math.PI);
|
|
8958
|
+
const lights = createLightLayer(THREE, pools.lights, options.lightScale ?? Math.PI, options.lights);
|
|
8769
8959
|
const marks = createMarkLayer(THREE, { ground: pools.ground, createCanvas: options.createCanvas, rockGeometry, plateGeometry, ...options.markLimits });
|
|
8770
8960
|
root.add(puffs.mesh, sparks.mesh, glows.mesh, chunks.rocks, chunks.plates, shocks.group, lights.group, sprites.additive, sprites.normal, marks.group);
|
|
8771
8961
|
const stopMarks = world.onMarks((event) => marks.handle(event));
|
|
@@ -8798,7 +8988,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8798
8988
|
workshopLayers?.dispose();
|
|
8799
8989
|
if (workshopLayers) root.remove(workshopLayers.group);
|
|
8800
8990
|
workshopEngine = engine;
|
|
8801
|
-
workshopLayers = createWorkshopLayers(THREE, engine, options.pointScale ?? 700, 1);
|
|
8991
|
+
workshopLayers = createWorkshopLayers(THREE, engine, options.pointScale ?? 700, 1, options.lights);
|
|
8802
8992
|
root.add(workshopLayers.group);
|
|
8803
8993
|
applyLayers();
|
|
8804
8994
|
}
|
|
@@ -8871,7 +9061,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8871
9061
|
const meshes = createMeshLayerProbes(THREE);
|
|
8872
9062
|
for (const mesh2 of meshes) mesh2.frustumCulled = false;
|
|
8873
9063
|
const group = new THREE.Group();
|
|
8874
|
-
group.add(...meshes);
|
|
9064
|
+
group.add(...meshes, ...marks.probes());
|
|
8875
9065
|
anchors = { meshes, group };
|
|
8876
9066
|
return { group, dispose: () => {
|
|
8877
9067
|
} };
|
|
@@ -9739,7 +9929,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9739
9929
|
}
|
|
9740
9930
|
};
|
|
9741
9931
|
}
|
|
9742
|
-
var
|
|
9932
|
+
var range2 = (random, from, to) => from + random() * (to - from);
|
|
9743
9933
|
function updateDrip(drip, bead, layout, random, launch, dt) {
|
|
9744
9934
|
if (!drip) {
|
|
9745
9935
|
bead.visible = false;
|
|
@@ -9758,11 +9948,11 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9758
9948
|
if (drip.elapsed < drip.every) return;
|
|
9759
9949
|
const origin = [bead.position[0], bead.position[1] + -radius * 1e-3, bead.position[2]];
|
|
9760
9950
|
if (isWorkshop) {
|
|
9761
|
-
const sideX2 =
|
|
9762
|
-
const sideZ2 =
|
|
9763
|
-
launch(origin, [sideX2, -0.2, sideZ2], drip.radius *
|
|
9951
|
+
const sideX2 = range2(random, -0.025, 0.025);
|
|
9952
|
+
const sideZ2 = range2(random, -0.025, 0.025);
|
|
9953
|
+
launch(origin, [sideX2, -0.2, sideZ2], drip.radius * range2(random, 0.85, 1.15));
|
|
9764
9954
|
drip.elapsed = 0;
|
|
9765
|
-
drip.every = drip.base *
|
|
9955
|
+
drip.every = drip.base * range2(random, 0.75, 1.25);
|
|
9766
9956
|
return;
|
|
9767
9957
|
}
|
|
9768
9958
|
const sideX = (random() - 0.5) * 0.05;
|
|
@@ -10095,7 +10285,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
10095
10285
|
var DEFAULT_CURB_ROWS = 12;
|
|
10096
10286
|
var RULES = { dropCapacity: 160, curbCatch: false, guardBehindWall: false, clipRoadEnd: false, dripStyle: "padrao" };
|
|
10097
10287
|
var along3 = (origin, axis2, distance2) => add2(origin, scale(axis2, distance2));
|
|
10098
|
-
var reject = (
|
|
10288
|
+
var reject = (vector2, axis2) => sub3(vector2, scale(axis2, dot2(vector2, axis2)));
|
|
10099
10289
|
function layoutFromSurfaces(options) {
|
|
10100
10290
|
const columns = options.columns ?? DEFAULT_COLUMNS;
|
|
10101
10291
|
const totalRows = options.rows ?? DEFAULT_ROWS;
|
|
@@ -10700,6 +10890,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
10700
10890
|
const root = new THREE.Group();
|
|
10701
10891
|
root.name = "fluid_renderer";
|
|
10702
10892
|
scene.add(root);
|
|
10893
|
+
if (!options.vfx) warnOnce("game-fluids-three.own-effects-world", "game-fluids-three made an effects world of its own because the host lent none (options.vfx); pass the host effects so the effects share one budget");
|
|
10703
10894
|
const vfx = options.vfx ?? createVfx({ profile: quality, gravity: fluids.gravity, sprites: { capacity: profile.maxParticles } });
|
|
10704
10895
|
const ownVfx = options.vfx ? void 0 : createVfxRenderer(THREE, { scene, camera: options.camera ?? new THREE.PerspectiveCamera(), vfx, pointScale: options.pointScale ?? 600 });
|
|
10705
10896
|
const particles = new FluidSprites(vfx, `fluids-${++rendererCount}`);
|
|
@@ -11405,7 +11596,7 @@ void main(){
|
|
|
11405
11596
|
update(dt) {
|
|
11406
11597
|
this.time += dt;
|
|
11407
11598
|
const viewer = this.viewer();
|
|
11408
|
-
const
|
|
11599
|
+
const range3 = this.options.range ?? DEFAULT_RANGE;
|
|
11409
11600
|
const budget = this.options.budgetMs ?? DEFAULT_BUDGET_MS;
|
|
11410
11601
|
const drying = dt * (this.options.dryingSpeed ?? 1);
|
|
11411
11602
|
const order = [...this.grids].sort((a, b) => viewer ? distance(viewer.position, a.center) - distance(viewer.position, b.center) : 0);
|
|
@@ -11413,7 +11604,7 @@ void main(){
|
|
|
11413
11604
|
let starved = 0;
|
|
11414
11605
|
let uploaded = 0;
|
|
11415
11606
|
for (const grid of order) {
|
|
11416
|
-
if (viewer && distance(viewer.position, grid.center) >
|
|
11607
|
+
if (viewer && distance(viewer.position, grid.center) > range3 * BAKE_RANGE_FACTOR) {
|
|
11417
11608
|
this.release(grid, "range");
|
|
11418
11609
|
continue;
|
|
11419
11610
|
}
|