Three.js Config Constants — Runtime Tuning sem Tocar Código
Sistema de constants expostas para tuning em runtime: câmera, portal center, elevação, velocidades, materiais, física. Código em scripts/.
Quando usar (gatilhos concretos)
- "Three.js constants expostas para tuning"
- "Three.js config constants runtime"
- "Tuning camera position runtime"
- "Portal center constants"
- "Runtime config Three.js"
- "Tweakable parameters Three.js"
Quando NÃO usar
- Composição de cena → use
threejs-scene-composer
- Shaders customizados → use
threejs-shader-effects
- Deploy → use
threejs-deploy-pipeline
- Patterns responsivos → use
threejs-responsive-patterns
- Voxel systems → use
threejs-voxel-block-system
Core (scripts/config-constants.js)
ConfigConstants: register(key, default, {description, category, min/max/step, options, validator, readonly}) + registerMany → get/set (com validação, range check, history/undo até 50) → onChange/onAnyChange → savePreset/loadPreset → toJSON/loadJSON → getUIConfig/getByCategory → createControlPanel(container) (painel HTML por categoria). Tipos inferidos: array, vector2/3, color, euler, matrix4. createThreeJSDefaults() registra câmera, portal, ilha, animação, rendering, física e materiais.
import { ConfigConstants } from './scripts/config-constants.js';
const config = ConfigConstants.createThreeJSDefaults();
config.onChange('camera.fov', (v) => { camera.fov = v; camera.updateProjectionMatrix(); });
Presets (scripts/presets.js)
minecraftStyle (Gustavo Campelo), cinematic, mobileOptimized, development + applyPreset(config, name). Hot reload: teclas 1-4. Save/load: Ctrl+S / Ctrl+L (localStorage).
GUI (scripts/gui-integration.js + scripts/main.js)
createGUI(config) monta pastas dat.gui (Camera/Portal/Animation/Rendering/Materials/Physics). main.js mostra o fluxo completo: defaults → preset → GUI → callbacks Three.js → hot reload → save/load.
Validação (2026-08-30)
- Baseado no vídeo do Gustavo Campelo (portal center, elevação, posição ilha, velocidades)
- Three.js docs (Object3D, Camera, Material); dat.gui / tweakpane confirmados
Checklist de Entrega
Adapters (Por Plataforma)
1---2name: threejs-config-constants3description: Use when exposing tweakable Three.js constants for runtime tuning — camera, portal, elevation, speeds — without touching code. Triggers on "threejs constants", "threejs config constants", "threejs tuning constants", "threejs runtime config", "threejs tweakable parameters".4metadata:5 source: https://skillmd.com/skills/majinmagros/threejs-config-constants6 origin: AUTORAL7 source_docs:8 - https://threejs.org/docs/#api/en/core/Object3D9 - https://threejs.org/docs/#api/en/cameras/PerspectiveCamera10 - https://threejs.org/docs/#api/en/materials/Material11 platforms: [claude-code, opencode, cursor, codex, gemini-cli, hermes, openclaw]12 requires_adapters: []13---1415# Three.js Config Constants — Runtime Tuning sem Tocar Código1617Sistema de **constants expostas** para tuning em runtime: câmera, portal center, elevação, velocidades, materiais, física. Código em `scripts/`.1819## Quando usar (gatilhos concretos)2021- "Three.js constants expostas para tuning"22- "Three.js config constants runtime"23- "Tuning camera position runtime"24- "Portal center constants"25- "Runtime config Three.js"26- "Tweakable parameters Three.js"2728## Quando NÃO usar2930- Composição de cena → use `threejs-scene-composer`31- Shaders customizados → use `threejs-shader-effects`32- Deploy → use `threejs-deploy-pipeline`33- Patterns responsivos → use `threejs-responsive-patterns`34- Voxel systems → use `threejs-voxel-block-system`3536## Core (`scripts/config-constants.js`)3738`ConfigConstants`: `register(key, default, {description, category, min/max/step, options, validator, readonly})` + `registerMany` → `get/set` (com validação, range check, history/undo até 50) → `onChange/onAnyChange` → `savePreset/loadPreset` → `toJSON/loadJSON` → `getUIConfig/getByCategory` → `createControlPanel(container)` (painel HTML por categoria). Tipos inferidos: array, vector2/3, color, euler, matrix4. `createThreeJSDefaults()` registra câmera, portal, ilha, animação, rendering, física e materiais.3940```javascript41import { ConfigConstants } from './scripts/config-constants.js';42const config = ConfigConstants.createThreeJSDefaults();43config.onChange('camera.fov', (v) => { camera.fov = v; camera.updateProjectionMatrix(); });44```4546## Presets (`scripts/presets.js`)4748`minecraftStyle` (Gustavo Campelo), `cinematic`, `mobileOptimized`, `development` + `applyPreset(config, name)`. Hot reload: teclas 1-4. Save/load: Ctrl+S / Ctrl+L (localStorage).4950## GUI (`scripts/gui-integration.js` + `scripts/main.js`)5152`createGUI(config)` monta pastas dat.gui (Camera/Portal/Animation/Rendering/Materials/Physics). `main.js` mostra o fluxo completo: defaults → preset → GUI → callbacks Three.js → hot reload → save/load.5354## Validação (2026-08-30)5556- Baseado no vídeo do Gustavo Campelo (portal center, elevação, posição ilha, velocidades)57- Three.js docs (Object3D, Camera, Material); dat.gui / tweakpane confirmados5859## Checklist de Entrega6061- [ ] `ConfigConstants` (register/get/set/callbacks)62- [ ] Presets (minecraftStyle, cinematic, mobileOptimized, development)63- [ ] dat.gui / tweakpane + localStorage + hot reload64- [ ] Type inference (Vector2/3, Color, Euler) + validation + history/undo6566## Adapters (Por Plataforma)