create-threenative 0.2.8 → 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/agent-docs/references/assertion-reference.md +87 -35
- package/agent-docs/references/auto-exposure.md +57 -0
- package/agent-docs/references/capability-reference.md +1097 -23
- 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 +1210 -27
- package/dist/index.d.ts +28 -3
- package/dist/index.js +396 -166
- package/dist/threenative.js +986 -235
- 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/AGENTS.md +8 -9
- package/templates/rain/CLAUDE.md +8 -9
- package/templates/rain/native-playtests/boot.playtest.json +11 -1
- package/templates/rain/package.json +12 -9
- package/templates/rain/playtests/automation.playtest.json +1 -1
- package/templates/rain/playtests/performance.playtest.json +11 -1
- package/templates/rain/playtests/tiers.playtest.json +15 -0
- package/templates/rain/playtests/weather.playtest.json +1 -1
- package/templates/rain/src/game.ts +1 -34
- package/templates/rain/src/render/autoExposure.ts +225 -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/postprocessing.ts +3 -0
- package/templates/rain/src/render/quality.ts +27 -1
- package/templates/rain/src/render/worldEnvironment.ts +433 -30
- package/templates/rain/src/scenes/Boot.ts +14 -0
- package/templates/rain/src/state.ts +5 -1
- package/templates/rain/src/ui/GameUi.tsx +6 -6
- package/templates/rain/tools/generate-shaders.mjs +1 -1
- package/templates/rain/vite.config.ts +10 -2
- 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/AGENTS.md +8 -6
- package/templates/snow/CLAUDE.md +8 -6
- package/templates/snow/package.json +11 -9
- 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/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/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 +33 -1
- package/templates/snow/src/render/materialAssignments.ts +160 -0
- package/templates/snow/src/render/materialLighting.ts +155 -0
- package/templates/snow/src/render/postprocessing.ts +16 -2
- package/templates/snow/src/render/quality.ts +59 -1
- package/templates/snow/src/render/sky.ts +21 -2
- package/templates/snow/src/render/worldEnvironment.ts +433 -30
- package/templates/snow/src/scenes/Snow.ts +29 -1
- package/templates/snow/threenative.config.ts +3 -0
- package/templates/snow/vite.config.ts +10 -2
- 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
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { DataTexture, RGBAFormat, LinearSRGBColorSpace, LinearFilter } from 'three';
|
|
2
|
+
|
|
3
|
+
// ../three-native/src/addons/hdr-loader.ts
|
|
4
|
+
|
|
5
|
+
// ../three-native/src/addons/data-utils.ts
|
|
6
|
+
var floatView = new Float32Array(1);
|
|
7
|
+
var uint32View = new Uint32Array(floatView.buffer);
|
|
8
|
+
var baseTable = new Uint32Array(512);
|
|
9
|
+
var shiftTable = new Uint32Array(512);
|
|
10
|
+
var mantissaTable = new Uint32Array(2048);
|
|
11
|
+
var exponentTable = new Uint32Array(64);
|
|
12
|
+
var offsetTable = new Uint32Array(64);
|
|
13
|
+
for (let i = 0; i < 256; ++i) {
|
|
14
|
+
const e = i - 127;
|
|
15
|
+
let base;
|
|
16
|
+
let shift;
|
|
17
|
+
if (e < -27) [base, shift] = [0, 24];
|
|
18
|
+
else if (e < -14) [base, shift] = [1024 >> -e - 14, -e - 1];
|
|
19
|
+
else if (e <= 15) [base, shift] = [e + 15 << 10, 13];
|
|
20
|
+
else [base, shift] = [31744, e < 128 ? 24 : 13];
|
|
21
|
+
baseTable[i] = base;
|
|
22
|
+
baseTable[i | 256] = base | 32768;
|
|
23
|
+
shiftTable[i] = shiftTable[i | 256] = shift;
|
|
24
|
+
}
|
|
25
|
+
for (let i = 1; i < 1024; ++i) {
|
|
26
|
+
let m = i << 13;
|
|
27
|
+
let e = 0;
|
|
28
|
+
while ((m & 8388608) === 0) {
|
|
29
|
+
m <<= 1;
|
|
30
|
+
e -= 8388608;
|
|
31
|
+
}
|
|
32
|
+
mantissaTable[i] = m & -8388609 | e + 947912704;
|
|
33
|
+
}
|
|
34
|
+
for (let i = 1024; i < 2048; ++i) mantissaTable[i] = 939524096 + (i - 1024 << 13);
|
|
35
|
+
for (let i = 1; i < 31; ++i) exponentTable[i] = i << 23;
|
|
36
|
+
exponentTable[31] = 1199570944;
|
|
37
|
+
exponentTable[32] = 2147483648;
|
|
38
|
+
for (let i = 33; i < 63; ++i) exponentTable[i] = 2147483648 + (i - 32 << 23);
|
|
39
|
+
exponentTable[63] = 3347054592;
|
|
40
|
+
for (let i = 1; i < 64; ++i) if (i !== 32) offsetTable[i] = 1024;
|
|
41
|
+
function toHalfFloat(value) {
|
|
42
|
+
floatView[0] = Math.max(-65504, Math.min(65504, value));
|
|
43
|
+
const f = uint32View[0] ?? 0;
|
|
44
|
+
const e = f >> 23 & 511;
|
|
45
|
+
return (baseTable[e] ?? 0) + ((f & 8388607) >> (shiftTable[e] ?? 0));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ../three-native/src/addons/hdr.ts
|
|
49
|
+
var FLOAT_TYPE = 1015;
|
|
50
|
+
var HALF_FLOAT_TYPE = 1016;
|
|
51
|
+
function fail(message) {
|
|
52
|
+
throw new Error(`TN_HDR_INVALID: ${message}`);
|
|
53
|
+
}
|
|
54
|
+
function readHeader(bytes) {
|
|
55
|
+
let pos = 0;
|
|
56
|
+
const line = () => {
|
|
57
|
+
const end = bytes.indexOf(10, pos);
|
|
58
|
+
if (end < 0 || end - pos > 1024) return void 0;
|
|
59
|
+
const text = String.fromCharCode(...bytes.subarray(pos, end));
|
|
60
|
+
pos = end + 1;
|
|
61
|
+
return text;
|
|
62
|
+
};
|
|
63
|
+
if (!/^#\?(\S+)/.test(line() ?? "")) fail("bad initial token");
|
|
64
|
+
let format = false;
|
|
65
|
+
let width = 0;
|
|
66
|
+
let height = 0;
|
|
67
|
+
let gamma = 1;
|
|
68
|
+
let exposure = 1;
|
|
69
|
+
for (let text = line(); text !== void 0; text = line()) {
|
|
70
|
+
if (text.startsWith("#")) continue;
|
|
71
|
+
let match = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/.exec(text);
|
|
72
|
+
if (match) gamma = Number.parseFloat(match[1] ?? "1");
|
|
73
|
+
match = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/.exec(text);
|
|
74
|
+
if (match) exposure = Number.parseFloat(match[1] ?? "1");
|
|
75
|
+
if (/^\s*FORMAT=(\S+)\s*$/.test(text)) format = true;
|
|
76
|
+
match = /^\s*-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/.exec(text);
|
|
77
|
+
if (match) {
|
|
78
|
+
height = Number.parseInt(match[1] ?? "0", 10);
|
|
79
|
+
width = Number.parseInt(match[2] ?? "0", 10);
|
|
80
|
+
}
|
|
81
|
+
if (format && width > 0) break;
|
|
82
|
+
}
|
|
83
|
+
if (!format) fail("missing format specifier");
|
|
84
|
+
if (!(width > 0 && height > 0)) fail("missing image size specifier");
|
|
85
|
+
return { pos, width, height, gamma, exposure };
|
|
86
|
+
}
|
|
87
|
+
function readPixels(bytes, width, height) {
|
|
88
|
+
if (width < 8 || width > 32767 || bytes[0] !== 2 || bytes[1] !== 2 || ((bytes[2] ?? 0) & 128) !== 0)
|
|
89
|
+
return bytes;
|
|
90
|
+
if (width !== ((bytes[2] ?? 0) << 8 | (bytes[3] ?? 0))) fail("wrong scanline width");
|
|
91
|
+
const rgba = new Uint8Array(4 * width * height);
|
|
92
|
+
const scanline = new Uint8Array(4 * width);
|
|
93
|
+
let offset = 0;
|
|
94
|
+
let pos = 0;
|
|
95
|
+
for (let row = 0; row < height && pos < bytes.length; ++row) {
|
|
96
|
+
if (pos + 4 > bytes.length) fail("read error");
|
|
97
|
+
if (bytes[pos] !== 2 || bytes[pos + 1] !== 2 || ((bytes[pos + 2] ?? 0) << 8 | (bytes[pos + 3] ?? 0)) !== width)
|
|
98
|
+
fail("bad rgbe scanline format");
|
|
99
|
+
pos += 4;
|
|
100
|
+
let ptr = 0;
|
|
101
|
+
while (ptr < scanline.length && pos < bytes.length) {
|
|
102
|
+
let count = bytes[pos++] ?? 0;
|
|
103
|
+
const run = count > 128;
|
|
104
|
+
if (run) count -= 128;
|
|
105
|
+
if (count === 0 || ptr + count > scanline.length) fail("bad scanline data");
|
|
106
|
+
if (run) {
|
|
107
|
+
scanline.fill(bytes[pos++] ?? 0, ptr, ptr + count);
|
|
108
|
+
} else {
|
|
109
|
+
scanline.set(bytes.subarray(pos, pos + count), ptr);
|
|
110
|
+
pos += count;
|
|
111
|
+
}
|
|
112
|
+
ptr += count;
|
|
113
|
+
}
|
|
114
|
+
for (let i = 0; i < width; ++i, offset += 4) {
|
|
115
|
+
rgba[offset] = scanline[i] ?? 0;
|
|
116
|
+
rgba[offset + 1] = scanline[i + width] ?? 0;
|
|
117
|
+
rgba[offset + 2] = scanline[i + 2 * width] ?? 0;
|
|
118
|
+
rgba[offset + 3] = scanline[i + 3 * width] ?? 0;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return rgba;
|
|
122
|
+
}
|
|
123
|
+
function parseHDR(buffer, type = HALF_FLOAT_TYPE) {
|
|
124
|
+
if (type !== HALF_FLOAT_TYPE && type !== FLOAT_TYPE) fail(`unsupported type ${type}`);
|
|
125
|
+
const bytes = new Uint8Array(buffer);
|
|
126
|
+
const header = readHeader(bytes);
|
|
127
|
+
const rgbe = readPixels(bytes.subarray(header.pos), header.width, header.height);
|
|
128
|
+
if (rgbe.length !== 4 * header.width * header.height)
|
|
129
|
+
fail("pixel data does not match the image size");
|
|
130
|
+
const texels = header.width * header.height;
|
|
131
|
+
const data = type === FLOAT_TYPE ? new Float32Array(texels * 4) : new Uint16Array(texels * 4);
|
|
132
|
+
const one = type === FLOAT_TYPE ? 1 : toHalfFloat(1);
|
|
133
|
+
for (let j = 0; j < texels * 4; j += 4) {
|
|
134
|
+
const scale = 2 ** ((rgbe[j + 3] ?? 0) - 128) / 255;
|
|
135
|
+
for (let c = 0; c < 3; ++c) {
|
|
136
|
+
const value = (rgbe[j + c] ?? 0) * scale;
|
|
137
|
+
data[j + c] = type === FLOAT_TYPE ? value : toHalfFloat(Math.min(value, 65504));
|
|
138
|
+
}
|
|
139
|
+
data[j + 3] = one;
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
width: header.width,
|
|
143
|
+
height: header.height,
|
|
144
|
+
data,
|
|
145
|
+
type,
|
|
146
|
+
gamma: header.gamma,
|
|
147
|
+
exposure: header.exposure
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// ../three-native/src/addons/hdr-loader.ts
|
|
152
|
+
var EngineDataTexture = DataTexture;
|
|
153
|
+
var HDRLoader = class {
|
|
154
|
+
type = HALF_FLOAT_TYPE;
|
|
155
|
+
path = "";
|
|
156
|
+
setDataType(type) {
|
|
157
|
+
this.type = type;
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
setPath(path) {
|
|
161
|
+
this.path = path;
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
load(url, onLoad, _onProgress, onError) {
|
|
165
|
+
this.loadAsync(url).then(onLoad, (error) => {
|
|
166
|
+
if (onError === void 0) throw error;
|
|
167
|
+
onError(error);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
async loadAsync(url) {
|
|
171
|
+
const response = await fetch(this.path + url);
|
|
172
|
+
if (!response.ok)
|
|
173
|
+
throw new Error(`TN_HDR_FETCH: ${this.path + url} answered ${String(response.status)}`);
|
|
174
|
+
const image = parseHDR(await response.arrayBuffer(), this.type);
|
|
175
|
+
const texture = new EngineDataTexture(
|
|
176
|
+
image.data,
|
|
177
|
+
image.width,
|
|
178
|
+
image.height,
|
|
179
|
+
RGBAFormat,
|
|
180
|
+
image.type
|
|
181
|
+
);
|
|
182
|
+
texture.colorSpace = LinearSRGBColorSpace;
|
|
183
|
+
texture.minFilter = texture.magFilter = LinearFilter;
|
|
184
|
+
texture.flipY = true;
|
|
185
|
+
texture.needsUpdate = true;
|
|
186
|
+
return texture;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export { HDRLoader };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Data3DTexture, Vector3 } from 'three';
|
|
2
|
+
|
|
3
|
+
// ../three-native/src/addons/lut-cube-loader-web.ts
|
|
4
|
+
|
|
5
|
+
// ../three-native/src/addons/lut-cube-loader.ts
|
|
6
|
+
function cubeSize(words, previous) {
|
|
7
|
+
if (previous || words.length !== 2) throw new Error("TN_LUT_SIZE: expected one LUT_3D_SIZE");
|
|
8
|
+
const size = Number(words[1]);
|
|
9
|
+
if (!Number.isInteger(size) || size < 2 || size > 256)
|
|
10
|
+
throw new Error("TN_LUT_SIZE: expected 2 through 256");
|
|
11
|
+
return size;
|
|
12
|
+
}
|
|
13
|
+
function cubeRow(line, cube) {
|
|
14
|
+
if (!line || line.startsWith("#")) return;
|
|
15
|
+
const heading = /^TITLE\s+"([^"]*)"\s*(?:#.*)?$/u.exec(line);
|
|
16
|
+
if (heading) {
|
|
17
|
+
cube.title = heading[1] ?? "";
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const words = line.split("#")[0]?.trim().split(/\s+/u) ?? [];
|
|
21
|
+
const key = words[0];
|
|
22
|
+
if (key === "LUT_3D_SIZE") {
|
|
23
|
+
cube.size = cubeSize(words, cube.size);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const target = key === "DOMAIN_MIN" ? cube.min : key === "DOMAIN_MAX" ? cube.max : void 0;
|
|
27
|
+
const values = (target ? words.slice(1) : words).map(Number);
|
|
28
|
+
if (values.length !== 3 || !values.every(Number.isFinite)) throw new Error(`TN_LUT_ROW: ${line}`);
|
|
29
|
+
if (target) {
|
|
30
|
+
target.splice(0, 3, ...values);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!cube.size || cube.samples.length >= cube.size ** 3 * 4)
|
|
34
|
+
throw new Error("TN_LUT_DATA: missing size or excess samples");
|
|
35
|
+
cube.samples.push(...values, 1);
|
|
36
|
+
}
|
|
37
|
+
function parseCube(input) {
|
|
38
|
+
const cube = { title: null, size: 0, min: [0, 0, 0], max: [1, 1, 1], samples: [] };
|
|
39
|
+
for (const raw of input.split(/\r?\n/u)) cubeRow(raw.trim(), cube);
|
|
40
|
+
if (!cube.size || cube.samples.length !== cube.size ** 3 * 4)
|
|
41
|
+
throw new Error("TN_LUT_DATA: expected size cubed RGB samples");
|
|
42
|
+
if (cube.min.some((value, index) => value > (cube.max[index] ?? 0)))
|
|
43
|
+
throw new Error("TN_LUT_DOMAIN: minimum exceeds maximum");
|
|
44
|
+
return cube;
|
|
45
|
+
}
|
|
46
|
+
function defineLUTCubeLoader(classes, read) {
|
|
47
|
+
return class LUTCubeLoader {
|
|
48
|
+
constructor(manager) {
|
|
49
|
+
this.manager = manager;
|
|
50
|
+
}
|
|
51
|
+
manager;
|
|
52
|
+
type = 1009;
|
|
53
|
+
path = "";
|
|
54
|
+
setType(type) {
|
|
55
|
+
if (type !== 1009 && type !== 1015)
|
|
56
|
+
throw new Error("TN_LUT_TYPE: expected UnsignedByteType or FloatType");
|
|
57
|
+
this.type = type;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
setPath(path) {
|
|
61
|
+
this.path = path;
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
load(url, onLoad, _onProgress, onError) {
|
|
65
|
+
this.loadAsync(url).then(onLoad, (error) => {
|
|
66
|
+
if (onError === void 0) throw error;
|
|
67
|
+
onError(error);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async loadAsync(url) {
|
|
71
|
+
const resolved = this.path + url;
|
|
72
|
+
this.manager?.itemStart?.(resolved);
|
|
73
|
+
try {
|
|
74
|
+
return this.parse(await read(resolved));
|
|
75
|
+
} catch (error) {
|
|
76
|
+
this.manager?.itemError?.(resolved);
|
|
77
|
+
throw error;
|
|
78
|
+
} finally {
|
|
79
|
+
this.manager?.itemEnd?.(resolved);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
parse(input) {
|
|
83
|
+
this.setType(this.type);
|
|
84
|
+
const { title, size, min, max, samples } = parseCube(input);
|
|
85
|
+
const data = this.type === 1009 ? Uint8Array.from(samples, (value) => value * 255) : Float32Array.from(samples);
|
|
86
|
+
const texture3D = new classes.textureClass(data, size, size, size);
|
|
87
|
+
Object.assign(texture3D, {
|
|
88
|
+
type: this.type,
|
|
89
|
+
magFilter: 1006,
|
|
90
|
+
minFilter: 1006,
|
|
91
|
+
wrapS: 1001,
|
|
92
|
+
wrapT: 1001,
|
|
93
|
+
wrapR: 1001,
|
|
94
|
+
generateMipmaps: false,
|
|
95
|
+
needsUpdate: true
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
title,
|
|
99
|
+
size,
|
|
100
|
+
domainMin: new classes.vectorClass(min[0] ?? 0, min[1] ?? 0, min[2] ?? 0),
|
|
101
|
+
domainMax: new classes.vectorClass(max[0] ?? 1, max[1] ?? 1, max[2] ?? 1),
|
|
102
|
+
texture3D
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ../three-native/src/addons/lut-cube-loader-web.ts
|
|
109
|
+
var LUTCubeLoader = defineLUTCubeLoader(
|
|
110
|
+
{
|
|
111
|
+
// quality-allow: generated engine declarations omit the Data3DTexture source constructor and image record.
|
|
112
|
+
textureClass: Data3DTexture,
|
|
113
|
+
vectorClass: Vector3
|
|
114
|
+
},
|
|
115
|
+
async (url) => {
|
|
116
|
+
const response = await fetch(url);
|
|
117
|
+
if (!response.ok) throw new Error(`TN_LUT_FETCH: ${response.status} ${url}`);
|
|
118
|
+
return response.text();
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
export { LUTCubeLoader };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// ../three-native/src/refused.ts
|
|
2
|
+
function refused(name, diagnostic) {
|
|
3
|
+
const fail = () => {
|
|
4
|
+
throw new Error(`${diagnostic}: ${name} is not available on the native engine.`);
|
|
5
|
+
};
|
|
6
|
+
return new Proxy(function refusedExport() {
|
|
7
|
+
}, {
|
|
8
|
+
apply: fail,
|
|
9
|
+
construct: fail,
|
|
10
|
+
get: fail,
|
|
11
|
+
set: fail,
|
|
12
|
+
has: fail,
|
|
13
|
+
ownKeys: fail,
|
|
14
|
+
getPrototypeOf: fail,
|
|
15
|
+
defineProperty: fail,
|
|
16
|
+
deleteProperty: fail,
|
|
17
|
+
getOwnPropertyDescriptor: fail
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function unsupportedExport(name) {
|
|
21
|
+
return refused(name, `TN_NATIVE_UNSUPPORTED_${name.toUpperCase()}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ../three-native/src/addons/mesh-bvh-webgpu.ts
|
|
25
|
+
var bvhIntersectFirstHit = unsupportedExport("bvhIntersectFirstHit");
|
|
26
|
+
var rayStruct = unsupportedExport("rayStruct");
|
|
27
|
+
var bvhNodeStruct = unsupportedExport("bvhNodeStruct");
|
|
28
|
+
|
|
29
|
+
export { bvhIntersectFirstHit, bvhNodeStruct, rayStruct };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// ../three-native/src/addons/mesh-bvh.ts
|
|
2
|
+
var CENTER = 0;
|
|
3
|
+
var AVERAGE = 1;
|
|
4
|
+
var SAH = 2;
|
|
5
|
+
var MeshBVH = class {
|
|
6
|
+
geometry;
|
|
7
|
+
constructor(geometry, options) {
|
|
8
|
+
const { strategy, ...rest } = options ?? {};
|
|
9
|
+
if (strategy !== void 0 && strategy !== CENTER && strategy !== AVERAGE && strategy !== SAH)
|
|
10
|
+
throw new Error(
|
|
11
|
+
`TN_NATIVE_MESH_BVH_STRATEGY: ${String(strategy)} is not CENTER, AVERAGE or SAH`
|
|
12
|
+
);
|
|
13
|
+
const unsupported = Object.keys(rest);
|
|
14
|
+
if (unsupported.length > 0)
|
|
15
|
+
throw new Error(
|
|
16
|
+
`TN_NATIVE_MESH_BVH_OPTIONS_UNSUPPORTED: ${unsupported.join(", ")}: the engine MeshBVH builds no tree, so it takes no other build option`
|
|
17
|
+
);
|
|
18
|
+
this.geometry = geometry;
|
|
19
|
+
}
|
|
20
|
+
/** three-mesh-bvh's `raycastObject3D`: the object's hits (only the nearest with `firstHitOnly`). */
|
|
21
|
+
raycastObject3D(object, raycaster, intersects = []) {
|
|
22
|
+
const hits = raycaster.intersectObject(object, false);
|
|
23
|
+
if (raycaster.firstHitOnly === true) {
|
|
24
|
+
if (hits[0] !== void 0) intersects.push(hits[0]);
|
|
25
|
+
} else {
|
|
26
|
+
for (const hit of hits) intersects.push(hit);
|
|
27
|
+
}
|
|
28
|
+
return intersects;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { AVERAGE, CENTER, MeshBVH, SAH };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { __tnTsl } from 'three/tsl';
|
|
2
|
+
|
|
3
|
+
// ../three-native/src/addons/post-effects-web.ts
|
|
4
|
+
|
|
5
|
+
// ../three-native/src/refused.ts
|
|
6
|
+
function refused(name, diagnostic) {
|
|
7
|
+
const fail = () => {
|
|
8
|
+
throw new Error(`${diagnostic}: ${name} is not available on the native engine.`);
|
|
9
|
+
};
|
|
10
|
+
return new Proxy(function refusedExport() {
|
|
11
|
+
}, {
|
|
12
|
+
apply: fail,
|
|
13
|
+
construct: fail,
|
|
14
|
+
get: fail,
|
|
15
|
+
set: fail,
|
|
16
|
+
has: fail,
|
|
17
|
+
ownKeys: fail,
|
|
18
|
+
getPrototypeOf: fail,
|
|
19
|
+
defineProperty: fail,
|
|
20
|
+
deleteProperty: fail,
|
|
21
|
+
getOwnPropertyDescriptor: fail
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function unsupportedExport(name) {
|
|
25
|
+
return refused(name, `TN_NATIVE_UNSUPPORTED_${name.toUpperCase()}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ../three-native/src/addons/post-effects.ts
|
|
29
|
+
function uniforms(node, names) {
|
|
30
|
+
for (const name of names)
|
|
31
|
+
Object.defineProperty(node, name, {
|
|
32
|
+
configurable: true,
|
|
33
|
+
value: Object.freeze({
|
|
34
|
+
get value() {
|
|
35
|
+
return node.__effect(name);
|
|
36
|
+
},
|
|
37
|
+
set value(value) {
|
|
38
|
+
node.__effect(name, value);
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
return node;
|
|
43
|
+
}
|
|
44
|
+
function definePostEffects(tsl) {
|
|
45
|
+
return {
|
|
46
|
+
film: (input, intensity, uv) => tsl.film(input, intensity, uv),
|
|
47
|
+
lut3D: (input, lut, size, intensity) => uniforms(tsl.lut3D(input, lut, size, intensity), ["size"]),
|
|
48
|
+
traa(input, depth, velocity, camera) {
|
|
49
|
+
const node = tsl.traa(input, depth, velocity, camera);
|
|
50
|
+
const viewCamera = camera;
|
|
51
|
+
let jitterIndex = 0;
|
|
52
|
+
const halton = (start, base) => {
|
|
53
|
+
let index = start;
|
|
54
|
+
let fraction = 1;
|
|
55
|
+
let result = 0;
|
|
56
|
+
while (index > 0) {
|
|
57
|
+
fraction /= base;
|
|
58
|
+
result += fraction * (index % base);
|
|
59
|
+
index = Math.floor(index / base);
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
const setViewOffset = (width, height) => {
|
|
64
|
+
if (![width, height].every((v) => Number.isFinite(v) && v > 0))
|
|
65
|
+
throw new TypeError("TN_NATIVE_TRAA_SIZE: expected positive finite dimensions");
|
|
66
|
+
viewCamera.updateProjectionMatrix();
|
|
67
|
+
viewCamera.projectionMatrix.elements.forEach(
|
|
68
|
+
(value, i) => node.__effect(`projection${i}`, value)
|
|
69
|
+
);
|
|
70
|
+
viewCamera.setViewOffset(
|
|
71
|
+
width,
|
|
72
|
+
height,
|
|
73
|
+
halton(jitterIndex + 1, 2) - 0.5,
|
|
74
|
+
halton(jitterIndex + 1, 3) - 0.5,
|
|
75
|
+
width,
|
|
76
|
+
height
|
|
77
|
+
);
|
|
78
|
+
node.__effect("viewOffset", 1);
|
|
79
|
+
};
|
|
80
|
+
const clearViewOffset = () => {
|
|
81
|
+
viewCamera.clearViewOffset();
|
|
82
|
+
node.__effect("viewOffset", 0);
|
|
83
|
+
jitterIndex = (jitterIndex + 1) % 31;
|
|
84
|
+
};
|
|
85
|
+
Object.defineProperties(node, {
|
|
86
|
+
setViewOffset: { value: setViewOffset, configurable: true },
|
|
87
|
+
clearViewOffset: { value: clearViewOffset, configurable: true },
|
|
88
|
+
setup: {
|
|
89
|
+
configurable: true,
|
|
90
|
+
value: (builder) => {
|
|
91
|
+
const pipeline = builder.context.renderPipeline;
|
|
92
|
+
if (pipeline) {
|
|
93
|
+
pipeline.context.onBeforeRenderPipeline = () => {
|
|
94
|
+
const size = builder.renderer.getDrawingBufferSize({
|
|
95
|
+
set(width, height) {
|
|
96
|
+
return { width, height };
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
setViewOffset(size.width, size.height);
|
|
100
|
+
};
|
|
101
|
+
pipeline.context.onAfterRenderPipeline = clearViewOffset;
|
|
102
|
+
}
|
|
103
|
+
return node;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
for (const name of [
|
|
108
|
+
"depthThreshold",
|
|
109
|
+
"edgeDepthDiff",
|
|
110
|
+
"maxVelocityLength",
|
|
111
|
+
"useSubpixelCorrection"
|
|
112
|
+
])
|
|
113
|
+
Object.defineProperty(node, name, {
|
|
114
|
+
configurable: true,
|
|
115
|
+
get: () => name === "useSubpixelCorrection" ? node.__effect(name) !== 0 : node.__effect(name),
|
|
116
|
+
set: (value) => node.__effect(name, Number(value))
|
|
117
|
+
});
|
|
118
|
+
return node;
|
|
119
|
+
},
|
|
120
|
+
ao(depthNode, normalNode, camera) {
|
|
121
|
+
const node = uniforms(tsl.ao(depthNode, normalNode ?? null, camera), [
|
|
122
|
+
"radius",
|
|
123
|
+
"thickness",
|
|
124
|
+
"distanceExponent",
|
|
125
|
+
"distanceFallOff",
|
|
126
|
+
"scale",
|
|
127
|
+
"samples"
|
|
128
|
+
]);
|
|
129
|
+
Object.defineProperty(node, "resolutionScale", {
|
|
130
|
+
configurable: true,
|
|
131
|
+
get() {
|
|
132
|
+
return node.__effect("resolutionScale");
|
|
133
|
+
},
|
|
134
|
+
set(value) {
|
|
135
|
+
node.__effect("resolutionScale", value);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
node.getTextureNode = () => node;
|
|
139
|
+
return node;
|
|
140
|
+
},
|
|
141
|
+
denoise: (node, depthNode, normalNode, camera) => uniforms(tsl.denoise(node, depthNode, normalNode ?? null, camera), [
|
|
142
|
+
"lumaPhi",
|
|
143
|
+
"depthPhi",
|
|
144
|
+
"normalPhi",
|
|
145
|
+
"radius",
|
|
146
|
+
"index"
|
|
147
|
+
]),
|
|
148
|
+
smaa: (node) => tsl.smaa(node),
|
|
149
|
+
bloom: (node, strength, radius, threshold) => uniforms(tsl.bloom(node, strength, radius, threshold), [
|
|
150
|
+
"strength",
|
|
151
|
+
"radius",
|
|
152
|
+
"threshold",
|
|
153
|
+
"smoothWidth"
|
|
154
|
+
])
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ../three-native/src/addons/post-effects-web.ts
|
|
159
|
+
var { ao, denoise, smaa, bloom, traa, film, lut3D } = definePostEffects(
|
|
160
|
+
__tnTsl
|
|
161
|
+
);
|
|
162
|
+
var fxaa = unsupportedExport("fxaa");
|
|
163
|
+
var godrays = unsupportedExport("godrays");
|
|
164
|
+
var ssgi = unsupportedExport("ssgi");
|
|
165
|
+
var ssr = unsupportedExport("ssr");
|
|
166
|
+
var sharpen = unsupportedExport("sharpen");
|
|
167
|
+
|
|
168
|
+
export { ao, bloom, denoise, film, fxaa, godrays, lut3D, sharpen, smaa, ssgi, ssr, traa };
|