ludic/packages/ludic.lab/plate.ludic
Orkuncakilkaya 19fcf60599 wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run
ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic
  1804 vars into 126 states, 64 into lets; 23498 edits in 460 files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 15:31:34 +03:00

34 lines
1.7 KiB
Text

# plate.ludic - the stage: a flat disc 40 m across at y = 0 with a line every metre, lit by the
# package's own small sky (a sun 40 degrees up), and nothing else. Its files are in plate/.
# the package's plate/ directory: beside the project (a checkout of the toolchain) or installed
export function lab_plate_dir(lab_st: mut LabState) -> string {
if lab_st.lb_plate_dir != "" { return lab_st.lb_plate_dir }
lab_st.lb_plate_dir = "packages/ludic.lab/plate"
if not Fs.exists(`{lab_st.lb_plate_dir}/plate.gltf`) { lab_st.lb_plate_dir = `{r3d_home()}/packages/ludic.lab/plate` }
return lab_st.lb_plate_dir
}
function lab_plate_load(lab_st: mut LabState, render3d_st: mut Render3dState) -> void {
let m = gltf_load(render3d_st, lab_plate_dir(lab_st), "plate.gltf", "plate")
if m == null { return }
lab_st.lb_plate = actor_new(render3d_st, m)
lab_st.lb_plate.casts = false
lab_st.lb_plate.cull = 0.0
lab_st.lb_plate.radius = 0.0
actor_place(lab_st.lb_plate, 0.0, 0.0, 0.0, 0.0)
}
# the ground under (x, z): the plate is flat at 0
export function lab_ground_y(x: float, z: float) -> float { return 0.0 }
# an actor stood on the plate at (x, z), facing yaw (radians)
export function lab_stand(a: Actor, x: float, z: float, yaw: float) -> void {
if a == null { return }
actor_place(a, x, lab_ground_y(x, z), z, yaw)
}
# a model from a glTF file stood on the plate: the one call a scene usually needs
export function lab_model(render3d_st: mut Render3dState, dir: string, file: string, node: string, x: float, z: float, yaw: float) -> Actor {
let m = gltf_load(render3d_st, dir, file, node)
if m == null { return null }
let a = actor_new(render3d_st, m)
lab_stand(a, x, z, yaw)
return a
}