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
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type BufferGeometry,
|
|
2
3
|
DataTexture,
|
|
3
4
|
DoubleSide,
|
|
4
|
-
|
|
5
|
+
Euler,
|
|
6
|
+
Matrix4,
|
|
5
7
|
Mesh,
|
|
6
8
|
MeshBasicMaterial,
|
|
7
9
|
type Object3D,
|
|
@@ -12,6 +14,7 @@ import {
|
|
|
12
14
|
UnsignedByteType,
|
|
13
15
|
Vector3,
|
|
14
16
|
} from "three";
|
|
17
|
+
import { DecalGeometry } from "three/addons/geometries/DecalGeometry.js";
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* Bullet holes, and any other flat mark a game wants to leave stuck to a wall.
|
|
@@ -125,9 +128,109 @@ const scratchQuaternion = new Quaternion();
|
|
|
125
128
|
const scratchRoll = new Quaternion();
|
|
126
129
|
const scratchNormal = new Vector3();
|
|
127
130
|
|
|
131
|
+
type DecalMesh = Mesh<BufferGeometry, MeshBasicMaterial>;
|
|
132
|
+
type DecalFade = { duration: number; opacity: (progress: number) => number };
|
|
133
|
+
|
|
134
|
+
function fadeOpacity(fade: DecalFade, progress: number): number {
|
|
135
|
+
const opacity = fade.opacity(progress);
|
|
136
|
+
if (!Number.isFinite(opacity) || opacity < 0 || opacity > 1)
|
|
137
|
+
throw new Error("Invalid decal opacity: the authored curve must return a value in [0, 1].");
|
|
138
|
+
return opacity;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Projection is deliberately limited to static opaque triangles under rigid/uniform transforms. */
|
|
142
|
+
function validateReceiver(receiver: Mesh, geometry: BufferGeometry): void {
|
|
143
|
+
const kind = receiver as Mesh & {
|
|
144
|
+
isSkinnedMesh?: boolean;
|
|
145
|
+
isInstancedMesh?: boolean;
|
|
146
|
+
isBatchedMesh?: boolean;
|
|
147
|
+
};
|
|
148
|
+
const materials = Array.isArray(receiver.material) ? receiver.material : [receiver.material];
|
|
149
|
+
const unsupportedMaterial = materials.some((material) => {
|
|
150
|
+
const custom = material as typeof material & {
|
|
151
|
+
isShaderMaterial?: boolean;
|
|
152
|
+
displacementMap?: Texture | null;
|
|
153
|
+
positionNode?: unknown;
|
|
154
|
+
vertexNode?: unknown;
|
|
155
|
+
transmission?: number;
|
|
156
|
+
};
|
|
157
|
+
return (
|
|
158
|
+
material.transparent ||
|
|
159
|
+
material.opacity !== 1 ||
|
|
160
|
+
material.alphaTest > 0 ||
|
|
161
|
+
material.alphaHash ||
|
|
162
|
+
custom.isShaderMaterial ||
|
|
163
|
+
custom.displacementMap != null ||
|
|
164
|
+
custom.positionNode != null ||
|
|
165
|
+
custom.vertexNode != null ||
|
|
166
|
+
(custom.transmission ?? 0) > 0
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
if (
|
|
170
|
+
!receiver.isMesh ||
|
|
171
|
+
kind.isSkinnedMesh ||
|
|
172
|
+
kind.isInstancedMesh ||
|
|
173
|
+
kind.isBatchedMesh ||
|
|
174
|
+
receiver.userData.deforming === true ||
|
|
175
|
+
unsupportedMaterial ||
|
|
176
|
+
Object.values(geometry.morphAttributes).some((attributes) => attributes.length > 0) ||
|
|
177
|
+
Object.values(receiver.geometry.morphAttributes).some((attributes) => attributes.length > 0)
|
|
178
|
+
) {
|
|
179
|
+
throw new Error("Unsupported receiver: decals require a static, opaque, non-instanced mesh.");
|
|
180
|
+
}
|
|
181
|
+
receiver.updateWorldMatrix(true, false);
|
|
182
|
+
const matrix = receiver.matrixWorld;
|
|
183
|
+
const x = new Vector3().setFromMatrixColumn(matrix, 0);
|
|
184
|
+
const y = new Vector3().setFromMatrixColumn(matrix, 1);
|
|
185
|
+
const z = new Vector3().setFromMatrixColumn(matrix, 2);
|
|
186
|
+
const length = x.lengthSq();
|
|
187
|
+
const tolerance = length * 1e-6;
|
|
188
|
+
if (
|
|
189
|
+
!matrix.elements.every(Number.isFinite) ||
|
|
190
|
+
matrix.determinant() <= 0 ||
|
|
191
|
+
length === 0 ||
|
|
192
|
+
Math.abs(y.lengthSq() - length) > tolerance ||
|
|
193
|
+
Math.abs(z.lengthSq() - length) > tolerance ||
|
|
194
|
+
Math.abs(x.dot(y)) > tolerance ||
|
|
195
|
+
Math.abs(x.dot(z)) > tolerance ||
|
|
196
|
+
Math.abs(y.dot(z)) > tolerance
|
|
197
|
+
) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
"Unsupported receiver: decals require a rigid or positive uniform-scale transform.",
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
const position = geometry.getAttribute("position");
|
|
203
|
+
const count = geometry.index?.count ?? position?.count ?? 0;
|
|
204
|
+
if (
|
|
205
|
+
position === undefined ||
|
|
206
|
+
position.itemSize !== 3 ||
|
|
207
|
+
count % 3 !== 0 ||
|
|
208
|
+
geometry.drawRange.start !== 0 ||
|
|
209
|
+
geometry.drawRange.count !== Number.POSITIVE_INFINITY
|
|
210
|
+
) {
|
|
211
|
+
throw new Error("Unsupported receiver: decals require complete triangle geometry.");
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Keep upstream clipping/UVs, but do not paint a thin receiver's reverse-facing triangles. */
|
|
216
|
+
function frontFaces(geometry: BufferGeometry, normal: Vector3): number[] {
|
|
217
|
+
const position = geometry.getAttribute("position");
|
|
218
|
+
const a = new Vector3();
|
|
219
|
+
const b = new Vector3();
|
|
220
|
+
const c = new Vector3();
|
|
221
|
+
const indices: number[] = [];
|
|
222
|
+
for (let index = 0; index < position.count; index += 3) {
|
|
223
|
+
a.fromBufferAttribute(position, index);
|
|
224
|
+
b.fromBufferAttribute(position, index + 1).sub(a);
|
|
225
|
+
c.fromBufferAttribute(position, index + 2).sub(a);
|
|
226
|
+
if (b.cross(c).dot(normal) > 0) indices.push(index, index + 1, index + 2);
|
|
227
|
+
}
|
|
228
|
+
return indices;
|
|
229
|
+
}
|
|
230
|
+
|
|
128
231
|
/** One family of marks: its own material, its own slots, its own recycle cursor. */
|
|
129
232
|
type Variant = {
|
|
130
|
-
readonly slots:
|
|
233
|
+
readonly slots: DecalMesh[];
|
|
131
234
|
readonly material: MeshBasicMaterial;
|
|
132
235
|
cursor: number;
|
|
133
236
|
};
|
|
@@ -135,9 +238,16 @@ type Variant = {
|
|
|
135
238
|
export class DecalField<TVariant extends string> {
|
|
136
239
|
readonly #variants = new Map<TVariant, Variant>();
|
|
137
240
|
readonly #geometry: PlaneGeometry;
|
|
241
|
+
readonly #parent: Object3D;
|
|
242
|
+
readonly #size: number;
|
|
243
|
+
readonly #projected = new Map<
|
|
244
|
+
DecalMesh,
|
|
245
|
+
{ receiver: Mesh; removed: () => void; elapsed: number; fade?: DecalFade }
|
|
246
|
+
>();
|
|
138
247
|
readonly #offset: number;
|
|
139
248
|
#placed = 0;
|
|
140
249
|
#capacity = 0;
|
|
250
|
+
#disposed = false;
|
|
141
251
|
/** Slots stop being submitted once their pipeline exists. See `settle`. */
|
|
142
252
|
#settled = false;
|
|
143
253
|
|
|
@@ -148,6 +258,7 @@ export class DecalField<TVariant extends string> {
|
|
|
148
258
|
countPerVariant: number;
|
|
149
259
|
/** Edge length of one mark in metres, before the per-place scale multiplier. */
|
|
150
260
|
size: number;
|
|
261
|
+
/** Borrowed: the caller retains ownership and disposes this after its last user. */
|
|
151
262
|
map: Texture;
|
|
152
263
|
/** Tint per variant: a hole in steel keeps a colder rim than one in wood. */
|
|
153
264
|
tints: Readonly<Record<TVariant, number>>;
|
|
@@ -156,6 +267,8 @@ export class DecalField<TVariant extends string> {
|
|
|
156
267
|
renderOrder?: number;
|
|
157
268
|
},
|
|
158
269
|
) {
|
|
270
|
+
this.#parent = parent;
|
|
271
|
+
this.#size = options.size;
|
|
159
272
|
this.#offset = options.offset ?? 0.018;
|
|
160
273
|
this.#geometry = new PlaneGeometry(options.size, options.size);
|
|
161
274
|
for (const [name, tint] of Object.entries(options.tints) as [TVariant, number][]) {
|
|
@@ -168,7 +281,7 @@ export class DecalField<TVariant extends string> {
|
|
|
168
281
|
side: DoubleSide,
|
|
169
282
|
transparent: true,
|
|
170
283
|
});
|
|
171
|
-
const slots:
|
|
284
|
+
const slots: DecalMesh[] = [];
|
|
172
285
|
for (let index = 0; index < options.countPerVariant; index += 1) {
|
|
173
286
|
const mesh = new Mesh(this.#geometry, material.clone());
|
|
174
287
|
// Present from the first frame at a size nothing can see, so this material's pipeline is
|
|
@@ -229,6 +342,7 @@ export class DecalField<TVariant extends string> {
|
|
|
229
342
|
const mesh = family.slots[family.cursor % family.slots.length];
|
|
230
343
|
family.cursor += 1;
|
|
231
344
|
if (mesh === undefined) return;
|
|
345
|
+
this.#releaseProjection(mesh);
|
|
232
346
|
this.#placed += 1;
|
|
233
347
|
scratchNormal.copy(normal).normalize();
|
|
234
348
|
scratchQuaternion.setFromUnitVectors(FORWARD, scratchNormal);
|
|
@@ -244,6 +358,179 @@ export class DecalField<TVariant extends string> {
|
|
|
244
358
|
mesh.updateMatrixWorld(true);
|
|
245
359
|
}
|
|
246
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Opt-in projection: pass the existing hit object and its authored/base geometry from the game.
|
|
363
|
+
* `point`, `normal`, `depth` and the size multiplier are world-space. Returns false on a miss or
|
|
364
|
+
* absent slot. Only this receiver is clipped; nearby objects are never projected onto. The
|
|
365
|
+
* upstream corner/overlap distortion remains: keep depth narrow for thin or concave surfaces.
|
|
366
|
+
* `uvRect` selects normalized atlas bounds without mutating the borrowed map. Optional fade
|
|
367
|
+
* duration is seconds; its authored opacity curve receives normalized progress in [0, 1).
|
|
368
|
+
* Call `update(dt)` each frame for expiry and receivers removed through an ancestor subtree.
|
|
369
|
+
*/
|
|
370
|
+
project(
|
|
371
|
+
receiver: Mesh,
|
|
372
|
+
geometry: BufferGeometry,
|
|
373
|
+
point: Vector3,
|
|
374
|
+
normal: Vector3,
|
|
375
|
+
variant: TVariant,
|
|
376
|
+
options: {
|
|
377
|
+
depth: number;
|
|
378
|
+
scale?: number;
|
|
379
|
+
uvRect?: readonly [number, number, number, number];
|
|
380
|
+
fade?: DecalFade;
|
|
381
|
+
},
|
|
382
|
+
): boolean {
|
|
383
|
+
const family = this.#variants.get(variant);
|
|
384
|
+
const mesh = family?.slots[family.cursor % family.slots.length];
|
|
385
|
+
if (family === undefined || mesh === undefined) return false;
|
|
386
|
+
const size = this.#size * (options.scale ?? 1);
|
|
387
|
+
if (
|
|
388
|
+
![
|
|
389
|
+
point.x,
|
|
390
|
+
point.y,
|
|
391
|
+
point.z,
|
|
392
|
+
normal.x,
|
|
393
|
+
normal.y,
|
|
394
|
+
normal.z,
|
|
395
|
+
size,
|
|
396
|
+
options.depth,
|
|
397
|
+
this.#offset,
|
|
398
|
+
].every(Number.isFinite) ||
|
|
399
|
+
size <= 0 ||
|
|
400
|
+
options.depth <= 0 ||
|
|
401
|
+
!Number.isFinite(normal.lengthSq()) ||
|
|
402
|
+
normal.lengthSq() === 0
|
|
403
|
+
) {
|
|
404
|
+
throw new Error(
|
|
405
|
+
"Invalid decal projector: finite point/normal and positive size/depth required.",
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
if (this.#offset < 0 || this.#offset > options.depth / 2)
|
|
409
|
+
throw new Error("Invalid decal bias: offset must be in [0, projector depth / 2].");
|
|
410
|
+
const rect = options.uvRect;
|
|
411
|
+
if (
|
|
412
|
+
rect !== undefined &&
|
|
413
|
+
(rect.length !== 4 ||
|
|
414
|
+
!rect.every(Number.isFinite) ||
|
|
415
|
+
rect[0] < 0 ||
|
|
416
|
+
rect[1] < 0 ||
|
|
417
|
+
rect[2] > 1 ||
|
|
418
|
+
rect[3] > 1 ||
|
|
419
|
+
rect[0] >= rect[2] ||
|
|
420
|
+
rect[1] >= rect[3])
|
|
421
|
+
)
|
|
422
|
+
throw new Error("Invalid decal atlas rectangle: ordered UV bounds in [0, 1] required.");
|
|
423
|
+
// Snapshot timing so mutating a caller's options cannot invalidate a live mark.
|
|
424
|
+
const fade = options.fade === undefined ? undefined : { ...options.fade };
|
|
425
|
+
if (
|
|
426
|
+
fade !== undefined &&
|
|
427
|
+
(!Number.isFinite(fade.duration) || fade.duration <= 0 || typeof fade.opacity !== "function")
|
|
428
|
+
)
|
|
429
|
+
throw new Error("Invalid decal fade: positive finite duration and opacity curve required.");
|
|
430
|
+
const opacity = fade === undefined ? 1 : fadeOpacity(fade, 0);
|
|
431
|
+
validateReceiver(receiver, geometry);
|
|
432
|
+
if (!this.#contains(receiver))
|
|
433
|
+
throw new Error("Unsupported receiver: mesh is outside the field's parent.");
|
|
434
|
+
const direction = normal.clone().normalize();
|
|
435
|
+
const orientation = new Quaternion().setFromUnitVectors(FORWARD, direction);
|
|
436
|
+
orientation.multiply(
|
|
437
|
+
new Quaternion().setFromAxisAngle(FORWARD, ((this.#placed + 1) * 2.399) % (Math.PI * 2)),
|
|
438
|
+
);
|
|
439
|
+
// A proxy borrows the authored geometry without ever swapping the receiver's render LOD.
|
|
440
|
+
const source = new Mesh(geometry, receiver.material);
|
|
441
|
+
source.matrixWorld.copy(receiver.matrixWorld);
|
|
442
|
+
const projected = new DecalGeometry(
|
|
443
|
+
source,
|
|
444
|
+
point,
|
|
445
|
+
new Euler().setFromQuaternion(orientation),
|
|
446
|
+
new Vector3(size, size, options.depth),
|
|
447
|
+
);
|
|
448
|
+
const indices = frontFaces(projected, direction);
|
|
449
|
+
if (indices.length === 0) {
|
|
450
|
+
projected.dispose();
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
projected.setIndex(indices);
|
|
454
|
+
if (rect !== undefined) {
|
|
455
|
+
const uv = projected.getAttribute("uv");
|
|
456
|
+
for (let i = 0; i < uv.count; i += 1)
|
|
457
|
+
uv.setXY(
|
|
458
|
+
i,
|
|
459
|
+
rect[0] + uv.getX(i) * (rect[2] - rect[0]),
|
|
460
|
+
rect[1] + uv.getY(i) * (rect[3] - rect[1]),
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
projected.translate(
|
|
464
|
+
direction.x * this.#offset,
|
|
465
|
+
direction.y * this.#offset,
|
|
466
|
+
direction.z * this.#offset,
|
|
467
|
+
);
|
|
468
|
+
projected.applyMatrix4(new Matrix4().copy(receiver.matrixWorld).invert());
|
|
469
|
+
this.#releaseProjection(mesh);
|
|
470
|
+
mesh.geometry = projected;
|
|
471
|
+
mesh.position.set(0, 0, 0);
|
|
472
|
+
mesh.quaternion.identity();
|
|
473
|
+
mesh.scale.setScalar(1);
|
|
474
|
+
mesh.visible = true;
|
|
475
|
+
mesh.material.opacity = opacity;
|
|
476
|
+
receiver.add(mesh);
|
|
477
|
+
const removed = (): void => this.#releaseProjection(mesh);
|
|
478
|
+
this.#projected.set(mesh, { receiver, removed, elapsed: 0, fade });
|
|
479
|
+
receiver.addEventListener("removed", removed);
|
|
480
|
+
mesh.updateWorldMatrix(true, false);
|
|
481
|
+
family.cursor += 1;
|
|
482
|
+
this.#placed += 1;
|
|
483
|
+
return true;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/** Release marks before a receiver is destroyed; its geometry and material remain borrowed. */
|
|
487
|
+
removeReceiver(receiver: Mesh): void {
|
|
488
|
+
for (const [mesh, entry] of this.#projected) {
|
|
489
|
+
if (entry.receiver === receiver) this.#releaseProjection(mesh);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** Advance authored fades and clean detached ancestors, visiting at most the slot capacity. */
|
|
494
|
+
update(dt = 0): void {
|
|
495
|
+
if (!Number.isFinite(dt) || dt < 0)
|
|
496
|
+
throw new Error("Invalid decal timestep: finite nonnegative seconds required.");
|
|
497
|
+
for (const [mesh, entry] of this.#projected) {
|
|
498
|
+
if (!this.#contains(entry.receiver)) {
|
|
499
|
+
this.#releaseProjection(mesh);
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
if (entry.fade === undefined) continue;
|
|
503
|
+
const elapsed = Math.min(entry.elapsed + dt, entry.fade.duration);
|
|
504
|
+
if (elapsed >= entry.fade.duration) this.#releaseProjection(mesh);
|
|
505
|
+
else {
|
|
506
|
+
mesh.material.opacity = fadeOpacity(entry.fade, elapsed / entry.fade.duration);
|
|
507
|
+
entry.elapsed = elapsed;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
#contains(object: Object3D): boolean {
|
|
513
|
+
for (let current: Object3D | null = object; current !== null; current = current.parent) {
|
|
514
|
+
if (current === this.#parent) return true;
|
|
515
|
+
}
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
#releaseProjection(mesh: DecalMesh): void {
|
|
520
|
+
const entry = this.#projected.get(mesh);
|
|
521
|
+
if (entry === undefined) return;
|
|
522
|
+
entry.receiver.removeEventListener("removed", entry.removed);
|
|
523
|
+
this.#projected.delete(mesh);
|
|
524
|
+
mesh.geometry.dispose();
|
|
525
|
+
mesh.geometry = this.#geometry;
|
|
526
|
+
this.#parent.add(mesh);
|
|
527
|
+
mesh.position.set(0, 0, 0);
|
|
528
|
+
mesh.quaternion.identity();
|
|
529
|
+
mesh.scale.setScalar(0.0001);
|
|
530
|
+
mesh.visible = false;
|
|
531
|
+
mesh.material.opacity = 1;
|
|
532
|
+
}
|
|
533
|
+
|
|
247
534
|
/** Registered as an entity so a scenario can assert that a round actually left a mark. */
|
|
248
535
|
debug(): { capacity: number; placed: number } {
|
|
249
536
|
return { capacity: this.#capacity, placed: this.#placed };
|
|
@@ -253,6 +540,7 @@ export class DecalField<TVariant extends string> {
|
|
|
253
540
|
clear(): void {
|
|
254
541
|
for (const family of this.#variants.values()) {
|
|
255
542
|
for (const mesh of family.slots) {
|
|
543
|
+
this.#releaseProjection(mesh);
|
|
256
544
|
mesh.scale.setScalar(0.0001);
|
|
257
545
|
if (this.#settled) mesh.visible = false;
|
|
258
546
|
}
|
|
@@ -261,9 +549,15 @@ export class DecalField<TVariant extends string> {
|
|
|
261
549
|
}
|
|
262
550
|
|
|
263
551
|
dispose(): void {
|
|
552
|
+
if (this.#disposed) return;
|
|
553
|
+
this.#disposed = true;
|
|
264
554
|
for (const family of this.#variants.values()) {
|
|
265
|
-
for (const mesh of family.slots)
|
|
266
|
-
|
|
555
|
+
for (const mesh of family.slots) {
|
|
556
|
+
this.#releaseProjection(mesh);
|
|
557
|
+
mesh.removeFromParent();
|
|
558
|
+
mesh.material.dispose();
|
|
559
|
+
}
|
|
560
|
+
family.material.dispose();
|
|
267
561
|
}
|
|
268
562
|
this.#variants.clear();
|
|
269
563
|
this.#geometry.dispose();
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// Generated for you. Measure actual source radiance; unreadable environments stay unknown.
|
|
2
|
+
import {
|
|
3
|
+
type Color,
|
|
4
|
+
EquirectangularReflectionMapping,
|
|
5
|
+
FloatType,
|
|
6
|
+
LinearSRGBColorSpace,
|
|
7
|
+
NoColorSpace,
|
|
8
|
+
RGBAFormat,
|
|
9
|
+
SRGBColorSpace,
|
|
10
|
+
type Scene,
|
|
11
|
+
type Texture,
|
|
12
|
+
UnsignedByteType,
|
|
13
|
+
} from "three";
|
|
14
|
+
|
|
15
|
+
export interface IEnvironmentMeasurement {
|
|
16
|
+
readonly status: "measured" | "unknown";
|
|
17
|
+
readonly meanRadiance: number | null;
|
|
18
|
+
readonly meanRGB: readonly [number, number, number] | null;
|
|
19
|
+
readonly reason: string;
|
|
20
|
+
}
|
|
21
|
+
const unknown = (reason: string): IEnvironmentMeasurement => ({
|
|
22
|
+
status: "unknown",
|
|
23
|
+
meanRadiance: null,
|
|
24
|
+
meanRGB: null,
|
|
25
|
+
reason,
|
|
26
|
+
});
|
|
27
|
+
const linear = (value: number) =>
|
|
28
|
+
value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
29
|
+
|
|
30
|
+
function validSize(value: unknown): value is number {
|
|
31
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
32
|
+
}
|
|
33
|
+
interface IReadableSource {
|
|
34
|
+
readonly status: "source";
|
|
35
|
+
readonly data: Uint8Array | Float32Array;
|
|
36
|
+
readonly width: number;
|
|
37
|
+
readonly height: number;
|
|
38
|
+
readonly bytes: boolean;
|
|
39
|
+
}
|
|
40
|
+
function readSource(
|
|
41
|
+
texture: Texture,
|
|
42
|
+
maxSourceTexels: number,
|
|
43
|
+
): IReadableSource | IEnvironmentMeasurement {
|
|
44
|
+
if (texture.mapping !== EquirectangularReflectionMapping)
|
|
45
|
+
return unknown("Only CPU-readable equirectangular source radiance is qualified.");
|
|
46
|
+
const image: unknown = texture.image;
|
|
47
|
+
if (
|
|
48
|
+
image === null ||
|
|
49
|
+
typeof image !== "object" ||
|
|
50
|
+
!("data" in image) ||
|
|
51
|
+
!("width" in image) ||
|
|
52
|
+
!("height" in image)
|
|
53
|
+
)
|
|
54
|
+
return unknown("Environment source pixels are not CPU-readable; no radiance was inferred.");
|
|
55
|
+
const { data, width, height } = image;
|
|
56
|
+
if (!validSize(width) || !validSize(height))
|
|
57
|
+
return unknown("Environment source dimensions are invalid.");
|
|
58
|
+
if (width * height > maxSourceTexels)
|
|
59
|
+
return unknown("Environment CPU sample budget exceeded; no radiance was inferred.");
|
|
60
|
+
if (texture.format !== RGBAFormat)
|
|
61
|
+
return unknown("Only explicit RGBA source samples are qualified.");
|
|
62
|
+
const bytes = texture.type === UnsignedByteType && data instanceof Uint8Array;
|
|
63
|
+
const floats = texture.type === FloatType && data instanceof Float32Array;
|
|
64
|
+
if (!bytes && !floats) return unknown("Environment source sample type is not qualified.");
|
|
65
|
+
if (data.length !== width * height * 4)
|
|
66
|
+
return unknown("Environment source samples do not match their dimensions.");
|
|
67
|
+
if (
|
|
68
|
+
!new Set<string>([NoColorSpace, LinearSRGBColorSpace, SRGBColorSpace]).has(texture.colorSpace)
|
|
69
|
+
)
|
|
70
|
+
return unknown("Environment source color-space conversion is not qualified.");
|
|
71
|
+
return { status: "source", data, width, height, bytes };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function accumulate(source: IReadableSource, srgb: boolean) {
|
|
75
|
+
const { data, width, height, bytes } = source;
|
|
76
|
+
const sums = [0, 0, 0];
|
|
77
|
+
const weights = Array.from(
|
|
78
|
+
{ length: height },
|
|
79
|
+
(_, y) => Math.cos((Math.PI * y) / height) - Math.cos((Math.PI * (y + 1)) / height),
|
|
80
|
+
);
|
|
81
|
+
for (let offset = 0; offset < data.length; offset += 4) {
|
|
82
|
+
const weight = weights[Math.floor(offset / (width * 4))] ?? 0;
|
|
83
|
+
for (let channel = 0; channel < 3; channel += 1) {
|
|
84
|
+
const sample = data[offset + channel];
|
|
85
|
+
if (sample === undefined || !Number.isFinite(sample) || sample < 0)
|
|
86
|
+
return unknown("Environment radiance samples must be finite and nonnegative.");
|
|
87
|
+
const value = bytes ? sample / 255 : sample;
|
|
88
|
+
sums[channel] = (sums[channel] ?? 0) + (srgb ? linear(value) : value) * weight;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return { sums, weightSum: weights.reduce((a, b) => a + b, 0) * width };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* CPU-readable equirectangular source radiance only; no DOM/canvas or invented JPEG mean.
|
|
96
|
+
* Rows are weighted by their exact spherical solid angle, rather than overweighting the poles.
|
|
97
|
+
* Arbitrary GPU/compressed/HTML/cube sources remain explicitly unknown until separately proven.
|
|
98
|
+
*/
|
|
99
|
+
export function measureEnvironment(scene: Scene, maxSourceTexels: number): IEnvironmentMeasurement {
|
|
100
|
+
if (!Number.isSafeInteger(maxSourceTexels) || maxSourceTexels < 1)
|
|
101
|
+
throw new Error("Environment CPU sample budget must be a positive safe integer.");
|
|
102
|
+
const texture = scene.environment;
|
|
103
|
+
if (texture === null)
|
|
104
|
+
return {
|
|
105
|
+
status: "measured",
|
|
106
|
+
meanRadiance: 0,
|
|
107
|
+
meanRGB: [0, 0, 0],
|
|
108
|
+
reason: "No environment is bound.",
|
|
109
|
+
};
|
|
110
|
+
if (!Number.isFinite(scene.environmentIntensity) || scene.environmentIntensity < 0)
|
|
111
|
+
return unknown("Environment intensity must be finite and nonnegative.");
|
|
112
|
+
const source = readSource(texture, maxSourceTexels);
|
|
113
|
+
if (source.status !== "source") return source;
|
|
114
|
+
const accumulated = accumulate(source, texture.colorSpace === SRGBColorSpace);
|
|
115
|
+
if ("status" in accumulated) return accumulated;
|
|
116
|
+
const { sums, weightSum } = accumulated;
|
|
117
|
+
const meanRGB = sums.map((sum) => (sum / weightSum) * scene.environmentIntensity) as [
|
|
118
|
+
number,
|
|
119
|
+
number,
|
|
120
|
+
number,
|
|
121
|
+
];
|
|
122
|
+
const meanRadiance = meanRGB[0] * 0.2126 + meanRGB[1] * 0.7152 + meanRGB[2] * 0.0722;
|
|
123
|
+
if (!meanRGB.every(Number.isFinite) || !Number.isFinite(meanRadiance))
|
|
124
|
+
return unknown("Environment radiance accumulation overflowed.");
|
|
125
|
+
return {
|
|
126
|
+
status: "measured",
|
|
127
|
+
meanRadiance,
|
|
128
|
+
meanRGB,
|
|
129
|
+
reason: "Solid-angle-weighted linear source radiance, with active environment intensity.",
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
interface IContributionControls {
|
|
134
|
+
readonly darkThreshold: number;
|
|
135
|
+
readonly rimGain: number;
|
|
136
|
+
readonly fillGain: number;
|
|
137
|
+
readonly fillAdmitted: boolean;
|
|
138
|
+
readonly fillColor: Color;
|
|
139
|
+
readonly maxSourceTexels: number;
|
|
140
|
+
}
|
|
141
|
+
function fillReport(options: IContributionControls) {
|
|
142
|
+
const blackColorOverride = options.fillColor.toArray().every((value) => value === 0);
|
|
143
|
+
let reason = "analytic fill enabled by caller; contribution still needs pixel qualification";
|
|
144
|
+
if (!options.fillAdmitted) reason = "not admitted by this qualification";
|
|
145
|
+
else if (options.fillGain === 0) reason = "disabled by fillGain override";
|
|
146
|
+
else if (blackColorOverride) reason = "disabled by black fillColor override";
|
|
147
|
+
return {
|
|
148
|
+
requestedGain: options.fillGain,
|
|
149
|
+
admitted: options.fillAdmitted,
|
|
150
|
+
effectiveGain: options.fillAdmitted ? options.fillGain : 0,
|
|
151
|
+
color: options.fillColor.toArray(),
|
|
152
|
+
blackColorOverride,
|
|
153
|
+
reason,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/** Overrides change the look, never whether its source contribution is measured/reported. */
|
|
157
|
+
export function reportEnvironmentContribution(
|
|
158
|
+
scene: Scene,
|
|
159
|
+
options: IContributionControls,
|
|
160
|
+
measurement?: IEnvironmentMeasurement,
|
|
161
|
+
) {
|
|
162
|
+
if (
|
|
163
|
+
![
|
|
164
|
+
options.darkThreshold,
|
|
165
|
+
options.rimGain,
|
|
166
|
+
options.fillGain,
|
|
167
|
+
...options.fillColor.toArray(),
|
|
168
|
+
].every((value) => Number.isFinite(value) && value >= 0)
|
|
169
|
+
)
|
|
170
|
+
throw new Error("Backlight measurement controls must be finite and nonnegative.");
|
|
171
|
+
const measured = measurement ?? measureEnvironment(scene, options.maxSourceTexels);
|
|
172
|
+
const dark =
|
|
173
|
+
measured.meanRadiance === null ? null : measured.meanRadiance <= options.darkThreshold;
|
|
174
|
+
const environmentState =
|
|
175
|
+
scene.environment === null ? "missing" : dark === null ? "unknown" : dark ? "dark" : "bright";
|
|
176
|
+
const report = {
|
|
177
|
+
...measured,
|
|
178
|
+
scope: "scene environment source availability; not material-specific reflected contribution",
|
|
179
|
+
environmentState,
|
|
180
|
+
ibl: dark === null ? "unknown" : dark ? "non-contributing" : "contributing",
|
|
181
|
+
analyticFill: fillReport(options),
|
|
182
|
+
rimGain: options.rimGain,
|
|
183
|
+
fillGain: options.fillGain,
|
|
184
|
+
darkThreshold: options.darkThreshold,
|
|
185
|
+
};
|
|
186
|
+
console.info(`TN_ENVIRONMENT_CONTRIBUTION:${JSON.stringify(report)}`);
|
|
187
|
+
return report;
|
|
188
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Generated for you. Spherical accumulation of bounded linear source samples.
|
|
2
|
+
import type { IEnvironmentMeasurement } from "./environmentContribution.js";
|
|
3
|
+
const WIDTH = 64;
|
|
4
|
+
const HEIGHT = 32;
|
|
5
|
+
function unmeasured(reason: string): IEnvironmentMeasurement {
|
|
6
|
+
return { status: "unknown", meanRadiance: null, meanRGB: null, reason };
|
|
7
|
+
}
|
|
8
|
+
export function sampledRadiance(samples: unknown, intensity: number): IEnvironmentMeasurement {
|
|
9
|
+
if (!(samples instanceof Float32Array) || samples.length !== WIDTH * HEIGHT * 4)
|
|
10
|
+
return unmeasured("GPU readback did not provide the qualified float RGBA sample layout.");
|
|
11
|
+
const sums = [0, 0, 0];
|
|
12
|
+
const weights = Array.from(
|
|
13
|
+
{ length: HEIGHT },
|
|
14
|
+
(_, y) => Math.cos((Math.PI * y) / HEIGHT) - Math.cos((Math.PI * (y + 1)) / HEIGHT),
|
|
15
|
+
);
|
|
16
|
+
const totalWeight = weights.reduce((sum, weight) => sum + weight, 0) * WIDTH;
|
|
17
|
+
for (const [offset, value] of samples.entries()) {
|
|
18
|
+
const channel = offset % 4;
|
|
19
|
+
if (channel === 3) continue;
|
|
20
|
+
if (!Number.isFinite(value) || value < 0)
|
|
21
|
+
return unmeasured("GPU radiance samples must be finite and nonnegative.");
|
|
22
|
+
const weight = weights[Math.floor(offset / (WIDTH * 4))] ?? 0;
|
|
23
|
+
sums[channel] = (sums[channel] ?? 0) + value * weight;
|
|
24
|
+
}
|
|
25
|
+
const meanRGB = sums.map((sum) => (sum / totalWeight) * intensity) as [number, number, number];
|
|
26
|
+
const meanRadiance = meanRGB[0] * 0.2126 + meanRGB[1] * 0.7152 + meanRGB[2] * 0.0722;
|
|
27
|
+
if (!meanRGB.every(Number.isFinite) || !Number.isFinite(meanRadiance))
|
|
28
|
+
return unmeasured("GPU radiance accumulation overflowed.");
|
|
29
|
+
return {
|
|
30
|
+
status: "measured",
|
|
31
|
+
meanRGB,
|
|
32
|
+
meanRadiance,
|
|
33
|
+
reason:
|
|
34
|
+
"Estimated linear scene-environment source radiance from 64x32 GPU samples, spherical row weighting and active intensity; not material-specific BRDF contribution.",
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Generated for you. Weak ownership and full provenance guard successful source estimates.
|
|
2
|
+
import type { Scene, Texture } from "three";
|
|
3
|
+
import type { IEnvironmentSample } from "./environmentSampling.js";
|
|
4
|
+
import { environmentSnapshotCurrent } from "./environmentSnapshot.js";
|
|
5
|
+
const samples = new WeakMap<object, WeakMap<Texture, IEnvironmentSample>>();
|
|
6
|
+
export function cachedEnvironmentSample(
|
|
7
|
+
renderer: object,
|
|
8
|
+
scene: Scene,
|
|
9
|
+
): IEnvironmentSample | undefined {
|
|
10
|
+
if (scene.environment === null) return undefined;
|
|
11
|
+
const sample = samples.get(renderer)?.get(scene.environment);
|
|
12
|
+
return sample !== undefined && environmentSnapshotCurrent(scene, sample)
|
|
13
|
+
? copySample(sample)
|
|
14
|
+
: undefined;
|
|
15
|
+
}
|
|
16
|
+
export function cacheEnvironmentSample(
|
|
17
|
+
renderer: object,
|
|
18
|
+
scene: Scene,
|
|
19
|
+
sample: IEnvironmentSample,
|
|
20
|
+
): void {
|
|
21
|
+
if (
|
|
22
|
+
sample.source === null ||
|
|
23
|
+
sample.measurement.status !== "measured" ||
|
|
24
|
+
!environmentSnapshotCurrent(scene, sample)
|
|
25
|
+
)
|
|
26
|
+
return;
|
|
27
|
+
let byTexture = samples.get(renderer);
|
|
28
|
+
if (byTexture === undefined) {
|
|
29
|
+
byTexture = new WeakMap();
|
|
30
|
+
samples.set(renderer, byTexture);
|
|
31
|
+
}
|
|
32
|
+
byTexture.set(sample.source, copySample(sample));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function copySample(sample: IEnvironmentSample): IEnvironmentSample {
|
|
36
|
+
return {
|
|
37
|
+
...sample,
|
|
38
|
+
measurement: {
|
|
39
|
+
...sample.measurement,
|
|
40
|
+
meanRGB: sample.measurement.meanRGB === null ? null : [...sample.measurement.meanRGB],
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|