How eepyberry/lagrange works
Purpose and runtime
Lagrange is a client-side procedural planet builder. Vue 3 provides the application UI; Three.js renders procedural planets through WebGL2 or optionally WebGPU. Vite builds and serves the SPA. Static skyboxes, backgrounds, and extras are shipped from public/.
Key entry points: index.html, src/main.ts, src/App.vue, src/router.config.ts.
Application shell and navigation
The root app initializes global UI, routing, localization, dialogs, navigation, footer, and toast presentation. Routing separates the creation/editor workflow from the saved-planet Codex landing view and a not-found fallback.
Paths: src/App.vue, src/router.config.ts, src/views/EditorView.vue, src/views/CodexView.vue, src/components/global/AppNavigation.vue.
Editor orchestration and state
The editor is the primary interactive boundary. Its service and centralized state coordinate initialization, current planet data, render configuration, scene lifecycle, dirty/save behavior, and UI-to-renderer updates. The editor exposes categorized controls for basic identity, surface, biomes, clouds, atmosphere, rings, lighting, rendering, and post-processing.
Paths: src/core/services/editor.service.ts, src/core/state/editor.state.ts, src/components/editor/controls/ControlsContainer.vue, src/components/editor/controls/EditorSidebarControls.vue.
Planet and render-domain models
Typed model objects represent editable planet parameters and rendering-pipeline parameters. Converter modules translate persisted/imported data into runtime model shape. Observers react to parameter changes and propagate them into generated scene/material state, separating UI data representation from GPU resources.
Paths: src/core/models/planet/planet-data.model.ts, src/core/models/renderpipeline/render-pipeline-data.model.ts, src/core/models/converters/model-converter.ts, src/core/observers/planet-data.observer.ts.
Rendering capability, scene, and pipeline
Renderer selection is gated by explicit WebGL/WebGPU capability checks. Scene, preview, texture, and baking helpers establish Three.js objects and render targets; the render-pipeline abstraction controls base rendering and post-processing. This is the browser/GPU boundary and requires WebGL2, with WebGPU available when supported.
Paths: src/core/capabilities/WebGL.ts, src/core/capabilities/WebGPU.ts, src/core/helpers/scene.helper.ts, src/core/tsl/rendering/render-pipeline.ts.
Procedural GPU materials
Three.js TSL materials implement the planet layers: procedural surface/noise and biomes, clouds, atmosphere scattering, rings, and lens flare. Parameter changes from the editor/models drive uniforms or material graph inputs, then the active renderer produces the viewport and previews.
Paths: src/core/tsl/materials/planet.tslmat.ts, src/core/tsl/materials/atmosphere.tslmat.ts, src/core/tsl/materials/clouds.tslmat.ts, src/core/tsl/materials/ring.tslmat.ts.
Persistence, import/export, and Codex
Dexie provides browser-local persistent storage, making saved planets available to the Codex. Import/export helpers form the file boundary for portable planet data. The Codex lists saved worlds, produces previews, shows metadata/graphs, and supports deletion.
Paths: src/core/services/dexie.service.ts, src/core/helpers/import.helper.ts, src/core/helpers/export.helper.ts, src/components/codex/elements/PlanetCardElement.vue.
Deployment and external assets
The app is a static Vite build, suitable for browser hosting; Dockerfile supports containerized delivery. CI and release automation are GitHub Actions. No backend service is indicated. External runtime dependencies are the browser WebGL2/WebGPU APIs and Three.js; bundled assets include skyboxes under public/skyboxes/.
Paths: vite.config.ts, Dockerfile, .github/workflows/main.yml, public/skyboxes/.
Main entry points: editor.service.ts Editor service · render-pipeline.ts Render pipeline · planet-data.observer.ts Planet observer · editor.state.ts Editor state
Components 25
Vue application
- Vite SPA build · Builds and serves the client-side application.
vite.config.ts - Application entry
src/main.ts - Root application shell · Hosts global UI, routing, dialogs, navigation, footer, and toasts.
src/App.vue - Router · Selects editor, Codex, and not-found views.
src/router.config.ts - App navigation
src/components/global/AppNavigation.vue
Editor domain
- Editor view · Primary planet creation and editing workflow.
src/views/EditorView.vue - Editor service · Coordinates initialization, scene lifecycle, saves, and renderer updates.
src/core/services/editor.service.ts - Editor state · Holds current planet data, render configuration, and dirty state.
src/core/state/editor.state.ts - Editor controls · Categorized controls drive editable planet and render parameters.
src/components/editor/controls/ControlsContainer.vue - Planet data model
src/core/models/planet/planet-data.model.ts - Render pipeline model
src/core/models/renderpipeline/render-pipeline-data.model.ts - Model converter · Transforms persisted or imported data into runtime model shape.
src/core/models/converters/model-converter.ts
GPU rendering
- Planet observer · Propagates parameter changes into generated scene and material state.
src/core/observers/planet-data.observer.ts - WebGL/WebGPU checks · Requires WebGL2 and enables WebGPU when supported.
src/core/capabilities/WebGL.ts - Render pipeline · Controls base rendering and post-processing.
src/core/tsl/rendering/render-pipeline.ts - Planet material · Generates procedural surface, noise, and biome layers.
src/core/tsl/materials/planet.tslmat.ts - Atmosphere material · Renders atmospheric scattering.
src/core/tsl/materials/atmosphere.tslmat.ts - Clouds material
src/core/tsl/materials/clouds.tslmat.ts - Ring material
src/core/tsl/materials/ring.tslmat.ts - Browser GPU APIs · WebGL2 and optional WebGPU execution environment.
Persistence & assets
- Codex view · Landing view for saved planets.
src/views/CodexView.vue - Planet card · Lists saved worlds with previews, metadata, and deletion.
src/components/codex/elements/PlanetCardElement.vue - Local planet store · Browser-local storage for saved planets.
src/core/services/dexie.service.ts - Import/export · Reads and writes portable planet data.
src/core/helpers/import.helper.ts - Skybox assets · Bundled backgrounds and skyboxes.
Connections 31
- Vite SPA build → Application entry: builds
- Application entry → Root application shell: mounts
- Root application shell → Router: uses
- Root application shell → App navigation: hosts
- Router → Editor view: routes to
- Router → Codex view: routes to
- Editor view → Editor controls: hosts
- Editor view → Editor service: drives
- Editor controls → Editor state: edits
- Editor service → Editor state: coordinates
- Editor state → Planet data model: holds
- Editor state → Render pipeline model: holds
- Editor state → Planet observer: notifies
- Planet observer → Planet material: updates
- Planet observer → Atmosphere material: updates
- Planet observer → Clouds material: updates
- Planet observer → Ring material: updates
- Editor service → WebGL/WebGPU checks: selects renderer via
- WebGL/WebGPU checks → Browser GPU APIs: detects
- Editor service → Render pipeline: manages
- Render pipeline → Planet material: renders
- Render pipeline → Atmosphere material: renders
- Render pipeline → Clouds material: renders
- Render pipeline → Ring material: renders
- Render pipeline → Browser GPU APIs: executes on
- Editor service → Local planet store: saves to
- Import/export → Model converter: converts through
- Model converter → Planet data model: creates
- Codex view → Planet card: lists with
- Planet card → Local planet store: loads and deletes
- Editor service → Skybox assets: uses