create-threenative 0.2.7 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/agent-docs/references/assertion-reference.md +87 -35
- package/agent-docs/references/auto-exposure.md +57 -0
- package/agent-docs/references/capability-reference.md +1306 -62
- package/agent-docs/references/debug-surface.md +6 -0
- package/agent-docs/references/finding-assets.md +46 -10
- package/agent-docs/references/performance-basics.md +5 -4
- package/agent-docs/references/terrain-authoring.md +140 -0
- package/agent-files/.agents/skills/threenative-assets/SKILL.md +2 -1
- package/capabilities.json +1505 -79
- package/dist/index.d.ts +28 -3
- package/dist/index.js +402 -167
- package/dist/threenative.js +989 -237
- package/dist/web-engine-buffer-geometry-utils.js +281 -0
- package/dist/web-engine-decal-geometry.js +184 -0
- package/dist/web-engine-gltf-loader.js +196 -0
- package/dist/web-engine-hdr-loader.js +190 -0
- package/dist/web-engine-lut-cube-loader.js +122 -0
- package/dist/web-engine-mesh-bvh-webgpu.js +29 -0
- package/dist/web-engine-mesh-bvh.js +32 -0
- package/dist/web-engine-post-effects.js +168 -0
- package/dist/web-engine-runtime.js +42506 -0
- package/package.json +11 -8
- package/template-assets/autoExposure.ts +225 -0
- package/template-assets/exposure.ts +111 -0
- package/template-assets/exposureGraph.ts +178 -0
- package/template-assets/exposureReadback.ts +79 -0
- package/template-assets/patches/@tailwindcss__node@4.3.3.patch +22 -0
- package/template-assets/patches/three@0.185.1.patch +6594 -700
- package/template-assets/patches/vite@8.2.0.patch +422 -0
- package/template-assets/worldEnvironment.ts +433 -30
- package/templates/action-rpg/AGENTS.md +11 -10
- package/templates/action-rpg/CLAUDE.md +11 -10
- package/templates/action-rpg/package.json +11 -9
- package/templates/action-rpg/playtests/performance.playtest.json +7 -1
- package/templates/action-rpg/src/progress.ts +0 -4
- package/templates/action-rpg/src/render/autoExposure.ts +225 -0
- package/templates/action-rpg/src/render/backlightControls.ts +66 -0
- package/templates/action-rpg/src/render/backlightMaterial.ts +147 -0
- package/templates/action-rpg/src/render/environmentContribution.ts +188 -0
- package/templates/action-rpg/src/render/environmentRadiance.ts +36 -0
- package/templates/action-rpg/src/render/environmentSampleCache.ts +43 -0
- package/templates/action-rpg/src/render/environmentSampling.ts +193 -0
- package/templates/action-rpg/src/render/environmentSnapshot.ts +53 -0
- package/templates/action-rpg/src/render/exposure.ts +111 -0
- package/templates/action-rpg/src/render/exposureGraph.ts +178 -0
- package/templates/action-rpg/src/render/exposureReadback.ts +79 -0
- package/templates/action-rpg/src/render/heightFog.ts +118 -0
- package/templates/action-rpg/src/render/lighting.ts +26 -1
- package/templates/action-rpg/src/render/materialAssignments.ts +160 -0
- package/templates/action-rpg/src/render/materialLighting.ts +155 -0
- package/templates/action-rpg/src/render/postprocessing.ts +17 -2
- package/templates/action-rpg/src/render/quality.ts +61 -2
- package/templates/action-rpg/src/render/sky.ts +21 -1
- package/templates/action-rpg/src/render/vfx.ts +133 -58
- package/templates/action-rpg/src/render/worldEnvironment.ts +433 -30
- package/templates/action-rpg/src/scenes/Play.ts +81 -16
- package/templates/action-rpg/threenative.config.ts +3 -0
- package/templates/action-rpg/vite.config.ts +10 -2
- package/templates/minimal/AGENTS.md +9 -10
- package/templates/minimal/CLAUDE.md +9 -10
- package/templates/minimal/package.json +9 -8
- package/templates/minimal/playtests/play.playtest.json +7 -1
- package/templates/minimal/playtests/sky.playtest.json +10 -1
- package/templates/minimal/src/render/autoExposure.ts +225 -0
- package/templates/minimal/src/render/backlightControls.ts +66 -0
- package/templates/minimal/src/render/backlightMaterial.ts +147 -0
- package/templates/minimal/src/render/environmentContribution.ts +188 -0
- package/templates/minimal/src/render/environmentRadiance.ts +36 -0
- package/templates/minimal/src/render/environmentSampleCache.ts +43 -0
- package/templates/minimal/src/render/environmentSampling.ts +193 -0
- package/templates/minimal/src/render/environmentSnapshot.ts +53 -0
- package/templates/minimal/src/render/exposure.ts +111 -0
- package/templates/minimal/src/render/exposureGraph.ts +178 -0
- package/templates/minimal/src/render/exposureReadback.ts +79 -0
- package/templates/minimal/src/render/heightFog.ts +118 -0
- package/templates/minimal/src/render/lighting.ts +25 -1
- package/templates/minimal/src/render/materialAssignments.ts +102 -0
- package/templates/minimal/src/render/materialLighting.ts +146 -0
- package/templates/minimal/src/render/postprocessing.ts +16 -2
- package/templates/minimal/src/render/quality.ts +60 -2
- package/templates/minimal/src/render/sky.ts +21 -1
- package/templates/minimal/src/render/worldEnvironment.ts +433 -30
- package/templates/minimal/src/scenes/Play.ts +50 -1
- package/templates/minimal/vite.config.ts +10 -2
- package/templates/platformer/AGENTS.md +7 -5
- package/templates/platformer/CLAUDE.md +7 -5
- package/templates/platformer/package.json +11 -9
- package/templates/platformer/playtests/performance.playtest.json +7 -1
- package/templates/platformer/src/render/autoExposure.ts +225 -0
- package/templates/platformer/src/render/backlightControls.ts +66 -0
- package/templates/platformer/src/render/backlightMaterial.ts +147 -0
- package/templates/platformer/src/render/environmentContribution.ts +188 -0
- package/templates/platformer/src/render/environmentRadiance.ts +36 -0
- package/templates/platformer/src/render/environmentSampleCache.ts +43 -0
- package/templates/platformer/src/render/environmentSampling.ts +193 -0
- package/templates/platformer/src/render/environmentSnapshot.ts +53 -0
- package/templates/platformer/src/render/exposure.ts +111 -0
- package/templates/platformer/src/render/exposureGraph.ts +178 -0
- package/templates/platformer/src/render/exposureReadback.ts +79 -0
- package/templates/platformer/src/render/heightFog.ts +118 -0
- package/templates/platformer/src/render/lighting.ts +26 -1
- package/templates/platformer/src/render/materialAssignments.ts +160 -0
- package/templates/platformer/src/render/materialLighting.ts +155 -0
- package/templates/platformer/src/render/materials.ts +7 -2
- package/templates/platformer/src/render/palette.ts +3 -3
- package/templates/platformer/src/render/postprocessing.ts +17 -2
- package/templates/platformer/src/render/quality.ts +61 -2
- package/templates/platformer/src/render/sky.ts +72 -23
- package/templates/platformer/src/render/skyEnvironment.ts +50 -0
- package/templates/platformer/src/render/worldEnvironment.ts +433 -30
- package/templates/platformer/src/scenes/Play.ts +70 -6
- package/templates/platformer/vite.config.ts +10 -2
- package/templates/puzzle/AGENTS.md +10 -9
- package/templates/puzzle/CLAUDE.md +10 -9
- package/templates/puzzle/package.json +11 -9
- package/templates/puzzle/playtests/boot-failure.playtest.json +2 -2
- package/templates/puzzle/playtests/lit.playtest.json +7 -1
- package/templates/puzzle/playtests/performance.playtest.json +7 -1
- package/templates/puzzle/src/render/autoExposure.ts +225 -0
- package/templates/puzzle/src/render/backlightControls.ts +66 -0
- package/templates/puzzle/src/render/backlightMaterial.ts +147 -0
- package/templates/puzzle/src/render/environmentContribution.ts +188 -0
- package/templates/puzzle/src/render/environmentRadiance.ts +36 -0
- package/templates/puzzle/src/render/environmentSampleCache.ts +43 -0
- package/templates/puzzle/src/render/environmentSampling.ts +193 -0
- package/templates/puzzle/src/render/environmentSnapshot.ts +53 -0
- package/templates/puzzle/src/render/exposure.ts +111 -0
- package/templates/puzzle/src/render/exposureGraph.ts +178 -0
- package/templates/puzzle/src/render/exposureReadback.ts +79 -0
- package/templates/puzzle/src/render/heightFog.ts +118 -0
- package/templates/puzzle/src/render/lighting.ts +33 -1
- package/templates/puzzle/src/render/materialAssignments.ts +160 -0
- package/templates/puzzle/src/render/materialLighting.ts +155 -0
- package/templates/puzzle/src/render/materials.ts +1 -1
- package/templates/puzzle/src/render/postprocessing.ts +8 -2
- package/templates/puzzle/src/render/quality.ts +62 -1
- package/templates/puzzle/src/render/sky.ts +20 -1
- package/templates/puzzle/src/render/worldEnvironment.ts +433 -30
- package/templates/puzzle/src/scenes/Play.ts +51 -2
- package/templates/puzzle/vite.config.ts +10 -2
- package/templates/racing/AGENTS.md +8 -7
- package/templates/racing/CLAUDE.md +8 -7
- package/templates/racing/package.json +11 -9
- package/templates/racing/playtests/performance.playtest.json +7 -1
- package/templates/racing/playtests/survives.playtest.json +6 -0
- package/templates/racing/src/render/autoExposure.ts +225 -0
- package/templates/racing/src/render/backlightControls.ts +66 -0
- package/templates/racing/src/render/backlightMaterial.ts +147 -0
- package/templates/racing/src/render/environmentContribution.ts +188 -0
- package/templates/racing/src/render/environmentRadiance.ts +36 -0
- package/templates/racing/src/render/environmentSampleCache.ts +43 -0
- package/templates/racing/src/render/environmentSampling.ts +193 -0
- package/templates/racing/src/render/environmentSnapshot.ts +53 -0
- package/templates/racing/src/render/exposure.ts +111 -0
- package/templates/racing/src/render/exposureGraph.ts +178 -0
- package/templates/racing/src/render/exposureReadback.ts +79 -0
- package/templates/racing/src/render/heightFog.ts +118 -0
- package/templates/racing/src/render/lighting.ts +29 -1
- package/templates/racing/src/render/materialAssignments.ts +160 -0
- package/templates/racing/src/render/materialLighting.ts +155 -0
- package/templates/racing/src/render/palette.ts +1 -10
- package/templates/racing/src/render/postprocessing.ts +17 -2
- package/templates/racing/src/render/quality.ts +61 -2
- package/templates/racing/src/render/shapes.ts +0 -25
- package/templates/racing/src/render/sky.ts +21 -1
- package/templates/racing/src/render/worldEnvironment.ts +433 -30
- package/templates/racing/src/scenes/Race.ts +91 -3
- package/templates/racing/src/track/circuit.ts +0 -9
- package/templates/racing/vite.config.ts +10 -2
- package/templates/rain/.codex/config.toml +19 -0
- package/templates/rain/.cursor/mcp.json +32 -0
- package/templates/rain/.gemini/settings.json +32 -0
- package/templates/rain/.mcp.json +32 -0
- package/templates/rain/.vscode/mcp.json +36 -0
- package/templates/rain/.zed/settings.json +36 -0
- package/templates/rain/AGENTS.md +95 -0
- package/templates/rain/CLAUDE.md +97 -0
- package/templates/rain/assets/rain-loop.wav +0 -0
- package/templates/rain/assets/thunder.wav +0 -0
- package/templates/rain/assets/wind-loop.wav +0 -0
- package/templates/rain/index.html +18 -0
- package/templates/rain/kit.json +7 -0
- package/templates/rain/native-playtests/boot.playtest.json +23 -0
- package/templates/rain/native-playtests/lightning.playtest.json +173 -0
- package/templates/rain/opencode.json +41 -0
- package/templates/rain/package.json +59 -0
- package/templates/rain/playtests/auto-lightning-clear.playtest.json +66 -0
- package/templates/rain/playtests/auto-lightning.playtest.json +26 -0
- package/templates/rain/playtests/automation.playtest.json +133 -0
- package/templates/rain/playtests/cinematic.playtest.json +59 -0
- package/templates/rain/playtests/flash.playtest.json +27 -0
- package/templates/rain/playtests/fly.playtest.json +54 -0
- package/templates/rain/playtests/lightning.playtest.json +220 -0
- package/templates/rain/playtests/loading.playtest.json +57 -0
- package/templates/rain/playtests/paused.playtest.json +59 -0
- package/templates/rain/playtests/performance.playtest.json +32 -0
- package/templates/rain/playtests/reduced-motion.playtest.json +87 -0
- package/templates/rain/playtests/simulation.playtest.json +20 -0
- package/templates/rain/playtests/storm.playtest.json +150 -0
- package/templates/rain/playtests/survives.playtest.json +58 -0
- package/templates/rain/playtests/tiers.playtest.json +194 -0
- package/templates/rain/playtests/weather.playtest.json +77 -0
- package/templates/rain/public/favicon.svg +5 -0
- package/templates/rain/src/audio/storm.ts +314 -0
- package/templates/rain/src/game.ts +81 -0
- package/templates/rain/src/main.ts +15 -0
- package/templates/rain/src/render/autoExposure.ts +225 -0
- package/templates/rain/src/render/bloom-shader.ts +65 -0
- package/templates/rain/src/render/camera.ts +160 -0
- package/templates/rain/src/render/clouds-shader.ts +242 -0
- package/templates/rain/src/render/clouds.ts +142 -0
- package/templates/rain/src/render/exposure.ts +111 -0
- package/templates/rain/src/render/exposureGraph.ts +178 -0
- package/templates/rain/src/render/exposureReadback.ts +79 -0
- package/templates/rain/src/render/lighting.ts +39 -0
- package/templates/rain/src/render/lightning.ts +360 -0
- package/templates/rain/src/render/loading.ts +327 -0
- package/templates/rain/src/render/materials.ts +19 -0
- package/templates/rain/src/render/noise-volume.ts +159 -0
- package/templates/rain/src/render/palette.ts +18 -0
- package/templates/rain/src/render/post-shader.ts +178 -0
- package/templates/rain/src/render/postprocessing.ts +229 -0
- package/templates/rain/src/render/quality.ts +161 -0
- package/templates/rain/src/render/rain.ts +299 -0
- package/templates/rain/src/render/sky.ts +28 -0
- package/templates/rain/src/render/world-shader.ts +680 -0
- package/templates/rain/src/render/world.ts +146 -0
- package/templates/rain/src/render/worldEnvironment.ts +1212 -0
- package/templates/rain/src/scenes/Boot.ts +348 -0
- package/templates/rain/src/state.ts +261 -0
- package/templates/rain/src/style.css +1160 -0
- package/templates/rain/src/ui/App.tsx +29 -0
- package/templates/rain/src/ui/GameUi.tsx +187 -0
- package/templates/rain/src/ui/Hud.tsx +327 -0
- package/templates/rain/src/ui/LoadingOverlay.tsx +46 -0
- package/templates/rain/src/ui/Menu.tsx +370 -0
- package/templates/rain/src/ui/automation.ts +60 -0
- package/templates/rain/src/ui/main.tsx +7 -0
- package/templates/rain/src/ui/tempest.ts +149 -0
- package/templates/rain/tailwind.config.ts +2 -0
- package/templates/rain/threenative.config.ts +66 -0
- package/templates/rain/tools/generate-shaders.mjs +656 -0
- package/templates/rain/tools/make-storm-audio.mjs +387 -0
- package/templates/rain/tools/storm-dsp.mjs +177 -0
- package/templates/rain/tools/tempest-bloom.frag +10 -0
- package/templates/rain/tools/tempest-clouds.frag +86 -0
- package/templates/rain/tools/tempest-post.frag +47 -0
- package/templates/rain/tools/tempest-world.frag +210 -0
- package/templates/rain/tools/verify-noise-volume.mjs +61 -0
- package/templates/rain/tsconfig.json +17 -0
- package/templates/rain/vite.config.ts +45 -0
- package/templates/rts/AGENTS.md +10 -11
- package/templates/rts/CLAUDE.md +10 -11
- package/templates/rts/package.json +10 -8
- package/templates/rts/playtests/performance.playtest.json +7 -1
- package/templates/rts/playtests/rts-ai-attack.playtest.json +10 -1
- package/templates/rts/playtests/rts-attack.playtest.json +10 -1
- package/templates/rts/playtests/rts-build.playtest.json +10 -1
- package/templates/rts/playtests/rts-orders.playtest.json +7 -1
- package/templates/rts/playtests/rts-train.playtest.json +10 -1
- package/templates/rts/src/render/army.ts +10 -2
- package/templates/rts/src/render/autoExposure.ts +225 -0
- package/templates/rts/src/render/backlightControls.ts +66 -0
- package/templates/rts/src/render/backlightMaterial.ts +147 -0
- package/templates/rts/src/render/environmentContribution.ts +188 -0
- package/templates/rts/src/render/environmentRadiance.ts +36 -0
- package/templates/rts/src/render/environmentSampleCache.ts +43 -0
- package/templates/rts/src/render/environmentSampling.ts +193 -0
- package/templates/rts/src/render/environmentSnapshot.ts +53 -0
- package/templates/rts/src/render/exposure.ts +111 -0
- package/templates/rts/src/render/exposureGraph.ts +178 -0
- package/templates/rts/src/render/exposureReadback.ts +79 -0
- package/templates/rts/src/render/heightFog.ts +118 -0
- package/templates/rts/src/render/lighting.ts +26 -1
- package/templates/rts/src/render/materialAssignments.ts +160 -0
- package/templates/rts/src/render/materialLighting.ts +155 -0
- package/templates/rts/src/render/postprocessing.ts +8 -2
- package/templates/rts/src/render/quality.ts +61 -2
- package/templates/rts/src/render/sky.ts +21 -1
- package/templates/rts/src/render/worldEnvironment.ts +433 -30
- package/templates/rts/src/scenes/Play.ts +54 -3
- package/templates/rts/src/sim/ai.ts +0 -1
- package/templates/rts/src/sim/terrain.ts +0 -4
- package/templates/rts/vite.config.ts +10 -2
- package/templates/runner/AGENTS.md +10 -8
- package/templates/runner/CLAUDE.md +10 -8
- package/templates/runner/package.json +11 -9
- package/templates/runner/playtests/performance.playtest.json +10 -1
- package/templates/runner/src/physics.ts +0 -1
- package/templates/runner/src/render/autoExposure.ts +225 -0
- package/templates/runner/src/render/backlightControls.ts +66 -0
- package/templates/runner/src/render/backlightMaterial.ts +147 -0
- package/templates/runner/src/render/environmentContribution.ts +188 -0
- package/templates/runner/src/render/environmentRadiance.ts +36 -0
- package/templates/runner/src/render/environmentSampleCache.ts +43 -0
- package/templates/runner/src/render/environmentSampling.ts +193 -0
- package/templates/runner/src/render/environmentSnapshot.ts +53 -0
- package/templates/runner/src/render/exposure.ts +111 -0
- package/templates/runner/src/render/exposureGraph.ts +178 -0
- package/templates/runner/src/render/exposureReadback.ts +79 -0
- package/templates/runner/src/render/heightFog.ts +118 -0
- package/templates/runner/src/render/lighting.ts +26 -1
- package/templates/runner/src/render/materialAssignments.ts +160 -0
- package/templates/runner/src/render/materialLighting.ts +155 -0
- package/templates/runner/src/render/postprocessing.ts +17 -2
- package/templates/runner/src/render/quality.ts +61 -2
- package/templates/runner/src/render/sky.ts +21 -1
- package/templates/runner/src/render/worldEnvironment.ts +433 -30
- package/templates/runner/src/scenes/Run.ts +67 -2
- package/templates/runner/threenative.config.ts +3 -0
- package/templates/runner/vite.config.ts +10 -2
- package/templates/sailing/AGENTS.md +14 -13
- package/templates/sailing/CLAUDE.md +14 -13
- package/templates/sailing/native-playtests/survives.playtest.json +7 -0
- package/templates/sailing/package.json +11 -9
- package/templates/sailing/playtests/live/render-motion.playtest.json +30 -0
- package/templates/sailing/src/entities/Ship.ts +38 -18
- package/templates/sailing/src/render/autoExposure.ts +225 -0
- package/templates/sailing/src/render/backlightControls.ts +66 -0
- package/templates/sailing/src/render/backlightMaterial.ts +147 -0
- package/templates/sailing/src/render/camera.ts +12 -4
- package/templates/sailing/src/render/environmentContribution.ts +188 -0
- package/templates/sailing/src/render/environmentRadiance.ts +36 -0
- package/templates/sailing/src/render/environmentSampleCache.ts +43 -0
- package/templates/sailing/src/render/environmentSampling.ts +193 -0
- package/templates/sailing/src/render/environmentSetup.ts +24 -0
- package/templates/sailing/src/render/environmentSnapshot.ts +53 -0
- package/templates/sailing/src/render/exposure.ts +111 -0
- package/templates/sailing/src/render/exposureGraph.ts +178 -0
- package/templates/sailing/src/render/exposureReadback.ts +79 -0
- package/templates/sailing/src/render/heightFog.ts +118 -0
- package/templates/sailing/src/render/lighting.ts +26 -1
- package/templates/sailing/src/render/materialAssignments.ts +160 -0
- package/templates/sailing/src/render/materialLighting.ts +155 -0
- package/templates/sailing/src/render/ocean.ts +71 -53
- package/templates/sailing/src/render/postprocessing.ts +16 -2
- package/templates/sailing/src/render/props.ts +0 -45
- package/templates/sailing/src/render/quality.ts +61 -1
- package/templates/sailing/src/render/sky.ts +21 -1
- package/templates/sailing/src/render/worldEnvironment.ts +433 -30
- package/templates/sailing/src/scenes/Boot.ts +12 -1
- package/templates/sailing/src/scenes/Sailing.ts +87 -2
- package/templates/sailing/src/scenes/ocean-readiness.ts +68 -0
- package/templates/sailing/threenative.config.ts +3 -0
- package/templates/sailing/vite.config.ts +10 -2
- package/templates/shooter/AGENTS.md +8 -6
- package/templates/shooter/CLAUDE.md +8 -6
- package/templates/shooter/package.json +11 -9
- package/templates/shooter/playtests/performance.playtest.json +7 -1
- package/templates/shooter/src/entities/Enemy.ts +0 -15
- package/templates/shooter/src/entities/Rifle.ts +38 -1
- package/templates/shooter/src/render/autoExposure.ts +225 -0
- package/templates/shooter/src/render/backlightControls.ts +66 -0
- package/templates/shooter/src/render/backlightMaterial.ts +147 -0
- package/templates/shooter/src/render/camera.ts +1 -12
- package/templates/shooter/src/render/decals.ts +299 -5
- package/templates/shooter/src/render/environmentContribution.ts +188 -0
- package/templates/shooter/src/render/environmentRadiance.ts +36 -0
- package/templates/shooter/src/render/environmentSampleCache.ts +43 -0
- package/templates/shooter/src/render/environmentSampling.ts +193 -0
- package/templates/shooter/src/render/environmentSnapshot.ts +53 -0
- package/templates/shooter/src/render/exposure.ts +111 -0
- package/templates/shooter/src/render/exposureGraph.ts +178 -0
- package/templates/shooter/src/render/exposureReadback.ts +79 -0
- package/templates/shooter/src/render/gunfx.ts +0 -1
- package/templates/shooter/src/render/heightFog.ts +118 -0
- package/templates/shooter/src/render/lighting.ts +26 -1
- package/templates/shooter/src/render/materialAssignments.ts +160 -0
- package/templates/shooter/src/render/materialLighting.ts +155 -0
- package/templates/shooter/src/render/postprocessing.ts +17 -2
- package/templates/shooter/src/render/quality.ts +61 -2
- package/templates/shooter/src/render/scale.ts +2 -93
- package/templates/shooter/src/render/sky.ts +21 -1
- package/templates/shooter/src/render/vehicles.ts +0 -17
- package/templates/shooter/src/render/worldEnvironment.ts +433 -30
- package/templates/shooter/src/scenes/Play.ts +64 -2
- package/templates/shooter/vite.config.ts +10 -2
- package/templates/snow/.codex/config.toml +19 -0
- package/templates/snow/.cursor/mcp.json +32 -0
- package/templates/snow/.gemini/settings.json +32 -0
- package/templates/snow/.mcp.json +32 -0
- package/templates/snow/.vscode/mcp.json +36 -0
- package/templates/snow/.zed/settings.json +36 -0
- package/templates/snow/AGENTS.md +90 -0
- package/templates/snow/CLAUDE.md +92 -0
- package/templates/snow/README.md +26 -0
- package/templates/snow/assets/crunch.wav +0 -0
- package/templates/snow/assets/wind.wav +0 -0
- package/templates/snow/index.html +12 -0
- package/templates/snow/kit.json +7 -0
- package/templates/snow/native-playtests/snow-physics.playtest.json +150 -0
- package/templates/snow/native-playtests/survives.playtest.json +47 -0
- package/templates/snow/opencode.json +41 -0
- package/templates/snow/package.json +60 -0
- package/templates/snow/playtests/footsteps.playtest.json +95 -0
- package/templates/snow/playtests/performance.playtest.json +36 -0
- package/templates/snow/playtests/snow-physics.playtest.json +154 -0
- package/templates/snow/playtests/survives.playtest.json +56 -0
- package/templates/snow/playtests/touch-controls.playtest.json +71 -0
- package/templates/snow/playtests/weather.playtest.json +119 -0
- package/templates/snow/public/favicon.svg +5 -0
- package/templates/snow/src/audio.ts +58 -0
- package/templates/snow/src/commands.ts +8 -0
- package/templates/snow/src/entities/Explorer.ts +279 -0
- package/templates/snow/src/game.ts +69 -0
- package/templates/snow/src/main.ts +15 -0
- package/templates/snow/src/render/autoExposure.ts +225 -0
- package/templates/snow/src/render/backlightControls.ts +66 -0
- package/templates/snow/src/render/backlightMaterial.ts +147 -0
- package/templates/snow/src/render/bootPrint.ts +50 -0
- package/templates/snow/src/render/camera.ts +84 -0
- package/templates/snow/src/render/environmentContribution.ts +188 -0
- package/templates/snow/src/render/environmentRadiance.ts +36 -0
- package/templates/snow/src/render/environmentSampleCache.ts +43 -0
- package/templates/snow/src/render/environmentSampling.ts +193 -0
- package/templates/snow/src/render/environmentSnapshot.ts +53 -0
- package/templates/snow/src/render/explorer.ts +321 -0
- package/templates/snow/src/render/exposure.ts +111 -0
- package/templates/snow/src/render/exposureGraph.ts +178 -0
- package/templates/snow/src/render/exposureReadback.ts +79 -0
- package/templates/snow/src/render/heightFog.ts +118 -0
- package/templates/snow/src/render/lighting.ts +82 -0
- package/templates/snow/src/render/loading.ts +325 -0
- package/templates/snow/src/render/materialAssignments.ts +160 -0
- package/templates/snow/src/render/materialLighting.ts +155 -0
- package/templates/snow/src/render/materials.ts +36 -0
- package/templates/snow/src/render/palette.ts +17 -0
- package/templates/snow/src/render/postprocessing.ts +58 -0
- package/templates/snow/src/render/props.ts +42 -0
- package/templates/snow/src/render/quality.ts +193 -0
- package/templates/snow/src/render/scenery.ts +244 -0
- package/templates/snow/src/render/sky.ts +76 -0
- package/templates/snow/src/render/snowSurface.ts +259 -0
- package/templates/snow/src/render/touch-controls.ts +143 -0
- package/templates/snow/src/render/weather.ts +279 -0
- package/templates/snow/src/render/worldEnvironment.ts +1212 -0
- package/templates/snow/src/scenes/Boot.ts +12 -0
- package/templates/snow/src/scenes/Snow.ts +663 -0
- package/templates/snow/src/state.ts +46 -0
- package/templates/snow/src/style.css +143 -0
- package/templates/snow/src/terrain.ts +64 -0
- package/templates/snow/src/ui/App.tsx +15 -0
- package/templates/snow/src/ui/Controls.tsx +322 -0
- package/templates/snow/src/ui/GameUi.tsx +354 -0
- package/templates/snow/src/ui/icons.tsx +54 -0
- package/templates/snow/src/ui/main.tsx +7 -0
- package/templates/snow/tailwind.config.ts +2 -0
- package/templates/snow/threenative.config.ts +54 -0
- package/templates/snow/tsconfig.json +17 -0
- package/templates/snow/vite.config.ts +45 -0
- package/templates/starter/AGENTS.md +11 -16
- package/templates/starter/CLAUDE.md +11 -16
- package/templates/starter/native-playtests/react-hud.playtest.json +1 -1
- package/templates/starter/native-playtests/render-chain.playtest.json +51 -8
- package/templates/starter/native-playtests/smooth-motion.playtest.json +64 -0
- package/templates/starter/package.json +11 -9
- package/templates/starter/playtests/live/smooth-motion.playtest.json +63 -0
- package/templates/starter/playtests/movement.playtest.json +192 -0
- package/templates/starter/playtests/play.playtest.json +18 -2
- package/templates/starter/playtests/production-readiness.playtest.json +1 -1
- package/templates/starter/public/grade.cube +735 -0
- package/templates/starter/src/entities/Crate.ts +4 -0
- package/templates/starter/src/entities/Player.ts +79 -18
- package/templates/starter/src/game.ts +1 -0
- package/templates/starter/src/render/adaptiveQuality.ts +28 -41
- package/templates/starter/src/render/autoExposure.ts +225 -0
- package/templates/starter/src/render/backlightControls.ts +66 -0
- package/templates/starter/src/render/backlightMaterial.ts +147 -0
- package/templates/starter/src/render/environmentContribution.ts +188 -0
- package/templates/starter/src/render/environmentRadiance.ts +36 -0
- package/templates/starter/src/render/environmentSampleCache.ts +43 -0
- package/templates/starter/src/render/environmentSampling.ts +193 -0
- package/templates/starter/src/render/environmentSnapshot.ts +53 -0
- package/templates/starter/src/render/exposure.ts +111 -0
- package/templates/starter/src/render/exposureGraph.ts +178 -0
- package/templates/starter/src/render/exposureReadback.ts +79 -0
- package/templates/starter/src/render/grade.ts +157 -0
- package/templates/starter/src/render/heightFog.ts +118 -0
- package/templates/starter/src/render/lighting.ts +26 -1
- package/templates/starter/src/render/materialAssignments.ts +160 -0
- package/templates/starter/src/render/materialLighting.ts +155 -0
- package/templates/starter/src/render/postprocessing.ts +84 -4
- package/templates/starter/src/render/quality.ts +80 -8
- package/templates/starter/src/render/qualityPolicy.ts +54 -0
- package/templates/starter/src/render/rendererGate.ts +36 -0
- package/templates/starter/src/render/sky.ts +23 -1
- package/templates/starter/src/render/temporalAA.ts +197 -0
- package/templates/starter/src/render/temporalAAFrame.ts +179 -0
- package/templates/starter/src/render/temporalAAHooks.ts +101 -0
- package/templates/starter/src/render/temporalAAInput.ts +56 -0
- package/templates/starter/src/render/temporalAAResolve.ts +65 -0
- package/templates/starter/src/render/temporalAAStage.ts +76 -0
- package/templates/starter/src/render/temporalCurrentArea.ts +31 -0
- package/templates/starter/src/render/temporalCurrentFootprint.ts +198 -0
- package/templates/starter/src/render/temporalCurrentFootprintMath.ts +41 -0
- package/templates/starter/src/render/temporalCurrentProducer.ts +161 -0
- package/templates/starter/src/render/temporalCurrentReplay.ts +160 -0
- package/templates/starter/src/render/temporalCurrentSelection.ts +89 -0
- package/templates/starter/src/render/temporalCurrentVisibility.ts +170 -0
- package/templates/starter/src/render/temporalDepthSamples.ts +34 -0
- package/templates/starter/src/render/temporalRejectionCounter.ts +179 -0
- package/templates/starter/src/render/temporalResolve.ts +139 -0
- package/templates/starter/src/render/temporalResolveDepth.ts +193 -0
- package/templates/starter/src/render/temporalResolveMath.ts +196 -0
- package/templates/starter/src/render/volumetricFog.ts +124 -0
- package/templates/starter/src/render/volumetricFogOptions.ts +96 -0
- package/templates/starter/src/render/volumetricFogTransport.ts +176 -0
- package/templates/starter/src/render/volumetricFogVolume.ts +139 -0
- package/templates/starter/src/render/worldEnvironment.ts +433 -30
- package/templates/starter/src/scenes/Play.ts +110 -1
- package/templates/starter/src/state.ts +1 -0
- package/templates/starter/src/ui/Hud.tsx +1 -1
- package/templates/starter/src/ui/Menu.tsx +1 -1
- package/templates/starter/tools/make-grade-lut.mjs +101 -0
- package/templates/starter/vite.config.ts +10 -2
- package/templates/tower-defense/AGENTS.md +10 -9
- package/templates/tower-defense/CLAUDE.md +10 -9
- package/templates/tower-defense/package.json +11 -9
- package/templates/tower-defense/playtests/performance.playtest.json +7 -1
- package/templates/tower-defense/src/render/autoExposure.ts +225 -0
- package/templates/tower-defense/src/render/backlightControls.ts +66 -0
- package/templates/tower-defense/src/render/backlightMaterial.ts +147 -0
- package/templates/tower-defense/src/render/environmentContribution.ts +188 -0
- package/templates/tower-defense/src/render/environmentRadiance.ts +36 -0
- package/templates/tower-defense/src/render/environmentSampleCache.ts +43 -0
- package/templates/tower-defense/src/render/environmentSampling.ts +193 -0
- package/templates/tower-defense/src/render/environmentSnapshot.ts +53 -0
- package/templates/tower-defense/src/render/exposure.ts +111 -0
- package/templates/tower-defense/src/render/exposureGraph.ts +178 -0
- package/templates/tower-defense/src/render/exposureReadback.ts +79 -0
- package/templates/tower-defense/src/render/lighting.ts +33 -1
- package/templates/tower-defense/src/render/materialAssignments.ts +160 -0
- package/templates/tower-defense/src/render/materialLighting.ts +155 -0
- package/templates/tower-defense/src/render/postprocessing.ts +8 -2
- package/templates/tower-defense/src/render/quality.ts +61 -2
- package/templates/tower-defense/src/render/shapes.ts +0 -3
- package/templates/tower-defense/src/render/worldEnvironment.ts +433 -30
- package/templates/tower-defense/src/scenes/Battle.ts +65 -2
- package/templates/tower-defense/vite.config.ts +10 -2
- package/templates/minimal/src/scenes/Boot.ts +0 -5
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { spawn } from 'child_process';
|
|
4
4
|
import { existsSync, realpathSync, readdirSync, readFileSync, rmSync, mkdirSync, writeFileSync } from 'fs';
|
|
5
|
-
import { mkdir, cp, rename, readFile, readdir, writeFile, symlink, access, unlink, stat } from 'fs/promises';
|
|
6
|
-
import
|
|
5
|
+
import { mkdir, cp, rename, readFile, readdir, writeFile, rm, symlink, access, unlink, stat } from 'fs/promises';
|
|
6
|
+
import path6 from 'path';
|
|
7
7
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
8
8
|
import { LoadingManager, Box3, Vector3 } from 'three';
|
|
9
9
|
import { createHash } from 'crypto';
|
|
@@ -86,10 +86,10 @@ function localResourcePath(baseDirectory, uri) {
|
|
|
86
86
|
} catch (error) {
|
|
87
87
|
throw new Error(`Invalid glTF resource URI "${uri}": ${String(error)}`);
|
|
88
88
|
}
|
|
89
|
-
return
|
|
89
|
+
return path6.resolve(baseDirectory, decoded);
|
|
90
90
|
}
|
|
91
91
|
function resourceMimeType(resourcePath, declared) {
|
|
92
|
-
return declared ?? RESOURCE_MIME_TYPES[
|
|
92
|
+
return declared ?? RESOURCE_MIME_TYPES[path6.extname(resourcePath).toLowerCase()] ?? "application/octet-stream";
|
|
93
93
|
}
|
|
94
94
|
function gltfResourceReferences(document) {
|
|
95
95
|
const references = [];
|
|
@@ -118,10 +118,10 @@ async function readLocalResources(baseDirectory, references) {
|
|
|
118
118
|
return resources;
|
|
119
119
|
}
|
|
120
120
|
async function localResourceResolver(file, data) {
|
|
121
|
-
if (
|
|
121
|
+
if (path6.extname(file).toLowerCase() !== ".gltf") return (url) => url;
|
|
122
122
|
const document = JSON.parse(data.toString("utf8"));
|
|
123
123
|
const references = gltfResourceReferences(document);
|
|
124
|
-
const baseDirectory =
|
|
124
|
+
const baseDirectory = path6.dirname(path6.resolve(file));
|
|
125
125
|
const resources = await readLocalResources(baseDirectory, references);
|
|
126
126
|
return (url) => {
|
|
127
127
|
const resourcePath = localResourcePath(baseDirectory, url);
|
|
@@ -135,11 +135,11 @@ async function parseGltfAsset(file, data) {
|
|
|
135
135
|
const manager = new LoadingManager();
|
|
136
136
|
manager.setURLModifier(await localResourceResolver(file, data));
|
|
137
137
|
const loader = new GLTFLoader(manager);
|
|
138
|
-
const extension =
|
|
138
|
+
const extension = path6.extname(file).toLowerCase();
|
|
139
139
|
const payload = extension === ".gltf" ? data.toString("utf8") : data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
140
140
|
const parsed = await loader.parseAsync(
|
|
141
141
|
payload,
|
|
142
|
-
`${
|
|
142
|
+
`${path6.dirname(path6.resolve(file))}${path6.sep}`
|
|
143
143
|
);
|
|
144
144
|
const json = parsed.parser.json;
|
|
145
145
|
return {
|
|
@@ -199,11 +199,11 @@ function inspectScene(file, scene, animations, resourceCounts) {
|
|
|
199
199
|
bounds,
|
|
200
200
|
bones: resources.bones,
|
|
201
201
|
clips: animations.map((clip) => clip.name || "(unnamed)"),
|
|
202
|
-
file:
|
|
202
|
+
file: path6.basename(file),
|
|
203
203
|
forwardAxis: largest === void 0 ? { axis: "unknown", basis: "none", direction: "unknown" } : { axis: largest.axis, basis: "longest geometry axis", direction: "unknown" },
|
|
204
204
|
materials: resourceCounts.materials ?? resources.materials,
|
|
205
205
|
meshes: resourceCounts.meshes ?? resources.meshes,
|
|
206
|
-
path:
|
|
206
|
+
path: path6.resolve(file),
|
|
207
207
|
textures: resourceCounts.textures ?? resources.textures,
|
|
208
208
|
units: {
|
|
209
209
|
label: unitsLabel(largest?.value ?? 0),
|
|
@@ -232,7 +232,7 @@ function parseInspectArgs(argv) {
|
|
|
232
232
|
return { file, json: argv.includes("--json") };
|
|
233
233
|
}
|
|
234
234
|
async function inspectAsset(file) {
|
|
235
|
-
const extension =
|
|
235
|
+
const extension = path6.extname(file).toLowerCase();
|
|
236
236
|
if (!SUPPORTED_EXTENSIONS.has(extension)) {
|
|
237
237
|
throw new Error(`TN_ASSET_INSPECT_UNSUPPORTED: ${file}: expected a .glb or .gltf file.`);
|
|
238
238
|
}
|
|
@@ -396,23 +396,23 @@ var DECODER_LIB_ASSET_URL = /new URL\(\s*(['"])\.\.\/libs\/([^'"]+)\1\s*,\s*impo
|
|
|
396
396
|
function rewriteDecoderAssetUrls(code) {
|
|
397
397
|
return code.replace(DECODER_LIB_ASSET_URL, '"../libs/$2"');
|
|
398
398
|
}
|
|
399
|
-
var MARKER_RELATIVE =
|
|
399
|
+
var MARKER_RELATIVE = path6.join("node_modules", ".vite", "threenative-engine-build.json");
|
|
400
400
|
function hashTree(hash, directory) {
|
|
401
401
|
const entries = readdirSync(directory, { withFileTypes: true }).sort(
|
|
402
402
|
(left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0
|
|
403
403
|
);
|
|
404
404
|
for (const entry of entries) {
|
|
405
|
-
const full =
|
|
405
|
+
const full = path6.join(directory, entry.name);
|
|
406
406
|
if (entry.isDirectory()) {
|
|
407
407
|
hashTree(hash, full);
|
|
408
408
|
} else if (entry.isFile()) {
|
|
409
|
-
hash.update(
|
|
409
|
+
hash.update(path6.relative(directory, full));
|
|
410
410
|
hash.update(readFileSync(full));
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
function hashEngineDist(projectRoot) {
|
|
415
|
-
const scopeDir =
|
|
415
|
+
const scopeDir = path6.join(projectRoot, "node_modules", "@threenative");
|
|
416
416
|
let packages;
|
|
417
417
|
try {
|
|
418
418
|
packages = readdirSync(scopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => entry.name).sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
|
|
@@ -421,13 +421,13 @@ function hashEngineDist(projectRoot) {
|
|
|
421
421
|
}
|
|
422
422
|
const dists = [];
|
|
423
423
|
for (const name of packages) {
|
|
424
|
-
let packageDir =
|
|
424
|
+
let packageDir = path6.join(scopeDir, name);
|
|
425
425
|
try {
|
|
426
426
|
packageDir = realpathSync(packageDir);
|
|
427
427
|
} catch {
|
|
428
428
|
continue;
|
|
429
429
|
}
|
|
430
|
-
const dist =
|
|
430
|
+
const dist = path6.join(packageDir, "dist");
|
|
431
431
|
if (existsSync(dist)) dists.push([name, dist]);
|
|
432
432
|
}
|
|
433
433
|
if (dists.length === 0) return void 0;
|
|
@@ -439,7 +439,7 @@ function hashEngineDist(projectRoot) {
|
|
|
439
439
|
return hash.digest("hex");
|
|
440
440
|
}
|
|
441
441
|
function markerPath(projectRoot) {
|
|
442
|
-
return
|
|
442
|
+
return path6.join(projectRoot, MARKER_RELATIVE);
|
|
443
443
|
}
|
|
444
444
|
function readMarker(file) {
|
|
445
445
|
try {
|
|
@@ -459,7 +459,7 @@ function processIsAlive(pid) {
|
|
|
459
459
|
}
|
|
460
460
|
function createEngineFreshnessPlugin() {
|
|
461
461
|
let recordedHash;
|
|
462
|
-
const rootOf = (config) =>
|
|
462
|
+
const rootOf = (config) => path6.resolve(config.root ?? process.cwd());
|
|
463
463
|
return {
|
|
464
464
|
name: "threenative-engine-freshness",
|
|
465
465
|
config(config, env) {
|
|
@@ -491,7 +491,7 @@ function createEngineFreshnessPlugin() {
|
|
|
491
491
|
const writeBootMarker = (port) => {
|
|
492
492
|
const hash = recordedHash ?? hashEngineDist(root);
|
|
493
493
|
if (hash === void 0) return;
|
|
494
|
-
mkdirSync(
|
|
494
|
+
mkdirSync(path6.dirname(file), { recursive: true });
|
|
495
495
|
writeFileSync(
|
|
496
496
|
file,
|
|
497
497
|
JSON.stringify(
|
|
@@ -591,13 +591,13 @@ function defaultAppId(name) {
|
|
|
591
591
|
return `com.threenative.${segment}`;
|
|
592
592
|
}
|
|
593
593
|
function projectRequire(cwd) {
|
|
594
|
-
return createRequire$1(
|
|
594
|
+
return createRequire$1(path6.join(cwd, "package.json"));
|
|
595
595
|
}
|
|
596
596
|
function configLoaderSearch(cwd) {
|
|
597
597
|
return [
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
598
|
+
path6.join(cwd, "node_modules", "vite"),
|
|
599
|
+
path6.join(cwd, "node_modules", "esbuild"),
|
|
600
|
+
path6.resolve(path6.dirname(fileURLToPath(import.meta.url)), "..", "node_modules", "esbuild")
|
|
601
601
|
];
|
|
602
602
|
}
|
|
603
603
|
var CONFIG_BUILD_COMMAND = "pnpm exec threenative build --target web";
|
|
@@ -605,7 +605,7 @@ function configContext(cwd, layer, sources, searched, fix) {
|
|
|
605
605
|
return { cwd, fix, layer, searched, sources };
|
|
606
606
|
}
|
|
607
607
|
function packageContext(cwd) {
|
|
608
|
-
const packagePath =
|
|
608
|
+
const packagePath = path6.join(cwd, "package.json");
|
|
609
609
|
return configContext(
|
|
610
610
|
cwd,
|
|
611
611
|
"package manifest",
|
|
@@ -628,8 +628,8 @@ function validationContext(cwd, sources) {
|
|
|
628
628
|
cwd,
|
|
629
629
|
"config validation",
|
|
630
630
|
sources,
|
|
631
|
-
[
|
|
632
|
-
`fix '${
|
|
631
|
+
[path6.join(cwd, "package.json"), path6.join(cwd, CONFIG_FILE)],
|
|
632
|
+
`fix '${path6.join(cwd, CONFIG_FILE)}' and rerun ${CONFIG_BUILD_COMMAND}`
|
|
633
633
|
);
|
|
634
634
|
}
|
|
635
635
|
function configFailure(code, context, detail) {
|
|
@@ -669,7 +669,7 @@ function resolveEsbuild(cwd) {
|
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
671
|
async function importConfig(cwd) {
|
|
672
|
-
const sourcePath =
|
|
672
|
+
const sourcePath = path6.join(cwd, CONFIG_FILE);
|
|
673
673
|
try {
|
|
674
674
|
await access(sourcePath);
|
|
675
675
|
} catch {
|
|
@@ -730,7 +730,7 @@ async function importConfig(cwd) {
|
|
|
730
730
|
error instanceof Error ? error.message : String(error)
|
|
731
731
|
);
|
|
732
732
|
}
|
|
733
|
-
const compiledPath =
|
|
733
|
+
const compiledPath = path6.join(cwd, `.threenative.config.${process.pid}.${Date.now()}.mjs`);
|
|
734
734
|
try {
|
|
735
735
|
await writeFile(compiledPath, code, "utf8");
|
|
736
736
|
} catch (error) {
|
|
@@ -766,7 +766,7 @@ async function importConfig(cwd) {
|
|
|
766
766
|
async function readManifest(cwd) {
|
|
767
767
|
let parsed;
|
|
768
768
|
try {
|
|
769
|
-
parsed = JSON.parse(await readFile(
|
|
769
|
+
parsed = JSON.parse(await readFile(path6.join(cwd, "package.json"), "utf8"));
|
|
770
770
|
} catch (error) {
|
|
771
771
|
fail("TN_CONFIG_PACKAGE_INVALID", error instanceof Error ? error.message : String(error));
|
|
772
772
|
}
|
|
@@ -785,12 +785,12 @@ function packageNativeEntry(manifest) {
|
|
|
785
785
|
}
|
|
786
786
|
function validateNativeEntry(value, cwd) {
|
|
787
787
|
const entry = nonEmptyString(value, "TN_NATIVE_ENTRY_MISSING", "nativeEntry");
|
|
788
|
-
if (
|
|
788
|
+
if (path6.isAbsolute(entry)) {
|
|
789
789
|
fail("TN_CONFIG_NATIVE_ENTRY_INVALID", "nativeEntry must be project-relative.");
|
|
790
790
|
}
|
|
791
|
-
const resolved =
|
|
792
|
-
const relative =
|
|
793
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
791
|
+
const resolved = path6.resolve(cwd, entry);
|
|
792
|
+
const relative = path6.relative(cwd, resolved);
|
|
793
|
+
if (relative === ".." || relative.startsWith(`..${path6.sep}`) || path6.isAbsolute(relative)) {
|
|
794
794
|
fail("TN_CONFIG_NATIVE_ENTRY_INVALID", "nativeEntry must stay inside the project.");
|
|
795
795
|
}
|
|
796
796
|
return entry;
|
|
@@ -834,18 +834,18 @@ async function validateApp(raw, name, cwd) {
|
|
|
834
834
|
}
|
|
835
835
|
async function validateProjectAsset(raw, cwd, label, options) {
|
|
836
836
|
const relative = nonEmptyString(raw, `${options.codePrefix}_INVALID`, label);
|
|
837
|
-
if (
|
|
837
|
+
if (path6.isAbsolute(relative)) {
|
|
838
838
|
fail(`${options.codePrefix}_PATH_INVALID`, `${label} must be project-relative: ${relative}`);
|
|
839
839
|
}
|
|
840
|
-
const resolved =
|
|
841
|
-
const withinProject =
|
|
842
|
-
if (withinProject === ".." || withinProject.startsWith(`..${
|
|
840
|
+
const resolved = path6.resolve(cwd, relative);
|
|
841
|
+
const withinProject = path6.relative(cwd, resolved);
|
|
842
|
+
if (withinProject === ".." || withinProject.startsWith(`..${path6.sep}`) || path6.isAbsolute(withinProject)) {
|
|
843
843
|
fail(
|
|
844
844
|
`${options.codePrefix}_PATH_INVALID`,
|
|
845
845
|
`${label} must stay inside the project: ${relative}`
|
|
846
846
|
);
|
|
847
847
|
}
|
|
848
|
-
const extension =
|
|
848
|
+
const extension = path6.extname(relative).slice(1).toLowerCase();
|
|
849
849
|
if (!options.formats.includes(extension)) {
|
|
850
850
|
fail(
|
|
851
851
|
options.codePrefix === "TN_CONFIG_ICON" ? `${options.codePrefix}_INVALID` : `${options.codePrefix}_FORMAT_INVALID`,
|
|
@@ -1065,13 +1065,23 @@ async function validateBootSplash(raw, cwd) {
|
|
|
1065
1065
|
...image === void 0 ? {} : { image }
|
|
1066
1066
|
};
|
|
1067
1067
|
}
|
|
1068
|
-
|
|
1068
|
+
function validateEngine(raw) {
|
|
1069
|
+
if (raw === void 0) return "threenative";
|
|
1070
|
+
if (raw === "threejs" || raw === "threenative") return raw;
|
|
1071
|
+
if (raw === "native" || raw === "legacy")
|
|
1072
|
+
return fail(
|
|
1073
|
+
"TN_CONFIG_ENGINE_RENAMED",
|
|
1074
|
+
`engine "${raw}" was renamed: use "${raw === "native" ? "threenative" : "threejs"}".`
|
|
1075
|
+
);
|
|
1076
|
+
return fail("TN_CONFIG_ENGINE_INVALID", 'engine must be "threenative" or "threejs".');
|
|
1077
|
+
}
|
|
1078
|
+
var UI_RENDERERS = ["native", "native-css", "web"];
|
|
1069
1079
|
function validateUi(raw) {
|
|
1070
1080
|
const ui = assertRecord(raw, "ui");
|
|
1071
1081
|
assertKeys(ui, "ui", ["renderer"]);
|
|
1072
1082
|
const renderer = ui.renderer === void 0 ? "web" : ui.renderer;
|
|
1073
1083
|
if (typeof renderer !== "string" || !UI_RENDERERS.includes(renderer)) {
|
|
1074
|
-
fail("TN_CONFIG_UI_RENDERER_INVALID", "ui.renderer must be web or native.");
|
|
1084
|
+
fail("TN_CONFIG_UI_RENDERER_INVALID", "ui.renderer must be web, native or native-css.");
|
|
1075
1085
|
}
|
|
1076
1086
|
return { renderer };
|
|
1077
1087
|
}
|
|
@@ -1200,6 +1210,17 @@ function textureQuality(value, label) {
|
|
|
1200
1210
|
return value;
|
|
1201
1211
|
}
|
|
1202
1212
|
function textureMaxSize(value) {
|
|
1213
|
+
if (isRecord(value))
|
|
1214
|
+
return Object.fromEntries(
|
|
1215
|
+
Object.entries(value).map(([slot, cap]) => {
|
|
1216
|
+
if (!/^[a-z][a-zA-Z]*Texture$/u.test(slot) || typeof cap !== "number" || !Number.isSafeInteger(cap) || cap < 4)
|
|
1217
|
+
fail(
|
|
1218
|
+
"TN_CONFIG_ASSETS_INVALID",
|
|
1219
|
+
`assets.textures.maxSize.${slot} must name a glTF texture slot with a positive integer cap of at least 4.`
|
|
1220
|
+
);
|
|
1221
|
+
return [slot, cap];
|
|
1222
|
+
})
|
|
1223
|
+
);
|
|
1203
1224
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 4) {
|
|
1204
1225
|
fail(
|
|
1205
1226
|
"TN_CONFIG_ASSETS_INVALID",
|
|
@@ -1253,7 +1274,37 @@ function validateTextures(raw) {
|
|
|
1253
1274
|
...textures.overrides === void 0 ? {} : { overrides: validateTextureOverrides(textures.overrides) }
|
|
1254
1275
|
};
|
|
1255
1276
|
}
|
|
1256
|
-
var
|
|
1277
|
+
var ASSETS_CONFIG_KEYS = [
|
|
1278
|
+
"audio",
|
|
1279
|
+
"budget",
|
|
1280
|
+
"exclude",
|
|
1281
|
+
"concurrency",
|
|
1282
|
+
"lod",
|
|
1283
|
+
"models",
|
|
1284
|
+
"nativePackage",
|
|
1285
|
+
"source",
|
|
1286
|
+
"output",
|
|
1287
|
+
"targets",
|
|
1288
|
+
"textures"
|
|
1289
|
+
];
|
|
1290
|
+
var MODELS_CONFIG_KEYS = [
|
|
1291
|
+
"compact",
|
|
1292
|
+
"lightmap",
|
|
1293
|
+
"passes",
|
|
1294
|
+
"quantize",
|
|
1295
|
+
"sharedImages",
|
|
1296
|
+
"simplify",
|
|
1297
|
+
"textures",
|
|
1298
|
+
"virtual"
|
|
1299
|
+
];
|
|
1300
|
+
var LIGHTMAP_CONFIG_KEYS = ["atlasSize", "padding"];
|
|
1301
|
+
var MODEL_PASS_KEYS = [
|
|
1302
|
+
"dedup",
|
|
1303
|
+
"meshopt",
|
|
1304
|
+
"prune",
|
|
1305
|
+
"quantize",
|
|
1306
|
+
"reorder"
|
|
1307
|
+
];
|
|
1257
1308
|
var MODEL_QUANTIZE_KEYS = ["normalBits", "positionBits", "uvBits"];
|
|
1258
1309
|
var MODEL_VIRTUAL_KEYS = [
|
|
1259
1310
|
"groupSize",
|
|
@@ -1271,16 +1322,7 @@ function bitDepth(value, label) {
|
|
|
1271
1322
|
function validateModels(raw) {
|
|
1272
1323
|
if (raw === "none") return "none";
|
|
1273
1324
|
const models = assertRecord(raw, "assets.models");
|
|
1274
|
-
assertKeys(models, "assets.models",
|
|
1275
|
-
"compact",
|
|
1276
|
-
"lightmap",
|
|
1277
|
-
"passes",
|
|
1278
|
-
"quantize",
|
|
1279
|
-
"sharedImages",
|
|
1280
|
-
"simplify",
|
|
1281
|
-
"textures",
|
|
1282
|
-
"virtual"
|
|
1283
|
-
]);
|
|
1325
|
+
assertKeys(models, "assets.models", MODELS_CONFIG_KEYS);
|
|
1284
1326
|
if (models.sharedImages !== void 0 && typeof models.sharedImages !== "boolean") {
|
|
1285
1327
|
fail("TN_CONFIG_ASSETS_INVALID", "assets.models.sharedImages must be true or false.");
|
|
1286
1328
|
}
|
|
@@ -1288,17 +1330,21 @@ function validateModels(raw) {
|
|
|
1288
1330
|
let lightmap;
|
|
1289
1331
|
if (models.lightmap !== void 0) {
|
|
1290
1332
|
const rawLightmap = assertRecord(models.lightmap, "assets.models.lightmap");
|
|
1291
|
-
assertKeys(rawLightmap, "assets.models.lightmap",
|
|
1333
|
+
assertKeys(rawLightmap, "assets.models.lightmap", LIGHTMAP_CONFIG_KEYS);
|
|
1292
1334
|
if (rawLightmap.atlasSize === void 0 || rawLightmap.padding === void 0) {
|
|
1293
1335
|
fail("TN_CONFIG_ASSETS_INVALID", "assets.models.lightmap requires atlasSize and padding.");
|
|
1294
1336
|
}
|
|
1337
|
+
const atlasSize = positiveInteger(
|
|
1338
|
+
rawLightmap.atlasSize,
|
|
1339
|
+
1,
|
|
1340
|
+
"TN_CONFIG_ASSETS_INVALID",
|
|
1341
|
+
"assets.models.lightmap.atlasSize"
|
|
1342
|
+
);
|
|
1343
|
+
if (atlasSize % 4 !== 0) {
|
|
1344
|
+
fail("TN_CONFIG_ASSETS_INVALID", "assets.models.lightmap.atlasSize must be a multiple of 4.");
|
|
1345
|
+
}
|
|
1295
1346
|
lightmap = {
|
|
1296
|
-
atlasSize
|
|
1297
|
-
rawLightmap.atlasSize,
|
|
1298
|
-
1,
|
|
1299
|
-
"TN_CONFIG_ASSETS_INVALID",
|
|
1300
|
-
"assets.models.lightmap.atlasSize"
|
|
1301
|
-
),
|
|
1347
|
+
atlasSize,
|
|
1302
1348
|
padding: positiveInteger(
|
|
1303
1349
|
rawLightmap.padding,
|
|
1304
1350
|
1,
|
|
@@ -1549,18 +1595,7 @@ function validateAudio(raw) {
|
|
|
1549
1595
|
}
|
|
1550
1596
|
function validateAssets(raw) {
|
|
1551
1597
|
const assets = assertRecord(raw, "assets");
|
|
1552
|
-
assertKeys(assets, "assets",
|
|
1553
|
-
"audio",
|
|
1554
|
-
"budget",
|
|
1555
|
-
"exclude",
|
|
1556
|
-
"concurrency",
|
|
1557
|
-
"lod",
|
|
1558
|
-
"models",
|
|
1559
|
-
"source",
|
|
1560
|
-
"output",
|
|
1561
|
-
"targets",
|
|
1562
|
-
"textures"
|
|
1563
|
-
]);
|
|
1598
|
+
assertKeys(assets, "assets", ASSETS_CONFIG_KEYS);
|
|
1564
1599
|
const targets = assets.targets === void 0 ? void 0 : validateAssetTargets(assets.targets);
|
|
1565
1600
|
const lod = assets.lod === void 0 ? void 0 : validateLod(assets.lod);
|
|
1566
1601
|
const models = assets.models === void 0 ? void 0 : validateModels(assets.models);
|
|
@@ -1568,6 +1603,9 @@ function validateAssets(raw) {
|
|
|
1568
1603
|
if (assets.exclude !== void 0 && (!Array.isArray(assets.exclude) || assets.exclude.some((glob) => typeof glob !== "string" || glob.trim() === ""))) {
|
|
1569
1604
|
fail("TN_CONFIG_ASSETS_INVALID", "assets.exclude must be an array of non-empty glob strings.");
|
|
1570
1605
|
}
|
|
1606
|
+
if (assets.nativePackage !== void 0 && typeof assets.nativePackage !== "boolean") {
|
|
1607
|
+
fail("TN_CONFIG_ASSETS_INVALID", "assets.nativePackage must be true or false.");
|
|
1608
|
+
}
|
|
1571
1609
|
return {
|
|
1572
1610
|
...assets.audio === void 0 ? {} : { audio: validateAudio(assets.audio) },
|
|
1573
1611
|
...assets.exclude === void 0 ? {} : { exclude: assets.exclude },
|
|
@@ -1588,6 +1626,7 @@ function validateAssets(raw) {
|
|
|
1588
1626
|
...targets === void 0 ? {} : { targets },
|
|
1589
1627
|
...lod === void 0 ? {} : { lod },
|
|
1590
1628
|
...models === void 0 ? {} : { models },
|
|
1629
|
+
...assets.nativePackage === void 0 ? {} : { nativePackage: assets.nativePackage },
|
|
1591
1630
|
...textures === void 0 ? {} : { textures }
|
|
1592
1631
|
};
|
|
1593
1632
|
}
|
|
@@ -1597,6 +1636,7 @@ var PROFILE_ASSET_KEYS = [
|
|
|
1597
1636
|
"budget",
|
|
1598
1637
|
"lod",
|
|
1599
1638
|
"models",
|
|
1639
|
+
"nativePackage",
|
|
1600
1640
|
"targets",
|
|
1601
1641
|
"textures"
|
|
1602
1642
|
];
|
|
@@ -1795,8 +1835,8 @@ function assertProfileCapReachable(assets, overlay, name) {
|
|
|
1795
1835
|
}
|
|
1796
1836
|
}
|
|
1797
1837
|
async function loadConfigInternal(root, selection) {
|
|
1798
|
-
const packagePath =
|
|
1799
|
-
const sourcePath =
|
|
1838
|
+
const packagePath = path6.join(root, "package.json");
|
|
1839
|
+
const sourcePath = path6.join(root, CONFIG_FILE);
|
|
1800
1840
|
const manifest = await withConfigContext(
|
|
1801
1841
|
packageContext(root),
|
|
1802
1842
|
"TN_CONFIG_PACKAGE_INVALID",
|
|
@@ -1821,6 +1861,7 @@ async function loadConfigInternal(root, selection) {
|
|
|
1821
1861
|
if (raw !== void 0) {
|
|
1822
1862
|
assertKeys(raw, "config", [
|
|
1823
1863
|
"app",
|
|
1864
|
+
"engine",
|
|
1824
1865
|
"display",
|
|
1825
1866
|
"bootSplash",
|
|
1826
1867
|
"window",
|
|
@@ -1848,6 +1889,7 @@ async function loadConfigInternal(root, selection) {
|
|
|
1848
1889
|
}
|
|
1849
1890
|
return {
|
|
1850
1891
|
app,
|
|
1892
|
+
engine: validateEngine(raw?.engine),
|
|
1851
1893
|
display: validateDisplay(raw?.display),
|
|
1852
1894
|
window: validateWindow(raw?.window, app.name),
|
|
1853
1895
|
nativeEntry: validateNativeEntry(configuredEntry ?? packageEntry ?? "src/game.ts", root),
|
|
@@ -1869,13 +1911,150 @@ async function loadConfigInternal(root, selection) {
|
|
|
1869
1911
|
);
|
|
1870
1912
|
}
|
|
1871
1913
|
async function loadConfig(cwd, selection) {
|
|
1872
|
-
const root =
|
|
1914
|
+
const root = path6.resolve(cwd);
|
|
1873
1915
|
return withConfigContext(
|
|
1874
|
-
validationContext(root, [
|
|
1916
|
+
validationContext(root, [path6.join(root, CONFIG_FILE), path6.join(root, "package.json")]),
|
|
1875
1917
|
"TN_CONFIG_VALIDATION_FAILED",
|
|
1876
1918
|
() => loadConfigInternal(root, selection)
|
|
1877
1919
|
);
|
|
1878
1920
|
}
|
|
1921
|
+
function webRuntimeDecoders(config) {
|
|
1922
|
+
return config.engine === "threejs" ? { ktx2: true, meshopt: true } : { ktx2: false, meshopt: false };
|
|
1923
|
+
}
|
|
1924
|
+
var WEB_ENGINE_ID = "\0threenative:web-engine";
|
|
1925
|
+
var UPSTREAM = ["three", "three/webgpu", "three/tsl"];
|
|
1926
|
+
var POST_EFFECT_ADDONS = [
|
|
1927
|
+
"GTAONode",
|
|
1928
|
+
"DenoiseNode",
|
|
1929
|
+
"SMAANode",
|
|
1930
|
+
"BloomNode",
|
|
1931
|
+
"TRAANode",
|
|
1932
|
+
"FilmNode",
|
|
1933
|
+
"Lut3DNode",
|
|
1934
|
+
// Refused on use, as on the V8 player: upstream's copies run `Fn(...).setLayout(...)` at import.
|
|
1935
|
+
"FXAANode",
|
|
1936
|
+
"GodraysNode",
|
|
1937
|
+
"SSGINode",
|
|
1938
|
+
"SSRNode",
|
|
1939
|
+
"SharpenNode"
|
|
1940
|
+
].map((node) => `three/addons/tsl/display/${node}.js`);
|
|
1941
|
+
var ENGINE_ADDON_CLASSES = {
|
|
1942
|
+
"three/addons/geometries/RoundedBoxGeometry.js": "RoundedBoxGeometry"
|
|
1943
|
+
};
|
|
1944
|
+
var ENGINE_ADDON_PREFIX = "\0threenative:web-engine-addon:";
|
|
1945
|
+
var SKELETON_UTILS_ID = "\0threenative:web-engine-skeleton-utils";
|
|
1946
|
+
var WASM_ENGINE_ENTRY = "build/web/tn-native-engine-web.mjs";
|
|
1947
|
+
function browserModule(built, source) {
|
|
1948
|
+
const bundled = fileURLToPath(new URL(`./${built}`, import.meta.url));
|
|
1949
|
+
if (existsSync(bundled)) return bundled;
|
|
1950
|
+
const workspace = fileURLToPath(new URL(`../../three-native/src/${source}`, import.meta.url));
|
|
1951
|
+
if (existsSync(workspace)) return workspace;
|
|
1952
|
+
throw new Error(`TN_WEB_ENGINE_RUNTIME_MISSING: neither ${bundled} nor ${workspace} exists.`);
|
|
1953
|
+
}
|
|
1954
|
+
var runtimeModule = () => browserModule("web-engine-runtime.js", "browser-entry.ts");
|
|
1955
|
+
function wasmModule(root, explicit) {
|
|
1956
|
+
if (explicit !== void 0) {
|
|
1957
|
+
if (!existsSync(explicit))
|
|
1958
|
+
throw new Error(
|
|
1959
|
+
`TN_WASM_ENGINE_MISSING: engine "threenative" needs the Wasm engine at ${explicit}.`
|
|
1960
|
+
);
|
|
1961
|
+
return explicit;
|
|
1962
|
+
}
|
|
1963
|
+
let entry;
|
|
1964
|
+
try {
|
|
1965
|
+
const require2 = createRequire$1(path6.join(root, "package.json"));
|
|
1966
|
+
entry = path6.join(
|
|
1967
|
+
path6.dirname(require2.resolve("@threenative/runtime-native/package.json")),
|
|
1968
|
+
WASM_ENGINE_ENTRY
|
|
1969
|
+
);
|
|
1970
|
+
} catch {
|
|
1971
|
+
throw new Error(
|
|
1972
|
+
`TN_WASM_ENGINE_MISSING: engine "threenative" needs @threenative/runtime-native installed in ${root}. Set engine: "threejs" in threenative.config.ts to keep upstream three.`
|
|
1973
|
+
);
|
|
1974
|
+
}
|
|
1975
|
+
if (!existsSync(entry))
|
|
1976
|
+
throw new Error(
|
|
1977
|
+
`TN_WASM_ENGINE_MISSING: engine "threenative" needs the Wasm engine at ${entry}; build it with \`cmake --build build/wasm --target tn-native-engine-web\` in packages/runtime-native, or set engine: "threejs" in threenative.config.ts to keep upstream three.`
|
|
1978
|
+
);
|
|
1979
|
+
return entry;
|
|
1980
|
+
}
|
|
1981
|
+
async function upstreamNames(root) {
|
|
1982
|
+
const require2 = createRequire$1(path6.join(root, "package.json"));
|
|
1983
|
+
const modules = await Promise.all(
|
|
1984
|
+
UPSTREAM.map((id) => import(pathToFileURL(require2.resolve(id)).href))
|
|
1985
|
+
);
|
|
1986
|
+
return [...new Set(modules.flatMap((module) => Object.keys(module)))].filter((name) => name !== "default").sort();
|
|
1987
|
+
}
|
|
1988
|
+
function createWebEnginePlugin(options = {}) {
|
|
1989
|
+
let root = options.root;
|
|
1990
|
+
const native = options.engine === "threenative";
|
|
1991
|
+
const projectRoot = () => {
|
|
1992
|
+
if (root === void 0)
|
|
1993
|
+
throw new Error("TN_WEB_ENGINE_ROOT: Vite has not resolved its config yet.");
|
|
1994
|
+
return root;
|
|
1995
|
+
};
|
|
1996
|
+
return {
|
|
1997
|
+
name: "threenative-web-engine",
|
|
1998
|
+
enforce: "pre",
|
|
1999
|
+
configResolved(config) {
|
|
2000
|
+
root ??= config.root;
|
|
2001
|
+
},
|
|
2002
|
+
resolveId(specifier) {
|
|
2003
|
+
if (!native) return null;
|
|
2004
|
+
const source = specifier.replace(/^three\/examples\/jsm\//u, "three/addons/");
|
|
2005
|
+
if (UPSTREAM.includes(source)) return WEB_ENGINE_ID;
|
|
2006
|
+
const engineClass = ENGINE_ADDON_CLASSES[source];
|
|
2007
|
+
if (engineClass !== void 0) return ENGINE_ADDON_PREFIX + engineClass;
|
|
2008
|
+
if (source === "three/addons/utils/SkeletonUtils.js") return SKELETON_UTILS_ID;
|
|
2009
|
+
if (source === "three-mesh-bvh")
|
|
2010
|
+
return browserModule("web-engine-mesh-bvh.js", "addons/mesh-bvh.ts");
|
|
2011
|
+
if (source === "three-mesh-bvh/webgpu")
|
|
2012
|
+
return browserModule("web-engine-mesh-bvh-webgpu.js", "addons/mesh-bvh-webgpu.ts");
|
|
2013
|
+
if (source === "three/addons/utils/BufferGeometryUtils.js")
|
|
2014
|
+
return browserModule(
|
|
2015
|
+
"web-engine-buffer-geometry-utils.js",
|
|
2016
|
+
"addons/buffer-geometry-utils.ts"
|
|
2017
|
+
);
|
|
2018
|
+
if (source === "three/addons/geometries/DecalGeometry.js")
|
|
2019
|
+
return browserModule("web-engine-decal-geometry.js", "addons/decal-geometry.ts");
|
|
2020
|
+
if (source === "three/addons/loaders/HDRLoader.js")
|
|
2021
|
+
return browserModule("web-engine-hdr-loader.js", "addons/hdr-loader.ts");
|
|
2022
|
+
if (source === "three/addons/loaders/GLTFLoader.js")
|
|
2023
|
+
return browserModule("web-engine-gltf-loader.js", "addons/gltf-loader-web.ts");
|
|
2024
|
+
if (source === "three/addons/loaders/LUTCubeLoader.js")
|
|
2025
|
+
return browserModule("web-engine-lut-cube-loader.js", "addons/lut-cube-loader-web.ts");
|
|
2026
|
+
if (POST_EFFECT_ADDONS.includes(source))
|
|
2027
|
+
return browserModule("web-engine-post-effects.js", "addons/post-effects-web.ts");
|
|
2028
|
+
if (/^three\/(?:src|build)\//u.test(source))
|
|
2029
|
+
throw new Error(
|
|
2030
|
+
`TN_NATIVE_UPSTREAM_IMPORT: ${source} would bundle upstream three under engine "threenative"; import from three, three/webgpu or three/tsl.`
|
|
2031
|
+
);
|
|
2032
|
+
return null;
|
|
2033
|
+
},
|
|
2034
|
+
async load(id) {
|
|
2035
|
+
if (native && id.startsWith(ENGINE_ADDON_PREFIX))
|
|
2036
|
+
return `export { ${id.slice(ENGINE_ADDON_PREFIX.length)} } from "three";
|
|
2037
|
+
`;
|
|
2038
|
+
if (native && id === SKELETON_UTILS_ID)
|
|
2039
|
+
return 'import { SkeletonUtils } from "three";\nexport const clone = (source) => SkeletonUtils.clone(source);\n';
|
|
2040
|
+
if (!native || id !== WEB_ENGINE_ID) return null;
|
|
2041
|
+
const names = [
|
|
2042
|
+
...await upstreamNames(projectRoot()),
|
|
2043
|
+
...Object.values(ENGINE_ADDON_CLASSES),
|
|
2044
|
+
"SkeletonUtils",
|
|
2045
|
+
"__tnTsl",
|
|
2046
|
+
"__tnLoadGltf"
|
|
2047
|
+
];
|
|
2048
|
+
return [
|
|
2049
|
+
`import { bindWebEngine } from ${JSON.stringify(runtimeModule())};`,
|
|
2050
|
+
`import createModule from ${JSON.stringify(wasmModule(projectRoot(), options.wasm))};`,
|
|
2051
|
+
`const engine = await bindWebEngine(createModule, ${JSON.stringify(names)});`,
|
|
2052
|
+
`export const { ${names.join(", ")} } = engine;`,
|
|
2053
|
+
""
|
|
2054
|
+
].join("\n");
|
|
2055
|
+
}
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
1879
2058
|
|
|
1880
2059
|
// src/web-brand.ts
|
|
1881
2060
|
function htmlAttribute(value) {
|
|
@@ -1883,8 +2062,8 @@ function htmlAttribute(value) {
|
|
|
1883
2062
|
}
|
|
1884
2063
|
function publicUrl(root, value) {
|
|
1885
2064
|
if (value === void 0) return void 0;
|
|
1886
|
-
const relative =
|
|
1887
|
-
const normalized = relative.replaceAll(
|
|
2065
|
+
const relative = path6.isAbsolute(value) ? path6.relative(root, value) : value;
|
|
2066
|
+
const normalized = relative.replaceAll(path6.sep, "/").replace(/^public\//u, "");
|
|
1888
2067
|
return `/${normalized.replace(/^\//u, "")}`;
|
|
1889
2068
|
}
|
|
1890
2069
|
function manifestIcon(root, source, purpose) {
|
|
@@ -1945,7 +2124,8 @@ function updateLaunchMarkup(root, config, html) {
|
|
|
1945
2124
|
);
|
|
1946
2125
|
}
|
|
1947
2126
|
const links = metadataLinks(root, config);
|
|
1948
|
-
|
|
2127
|
+
if (publicUrl(root, config.app.icons?.web?.favicon ?? config.app.icon) !== void 0)
|
|
2128
|
+
output = output.replace(/\s*<link\s+rel="icon"[^>]*>/giu, "");
|
|
1949
2129
|
output = output.replace(/\s*<link\s+rel="apple-touch-icon"[^>]*>/giu, "");
|
|
1950
2130
|
output = output.replace(/\s*<link\s+rel="manifest"[^>]*>/giu, "");
|
|
1951
2131
|
output = output.replace(/(<\/head>)/iu, ` ${links}
|
|
@@ -1955,11 +2135,29 @@ function updateLaunchMarkup(root, config, html) {
|
|
|
1955
2135
|
function createWebBrandPlugin() {
|
|
1956
2136
|
let root = process.cwd();
|
|
1957
2137
|
let config;
|
|
2138
|
+
let engine;
|
|
1958
2139
|
return {
|
|
1959
2140
|
name: "threenative-web-brand",
|
|
2141
|
+
enforce: "pre",
|
|
2142
|
+
async config(vite) {
|
|
2143
|
+
const loaded = await loadConfig(path6.resolve(vite.root ?? process.cwd()));
|
|
2144
|
+
if (loaded.engine === "threenative")
|
|
2145
|
+
return {
|
|
2146
|
+
optimizeDeps: { exclude: ["three", "three/webgpu", "three/tsl", "three-mesh-bvh"] }
|
|
2147
|
+
};
|
|
2148
|
+
return void 0;
|
|
2149
|
+
},
|
|
2150
|
+
resolveId(source) {
|
|
2151
|
+
return engine?.resolveId(source) ?? null;
|
|
2152
|
+
},
|
|
2153
|
+
async load(id) {
|
|
2154
|
+
return engine?.load(id) ?? null;
|
|
2155
|
+
},
|
|
1960
2156
|
async configResolved(resolved) {
|
|
1961
2157
|
root = resolved.root;
|
|
1962
2158
|
config = await loadConfig(root);
|
|
2159
|
+
if (config.engine === "threenative")
|
|
2160
|
+
engine = createWebEnginePlugin({ root, engine: config.engine });
|
|
1963
2161
|
},
|
|
1964
2162
|
transformIndexHtml(html) {
|
|
1965
2163
|
if (config === void 0) throw new Error("TN_WEB_BRAND_CONFIG_MISSING");
|
|
@@ -1998,22 +2196,22 @@ var TEMPLATE_NAME = /^[a-z][a-z0-9-]*$/u;
|
|
|
1998
2196
|
var SHARED_AGENT_MARKER_LINE = /^<!--\s*(?:shared:\s*[^>]+|\/shared)\s*-->\r?\n?/gmu;
|
|
1999
2197
|
var DEFAULT_TEMPLATE = "starter";
|
|
2000
2198
|
function templateRoot() {
|
|
2001
|
-
return
|
|
2199
|
+
return path6.resolve(path6.dirname(fileURLToPath(import.meta.url)), "../templates");
|
|
2002
2200
|
}
|
|
2003
|
-
var LOADING_SOURCE_RELATIVE_PATH =
|
|
2201
|
+
var LOADING_SOURCE_RELATIVE_PATH = path6.join("src", "render", "loading.ts");
|
|
2004
2202
|
var LOADING_APPEARANCE_MARKER = "BEGIN THREENATIVE LOADING APPEARANCE";
|
|
2005
2203
|
var TEMPLATE_ICON_NAME = "icon.png";
|
|
2006
2204
|
var LOADING_APPEARANCE_BLOCK_PATTERN = /\/\* BEGIN THREENATIVE LOADING APPEARANCE \*\/[\s\S]*?\/\* END THREENATIVE LOADING APPEARANCE \*\//gu;
|
|
2007
2205
|
function discoverStampedTemplates(root = templateRoot()) {
|
|
2008
2206
|
return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).sort((left, right) => left.localeCompare(right)).filter((template) => {
|
|
2009
|
-
const file =
|
|
2207
|
+
const file = path6.join(root, template, LOADING_SOURCE_RELATIVE_PATH);
|
|
2010
2208
|
return existsSync(file) && readFileSync(file, "utf8").includes(LOADING_APPEARANCE_MARKER);
|
|
2011
2209
|
});
|
|
2012
2210
|
}
|
|
2013
2211
|
function canonicalLoadingPath(root = templateRoot()) {
|
|
2014
|
-
const local =
|
|
2212
|
+
const local = path6.resolve(root, "..", "template-assets", "loading.ts");
|
|
2015
2213
|
if (existsSync(local)) return local;
|
|
2016
|
-
return
|
|
2214
|
+
return path6.resolve(templateRoot(), "..", "template-assets", "loading.ts");
|
|
2017
2215
|
}
|
|
2018
2216
|
function loadingAppearanceBlock(source, file) {
|
|
2019
2217
|
const matches = source.match(LOADING_APPEARANCE_BLOCK_PATTERN) ?? [];
|
|
@@ -2029,19 +2227,24 @@ function stampLoadingSource(canonical, template) {
|
|
|
2029
2227
|
const templateBlock = loadingAppearanceBlock(template, "template loading source");
|
|
2030
2228
|
return canonical.replace(canonicalBlock, templateBlock);
|
|
2031
2229
|
}
|
|
2032
|
-
var SHARED_RENDER_SOURCES = [
|
|
2230
|
+
var SHARED_RENDER_SOURCES = [
|
|
2231
|
+
path6.join("src", "render", "worldEnvironment.ts"),
|
|
2232
|
+
path6.join("src", "render", "autoExposure.ts"),
|
|
2233
|
+
path6.join("src", "render", "exposureGraph.ts"),
|
|
2234
|
+
path6.join("src", "render", "exposureReadback.ts")
|
|
2235
|
+
];
|
|
2033
2236
|
function canonicalRenderSourcePath(relativePath, root = templateRoot()) {
|
|
2034
|
-
const name =
|
|
2035
|
-
const local =
|
|
2237
|
+
const name = path6.basename(relativePath);
|
|
2238
|
+
const local = path6.resolve(root, "..", "template-assets", name);
|
|
2036
2239
|
if (existsSync(local)) return local;
|
|
2037
|
-
return
|
|
2240
|
+
return path6.resolve(templateRoot(), "..", "template-assets", name);
|
|
2038
2241
|
}
|
|
2039
2242
|
async function restampSharedRenderCopies(root = templateRoot()) {
|
|
2040
2243
|
const stamped = [];
|
|
2041
2244
|
for (const relativePath of SHARED_RENDER_SOURCES) {
|
|
2042
2245
|
const canonical = await readFile(canonicalRenderSourcePath(relativePath, root), "utf8");
|
|
2043
2246
|
for (const template of readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).sort((left, right) => left.localeCompare(right))) {
|
|
2044
|
-
const file =
|
|
2247
|
+
const file = path6.join(root, template, relativePath);
|
|
2045
2248
|
if (!existsSync(file)) continue;
|
|
2046
2249
|
await writeFile(file, canonical);
|
|
2047
2250
|
stamped.push(file);
|
|
@@ -2053,7 +2256,7 @@ async function restampTemplateLoadingCopies(root = templateRoot()) {
|
|
|
2053
2256
|
const canonical = await readFile(canonicalLoadingPath(root), "utf8");
|
|
2054
2257
|
const stamped = [];
|
|
2055
2258
|
for (const template of discoverStampedTemplates(root)) {
|
|
2056
|
-
const file =
|
|
2259
|
+
const file = path6.join(root, template, LOADING_SOURCE_RELATIVE_PATH);
|
|
2057
2260
|
const source = await readFile(file, "utf8");
|
|
2058
2261
|
await writeFile(file, stampLoadingSource(canonical, source));
|
|
2059
2262
|
stamped.push(file);
|
|
@@ -2061,19 +2264,19 @@ async function restampTemplateLoadingCopies(root = templateRoot()) {
|
|
|
2061
2264
|
return stamped;
|
|
2062
2265
|
}
|
|
2063
2266
|
async function stampTemplateLoading(target, template, root) {
|
|
2064
|
-
const sourcePath =
|
|
2267
|
+
const sourcePath = path6.join(template, LOADING_SOURCE_RELATIVE_PATH);
|
|
2065
2268
|
if (!existsSync(sourcePath)) return;
|
|
2066
2269
|
const source = await readFile(sourcePath, "utf8");
|
|
2067
2270
|
if (!source.includes("BEGIN THREENATIVE LOADING APPEARANCE")) return;
|
|
2068
2271
|
const canonical = await readFile(canonicalLoadingPath(root), "utf8");
|
|
2069
2272
|
await writeFile(
|
|
2070
|
-
|
|
2273
|
+
path6.join(target, LOADING_SOURCE_RELATIVE_PATH),
|
|
2071
2274
|
stampLoadingSource(canonical, source)
|
|
2072
2275
|
);
|
|
2073
2276
|
}
|
|
2074
2277
|
async function copyTemplateIcon(target, templateRootDirectory) {
|
|
2075
|
-
const source =
|
|
2076
|
-
|
|
2278
|
+
const source = path6.join(
|
|
2279
|
+
path6.dirname(templateRootDirectory),
|
|
2077
2280
|
"template-assets",
|
|
2078
2281
|
TEMPLATE_ICON_NAME
|
|
2079
2282
|
);
|
|
@@ -2082,18 +2285,18 @@ async function copyTemplateIcon(target, templateRootDirectory) {
|
|
|
2082
2285
|
`TN_TEMPLATE_ICON_MISSING: '${source}' is not in the package; every generated project needs the native icon asset.`
|
|
2083
2286
|
);
|
|
2084
2287
|
}
|
|
2085
|
-
const destination =
|
|
2086
|
-
await mkdir(
|
|
2288
|
+
const destination = path6.join(target, "public", TEMPLATE_ICON_NAME);
|
|
2289
|
+
await mkdir(path6.dirname(destination), { recursive: true });
|
|
2087
2290
|
await cp(source, destination, { errorOnExist: true, force: false });
|
|
2088
2291
|
}
|
|
2089
2292
|
async function copySharedAssets(target, templateRootDirectory) {
|
|
2090
|
-
const shared =
|
|
2293
|
+
const shared = path6.join(path6.dirname(templateRootDirectory), "template-assets", "assets");
|
|
2091
2294
|
if (!existsSync(shared)) return;
|
|
2092
|
-
const source =
|
|
2295
|
+
const source = path6.join(target, "src");
|
|
2093
2296
|
const texts = [];
|
|
2094
2297
|
const walk = async (directory) => {
|
|
2095
2298
|
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
2096
|
-
const file =
|
|
2299
|
+
const file = path6.join(directory, entry.name);
|
|
2097
2300
|
if (entry.isDirectory()) await walk(file);
|
|
2098
2301
|
else if (/\.(?:ts|tsx)$/u.test(entry.name)) texts.push(await readFile(file, "utf8"));
|
|
2099
2302
|
}
|
|
@@ -2101,9 +2304,9 @@ async function copySharedAssets(target, templateRootDirectory) {
|
|
|
2101
2304
|
if (existsSync(source)) await walk(source);
|
|
2102
2305
|
for (const name of readdirSync(shared)) {
|
|
2103
2306
|
if (!texts.some((text) => text.includes(`"${name}"`))) continue;
|
|
2104
|
-
const destination =
|
|
2105
|
-
await mkdir(
|
|
2106
|
-
await cp(
|
|
2307
|
+
const destination = path6.join(target, "assets", name);
|
|
2308
|
+
await mkdir(path6.dirname(destination), { recursive: true });
|
|
2309
|
+
await cp(path6.join(shared, name), destination, { errorOnExist: true, force: false });
|
|
2107
2310
|
}
|
|
2108
2311
|
}
|
|
2109
2312
|
function invalidManifest(file, reason) {
|
|
@@ -2115,7 +2318,7 @@ function nonEmptyString2(value, field, file) {
|
|
|
2115
2318
|
return value;
|
|
2116
2319
|
}
|
|
2117
2320
|
function loadManifest(directory) {
|
|
2118
|
-
const file =
|
|
2321
|
+
const file = path6.join(directory, "kit.json");
|
|
2119
2322
|
let raw;
|
|
2120
2323
|
try {
|
|
2121
2324
|
raw = readFileSync(file, "utf8");
|
|
@@ -2133,7 +2336,7 @@ function loadManifest(directory) {
|
|
|
2133
2336
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
2134
2337
|
return invalidManifest(file, "the root must be an object");
|
|
2135
2338
|
const record = value;
|
|
2136
|
-
const directoryName =
|
|
2339
|
+
const directoryName = path6.basename(directory);
|
|
2137
2340
|
const name = nonEmptyString2(record.name, "name", file);
|
|
2138
2341
|
if (!TEMPLATE_NAME.test(name))
|
|
2139
2342
|
return invalidManifest(file, "name must match /^[a-z][a-z0-9-]*$/");
|
|
@@ -2150,7 +2353,7 @@ function loadManifest(directory) {
|
|
|
2150
2353
|
};
|
|
2151
2354
|
}
|
|
2152
2355
|
function discoverKitManifests(root = templateRoot()) {
|
|
2153
|
-
return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => loadManifest(
|
|
2356
|
+
return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => loadManifest(path6.join(root, entry.name))).sort((left, right) => left.name.localeCompare(right.name));
|
|
2154
2357
|
}
|
|
2155
2358
|
function discoverTemplateNames(root = templateRoot()) {
|
|
2156
2359
|
return discoverKitManifests(root).map(({ name }) => name);
|
|
@@ -2198,7 +2401,7 @@ function cliHelp() {
|
|
|
2198
2401
|
`;
|
|
2199
2402
|
}
|
|
2200
2403
|
function packageName(target) {
|
|
2201
|
-
const name =
|
|
2404
|
+
const name = path6.basename(target).toLowerCase().replace(/[^a-z0-9-_]+/g, "-");
|
|
2202
2405
|
if (name.length === 0 || name === "-" || name === "_") {
|
|
2203
2406
|
throw new Error(`Cannot derive a package name from '${target}'.`);
|
|
2204
2407
|
}
|
|
@@ -2221,12 +2424,12 @@ function substituteTemplateVariables(content, replacements) {
|
|
|
2221
2424
|
async function renderTemplate(directory, replacements) {
|
|
2222
2425
|
const files = await readdir(directory, { withFileTypes: true });
|
|
2223
2426
|
for (const entry of files) {
|
|
2224
|
-
const source =
|
|
2427
|
+
const source = path6.join(directory, entry.name);
|
|
2225
2428
|
if (entry.isDirectory()) {
|
|
2226
2429
|
await renderTemplate(source, replacements);
|
|
2227
2430
|
continue;
|
|
2228
2431
|
}
|
|
2229
|
-
if (!TEXT_FILE_EXTENSIONS.has(
|
|
2432
|
+
if (!TEXT_FILE_EXTENSIONS.has(path6.extname(entry.name))) continue;
|
|
2230
2433
|
const content = await readFile(source, "utf8");
|
|
2231
2434
|
let rendered = substituteTemplateVariables(content, replacements);
|
|
2232
2435
|
if (entry.name === "AGENTS.md" || entry.name === "CLAUDE.md") {
|
|
@@ -2244,34 +2447,39 @@ var AUTHORING_GITIGNORE_RULES = [
|
|
|
2244
2447
|
"node_modules/",
|
|
2245
2448
|
".env",
|
|
2246
2449
|
".env.*",
|
|
2247
|
-
"!.env.example"
|
|
2450
|
+
"!.env.example",
|
|
2451
|
+
// The asset pipeline's compiled outputs: any project with an assets/ folder gets them in public/
|
|
2452
|
+
// on its first dev run or build. Hand-owned public files (favicon, icons) stay committed.
|
|
2453
|
+
"public/assets.manifest.json",
|
|
2454
|
+
"public/bake.receipt.json",
|
|
2455
|
+
"public/*.[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].*"
|
|
2248
2456
|
];
|
|
2249
2457
|
var REFERENCE_TOKEN_PATTERN = new RegExp(
|
|
2250
2458
|
`\`${REFERENCE_BUNDLE_PREFIX}([a-z0-9][a-z0-9./-]*\\.md)\`|\\[[^\\]]*\\]\\(${REFERENCE_BUNDLE_PREFIX}([^)#]+\\.md)\\)`,
|
|
2251
2459
|
"gu"
|
|
2252
2460
|
);
|
|
2253
2461
|
async function linkClaudeSkills(target) {
|
|
2254
|
-
const stored =
|
|
2462
|
+
const stored = path6.join(target, ".agents", "skills");
|
|
2255
2463
|
if (!existsSync(stored)) return;
|
|
2256
|
-
const hostSkills =
|
|
2257
|
-
const subagents =
|
|
2464
|
+
const hostSkills = path6.join(target, ".claude", "skills");
|
|
2465
|
+
const subagents = path6.join(target, ".claude", "agents");
|
|
2258
2466
|
await mkdir(hostSkills, { recursive: true });
|
|
2259
2467
|
for (const entry of await readdir(stored, { withFileTypes: true })) {
|
|
2260
2468
|
if (!entry.isDirectory()) continue;
|
|
2261
|
-
if (existsSync(
|
|
2262
|
-
const link =
|
|
2263
|
-
const relative =
|
|
2469
|
+
if (existsSync(path6.join(subagents, `${entry.name}.md`))) continue;
|
|
2470
|
+
const link = path6.join(hostSkills, entry.name);
|
|
2471
|
+
const relative = path6.relative(hostSkills, path6.join(stored, entry.name));
|
|
2264
2472
|
try {
|
|
2265
2473
|
await symlink(relative, link, "dir");
|
|
2266
2474
|
} catch (error) {
|
|
2267
2475
|
const code = error.code;
|
|
2268
2476
|
if (code !== "EPERM" && code !== "EACCES") throw error;
|
|
2269
|
-
await cp(
|
|
2477
|
+
await cp(path6.join(stored, entry.name), link, { recursive: true });
|
|
2270
2478
|
}
|
|
2271
2479
|
}
|
|
2272
2480
|
}
|
|
2273
2481
|
async function copyAgentFiles(target, templateRootDirectory) {
|
|
2274
|
-
const source =
|
|
2482
|
+
const source = path6.join(path6.dirname(templateRootDirectory), AGENT_FILES_DIRECTORY);
|
|
2275
2483
|
if (!existsSync(source)) {
|
|
2276
2484
|
throw new Error(
|
|
2277
2485
|
`TN_AGENT_FILES_MISSING: '${source}' is not in the package; every generated project needs the canonical agent roles.`
|
|
@@ -2281,7 +2489,7 @@ async function copyAgentFiles(target, templateRootDirectory) {
|
|
|
2281
2489
|
await linkClaudeSkills(target);
|
|
2282
2490
|
}
|
|
2283
2491
|
async function installAuthoringGitignore(target) {
|
|
2284
|
-
const file =
|
|
2492
|
+
const file = path6.join(target, ".gitignore");
|
|
2285
2493
|
const existing = existsSync(file) ? await readFile(file, "utf8") : "";
|
|
2286
2494
|
const present = new Set(existing.split(/\r?\n/u));
|
|
2287
2495
|
const missing = AUTHORING_GITIGNORE_RULES.filter((entry) => !present.has(entry));
|
|
@@ -2295,8 +2503,8 @@ async function installAuthoringGitignore(target) {
|
|
|
2295
2503
|
);
|
|
2296
2504
|
}
|
|
2297
2505
|
async function assertReferenceBundle(target, templateRootDirectory) {
|
|
2298
|
-
const bundleDirectory =
|
|
2299
|
-
|
|
2506
|
+
const bundleDirectory = path6.join(
|
|
2507
|
+
path6.dirname(templateRootDirectory),
|
|
2300
2508
|
"agent-docs",
|
|
2301
2509
|
"references"
|
|
2302
2510
|
);
|
|
@@ -2308,7 +2516,7 @@ async function assertReferenceBundle(target, templateRootDirectory) {
|
|
|
2308
2516
|
".agents/skills/threenative-assets/SKILL.md",
|
|
2309
2517
|
".claude/skills/threenative-assets/SKILL.md"
|
|
2310
2518
|
]) {
|
|
2311
|
-
const filePath =
|
|
2519
|
+
const filePath = path6.join(target, file);
|
|
2312
2520
|
if (existsSync(filePath)) await assertReferenceTargets(file, filePath, bundleDirectory);
|
|
2313
2521
|
}
|
|
2314
2522
|
}
|
|
@@ -2322,7 +2530,7 @@ async function assertReferenceTargets(from, filePath, bundleDirectory) {
|
|
|
2322
2530
|
`RED observed: referenced recipe missing: '${from}' names '${referenced}', which is not a shipped reference page.`
|
|
2323
2531
|
);
|
|
2324
2532
|
}
|
|
2325
|
-
if (!existsSync(
|
|
2533
|
+
if (!existsSync(path6.join(bundleDirectory, referenced))) {
|
|
2326
2534
|
throw new Error(
|
|
2327
2535
|
`RED observed: referenced recipe missing: '${from}' links '${REFERENCE_BUNDLE_PREFIX}${referenced}', which the package does not ship.`
|
|
2328
2536
|
);
|
|
@@ -2331,11 +2539,11 @@ async function assertReferenceTargets(from, filePath, bundleDirectory) {
|
|
|
2331
2539
|
}
|
|
2332
2540
|
async function applyPackageSources(target, packageSources) {
|
|
2333
2541
|
if (packageSources === void 0) return;
|
|
2334
|
-
const packagePath =
|
|
2542
|
+
const packagePath = path6.join(target, "package.json");
|
|
2335
2543
|
const packageJson = JSON.parse(await readFile(packagePath, "utf8"));
|
|
2336
2544
|
const localSource = (source) => {
|
|
2337
2545
|
const filePath = source.startsWith("file:") ? source.slice("file:".length) : source;
|
|
2338
|
-
return `file:${
|
|
2546
|
+
return `file:${path6.resolve(filePath)}`;
|
|
2339
2547
|
};
|
|
2340
2548
|
for (const [name, source] of Object.entries(packageSources)) {
|
|
2341
2549
|
if (source === void 0) continue;
|
|
@@ -2358,24 +2566,36 @@ async function applyPackageSources(target, packageSources) {
|
|
|
2358
2566
|
`);
|
|
2359
2567
|
}
|
|
2360
2568
|
var FRAMEWORK_PATCH_DIRECTORY = "patches";
|
|
2361
|
-
var
|
|
2569
|
+
var FRAMEWORK_PATCH_SOURCES = {
|
|
2570
|
+
"three@0.185.1.patch": "../core/patches/three@0.185.1.patch",
|
|
2571
|
+
"vite@8.2.0.patch": "../../patches/vite@8.2.0.patch",
|
|
2572
|
+
"@tailwindcss__node@4.3.3.patch": "../../patches/@tailwindcss__node@4.3.3.patch"
|
|
2573
|
+
};
|
|
2362
2574
|
async function copyFrameworkPatches(target, templateRootDirectory) {
|
|
2363
|
-
const
|
|
2364
|
-
const
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
`TN_FRAMEWORK_PATCH_MISSING: none of ${candidates.map((candidate) => `'${candidate}'`).join(", ")} exists; the generated project needs the Three.js velocity patch for batched temporal history.`
|
|
2575
|
+
const manifest = JSON.parse(await readFile(path6.join(target, "package.json"), "utf8"));
|
|
2576
|
+
const packageRoot = path6.dirname(templateRoot());
|
|
2577
|
+
for (const relative of Object.values(manifest.pnpm?.patchedDependencies ?? {})) {
|
|
2578
|
+
const name = path6.basename(relative);
|
|
2579
|
+
const fallback = FRAMEWORK_PATCH_SOURCES[name];
|
|
2580
|
+
if (fallback === void 0 || relative !== `${FRAMEWORK_PATCH_DIRECTORY}/${name}`) {
|
|
2581
|
+
throw new Error(`TN_FRAMEWORK_PATCH_MISSING: unsupported template patch '${relative}'.`);
|
|
2582
|
+
}
|
|
2583
|
+
const candidates = [.../* @__PURE__ */ new Set([path6.dirname(templateRootDirectory), packageRoot])].map(
|
|
2584
|
+
(root) => path6.join(root, "template-assets", FRAMEWORK_PATCH_DIRECTORY, name)
|
|
2374
2585
|
);
|
|
2586
|
+
const canonical = path6.resolve(packageRoot, fallback);
|
|
2587
|
+
if (existsSync(path6.join(packageRoot, "src", "index.ts"))) candidates.unshift(canonical);
|
|
2588
|
+
else candidates.push(canonical);
|
|
2589
|
+
const source = candidates.find((candidate) => existsSync(candidate));
|
|
2590
|
+
if (source === void 0) {
|
|
2591
|
+
throw new Error(
|
|
2592
|
+
`TN_FRAMEWORK_PATCH_MISSING: dependency patch '${name}' is absent from the CLI package.`
|
|
2593
|
+
);
|
|
2594
|
+
}
|
|
2595
|
+
const destination = path6.join(target, relative);
|
|
2596
|
+
await mkdir(path6.dirname(destination), { recursive: true });
|
|
2597
|
+
await cp(source, destination);
|
|
2375
2598
|
}
|
|
2376
|
-
const destination = path5.join(target, FRAMEWORK_PATCH_DIRECTORY, THREE_PATCH_NAME);
|
|
2377
|
-
await mkdir(path5.dirname(destination), { recursive: true });
|
|
2378
|
-
await cp(source, destination);
|
|
2379
2599
|
}
|
|
2380
2600
|
var NODE_MODULES_PREFIX = "./node_modules/";
|
|
2381
2601
|
var REQUIRED_MCP_SERVERS = Object.fromEntries(
|
|
@@ -2386,7 +2606,7 @@ function mcpPackageName(entry) {
|
|
|
2386
2606
|
return entry.startsWith(`${NODE_MODULES_PREFIX}@`) ? segments.slice(0, 2).join("/") : segments[0] ?? "";
|
|
2387
2607
|
}
|
|
2388
2608
|
async function assertMcpConfig(target) {
|
|
2389
|
-
const configPath =
|
|
2609
|
+
const configPath = path6.join(target, ".mcp.json");
|
|
2390
2610
|
const raw = await readFile(configPath, "utf8").catch(() => {
|
|
2391
2611
|
throw new Error(`Scaffold produced no .mcp.json at '${configPath}'.`);
|
|
2392
2612
|
});
|
|
@@ -2399,7 +2619,7 @@ async function assertMcpConfig(target) {
|
|
|
2399
2619
|
throw new Error(`'${configPath}' is missing required MCP server '${name}'.`);
|
|
2400
2620
|
}
|
|
2401
2621
|
}
|
|
2402
|
-
const manifest = JSON.parse(await readFile(
|
|
2622
|
+
const manifest = JSON.parse(await readFile(path6.join(target, "package.json"), "utf8"));
|
|
2403
2623
|
const declared = /* @__PURE__ */ new Set([
|
|
2404
2624
|
...Object.keys(manifest.dependencies ?? {}),
|
|
2405
2625
|
...Object.keys(manifest.devDependencies ?? {})
|
|
@@ -2433,7 +2653,7 @@ async function assertMcpConfig(target) {
|
|
|
2433
2653
|
);
|
|
2434
2654
|
}
|
|
2435
2655
|
}
|
|
2436
|
-
const codexPath =
|
|
2656
|
+
const codexPath = path6.join(target, ".codex", "config.toml");
|
|
2437
2657
|
const codex = await readFile(codexPath, "utf8").catch(() => {
|
|
2438
2658
|
throw new Error(`Scaffold produced no Codex MCP config at '${codexPath}'.`);
|
|
2439
2659
|
});
|
|
@@ -2453,40 +2673,55 @@ async function runInstall(target) {
|
|
|
2453
2673
|
});
|
|
2454
2674
|
});
|
|
2455
2675
|
}
|
|
2676
|
+
async function discardScaffold(target, existedBefore) {
|
|
2677
|
+
if (!existedBefore) {
|
|
2678
|
+
await rm(target, { force: true, recursive: true });
|
|
2679
|
+
return;
|
|
2680
|
+
}
|
|
2681
|
+
for (const entry of await readdir(target)) {
|
|
2682
|
+
await rm(path6.join(target, entry), { force: true, recursive: true });
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2456
2685
|
async function createProject(options, cwd = process.cwd(), root = templateRoot()) {
|
|
2457
2686
|
const manifests = discoverKitManifests(root);
|
|
2458
2687
|
const template = options.template ?? DEFAULT_TEMPLATE;
|
|
2459
2688
|
if (!manifests.some(({ name }) => name === template)) kitManifest(template, root);
|
|
2460
|
-
const target =
|
|
2689
|
+
const target = path6.resolve(cwd, options.target);
|
|
2461
2690
|
const targetExists = await isEmpty(target).catch(() => false);
|
|
2462
2691
|
if (!targetExists) {
|
|
2463
2692
|
throw new Error(`Target '${target}' already exists and is not empty.`);
|
|
2464
2693
|
}
|
|
2694
|
+
const existedBefore = existsSync(target);
|
|
2465
2695
|
await mkdir(target, { recursive: true });
|
|
2466
|
-
const source = path5.join(root, template);
|
|
2467
|
-
await cp(source, target, { recursive: true, errorOnExist: true });
|
|
2468
|
-
await copyTemplateIcon(target, root);
|
|
2469
|
-
await copySharedAssets(target, root);
|
|
2470
|
-
if (existsSync(path5.join(target, "gitignore"))) {
|
|
2471
|
-
await rename(path5.join(target, "gitignore"), path5.join(target, ".gitignore"));
|
|
2472
|
-
}
|
|
2473
|
-
await installAuthoringGitignore(target);
|
|
2474
|
-
const projectName = packageName(target);
|
|
2475
|
-
const compactProjectId = projectName.toLowerCase().replace(/[^a-z0-9]+/gu, "") || "game";
|
|
2476
|
-
const projectId = /^[a-z]/u.test(compactProjectId) ? compactProjectId : `game${compactProjectId}`;
|
|
2477
|
-
const replacements = Object.fromEntries([
|
|
2478
|
-
["__PROJECT_NAME__", projectName],
|
|
2479
|
-
["__PROJECT_ID__", projectId]
|
|
2480
|
-
]);
|
|
2481
|
-
await stampTemplateLoading(target, source, root);
|
|
2482
|
-
await copyAgentFiles(target, root);
|
|
2483
|
-
await renderTemplate(target, replacements);
|
|
2484
|
-
await copyFrameworkPatches(target, root);
|
|
2485
|
-
await applyPackageSources(target, options.packageSources);
|
|
2486
|
-
await assertMcpConfig(target);
|
|
2487
|
-
await assertReferenceBundle(target, root);
|
|
2488
2696
|
const installed = options.install ?? true;
|
|
2489
|
-
|
|
2697
|
+
try {
|
|
2698
|
+
const source = path6.join(root, template);
|
|
2699
|
+
await cp(source, target, { recursive: true, errorOnExist: true });
|
|
2700
|
+
await copyTemplateIcon(target, root);
|
|
2701
|
+
await copySharedAssets(target, root);
|
|
2702
|
+
if (existsSync(path6.join(target, "gitignore"))) {
|
|
2703
|
+
await rename(path6.join(target, "gitignore"), path6.join(target, ".gitignore"));
|
|
2704
|
+
}
|
|
2705
|
+
await installAuthoringGitignore(target);
|
|
2706
|
+
const projectName = packageName(target);
|
|
2707
|
+
const compactProjectId = projectName.toLowerCase().replace(/[^a-z0-9]+/gu, "") || "game";
|
|
2708
|
+
const projectId = /^[a-z]/u.test(compactProjectId) ? compactProjectId : `game${compactProjectId}`;
|
|
2709
|
+
const replacements = Object.fromEntries([
|
|
2710
|
+
["__PROJECT_NAME__", projectName],
|
|
2711
|
+
["__PROJECT_ID__", projectId]
|
|
2712
|
+
]);
|
|
2713
|
+
await stampTemplateLoading(target, source, root);
|
|
2714
|
+
await copyAgentFiles(target, root);
|
|
2715
|
+
await renderTemplate(target, replacements);
|
|
2716
|
+
await copyFrameworkPatches(target, root);
|
|
2717
|
+
await applyPackageSources(target, options.packageSources);
|
|
2718
|
+
await assertMcpConfig(target);
|
|
2719
|
+
await assertReferenceBundle(target, root);
|
|
2720
|
+
if (installed) await runInstall(target);
|
|
2721
|
+
} catch (error) {
|
|
2722
|
+
await discardScaffold(target, existedBefore);
|
|
2723
|
+
throw error;
|
|
2724
|
+
}
|
|
2490
2725
|
return { installed, target, template };
|
|
2491
2726
|
}
|
|
2492
2727
|
var PACKAGE_SOURCE_FLAG = /^--([a-z0-9-]+)-package$/u;
|
|
@@ -2596,7 +2831,7 @@ async function main() {
|
|
|
2596
2831
|
else process.stdout.write("Next: cd into the project and run pnpm dev.\n");
|
|
2597
2832
|
}
|
|
2598
2833
|
var entryPath = process.argv[1];
|
|
2599
|
-
if (entryPath !== void 0 && existsSync(entryPath) && realpathSync(
|
|
2834
|
+
if (entryPath !== void 0 && existsSync(entryPath) && realpathSync(path6.resolve(entryPath)) === realpathSync(fileURLToPath(import.meta.url))) {
|
|
2600
2835
|
main().catch((error) => {
|
|
2601
2836
|
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
2602
2837
|
`);
|
|
@@ -2604,4 +2839,4 @@ if (entryPath !== void 0 && existsSync(entryPath) && realpathSync(path5.resolve(
|
|
|
2604
2839
|
});
|
|
2605
2840
|
}
|
|
2606
2841
|
|
|
2607
|
-
export { SHARED_RENDER_SOURCES, canonicalLoadingPath, canonicalRenderSourcePath, cliHelp, createEngineFreshnessPlugin, createProject, createWebBrandPlugin, discoverKitManifests, discoverStampedTemplates, discoverTemplateNames, hashEngineDist, kitManifest, packageNameFromFlag, parseArgs, renderWebManifest, restampSharedRenderCopies, restampTemplateLoadingCopies, scaffoldCompletionMessage, stampLoadingSource, templateForGenre, templateRoot };
|
|
2842
|
+
export { SHARED_RENDER_SOURCES, canonicalLoadingPath, canonicalRenderSourcePath, cliHelp, createEngineFreshnessPlugin, createProject, createWebBrandPlugin, discoverKitManifests, discoverStampedTemplates, discoverTemplateNames, hashEngineDist, kitManifest, packageNameFromFlag, parseArgs, renderWebManifest, restampSharedRenderCopies, restampTemplateLoadingCopies, scaffoldCompletionMessage, stampLoadingSource, templateForGenre, templateRoot, webRuntimeDecoders };
|