Bastion Works: Towers, Turrets and Targeting Kit
README.md
projectileKit.render
Draws every projectile, beam and effect with pooled entities. Each look (see
projectileKit.looks) owns one pool of plain local, temporary entities, one Model each,
made once and kept while the scene lives. Each frame the caller queues what to draw and
flush() writes all the transforms of a pool in three batched calls (position, rotation,
scale) through typed CPU buffers. Unused pool members are parked at zero scale far below
the world (y = -900), so nothing is spawned, toggled or despawned per shot.
A pool grows only when a frame asks for more than it has, by at most spawnPerFrame
entities a frame, up to the look's cap and the global maxVisible budget. If the
scene drops the pool entities (reload, mode change) the pool is rebuilt automatically.
Called by projectileKit.api each frame (begin → draw… → flush). Game code
normally only touches setBudget, prewarm and stats, usually through the api.
Functions
begin(): starts a frame; forgets what was queued last frame.draw(look: string, pos: { number }, rot: { number }, scale: { number }): boolean- queues one item (rotis a quaternion{ x, y, z, w }). Returnsfalsewhen the look is unknown or its pool is full this frame (the item is not drawn).flush(): writes every queued item to its pooled entity and parks the rest. Call once a frame after the draws.prewarm(look: string, count: number): makes up tocountentities of a look ahead of time so the first volley does not wait for its pool.setBudget(t: any): setsmaxVisible(all looks together, default 600) and/orspawnPerFrame(default 12).budget(): any: a copy of the current budget.stats(): any:{ created, visibleNow, peakVisible, skipped, poolEntities, pools = { [look] = { size, drawn, peak } } }.clear(): despawns every pooled entity (they come back on demand).
State lives in modules.state(), so it survives hot reloads of the module.