Audience: humans and AI agents working in this repository. This file defines expectations, conventions, and tips for making safe, minimal, and consistent changes.
Scope: the entire repository rooted at this folder.
- Requirements: Node.js 18+ (Vite 5), npm 9+.
- Install:
npm i - Dev server:
npm run dev - Build:
npm run build - Preview build:
npm run preview - Lint/format:
npm run lint,npm run format - Scene tests:
npm run test(servessrc/testsvia Vite)
index.html,main.js: default app entry.src/: application code and assets.core/: rendering, cameras, environments, managers, etc.gui/: Tweakpane Manager and helpers.assets/: images, HDRI, models, audio.presets/: preset data (env, fog, camera, scene requirements).
public/: static assets served at root (avoid duplicating assets already insrc/assets).lumaLabs/: standalone prototypes/demos; not part of the main build. Keep edits minimal and localized when fixing issues here.
Aliased imports are configured in both vite.config.js and jsconfig.json. Prefer these paths:
@→src@core→src/core@components→src/core/components@managers→src/core/managers@renderers→src/core/renderers@cameras→src/core/cameras@controls→src/core/controls@environments→src/core/components/environments@effects→src/core/effects@postprocessing→src/core/postprocessing@utils→src/utils@gui→src/gui@assets→src/assets@models→src/assets/models@textures→src/assets/textures@environmentMaps→src/assets/environmentMaps@presets→src/presets@tests→src/tests
When you add or move folders, update both vite.config.js and jsconfig.json consistently.
- Use
THREE.SRGBColorSpacefor color spaces; avoid deprecatedencodingoptions. - For
WebGLRenderTarget/WebGLCubeRenderTarget, prefer{ colorSpace: THREE.SRGBColorSpace }. - Tone mapping defaults: ACESFilmic is standard here.
- Use
TweakpaneManager(@gui/TweakpaneManager) to create UI. It provides:addFolder({ title: string })oraddFolder("Title")alias (internally usescreateFolder).pane.addTab,folder.addBinding, etc. via Tweakpane.refresh()anddispose()passthroughs.
- Event signature:
.on("change", ({ value }) => { ... })(Tweakpane v4 style). Do not assume raw value is passed. - Prefer updating parameters then calling
pane.refresh()or component-specific update methods when needed.
- HDR files live under
src/assets/environmentMaps/hdr/. EXR files, if used, undersrc/assets/environmentMaps/exr/. HDRIEnvironmentresolves preset paths using Vite’simport.meta.globwith{ as: 'url' }. Keep preset paths insrc/presets/envPresets.jslike/environmentMaps/hdr/<file>.hdr— the loader will resolve to the correct bundled URL.- If you add new HDRs, place them in the folder above and add a corresponding preset entry.
- The environment system exposes
environment.debugObjectwith keys likeintensity,blur,rotation,path,exposure. Useenvironment.updateFromDebug(scene, renderer)to apply changes.
- Aliases are defined under
resolve.alias. buildandserver.hmrshould be top-level keys in the exported config (not nested underresolve). If you alter Vite config, preserve structure and keep aliases in sync withjsconfig.json.- For runtime asset URLs, prefer
import.meta.globornew URL('./path', import.meta.url). Avoid hardcoding dev server URLs.
- ESM only (
"type": "module"is set). Useimport/export; do not use CommonJS. - Keep diffs small and focused. Avoid refactors that aren’t required by the task.
- Match existing file style (Prettier config included). Run
npm run formatif you touch multiple files. - Favor descriptive variable names; avoid single-letter names.
- Do not add license headers unless explicitly requested.
- These HTML files are standalone demos. If fixing issues (e.g., reassigning a
const), keep changes minimal (e.g., change tolet) and avoid cross-wiring them into the main app.
- Tweakpane change handlers must destructure
{ value }. - With Three r157+, replace deprecated
encodingwithcolorSpaceoptions. - Reassignments: don’t reassign
constvariables. Useletif reassignment is intended. - Ensure new assets are placed under
src/assets/...to be bundled by Vite.
- Use clear, task-focused commit messages.
- Don’t mix unrelated changes. Update docs when behavior changes.
- If you move/rename files referenced by presets or aliases, update references atomically.
- Prefer minimal, surgical changes.
- Keep presets and aliases consistent.
- Validate locally (
npm run dev) and check the browser console for warnings/errors.