refactor: move world concepts into engine
This commit is contained in:
parent
eeedcb8e48
commit
2d15c7ab8d
52 changed files with 3298 additions and 1558 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import type { Vec3 } from "../../engine/math/Vec3"
|
||||
import { STRIDE, type Mesh } from "../../engine/scene/Mesh"
|
||||
import type { Material } from "../../engine/render/Material"
|
||||
import type { Prefab } from "../../engine/scene/Prefab"
|
||||
|
||||
const TAU = Math.PI * 2
|
||||
|
||||
|
|
@ -17,6 +19,13 @@ export type Bush = {
|
|||
* wound outward, so backface culling is safe. `build` appends into a shared
|
||||
* (leaf-textured) mesh. */
|
||||
export namespace Bush {
|
||||
export function create(material: Material): Prefab<Bush> {
|
||||
return {
|
||||
position: (bush) => bush.position,
|
||||
bakeNear: (bush, batch) => build(bush, batch.mesh(material)),
|
||||
}
|
||||
}
|
||||
|
||||
export function build(bush: Bush, mesh: Mesh): void {
|
||||
const rand = rng(bush.seed)
|
||||
// A handful of smaller overlapping lumps reads as a soft shrub; one big
|
||||
|
|
@ -34,7 +43,14 @@ export namespace Bush {
|
|||
}
|
||||
|
||||
/** A small lumpy low-poly sphere, wound outward (matches the oak canopy blob). */
|
||||
function blob(mesh: Mesh, cx: number, cy: number, cz: number, radius: number, rand: () => number): void {
|
||||
function blob(
|
||||
mesh: Mesh,
|
||||
cx: number,
|
||||
cy: number,
|
||||
cz: number,
|
||||
radius: number,
|
||||
rand: () => number,
|
||||
): void {
|
||||
const seg = 6
|
||||
const rings = 4
|
||||
const start = mesh.verts.length / STRIDE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue