feat: actors stage 2
This commit is contained in:
parent
4869db01e5
commit
581e5892b0
19 changed files with 752 additions and 594 deletions
21
app/main.ts
21
app/main.ts
|
|
@ -1,7 +1,7 @@
|
|||
import { RenderConfig } from "../engine/render/RenderConfig"
|
||||
import { Camera } from "../engine/scene/Camera"
|
||||
import type { Mesh } from "../engine/scene/Mesh"
|
||||
import { Mob } from "../engine/scene/Mob"
|
||||
import { Mob, MOB_KINDS, type MobKind } from "../engine/scene/Mob"
|
||||
import type { Vec3 } from "../engine/math/Vec3"
|
||||
import { loadTextures } from "./assets"
|
||||
import { buildLevel, type Level } from "./level"
|
||||
|
|
@ -48,21 +48,22 @@ function benchStats(a: number[]): { median: number; p95: number; max: number; me
|
|||
async function main(): Promise<void> {
|
||||
const textures = await loadTextures()
|
||||
const level = buildLevel(textures)
|
||||
// Two canonical mob meshes, built once and shared by every instance (the sim
|
||||
// supplies each mob's per-frame transform).
|
||||
const frogMesh: Mesh = { verts: [], indices: [] }
|
||||
const beeMesh: Mesh = { verts: [], indices: [] }
|
||||
const robinMesh: Mesh = { verts: [], indices: [] }
|
||||
Mob.build("frog", frogMesh)
|
||||
Mob.build("bee", beeMesh)
|
||||
Mob.build("robin", robinMesh)
|
||||
// Build each kind's canonical mesh once, shared by every instance (the sim
|
||||
// supplies each mob's per-frame transform). Registry-driven -- a new kind needs
|
||||
// no change here.
|
||||
const mobMesh = {} as Record<MobKind, Mesh>
|
||||
for (const kind of MOB_KINDS) {
|
||||
const m: Mesh = { verts: [], indices: [] }
|
||||
Mob.build(kind, m)
|
||||
mobMesh[kind] = m
|
||||
}
|
||||
const scene: Scene = {
|
||||
chunks: level.chunks,
|
||||
floor: level.floor,
|
||||
walls: level.walls,
|
||||
crate: level.crate,
|
||||
npc: { position: level.npcPosition, size: { x: 1.1, y: 1.5 } },
|
||||
mobMesh: { frog: frogMesh, bee: beeMesh, robin: robinMesh },
|
||||
mobMesh,
|
||||
mobCount: level.mobs.length,
|
||||
sky: level.sky,
|
||||
textures,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue