tycho_3d

    Tycho 3D — three.js-inspired pure-MoonBit scene graph, cameras, materials, lights, shadows, and forward PBR renderer over laplaceliu/tycho

    3d
    graphics
    pbr
    scene-graph
    threejs
    tycho
    Download zip
    Version
    0.13.0
    License
    Apache-2.0
    Last updated
    1 hour ago
    Downloads
    33

    #laplaceliu/tycho_3d

    Part of the Tycho graphics stack — mounted there as the 3d/ submodule.

    three.js-inspired pure-MoonBit 3D rendering library over laplaceliu/tycho (RHI), laplaceliu/tycho_math, and laplaceliu/tycho_geometry.

    #What works today (M0–M1)

    • Scene: arena-based scene graph with generation-checked NodeId handles, dirty-flag world-transform propagation, reparenting with keep_world, layers, traversal, subtree destruction, and frustum-culled collection.
    • AnimationClip / AnimationPlayer: translation / rotation / scale keyframe tracks with linear (Vec3) or slerp (Quat) interpolation, per-channel node binding, looping or clamped playback, and update(scene, dt) that writes local transforms (3d/animation).
    • AnimationMixer / AnimationAction: any number of clips blended by normalized weight (a lone action at weight 0.5 plays its full pose), crossfade, LoopRepeat / LoopOnce / LoopPingPong, per-action speed/pause/seek/fade, a global time scale, and channels bound to destroyed nodes are skipped.
    • Camera: perspective (infinite reversed-Z by default) / orthographic reversed-Z projections, view/view-projection matrices, screen rays, and an analytic sky ray matrix.
    • Split-sum IBL: a 64x64 RG16F LUT is baked once by brdf_lut.frag (GGX + Smith visibility), so environment specular is prefiltered * (F0 * A + B) instead of an analytic Fresnel guess.
    • Shadow atlas: one 2x2 depth atlas holds up to four shadow-casting lights (directional or spot, one tile each); Light::spot(..., shadow=...) opts a spot in. Each light carries its tile view-projection and tile rect in the light SSBO, and PCF clamps to the tile so taps never bleed across lights.
    • TAA: RendererDesc::with_taa(true) rasterises with an 8-phase Halton sub-pixel jitter and resolves against a reprojected history buffer (camera-only reprojection, 3x3 neighbourhood clamp, residual guard). Call reset_taa() after a camera cut. There are no per-object motion vectors yet, so fast-moving geometry can ghost (3d/taa).
    • SSAO: RendererDesc::with_ssao(true) reconstructs world positions from the single-sample depth buffer (no G-buffer), accumulates a 12-sample rotated hemisphere and box-blurs the result; the tonemap pass multiplies it in before ACES. SSAO needs a single-sample depth attachment, so enabling it forces MSAA off; set_ssao_intensity(0) toggles it off at runtime (3d/ssao).
    • Non-bindless fallback: RendererDesc::with_bindless(false) (or a device without descriptor indexing) switches to a PBR shader variant that binds albedo/normal per batch; identical output, exercised by 3d/brdf-fallback.
    • Renderer3D: forward PBR metallic-roughness with linear-space materials, directional/point/spot/ambient/hemisphere lights, one directional PCF shadow map (two cascades: an inner half-radius fit at twice the density plus the full caster union), GGX-prefiltered (PMREM) environment IBL, HDR RGBA16F, separable bloom, and ACES tonemapping into RGBA8Srgb.
    • glTF: load_gltf_instance uploads parse_gltf / parse_glb meshes and materials — JSON documents with data-URI buffers and binary GLB containers with buffer-view images alike — decoding images through the RHI (base colour as sRGB, normal and metallic-roughness maps linear), and returns one GltfInstance aggregating roots, the glTF-node → NodeId map, meshes, materials, and the AnimationClips already bound to the instantiated nodes. load_gltf / load_gltf_with_nodes / load_gltf_animations remain as thin specialisations (3d/gltf-viewer / 3d/gltf-animation).
    • Physical glTF materials: parse_glb maps KHR_materials_transmission / KHR_materials_ior onto MaterialDesc::with_transmission, KHR_materials_iridescence (midpoint thickness) onto with_iridescence, KHR_materials_clearcoat onto with_clearcoat, and KHR_materials_emissive_strength into emissive, so an authored asset keeps its film and glass response without hand-written material code (3d/iridescence-lamp).
    • Metallic-roughness maps: MaterialDesc::with_metallic_roughness_tex samples a packed glTF metallicRoughnessTexture (G roughness, B metallic) from the bindless heap; the scalar factors stay as multipliers. The non-bindless fallback keeps the factors only.
    • HDR environments: decode_hdr parses Radiance RGBE (RLE and flat scanlines, -Y/+Y and +X/-X), encode_hdr writes it, and equirect_environment_cubemap projects a linear equirect image into the GGX-prefiltered RGBA16F mip chain, so sun values above 1.0 survive (f16_bits packs half floats).
    • procedural_environment_cubemap(size=256, samples=128): linear sky baked into a full GGX mip chain by a GPU prefilter pass (one draw per face per mip, read back and uploaded via create_cubemap_mipmapped); 512^2 with 256 samples is supported, and PBR samples textureLod(uEnv, R, roughness * maxLod) with no pow(2.2) approximation.
    • Static batch cache: every mesh lives in a shared vertex/index arena, so a draw is just a range. Opaque batches upload one indirect command each and a single draw_indexed_indirect_count issues them all (compute culling fills instance counts); the non-bindless fallback keeps per-batch draws because it rebinds material textures.
    • Physical clearcoat: MaterialDesc::with_clearcoat(1.0, roughness=0.2) adds a second GGX lobe in the direct and environment terms (3d/clearcoat).
    • Physical sheen: MaterialDesc::with_sheen(color, roughness=...) adds the glTF KHR_materials_sheen Charlie/Ashikhmin grazing lobe to the direct and environment terms; a zero colour disables it (material SSBO 64 → 80 bytes).
    • Thin-film iridescence: MaterialDesc::with_iridescence(1.0, ior=1.35,thickness_nm=380) evaluates two-beam (Airy) interference at the R/G/B wavelengths per pixel and blends the view-dependent reflectance into the specular F0 of both the direct and environment terms. A perfect mirror correctly shows no tint, since it reflects all light; dielectrics with a dark base show the soap-bubble shift (3d/iridescence).
    • Screen-space transmission: MaterialDesc::with_transmission(0.92, ior=1.45) draws the mesh in a second pass against a copy of the already-shaded scene and refracts that view by ior, so the background is genuinely displaced instead of merely alpha-blended (3d/transmission). The pass only runs when a transmissive object is visible; static meshes only, and it does not use the ray-shadow shader variant (material SSBO 80 → 96 bytes).
    • Morph targets: MeshData::add_morph_target stores up to two position-delta sets, create_morph_node/set_morph_weights animate them through a 72-byte stream with per-draw push-constant weights (3d/morph).
    • Point cube shadows: point lights with a ShadowDesc render six faces into a 4x2 atlas; the fragment shader selects the face from the dominant axis and reads the shared tile table (3d/point-shadow).
    • Ray-traced sun shadows: set_ray_shadows(true) swaps in a VK_KHR_ray_query fragment variant that traces one shadow ray per pixel against a per-mesh BLAS/TLAS (3d/ray-shadow; opt-in, no-op without ray query support).
    • Distance LOD: create_lod_node(scene, levels, switch_distances, material) swaps meshes per camera distance, shares one material for instancing, and reports stats.lod_switches (3d/lod selects 48x32 / 20x12 / 8x5 spheres).
    • Shared LOD specs: create_lod_spec(levels, switch_distances) registers a level chain once, and create_lod_instance(scene, spec, material, ...) spawns any number of nodes on it — 10k instances of one chain cost one spec instead of 10k per-node arrays (three.js BatchedMesh.addGeometryLOD). The binding is visible through Scene::instance_lod.
    • Per-instance tint: MeshInstance::with_tint / Scene::set_instance_tint multiplies the material base colour per node (linear RGBA), so one shared material paints thousands of differently coloured instances and a hover highlight rewrites exactly one object record (3d/batch-lod-bvh).
    • GPU skinning: MeshData::set_skin attaches four joint indices/weights per vertex (80-byte stream), Renderer3D::create_skinned_node binds a joint list plus inverse bind matrices, and the vertex shader applies the palette from a bone SSBO indexed through the object record; skinned nodes also cast into the shadow atlas through a depth-only skinned pipeline (3d/skinning).
    • Automatic instancing: visible mesh nodes are grouped by (mesh, material) and each run is drawn with draw_indexed(..., instances=n). Shaders index the object SSBO as firstObject + gl_InstanceIndex, so 10k nodes collapse into one draw with no per-instance vertex layout.
    • Material textures: Renderer3D::create_texture uploads RGBA8 (sRGB or linear) into a bindless heap (descriptor set 1); the material SSBO stores albedo/normal slot indices, so switching materials never rebinds samplers. Missing maps fall back to 1x1 white / flat-normal slots. Tangents are generated on upload, enabling world-space normal mapping, and AlphaMode::Mask discards against the sampled albedo alpha.
    • GpuMesh: interleaved P3/N3/UV2/T4 upload from @tgeo.MeshData (16-bit indices when possible, CPU copy retained for picking).
    • Renderer3D::pick + ray_mesh_hit: frustum-culled, world-space ray picking with Moller-Trumbore and normal-matrix-transformed normals.
    • Picking BVH: MeshBvh builds a median-split hierarchy per mesh; pick / pick_pixels lazily build and cache one per uploaded mesh, so a pointer ray no longer touches every triangle. ray_mesh_hit stays as the brute-force reference used by tests.
    • Fog: Renderer3D::set_fog(fog_linear(...)) / fog_exp2(...) mix linear or exponential-squared distance fog before tone mapping. Fog parameters ride in the frame UBO, so toggling fog creates no pipeline variant and applies to unlit materials too.
    • OrbitCamera / FlyCamera: drag-to-orbit, scroll-to-zoom and WASD/QE fly controllers that consume @tycho.Event and emit camera Transforms.
    • 4x MSAA: the HDR pass renders into a multisampled RGBA16F target and resolves into a single-sample target consumed by bloom/tonemap; RendererDesc.msaa=false selects the single-sampled path.
    • HUD composition: Renderer3D::render_swapchain_into(cmd, sc, ...) renders and blits without ending the frame, so tycho_2d can draw a HUD on top with load_op = Load before the app presents (general/3d-hud).
    • Transparent pass: AlphaMode::Blend nodes are sorted back-to-front by camera distance and drawn with a depth-tested, depth-write-disabled pipeline.
    • Debug lines: add_debug_line / add_debug_aabb queue world-space segments drawn through a depth-tested LineList pipeline after the transparent pass; clear_debug_lines resets them and stats().line_segments reports them.
    • Line nodes: upload_lines(@tgeo.LineData) keeps an edge/wireframe line list in local space on the GPU, and create_line_node(scene, handle, material,transform) draws it through the shared LineList pipeline with the node's world transform plus a LineMaterial colour (push constants). Line nodes are frustum-culled and pickable (LINE_PICK_RADIUS), but cast no shadows and are not ray-tracing geometry.
    • glTF 2.0 subset: @tgeo.parse_gltf (JSON + data-URI buffers) and @tgeo.parse_glb (binary container + buffer-view images) handle POSITION/NORMAL/TEXCOORD_0, 8/16/32-bit indices, node TRS/matrix hierarchy, base-colour / normal / metallic-roughness texture references, and the physical material extensions listed above; @t3d.load_gltf uploads meshes/materials and instantiates the hierarchy.
    • GPU-driven path (RendererDesc.gpu_culling): submits every mesh node, runs cull.comp per instanced batch (bounding-sphere vs frustum) to compact a visible index list and grow a draw_indexed_indirect command, then the PBR vertex shader remaps gl_InstanceIndex through that list. Example 70 shows the GPU-culled image is pixel-identical to the CPU-culled one.
    • Ergonomics: create_mesh_node / create_pbr_node (mesh + material + bounds in one call), add_sun / add_ambient, and set_procedural_environment (renderer-owned PMREM env), which keep showcase apps around 150 lines. Skinned/morph nodes come in both flavours: create_skinned_node / create_morph_node allocate a material from a MaterialDesc, while create_skinned_mesh_node / create_morph_mesh_node take an existing MaterialHandle so materials can be shared and freed explicitly.
    • Safety: MeshHandle / MaterialHandle / TextureHandle can only be created by the renderer (no public from_id), so a scene cannot reference a slot the renderer never allocated. Scene::add_camera returns a typed CameraId (Scene::camera_of(node) validates an existing node), and the render entries take it — render_offscreen(target, scene, camera) / render_swapchain(sc, scene, camera) share one target-first argument order.
    • Passes: render_frame records the shadow atlas, the main opaque/transparent pass, the bloom extract/blur pair and the tonemap through cmd.render_pass(…) scopes, so every pass is closed even when recording fails. and cannot be handed a mesh node.
    • Typed failures: renderer and scene helpers raise Render3DError (InvalidMesh / InvalidMaterial / InvalidTexture / InvalidCamera / CapacityExceeded / Unsupported) instead of bare fail(...) messages.
    • RenderStats3D: counters with summary() and to_json() for gates.

    All pipelines are AOT SPIR-V (shaders_spv.mbt, generated by tools/gen-glsl-shaders.py); material parameters travel through an SSBO, so material count does not create pipelines.

    #Usage

    let renderer = @t3d.Renderer3D::new(dev)
    let scene = @t3d.Scene::new()
    let mesh = renderer.upload_mesh(@tgeo.sphere(radius=0.5))
    let mat = renderer.create_material(
    @t3d.MaterialDesc::pbr(@t3d.srgb(1.0, 0.6, 0.2), metallic=0.0, roughness=0.4),
    )
    let node = scene.create_node(
    transform=@tmath.Transform::from_translation(@tmath.Vec3::new(0.0, 0.0, 0.0)),
    payload=@t3d.NodePayload::Mesh(@t3d.MeshInstance::new(mesh, mat)),
    )
    scene.set_local_bounds(node, renderer.mesh_bounds(mesh))
    renderer.render_swapchain(sc, scene, camera_node)

    See examples/3d/hello for the smallest complete scene written with this layer, examples/3d/showcase for the full PBR showcase, examples/3d/batch-lod-bvh for the three.js webgl_batch_lod_bvh port (shared LOD specs, per-instance tint, BVH picking over 4096 instances), and examples/3d/iridescence-lamp for the three.js webgl_loader_gltf_iridescence port (binary glTF, HDR sky, physical glass).

    #three.js-style authoring layer

    The renderer keeps the arena + handle core (generation-checked NodeId, AOT pipeline family, SSBO-packed materials), while the authoring surface follows three.js so a scene reads like the one you would write in JS.

    let renderer = @t3d.Renderer3D::new(dev)
    let scene = @t3d.Scene::new()

    // `new Mesh(geometry, material)` + `scene.add(mesh)` in one call.
    let ball = renderer.add(
    scene,
    @tgeo.sphere(radius=0.5),
    @t3d.MaterialDesc::standard(@t3d.hex(0xFF8800), roughness=0.35),
    )
    scene.set_position(ball, 0.0, 1.0, 0.0)
    scene.set_uniform_scale(ball, 0.8)

    // Grouping, orientation and inherited visibility.
    let pivot = scene.add_group(name="pivot")
    let _child = renderer.add(scene, @tgeo.box(), @t3d.MaterialDesc::basic(@t3d.hex(0x88CCFF)), parent=pivot)
    scene.look_at(_child, @tmath.Vec3::zero())

    // Lights, grid and axes.
    let _sun = scene.add_directional_light(
    direction=@tmath.Vec3::new(-0.4, -1.0, -0.3),
    intensity=4.0,
    )
    let _ambient = scene.add_ambient_light(intensity=0.2)
    let _grid = renderer.add_grid(scene, size=20.0, divisions=20)
    let _axes = renderer.add_axes(scene, size=1.0)

    // Degrees are accepted where three.js uses degrees.
    let camera = scene.add_camera(
    @t3d.Camera::perspective_deg(60.0, 800.0 / 600.0, near=0.1),
    )

    // Frame loop: the platform owns the monotonic timestamp.
    let clock = @t3d.Clock::new()
    // per frame: let dt = clock.tick(now_seconds)
    // renderer.render_offscreen(target, scene, camera)

    // Pointer picking in pixel space (top-left origin, any ClipSpace).
    // match renderer.pick_pixels(scene, camera, px, py, 800.0, 600.0) { ... }

    three.jstycho_3d
    new Scene()Scene::new()
    new Mesh(g, m) + scene.addRenderer3D::add(scene, geometry, desc)
    new BoxGeometry(...) / SphereGeometry@tgeo.box(...) / @tgeo.sphere(...)
    new MeshStandardMaterial({ color: 0xff8800 })MaterialDesc::standard(hex(0xFF8800))
    new MeshBasicMaterial(...)MaterialDesc::basic(...)
    material.transmission = 0.9; material.ior = 1.45MaterialDesc::with_transmission(0.9, ior=1.45)
    material.iridescence = 1; iridescenceThicknessRange = [380, 380]MaterialDesc::with_iridescence(1.0, thickness_nm=380)
    SSAOPass (addon)RendererDesc::with_ssao(true) + set_ssao_intensity
    TAARenderPass (addon)RendererDesc::with_taa(true) + reset_taa
    new Color(0xff8800) / setHSLhex(0xFF8800) / hsl(deg, s, l) → linear Vec4
    mesh.position.set(x, y, z)Scene::set_position(id, v) / translate
    mesh.rotation.set(x, y, z)Scene::set_euler(id, x, y, z)
    mesh.scale.setScalar(s)Scene::set_uniform_scale(id, s)
    mesh.lookAt(v)Scene::look_at(id, v)
    parent.add(child)Scene::set_parent(child, Some(parent))
    mesh.removeFromParent()Scene::remove(id) (stays alive, becomes a root)
    object.visible = falseScene::set_visible(id, false) — inherited by the subtree
    new DirectionalLight / PointLight / SpotLightScene::add_directional_light / add_point_light / add_spot_light
    new PerspectiveCamera(60, ...)Camera::perspective_deg(60.0, aspect)
    camera.aspect = w / h on resizescene.set_camera(cam, scene.camera(cam).with_viewport(w, h))
    scene.background = new Color(...)Renderer3D::set_background(hex(...)) / clear_background()
    scene.fog = new Fog(c, near, far)Renderer3D::set_fog(fog_linear(c, near=..., far=...))
    scene.fog = new FogExp2(c, density)Renderer3D::set_fog(fog_exp2(c, density=...))
    GridHelper / AxesHelperRenderer3D::add_grid / add_axes
    InstancedMesh.setColorAt(i, c)Scene::set_instance_tint(id, c) (MeshInstance::with_tint)
    BatchedMesh.addGeometryLOD + instanceCountcreate_lod_spec / create_lod_instance (3d/batch-lod-bvh)
    RaycasterRenderer3D::pick_pixels (pixels) or pick (NDC)
    Clock.getDelta()Clock::tick(now_seconds)
    GLTFLoader@tgeo.parse_gltf + Renderer3D::load_gltf_instance
    AnimationMixer / clipActionAnimationMixer::add / action (AnimationPlayer for one clip)

    Design notes:

    • Renderer3D::add uploads a fresh geometry per call, mirroring new Mesh(new BoxGeometry()). For a shared mesh (10k instanced nodes), call upload_mesh / create_material once and use create_mesh_node; equal (mesh, material) pairs still collapse into one instanced draw.
    • Colors stay linear Vec3/Vec4; hex / hsl / linear are authoring converters only, so there is still one color source of truth.
    • set_background skips the sky draw and clears the HDR target to a flat authoring color; the environment cubemap stays bound for IBL. clear_background returns to the procedural sky. Fog is applied to geometry only, matching the three.js split between scene.fog and scene.background.
    • Every create_*_node helper accepts parent?, so a mesh / LOD / skinned / morph node can join a group in the same call (create_mesh_node(..., parent=g)).
    • Visibility, frustum collection, light collection and picking all use Scene::is_visible_in_world, so hiding a group hides its whole subtree.
    • LOD / skin / morph registrations are matched by the full generation-checked NodeId and pruned for dead nodes each frame; Renderer3D::release_node drops them deterministically before an arena slot is reused.
    • Clock clamps long frames (max_delta, 0.25 s by default) and returns 0 on the first tick, so pausing a debugger never teleports animation.

    #Conventions

    • Right-handed, +Y up, -Z forward; lights and cameras look down local -Z.
    • Linear working space; sRGB only at texture input and output encoding.
    • One Quat source of truth in Transform (no Euler/quaternion dual state).
    • Reversed-Z everywhere in the scene pass (GreaterEqual, depth clear 0).

    #Test

    moon test --target native python tools/run-gates.py 3d # from the meta-repo: unit tests + the 3D examples on every ICD

    Render3DError

    pub suberror Render3DError {
    InvalidMesh(String)
    InvalidMaterial(String)
    InvalidTexture(String)
    InvalidCamera(String)
    CapacityExceeded(String)
    Unsupported(String)
    }

    Failures raised by the 3D renderer and scene helpers.

    AlphaMode

    pub(all) enum AlphaMode {
    Opaque
    Mask(Float)
    Blend
    }

    AmbientLight

    pub(all) struct AmbientLight {
    color :
    Vec3

    intensity : Float
    }

    AnimationAction

    pub struct AnimationAction {
    clip : AnimationClip
    // private fields
    }

    One clip bound to a mixer. Actions are owned by their AnimationMixer; the value returned by AnimationMixer::add / action refers to the live action, so play / fade_in / seek mutate what the mixer will sample next frame.

    AnimationAction::duration

    fn AnimationAction::duration(self : AnimationAction) -> Float

    Clip duration in seconds.

    AnimationAction::fade_in

    fn AnimationAction::fade_in(self : AnimationAction, duration : Float) -> Unit

    Fade the action in over duration seconds, starting from its current fade factor. A non-positive duration snaps to full weight.

    AnimationAction::fade_out

    fn AnimationAction::fade_out(self : AnimationAction, duration : Float) -> Unit

    Fade the action out over duration seconds. The action keeps running at weight 0 afterwards; call stop to release it.

    AnimationAction::is_finished

    fn AnimationAction::is_finished(self : AnimationAction) -> Bool

    true after a Once action reached its last keyframe.

    AnimationAction::is_paused

    fn AnimationAction::is_paused(self : AnimationAction) -> Bool

    AnimationAction::is_playing

    fn AnimationAction::is_playing(self : AnimationAction) -> Bool

    AnimationAction::loop_mode

    fn AnimationAction::loop_mode(self : AnimationAction) -> LoopMode

    AnimationAction::name

    fn AnimationAction::name(self : AnimationAction) -> String

    Clip name this action plays.

    AnimationAction::pause

    fn AnimationAction::pause(self : AnimationAction) -> Unit

    Freeze the action at its current time; the pose still contributes its weight.

    AnimationAction::play

    fn AnimationAction::play(self : AnimationAction) -> Unit

    Start (or resume) the action. A finished Once action restarts from zero.

    AnimationAction::seek

    fn AnimationAction::seek(self : AnimationAction, t : Float) -> Unit

    Jump to t seconds (clamped to the clip range); does not change play state.

    AnimationAction::set_loop

    fn AnimationAction::set_loop(self : AnimationAction, mode : LoopMode) -> Unit

    Change the loop behaviour; switching to Once clears the finished flag.

    AnimationAction::set_speed

    fn AnimationAction::set_speed(self : AnimationAction, speed : Float) -> Unit

    Set the playback speed multiplier.

    AnimationAction::set_weight

    fn AnimationAction::set_weight(self : AnimationAction, weight : Float) -> Unit

    Set the user weight (clamped to [0, 1]).

    AnimationAction::speed

    fn AnimationAction::speed(self : AnimationAction) -> Float

    Playback speed multiplier (negative values run the clip backwards).

    AnimationAction::stop

    fn AnimationAction::stop(self : AnimationAction) -> Unit

    Stop and rewind; the action contributes nothing until play.

    AnimationAction::time

    fn AnimationAction::time(self : AnimationAction) -> Float

    Local playback time, in seconds.

    AnimationAction::weight

    fn AnimationAction::weight(self : AnimationAction) -> Float

    Current user weight in [0, 1]; fades multiply it by an internal factor.

    AnimationChannel

    pub(all) struct AnimationChannel {
    node : NodeId
    track : TransformTrack
    }

    AnimationChannel::new

    AnimationClip

    pub(all) struct AnimationClip {
    name : String
    channels : Array[AnimationChannel]
    }

    AnimationClip::duration

    fn AnimationClip::duration(self : AnimationClip) -> Float

    AnimationClip::new

    fn AnimationClip::new(name : String, channels : Array[AnimationChannel]) -> AnimationClip

    AnimationMixer

    pub struct AnimationMixer {
    // private fields
    }

    Owns every clip action and advances / blends them together.

    AnimationMixer::action

    fn AnimationMixer::action(self : AnimationMixer, name : String) -> AnimationAction?

    Look up an action by clip name (the first match, or None).

    AnimationMixer::action_count

    fn AnimationMixer::action_count(self : AnimationMixer) -> Int

    Number of actions owned by this mixer.

    AnimationMixer::add

    Add a clip and return its action. The action starts playing at weight 1; call fade_in / set_weight(0) first when it should blend in.

    AnimationMixer::cross_fade

    fn AnimationMixer::cross_fade(self : AnimationMixer, from : AnimationAction, to : AnimationAction, duration : Float) -> Unit

    Fade from out and to in over duration seconds (three.js AnimationAction.crossFadeTo). to is rewound to weight 0 first, so a crossfade is symmetric even when to was already fully faded in.

    AnimationMixer::new

    AnimationMixer::set_time_scale

    fn AnimationMixer::set_time_scale(self : AnimationMixer, scale : Float) -> Unit

    Set the global time multiplier.

    AnimationMixer::stop_all

    fn AnimationMixer::stop_all(self : AnimationMixer) -> Unit

    Stop every action and rewind it.

    AnimationMixer::time_scale

    fn AnimationMixer::time_scale(self : AnimationMixer) -> Float

    Global time multiplier applied to every action's delta.

    AnimationMixer::update

    fn AnimationMixer::update(self : AnimationMixer, scene : Scene, dt : Float) -> Unit

    Advance every action by dt * time_scale and write the blended local transforms into scene. Channels bound to destroyed nodes are ignored; nodes with no active channel keep whatever transform they had.

    AnimationPlayer

    pub(all) struct AnimationPlayer {
    clip : AnimationClip
    // private fields
    }

    AnimationPlayer::apply

    fn AnimationPlayer::apply(self : AnimationPlayer, scene : Scene) -> Unit

    Write the sampled local transforms without advancing time.

    AnimationPlayer::duration

    fn AnimationPlayer::duration(self : AnimationPlayer) -> Float

    AnimationPlayer::is_playing

    fn AnimationPlayer::is_playing(self : AnimationPlayer) -> Bool

    AnimationPlayer::new

    AnimationPlayer::pause

    fn AnimationPlayer::pause(self : AnimationPlayer) -> Unit

    AnimationPlayer::play

    fn AnimationPlayer::play(self : AnimationPlayer) -> Unit

    AnimationPlayer::seek

    fn AnimationPlayer::seek(self : AnimationPlayer, t : Float) -> Unit

    AnimationPlayer::set_looping

    fn AnimationPlayer::set_looping(self : AnimationPlayer, looping : Bool) -> Unit

    AnimationPlayer::set_speed

    fn AnimationPlayer::set_speed(self : AnimationPlayer, speed : Float) -> Unit

    AnimationPlayer::time

    fn AnimationPlayer::time(self : AnimationPlayer) -> Float

    AnimationPlayer::update

    fn AnimationPlayer::update(self : AnimationPlayer, scene : Scene, dt : Float) -> Unit

    Advance by dt * speed, wrap (or clamp) to the clip duration and apply.

    Camera

    pub(all) struct Camera {
    projection : Projection
    clip :
    ClipSpace

    }

    Camera::aspect

    fn Camera::aspect(self : Camera) -> Float

    Viewport aspect ratio (width / height); 0 for an orthographic camera.

    Camera::far

    fn Camera::far(self : Camera) -> Float?

    Far plane distance; None for an infinite reversed-Z perspective camera.

    Camera::fov_y

    fn Camera::fov_y(self : Camera) -> Float

    Vertical field of view in radians; 0 for an orthographic camera.

    Camera::is_orthographic

    fn Camera::is_orthographic(self : Camera) -> Bool

    true for an orthographic projection.

    Camera::near

    fn Camera::near(self : Camera) -> Float

    Near plane distance.

    Camera::orthographic

    fn Camera::orthographic(left : Float, right : Float, bottom : Float, top : Float, near? : Float, far? : Float, clip? :
    ClipSpace
    ) -> Camera

    Camera::perspective

    fn Camera::perspective(fov_y_rad : Float, aspect : Float, near? : Float, far? : Float, clip? :
    ClipSpace
    ) -> Camera

    Camera::perspective_deg

    fn Camera::perspective_deg(fov_y_deg : Float, aspect : Float, near? : Float, far? : Float, clip? :
    ClipSpace
    ) -> Camera

    Perspective camera taking the vertical field of view in degrees, which is how three.js PerspectiveCamera authors it. Composition is left unchanged: the value is converted once, at this boundary.

    Camera::projection_matrix

    fn Camera::projection_matrix(self : Camera) ->
    Mat4

    Camera::screen_ray

    fn Camera::screen_ray(self : Camera, world :
    Affine3
    , ndc_x : Float, ndc_y : Float) ->
    Ray
    ?

    Ray through a normalized-device-coordinate point, for picking. Perspective rays start at the eye; orthographic rays start on the near plane along the camera forward axis (-Z).

    Camera::screen_ray_pixels

    fn Camera::screen_ray_pixels(self : Camera, world :
    Affine3
    , x : Float, y : Float, width : Float, height : Float) ->
    Ray
    ?

    Ray through a pixel coordinate, with the conventional top-left window origin that pointer events report (three.js Raycaster.setFromCamera after setFromWindow). width / height are the viewport size in pixels.

    The NDC mapping honours the camera's ClipSpace, so a Vulkan (y-down NDC) camera and a Metal/WebGPU (y-up NDC) camera both put the top-left pixel at the top-left of the image.

    Camera::sky_ray_matrix

    Rotation-only matrix that reconstructs a world-space view direction from an NDC direction (skybox). Built analytically from the FOV instead of inverting mat3(proj), because the infinite reversed-Z projection has a zero m22 and is therefore singular in 3x3. Equivalent to the hand-derived invRotProj in examples/rhi/pbr-showcase; scaled camera nodes are normalized first.

    Camera::view_matrix

    Camera::with_aspect

    fn Camera::with_aspect(self : Camera, aspect : Float) -> Camera

    Convenience for window resize: returns a copy with a new aspect ratio.

    Camera::with_viewport

    fn Camera::with_viewport(self : Camera, width : Float, height : Float) -> Camera

    Resize helper taking the viewport in pixels: aspect is recomputed from width / height; non-positive sizes are ignored.

    CameraId

    pub(all) struct CameraId {
    // private fields
    } derive(Eq,
    Debug
    )

    A camera node handle. Only Scene::add_camera / Scene::camera_of produce one, so the render entry points cannot be handed a mesh or light node.

    CameraId::index

    fn CameraId::index(self : CameraId) -> Int

    CameraId::node

    fn CameraId::node(self : CameraId) -> NodeId

    The underlying scene node, for APIs that still take a NodeId (transforms, parenting, picking).

    Clock

    pub struct Clock {
    // private fields
    }

    Delta-time accumulator fed by a caller-supplied monotonic timestamp in seconds (three.js Clock, minus the global performance.now()).

    The first tick returns 0 (there is no previous sample to subtract), and a delta larger than max_delta — a debugger pause, a backgrounded window, or a stalled frame — is clamped instead of teleporting every animation.

    Clock::delta

    fn Clock::delta(self : Clock) -> Float

    Last returned delta, in seconds.

    Clock::elapsed

    fn Clock::elapsed(self : Clock) -> Float

    Total non-clamped time accumulated so far, in seconds.

    Clock::fps

    fn Clock::fps(self : Clock) -> Float

    Instantaneous frames per second derived from the last delta (0 before the second sample).

    Clock::frames

    fn Clock::frames(self : Clock) -> Int

    Number of tick calls since construction or reset.

    Clock::new

    fn Clock::new(max_delta? : Float) -> Clock

    max_delta is the largest accepted frame step, in seconds.

    Clock::reset

    fn Clock::reset(self : Clock) -> Unit

    Forget the previous sample so the next tick starts at delta 0.

    Clock::tick

    fn Clock::tick(self : Clock, now : Float) -> Float

    Advance the clock to now (monotonic seconds) and return the clamped delta.

    CustomShader

    pub(all) struct CustomShader {
    // private fields
    } derive(Eq,
    Debug
    )

    Renderer-owned custom shader slot. Only Renderer3D::create_custom_shader can produce one, so a material can never reference an unregistered slot.

    CustomShader::id

    fn CustomShader::id(self : CustomShader) -> Int

    DirectionalLight

    pub(all) struct DirectionalLight {
    color :
    Vec3

    intensity : Float
    shadow : ShadowDesc?
    }

    FlyCamera

    pub struct FlyCamera {
    // private fields
    }

    FlyCamera::apply

    fn FlyCamera::apply(self : FlyCamera, ev :
    Event
    ) -> Bool

    Returns true when the event changed the fly state.

    FlyCamera::new

    fn FlyCamera::new(position? :
    Vec3
    , yaw? : Float, pitch? : Float) -> FlyCamera

    FlyCamera::pitch

    fn FlyCamera::pitch(self : FlyCamera) -> Float

    FlyCamera::position

    FlyCamera::rotation

    FlyCamera::transform

    FlyCamera::yaw

    fn FlyCamera::yaw(self : FlyCamera) -> Float

    Fog

    pub(all) enum Fog {
    Linear(
    Vec3
    , Float, Float)
    Exp2(
    Vec3
    , Float)
    }

    Fog model for a scene.

    • Linear(color, near, far) matches three.js Fog: no fog before near, fully fogged past far, linear in between.
    • Exp2(color, density) matches three.js FogExp2: 1 - exp(-(density *distance)^2), which scales more naturally with distance.

    Fog::color

    The fog color (linear RGB).

    GltfInstance

    pub(all) struct GltfInstance {
    roots : Array[NodeId]
    nodes : Array[NodeId?]
    meshes : Array[MeshHandle]
    materials : Array[MaterialHandle]
    animations : Array[AnimationClip]
    }

    Everything a glTF import produced: instantiated nodes (indexed by glTF node index), the uploaded meshes/materials, the scene roots, and the animation clips already bound to the instantiated nodes.

    GpuMesh

    GpuMesh::bounds

    GpuMesh::first_index

    fn GpuMesh::first_index(self : GpuMesh) -> Int

    GpuMesh::first_vertex

    fn GpuMesh::first_vertex(self : GpuMesh) -> Int

    GpuMesh::index_count

    fn GpuMesh::index_count(self : GpuMesh) -> Int

    GpuMesh::mesh

    CPU-side mesh data retained for picking.

    GpuMesh::morph

    fn GpuMesh::morph(self : GpuMesh) -> Int

    Number of GPU morph targets (0 for plain meshes).

    GpuMesh::range

    fn GpuMesh::range(mesh :
    MeshData
    , first_vertex : Int, first_index : Int) -> GpuMesh

    GpuMesh::skinned

    fn GpuMesh::skinned(self : GpuMesh) -> Bool

    GpuMesh::vertex_count

    fn GpuMesh::vertex_count(self : GpuMesh) -> Int

    HdrImage

    pub(all) struct HdrImage {
    width : Int
    height : Int
    rgb : FixedArray[Float]
    }

    Linear RGB image decoded from a Radiance .hdr file.

    HdrImage::new

    fn HdrImage::new(width : Int, height : Int) -> HdrImage

    HdrImage::pixel

    fn HdrImage::pixel(self : HdrImage, x : Int, y : Int) -> (Float, Float, Float)

    HdrImage::set_pixel

    fn HdrImage::set_pixel(self : HdrImage, x : Int, y : Int, r : Float, g : Float, b : Float) -> Unit

    HemisphereLight

    pub(all) struct HemisphereLight {
    sky :
    Vec3

    ground :
    Vec3

    intensity : Float
    }

    Interpolation

    pub(all) enum Interpolation {
    Linear
    Step
    }

    Light

    pub(all) enum Light {
    Directional(DirectionalLight)
    Point(PointLight)
    Spot(SpotLight)
    Ambient(AmbientLight)
    Hemisphere(HemisphereLight)
    }

    Light::ambient

    fn Light::ambient(color :
    Vec3
    , intensity : Float) -> Light

    Light::cast_shadow

    fn Light::cast_shadow(self : Light) -> Bool

    Light::directional

    fn Light::directional(color :
    Vec3
    , intensity : Float, shadow? : ShadowDesc) -> Light

    Light::hemisphere

    fn Light::hemisphere(sky :
    Vec3
    , ground :
    Vec3
    , intensity : Float) -> Light

    Light::point

    fn Light::point(color :
    Vec3
    , intensity : Float, range? : Float, decay? : Float, shadow? : ShadowDesc) -> Light

    Light::spot

    fn Light::spot(color :
    Vec3
    , intensity : Float, range? : Float, inner_angle? : Float, outer_angle? : Float, shadow? : ShadowDesc) -> Light

    LineHandle

    pub(all) struct LineHandle {
    // private fields
    } derive(Eq,
    Debug
    )

    Renderer-owned GPU line list (@tgeo.LineData) kept in local space. It is drawn by a NodePayload::Lines scene node, which supplies the world transform and the LineMaterial colour.

    LineHandle::id

    fn LineHandle::id(self : LineHandle) -> Int

    LineInstance

    pub(all) struct LineInstance {
    lines : LineHandle
    material : LineMaterial
    }

    A line node's drawable pair: GPU line list plus its colour.

    LineInstance::new

    fn LineInstance::new(lines : LineHandle, material : LineMaterial) -> LineInstance

    LineMaterial

    pub(all) struct LineMaterial {
    color :
    Vec3

    }

    Material for line nodes: colour only. Line vertices carry no normals or UVs, so lighting/texturing do not apply.

    LineMaterial::new

    LodHandle

    pub(all) struct LodHandle {
    // private fields
    } derive(Eq,
    Debug
    )

    Renderer-owned distance-LOD spec: a level chain plus the world distances where the next level takes over. One spec is shared by any number of nodes (Renderer3D::create_lod_instance), so 10k instances of the same LOD chain cost one allocation instead of one per node (three.js BatchedMesh LOD).

    LodHandle::id

    fn LodHandle::id(self : LodHandle) -> Int

    LoopMode

    pub(all) enum LoopMode {
    Repeat
    Once
    PingPong
    }

    Playback loop behaviour of one action (three.js LoopOnce / LoopRepeat / LoopPingPong).

    MaterialDesc

    pub(all) struct MaterialDesc {
    shading : Shading
    base_color :
    Vec4

    metallic : Float
    roughness : Float
    clearcoat : Float
    clearcoat_roughness : Float
    emissive :
    Vec3

    sheen_color :
    Vec3

    sheen_roughness : Float
    transmission : Float
    ior : Float
    iridescence : Float
    iridescence_ior : Float
    iridescence_thickness : Float
    alpha_mode : AlphaMode
    double_sided : Bool
    albedo_tex : TextureHandle?
    normal_tex : TextureHandle?
    metallic_roughness_tex : TextureHandle?
    emissive_tex : TextureHandle?
    }

    MaterialDesc::basic

    three.js-style name for unlit: MeshBasicMaterial — a solid color with no lighting, IBL or shadow response.

    MaterialDesc::custom

    fn MaterialDesc::custom(shader : CustomShader) -> MaterialDesc

    A material shaded by a user-registered custom shader pipeline (Renderer3D::create_custom_shader), the equivalent of three.js ShaderMaterial / NodeMaterial. The PBR fields are ignored; the shader reads its parameters from the per-shader uniform block uploaded with Renderer3D::set_custom_uniforms. Blending and depth-write are fixed when the shader is registered, not by alpha_mode.

    MaterialDesc::pbr

    fn MaterialDesc::pbr(base_color :
    Vec4
    , metallic? : Float, roughness? : Float) -> MaterialDesc

    MaterialDesc::standard

    fn MaterialDesc::standard(base_color :
    Vec4
    , metallic? : Float, roughness? : Float) -> MaterialDesc

    three.js-style name for pbr: MeshStandardMaterial. standard(hex(0xFF8800), roughness=0.4) reads like the three.js original.

    MaterialDesc::unlit

    MaterialDesc::with_albedo_tex

    fn MaterialDesc::with_albedo_tex(self : MaterialDesc, tex : TextureHandle) -> MaterialDesc

    MaterialDesc::with_alpha

    fn MaterialDesc::with_alpha(self : MaterialDesc, mode : AlphaMode) -> MaterialDesc

    MaterialDesc::with_base_color

    Replace the linear base color, keeping the rest of the material.

    MaterialDesc::with_clearcoat

    fn MaterialDesc::with_clearcoat(self : MaterialDesc, clearcoat : Float, roughness? : Float) -> MaterialDesc

    Physical clearcoat layer (0 disables it).

    MaterialDesc::with_double_sided

    fn MaterialDesc::with_double_sided(self : MaterialDesc, double_sided : Bool) -> MaterialDesc

    MaterialDesc::with_emissive

    MaterialDesc::with_iridescence

    fn MaterialDesc::with_iridescence(self : MaterialDesc, amount : Float, ior? : Float, thickness_nm? : Float) -> MaterialDesc

    Thin-film iridescence (three.js iridescence / iridescenceIOR / iridescenceThicknessRange, glTF KHR_materials_iridescence).

    The fragment shader evaluates two-beam interference for the R/G/B wavelengths of a film thickness_nm thick with index ior, and blends the resulting view-dependent reflectance into the base specular F0. Typical values: with_iridescence(1.0, thickness_nm=350) gives a soap-bubble / beetle-shell shift; amount = 0 disables it.

    MaterialDesc::with_metallic

    fn MaterialDesc::with_metallic(self : MaterialDesc, metallic : Float) -> MaterialDesc

    Replace the metallic factor (0..1).

    MaterialDesc::with_metallic_roughness_tex

    fn MaterialDesc::with_metallic_roughness_tex(self : MaterialDesc, tex : TextureHandle) -> MaterialDesc

    Metallic-roughness map (glTF metallicRoughnessTexture, three.js metalnessMap + roughnessMap packed in one image): G scales roughness and B scales metallic, sampled in linear space. The packed texture path needs the bindless heap; the non-bindless fallback keeps the scalar factors.

    MaterialDesc::with_normal_tex

    fn MaterialDesc::with_normal_tex(self : MaterialDesc, tex : TextureHandle) -> MaterialDesc

    MaterialDesc::with_roughness

    fn MaterialDesc::with_roughness(self : MaterialDesc, roughness : Float) -> MaterialDesc

    Replace the roughness factor (0..1).

    MaterialDesc::with_sheen

    fn MaterialDesc::with_sheen(self : MaterialDesc, color :
    Vec3
    , roughness? : Float) -> MaterialDesc

    Physical sheen lobe (three.js sheenColor / sheenRoughness, glTF KHR_materials_sheen). Use a light colour such as srgb(1, 1, 1).truncate() for fabric-like grazing highlights; a zero colour disables the lobe.

    MaterialDesc::with_transmission

    fn MaterialDesc::with_transmission(self : MaterialDesc, amount : Float, ior? : Float) -> MaterialDesc

    Screen-space transmission (three.js transmission / ior, glTF KHR_materials_transmission / KHR_materials_ior).

    amount is the fraction of the surface that shows the scene behind it (0 = opaque, 1 = fully transmissive) and ior bends that view. The renderer draws transmissive static meshes in a second pass against a copy of the opaque color, so the background is genuinely refracted instead of merely alpha-blended. Skinned and morph meshes ignore transmission for now.

    MaterialHandle

    pub(all) struct MaterialHandle {
    // private fields
    } derive(Eq,
    Debug
    )

    Renderer-owned material slot.

    MaterialHandle::id

    fn MaterialHandle::id(self : MaterialHandle) -> Int

    MeshBvh

    pub struct MeshBvh {
    // private fields
    }

    CPU-side BVH over one mesh's triangles, in mesh-local space.

    Build once per mesh (Renderer3D::pick caches one per uploaded mesh) and reuse for any number of rays. The source mesh is kept by reference, so the BVH stays valid as long as the MeshData is not mutated.

    MeshBvh::bounds

    Tight local-space bounds of every indexed triangle.

    MeshBvh::build

    Build a BVH for mesh. Cost is O(n log n) in triangles and memory is roughly 32 bytes * 2 * leaves; an empty mesh still returns a valid, always-missing BVH.

    MeshBvh::mesh

    The source mesh this hierarchy indexes.

    MeshBvh::node_count

    fn MeshBvh::node_count(self : MeshBvh) -> Int

    Number of BVH nodes (interior + leaves); useful for memory sanity checks.

    MeshBvh::ray_hit

    Nearest triangle hit under a world-space ray, matching ray_mesh_hit.

    The returned distance is the world-space distance along a normalized ray, triangle is the mesh triangle index and normal is the world-space face normal from the normal matrix.

    MeshBvh::triangle_count

    fn MeshBvh::triangle_count(self : MeshBvh) -> Int

    Number of triangles covered.

    MeshHandle

    pub(all) struct MeshHandle {
    // private fields
    } derive(Eq,
    Debug
    )

    Renderer-owned GPU mesh. The scene only carries the handle.

    MeshHandle::id

    fn MeshHandle::id(self : MeshHandle) -> Int

    MeshHit

    pub(all) struct MeshHit {
    triangle : Int
    distance : Float
    position :
    Vec3

    normal :
    Vec3

    }

    MeshInstance

    pub(all) struct MeshInstance {
    mesh : MeshHandle
    material : MaterialHandle
    cast_shadow : Bool
    receive_shadow : Bool
    tint :
    Vec4

    lod : LodHandle?
    }

    A mesh node's drawable pair. The renderer resolves both handles to GPU state; MeshInstance itself stays a small value struct.

    tint is a per-instance multiplier on the material base colour (linear RGBA), which is how one shared material paints thousands of differently coloured instances (three.js InstancedMesh.setColorAt). lod, when set, swaps mesh for the level LodHandle selects at the camera distance.

    MeshInstance::new

    fn MeshInstance::new(mesh : MeshHandle, material : MaterialHandle) -> MeshInstance

    MeshInstance::tint

    MeshInstance::with_lod

    fn MeshInstance::with_lod(self : MeshInstance, lod : LodHandle) -> MeshInstance

    Same instance driven by a shared distance-LOD spec.

    MeshInstance::with_tint

    Same instance with a per-instance colour multiplier (linear RGBA).

    NodeId

    pub(all) struct NodeId {
    // private fields
    } derive(Eq,
    Debug
    )

    Generation-checked arena index. Destroying a node bumps its generation, so stale handles can never alias a reused slot.

    NodeId::index

    fn NodeId::index(self : NodeId) -> Int

    NodePayload

    pub(all) enum NodePayload {
    Empty
    Mesh(MeshInstance)
    Lines(LineInstance)
    Light(Light)
    Camera(Camera)
    }

    OrbitCamera

    pub struct OrbitCamera {
    // private fields
    }

    OrbitCamera::apply

    Returns true when the event changed the orbit state.

    OrbitCamera::distance

    fn OrbitCamera::distance(self : OrbitCamera) -> Float

    OrbitCamera::new

    fn OrbitCamera::new(target? :
    Vec3
    , distance? : Float, yaw? : Float, pitch? : Float) -> OrbitCamera

    OrbitCamera::pitch

    fn OrbitCamera::pitch(self : OrbitCamera) -> Float

    OrbitCamera::position

    OrbitCamera::set_distance

    fn OrbitCamera::set_distance(self : OrbitCamera, distance : Float) -> Unit

    OrbitCamera::set_pitch

    fn OrbitCamera::set_pitch(self : OrbitCamera, pitch : Float) -> Unit

    OrbitCamera::set_target

    fn OrbitCamera::set_target(self : OrbitCamera, target :
    Vec3
    ) -> Unit

    OrbitCamera::set_yaw

    fn OrbitCamera::set_yaw(self : OrbitCamera, yaw : Float) -> Unit

    OrbitCamera::target

    OrbitCamera::transform

    OrbitCamera::yaw

    fn OrbitCamera::yaw(self : OrbitCamera) -> Float

    OrthoParams

    pub(all) struct OrthoParams {
    left : Float
    right : Float
    bottom : Float
    top : Float
    near : Float
    far : Float
    }

    PerspectiveParams

    pub(all) struct PerspectiveParams {
    fov_y_rad : Float
    aspect : Float
    near : Float
    far : Float?
    }

    PickHit

    pub(all) struct PickHit {
    node : NodeId
    distance : Float
    position :
    Vec3

    normal :
    Vec3

    triangle : Int
    }

    PointLight

    pub(all) struct PointLight {
    color :
    Vec3

    intensity : Float
    range : Float
    decay : Float
    shadow : ShadowDesc?
    }

    Projection

    pub(all) enum Projection {
    Perspective(PerspectiveParams)
    Orthographic(OrthoParams)
    }

    QuatTrack

    pub(all) struct QuatTrack {
    times : Array[Float]
    values : Array[
    Quat
    ]
    interpolation : Interpolation
    }

    QuatTrack::duration

    fn QuatTrack::duration(self : QuatTrack) -> Float

    QuatTrack::new

    fn QuatTrack::new(times : Array[Float], values : Array[
    Quat
    ], interpolation? : Interpolation) -> QuatTrack

    QuatTrack::sample

    fn QuatTrack::sample(self : QuatTrack, t : Float) ->
    Quat

    RenderStats3D

    pub(all) struct RenderStats3D {
    draw_calls : Int
    triangles : Int
    visible_nodes : Int
    culled_nodes : Int
    shadow_passes : Int
    upload_bytes : Int
    instance_batches : Int
    line_segments : Int
    lod_switches : Int
    }

    RenderStats3D::new

    RenderStats3D::summary

    fn RenderStats3D::summary(self : RenderStats3D) -> String

    RenderStats3D::to_json

    fn RenderStats3D::to_json(self : RenderStats3D) -> String

    Renderer3D

    pub struct Renderer3D {
    // private fields
    }

    Renderer3D::add

    fn Renderer3D::add(self : Renderer3D, scene : Scene, geometry :
    MeshData
    , material : MaterialDesc, transform? :
    Transform
    , parent? : NodeId, name? : String) -> NodeId raise

    Upload a geometry, allocate a material and attach the resulting mesh node in one call — the closest equivalent of three.js scene.add(new Mesh(...)).

    let ball = renderer.add(scene, @tgeo.sphere(radius=0.5),
    @t3d.MaterialDesc::standard(@t3d.hex(0x2E7DFF), roughness=0.35))
    scene.set_position(ball, 0.0, 1.0, 0.0)

    Each call uploads a fresh geometry copy. When many nodes share one mesh, call upload_mesh / create_material once and use create_mesh_node.

    Renderer3D::add_axes

    fn Renderer3D::add_axes(self : Renderer3D, scene : Scene, size? : Float, parent? : NodeId) -> (NodeId, NodeId, NodeId) raise

    Attach a red/green/blue axis triad at the origin (three.js AxesHelper). One line list is uploaded and shared by three nodes rotated into place; returns the X, Y and Z axis nodes.

    Renderer3D::add_debug_aabb

    Queue the 12 edges of a world-space AABB.

    Renderer3D::add_debug_line

    Queue a world-space debug line for the next render call. Lines are depth-tested against the scene and cleared after each frame.

    Renderer3D::add_grid

    fn Renderer3D::add_grid(self : Renderer3D, scene : Scene, size? : Float, divisions? : Int, color? :
    Vec4
    , parent? : NodeId, name? : String) -> NodeId raise

    Upload grid_line_data and attach it as a line node (three.js GridHelper). Returns the scene node.

    Renderer3D::add_lines

    fn Renderer3D::add_lines(self : Renderer3D, scene : Scene, lines :
    LineData
    , color? :
    Vec4
    , transform? :
    Transform
    , parent? : NodeId, name? : String) -> NodeId raise

    Upload a line list and attach it in one call.

    Renderer3D::background

    The flat background override, when one is set.

    Renderer3D::brdf_lut

    The baked split-sum BRDF LUT (RG16F), exposed for diagnostics and tests.

    Renderer3D::clear_background

    fn Renderer3D::clear_background(self : Renderer3D) -> Unit

    Restore the environment sky as the background.

    Renderer3D::clear_debug_lines

    fn Renderer3D::clear_debug_lines(self : Renderer3D) -> Unit

    Renderer3D::clear_fog

    fn Renderer3D::clear_fog(self : Renderer3D) -> Unit

    Disable fog.

    Renderer3D::create_custom_shader

    fn Renderer3D::create_custom_shader(self : Renderer3D, vert : FixedArray[UInt], frag : FixedArray[UInt], uniform_floats : Int, texture_slots? : Int, blend? : Bool, depth_write? : Bool, cull_mode? :
    CullMode
    , depth_test? : Bool) -> CustomShader raise

    Register a custom shader pipeline drawn inside the main HDR pass.

    uniform_floats is the size of the user uniform block in floats (std140 layout is the caller's responsibility; the block is padded to a vec4 multiple). texture_slots reserves bindings 3 .. 3 + texture_slots - 1. blend selects standard alpha blending (water, decals); depth_write defaults to true for opaque custom surfaces. The pipeline matches the renderer's MSAA sample count and the reversed-Z HDR pass format.

    Renderer3D::create_line_node

    fn Renderer3D::create_line_node(self : Renderer3D, scene : Scene, lines : LineHandle, material? : LineMaterial, transform? :
    Transform
    , name? : String, parent? : NodeId) -> NodeId

    Create a scene node that draws an uploaded line list.

    The node's world transform is applied to the (local-space) vertices and material.color tints them. Lines are depth-tested overlays: they do not cast shadows, are not ray-traceable, and have no normals/UVs.

    Renderer3D::create_lod_instance

    fn Renderer3D::create_lod_instance(self : Renderer3D, scene : Scene, spec : LodHandle, material : MaterialHandle, transform? :
    Transform
    , name? : String, parent? : NodeId) -> NodeId raise

    Create a mesh node driven by a shared LOD spec. Instances of the same spec still collapse into one instanced draw per level, so a field of 10k LOD nodes costs one draw per (level, material) pair.

    Renderer3D::create_lod_node

    fn Renderer3D::create_lod_node(self : Renderer3D, scene : Scene, levels : Array[MeshHandle], switch_distances : Array[Float], material : MaterialHandle, transform? :
    Transform
    , name? : String, parent? : NodeId) -> NodeId raise

    Create a node with distance-based mesh LOD. levels runs from highest to lowest detail and switch_distances (length levels.length() - 1) holds the strictly increasing world-space distances where the next level takes over.

    Renderer3D::create_lod_spec

    fn Renderer3D::create_lod_spec(self : Renderer3D, levels : Array[MeshHandle], switch_distances : Array[Float]) -> LodHandle raise

    Register a distance-LOD chain once and reuse it for any number of nodes. levels runs from highest to lowest detail; switch_distances (length levels.length() - 1) holds the strictly increasing camera distances where the next level takes over.

    Renderer3D::create_material

    fn Renderer3D::create_material(self : Renderer3D, m : MaterialDesc) -> MaterialHandle raise

    Renderer3D::create_mesh_node

    fn Renderer3D::create_mesh_node(self : Renderer3D, scene : Scene, mesh : MeshHandle, material : MaterialHandle, transform? :
    Transform
    , name? : String, parent? : NodeId) -> NodeId

    Create a mesh node and register its local bounds in one call.

    Renderer3D::create_morph_mesh_node

    fn Renderer3D::create_morph_mesh_node(self : Renderer3D, scene : Scene, mesh : MeshHandle, material : MaterialHandle, weights : Array[Float], transform? :
    Transform
    , name? : String, parent? : NodeId) -> NodeId raise

    Create a morph-animated mesh node from an existing material handle.

    Renderer3D::create_morph_node

    fn Renderer3D::create_morph_node(self : Renderer3D, scene : Scene, mesh : MeshHandle, desc : MaterialDesc, weights : Array[Float], transform? :
    Transform
    , name? : String, parent? : NodeId) -> NodeId raise

    Create a morph-animated mesh node (opaque materials only). The material is allocated from desc; use create_morph_mesh_node to reuse one.

    Renderer3D::create_pbr_node

    fn Renderer3D::create_pbr_node(self : Renderer3D, scene : Scene, mesh : MeshHandle, desc : MaterialDesc, transform? :
    Transform
    , name? : String, parent? : NodeId) -> NodeId raise

    Create a material from desc and attach a mesh node using it.

    Renderer3D::create_skinned_mesh_node

    fn Renderer3D::create_skinned_mesh_node(self : Renderer3D, scene : Scene, mesh : MeshHandle, material : MaterialHandle, joints : Array[NodeId], inverse_bind : Array[
    Mat4
    ], transform? :
    Transform
    , name? : String, parent? : NodeId) -> NodeId raise

    Create a mesh node driven by a skeleton, reusing an existing material handle. joints are scene nodes and inverse_bind their rest-pose inverse world matrices (mesh-local space).

    Renderer3D::create_skinned_node

    fn Renderer3D::create_skinned_node(self : Renderer3D, scene : Scene, mesh : MeshHandle, desc : MaterialDesc, joints : Array[NodeId], inverse_bind : Array[
    Mat4
    ], transform? :
    Transform
    , name? : String, parent? : NodeId) -> NodeId raise

    Create a mesh node driven by a skeleton. The material is allocated from desc; use create_skinned_mesh_node to reuse one.

    Renderer3D::create_texture

    fn Renderer3D::create_texture(self : Renderer3D, width : Int, height : Int, rgba8 : FixedArray[Byte], srgb? : Bool) -> TextureHandle raise

    Upload an RGBA8 texture. srgb selects RGBA8Srgb (albedo/emissive) versus linear RGBA8 (normal/metallic-roughness maps).

    Renderer3D::custom_shader_count

    fn Renderer3D::custom_shader_count(self : Renderer3D) -> Int

    Number of registered custom shaders (verification helper).

    Renderer3D::destroy

    fn Renderer3D::destroy(self : Renderer3D) -> Unit

    Renderer3D::fog

    fn Renderer3D::fog(self : Renderer3D) -> Fog?

    The active fog model, when one is set.

    Renderer3D::lines_bounds

    Bounds of an uploaded line list, or None for a stale handle.

    Renderer3D::material

    fn Renderer3D::material(self : Renderer3D, handle : MaterialHandle) -> MaterialDesc?

    The material description behind a handle, for editors and debug UIs.

    Renderer3D::material_count

    fn Renderer3D::material_count(self : Renderer3D) -> Int

    Number of materials allocated so far.

    Renderer3D::mesh_bounds

    Renderer3D::mesh_count

    fn Renderer3D::mesh_count(self : Renderer3D) -> Int

    Number of uploaded meshes.

    Renderer3D::new

    Renderer3D::pick

    fn Renderer3D::pick(self : Renderer3D, scene : Scene, camera : NodeId, ndc_x : Float, ndc_y : Float, layer_mask? : UInt) -> PickHit?

    Nearest mesh or line node under an NDC point. Uses the frustum-culled drawable list, so nodes behind the camera or past the far plane are not pickable.

    Renderer3D::pick_pixels

    fn Renderer3D::pick_pixels(self : Renderer3D, scene : Scene, camera : CameraId, x : Float, y : Float, width : Float, height : Float, layer_mask? : UInt) -> PickHit?

    Nearest mesh or line node under a pixel coordinate with a top-left origin, matching pointer-event coordinates (three.js Raycaster usage). width / height are the viewport size the event was measured in.

    Both NDC conventions are handled: a Vulkan camera (y-down NDC) and a Metal/WebGPU camera (y-up NDC) put the top-left pixel at the top-left of the image.

    Renderer3D::ray_shadows_supported

    fn Renderer3D::ray_shadows_supported(self : Renderer3D) -> Bool

    Renderer3D::release_node

    fn Renderer3D::release_node(self : Renderer3D, node : NodeId) -> Unit

    Drop the renderer-side bindings a node owns: its LOD group, its skin palette entry and its morph weights. The scene node itself is untouched, so call this before or after Scene::destroy_node to release per-node state deterministically instead of waiting for the next frame's lazy prune.

    GPU meshes, materials and textures are arena-owned and are released by Renderer3D::destroy — a destroyed node never frees a mesh other nodes may still share.

    Renderer3D::render_offscreen

    fn Renderer3D::render_offscreen(self : Renderer3D, target :
    Texture
    , scene : Scene, camera : CameraId) -> Unit raise

    Renderer3D::render_swapchain

    fn Renderer3D::render_swapchain(self : Renderer3D, sc :
    Swapchain
    , scene : Scene, camera : CameraId) -> Unit raise

    Renderer3D::render_swapchain_into

    fn Renderer3D::render_swapchain_into(self : Renderer3D, cmd :
    CommandBuffer
    , sc :
    Swapchain
    , scene : Scene, camera : CameraId) -> Unit raise

    Render into the already-acquired swapchain image without ending the frame, so an overlay (e.g. Renderer2D::render_swapchain_pass) can draw on top before the caller presents with Swapchain::end_frame.

    Renderer3D::reset_taa

    fn Renderer3D::reset_taa(self : Renderer3D) -> Unit

    Drop the TAA history. Call after a camera cut or a teleport so the old frame cannot bleed into the new view.

    Renderer3D::set_background

    fn Renderer3D::set_background(self : Renderer3D, color :
    Vec4
    ) -> Unit

    Draw a flat linear background instead of the environment sky (three.js scene.background = new Color(...)).

    The environment cubemap stays bound for image-based lighting, so the material response is unchanged; only the pixels that no geometry covers are affected. The clear value goes through the same HDR → bloom → ACES chain, so author it with hex(...) / linear(...) like any other color.

    Renderer3D::set_custom_texture

    fn Renderer3D::set_custom_texture(self : Renderer3D, shader : CustomShader, slot : Int, texture :
    Texture
    ?, sampler? :
    Sampler
    ) -> Unit raise

    Bind a sampled texture into custom-shader slot slot (fragment binding 3 + slot). Passing None clears the slot. The default sampler is linear clamp-to-edge; supply a custom sampler for repeat / nearest filtering.

    Renderer3D::set_custom_uniforms

    fn Renderer3D::set_custom_uniforms(self : Renderer3D, shader : CustomShader, floats : FixedArray[Float]) -> Unit raise

    Stage the user uniform block for a custom shader. The floats are uploaded to the current frame slot at draw time; the layout must be std140. Extra floats beyond the registered size are ignored.

    Renderer3D::set_environment

    fn Renderer3D::set_environment(self : Renderer3D, cube :
    Texture
    , sun_dir :
    Vec3
    , intensity? : Float) -> Unit

    Renderer3D::set_fog

    fn Renderer3D::set_fog(self : Renderer3D, fog : Fog) -> Unit

    Enable linear or exp2 distance fog (three.js scene.fog).

    Fog is mixed in linear space before tone mapping and applies to lit and unlit materials alike; the sky/background layer is left untouched, matching three.js. Switching fog needs no pipeline change — the parameters ride in the frame UBO.

    Renderer3D::set_morph_weights

    fn Renderer3D::set_morph_weights(self : Renderer3D, node : NodeId, weights : Array[Float]) -> Unit raise

    Set the two GPU morph weights for a node. The mesh must carry morph targets (see MeshData::add_morph_target); at most two are evaluated.

    Renderer3D::set_procedural_environment

    fn Renderer3D::set_procedural_environment(self : Renderer3D, sun_dir :
    Vec3
    , size? : Int, samples? : Int) -> Unit raise

    Build and own a procedural PMREM environment for sun_dir.

    Renderer3D::set_ray_shadows

    fn Renderer3D::set_ray_shadows(self : Renderer3D, enabled : Bool) -> Unit

    Toggle hardware ray-traced sun shadows (no effect when unsupported).

    Renderer3D::set_ssao_bias

    fn Renderer3D::set_ssao_bias(self : Renderer3D, bias : Float) -> Unit

    Depth bias that keeps self-occlusion from darkening flat surfaces.

    Renderer3D::set_ssao_intensity

    fn Renderer3D::set_ssao_intensity(self : Renderer3D, intensity : Float) -> Unit

    SSAO strength in [0, 2]; 0 renders without occlusion (useful for toggling the effect at runtime).

    Renderer3D::set_ssao_radius

    fn Renderer3D::set_ssao_radius(self : Renderer3D, radius : Float) -> Unit

    World-space sampling radius of the SSAO hemisphere (default 0.6).

    Renderer3D::set_taa_history_weight

    fn Renderer3D::set_taa_history_weight(self : Renderer3D, weight : Float) -> Unit

    History blend weight in [0, 1] (default 0.9). Higher values smooth more but ghost more; 0 effectively disables accumulation.

    Renderer3D::ssao_enabled

    fn Renderer3D::ssao_enabled(self : Renderer3D) -> Bool

    true when the renderer was created with RendererDesc::with_ssao(true).

    Renderer3D::ssao_intensity

    fn Renderer3D::ssao_intensity(self : Renderer3D) -> Float

    Renderer3D::stats

    fn Renderer3D::stats(self : Renderer3D) -> RenderStats3D

    Renderer3D::taa_enabled

    fn Renderer3D::taa_enabled(self : Renderer3D) -> Bool

    true when the renderer was created with RendererDesc::with_taa(true).

    Renderer3D::taa_frame_number

    fn Renderer3D::taa_frame_number(self : Renderer3D) -> Int

    Number of TAA frames accumulated since the last reset.

    Renderer3D::taa_history_valid

    fn Renderer3D::taa_history_valid(self : Renderer3D) -> Bool

    true once a history frame exists.

    Renderer3D::taa_history_weight

    fn Renderer3D::taa_history_weight(self : Renderer3D) -> Float

    Renderer3D::texture_count

    fn Renderer3D::texture_count(self : Renderer3D) -> Int

    Number of uploaded textures.

    Renderer3D::update_material

    fn Renderer3D::update_material(self : Renderer3D, h : MaterialHandle, m : MaterialDesc) -> Unit raise

    Renderer3D::upload_lines

    Upload a @tgeo.LineData line list as a local-space drawable.

    The list is drawn by NodePayload::Lines scene nodes, which supply the world transform and the colour tint through push constants. Vertices bake white, so the node's LineMaterial fully controls the colour.

    Renderer3D::upload_mesh

    RendererDesc

    pub(all) struct RendererDesc {
    max_objects : Int
    max_lights : Int
    max_materials : Int
    max_textures : Int
    msaa : Bool
    shadow_cascades : Int
    gpu_culling : Bool
    bindless : Bool
    bloom : Bool
    shadows : Bool
    shadow_map_size : Int
    ssao : Bool
    taa : Bool
    }

    RendererDesc::default

    fn RendererDesc::default() -> RendererDesc

    RendererDesc::with_bindless

    fn RendererDesc::with_bindless(self : RendererDesc, on : Bool) -> RendererDesc

    RendererDesc::with_max_objects

    fn RendererDesc::with_max_objects(self : RendererDesc, max_objects : Int) -> RendererDesc

    Capacity of the per-frame object SSBO. One record exists per drawn instance (plus one shadow copy per caster), so a large instanced field raises this before it raises the scene's node count.

    RendererDesc::with_msaa

    fn RendererDesc::with_msaa(self : RendererDesc, on : Bool) -> RendererDesc

    RendererDesc::with_shadows

    fn RendererDesc::with_shadows(self : RendererDesc, on : Bool) -> RendererDesc

    RendererDesc::with_ssao

    fn RendererDesc::with_ssao(self : RendererDesc, on : Bool) -> RendererDesc

    Enable screen-space ambient occlusion. SSAO reconstructs positions from the depth buffer, which a multisampled depth attachment cannot provide, so turning it on also turns MSAA off (they are mutually exclusive).

    RendererDesc::with_taa

    fn RendererDesc::with_taa(self : RendererDesc, on : Bool) -> RendererDesc

    Enable temporal anti-aliasing. TAA jitters the projection every frame and resolves against a reprojected history buffer; it composes with MSAA but is cheapest with it off.

    Scene

    pub struct Scene {
    // private fields
    }

    Scene::add_ambient_light

    fn Scene::add_ambient_light(self : Scene, color? :
    Vec3
    , intensity? : Float, parent? : NodeId, name? : String) -> NodeId

    Add a uniform ambient term.

    Scene::add_camera

    fn Scene::add_camera(self : Scene, camera : Camera, transform? :
    Transform
    , name? : String) -> CameraId

    Create a camera node and return its typed handle.

    Scene::add_directional_light

    fn Scene::add_directional_light(self : Scene, color? :
    Vec3
    , intensity? : Float, direction? :
    Vec3
    , shadow? : Bool, parent? : NodeId, name? : String) -> NodeId

    Add a directional (sun) light whose -Z axis points along direction. shadow opts into the shadow atlas; the default enables it.

    Scene::add_group

    fn Scene::add_group(self : Scene, parent? : NodeId, transform? :
    Transform
    , name? : String) -> NodeId

    Create an empty transform node (three.js Group). Useful as a pivot or as the parent of a subtree that moves together.

    Scene::add_hemisphere_light

    fn Scene::add_hemisphere_light(self : Scene, sky :
    Vec3
    , ground :
    Vec3
    , intensity? : Float, parent? : NodeId, name? : String) -> NodeId

    Add a sky/ground hemisphere term.

    Scene::add_light

    fn Scene::add_light(self : Scene, light : Light, transform? :
    Transform
    , parent? : NodeId, name? : String) -> NodeId

    Create a light node from any Light value.

    Scene::add_point_light

    fn Scene::add_point_light(self : Scene, color? :
    Vec3
    , intensity? : Float, range? : Float, decay? : Float, shadow? : Bool, position? :
    Vec3
    , parent? : NodeId, name? : String) -> NodeId

    Add a point light at position (local to parent).

    Scene::add_spot_light

    fn Scene::add_spot_light(self : Scene, color? :
    Vec3
    , intensity? : Float, range? : Float, inner_angle? : Float, outer_angle? : Float, shadow? : Bool, position? :
    Vec3
    , direction? :
    Vec3
    , parent? : NodeId, name? : String) -> NodeId

    Add a spot light at position aimed along direction (its -Z axis).

    Scene::alive_count

    fn Scene::alive_count(self : Scene) -> Int

    Scene::camera

    fn Scene::camera(self : Scene, handle : CameraId) -> Camera?

    The camera component behind a typed handle.

    Scene::camera_component

    fn Scene::camera_component(self : Scene, id : NodeId) -> Camera?

    The camera component of a node, when it has one.

    Scene::camera_of

    fn Scene::camera_of(self : Scene, node : NodeId) -> CameraId?

    The typed camera handle for node, or None when the node is not a camera.

    Scene::child_count

    fn Scene::child_count(self : Scene, id : NodeId) -> Int

    Number of direct children.

    Scene::children_of

    fn Scene::children_of(self : Scene, id : NodeId) -> Array[NodeId]

    Scene::clear

    fn Scene::clear(self : Scene) -> Unit

    Destroy every node in the scene, parents before children. Renderer-owned GPU resources are not affected.

    Scene::collect_visible

    fn Scene::collect_visible(self : Scene, frustum :
    Frustum
    , camera_mask : UInt) -> Array[NodeId]

    Mesh nodes that pass the layer mask and frustum test. Call update() first so world matrices are current. Nodes without local bounds are kept.

    Visibility is inherited: hiding a group removes its whole subtree, exactly like three.js Object3D.visible = false.

    Scene::create_node

    fn Scene::create_node(self : Scene, parent? : NodeId, transform? :
    Transform
    , payload? : NodePayload, name? : String, layer_mask? : UInt) -> NodeId

    Create a node (optionally parented) and return its handle.

    Scene::destroy_node

    fn Scene::destroy_node(self : Scene, id : NodeId) -> Unit

    Destroy a node and its subtree. Handles become invalid immediately.

    Scene::direction_to_world

    Transform a direction (no translation) from local to world space, including the node's scale.

    Scene::find_all_by_name

    fn Scene::find_all_by_name(self : Scene, name : String) -> Array[NodeId]

    Every live node carrying name, in arena order.

    Scene::find_by_name

    fn Scene::find_by_name(self : Scene, name : String) -> NodeId?

    Scene::instance_lod

    fn Scene::instance_lod(self : Scene, id : NodeId) -> LodHandle?

    The distance-LOD spec bound to a mesh node, if any.

    Scene::instance_tint

    fn Scene::instance_tint(self : Scene, id : NodeId) ->
    Vec4
    ?

    The mesh node's per-instance tint, or None when id is not a mesh node.

    Scene::is_alive

    fn Scene::is_alive(self : Scene, id : NodeId) -> Bool

    Scene::is_visible_in_world

    fn Scene::is_visible_in_world(self : Scene, id : NodeId) -> Bool

    Effective visibility: false when the node or any ancestor is hidden.

    three.js hides a whole subtree by setting group.visible = false; the renderer, picker and light collection all consult this function so the same behaviour holds here.

    Scene::layer_mask

    fn Scene::layer_mask(self : Scene, id : NodeId) -> UInt

    Layer mask used by frustum collection and picking.

    Scene::light_of

    fn Scene::light_of(self : Scene, id : NodeId) -> Light?

    The light component of a node, when it has one.

    Scene::lines_of

    fn Scene::lines_of(self : Scene, id : NodeId) -> LineInstance?

    The line drawable of a node, when it has one.

    Scene::local_to_world

    Transform a point from the node's local space to world space. Calls update() so the result is current even right after a transform write.

    Scene::look_at

    fn Scene::look_at(self : Scene, id : NodeId, target :
    Vec3
    , up? :
    Vec3
    ) -> Unit

    Orient the node so its local -Z axis points at target and its local +Y axis follows up (three.js Object3D.lookAt).

    The node's world position is used, and the parent's world rotation is divided out so the result is correct under transformed parents. A node at target keeps its current rotation instead of producing NaNs.

    Scene::mesh_of

    fn Scene::mesh_of(self : Scene, id : NodeId) -> MeshInstance?

    The mesh drawable of a node, when it has one.

    Scene::name

    fn Scene::name(self : Scene, id : NodeId) -> String

    Node name (empty string when unnamed or dead).

    Scene::new

    fn Scene::new() -> Scene

    Scene::parent_of

    fn Scene::parent_of(self : Scene, id : NodeId) -> NodeId?

    Scene::payload

    fn Scene::payload(self : Scene, id : NodeId) -> NodePayload?

    Scene::position

    fn Scene::position(self : Scene, id : NodeId) ->
    Vec3

    Local translation of a node.

    Scene::remove

    fn Scene::remove(self : Scene, id : NodeId) -> Unit

    Detach a node from its parent and keep it alive as a scene root (three.js Object3D.remove). The subtree, payload and GPU resources are untouched; use destroy_node to release the subtree.

    Scene::roots

    fn Scene::roots(self : Scene) -> Array[NodeId]

    Snapshot of the current root nodes (roots change as nodes are reparented).

    Scene::rotate

    fn Scene::rotate(self : Scene, id : NodeId, axis :
    Vec3
    , angle : Float) -> Unit

    Rotate around a local-space axis by angle radians (three.js Object3D.rotateOnAxis).

    Scene::rotate_world

    fn Scene::rotate_world(self : Scene, id : NodeId, axis :
    Vec3
    , angle : Float) -> Unit

    Rotate around a world-space axis by angle radians (three.js Object3D.rotateOnWorldAxis).

    Scene::rotation

    fn Scene::rotation(self : Scene, id : NodeId) ->
    Quat

    Local rotation of a node.

    Scene::scale

    Local scale of a node.

    Scene::set_camera

    fn Scene::set_camera(self : Scene, handle : CameraId, value : Camera) -> Unit

    Replace a camera component (e.g. after a resize: cam.with_viewport(w, h)). A handle that no longer refers to a camera node is ignored.

    Scene::set_euler

    fn Scene::set_euler(self : Scene, id : NodeId, x : Float, y : Float, z : Float, order? :
    EulerOrder
    ) -> Unit

    Write the local rotation from Euler angles in radians. order defaults to XYZ, matching three.js Euler / Object3D.rotation.

    Scene::set_instance_tint

    fn Scene::set_instance_tint(self : Scene, id : NodeId, tint :
    Vec4
    ) -> Unit

    Change one mesh node's per-instance colour multiplier (linear RGBA). Only a mesh node is affected; other payloads ignore the call.

    Scene::set_layer_mask

    fn Scene::set_layer_mask(self : Scene, id : NodeId, mask : UInt) -> Unit

    Scene::set_local_bounds

    fn Scene::set_local_bounds(self : Scene, id : NodeId, bounds :
    Aabb3
    ?) -> Unit

    Local AABB used for frustum culling (normally MeshData::bounds).

    Scene::set_name

    fn Scene::set_name(self : Scene, id : NodeId, name : String) -> Unit

    Scene::set_parent

    fn Scene::set_parent(self : Scene, id : NodeId, parent : NodeId?, keep_world? : Bool) -> Bool

    Reparent a node. With keep_world the node keeps its current world transform by adjusting the local TRS (three.js attach).

    Scene::set_payload

    fn Scene::set_payload(self : Scene, id : NodeId, p : NodePayload) -> Unit

    Scene::set_position

    fn Scene::set_position(self : Scene, id : NodeId, p :
    Vec3
    ) -> Unit

    Write the local translation, preserving rotation and scale.

    Scene::set_rotation

    fn Scene::set_rotation(self : Scene, id : NodeId, q :
    Quat
    ) -> Unit

    Write the local rotation, preserving translation and scale.

    Scene::set_scale

    fn Scene::set_scale(self : Scene, id : NodeId, s :
    Vec3
    ) -> Unit

    Write the local scale, preserving translation and rotation.

    Scene::set_transform

    fn Scene::set_transform(self : Scene, id : NodeId, t :
    Transform
    ) -> Unit

    Scene::set_uniform_scale

    fn Scene::set_uniform_scale(self : Scene, id : NodeId, s : Float) -> Unit

    Set a uniform scale on all three axes.

    Scene::set_visible

    fn Scene::set_visible(self : Scene, id : NodeId, visible : Bool) -> Unit

    Scene::transform

    Scene::translate

    fn Scene::translate(self : Scene, id : NodeId, delta :
    Vec3
    ) -> Unit

    Offset the local translation by delta (parent space), preserving rotation and scale.

    Scene::traverse

    fn Scene::traverse(self : Scene, f : (NodeId) -> Unit, root? : NodeId) -> Unit

    Iterative pre-order traversal. None starts from every root.

    Scene::update

    fn Scene::update(self : Scene) -> Unit

    Propagate local TRS into world Affine3 with one iterative DFS. Only nodes whose own or ancestor transform is dirty are recomputed.

    Scene::visible

    fn Scene::visible(self : Scene, id : NodeId) -> Bool

    The node's own visibility flag (not inherited).

    Scene::world_bounds

    fn Scene::world_bounds(self : Scene, id : NodeId) ->
    Aabb3
    ?

    World-space AABB, or None when no local bounds were registered.

    Scene::world_to_local

    Transform a world-space point into the node's local space.

    Scene::world_transform

    fn Scene::world_transform(self : Scene, id : NodeId) ->
    Affine3

    Shading

    pub(all) enum Shading {
    Pbr
    Unlit
    Custom(Int)
    }

    ShadowDesc

    pub(all) struct ShadowDesc {
    map_size : Int
    bias : Float
    normal_bias : Float
    pcf_radius : Int
    half_extents : Float?
    }

    ShadowDesc::default

    fn ShadowDesc::default() -> ShadowDesc

    SpotLight

    pub(all) struct SpotLight {
    color :
    Vec3

    intensity : Float
    range : Float
    inner_angle : Float
    outer_angle : Float
    shadow : ShadowDesc?
    }

    TextureHandle

    pub(all) struct TextureHandle {
    // private fields
    } derive(Eq,
    Debug
    )

    Renderer-owned GPU texture. The material only carries the handle.

    TextureHandle::id

    fn TextureHandle::id(self : TextureHandle) -> Int

    TransformTrack

    pub(all) struct TransformTrack {
    translation : Vec3Track?
    rotation : QuatTrack?
    scale : Vec3Track?
    }

    Any subset of the three channels; missing channels keep the node's value.

    TransformTrack::duration

    fn TransformTrack::duration(self : TransformTrack) -> Float

    TransformTrack::new

    fn TransformTrack::new(translation? : Vec3Track, rotation? : QuatTrack, scale? : Vec3Track) -> TransformTrack

    TransformTrack::sample_with

    Sample over base: channels that the track does not animate are preserved.

    Vec3Track

    pub(all) struct Vec3Track {
    times : Array[Float]
    values : Array[
    Vec3
    ]
    interpolation : Interpolation
    }

    Vec3Track::duration

    fn Vec3Track::duration(self : Vec3Track) -> Float

    Vec3Track::new

    fn Vec3Track::new(times : Array[Float], values : Array[
    Vec3
    ], interpolation? : Interpolation) -> Vec3Track

    Vec3Track::sample

    fn Vec3Track::sample(self : Vec3Track, t : Float) ->
    Vec3

    LINE_PICK_RADIUS

    let LINE_PICK_RADIUS : Float

    World-space pick radius for line nodes. Lines have no thickness, so picking accepts segments within this distance of the ray.

    MESH_VERTEX_BYTES

    let MESH_VERTEX_BYTES : Int

    MESH_VERTEX_FLOATS

    let MESH_VERTEX_FLOATS : Int

    MORPH_TARGETS_MAX

    let MORPH_TARGETS_MAX : Int

    MORPH_VERTEX_BYTES

    let MORPH_VERTEX_BYTES : Int

    MORPH_VERTEX_FLOATS

    let MORPH_VERTEX_FLOATS : Int

    Morph vertices append up to two position deltas: 72 bytes per vertex.

    SKIN_VERTEX_BYTES

    let SKIN_VERTEX_BYTES : Int

    SKIN_VERTEX_FLOATS

    let SKIN_VERTEX_FLOATS : Int

    Skinned vertices append joints(4) and weights(4): 80 bytes per vertex.

    aabb_line_data

    The twelve edges of an axis-aligned box, as a line list.

    add_ambient

    fn add_ambient(scene : Scene, color? :
    Vec3
    , intensity? : Float) -> NodeId

    add_sun

    fn add_sun(scene : Scene, direction :
    Vec3
    , color? :
    Vec3
    , intensity? : Float, shadow? : Bool) -> NodeId

    Add a directional light node whose -Z axis points along direction (the same convention as cameras). Absorbs the repeated rotation boilerplate.

    axis_line_data

    fn axis_line_data(size? : Float) ->
    LineData

    One segment from the origin along +Z (the reference axis that add_axes rotates into X and Y).

    circle_line_data

    fn circle_line_data(radius? : Float, segments? : Int) ->
    LineData

    Closed circle of segments on the XZ plane (a ground ring / radius gizmo).

    custom_flat_shader_spv

    fn custom_flat_shader_spv() -> (FixedArray[UInt], FixedArray[UInt])

    The reference custom-shader pair (shaders/custom_flat.{vert,frag}): a flat HDR colour read from the user uniform block (one vec4). Useful as a starting point and as the contract test for the custom pipeline path.

    decode_hdr

    fn decode_hdr(data : Bytes) -> HdrImage?

    Decode a Radiance RGBE image. Returns None for malformed input.

    default_environment_cubemap

    fn default_environment_cubemap(dev :
    Device
    ) ->
    Texture
    raise

    A tiny dark cube used when the user never sets an environment, so the shaders always have a valid samplerCube binding.

    encode_hdr

    fn encode_hdr(img : HdrImage, rle? : Bool) -> Bytes

    Encode a linear RGB image as Radiance RGBE. RLE is used when the width permits it (8..32767); otherwise scanlines are stored flat.

    equirect_environment_cubemap

    fn equirect_environment_cubemap(dev :
    Device
    , image : HdrImage, size? : Int, samples? : Int) ->
    Texture
    raise

    Build a GGX-prefiltered RGBA16F environment cubemap from a linear HDR equirectangular image (see decode_hdr). Values above 1.0 survive, so the sun keeps its energy through the mip chain.

    equirect_uv

    fn equirect_uv(dir :
    Vec3
    ) -> (Float, Float)

    Equirectangular UV for a world direction: u wraps around +Y (0.5 looks along +Z) and v is 0 at the zenith, 1 at the nadir.

    f16_bits

    fn f16_bits(v : Float) -> UInt16

    IEEE binary16 bits, round-to-nearest on the top mantissa bit. Values below 2^-14 flush to zero (environment texels are never that dark in practice).

    f16_to_float

    fn f16_to_float(bits : UInt16) -> Float

    Decode IEEE binary16 bits back to a float (used by tests and LUT readback).

    fog_exp2

    fn fog_exp2(color :
    Vec3
    , density? : Float) -> Fog

    three.js new FogExp2(color, density).

    fog_linear

    fn fog_linear(color :
    Vec3
    , near? : Float, far? : Float) -> Fog

    three.js new Fog(color, near, far).

    grid_line_data

    fn grid_line_data(size? : Float, divisions? : Int) ->
    LineData

    Square grid on the XZ plane, centred on the origin (three.js GridHelper). size is the full edge length; divisions is the number of cells per side.

    hex

    fn hex(rgb : Int, a? : Float) ->
    Vec4

    Author an sRGB color from a packed 0xRRGGBB literal, returning linear RGBA.

    hex(0xFF8800) is the three.js new Color(0xff8800) equivalent, and the result feeds MaterialDesc::pbr directly:

    let mat = @t3d.MaterialDesc::standard(@t3d.hex(0xFF8800), roughness=0.4)

    Channels above 0xFFFFFF are ignored; alpha is authored separately and is not gamma-encoded (three.js Color behaves the same way).

    hsl

    fn hsl(h : Float, s : Float, l : Float, a? : Float) ->
    Vec4

    Author an sRGB color from HSL, returning linear RGBA.

    h is degrees (0 = red, 120 = green, 240 = blue, wraps at 360); s / l are 0..1. This is the Color.setHSL equivalent; the palette helpers that produce 0xRRGGBB constants and hsl(...) land on identical values for the same color.

    linear

    fn linear(r : Float, g : Float, b : Float, a? : Float) ->
    Vec4

    Linear RGBA from explicit linear channels — the counterpart of srgb. Values may exceed 1 for HDR emitters when used as an emissive color.

    load_gltf

    fn load_gltf(renderer : Renderer3D, scene : Scene, gltf :
    GltfScene
    , parent? : NodeId) -> Array[NodeId] raise

    Upload every glTF mesh/material and instantiate its node hierarchy under parent. Returns the created nodes in pre-order.

    load_gltf_animations

    fn load_gltf_animations(gltf :
    GltfScene
    , node_map : Array[NodeId?]) -> Array[AnimationClip]

    Convert glTF animation channels into engine clips. Channels sharing a node merge into one transform track; cubic-spline keys use their value key.

    load_gltf_instance

    fn load_gltf_instance(renderer : Renderer3D, scene : Scene, gltf :
    GltfScene
    , parent? : NodeId) -> GltfInstance raise

    Upload every glTF mesh/material, instantiate its node hierarchy under parent, and return a single GltfInstance that ties the nodes, GPU resources, and animation clips together. This is the entry point most callers want; load_gltf / load_gltf_with_nodes remain thin wrappers.

    load_gltf_with_nodes

    fn load_gltf_with_nodes(renderer : Renderer3D, scene : Scene, gltf :
    GltfScene
    , parent? : NodeId) -> Array[NodeId?] raise

    Node map indexed by glTF node index (None for nodes that are not instantiated), which load_gltf_animations uses to bind channels.

    mesh_morph_vertex_floats

    fn mesh_morph_vertex_floats(mesh :
    MeshData
    ) -> FixedArray[Float]

    Interleaved morph vertex stream: 12 static floats plus the first two morph target deltas (zero-filled when a target is absent).

    mesh_skinned_vertex_floats

    fn mesh_skinned_vertex_floats(mesh :
    MeshData
    ) -> FixedArray[Float]

    Interleaved skinned vertex stream: the static 12 floats plus joints(4) and weights(4). Vertices without skin data get zero joints and weights.

    mesh_vertex_floats

    fn mesh_vertex_floats(mesh :
    MeshData
    ) -> FixedArray[Float]

    Interleaved position(3) + normal(3) + uv(2) + tangent(4) floats. Tangents must already be generated.

    procedural_environment_cubemap

    fn procedural_environment_cubemap(dev :
    Device
    , sun_dir :
    Vec3
    , size? : Int, samples? : Int) ->
    Texture
    raise

    Create a procedural sky cubemap with a GPU-prefiltered mip chain. size is the base face resolution (256 by default); samples is the GGX integration sample count per texel per mip (128 by default).

    ray_lines_hit

    Nearest line segment under a ray, in world space. triangle in the returned hit carries the segment index.

    srgb

    fn srgb(r : Float, g : Float, b : Float, a? : Float) ->
    Vec4

    Author a color in familiar sRGB space; returns a linear Vec4.

    srgb_to_linear

    fn srgb_to_linear(c : Float) -> Float

    sRGB (IEC 61966-2-1) to linear.