import { createScene, environmentOf, type EnvironmentPreset, type Scene, type SceneEnvironment } from "@klorad/api/world";
/** The light of a time of day with its haze: an environment is plain data, so a change is a new value. */
export function lightOf(preset: EnvironmentPreset, fog: number): SceneEnvironment {
return { ...environmentOf(preset), fog };
}
import type { ObjectTransform } from "@klorad/engine-three";
/** A courtyard with a few pieces to arrange: two plinths, a stele and a column. */
export function createLookDemo(): { readonly scene: Scene } {
const scene = createScene({ name: "Courtyard", coordinateSystem: { origin: { lat: 40.632, lon: 22.951, height: 12 } } });
scene.add({ id: "plinth-a", name: "Plinth A", position: { east: -3, north: 0 }, geometry: { kind: "box", width: 1.2, depth: 1.2, height: 1 }, color: "#c9b48a" });
scene.add({ id: "plinth-b", name: "Plinth B", position: { east: 3, north: 0 }, geometry: { kind: "box", width: 1.2, depth: 1.2, height: 1 }, color: "#c9b48a" });
scene.add({ id: "stele", name: "Stele", position: { east: 0, north: 4 }, orientation: { heading: 20 }, geometry: { kind: "box", width: 0.8, depth: 0.3, height: 2.2 }, color: "#9aa3ad" });
scene.add({ id: "column", name: "Column", position: { east: 0, north: -4 }, geometry: { kind: "cylinder", radius: 0.35, height: 3 }, color: "#e2dccf" });
return { scene };
}
/** The handles report where the object would be; the scene is updated, and every view draws it there. */
export function arrange(scene: Scene, t: ObjectTransform) {
return scene.update(t.objectId, { position: t.position, orientation: { heading: t.heading }, scale: t.scale });
}