Skip to content

Latest commit

 

History

History
268 lines (235 loc) · 27.8 KB

File metadata and controls

268 lines (235 loc) · 27.8 KB

leCore API Quick Reference

A scannable, one-line-per-symbol map of the app-building surface -- auto-generated by apiquickref.py. For the full engine (every module), see REFERENCE.md.

Scene authoring

holographic_scene_doc

holographic_scene_doc.py -- the canonical Scene document (modeling-app backlog, item 0: A + B + E).

  • class SceneObject -- One object in the scene, as a role-bound RECORD: a stable handle plus its properties.
  • class Scene -- The single source of truth: a table of object records + a hierarchy, owning selection and undo history and firing change events.
    • on_change(self, callback) -- Register callback(kind, handle), fired on every change.
    • handle_vector(self, handle) -- The object's permanent identity atom -- its holographic handle (used for labelled bundles / query).
    • add(self, name=None, transform=None, geometry=None, material=None, tags=None, params=None, parent=None, overrides=None, _record=True) -- Add an object; return its STABLE handle.
    • edit(self, handle, _record=True, **changes) -- Mutate an object's fields (name/transform/geometry/material/tags/params).
    • remove(self, handle, _record=True) -- Remove an object (and drop it from the selection/hierarchy).
    • remove_tag(self, handle, key, _record=True) -- Remove one tag from an object.
    • clear_override(self, handle, prop, _record=True) -- Remove one render override from an object, so it FALLS BACK to the scene default.
    • select(self, handles) -- Set the current selection (a set of handles) and fire a 'select' event.
    • get(self, handle) --
    • set_parent(self, child, parent, _record=True) -- Parent child under parent (both handles; parent=None for top level).
    • parent_of(self, handle) -- The parent handle of an object (None if top level).
    • children_of(self, handle) --
    • begin_group(self, label='Edit') -- Open a transaction: every mutation until end_group() coalesces into ONE undo step labelled label.
    • end_group(self) -- Close the current transaction; commit the accumulated changes as a single step (nothing if empty).
    • group(self, label='Edit') -- with scene.group("Move wheels"): ... -- everything inside becomes one undo step.
    • undo(self) -- Undo the last STEP by restoring its BEFORE snapshots (in reverse order within the step).
    • redo(self) -- Redo the last undone step by restoring its AFTER snapshots.
    • history(self) -- The undo stack's step labels, oldest first.
    • redo_history(self) -- The redo stack's step labels (most-recently-undone last).
    • can_undo(self) --
    • can_redo(self) --
  • scene_info(scene, verbose=True) -- WHAT IS IN THIS SCENE -- the first call to make, before adding to it or rendering it.

holographic_modifier

holographic_modifier.py -- the per-object MODIFIER STACK + dependency graph (modeling-app backlog, items C + D).

  • class Modifier -- One entry in the stack: a named operation with parameters, applied non-destructively to the previous result.
  • class ModifierStack -- A per-object modifier stack: a base payload + an ordered list of modifiers, evaluated non-destructively, re-evaluated O(change) (only downstream of a change), with stable handles and validation.
    • handles(self) --
    • names(self) --
    • add(self, name, op, params=None, specs=None, muted=False) -- Append a modifier to the top of the stack; returns its stable handle.
    • insert(self, index, name, op, params=None, specs=None, muted=False) -- Insert a modifier at index (everything from there down must recompute).
    • remove(self, handle) --
    • move(self, handle, to_index) -- Reorder a modifier (a real modeling operation -- bevel-then-subdivide differs from the reverse).
    • set_muted(self, handle, muted) --
    • set_param(self, handle, **params) -- Change a modifier's parameters -- the common case a dependency graph optimises.
    • evaluate(self) -- Fold the stack over the base, non-destructively.
    • validate(self) -- Well-formedness (like recipeops.validate): every op callable, and every declared param within its min/max.
    • describe(self, handle) -- The property-panel schema for one modifier: each parameter's name, type, current value, and (if the modifier declared specs) default/min/max.
  • describe_object(obj) -- Item D over a SceneObject: enumerate its editable roles (name, material, tags, params) as a schema for a property panel.

Geometry / SDF

holographic_sdf

