Appearance
Project Architecture
How does the app actually run? Here's the flow.
Entry Flow
index.html
└── src/main.ts
└── App.svelte
└── init(canvas) ← from src/lib/ts/test.tsindex.html loads the module.
main.ts mounts the Svelte app.
App.svelte renders the canvas and UI, calls init(canvas) on mount.
Render.test.ts wires everything together:
- Initializes managers with the canvas
- Creates scene objects
- Sets initial rotations
- Hooks up input → outer cube rotation
- Hooks up animation tick → inner cube spin + render
- Starts the loop
Types
See rendering.types.md.
Scene Graph
i wanted nested rotations without gimbal lock. Each O_Scene can have a parent—child transforms are relative to parent's world matrix.
outer_cube (teal)
└── inner_cube (red, scale 0.4, auto-rotates)Drag the outer cube, inner cube follows. Inner cube spins independently inside.
File Layout
See files.md.
Pipeline
The render pipeline, step by step:
render.get_world_matrix(obj)— builds local matrix from quat + position + scale, multiplies by parent's world matrixrender.project_vertex(v, world_matrix)— transforms through MVP, perspective divide, maps to screenrender.render_object(obj)— projects vertices, draws edges with depth-based alpharender.render()— clears canvas, iteratesscene.get_all()
Matrices
| Matrix | Location | What it does |
|---|---|---|
view | camera | Camera transform via mat4.lookAt |
projection | camera | Perspective via mat4.perspective |
mvp_matrix | render | Combined MVP, reused per batch |