// Impulse jets — a Meep example for the GPU fluid simulation + impulse
// effector + solid obstacles + GPU particles.
//
// Three stationary jets line the upwind edge of a meadow and PULSE, each
// firing a puff of air down its lane every few seconds. The puffs are
// ImpulseFluidEffectors inside a 2-cascade GPUFluidComponent domain; ~60,000
// GPU particles spawn across the 16×12 grid where the plantation stands and
// sample the live GPU wind field each frame via `SAMPLE_WIND` — so each puff
// reads as a luminous wave rolling away from its nozzle.
//
// Standing mid-field in the two outer lanes are stone PILLARS tagged with
// FluidObstacle: GPUFluidSystem packs their colliders into the GPU LBVH forcing
// pass, so the air genuinely parts around and over them. Particles in a
// pillar's lee linger in a calm wind-shadow, while the unobstructed centre lane
// streams freely across the field.
//
// The pieces and who does what:
//
// - GPUFluidComponent the domain: nested, two-way coupled 3D cascades
// centred on its entity's Transform64.
// - ImpulseFluidEffector the puffer: a fixed world position + a force
// vector + a radius. We pulse `force` per-frame.
// - GlobalFluidEffector the calm far field (`wind = 0`, `drag = 1.35`):
// relaxes the GPU cascades back toward still air
// after each puff passes.
// - FluidObstacle the wall marker: rides a (Collider, RigidBody,
// Transform64) tuple read directly by GPUFluidSystem.
// - GPUFluidSystem steps the cascade stack on the GPU and publishes
// the velocity field to `GPUSceneContext#wind`.
// - GPUParticleEmitterSystem spawns and simulates ~60k particles on the GPU,
// sampling `wind` at each particle's world position.
//
// Sections:
// §1 Tuning constants
// §2 Shade materials & particle sprite
// §3 Engine bootstrap
// §4 Ground
// §5 The GPU fluid volume + calm far field
// §6 The particle field ~60k GPU particles arranged across the 16×12 grid
// §7 The jets + the pillars effectors that puff · obstacles that block
// §8 Per-frame pulse the jets, HUD
import { EngineHarness } from "@woosh/meep-engine/src/engine/EngineHarness.js";
import TopDownCameraController from "@woosh/meep-engine/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.js";
import { Light } from "@woosh/meep-engine/src/engine/graphics/ecs/light/Light.js";
import { LightType } from "@woosh/meep-engine/src/engine/graphics/ecs/light/LightType.js";
import Entity from "@woosh/meep-engine/src/engine/ecs/Entity.js";
import { Transform64 } from "@woosh/meep-engine/src/engine/ecs/transform/Transform64.js";
import { t64_announce_change } from "@woosh/meep-engine/src/engine/ecs/transform/t64_announce_change.js";
import { ShadedGeometry } from "@woosh/meep-engine/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js";
import { ShadedGeometrySystem } from "@woosh/meep-engine/src/engine/graphics3/ShadedGeometrySystem.js";
import { make_box_geometry } from "@woosh/meep-engine/src/shade/renderer/geometry/primitives/make_box_geometry.js";
import { make_cylinder_geometry } from "@woosh/meep-engine/src/shade/renderer/geometry/primitives/make_cylinder_geometry.js";
import { meshlet_geometry_build_from_geometry } from "@woosh/meep-engine/src/shade/renderer/geometry/meshlet_geometry_build_from_geometry.js";
import { StandardShadeMaterial } from "@woosh/meep-engine/src/shade/renderer/material/StandardShadeMaterial.js";
import { PhysicsSystem } from "@woosh/meep-engine/src/engine/physics/ecs/PhysicsSystem.js";
import { ColliderObserverSystem } from "@woosh/meep-engine/src/engine/physics/ecs/ColliderObserverSystem.js";
import { RigidBody } from "@woosh/meep-engine/src/engine/physics/ecs/RigidBody.js";
import { Collider } from "@woosh/meep-engine/src/engine/physics/ecs/Collider.js";
import { BodyKind } from "@woosh/meep-engine/src/engine/physics/ecs/BodyKind.js";
import { BoxShape3D } from "@woosh/meep-engine/src/core/geom/3d/shape/BoxShape3D.js";
import { NodeGraph } from "@woosh/meep-engine/src/core/model/node-graph/NodeGraph.js";
import { ParticleEffect } from "@woosh/meep-engine/src/engine/graphics/ecs/particles/ParticleEffect.js";
import { GPUParticleEmitterSystem } from "@woosh/meep-engine/src/engine/graphics3/GPUParticleEmitterSystem.js";
import {
EMITTER_BLEND,
EMITTER_PROJECTION,
} from "@woosh/meep-engine/src/shade/renderer/particles/data/PARTICLE_EMITTER_STRUCT.js";
import {
particle_node,
particle_wire,
} from "@woosh/meep-engine/src/shade/renderer/particles/graph/particle_graph_authoring.js";
import { VM_BUILTIN } from "@woosh/meep-engine/src/shade/renderer/particles/isa/ParticleVMISA.js";
import { ParticleLayout } from "@woosh/meep-engine/src/shade/renderer/particles/layout/ParticleLayout.js";
import { create_particle_effect } from "@woosh/meep-engine/src/shade/renderer/particles/runtime/create_particle_effect.js";
import { GPUFluidComponent } from "@woosh/meep-engine/src/engine/physics/fluid/ecs/GPUFluidComponent.js";
import { GPUFluidSystem } from "@woosh/meep-engine/src/engine/graphics3/GPUFluidSystem.js";
import { FluidEffectorsComponent } from "@woosh/meep-engine/src/engine/physics/fluid/ecs/FluidEffectorsComponent.js";
import { FluidEffectorsSystem } from "@woosh/meep-engine/src/engine/physics/fluid/ecs/FluidEffectorsSystem.js";
import { FluidObstacle } from "@woosh/meep-engine/src/engine/physics/fluid/ecs/FluidObstacle.js";
import { GlobalFluidEffector } from "@woosh/meep-engine/src/engine/physics/fluid/effector/GlobalFluidEffector.js";
import { ImpulseFluidEffector } from "@woosh/meep-engine/src/engine/physics/fluid/effector/ImpulseFluidEffector.js";
import { Color } from "@woosh/meep-engine/src/core/color/Color.js";
import Vector3 from "@woosh/meep-engine/src/core/geom/Vector3.js";
import Quaternion from "@woosh/meep-engine/src/core/geom/Quaternion.js";
// ─── §1 Tuning constants ────────────────────────────────────────────────────
// The spawn volume: spans the 16 × 12 plantation footprint (25.6 m × 19.2 m).
const SITES_X = 16;
const SITES_Z = 12;
const SITE_SPACING = 1.6;
const SPAWN_HALF_X = (SITES_X * SITE_SPACING) * 0.5;
const SPAWN_HALF_Z = (SITES_Z * SITE_SPACING) * 0.5;
const SPAWN_Y_MIN = 0.15;
const SPAWN_Y_MAX = 2.85;
// ~60,000 average live particles by Little's Law: 20,000/s × 3.0 s mean life = 60,000.
const PARTICLE_SPAWN_RATE = 20000;
const PARTICLE_LIFE_MIN = 2.8;
const PARTICLE_LIFE_MAX = 3.2;
// Ground footprint.
const FIELD_SIZE_X = 30;
const FIELD_SIZE_Z = 22;
// The GPU fluid cascade stack: 2 cascades of 64 × 32 × 64 cells, finest cell 0.6 m.
// Centred at Y = 6.0 m so cascade 0 (38.4 × 19.2 × 38.4 m) captures the entire
// ground footprint and 15.6 m above the ground, while cascade 1 reaches
// 76.8 × 38.4 × 76.8 m.
const FLUID_RESOLUTION = [64, 32, 64];
const FLUID_CELL_SIZE = 0.6;
const FLUID_CASCADES = 2;
const FLUID_CENTER_Y = 6.0;
const CALM_DRAG = 1.35; // 1/s relaxation toward still air between puffs
// The jets. Each sits at the upwind edge in its own lane and fires a squared-
// sine puff of air in +X.
const JET_X = -13;
const JET_Y = 1.65;
const JET_STRENGTH = 450; // peak force magnitude (world units/s²)
const JET_RADIUS = 2.8; // world-space splat sphere
const JET_PERIOD = 5.4; // seconds between a lane's puffs
const JET_LANES_Z = [-6, 0, 6]; // one jet per lane
const JET_PHASES = [0.0, 1.8, 3.6]; // seconds — stagger the three lanes
// The pillars: one sits mid-field in each OUTER lane (z = ±6); the CENTRE lane
// (z = 0) is left open so the contrast between open flow and obstacle lee is clear.
const PILLAR_X = -3;
const PILLAR_LANES_Z = [-6, 6];
const PILLAR_W = 1.0; // X — thin, across the flow
const PILLAR_D = 3.4; // Z — wide, shadows the outer lane
const PILLAR_H = 3.8; // Y — tall enough to deflect flow around and over
const OBSTACLE_INFLATION = FLUID_CELL_SIZE * 0.5;
const GROUND_COLOR = "#161c24";
const PILLAR_COLOR = "#39404a";
const JET_COLOR = "#f58f3d";
const JET_BASE_COLOR = "#6b7079";
// 7-stop velocity LUT in HDR linear RGB (emerald → teal → cobalt → violet → magenta → coral → gold),
// indexed by normalized wind speed (`excitement ∈ [0, 1]`).
const PLASMA_LUT_STOPS = [
{ position: 0.00, color: [0.10, 0.52, 0.34, 0.70] },
{ position: 0.10, color: [0.08, 0.64, 0.68, 0.73] },
{ position: 0.22, color: [0.14, 0.38, 0.98, 0.76] },
{ position: 0.36, color: [0.44, 0.16, 0.92, 0.80] },
{ position: 0.50, color: [0.71, 0.15, 0.40, 0.84] },
{ position: 0.75, color: [1.11, 0.43, 0.14, 0.90] },
{ position: 1.00, color: [1.40, 1.16, 0.27, 0.96] },
];
// Pulse indicator envelope for the nozzle and glowing flare cone.
const PULSE_ATTACK = 22;
const PULSE_RELEASE = 2.2;
const PULSE_GLOW = 1.2;
const PULSE_GROW = 0.45;
const FLARE_MIN_SCALE = 0.001;
// ─── §2 Shade materials & particle sprite ───────────────────────────────────
function standardMaterial(hexColor, roughness, metalness = 0) {
const material = new StandardShadeMaterial();
material.diffuse_color.copy(Color.from_sRGB_to_linear(Color.parse(hexColor)));
material.roughness_factor = roughness;
material.metallic_factor = metalness;
return material;
}
function makeMoteSprite() {
const size = 48;
const canvas = document.createElement("canvas");
canvas.width = size;
canvas.height = size;
const ctx = canvas.getContext("2d");
const img = ctx.createImageData(size, size);
const data = img.data;
for (let iy = 0; iy < size; iy++) {
for (let ix = 0; ix < size; ix++) {
const x = ((ix + 0.5) / size) * 2 - 1;
const y = ((iy + 0.5) / size) * 2 - 1;
const r = Math.hypot(x, y);
const offset = (iy * size + ix) * 4;
data[offset] = 255;
data[offset + 1] = 255;
data[offset + 2] = 255;
if (r >= 1) {
data[offset + 3] = 0;
} else {
const falloff = 1 - r;
const core = Math.max(0, 1 - r * 1.65);
const alpha = Math.min(1, falloff * falloff * 0.65 + core * core * 0.55);
data[offset + 3] = Math.round(alpha * 255);
}
}
}
ctx.putImageData(img, 0, 0);
return canvas.toDataURL("image/png");
}
// ─── §3 Engine bootstrap ────────────────────────────────────────────────────
const engine = await EngineHarness.bootstrap({
configuration: (config, engine) => {
const shadeScene = EngineHarness.shadeScene(engine);
config.addSystem(new ShadedGeometrySystem(engine.graphics, shadeScene));
// Static rigid bodies for the stone pillars (`FluidObstacle`).
const physics = new PhysicsSystem();
config.addSystem(physics);
config.addSystem(new ColliderObserverSystem(physics));
// Folds the calm GlobalFluidEffector into the far field and steps the
// 2-cascade 3D fluid domain on the GPU.
config.addSystem(new FluidEffectorsSystem());
config.addSystem(new GPUFluidSystem(engine.graphics, shadeScene));
config.addSystem(new GPUParticleEmitterSystem(engine.graphics, shadeScene, engine.assetManager));
},
});
await EngineHarness.buildBasics({
engine,
enableTerrain: false,
enableWater: false,
enableLights: true,
enableShadows: true,
focus: new Vector3(0, 1.5, 0),
distance: 28,
pitch: 0.88,
yaw: 0,
cameraFarDistance: 84,
showFps: false,
});
engine.entityManager.dataset.getAnyComponent(TopDownCameraController).component.distanceMax = 56;
engine.graphics.renderer.feature_automatic_exposure_enabled = false;
engine.entityManager.dataset.traverseEntities([Light], (light) => {
if (light.type.getValue() === LightType.DIRECTION) {
light.intensity.set(6);
}
});
const ecd = engine.entityManager.dataset;
// ─── §4 Ground ──────────────────────────────────────────────────────────────
{
const t = new Transform64();
t.setTranslation(0, -0.25, 0);
new Entity()
.add(t)
.add(ShadedGeometry.from(
meshlet_geometry_build_from_geometry(
make_box_geometry(FIELD_SIZE_X + 10, 0.5, FIELD_SIZE_Z + 8),
),
standardMaterial(GROUND_COLOR, 1),
))
.build(ecd);
}
// ─── §5 The GPU fluid volume + calm far field ───────────────────────────────
const fluid = new GPUFluidComponent();
fluid.resolution = FLUID_RESOLUTION;
fluid.cell_size = FLUID_CELL_SIZE;
fluid.cascade_count = FLUID_CASCADES;
const fluidTransform = new Transform64();
fluidTransform.setTranslation(0, FLUID_CENTER_Y, 0);
new Entity().add(fluidTransform).add(fluid).build(ecd);
// ─── §6 The particle field (~60k GPU particles) ─────────────────────────────
//
// Particles spawn across the 16 × 12 grid where the trees stood and sample the
// GPU fluid velocity via `wind` (`SAMPLE_WIND`). Calm particles (including those
// in the sheltered lee behind the two stone pillars) drift gently as deep
// teal-emerald motes, while particles caught in a jet puff stretch along their
// motion and flare bright cyan-blue.
function node(graph, type, inputs = {}, parameters = {}) {
const id = particle_node(graph, type, parameters);
for (const [port, source] of Object.entries(inputs)) {
particle_wire(graph, id, port, source);
}
return id;
}
const read = (graph, name) => node(graph, "particleField", {}, { name });
const write = (graph, name, value) => node(graph, "setParticleField", { value }, { name });
function randomRange(graph, min, max) {
if (min === max) return [min];
const r = node(graph, "random", {}, { components: 1 });
return node(graph, "mad", { a: r, b: [max - min], c: [min] });
}
function scaleCurve(stops) {
const slope = (a, b) => (b[1] - a[1]) / (b[0] - a[0]);
return {
keys: stops.map(([time, value], i) => ({
time,
value,
inTangent: i === 0 ? 0 : slope(stops[i - 1], stops[i]),
outTangent: i === stops.length - 1 ? 0 : slope(stops[i], stops[i + 1]),
})),
};
}
function buildJetParticleEffect(spriteUrl) {
const layout = new ParticleLayout([
{ name: "position", components: 3 },
{ name: "velocity", components: 3 },
{ name: "streak", components: 3 },
{ name: "age", components: 1 },
{ name: "life", components: 1 },
{ name: "size0", components: 1 },
{ name: "size", components: 1 },
{ name: "color", components: 4, type: "color" },
]);
const init = new NodeGraph();
const px = randomRange(init, -SPAWN_HALF_X, SPAWN_HALF_X);
const py = randomRange(init, SPAWN_Y_MIN, SPAWN_Y_MAX);
const pz = randomRange(init, -SPAWN_HALF_Z, SPAWN_HALF_Z);
write(init, "position", node(init, "vec3", { x: px, y: py, z: pz }));
const vy = randomRange(init, 0.06, 0.18);
write(init, "velocity", node(init, "vec3", { x: [0], y: vy, z: [0] }));
write(init, "streak", [0, 0, 0]);
write(init, "age", [0]);
write(init, "life", randomRange(init, PARTICLE_LIFE_MIN, PARTICLE_LIFE_MAX));
write(init, "size0", randomRange(init, 0.032, 0.056));
write(init, "size", [0]);
write(init, "color", [0.10, 0.52, 0.34, 0]);
const update = new NodeGraph();
const dt = node(update, "builtin", {}, { id: VM_BUILTIN.DELTA_TIME });
const age = node(update, "add", { a: read(update, "age"), b: dt });
const life = read(update, "life");
write(update, "age", age);
const expired = node(update, "compare", { a: age, b: life }, { op: "ge" });
node(update, "kill", { condition: expired });
const pos = read(update, "position");
const vel = read(update, "velocity");
const rawWind = node(update, "wind", { position: pos });
const speed = node(update, "length", { x: rawWind });
// Smooth terminal-velocity soft cap so particles right inside a firing nozzle
// mouth don't overshoot the field while downstream puffs move at full speed.
const gain = node(update, "div", {
a: [1.0],
b: node(update, "mad", { a: speed, b: [0.06], c: [1.0] }),
});
const w = node(update, "scale", { v: rawWind, s: gain });
const targetVel = node(update, "add", { a: w, b: [0, 0.12, 0] });
const dragT = node(update, "saturate", {
x: node(update, "mul", { a: dt, b: [7.0] }),
});
const velNext = node(update, "mix", { a: vel, b: targetVel, t: dragT });
const posNext = node(update, "add", {
a: pos,
b: node(update, "scale", { v: velNext, s: dt }),
});
write(update, "velocity", velNext);
write(update, "position", posNext);
write(update, "streak", node(update, "scale", { v: velNext, s: [0.36] }));
const u = node(update, "saturate", {
x: node(update, "div", { a: age, b: life }),
});
const excitement = node(update, "saturate", {
x: node(update, "mul", { a: speed, b: [0.14] }),
});
const env = node(
update,
"curveLiteral",
{ t: u },
{
curve: scaleCurve([
[0.0, 0.0],
[0.12, 1.0],
[0.78, 1.0],
[1.0, 0.0],
]),
},
);
const boost = node(update, "add", {
a: [1.0],
b: node(update, "mul", { a: excitement, b: [0.38] }),
});
write(
update,
"size",
node(update, "mul", {
a: read(update, "size0"),
b: node(update, "mul", { a: env, b: boost }),
}),
);
const plasmaColor = node(
update,
"gradientRGBA",
{ t: excitement },
{ stops: PLASMA_LUT_STOPS },
);
const ageFade = node(update, "vec4", { x: [1], y: [1], z: [1], w: env });
write(
update,
"color",
node(update, "mul", { a: plasmaColor, b: ageFade }),
);
return ParticleEffect.from({
...create_particle_effect({ layout, init, update }),
texture: spriteUrl,
spawn_rate: PARTICLE_SPAWN_RATE,
prewarm: PARTICLE_LIFE_MAX,
flags: {
soft_depth: true,
blend: EMITTER_BLEND.ALPHA,
projection: EMITTER_PROJECTION.STRETCHED,
},
render: {
position: "position",
velocity: "streak",
size: "size",
color: "color",
},
});
}
new Entity()
.add(new Transform64())
.add(buildJetParticleEffect(makeMoteSprite()))
.build(ecd);
// ─── §7 The jets + the pillars ──────────────────────────────────────────────
const effectors = new FluidEffectorsComponent();
// Calm global far-field effector (`wind = [0, 0, 0]`, `drag = 1.35`) so each
// puff travels down its lane and then relaxes back to still air.
const calmAtmosphere = new GlobalFluidEffector();
calmAtmosphere.wind = [0, 0, 0];
calmAtmosphere.drag = CALM_DRAG;
effectors.addEffector(calmAtmosphere);
const jets = [];
for (let i = 0; i < JET_LANES_Z.length; i++) {
const z = JET_LANES_Z[i];
const jet = new ImpulseFluidEffector();
jet.position = [JET_X, JET_Y, z];
jet.radius = JET_RADIUS;
jet.force = [0, 0, 0];
effectors.addEffector(jet);
jets.push({ effector: jet, phase: JET_PHASES[i], vis: 0 });
}
new Entity().add(effectors).build(ecd);
const CONE_AXIS = new Vector3(0, 0, 1);
const nozzleGeometry = meshlet_geometry_build_from_geometry(
make_cylinder_geometry(0, 0.4, 1.1, 16),
);
const nozzleMaterial = standardMaterial(JET_BASE_COLOR, 0.5);
const FLARE_LENGTH = 1.6;
const FLARE_OFFSET = 0.55 + FLARE_LENGTH / 2;
const flareGeometry = meshlet_geometry_build_from_geometry(
make_cylinder_geometry(0, 0.34, FLARE_LENGTH, 16),
);
const flareMaterial = standardMaterial(JET_COLOR, 0.4);
flareMaterial.emissive_factor.copy(Color.from_sRGB_to_linear(Color.parse(JET_COLOR)));
flareMaterial.emissive_factor.multiplyScalar(PULSE_GLOW);
const nozzleTransforms = [];
const flareTransforms = [];
const coneRotation = new Quaternion();
for (let i = 0; i < jets.length; i++) {
const z = JET_LANES_Z[i];
coneRotation.fromAxisAngle(CONE_AXIS, -Math.PI / 2);
const nozzle = new Transform64();
nozzle.setTranslation(JET_X, JET_Y, z);
nozzle.setRotation(coneRotation.x, coneRotation.y, coneRotation.z, coneRotation.w);
nozzle.updateMatrix();
const nozzleEntity = new Entity()
.add(nozzle)
.add(ShadedGeometry.from(nozzleGeometry, nozzleMaterial))
.build(ecd);
const flare = new Transform64();
flare.setTranslation(JET_X + FLARE_OFFSET, JET_Y, z);
flare.setRotation(coneRotation.x, coneRotation.y, coneRotation.z, coneRotation.w);
flare.setScale(FLARE_MIN_SCALE, FLARE_MIN_SCALE, FLARE_MIN_SCALE);
flare.updateMatrix();
const flareEntity = new Entity()
.add(flare)
.add(ShadedGeometry.from(flareGeometry, flareMaterial))
.build(ecd);
nozzleTransforms.push({ transform: nozzle, entity: nozzleEntity });
flareTransforms.push({ transform: flare, entity: flareEntity });
}
// PILLARS: Static rigid bodies tagged with FluidObstacle in the two outer lanes.
const pillarGeometry = meshlet_geometry_build_from_geometry(
make_box_geometry(PILLAR_W, PILLAR_H, PILLAR_D),
);
const pillarMaterial = standardMaterial(PILLAR_COLOR, 0.95);
for (let i = 0; i < PILLAR_LANES_Z.length; i++) {
const z = PILLAR_LANES_Z[i];
const transform = new Transform64();
transform.setTranslation(PILLAR_X, PILLAR_H / 2, z);
const body = new RigidBody();
body.kind = BodyKind.Static;
const collider = new Collider();
collider.shape = BoxShape3D.from_size(PILLAR_W, PILLAR_H, PILLAR_D);
const obstacle = new FluidObstacle();
obstacle.inflation = OBSTACLE_INFLATION;
new Entity()
.add(transform)
.add(body)
.add(collider)
.add(obstacle)
.add(ShadedGeometry.from(pillarGeometry, pillarMaterial))
.build(ecd);
}
// ─── §8 Per-frame: pulse the jets, HUD ──────────────────────────────────────
const fpsEl = document.getElementById("fps");
const JET_OMEGA = (2 * Math.PI) / JET_PERIOD;
let elapsed = 0;
let fpsWindow = 0, fpsFrames = 0;
let lastFrameMs = performance.now();
engine.graphics.on.postRender.add(() => {
const nowMs = performance.now();
const dt = Math.min((nowMs - lastFrameMs) / 1000, 0.1);
lastFrameMs = nowMs;
elapsed += dt;
for (let i = 0; i < jets.length; i++) {
const j = jets[i];
const s = Math.sin(JET_OMEGA * elapsed - j.phase * JET_OMEGA);
const gust = s > 0 ? s * s : 0;
j.effector.force[0] = JET_STRENGTH * gust;
const rate = gust > j.vis ? PULSE_ATTACK : PULSE_RELEASE;
j.vis += (gust - j.vis) * (1 - Math.exp(-rate * dt));
const nozzleScale = 1 + PULSE_GROW * j.vis;
nozzleTransforms[i].transform.setScale(nozzleScale, nozzleScale, nozzleScale);
nozzleTransforms[i].transform.updateMatrix();
t64_announce_change(ecd, nozzleTransforms[i].entity);
const flareScale = Math.max(j.vis, FLARE_MIN_SCALE);
flareTransforms[i].transform.setScale(flareScale, flareScale, flareScale);
flareTransforms[i].transform.updateMatrix();
t64_announce_change(ecd, flareTransforms[i].entity);
}
// — HUD
fpsWindow += dt;
fpsFrames++;
if (fpsWindow >= 0.5) {
fpsEl.textContent = (fpsFrames / fpsWindow).toFixed(0);
fpsWindow = 0;
fpsFrames = 0;
}
});