Holographic SDF / shader algebra (S1): a 3D signed-distance expression tree that evaluates, composes, represents itself holographically, and reads/writes both a compact DSL and a Shadertoy-ready GLSL shader.

  • as_eval(sdf) -- Return a plain callable P:(M,D) -> distances:(M,) for ANY of the engine's three ways of naming an SDF: * a node object with .eval(P) -- what sphere()/box()/parse_dsl() build * a bare callable -- what collide, emitter and every ad-hoc lambda pass around * a DSL STRING, e.g.
  • sdf_normal(sdf, P, eps=0.001) -- The surface normal at points P:(M,3) = the normalised gradient of the SDF, by central differences (6 vectorised evals).
  • class SDF -- A node in a signed-distance expression tree: kind, scalar params, and child SDFs.
    • eval(self, P) --
    • union(self, other) --
    • intersect(self, other) --
    • subtract(self, other) --
    • smooth_union(self, other, k=0.3) --
    • fillet_union(self, other, r=0.1) --
    • translate(self, t) --
    • scale(self, s) --
    • rotate(self, axis, angle) --
    • repeat(self, period) --
    • rounded(self, r) --
    • onion(self, thickness) --
    • displace(self, amount, freq) --
    • twist(self, k) --
    • elongate(self, hx=0.0, hy=0.0, hz=0.0) -- Stretch this shape by pulling it apart along the axes by half-extents (hx,hy,hz) -- iq's opElongate.
    • mirror(self, axis=0, plane=0.0) -- Fold space across a plane on one axis (kaleidoscopic symmetry from abs()).
    • fold(self, plane=0.0) -- Mirror all three axes about plane -- map the world into one octant (an 8-fold kaleidoscope).
    • bend(self, k, axis=0) -- Bend space by k radians per unit along axis (iq's opCheapBend) -- curl a straight beam into an arc.
    • to_tree(self) -- A nested tuple where the op name folds in the params (e.g.
    • to_dsl(self) -- A compact s-expression: (kind p0 p1 ...
    • cost(self) -- Estimate the per-ray evaluation COST of this SDF tree (W2) -- a machine-model annotation for deciding if a scene is cheap enough to raymarch in real time.
    • to_jit_expr(self) -- Emit this tree as a SINGLE symbolic expression string in (x, y, z) -- the jit_expr= that unlocks render_sdf's compiled fast path (client S-5: the fast path existed but nothing produced its input).
    • to_glsl(self, name='map', camera='fixed') -- Emit a complete Shadertoy-ready fragment shader for this SDF (see _emit_shader).
  • sphere(r=1.0) -- A sphere of radius r, centred at the origin.
  • box(bx=1.0, by=1.0, bz=1.0) -- An axis-aligned box with half-extents (bx, by, bz) centred at the origin -- so the box spans [-bx, bx] on x, etc.
  • torus(R=1.0, r=0.3) -- A torus in the XZ plane: R is the ring radius (centre to tube centre), r the tube radius.
  • cylinder(h=1.0, r=0.5) -- A capped cylinder of half-height h and radius r, axis along Y, centred at the origin.
  • plane(h=0.0) -- An infinite ground plane at height y = h (points above are outside).
  • menger(iterations=3, size=1.0) -- The Menger sponge: the classic recursive fractal cube, carved iterations deep at the given size.
  • fold_fractal(iterations=12, scale=2.0, min_radius=0.5, fold_limit=1.0) -- The KALEIDOSCOPIC-IFS / MANDELBOX distance-estimator SDF -- the general 'fold engine' behind the fractal-forums 3D fractals and the Yohei-Nishitsuji tweet-shader look.
  • mandelbulb(power=8.0, iterations=8, bailout=2.0) -- The MANDELBULB distance-estimator SDF (White & Nylander's polar-power fractal, the 3D Mandelbrot analogue).
  • capsule(h=1.0, r=0.3) -- A capsule (a cylinder with hemispherical caps) along Y: segment from -h to +h on the Y axis, radius r.
  • cone(h=1.0, r=0.5) -- A capped cone along Y: height h (apex at +h/2, base at -h/2), base radius r.
  • ellipsoid(ax=1.0, ay=0.7, az=0.5) -- An ellipsoid with semi-axes (ax,ay,az).
  • octahedron(s=1.0) -- A regular octahedron of 'radius' s (vertex distance along each axis).
  • escape_time(width=256, height=256, center=(-0.5, 0.0), span=3.0, max_iter=100, power=2.0, julia_c=None, bounds_ratio=None) -- The 2D ESCAPE-TIME fractal FIELD -- Mandelbrot (julia_c=None) or Julia (julia_c=(re,im)), the classic z -> z^power + c iteration in the complex plane.
  • to_callable(node) -- Wrap an SDF tree as a plain sdf(P)->dist callable for mesh_from_sdf / marching.
  • make_sdf_shape(kind='sphere', position=None, scale=None, rotate=None, **kw) -- Build an SDF primitive by NAME, optionally placed -- the one door to the shapes above.
  • dsl_grammar() -- The SDF DSL, described well enough to WRITE one -- node kinds, parameter meanings, and an example.
  • parse_dsl(text) -- Parse a (kind p0 ...
  • node_kinds(node) -- The set of kinds used anywhere in the tree (for the inexact-warp warning and for tests).

holographic_sdfscene

holographic_sdfscene.py -- a small, documented base class for "a scene is a set of SDF parts".

  • class SDFScene -- Subclass and implement parts() -> list of (sdf_fn, material_name).
    • parts(self) -- Return a list of (sdf_fn, material_name).
    • from_parts(cls, parts, bounds=None) -- Build an SDFScene DIRECTLY from a parts list, without writing a subclass -- the ergonomic door for a caller who just has some (sdf_fn, material) pairs and (optionally) their bounding spheres.
    • eval(self, P) -- Nearest-surface signed distance at each point = min over parts.
    • part_ids(self, P) -- Which part owns each point = argmin over parts (for material lookup).
    • material_at(self, P) -- The material_name of the owning part at each point (or None where the scene is empty).
    • bounds(self) -- Override to return a list of (center_xyz, radius) bounding spheres, one per part, each enclosing that part's surface.
    • parts_near(self, point, radius) -- Indices of parts whose bounding sphere lies within radius of point, using the SpatialGrid.

holographic_mesh

The explicit polygon mesh kernel (FWD-1): the substrate every explicit-geometry operator mutates.

  • class Mesh -- An explicit polygon mesh: positions + faces, with optional per-vertex attributes.
    • n_vertices(self) --
    • n_faces(self) --
    • edges(self) -- The set of UNDIRECTED edges as frozensets {vi, vj}.
    • n_edges(self) --
    • half_edges(self) -- Build (and cache) the half-edge table.
    • vertex_faces(self, v) -- The faces incident to vertex v, as a sorted list of face indices (deterministic).
    • vertex_neighbours(self, v) -- The 1-ring of vertex v: vertices sharing an edge with it, as a sorted list (deterministic).
    • euler_characteristic(self) -- chi = V - E + F.
    • is_closed(self) -- True iff the mesh has no boundary: every half-edge has a twin (the surface fully wraps).
    • is_manifold(self) -- True iff the half-edge structure built without raising (no directed edge appeared twice) AND -- the boundary-aware part -- every undirected edge is shared by at most two faces.
    • genus(self) -- The genus g of a CLOSED orientable mesh from chi = 2 - 2g.
    • validate_topology(self) -- The full well-formedness report for a 3-D modeling app: does this mesh have the clean, 2-manifold topology a user expects, or are there elements that will surprise them? Returns a dict: ok -- True iff manifold AND no degenerate faces (the one flag to gate on) manifold_edges -- True iff every undirected edge is shared by <= 2 faces, consistently oriented manifold_vertices -- True iff every vertex's face-fan is a single connected disk/half-disk (no BOWTIE: two cones meeting at one point pass the edge test but are non-manifold) watertight -- True iff closed (every edge has exactly two faces; no boundary/holes) non_manifold_edges -- list of (lo,hi) undirected edges shared by >2 faces (or mis-oriented) non_manifold_verts -- list of vertex indices whose link splits into >1 component (bowties) boundary_edges -- count of edges on a boundary (shared by exactly one face) degenerate_faces -- count of faces with a repeated vertex index (zero-area / collapsed) euler, genus -- the combinatorial invariants (chi = V-E+F; genus for a closed surface) Edge-manifoldness and orientation are decided by the half-edge build (a directed edge appearing twice is non-manifold).
    • vertex_normals(self, store=True) -- Per-vertex shading normals by Newell's method: each face contributes a normal whose magnitude is proportional to the face area (so big faces weigh more), accumulated at each of the face's vertices, then normalised per vertex.
    • triangulate(self) -- Fan-triangulate every polygon: a face [v0, v1, ..., v_{n-1}] becomes triangles (v0,v1,v2), (v0,v2,v3), ...
    • to_buffers(self) -- The flat, INDEXED buffers a glTF / three.js renderer consumes: position : (V, 3) float32 -- always present normal : (V, 3) float32 -- the stored normals, or freshly computed if absent uv : (V, 2) float32 -- only if the mesh has uvs colour : (V, 4) float32 -- only if the mesh has colours indices : (T*3,) int -- the triangle index buffer (flattened) float32 because that is what glTF stores; the integer index buffer is exact.
    • from_buffers(position, indices, normal=None, uv=None, colour=None) -- Reconstruct a (triangle) Mesh from flat buffers -- the inverse of to_buffers.
    • to_obj(self) -- Serialise to a Wavefront OBJ string: v x y z lines then f i j k ... lines (1-indexed, OBJ's convention).
    • from_obj(text) -- Parse a minimal Wavefront OBJ (v / f lines).
  • box(width=1.0, height=1.0, depth=1.0, center=(0.0, 0.0, 0.0)) -- An axis-aligned box as a QUAD mesh: 8 vertices, 6 quad faces, consistently oriented (outward CCW).
  • tetrahedron(scale=1.0, center=(0.0, 0.0, 0.0)) -- A regular tetrahedron as 4 triangles: V=4, E=6, F=4, chi=2.
  • grid(nx=4, ny=4, width=1.0, height=1.0, center=(0.0, 0.0, 0.0)) -- A flat subdivided plane in the z=0 plane: an (nx by ny) grid of quads.

Transforms

holographic_transform

holographic_transform.py -- TRANSFORM UTILITIES for a modeling app (modeling-app backlog, item G).

  • translation(t) -- A 4x4 translation matrix from a 3-vector.
  • scaling(s) -- A 4x4 scale matrix.
  • rotation_axis_angle(axis, angle) -- A 4x4 rotation of angle radians about axis (Rodrigues' formula).
  • compose(*mats) -- Matrix product M0 @ M1 @ ...
  • decompose(M) -- Split a 4x4 affine transform into (translate (3,), rotation quaternion (4,), scale (3,)).
  • compose_trs(translate, quat, scale) -- Build a 4x4 from translate (3,), a rotation quaternion (4,), and scale (3,) -- the inverse of decompose.
  • quat_normalize(q) --
  • quat_mul(a, b) -- The Hamilton product a*b: the rotation "apply b, then a".
  • quat_from_axis_angle(axis, angle) -- A quaternion for a rotation of angle radians about axis.
  • quat_to_axis_angle(q) -- Recover (axis, angle) from a quaternion.
  • quat_to_matrix(q) -- The 3x3 rotation matrix for a quaternion.
  • quat_from_matrix(R) -- The quaternion for a 3x3 rotation matrix (Shepperd's method: branch on the largest diagonal term for numerical stability -- a naive formula loses precision when the trace is near zero).
  • quat_from_euler(rx, ry, rz) -- A quaternion from euler angles applied X then Y then Z (R = Rz @ Ry @ Rx).
  • quat_to_euler(q) -- Recover euler angles (rx, ry, rz) from a quaternion, inverting R = Rz @ Ry @ Rx.
  • quat_slerp(a, b, t) -- Spherical linear interpolation between two rotations -- constant angular speed, the smooth in-between an animation wants.
  • quat_rotate(q, v) -- Rotate a 3-vector by a quaternion.
  • look_at(eye, target, up=(0.0, 1.0, 0.0)) -- An OpenGL view matrix for a camera at eye looking at target (the engine's convention: the camera looks down -z, y is up).

Camera

holographic_camera

holographic_camera.py -- the CAMERA CONTROLLER: viewport navigation (modeling-app feature layer).

  • class CameraController -- Orbit / pan / dolly / zoom / frame around a target.
    • distance(self) -- The eye-to-target distance (the orbit radius).
    • orbit(self, d_azimuth, d_elevation, elevation_limit=...) -- Rotate the eye around the target: d_azimuth about the world up axis, d_elevation about the current right axis.
    • pan(self, dx, dy) -- Slide the camera in its own right/up plane -- both eye and target move by the same vector, so the view direction and distance are unchanged (a translation of the whole rig).
    • dolly(self, distance) -- Move the eye toward (+) or away from (-) the target along the view direction.
    • zoom(self, factor) -- Scale the orbit radius by factor (0<factor<1 moves closer, >1 pulls back).
    • frame(self, bbox_min, bbox_max, fov_deg=45.0) -- Aim at the box centre and back off just far enough that its bounding SPHERE fills the vertical field of view: distance = radius / sin(fov/2).
    • view_matrix(self) -- The 4x4 OpenGL view matrix for the current pose (via item-G look_at).
    • to_camera(self, fov_deg=45.0, aspect=1.0) -- A render Camera at the current pose (for handing straight to the path tracer / session).

Rendering

holographic_render

A CPU rendering subsystem (RND-1): camera, lights, a mesh rasteriser, and a volumetric ray-marcher.

  • class Camera -- A pinhole camera.
    • view_matrix(self) -- World -> camera (look-at).
    • projection_matrix(self, aspect=None) -- Perspective projection (OpenGL-style, maps the frustum to the [-1,1] cube).
    • ray_dirs(self, width, height, jitter=None) -- Per-pixel world-space ray origins (the eye) and unit directions, shape (H, W, 3), for ray marching.
  • class Light -- A light.
  • rasterize_mesh(mesh, camera, width=512, height=512, lights=None, base_color=(0.8, 0.8, 0.8), background=(0.05, 0.06, 0.08), ambient=0.15, vectorized=True, texture=None, uvs=None, smooth=False, two_sided=False, vertex_colors=None) -- Rasterise a triangle mesh to an (H, W, 3) RGB image in [0,1] with a z-buffer and per-face Lambert shading.
  • volume_render(field, camera, bounds, width=256, height=256, steps=96, mode='smoke', sigma=12.0, emission_color=None, albedo=(0.9, 0.9, 0.95), lights=None, background=(0.0, 0.0, 0.0), early_term=True, empty_skip=True, occ_res=24, occ_thresh=0.001, term_eps=0.002, self_shadow=False, shadow_steps=16, shadow_sigma=None, ambient=(0.42, 0.52, 0.66), phase_g=0.0, powder=False, multi_scatter=1, only=None) -- Render a density FIELD (callable points(N,3)->density>=0) volumetrically by marching camera rays through bounds=(min_corner, max_corner) and accumulating the volume-rendering integral.
  • png_bytes(rgb01, level=6, filters=True) -- Encode an (H,W,3) image in [0,1] to PNG bytes -- a minimal, pure-stdlib encoder (zlib + struct), so the render module carries no image-library dependency.
  • png_decode(data) -- Decode PNG bytes to (array, info) -- the read side of png_bytes, pure stdlib (zlib + struct).
  • load_png(path, mode='rgb01') -- Read a PNG file back into an array -- the exact inverse of save_png, so a render survives a round trip.
  • save_image(path, rgb01, level=6, filters=True) -- Save an (H,W,3) [0,1] image, routed by extension: .png uses the stdlib encoder (deterministic, zero-dependency, always available); anything else (.jpg, .webp, .bmp, ...) uses Pillow when installed and otherwise refuses with the install command -- the same opt-in contract as every accelerator (pip install pillow, or the images extra).
  • load_hdr(path, exposure=1.0) -- Read a Radiance .hdr / .pic (RGBE) file -> (H,W,3) float32 of LINEAR radiance, UNBOUNDED.
  • save_gif(path, frames, fps=12.0, loop=0, palette='fixed', dither=False) --
  • save_png(path, rgb01, level=6, filters=True) -- Write an (H,W,3) image in [0,1] to a PNG file.
  • frame_delta_tiles(prev, curr, tile=32, thresh=0.001) -- The pixel-streaming primitive: split two frames into tilextile blocks and return only the tiles that CHANGED, as a list of (row, col, tile_pixels).
  • fit_camera(mesh, direction=(1.0, 0.75, 1.1), up=(0.0, 1.0, 0.0), fov_deg=50.0, aspect=1.0, margin=1.06) -- Solve for the camera that FRAMES a mesh: the closest eye along direction that keeps every vertex inside the frustum, with the target chosen so the subject is CENTRED.
  • gauss_area_map(mesh, nth=24, nph=48) -- The Extended Gaussian Image (Horn 1984): every face's AREA binned by its NORMAL's direction on the sphere.
  • egi_similarity(ref_mesh, mesh, nth=24, nph=48) -- Orientation-field preservation in [0, 1]: 1 - normalised L1 between the two Extended Gaussian Images.
  • silhouette_mask(mesh, direction, up=(0.0, 1.0, 0.0), size=128, frame=None) -- A binary ORTHOGRAPHIC coverage mask of mesh seen along direction -- the silhouette and nothing else.
  • silhouette_sweep(ref_mesh, mesh, n_azimuth=6, size=128, include_top=True, ref_cache=None) -- Rotate the pair under a fixed orthographic camera and score silhouette IoU at every stop -- Moose's turntable, made cheap enough to be a DEFAULT guard.
  • turnaround(mesh, ref_mesh=None, views=('top', 'front', 'side', '3q'), width=360, height=360, base_color=(0.7, 0.72, 0.62), ref_color=(0.55, 0.68, 0.75), background=(0.05, 0.06, 0.08), margin=1.6) -- TURNAROUND: render mesh from the standard modelling views (top/front/side/3q) in ONE call and, if a ref_mesh is given, score how well the silhouettes MATCH per view -- the loop that (by hand) caught the mantis's slurped legs and the box-model's proportions.

holographic_pipeline

holographic_pipeline.py -- ONE configurable render/simulation pipeline: pick a preset (or set flags), see exactly which stages will run and WHY, and get the right pipeline every time -- with the hand-assembly path still there for full control.

  • class PipelineError -- Raised at BUILD time (not render time) for an impossible configuration -- with a message that says what is wrong, so you fix the config instead of debugging a wrong image later.
  • class Stage -- One composable step.
  • class FrameState -- The mutable bag stages thread through: a stage's output is the next stage's input.
  • class RenderSpec -- A REAL scene for the pipeline (backlog A1).
  • class PipelineConfig -- Everything you'd otherwise piece together by hand, in ONE place -- the single opt-in/out surface.
    • preview() -- Fast, interactive-looking: reuse+reproject last frame, SVGF denoise, a splat proxy.
    • final() -- High quality single frame: full samples, no dirty-only reuse, final grade.
    • interactive() -- Preview plus live simulation (fluid + collision + field effects).
    • ocean() -- Preview plus the adaptive ocean/wave FX -- the plan_waves dispatch runs the cheap spectral method almost everywhere and the dear breaking grid solver only in the tiles that actually break.
  • dispatch_render(ctx) -- Resolve the RenderSpec's render method (or pick one via 'auto'), CHECK the chosen strategy's needs are present, then run it.
  • build_pipeline(cfg, registry=None) -- Config -> ordered, validated Pipeline.
  • class Pipeline -- An ordered list of stages.
    • plan(self) -- Dry run / EXPLAIN: every active stage, WHY it is here, and what it NEEDS and PRODUCES -- without rendering.
    • stage_names(self) --
    • run(self, scene=None, seed=0, prev_frame=None, renderer=None) -- Execute the pipeline: build the shared FrameState and thread it through every stage in order.
    • lower_to_program(self, machine) -- Phase 6: LOWER the pipeline to a machine PROGRAM -- one APPLY instruction per stage, in order, then HALT.
    • run_on_vm(self, machine=None, scene=None, seed=0, prev_frame=None, renderer=None) -- Phase 6: RUN the pipeline ON the VM instead of a Python for-loop.

holographic_session

holographic_session.py -- ONE render session that ties the disconnected rendering threads together.

  • sdf_surface_points(sdf, bounds, n=2000, seed=0, eps=0.02, oversample=8) -- Sample points that lie ON an SDF's surface -- the front half of the SDF->splat bridge that was missing.
  • class RenderSession -- One scene, every renderer.
    • preview(self, width=None, height=None, reuse_margin=None, **kw) -- FAST path: the material preview via render_surface (Lambert + spec + env reflection + one transparency layer), resolving every SurfaceMaterial channel per hit.
    • cache_stats(self) -- {hits, rebuilds, hit_rate, margin} for the preview's fat-margin cache, or None if it is not in use.
    • invalidate_preview(self) -- Drop the preview cache -- call after any scene edit.
    • render_final(self, spp=64, on_progress=None, progress_every=8, width=None, height=None, max_bounce=4, sky=None, seed=0, should_stop=None) -- SLOW path: the photoreal final via path_trace, using the SAME SurfaceMaterials as the preview (through the material adapter).
    • to_splats(self, n=2000, radius=0.12, seed=0) -- PROXY path: sample the SDF surface and fit splats (field_to_splats) so the scene can be drawn by a lightweight browser billboard shader -- no three.js scene graph, no mesh pipeline.
    • set_material(self, obj_id, material) -- Replace one object's material.
    • edit_channel(self, obj_id, channel, value) -- Edit ONE channel of one object's material (colour/roughness/reflect/emission/opacity) -- the value can be a constant, a Param, a pattern field, or a map.

holographic_cancel

holographic_cancel.py -- COOPERATIVE CANCELLATION for long operations (modeling-app backlog, item F).

  • class CancelToken -- A cooperative cancel flag.
    • cancel(self) -- Request cancellation.
    • reset(self) -- Clear the flag so the token can be reused for the next operation.
    • cancelled(self) --
    • should_stop(self) -- The cooperative check a loop calls between chunks.
  • run_cancellable(iterable, token, on_step=None) -- Iterate iterable, yielding items until token is cancelled -- a thin helper for wrapping any step loop (a sim advancing frames, an iterative solver) in cancellation.

Export / LOD

holographic_lod

Screen-space-error level-of-detail policy (holographic_lod).

  • build_lod_chain(mesh, targets=(0.5, 0.25, 0.125)) -- Decimate mesh (via QEM) to a chain of coarser levels at the given face-count FRACTIONS of the original, measuring each level's surface deviation from the ORIGINAL mesh.
  • build_cluster_lod_chain(mesh, grids=(48, 24, 12)) -- The PARALLEL counterpart of build_lod_chain, for an IMPORTED mesh with no field behind it: vertex-cluster the mesh (cluster_decimate) at decreasing grid resolutions, measuring each level's surface deviation from the ORIGINAL.
  • screen_space_error(world_error, distance, screen_height_px=1080, fov_rad=...) -- Project a world-space error to screen pixels at a viewing distance.
  • select_lod(chain, distance, pixel_threshold, screen_height_px=1080, fov_rad=...) -- Index of the COARSEST level in chain whose MAX screen-space error is still under pixel_threshold at this distance -- the cheapest mesh that looks right.

holographic_gltf

Binary glTF (.glb) emission and parsing (FWD-2): the boundary between the NumPy back end and three.js.

  • mesh_to_glb(mesh, base_colour=(0.8, 0.8, 0.8, 1.0), generator='holostuff', material=None, texture=None) -- Serialise a Mesh to a single-file binary glTF (.glb) and return the bytes.
  • scene_primitives(gltf) -- THE canonical vertex order of a glTF scene: the ordered list of (mesh_index, primitive_index, world_matrix, node_index) the active scene references, walked depth-first with node transforms composed.
  • glb_to_mesh(data) -- Parse a binary glTF (.glb) back into a Mesh -- the WHOLE scene, not a fragment.
  • write_glb(mesh, path, **kw) -- Write a mesh to a .glb file.
  • read_glb(path) -- Read a mesh from a .glb file.
  • validate_glb(data) -- A structural conformance check on a .glb: the container a real GLTFLoader requires.