feat: foilage
This commit is contained in:
parent
67cd54fe33
commit
6fb46573da
9 changed files with 270 additions and 19 deletions
31
AGENTS.md
31
AGENTS.md
|
|
@ -69,7 +69,9 @@ rules live in `.agents/rules/*.md`.
|
|||
(procedural low-poly oak/spruce geometry, sapling..full via a `growth` knob;
|
||||
`Tree.build` appends into shared trunk + foliage meshes), `Boulder`
|
||||
(procedural low-poly rock: a squashed, jittered, part-buried sphere;
|
||||
`Boulder.build` appends into a shared mesh).
|
||||
`Boulder.build` appends into a shared mesh), `Bush` (cluster of small leaf
|
||||
blobs, shares the oak leaf texture/mesh), `Flower` (thin stem + colored bloom;
|
||||
samples a 2x2 color-atlas texture, drawn double-sided).
|
||||
- `app/` — browser glue.
|
||||
- `main.ts` — game loop, input, preset switching, canvas blit, FPS meter.
|
||||
- `assets.ts` — load `/assets/*.png` → `Texture` (zero-copy; ImageData bytes
|
||||
|
|
@ -77,12 +79,13 @@ rules live in `.agents/rules/*.md`.
|
|||
- `level.ts` — builds the playground: a flat stone-floored room (three thick
|
||||
walls via `slab`, north side open) always drawn, in the center of a big grassy
|
||||
`Terrain` world (~20x across). Props are placed first (`placeTrees` /
|
||||
`placeBoulders` → instance lists + colliders; `TREE_/BOULDER_COUNT`/`_SEED`/
|
||||
`_REACH`), then `buildChunks` bakes terrain + props into a `CHUNK_GRID` x
|
||||
`CHUNK_GRID` grid of `Chunk`s (each = per-texture meshes grass/bark/leaf/needle/
|
||||
rock + a tight AABB) that `main` frustum-culls. `Aabb` colliders (walls, crate,
|
||||
grown trunks, big boulders), NPC position, `TERRAIN`/`TERRAIN_SUBDIV`/`GROUND_UV`,
|
||||
sky/cloud config. The stone floor is lifted by `FLOOR_LIFT` (a z-bias) so it
|
||||
`placeBoulders` / `placeBushes` / `placeFlowers` → instance lists + colliders;
|
||||
`TREE_/BOULDER_/BUSH_/FLOWER_COUNT`/`_SEED`/`_REACH`), then `buildChunks` bakes
|
||||
terrain + props into a `CHUNK_GRID` x `CHUNK_GRID` grid of `Chunk`s (each =
|
||||
per-texture meshes grass/bark/leaf/needle/rock/flowers + a tight AABB) that
|
||||
`main` frustum-culls; bushes fold into the leaf mesh, flowers get their own
|
||||
(drawn double-sided). `Aabb` colliders (walls, crate, grown trunks, big
|
||||
boulders), NPC position, `TERRAIN`/`TERRAIN_SUBDIV`/`GROUND_UV`, sky/cloud config. The stone floor is lifted by `FLOOR_LIFT` (a z-bias) so it
|
||||
stays clean over the terrain skirt that laps under the room edges. Room surfaces
|
||||
are single flat quads -- no subdivision needed since texturing is
|
||||
perspective-correct.
|
||||
|
|
@ -94,9 +97,10 @@ rules live in `.agents/rules/*.md`.
|
|||
`#fps` meter div (styled inline).
|
||||
- `scripts/gen-assets.ts` — procedurally draws the placeholder textures and
|
||||
writes PNGs (hand-rolled encoder via `node:zlib`). Run via `bun run assets`.
|
||||
- `assets/` — generated `floor/grass/bark/leaf/needle/rock/wall/crate/npc` PNGs
|
||||
(`floor` = room stone, `grass` = outdoor ground, `bark`/`leaf`/`needle` = tree
|
||||
trunk/oak/spruce, `rock` = boulders). Swap for real art anytime;
|
||||
- `assets/` — generated `floor/grass/bark/leaf/needle/rock/flower/wall/crate/npc`
|
||||
PNGs (`floor` = room stone, `grass` = outdoor ground, `bark`/`leaf`/`needle` =
|
||||
tree trunk/oak/spruce, `rock` = boulders, `flower` = 2x2 bloom-color atlas).
|
||||
Swap for real art anytime;
|
||||
filenames are the contract.
|
||||
- `server/` — Bun server stub. `shared/` — isomorphic slot.
|
||||
|
||||
|
|
@ -106,7 +110,8 @@ rules live in `.agents/rules/*.md`.
|
|||
`Sky.render` at 1/`SKY_STEP` res (fills color + resets depth, replaces a clear) →
|
||||
`Rasterizer.draw` floor, walls, crate (room, always) → `Frustum.fromViewProj`,
|
||||
then for each `Chunk` that `Frustum.intersectsAabb` passes: draw its grass, rock,
|
||||
bark, leaf, needle (backface-culled) → `Sprite.billboard(npc)` (double-sided) →
|
||||
bark, leaf, needle (backface-culled) + flowers (double-sided) →
|
||||
`Sprite.billboard(npc)` (double-sided) →
|
||||
`Framebuffer.quantize` → `present` (integer-scale, letterboxed blit;
|
||||
`imageSmoothingEnabled` follows `upscaleFilter`).
|
||||
|
||||
|
|
@ -190,7 +195,9 @@ canopy blobs (oak) / tiers (spruce); `seed` gives each tree its own wobble.
|
|||
appends a squashed, per-vertex-jittered low-poly sphere (seam/pole-safe so it
|
||||
never cracks) into one shared rock mesh, sunk partway into the ground.
|
||||
`scatterBoulders` sizes them small→big (biased small) and drops colliders on the
|
||||
big ones.
|
||||
big ones. `Bush` (leaf-blob clusters) and `Flower` (stem + colored bloom, atlas
|
||||
UVs) are the same again — ground detail scattered near the play area, no
|
||||
colliders; add a new prop type by cloning the pattern (generator + scatter).
|
||||
|
||||
## Controls
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue