libraryextensions/scene/lib/Scene.xtl
Scene.xtl -- the facade of the scene extension: retained 3D line and point scenes in a native window, patched by id, the mouse orbiting. Import: "sc:" u_se< "Scene" Run with xetal-x, which links scene and serves its windows on the main thread (xetal-x --ext DIR puts this directory on XETAL_PATH). Each signature line is written out by the binding macro (lib/Ffi.xtlm).
ˡo̲pen! : Num a => Char -> a -> Int
title sc:o_pen! width height: a scene window that size (points); its id.
"o_pen! : text float -> int" ᶠᶠⁱb̲ind< "scene/open"
ˡp̲olyline! : (Num a, Num b) => a -> b -> Int
(scene c_at object c_at red green blue) sc:p_olyline! points: put object (an id of your choice) as points joined in order; points are an n by 3 matrix (x y z), colors 0 to 1. Putting an id again replaces it.
"p_olyline! : float float -> int" ᶠᶠⁱb̲ind< "scene/polyline"
ᶠᶠⁱb̲ind< expands to
ˡp̲olyline! ← { a b → pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/polyline?float=" c̲at f̲ormat s̲hape a pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/polyline?float=" c̲at f̲ormat s̲hape b f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/polyline" }
ˡs̲egments! : (Num a, Num b) => a -> b -> Int
header sc:s_egments! points: the points taken in pairs, each a segment.
"s_egments! : float float -> int" ᶠᶠⁱb̲ind< "scene/segments"
ˡd̲ots! : (Num a, Num b) => a -> b -> Int
header sc:d_ots! points: each point a dot.
"d_ots! : float float -> int" ᶠᶠⁱb̲ind< "scene/dots"
ᶠᶠⁱb̲ind< expands to
ˡd̲ots! ← { a b → pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/dots?float=" c̲at f̲ormat s̲hape a pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/dots?float=" c̲at f̲ormat s̲hape b f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/dots" }
ˡq̲uads! : (Num a, Num b) => a -> b -> Int
header sc:q_uads! points: the points taken in fours, each the corners of a filled quad in order round it (4n by 3); shaded by how it faces the light, nearer quads hiding farther ones; lines and dots draw over.
"q_uads! : float float -> int" ᶠᶠⁱb̲ind< "scene/quads"
ˡf̲og! : (Num a, Num b) => a -> b -> Int
scene sc:f_og! near far: quads fade into the background between those depths (scene units from the camera); far <= near: no fog.
"f_og! : float float -> int" ᶠᶠⁱb̲ind< "scene/fog"
ˡe̲ye! : (Num a, Num b) => a -> b -> Int
scene sc:e_ye! x y z yaw pitch: a first-person camera at the eye, looking along yaw (0 toward -z, turning right toward +x) and pitch (up positive), radians; sc:c_amera! goes back to orbiting.
"e_ye! : float float -> int" ᶠᶠⁱb̲ind< "scene/eye"
ˡc̲urve! : (Num a, Num b) => a -> b -> Int
scene sc:c_urve! radius: a curved horizon for the first-person camera -- the world lowered by d^2 / 2R at a distance d along the ground from the eye, as on a small planet; 0 turns it off.
"c_urve! : float float -> int" ᶠᶠⁱb̲ind< "scene/curve"
ˡs̲ky! : (Num a, Num b) => a -> b -> Int
scene sc:s_ky! red green blue: the background, which fog fades to (0 to 1); -1 -1 -1 goes back to the dark default.
"s_ky! : float float -> int" ᶠᶠⁱb̲ind< "scene/sky"
ˡc̲ontrols : Num a => a -> Float
sc:c_ontrols scene: how far the mouse was dragged since last asked (x y, pixels), then 1 or 0 for each key held -- w a s d space shift and the arrows left right up down. Headless, XETAL_EVENTS may hold "keydown w", "keyup w" and "drag 10 0".
"c_ontrols : float -> floats" ᶠᶠⁱb̲ind< "scene/controls"
ˡr̲emove! : (Num a, Num b) => a -> b -> Int
scene sc:r_emove! object: 1 if it was there, else 0.
"r_emove! : float float -> int" ᶠᶠⁱb̲ind< "scene/remove"
ᶠᶠⁱb̲ind< expands to
ˡr̲emove! ← { a b → pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:scene/remove?float=" c̲at f̲ormat s̲hape a pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:scene/remove?float=" c̲at f̲ormat s̲hape b f̲loor f̲irst n̲umbers ⎕N̲GET "ext:scene/remove" }
ˡc̲amera! : (Num a, Num b) => a -> b -> Int
scene sc:c_amera! yaw pitch distance spin: where the camera orbits from (radians, scene units) and how fast it turns by itself (radians a second).
"c_amera! : float float -> int" ᶠᶠⁱb̲ind< "scene/camera"
ˡn̲ext! : Num a => a -> Char
sc:n_ext! scene: the next event, waiting at most a frame (1/60 s): "frame", "key Space", "key q", "close". Dragging orbits by itself.
"n_ext! : float -> text" ᶠᶠⁱb̲ind< "scene/next"