Spaces:
Running
Running
Codex CLI
feat(shaman): add shaman enemy type with fireball + teleport; refactor enemy typing; improve visuals, aim, and portal FX\n\n- Add shaman enemy (hood, cape, staff, glowing eyes)\n- Fireball projectile: glow, ring, light, flicker; faster speed\n- Aim fix: target camera, update world matrices, prevent reversed shots\n- Teleport: more frequent, portal FX at depart/arrive\n- Refactor enemies to be type-aware (orc/shaman)\n- Waves: spawn 1 shaman per wave\n- Track player velocity for future prediction\n- Add portal FX system
fd12cd0
metadata
title: Orcs In The Forest
emoji: 🧌
colorFrom: green
colorTo: purple
sdk: static
pinned: false
Orcs In The Forest
This project was created using bun init
in bun v1.2.4. Bun is a fast all-in-one JavaScript runtime.
Foliage (Grass/Bushes/Rocks/Flowers)
Ground cover is procedurally generated and batched with THREE.InstancedMesh
in chunked grids for performance. Wind sway for grass/flowers reuses the forest wind uniform and runs entirely in the vertex shader.
- Config: edit
CFG.foliage
insrc/config.js
to tune density and chunk size.chunkSize
: larger reduces draw calls (fewer chunks).grassPerChunk
,flowersPerChunk
,bushesPerChunk
,rocksPerChunk
: density per chunk.windStrength
: vertex bend amount for grass/flowers.densityNearClear
: density at the clearing edge; blends to 1 outward.
Performance tips:
- Lower
grassPerChunk
and/or increasechunkSize
if GPU load is high. - Keep rocks/bush counts modest; they cast shadows by default.
- Grass and flowers don’t receive/cast shadows for cheaper fills.
Performance and Tuning
This pass focused on removing CPU spikes in later waves and reducing GPU shadow/render cost. Key changes:
- Spatial grid for tree colliders drastically reduces O(N) scans for player/enemy movement and projectile collisions.
- Enemy line-of-sight checks are throttled (~0.3s) and now use cheap math instead of
THREE.Raycaster
on hundreds of meshes. - Foliage no longer casts shadows (still receives), and enemy meshes don’t cast shadows to shrink shadow passes.
- Shadow maps: sun maps reduced to 1024, moon and flashlight shadows disabled (big win on laptops/low-end GPUs).
- Render pixel ratio capped at 1.0 and shadow filter uses
PCFShadowMap
(cheaper than soft PCF). - Lightweight FPS display added (top-right) to verify gains.
If you still need more headroom:
- Lower
CFG.waves.maxAlive
from 30 → 24 for fewer concurrent enemies. - Lower
CFG.flashlight.intensity
and/or keep it off at night (pressF
). - Reduce
CLOUDS.count
or disable clouds/mountains insrc/config.js
. - Reduce
CFG.forestSize
orCFG.treeCount
for fewer blockers.
Notes:
- All removed geometry from enemies/FX is properly disposed to avoid GPU memory leaks.
- The LOS heuristic also samples terrain height to prevent shooting through hills without expensive raycasts.