import type { DrawGroup } from "./Material" import type { Vec3 } from "../math/Vec3" export type Bounds3 = { minX: number minY: number minZ: number maxX: number maxY: number maxZ: number } /** One cullable section of static world geometry with two engine-supported LODs. */ export type Chunk = Bounds3 & { readonly near: readonly DrawGroup[] readonly far: readonly DrawGroup[] } export namespace Chunk { export function isFar(chunk: Chunk, eye: Vec3, lodDistance: number): boolean { if (!(lodDistance < Infinity)) { return false } const dx = eye.x - Math.max(chunk.minX, Math.min(chunk.maxX, eye.x)) const dy = eye.y - Math.max(chunk.minY, Math.min(chunk.maxY, eye.y)) const dz = eye.z - Math.max(chunk.minZ, Math.min(chunk.maxZ, eye.z)) return dx * dx + dy * dy + dz * dz > lodDistance * lodDistance } }