@adatechnology/game-fluids-three 0.4.10 → 0.4.12
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 +27 -7
- package/dist/index.global.js.map +1 -1
- package/package.json +5 -5
package/dist/index.global.js
CHANGED
|
@@ -5680,13 +5680,14 @@ var GameFluidsThree = (() => {
|
|
|
5680
5680
|
function composeAfterEffects(context) {
|
|
5681
5681
|
const { core, def, random, x, y, z } = context;
|
|
5682
5682
|
const mark = def.mark;
|
|
5683
|
-
|
|
5683
|
+
const keepsMarks = !core.marklessAt?.(x, z);
|
|
5684
|
+
if (keepsMarks && mark.crater && mark.dent && y < 1.2) {
|
|
5684
5685
|
core.emit({ type: "crater", x, z, radius: mark.crater, depth: mark.dent });
|
|
5685
5686
|
core.trace?.crater?.(x, z, mark.crater, mark.dent);
|
|
5686
5687
|
addCrater(core.marks, core.ground, random, { x, z, radius: mark.crater, depth: mark.dent, marks: core.layers.mark });
|
|
5687
5688
|
if (core.layers.shrapnel) composeRimDebris(context);
|
|
5688
5689
|
}
|
|
5689
|
-
if (mark.scorch && y < 1.2 && core.layers.mark) {
|
|
5690
|
+
if (keepsMarks && mark.scorch && y < 1.2 && core.layers.mark) {
|
|
5690
5691
|
core.trace?.scorch?.(x, z, mark.scorch);
|
|
5691
5692
|
addScorch(core.marks, random, x, z, mark.scorch);
|
|
5692
5693
|
}
|
|
@@ -7437,6 +7438,7 @@ var GameFluidsThree = (() => {
|
|
|
7437
7438
|
spawned: { puffs: 0, sparks: 0, chunks: 0, lights: 0 },
|
|
7438
7439
|
clock: { time: 0, lastBlast: -1, lod: 1, forcedLod: null },
|
|
7439
7440
|
groundAt,
|
|
7441
|
+
...options.marklessAt ? { marklessAt: options.marklessAt } : {},
|
|
7440
7442
|
emit: (request) => options.onRequest?.(request)
|
|
7441
7443
|
};
|
|
7442
7444
|
function definitionOf(id) {
|
|
@@ -7463,6 +7465,7 @@ var GameFluidsThree = (() => {
|
|
|
7463
7465
|
return player ?? (player = createEffectPlayer({ engine: workshop(), effects, view }));
|
|
7464
7466
|
}
|
|
7465
7467
|
return {
|
|
7468
|
+
hostGroundAt: options.groundAt,
|
|
7466
7469
|
play(id, point, playOptions = {}) {
|
|
7467
7470
|
if (!(id in effects)) return null;
|
|
7468
7471
|
const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
@@ -7630,7 +7633,7 @@ var GameFluidsThree = (() => {
|
|
|
7630
7633
|
};
|
|
7631
7634
|
var EFFECT_STEP_SECONDS = 1 / 50;
|
|
7632
7635
|
|
|
7633
|
-
// ../game-vfx-three/dist/chunk-
|
|
7636
|
+
// ../game-vfx-three/dist/chunk-CPRCWTSQ.js
|
|
7634
7637
|
var GLOW_VERTEX = `attribute vec4 aP;attribute vec4 aC;varying vec2 vU;varying vec4 vC;
|
|
7635
7638
|
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]);
|
|
7636
7639
|
vec3 wp=aP.xyz+(R*position.x+Up*position.y)*aP.w;vU=position.xy;vC=aC;gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.);}`;
|
|
@@ -8070,7 +8073,11 @@ void main(){
|
|
|
8070
8073
|
const dirt = texture(paint(make, (context, size) => drawDirt(context, size, random)));
|
|
8071
8074
|
return { scorch, dirt };
|
|
8072
8075
|
}
|
|
8073
|
-
var
|
|
8076
|
+
var FLAT_STEPS_PER_METRE = 8;
|
|
8077
|
+
var MAX_FLAT_STEPS = 48;
|
|
8078
|
+
var DUG_STEPS_PER_METRE = 20;
|
|
8079
|
+
var MAX_DUG_STEPS = 64;
|
|
8080
|
+
var FLAT_TOLERANCE = 2e-3;
|
|
8074
8081
|
var MIN_CONFORM_STEPS = 16;
|
|
8075
8082
|
var BLOOD_GROW_RATE = 1.2;
|
|
8076
8083
|
var BLOOD_START_GROWTH = 0.05;
|
|
@@ -8153,9 +8160,21 @@ void main(){
|
|
|
8153
8160
|
spareGeometries.push(oldest.mesh.geometry);
|
|
8154
8161
|
if (spareGeometries.length > MAX_SPARE_GROUND_GEOMETRIES) spareGeometries.shift().dispose();
|
|
8155
8162
|
}
|
|
8163
|
+
const heightAt = options.heightAt ?? ((x, z) => options.ground?.heightAt(x, z) ?? 0);
|
|
8164
|
+
function groundDipsUnder(x, z, radius) {
|
|
8165
|
+
const centre = heightAt(x, z);
|
|
8166
|
+
for (const share of [0.25, 0.5, 0.75]) {
|
|
8167
|
+
for (let ray = 0; ray < 8; ray++) {
|
|
8168
|
+
const angle = ray / 8 * Math.PI * 2;
|
|
8169
|
+
if (Math.abs(heightAt(x + Math.cos(angle) * radius * share, z + Math.sin(angle) * radius * share) - centre) > FLAT_TOLERANCE) return true;
|
|
8170
|
+
}
|
|
8171
|
+
}
|
|
8172
|
+
return false;
|
|
8173
|
+
}
|
|
8156
8174
|
function conform(mark, material) {
|
|
8157
8175
|
const radius = mark.radius;
|
|
8158
|
-
const
|
|
8176
|
+
const dug = options.heightAt !== void 0 && groundDipsUnder(mark.x, mark.z, radius);
|
|
8177
|
+
const steps = Math.max(MIN_CONFORM_STEPS, Math.min(dug ? MAX_DUG_STEPS : MAX_FLAT_STEPS, Math.round(radius * (dug ? DUG_STEPS_PER_METRE : FLAT_STEPS_PER_METRE))));
|
|
8159
8178
|
if (groundMarks.length >= maxGroundMarks) evictOldestGroundMark();
|
|
8160
8179
|
const geometry = takeSpare((steps + 1) * (steps + 1)) ?? new THREE.PlaneGeometry(2, 2, steps, steps).rotateX(-Math.PI / 2);
|
|
8161
8180
|
const grid = geometry.attributes.position;
|
|
@@ -8167,7 +8186,7 @@ void main(){
|
|
|
8167
8186
|
const localZ = Math.fround(Math.floor(index / (steps + 1)) * cell - 1) * radius;
|
|
8168
8187
|
const worldX = mark.x + localX * cos2 - localZ * sin2;
|
|
8169
8188
|
const worldZ = mark.z + localX * sin2 + localZ * cos2;
|
|
8170
|
-
grid.setXYZ(index, worldX,
|
|
8189
|
+
grid.setXYZ(index, worldX, heightAt(worldX, worldZ) + mark.lift, worldZ);
|
|
8171
8190
|
}
|
|
8172
8191
|
grid.needsUpdate = true;
|
|
8173
8192
|
geometry.computeVertexNormals();
|
|
@@ -8957,7 +8976,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8957
8976
|
const shocks = createShockLayer(THREE, pools.shocks);
|
|
8958
8977
|
const sprites = createSpriteLayer(THREE, world.sprites(), options.pointScale ?? 700);
|
|
8959
8978
|
const lights = createLightLayer(THREE, pools.lights, options.lightScale ?? Math.PI, options.lights);
|
|
8960
|
-
const marks = createMarkLayer(THREE, { ground: pools.ground, createCanvas: options.createCanvas, rockGeometry, plateGeometry, ...options.markLimits });
|
|
8979
|
+
const marks = createMarkLayer(THREE, { ground: pools.ground, ...world.hostGroundAt ? { heightAt: world.hostGroundAt } : {}, createCanvas: options.createCanvas, rockGeometry, plateGeometry, ...options.markLimits });
|
|
8961
8980
|
root.add(puffs.mesh, sparks.mesh, glows.mesh, chunks.rocks, chunks.plates, shocks.group, lights.group, sprites.additive, sprites.normal, marks.group);
|
|
8962
8981
|
const stopMarks = world.onMarks((event) => marks.handle(event));
|
|
8963
8982
|
const overlay = options.overlay ? createScreenOverlay(options.overlay) : void 0;
|
|
@@ -9010,6 +9029,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9010
9029
|
drawCalls = Number(lastDrawn.puffs > 0) + Number(lastDrawn.sparks > 0) + Number(lastDrawn.glows > 0) + Number(chunks.rocks.count > 0) + Number(chunks.plates.count > 0) + Number(sprites.additive.geometry.drawRange.count > 0) + Number(sprites.normal.geometry.drawRange.count > 0) + lastDrawn.shocks * 2 + marks.count() + workshopCalls;
|
|
9011
9030
|
}
|
|
9012
9031
|
return {
|
|
9032
|
+
root,
|
|
9013
9033
|
world,
|
|
9014
9034
|
play(request) {
|
|
9015
9035
|
followCamera();
|