create-threenative 0.2.17 → 0.2.18
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/kit-mcp.md +1 -1
- package/agent-docs/kit-router.md +1 -1
- package/agent-docs/references/assertion-reference.md +54 -110
- package/agent-docs/references/capability-reference.md +580 -22
- package/agent-docs/references/conventions.md +28 -0
- package/agent-docs/references/performance-basics.md +8 -4
- package/agent-files/.agents/skills/ponytail/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +7 -4
- package/agent-files/.claude/hooks/discovery-gate.mjs +2 -2
- package/dist/index.d.ts +97 -6
- package/dist/index.js +769 -277
- package/dist/threenative.js +96 -17
- package/dist/web-engine-ccd-ik-solver.js +127 -0
- package/dist/web-engine-gltf-loader.js +52 -14
- package/dist/web-engine-post-effects.js +5 -10
- package/dist/web-engine-runtime.js +3648 -546
- package/package.json +8 -7
- package/template-assets/clearwater/README.md +1 -1
- package/template-assets/patches/manifest.json +18 -0
- package/template-assets/terrain/alpine/assets.json +12 -0
- package/template-assets/terrain/alpine/bake.mjs +6 -0
- package/template-assets/terrain/alpine/credits.json +164 -0
- package/template-assets/terrain/alpine/heightmap.r16 +0 -0
- package/template-assets/terrain/alpine/recipe.json +119 -0
- package/template-assets/terrain/alpine/surface.json +53 -0
- package/template-assets/terrain/coastal/assets.json +11 -0
- package/template-assets/terrain/coastal/bake.mjs +6 -0
- package/template-assets/terrain/coastal/credits.json +117 -0
- package/template-assets/terrain/coastal/heightmap.r16 +0 -0
- package/template-assets/terrain/coastal/recipe.json +113 -0
- package/template-assets/terrain/coastal/surface.json +41 -0
- package/template-assets/terrain/desert/assets.json +12 -0
- package/template-assets/terrain/desert/bake.mjs +6 -0
- package/template-assets/terrain/desert/credits.json +164 -0
- package/template-assets/terrain/desert/heightmap.r16 +0 -0
- package/template-assets/terrain/desert/recipe.json +108 -0
- package/template-assets/terrain/desert/surface.json +54 -0
- package/template-assets/terrain/forest/assets.json +65 -0
- package/template-assets/terrain/forest/bake.mjs +8 -0
- package/template-assets/terrain/forest/credits.json +225 -0
- package/template-assets/terrain/forest/heightmap.r16 +0 -0
- package/template-assets/terrain/forest/recipe.json +350 -0
- package/template-assets/terrain/forest/surface.json +79 -0
- package/template-assets/terrain/tundra/assets.json +12 -0
- package/template-assets/terrain/tundra/bake.mjs +6 -0
- package/template-assets/terrain/tundra/credits.json +164 -0
- package/template-assets/terrain/tundra/heightmap.r16 +0 -0
- package/template-assets/terrain/tundra/recipe.json +277 -0
- package/template-assets/terrain/tundra/surface.json +54 -0
- package/templates/action-rpg/AGENTS.md +8 -4
- package/templates/action-rpg/CLAUDE.md +8 -4
- package/templates/action-rpg/package.json +7 -7
- package/templates/action-rpg/src/game.ts +1 -1
- package/templates/action-rpg/src/render/atmosphere.ts +6 -0
- package/templates/action-rpg/src/render/backlightControls.ts +10 -0
- package/templates/action-rpg/src/render/backlightMaterial.ts +4 -4
- package/templates/action-rpg/src/render/clouds.ts +13 -0
- package/templates/action-rpg/src/render/materialLighting.ts +5 -5
- package/templates/action-rpg/src/render/quality.ts +7 -32
- package/templates/action-rpg/src/scenes/Play.ts +4 -1
- package/templates/action-rpg/src/style.css +4 -0
- package/templates/action-rpg/vite.config.ts +2 -0
- package/templates/adventure/AGENTS.md +7 -2
- package/templates/adventure/CLAUDE.md +7 -2
- package/templates/adventure/kit.json +5 -1
- package/templates/adventure/package.json +7 -7
- package/templates/adventure/src/game.ts +1 -1
- package/templates/adventure/src/style.css +4 -0
- package/templates/adventure/tsconfig.json +1 -1
- package/templates/adventure/vite.config.ts +2 -0
- package/templates/collectathon/AGENTS.md +7 -2
- package/templates/collectathon/CLAUDE.md +7 -2
- package/templates/collectathon/package.json +7 -7
- package/templates/collectathon/src/game.ts +1 -1
- package/templates/collectathon/src/level/Course.ts +55 -9
- package/templates/collectathon/src/level/terrain.ts +27 -6
- package/templates/collectathon/src/main.ts +1 -0
- package/templates/collectathon/src/render/foliage.ts +359 -98
- package/templates/collectathon/src/render/sky.ts +76 -12
- package/templates/collectathon/src/render/water.ts +32 -10
- package/templates/collectathon/src/scenes/Play.ts +18 -5
- package/templates/collectathon/src/style.css +4 -0
- package/templates/collectathon/tsconfig.json +1 -1
- package/templates/collectathon/vite.config.ts +2 -0
- package/templates/kart/AGENTS.md +7 -2
- package/templates/kart/CLAUDE.md +7 -2
- package/templates/kart/package.json +6 -6
- package/templates/kart/src/game.ts +1 -1
- package/templates/kart/src/main.ts +1 -0
- package/templates/kart/src/style.css +4 -0
- package/templates/kart/tsconfig.json +1 -1
- package/templates/kart/vite.config.ts +2 -0
- package/templates/minimal/AGENTS.md +8 -3
- package/templates/minimal/CLAUDE.md +8 -3
- package/templates/minimal/package.json +6 -6
- package/templates/minimal/playtests/stands-still.playtest.json +30 -0
- package/templates/minimal/src/game.ts +1 -1
- package/templates/minimal/src/render/atmosphere.ts +6 -0
- package/templates/minimal/src/render/backlightControls.ts +10 -0
- package/templates/minimal/src/render/backlightMaterial.ts +4 -4
- package/templates/minimal/src/render/camera.ts +13 -2
- package/templates/minimal/src/render/clouds.ts +13 -0
- package/templates/minimal/src/render/lighting.ts +4 -2
- package/templates/minimal/src/render/materialLighting.ts +5 -5
- package/templates/minimal/src/render/materials.ts +10 -0
- package/templates/minimal/src/render/quality.ts +7 -32
- package/templates/minimal/src/scenes/Play.ts +4 -1
- package/templates/minimal/vite.config.ts +7 -1
- package/templates/platformer/AGENTS.md +9 -4
- package/templates/platformer/CLAUDE.md +9 -4
- package/templates/platformer/index.html +1 -1
- package/templates/platformer/main.html +12 -0
- package/templates/platformer/package.json +7 -7
- package/templates/platformer/playtests/gamepad-idle.playtest.json +21 -0
- package/templates/platformer/playtests/gamepad.playtest.json +30 -0
- package/templates/platformer/src/entities/Fox.ts +21 -6
- package/templates/platformer/src/game.ts +1 -1
- package/templates/platformer/src/main.ts +1 -0
- package/templates/platformer/src/render/backlightControls.ts +10 -0
- package/templates/platformer/src/render/backlightMaterial.ts +4 -4
- package/templates/platformer/src/render/materialLighting.ts +5 -5
- package/templates/platformer/src/render/quality.ts +7 -32
- package/templates/platformer/src/scenes/Play.ts +2 -1
- package/templates/platformer/src/style.css +4 -0
- package/templates/platformer/src/worker-page.ts +29 -0
- package/templates/platformer/src/worker.ts +5 -0
- package/templates/platformer/tsconfig.json +1 -1
- package/templates/platformer/vite.config.ts +4 -0
- package/templates/puzzle/AGENTS.md +7 -2
- package/templates/puzzle/CLAUDE.md +7 -2
- package/templates/puzzle/package.json +7 -7
- package/templates/puzzle/src/game.ts +1 -1
- package/templates/puzzle/src/render/backlightControls.ts +10 -0
- package/templates/puzzle/src/render/backlightMaterial.ts +4 -4
- package/templates/puzzle/src/render/materialLighting.ts +5 -5
- package/templates/puzzle/src/render/quality.ts +7 -32
- package/templates/puzzle/src/scenes/Play.ts +1 -1
- package/templates/puzzle/src/style.css +4 -0
- package/templates/puzzle/tsconfig.json +1 -1
- package/templates/puzzle/vite.config.ts +2 -0
- package/templates/racing/AGENTS.md +7 -2
- package/templates/racing/CLAUDE.md +7 -2
- package/templates/racing/package.json +7 -7
- package/templates/racing/src/game.ts +1 -1
- package/templates/racing/src/render/atmosphere.ts +6 -0
- package/templates/racing/src/render/backlightControls.ts +10 -0
- package/templates/racing/src/render/backlightMaterial.ts +4 -4
- package/templates/racing/src/render/clouds.ts +13 -0
- package/templates/racing/src/render/materialLighting.ts +5 -5
- package/templates/racing/src/render/quality.ts +7 -32
- package/templates/racing/src/scenes/Race.ts +4 -1
- package/templates/racing/src/style.css +4 -0
- package/templates/racing/tsconfig.json +1 -1
- package/templates/racing/vite.config.ts +2 -0
- package/templates/rain/AGENTS.md +6 -2
- package/templates/rain/CLAUDE.md +6 -2
- package/templates/rain/package.json +6 -6
- package/templates/rain/src/game.ts +1 -1
- package/templates/rain/vite.config.ts +6 -0
- package/templates/rts/AGENTS.md +6 -2
- package/templates/rts/CLAUDE.md +6 -2
- package/templates/rts/package.json +6 -6
- package/templates/rts/src/game.ts +1 -1
- package/templates/rts/src/render/backlightControls.ts +10 -0
- package/templates/rts/src/render/backlightMaterial.ts +4 -4
- package/templates/rts/src/render/materialLighting.ts +5 -5
- package/templates/rts/src/render/quality.ts +7 -31
- package/templates/rts/src/scenes/Play.ts +1 -1
- package/templates/rts/src/style.css +4 -0
- package/templates/rts/vite.config.ts +2 -0
- package/templates/runner/AGENTS.md +7 -2
- package/templates/runner/CLAUDE.md +7 -2
- package/templates/runner/package.json +7 -7
- package/templates/runner/src/game.ts +1 -1
- package/templates/runner/src/render/atmosphere.ts +6 -0
- package/templates/runner/src/render/backlightControls.ts +10 -0
- package/templates/runner/src/render/backlightMaterial.ts +4 -4
- package/templates/runner/src/render/clouds.ts +13 -0
- package/templates/runner/src/render/materialLighting.ts +5 -5
- package/templates/runner/src/render/quality.ts +7 -32
- package/templates/runner/src/scenes/Run.ts +4 -1
- package/templates/runner/src/style.css +4 -0
- package/templates/runner/tsconfig.json +1 -1
- package/templates/runner/vite.config.ts +2 -0
- package/templates/sailing/AGENTS.md +7 -2
- package/templates/sailing/CLAUDE.md +7 -2
- package/templates/sailing/package.json +7 -7
- package/templates/sailing/src/game.ts +1 -1
- package/templates/sailing/src/render/backlightControls.ts +10 -0
- package/templates/sailing/src/render/backlightMaterial.ts +4 -4
- package/templates/sailing/src/render/environmentSetup.ts +1 -1
- package/templates/sailing/src/render/materialLighting.ts +5 -5
- package/templates/sailing/src/render/quality.ts +7 -32
- package/templates/sailing/src/style.css +5 -0
- package/templates/sailing/vite.config.ts +6 -0
- package/templates/shooter/AGENTS.md +6 -2
- package/templates/shooter/CLAUDE.md +6 -2
- package/templates/shooter/package.json +7 -7
- package/templates/shooter/src/game.ts +3 -2
- package/templates/shooter/src/render/atmosphere.ts +6 -0
- package/templates/shooter/src/render/backlightControls.ts +10 -0
- package/templates/shooter/src/render/backlightMaterial.ts +4 -4
- package/templates/shooter/src/render/clouds.ts +13 -0
- package/templates/shooter/src/render/materialLighting.ts +5 -5
- package/templates/shooter/src/render/quality.ts +7 -32
- package/templates/shooter/src/scenes/Play.ts +4 -1
- package/templates/shooter/src/style.css +4 -0
- package/templates/shooter/vite.config.ts +2 -0
- package/templates/snow/AGENTS.md +7 -2
- package/templates/snow/CLAUDE.md +7 -2
- package/templates/snow/package.json +7 -7
- package/templates/snow/src/game.ts +1 -1
- package/templates/snow/src/render/backlightControls.ts +10 -0
- package/templates/snow/src/render/backlightMaterial.ts +4 -4
- package/templates/snow/src/render/materialLighting.ts +5 -5
- package/templates/snow/src/render/quality.ts +7 -32
- package/templates/snow/src/style.css +5 -0
- package/templates/snow/vite.config.ts +6 -0
- package/templates/starter/AGENTS.md +8 -3
- package/templates/starter/CLAUDE.md +8 -3
- package/templates/starter/package.json +7 -7
- package/templates/starter/src/entities/Crate.ts +5 -2
- package/templates/starter/src/game.ts +4 -3
- package/templates/starter/src/render/adaptiveQuality.ts +17 -0
- package/templates/starter/src/render/atmosphere.ts +6 -0
- package/templates/starter/src/render/backlightControls.ts +10 -0
- package/templates/starter/src/render/backlightMaterial.ts +4 -4
- package/templates/starter/src/render/clouds.ts +13 -0
- package/templates/starter/src/render/contactShadow.ts +1 -1
- package/templates/starter/src/render/materialLighting.ts +5 -5
- package/templates/starter/src/render/postprocessing.ts +11 -10
- package/templates/starter/src/render/quality.ts +14 -1
- package/templates/starter/src/scenes/Play.ts +12 -3
- package/templates/starter/src/state.ts +2 -0
- package/templates/starter/src/style.css +4 -0
- package/templates/starter/src/ui/Menu.tsx +5 -1
- package/templates/starter/vite.config.ts +2 -0
- package/templates/tower-defense/AGENTS.md +7 -2
- package/templates/tower-defense/CLAUDE.md +7 -2
- package/templates/tower-defense/package.json +7 -7
- package/templates/tower-defense/src/game.ts +1 -1
- package/templates/tower-defense/src/render/backlightControls.ts +10 -0
- package/templates/tower-defense/src/render/backlightMaterial.ts +4 -4
- package/templates/tower-defense/src/render/materialLighting.ts +5 -5
- package/templates/tower-defense/src/render/quality.ts +7 -32
- package/templates/tower-defense/src/scenes/Battle.ts +1 -1
- package/templates/tower-defense/src/style.css +4 -0
- package/templates/tower-defense/tsconfig.json +1 -1
- package/templates/tower-defense/vite.config.ts +2 -0
- package/templates/action-rpg/src/render/environmentContribution.ts +0 -188
- package/templates/action-rpg/src/render/environmentRadiance.ts +0 -36
- package/templates/action-rpg/src/render/environmentSampleCache.ts +0 -43
- package/templates/action-rpg/src/render/environmentSampling.ts +0 -193
- package/templates/action-rpg/src/render/environmentSnapshot.ts +0 -53
- package/templates/minimal/src/render/environmentContribution.ts +0 -188
- package/templates/minimal/src/render/environmentRadiance.ts +0 -36
- package/templates/minimal/src/render/environmentSampleCache.ts +0 -43
- package/templates/minimal/src/render/environmentSampling.ts +0 -193
- package/templates/minimal/src/render/environmentSnapshot.ts +0 -53
- package/templates/platformer/src/render/environmentContribution.ts +0 -188
- package/templates/platformer/src/render/environmentRadiance.ts +0 -36
- package/templates/platformer/src/render/environmentSampleCache.ts +0 -43
- package/templates/platformer/src/render/environmentSampling.ts +0 -193
- package/templates/platformer/src/render/environmentSnapshot.ts +0 -53
- package/templates/puzzle/src/render/environmentContribution.ts +0 -188
- package/templates/puzzle/src/render/environmentRadiance.ts +0 -36
- package/templates/puzzle/src/render/environmentSampleCache.ts +0 -43
- package/templates/puzzle/src/render/environmentSampling.ts +0 -193
- package/templates/puzzle/src/render/environmentSnapshot.ts +0 -53
- package/templates/racing/src/render/environmentContribution.ts +0 -188
- package/templates/racing/src/render/environmentRadiance.ts +0 -36
- package/templates/racing/src/render/environmentSampleCache.ts +0 -43
- package/templates/racing/src/render/environmentSampling.ts +0 -193
- package/templates/racing/src/render/environmentSnapshot.ts +0 -53
- package/templates/rts/src/render/environmentContribution.ts +0 -188
- package/templates/rts/src/render/environmentRadiance.ts +0 -36
- package/templates/rts/src/render/environmentSampleCache.ts +0 -43
- package/templates/rts/src/render/environmentSampling.ts +0 -193
- package/templates/rts/src/render/environmentSnapshot.ts +0 -53
- package/templates/runner/src/render/environmentContribution.ts +0 -188
- package/templates/runner/src/render/environmentRadiance.ts +0 -36
- package/templates/runner/src/render/environmentSampleCache.ts +0 -43
- package/templates/runner/src/render/environmentSampling.ts +0 -193
- package/templates/runner/src/render/environmentSnapshot.ts +0 -53
- package/templates/sailing/src/render/environmentContribution.ts +0 -188
- package/templates/sailing/src/render/environmentRadiance.ts +0 -36
- package/templates/sailing/src/render/environmentSampleCache.ts +0 -43
- package/templates/sailing/src/render/environmentSampling.ts +0 -193
- package/templates/sailing/src/render/environmentSnapshot.ts +0 -53
- package/templates/shooter/src/render/environmentContribution.ts +0 -188
- package/templates/shooter/src/render/environmentRadiance.ts +0 -36
- package/templates/shooter/src/render/environmentSampleCache.ts +0 -43
- package/templates/shooter/src/render/environmentSampling.ts +0 -193
- package/templates/shooter/src/render/environmentSnapshot.ts +0 -53
- package/templates/snow/src/render/environmentContribution.ts +0 -188
- package/templates/snow/src/render/environmentRadiance.ts +0 -36
- package/templates/snow/src/render/environmentSampleCache.ts +0 -43
- package/templates/snow/src/render/environmentSampling.ts +0 -193
- package/templates/snow/src/render/environmentSnapshot.ts +0 -53
- package/templates/starter/src/render/environmentContribution.ts +0 -188
- package/templates/starter/src/render/environmentRadiance.ts +0 -36
- package/templates/starter/src/render/environmentSampleCache.ts +0 -43
- package/templates/starter/src/render/environmentSampling.ts +0 -193
- package/templates/starter/src/render/environmentSnapshot.ts +0 -53
- package/templates/starter/src/render/rendererGate.ts +0 -36
- package/templates/tower-defense/src/render/environmentContribution.ts +0 -188
- package/templates/tower-defense/src/render/environmentRadiance.ts +0 -36
- package/templates/tower-defense/src/render/environmentSampleCache.ts +0 -43
- package/templates/tower-defense/src/render/environmentSampling.ts +0 -193
- package/templates/tower-defense/src/render/environmentSnapshot.ts +0 -53
|
@@ -227,8 +227,9 @@ pnpm census:content public/assets
|
|
|
227
227
|
export function modelPass(options: IModelPassOptions = { … }
|
|
228
228
|
```
|
|
229
229
|
|
|
230
|
-
- **Use when:** reduce a model's download and GPU footprint · optimize a GLB before shipping it with a game
|
|
231
|
-
- **Constraints:** the pass self-verifies reachable geometry, animation, bounds, and embedded texture bindings before returning output
|
|
230
|
+
- **Use when:** reduce a model's download and GPU footprint · optimize a GLB before shipping it with a game · texture bytes too big after the model cook · a KTX2 model texture came out larger than its WebP or JPEG source · choose ETC1S or UASTC for a model's embedded textures · model texture codec ladder · keep smaller source texture · TN_ASSETS_COMPRESSION_SKIPPED
|
|
231
|
+
- **Constraints:** the pass self-verifies reachable geometry, animation, bounds, and embedded texture bindings before returning output · each colour texture climbs a codec ladder (ETC1S, then UASTC with RDO, then plain UASTC) and keeps the smallest rung that meets the quality floor (SSIM 0.95, ΔE00 3); a data slot such as a normal or metallic-roughness map takes UASTC only, as ETC1S is forbidden there (`TN_ASSETS_TEXTURE_SLOT_CODEC`); a result is kept only when it is smaller than the source, else the source stays and the report says `not-smaller` · a PNG or JPEG source can always be kept; a WebP source can be kept only on a web target, whose runtimes all decode WebP, so on desktop and mobile it always becomes KTX2
|
|
232
|
+
- **Overrides:** `textures: { overrides: [{ slot: "baseColorTexture", codec: "uastc" }] }` forces one glTF slot's codec (`etc1s`, `uastc` or `none`); `textures: { floor }` moves the quality floor; `textures: "none"` keeps every embedded texture as authored
|
|
232
233
|
|
|
233
234
|
```ts
|
|
234
235
|
const pass = modelPass({ simplify: { ratio: 0.5 } });
|
|
@@ -1026,9 +1027,9 @@ const counters = FrameCounters.install(counterDeviceOf(renderer.raw));
|
|
|
1026
1027
|
export function createAssetLoader(options: IAssetLoaderOptions = { … }
|
|
1027
1028
|
```
|
|
1028
1029
|
|
|
1029
|
-
- **Use when:** preload models, textures, or audio before a scene enters · keep downloaded web assets on disk between visits · download the next scene before the player gets there · free the disk cache from a settings menu · prefetch assets into the Cache Storage disk cache of a large web game · load assets from a nonstandard base path or a compiled asset manifest
|
|
1030
|
-
- **Constraints:** reuse the loader handed to scenes as `ctx.assets` instead of building parallel caches · await everything the spawn camera sees before the reveal; `ctx.assets.prefetch` and the background fill are for content out of view, or the player spawns into a half-built world · web only: a native host reads installed files, so `ctx.assets.cache` reports `enabled: false` with the reason and `prefetch` resolves at once
|
|
1031
|
-
- **Overrides:** `assets.cache: false` turns the disk cache off and `assets.backgroundFill: false` turns the post-reveal fill off; both are reported on `ctx.assets.cache`
|
|
1030
|
+
- **Use when:** preload models, textures, or audio before a scene enters · keep downloaded web assets on disk between visits · download the next scene before the player gets there · free the disk cache from a settings menu · prefetch assets into the Cache Storage disk cache of a large web game · load assets from a nonstandard base path or a compiled asset manifest · stream a large game: boot on the spawn bytes and prefetch the rest · make the first scene play before the whole game finishes downloading · draw a heavy model's coarsest level first and its full detail when the file lands · draw a model's textures at their resident mips first and the whole files later · coarse first model streaming · streamMeshes and streamTextures: stream the meshes and textures of a model · mip streaming textures · TN_STREAMING_POOL · TN_ASSET_LATE · an asset pops in after the reveal and the game needs to count it · a model texture looks blurry or low resolution right after load, then sharpens · build a collider or navmesh from a streamed model only once its full file landed · compressed texture upload on the owned engine (KTX2 to BC7 or ETC2 on the GPU) · load a model with KHR_texture_basisu or EXT_meshopt_compression on the owned engine · stream a finer mip level into a CompressedTexture that already draws · KTX2Loader on the owned engine · CompressedTexture upload · TN_TEXTURE_TRANSCODE_TARGET · TN_NATIVE_TEXTURE_UNSUPPORTED · webRuntimeDecoders meshopt ktx2
|
|
1031
|
+
- **Constraints:** reuse the loader handed to scenes as `ctx.assets` instead of building parallel caches · await everything the spawn camera sees before the reveal; `ctx.assets.prefetch` and the background fill are for content out of view, or the player spawns into a half-built world · a whole-file load requested after the reveal that the game had not `prefetch`ed logs one `TN_ASSET_LATE` line with its bytes, so a pop-in is countable from a playtest · web only: a native host reads installed files, so `ctx.assets.cache` reports `enabled: false` with the reason and `prefetch` resolves at once · streaming is engine-owned and on by default: a cooked LOD-chained model loads its `.coarse.<digest>.glb` companion first, then the full file at "soon" priority, and the full geometry replaces the coarse in place (clones and the projection mirror included); a failed coarse load falls back to the whole file and logs `TN_ASSETS_STREAM_FAILED` · texture streaming rides on the coarse parse: each shared `.ktx2` of that model is read by `Range` as its resident mips (the header and the tail), and the whole files replace them when the full model lands; a host without `Range` sends the whole file and keeps it whole. `TN_STREAMING_POOL` reports `files`, `residentBytes`, `fullBytes`, `deferredBytes` and `upgraded` once, two seconds after the last change · the whole texture keeps what the game set on the resident one (`anisotropy`, wrap, filters, offset, repeat, `userData`), so the swap changes the mips and nothing else · every web build cooks meshopt geometry and KTX2 textures for both engines (`webRuntimeDecoders` in create-threenative answers `{ ktx2: true, meshopt: true }`); the owned engine's glTF loader decodes both itself, with no JS decoder · the owned engine transcodes a KTX2 image to BC7 on a device with `texture-compression-bc`, else ETC2, else RGBA8 with an engine mip chain, and prints `TN_TEXTURE_TRANSCODE_TARGET <target>` once; a block format needs a width and height that are multiples of 4, so any other size stays RGBA8 and the same line names it · a three `CompressedTexture` (format plus `mipmaps`) uploads one GPU write per level; a block format the device lacks throws `TN_NATIVE_TEXTURE_UNSUPPORTED` by name instead of drawing garbage · levels are coarse-first: a level whose `mipmaps[i].data` is null is not resident and the texture samples its finest resident level; set `mipmaps[i].data` and `needsUpdate = true` to write that one finer level in place, without re-creating the texture or rewriting the other levels
|
|
1032
|
+
- **Overrides:** `assets.cache: false` turns the disk cache off and `assets.backgroundFill: false` turns the post-reveal fill off; both are reported on `ctx.assets.cache` · `ctx.assets.model(path, { whole: true })` resolves only once the full file has replaced the coarse companion, for a collider or navmesh that copies vertices once · `assets.streamMeshes: false` loads every model whole (reported once as `TN_ASSETS_STREAM_MESHES_OFF`); `assets.streamTextures: false` loads every model texture whole (`TN_ASSETS_STREAM_TEXTURES_OFF`) · `engine: "threejs"` runs three's own `KTX2Loader` and `MeshoptDecoder` in JS instead of the owned engine's decoders
|
|
1032
1033
|
|
|
1033
1034
|
```ts
|
|
1034
1035
|
const assets = createAssetLoader({ basePath: "/assets" });
|
|
@@ -1108,7 +1109,7 @@ ctx.add(daylight);
|
|
|
1108
1109
|
export function debugFlag(name: string): boolean { … }
|
|
1109
1110
|
```
|
|
1110
1111
|
|
|
1111
|
-
- **Use when:** read a debug toggle from the URL
|
|
1112
|
+
- **Use when:** read a debug toggle from the URL, an environment variable or a harness global
|
|
1112
1113
|
- **Constraints:** a name in camelCase becomes UPPER_SNAKE: `debugFlag("freeCam")` reads `?freeCam` or `TN_DEBUG_FREE_CAM` · `0` and `false` are off, so a saved URL cannot turn a switch back on
|
|
1113
1114
|
|
|
1114
1115
|
```ts
|
|
@@ -1161,6 +1162,22 @@ export function describeSceneWarning(warning: ISceneWarning): string { … }
|
|
|
1161
1162
|
defineGame({ display: { maxFps: 60 }, scenes: { Play } });
|
|
1162
1163
|
```
|
|
1163
1164
|
|
|
1165
|
+
### `devGlobal`
|
|
1166
|
+
|
|
1167
|
+
`function` — The one name every dev surface publishes under, and the reader/writer for it.
|
|
1168
|
+
|
|
1169
|
+
```ts
|
|
1170
|
+
export function devGlobal(scope: unknown): DevGlobal | undefined { … }
|
|
1171
|
+
```
|
|
1172
|
+
|
|
1173
|
+
- **Use when:** read or extend the `__THREENATIVE__` object a dev launch publishes
|
|
1174
|
+
- **Constraints:** every dev surface publishes under this key; the worker's typed mirror tuple names it too
|
|
1175
|
+
|
|
1176
|
+
```ts
|
|
1177
|
+
import { DEV_GLOBAL_KEY, devGlobal } from "@threenative/core";
|
|
1178
|
+
const tools = devGlobal(globalThis);
|
|
1179
|
+
```
|
|
1180
|
+
|
|
1164
1181
|
### `directionalTransmittance`
|
|
1165
1182
|
|
|
1166
1183
|
`function` — Approximate direct transmittance for a ray leaving the game surface.
|
|
@@ -1319,6 +1336,21 @@ export function exposureFromEv100(ev100: number): number { … }
|
|
|
1319
1336
|
renderer.toneMappingExposure = exposureFromEv100(ev100FromCamera(4, 1 / 60, 100));
|
|
1320
1337
|
```
|
|
1321
1338
|
|
|
1339
|
+
### `fetchAsset`
|
|
1340
|
+
|
|
1341
|
+
`function` — Fetch a data file the asset loader serves: each url `assets.resolve(path)` names, in order, until one answers ok. A built game serves the hashed output and a dev server the source path, so taking only the first url 404s on one of them. When none answers it throws `TN_ASSET_NOT_SERVED` naming every url tried and why, so a missing file is never a half-drawn world.
|
|
1342
|
+
|
|
1343
|
+
```ts
|
|
1344
|
+
export async function fetchAsset( assets: Pick<IAssetLoader, "resolve">, path: string, ): Promise<Response> { … }
|
|
1345
|
+
```
|
|
1346
|
+
|
|
1347
|
+
- **Use when:** load a baked JSON or binary file (a heightmap, a placement buffer, a data table) that the loader has no typed method for · a data file loads in dev but 404s in the built game
|
|
1348
|
+
- **Constraints:** reads the response once; call `.json()` or `.arrayBuffer()` on the result
|
|
1349
|
+
|
|
1350
|
+
```ts
|
|
1351
|
+
const heights = new Float32Array(await (await fetchAsset(ctx.assets, "world/forest.bin")).arrayBuffer());
|
|
1352
|
+
```
|
|
1353
|
+
|
|
1322
1354
|
### `FlightModel`
|
|
1323
1355
|
|
|
1324
1356
|
`class` — Fly a fixed-wing aircraft with a real force balance instead of a steered velocity.
|
|
@@ -1486,11 +1518,12 @@ model.step(1 / 60, { turn: -1, pitch: 0.4 });
|
|
|
1486
1518
|
export function getPlatform(): Readonly<IPlatformInfo> { … }
|
|
1487
1519
|
```
|
|
1488
1520
|
|
|
1489
|
-
- **Use when:** branch a portable game on web or native · choose touch controls for a mobile device · can I raytrace on native
|
|
1521
|
+
- **Use when:** branch a portable game on web or native · choose touch controls for a mobile device · can I raytrace on native · show gamepad prompts and bind pad buttons on a games console such as the PS4
|
|
1490
1522
|
- **Constraints:** only use the returned platform facts; native globals are host-owned · image ray tracing is unavailable on native until buffer-to-texture copy-out interop exists; `mystralRT.traceRays` refuses instead of resolving success without a readable result · a native desktop host with ray tracing hardware traces ray batches with `mystralRT.traceRayBatch`, which writes hit records into a typed array you own; read `mystralRT.capabilities().rayBatch` first, and keep the software BVH trace for the web and every other host · when `mystralRT.capabilities().sharedTransport` is true, `mystralRT.traceRayBatchGpu({ tlas, rays, hits, rayCount })` traces between two GPUBuffers with no copy through CPU memory; `rays` needs the CopySrc usage and `hits` the CopyDst usage, and each call costs CPU time, so measure it against the software trace for your batch size
|
|
1491
1523
|
|
|
1492
1524
|
```ts
|
|
1493
1525
|
if (isMobile()) showTouchControls();
|
|
1526
|
+
if (isConsole()) showPadPrompts(isPs4() ? "dualshock" : "generic");
|
|
1494
1527
|
```
|
|
1495
1528
|
|
|
1496
1529
|
### `GIBudget`
|
|
@@ -1598,8 +1631,9 @@ const snap = new GroundSnap(character, { enabled: true });
|
|
|
1598
1631
|
export class InputMap { … }
|
|
1599
1632
|
```
|
|
1600
1633
|
|
|
1601
|
-
- **Use when:** map WASD keys to a movement axis instead of reading the held key set in the update loop · read a jump, a fire or a reload as one named action bound to key, gamepad button and mouse button together · read mouse look, wheel zoom or a two-finger pinch as an axis the frame loop already ticks
|
|
1602
|
-
- **Constraints:** `buttons` is the gamepad and `mouseButtons` the mouse; `up`/`down`/`left`/`right` are the directions of `vector(name)`, not the keys that press it · scroll, pinch and pointer-relative sources are declared on the binding and read through `axis(name)`; a game adds no window listener of its own
|
|
1634
|
+
- **Use when:** map WASD keys to a movement axis instead of reading the held key set in the update loop · read a jump, a fire or a reload as one named action bound to key, gamepad button and mouse button together · read mouse look, wheel zoom or a two-finger pinch as an axis the frame loop already ticks · support an Xbox pad, a generic XInput clone, an 8BitDo or a Steam Deck controller · the character drifts while the controller stick is idle · the controller does nothing in Firefox on Linux · a second controller or a wheel steals the input from the pad the player holds
|
|
1635
|
+
- **Constraints:** `buttons` is the gamepad and `mouseButtons` the mouse; `up`/`down`/`left`/`right` are the directions of `vector(name)`, not the keys that press it · scroll, pinch and pointer-relative sources are declared on the binding and read through `axis(name)`; a game adds no window listener of its own · gamepad buttons are W3C standard indices on every pad: 0 south (A/Cross), 1 east, 2 west, 3 north, 4/5 shoulders, 6/7 triggers, 8 select, 9 start, 10/11 stick clicks; axes 0..3 are the sticks · both sticks carry a radial dead zone, `0.2` by default, reported per connected pad as `TN_GAMEPAD`; a pad the browser reports unmapped and the table does not know is ignored, never read with raw indices · a pad claims the input when a button goes down or a stick travels past half tilt, and keeps it while idle so its releases read; a stick resting past the dead zone or jittering across it claims nothing, so an idle pad in the first slot cannot steal input
|
|
1636
|
+
- **Overrides:** defineGame({ gamepadDeadZone: 0 }) publishes raw axes
|
|
1603
1637
|
|
|
1604
1638
|
```ts
|
|
1605
1639
|
const game = defineGame({ input: { move: { up: ["KeyW"], down: ["KeyS"], left: ["KeyA"], right: ["KeyD"] } }, scenes: { Play } });
|
|
@@ -1670,6 +1704,22 @@ export function invalidateStatic(object: Object3D): number | undefined { … }
|
|
|
1670
1704
|
invalidateStatic(drawbridge);
|
|
1671
1705
|
```
|
|
1672
1706
|
|
|
1707
|
+
### `isConsole`
|
|
1708
|
+
|
|
1709
|
+
`function` — Read the host platform without reaching for browser globals.
|
|
1710
|
+
|
|
1711
|
+
```ts
|
|
1712
|
+
export function isConsole(): boolean { … }
|
|
1713
|
+
```
|
|
1714
|
+
|
|
1715
|
+
- **Use when:** branch a portable game on web or native · choose touch controls for a mobile device · can I raytrace on native · show gamepad prompts and bind pad buttons on a games console such as the PS4
|
|
1716
|
+
- **Constraints:** only use the returned platform facts; native globals are host-owned · image ray tracing is unavailable on native until buffer-to-texture copy-out interop exists; `mystralRT.traceRays` refuses instead of resolving success without a readable result · a native desktop host with ray tracing hardware traces ray batches with `mystralRT.traceRayBatch`, which writes hit records into a typed array you own; read `mystralRT.capabilities().rayBatch` first, and keep the software BVH trace for the web and every other host · when `mystralRT.capabilities().sharedTransport` is true, `mystralRT.traceRayBatchGpu({ tlas, rays, hits, rayCount })` traces between two GPUBuffers with no copy through CPU memory; `rays` needs the CopySrc usage and `hits` the CopyDst usage, and each call costs CPU time, so measure it against the software trace for your batch size
|
|
1717
|
+
|
|
1718
|
+
```ts
|
|
1719
|
+
if (isMobile()) showTouchControls();
|
|
1720
|
+
if (isConsole()) showPadPrompts(isPs4() ? "dualshock" : "generic");
|
|
1721
|
+
```
|
|
1722
|
+
|
|
1673
1723
|
### `isMobile`
|
|
1674
1724
|
|
|
1675
1725
|
`function` — Read the host platform without reaching for browser globals.
|
|
@@ -1678,11 +1728,12 @@ invalidateStatic(drawbridge);
|
|
|
1678
1728
|
export function isMobile(): boolean { … }
|
|
1679
1729
|
```
|
|
1680
1730
|
|
|
1681
|
-
- **Use when:** branch a portable game on web or native · choose touch controls for a mobile device · can I raytrace on native
|
|
1731
|
+
- **Use when:** branch a portable game on web or native · choose touch controls for a mobile device · can I raytrace on native · show gamepad prompts and bind pad buttons on a games console such as the PS4
|
|
1682
1732
|
- **Constraints:** only use the returned platform facts; native globals are host-owned · image ray tracing is unavailable on native until buffer-to-texture copy-out interop exists; `mystralRT.traceRays` refuses instead of resolving success without a readable result · a native desktop host with ray tracing hardware traces ray batches with `mystralRT.traceRayBatch`, which writes hit records into a typed array you own; read `mystralRT.capabilities().rayBatch` first, and keep the software BVH trace for the web and every other host · when `mystralRT.capabilities().sharedTransport` is true, `mystralRT.traceRayBatchGpu({ tlas, rays, hits, rayCount })` traces between two GPUBuffers with no copy through CPU memory; `rays` needs the CopySrc usage and `hits` the CopyDst usage, and each call costs CPU time, so measure it against the software trace for your batch size
|
|
1683
1733
|
|
|
1684
1734
|
```ts
|
|
1685
1735
|
if (isMobile()) showTouchControls();
|
|
1736
|
+
if (isConsole()) showPadPrompts(isPs4() ? "dualshock" : "generic");
|
|
1686
1737
|
```
|
|
1687
1738
|
|
|
1688
1739
|
### `isNative`
|
|
@@ -1693,11 +1744,28 @@ if (isMobile()) showTouchControls();
|
|
|
1693
1744
|
export function isNative(): boolean { … }
|
|
1694
1745
|
```
|
|
1695
1746
|
|
|
1696
|
-
- **Use when:** branch a portable game on web or native · choose touch controls for a mobile device · can I raytrace on native
|
|
1747
|
+
- **Use when:** branch a portable game on web or native · choose touch controls for a mobile device · can I raytrace on native · show gamepad prompts and bind pad buttons on a games console such as the PS4
|
|
1697
1748
|
- **Constraints:** only use the returned platform facts; native globals are host-owned · image ray tracing is unavailable on native until buffer-to-texture copy-out interop exists; `mystralRT.traceRays` refuses instead of resolving success without a readable result · a native desktop host with ray tracing hardware traces ray batches with `mystralRT.traceRayBatch`, which writes hit records into a typed array you own; read `mystralRT.capabilities().rayBatch` first, and keep the software BVH trace for the web and every other host · when `mystralRT.capabilities().sharedTransport` is true, `mystralRT.traceRayBatchGpu({ tlas, rays, hits, rayCount })` traces between two GPUBuffers with no copy through CPU memory; `rays` needs the CopySrc usage and `hits` the CopyDst usage, and each call costs CPU time, so measure it against the software trace for your batch size
|
|
1698
1749
|
|
|
1699
1750
|
```ts
|
|
1700
1751
|
if (isMobile()) showTouchControls();
|
|
1752
|
+
if (isConsole()) showPadPrompts(isPs4() ? "dualshock" : "generic");
|
|
1753
|
+
```
|
|
1754
|
+
|
|
1755
|
+
### `isPs4`
|
|
1756
|
+
|
|
1757
|
+
`function` — Read the host platform without reaching for browser globals.
|
|
1758
|
+
|
|
1759
|
+
```ts
|
|
1760
|
+
export function isPs4(): boolean { … }
|
|
1761
|
+
```
|
|
1762
|
+
|
|
1763
|
+
- **Use when:** branch a portable game on web or native · choose touch controls for a mobile device · can I raytrace on native · show gamepad prompts and bind pad buttons on a games console such as the PS4
|
|
1764
|
+
- **Constraints:** only use the returned platform facts; native globals are host-owned · image ray tracing is unavailable on native until buffer-to-texture copy-out interop exists; `mystralRT.traceRays` refuses instead of resolving success without a readable result · a native desktop host with ray tracing hardware traces ray batches with `mystralRT.traceRayBatch`, which writes hit records into a typed array you own; read `mystralRT.capabilities().rayBatch` first, and keep the software BVH trace for the web and every other host · when `mystralRT.capabilities().sharedTransport` is true, `mystralRT.traceRayBatchGpu({ tlas, rays, hits, rayCount })` traces between two GPUBuffers with no copy through CPU memory; `rays` needs the CopySrc usage and `hits` the CopyDst usage, and each call costs CPU time, so measure it against the software trace for your batch size
|
|
1765
|
+
|
|
1766
|
+
```ts
|
|
1767
|
+
if (isMobile()) showTouchControls();
|
|
1768
|
+
if (isConsole()) showPadPrompts(isPs4() ? "dualshock" : "generic");
|
|
1701
1769
|
```
|
|
1702
1770
|
|
|
1703
1771
|
### `isStatic`
|
|
@@ -1715,6 +1783,21 @@ export function isStatic(root: Object3D): boolean { … }
|
|
|
1715
1783
|
invalidateStatic(drawbridge);
|
|
1716
1784
|
```
|
|
1717
1785
|
|
|
1786
|
+
### `isStreamedGeometry`
|
|
1787
|
+
|
|
1788
|
+
`function` — True while a geometry is the coarse companion a streamed model draws first (PRD-860), before its full file replaces it in place. A caller that copies vertices (a trimesh collider, a navmesh bake, a merge) waits with `ctx.assets.model(path, { whole: true })` instead of copying the coarse ones.
|
|
1789
|
+
|
|
1790
|
+
```ts
|
|
1791
|
+
export function isStreamedGeometry(geometry: BufferGeometry): boolean { … }
|
|
1792
|
+
```
|
|
1793
|
+
|
|
1794
|
+
- **Use when:** collider or navmesh built from a model is coarser than what is drawn · wait for the full model before copying its vertices · whole model before collision · TN_COLLIDER_COARSE
|
|
1795
|
+
- **Constraints:** `CollisionShape3D.fromMesh` with "trimesh" or "convexHull" on a streamed geometry warns `TN_COLLIDER_COARSE` naming the mesh and the `{ whole: true }` override, and still builds
|
|
1796
|
+
|
|
1797
|
+
```ts
|
|
1798
|
+
const coarse = isStreamedGeometry(mesh.geometry);
|
|
1799
|
+
```
|
|
1800
|
+
|
|
1718
1801
|
### `isTouchscreenAvailable`
|
|
1719
1802
|
|
|
1720
1803
|
`function` — Read the host platform without reaching for browser globals.
|
|
@@ -1723,11 +1806,12 @@ invalidateStatic(drawbridge);
|
|
|
1723
1806
|
export function isTouchscreenAvailable(): boolean { … }
|
|
1724
1807
|
```
|
|
1725
1808
|
|
|
1726
|
-
- **Use when:** branch a portable game on web or native · choose touch controls for a mobile device · can I raytrace on native
|
|
1809
|
+
- **Use when:** branch a portable game on web or native · choose touch controls for a mobile device · can I raytrace on native · show gamepad prompts and bind pad buttons on a games console such as the PS4
|
|
1727
1810
|
- **Constraints:** only use the returned platform facts; native globals are host-owned · image ray tracing is unavailable on native until buffer-to-texture copy-out interop exists; `mystralRT.traceRays` refuses instead of resolving success without a readable result · a native desktop host with ray tracing hardware traces ray batches with `mystralRT.traceRayBatch`, which writes hit records into a typed array you own; read `mystralRT.capabilities().rayBatch` first, and keep the software BVH trace for the web and every other host · when `mystralRT.capabilities().sharedTransport` is true, `mystralRT.traceRayBatchGpu({ tlas, rays, hits, rayCount })` traces between two GPUBuffers with no copy through CPU memory; `rays` needs the CopySrc usage and `hits` the CopyDst usage, and each call costs CPU time, so measure it against the software trace for your batch size
|
|
1728
1811
|
|
|
1729
1812
|
```ts
|
|
1730
1813
|
if (isMobile()) showTouchControls();
|
|
1814
|
+
if (isConsole()) showPadPrompts(isPs4() ? "dualshock" : "generic");
|
|
1731
1815
|
```
|
|
1732
1816
|
|
|
1733
1817
|
### `isWeb`
|
|
@@ -1738,11 +1822,12 @@ if (isMobile()) showTouchControls();
|
|
|
1738
1822
|
export function isWeb(): boolean { … }
|
|
1739
1823
|
```
|
|
1740
1824
|
|
|
1741
|
-
- **Use when:** branch a portable game on web or native · choose touch controls for a mobile device · can I raytrace on native
|
|
1825
|
+
- **Use when:** branch a portable game on web or native · choose touch controls for a mobile device · can I raytrace on native · show gamepad prompts and bind pad buttons on a games console such as the PS4
|
|
1742
1826
|
- **Constraints:** only use the returned platform facts; native globals are host-owned · image ray tracing is unavailable on native until buffer-to-texture copy-out interop exists; `mystralRT.traceRays` refuses instead of resolving success without a readable result · a native desktop host with ray tracing hardware traces ray batches with `mystralRT.traceRayBatch`, which writes hit records into a typed array you own; read `mystralRT.capabilities().rayBatch` first, and keep the software BVH trace for the web and every other host · when `mystralRT.capabilities().sharedTransport` is true, `mystralRT.traceRayBatchGpu({ tlas, rays, hits, rayCount })` traces between two GPUBuffers with no copy through CPU memory; `rays` needs the CopySrc usage and `hits` the CopyDst usage, and each call costs CPU time, so measure it against the software trace for your batch size
|
|
1743
1827
|
|
|
1744
1828
|
```ts
|
|
1745
1829
|
if (isMobile()) showTouchControls();
|
|
1830
|
+
if (isConsole()) showPadPrompts(isPs4() ? "dualshock" : "generic");
|
|
1746
1831
|
```
|
|
1747
1832
|
|
|
1748
1833
|
### `lampPenumbraTangent`
|
|
@@ -2060,6 +2145,22 @@ export class ProbeVolume extends Object3D implements IComputeDriven { … }
|
|
|
2060
2145
|
const probes = new ProbeVolume({ bounds, density: 0.5 }); ctx.add(probes); void probes.requestBake(scene);
|
|
2061
2146
|
```
|
|
2062
2147
|
|
|
2148
|
+
### `publishDevGlobal`
|
|
2149
|
+
|
|
2150
|
+
`function` — The one name every dev surface publishes under, and the reader/writer for it.
|
|
2151
|
+
|
|
2152
|
+
```ts
|
|
2153
|
+
export function publishDevGlobal(name: string, value: unknown, scope: unknown): void { … }
|
|
2154
|
+
```
|
|
2155
|
+
|
|
2156
|
+
- **Use when:** read or extend the `__THREENATIVE__` object a dev launch publishes
|
|
2157
|
+
- **Constraints:** every dev surface publishes under this key; the worker's typed mirror tuple names it too
|
|
2158
|
+
|
|
2159
|
+
```ts
|
|
2160
|
+
import { DEV_GLOBAL_KEY, devGlobal } from "@threenative/core";
|
|
2161
|
+
const tools = devGlobal(globalThis);
|
|
2162
|
+
```
|
|
2163
|
+
|
|
2063
2164
|
### `qualityPreset`
|
|
2064
2165
|
|
|
2065
2166
|
`function` — The quality tiers of the Unreal 5.8.3 look: what `high` (a desktop, Unreal's Epic), `medium` and `low` (a phone) turn on, how a GPU family picks its start tier, and the global illumination and shadow filter settings per tier named after Unreal's scalability levels. A `WorldEnvironment` with no options starts from `high`. `qualityTiers` holds the tier tables: `resolve` picks a start tier from a GPU class, `gi` and `shadow` read a tier's settings.
|
|
@@ -2076,6 +2177,22 @@ export function qualityPreset(tier: string): IWorldEnvironmentOptions { … }
|
|
|
2076
2177
|
const world = new WorldEnvironment({ ...qualityPreset(qualityTiers.resolve({ gpuClass: renderer.gpuClass })), bloomEnabled: false });
|
|
2077
2178
|
```
|
|
2078
2179
|
|
|
2180
|
+
### `RadianceCache`
|
|
2181
|
+
|
|
2182
|
+
`class` — A probe field of diffuse irradiance that refreshes by tracing the packed scene, with no scene draw: the radiance cache of a dynamic global-illumination pass. Probes in view refresh first, oldest first, within `numProbesToTraceBudget` a frame; a lamp toggled in game code or a sun that steps more than one degree re-traces them while the old values keep lighting the frame.
|
|
2183
|
+
|
|
2184
|
+
```ts
|
|
2185
|
+
export class RadianceCache extends ProbeVolume { … }
|
|
2186
|
+
```
|
|
2187
|
+
|
|
2188
|
+
- **Use when:** light follows a lamp that switches on and off in a room · bounce light that updates when the sun moves, with no baked lightmap · global illumination that refreshes fast enough to read as dynamic
|
|
2189
|
+
- **Constraints:** build a GPUSceneBVH of the static meshes first and pass it as trace.bvh; the cache reads colour and emissive from each material, a texture or a node is counted as ignored · add the cache with ctx.add() so its refresh is measured in the render phase, and read it with sampleNode(position, normal) from a game-owned material · a one-sided material is not seen from behind, as a cube capture would not draw it
|
|
2190
|
+
- **Overrides:** numProbesToTraceBudget (100), probeResolution (8, so 64 rays a probe; 32 for a small emitter), bounds, density, bounces and the sun and sky values are game-owned
|
|
2191
|
+
|
|
2192
|
+
```ts
|
|
2193
|
+
const bvh = new GPUSceneBVH(ctx.scene); ctx.add(bvh); const cache = new RadianceCache({ bounds, density: 0.5, trace: { bvh, sun, sky, camera: ctx.camera } }); ctx.add(cache);
|
|
2194
|
+
```
|
|
2195
|
+
|
|
2079
2196
|
### `readGIMarker`
|
|
2080
2197
|
|
|
2081
2198
|
`function` — Parse a `TN_GI` console line back into its report, or `undefined`.
|
|
@@ -3369,6 +3486,169 @@ const root = createCssUiRoot();
|
|
|
3369
3486
|
root.render(createElement("section", { className: "fixed inset-0 bg-zinc-900/90" }, "READY"));
|
|
3370
3487
|
```
|
|
3371
3488
|
|
|
3489
|
+
## `@threenative/core/render/environment`
|
|
3490
|
+
|
|
3491
|
+
### `cachedEnvironmentSample`
|
|
3492
|
+
|
|
3493
|
+
`function` — The sample this renderer took of `scene`'s environment, if it is still current.
|
|
3494
|
+
|
|
3495
|
+
```ts
|
|
3496
|
+
export function cachedEnvironmentSample( renderer: object, scene: Scene, ): IEnvironmentSample | undefined { … }
|
|
3497
|
+
```
|
|
3498
|
+
|
|
3499
|
+
- **Use when:** skip a second environment readback in the same frame
|
|
3500
|
+
- **Constraints:** a sample whose source texture or intensity moved is dropped, so a stale one never reaches a material
|
|
3501
|
+
|
|
3502
|
+
```ts
|
|
3503
|
+
const hit = cachedEnvironmentSample(renderer, scene);
|
|
3504
|
+
```
|
|
3505
|
+
|
|
3506
|
+
### `cacheEnvironmentSample`
|
|
3507
|
+
|
|
3508
|
+
`function` — Remembers `sample` as this renderer's reading of `scene`'s environment.
|
|
3509
|
+
|
|
3510
|
+
```ts
|
|
3511
|
+
export function cacheEnvironmentSample( renderer: object, scene: Scene, sample: IEnvironmentSample, ): void { … }
|
|
3512
|
+
```
|
|
3513
|
+
|
|
3514
|
+
- **Use when:** reuse one environment readback across the materials of a scene
|
|
3515
|
+
|
|
3516
|
+
```ts
|
|
3517
|
+
cacheEnvironmentSample(renderer, scene, sample);
|
|
3518
|
+
```
|
|
3519
|
+
|
|
3520
|
+
### `captureEnvironmentSnapshot`
|
|
3521
|
+
|
|
3522
|
+
`function` — The provenance of a scene's environment: which texture, at which intensity, in which colour space.
|
|
3523
|
+
|
|
3524
|
+
```ts
|
|
3525
|
+
export function captureEnvironmentSnapshot(scene: Scene): IEnvironmentSourceSnapshot { … }
|
|
3526
|
+
```
|
|
3527
|
+
|
|
3528
|
+
- **Use when:** reject an environment readback that belongs to a different sky
|
|
3529
|
+
|
|
3530
|
+
```ts
|
|
3531
|
+
const snapshot = captureEnvironmentSnapshot(scene);
|
|
3532
|
+
```
|
|
3533
|
+
|
|
3534
|
+
### `environmentSnapshotCurrent`
|
|
3535
|
+
|
|
3536
|
+
`function` — Whether the scene's environment still matches the snapshot a sample was taken from.
|
|
3537
|
+
|
|
3538
|
+
```ts
|
|
3539
|
+
export function environmentSnapshotCurrent( scene: Scene, snapshot: IEnvironmentSourceSnapshot, ): boolean { … }
|
|
3540
|
+
```
|
|
3541
|
+
|
|
3542
|
+
- **Use when:** hold a material's fill light to the sky that is on screen now
|
|
3543
|
+
|
|
3544
|
+
```ts
|
|
3545
|
+
if (environmentSnapshotCurrent(scene, snapshot)) draw(snapshot);
|
|
3546
|
+
```
|
|
3547
|
+
|
|
3548
|
+
### `isWebGLFallbackRenderer`
|
|
3549
|
+
|
|
3550
|
+
`function` — Whether a `WebGPURenderer` wrapper is running three's WebGL backend behind it.
|
|
3551
|
+
|
|
3552
|
+
```ts
|
|
3553
|
+
export function isWebGLFallbackRenderer(renderer: unknown): boolean { … }
|
|
3554
|
+
```
|
|
3555
|
+
|
|
3556
|
+
- **Use when:** refuse a GPU-only lane on a WebGL fallback instead of drawing something wrong
|
|
3557
|
+
|
|
3558
|
+
```ts
|
|
3559
|
+
if (isWebGLFallbackRenderer(renderer)) skipMaterialLane();
|
|
3560
|
+
```
|
|
3561
|
+
|
|
3562
|
+
### `materialLightingEnabled`
|
|
3563
|
+
|
|
3564
|
+
`function` — Whether `tier` may run the material-lighting lane in `environment`.
|
|
3565
|
+
|
|
3566
|
+
```ts
|
|
3567
|
+
export function materialLightingEnabled( tier: QualityTier, environment: IMaterialLightingEnvironment, ): boolean { … }
|
|
3568
|
+
```
|
|
3569
|
+
|
|
3570
|
+
- **Use when:** decide whether this renderer is the admitted material lane
|
|
3571
|
+
- **Constraints:** high tier, browser, hardware WebGPU, not mobile, not software, not a WebGL fallback
|
|
3572
|
+
|
|
3573
|
+
```ts
|
|
3574
|
+
if (materialLightingEnabled("high", env)) lightMaterials();
|
|
3575
|
+
```
|
|
3576
|
+
|
|
3577
|
+
### `measureEnvironment`
|
|
3578
|
+
|
|
3579
|
+
`function` — The environment measure-and-sample mechanism every kit repeats: what the scene's environment actually contributes, a bounded GPU sample of it with a cache and a readback deadline, the provenance a stale readback is rejected by, and the gate that decides which renderer may run the material lane. The backlight itself is a shader with fixed constants, so it stays in each kit's `src/render/` (stamped from one source there) where the game can change how it looks. This is machinery, not a look: every colour, gain and threshold arrives as an argument, and a kit that wants a different bound passes a different one. It lives here because twelve kits held byte-identical copies — 9 084 lines — so a fix to one left eleven wrong with every gate green (`c93b427d0` touched 552 files for one look change).
|
|
3580
|
+
|
|
3581
|
+
```ts
|
|
3582
|
+
export function measureEnvironment(scene: Scene, maxSourceTexels: number): IEnvironmentMeasurement { … }
|
|
3583
|
+
```
|
|
3584
|
+
|
|
3585
|
+
- **Use when:** measure what a scene's environment actually contributes · sample the environment on the GPU without stalling the frame · keep an environment readback from reaching a frame it does not belong to
|
|
3586
|
+
|
|
3587
|
+
```ts
|
|
3588
|
+
const m = measureEnvironment(scene, 2048);
|
|
3589
|
+
```
|
|
3590
|
+
|
|
3591
|
+
### `reportEnvironmentContribution`
|
|
3592
|
+
|
|
3593
|
+
`function` — The environment measure-and-sample mechanism every kit repeats: what the scene's environment actually contributes, a bounded GPU sample of it with a cache and a readback deadline, the provenance a stale readback is rejected by, and the gate that decides which renderer may run the material lane. The backlight itself is a shader with fixed constants, so it stays in each kit's `src/render/` (stamped from one source there) where the game can change how it looks. This is machinery, not a look: every colour, gain and threshold arrives as an argument, and a kit that wants a different bound passes a different one. It lives here because twelve kits held byte-identical copies — 9 084 lines — so a fix to one left eleven wrong with every gate green (`c93b427d0` touched 552 files for one look change).
|
|
3594
|
+
|
|
3595
|
+
```ts
|
|
3596
|
+
export function reportEnvironmentContribution( scene: Scene, options: IContributionControls, measurement?: IEnvironmentMeasurement, ) { … }
|
|
3597
|
+
```
|
|
3598
|
+
|
|
3599
|
+
- **Use when:** measure what a scene's environment actually contributes · sample the environment on the GPU without stalling the frame · keep an environment readback from reaching a frame it does not belong to
|
|
3600
|
+
|
|
3601
|
+
```ts
|
|
3602
|
+
reportEnvironmentContribution(scene, {
|
|
3603
|
+
darkThreshold: 0.02, fillAdmitted: true, fillColor: new Color(1, 1, 1), fillGain: 0.4,
|
|
3604
|
+
maxSourceTexels: 2048, rimGain: 0.6,
|
|
3605
|
+
});
|
|
3606
|
+
```
|
|
3607
|
+
|
|
3608
|
+
### `sampledRadiance`
|
|
3609
|
+
|
|
3610
|
+
`function` — The mean radiance and colour of a bounded linear sample, or `unknown` with the reason.
|
|
3611
|
+
|
|
3612
|
+
```ts
|
|
3613
|
+
export function sampledRadiance(samples: unknown, intensity: number): IEnvironmentMeasurement { … }
|
|
3614
|
+
```
|
|
3615
|
+
|
|
3616
|
+
- **Use when:** turn an environment readback into the radiance a material's fill light needs · know why an environment sample could not be measured
|
|
3617
|
+
- **Constraints:** the sample must be the qualified 64x32 float RGBA readback; anything else is refused by name
|
|
3618
|
+
|
|
3619
|
+
```ts
|
|
3620
|
+
const m = sampledRadiance(readback, 1);
|
|
3621
|
+
```
|
|
3622
|
+
|
|
3623
|
+
### `sampleEnvironment`
|
|
3624
|
+
|
|
3625
|
+
`function` — Measures and samples the scene's real environment on the GPU, bounded by a readback deadline.
|
|
3626
|
+
|
|
3627
|
+
```ts
|
|
3628
|
+
export async function sampleEnvironment( renderer: unknown, scene: Scene, environment: IMaterialLightingEnvironment, ): Promise<IEnvironmentSample> { … }
|
|
3629
|
+
```
|
|
3630
|
+
|
|
3631
|
+
- **Use when:** measure what a scene's environment actually contributes without stalling the frame · give a material's fill light the environment's own radiance
|
|
3632
|
+
- **Constraints:** off unless the renderer is the admitted high-tier WebGPU lane; every refusal is reported by name · the readback is abandoned after the deadline and the frame keeps the previous answer
|
|
3633
|
+
|
|
3634
|
+
```ts
|
|
3635
|
+
const sample = await sampleEnvironment(renderer, scene, env);
|
|
3636
|
+
```
|
|
3637
|
+
|
|
3638
|
+
### `samplingSourceSupported`
|
|
3639
|
+
|
|
3640
|
+
`function` — Whether an environment texture's mapping and colour space are qualified for the bounded GPU sample.
|
|
3641
|
+
|
|
3642
|
+
```ts
|
|
3643
|
+
export function samplingSourceSupported(source: NonNullable<Scene["environment"]>): boolean { … }
|
|
3644
|
+
```
|
|
3645
|
+
|
|
3646
|
+
- **Use when:** know why an environment was not sampled on the GPU
|
|
3647
|
+
|
|
3648
|
+
```ts
|
|
3649
|
+
if (samplingSourceSupported(source)) sample(source);
|
|
3650
|
+
```
|
|
3651
|
+
|
|
3372
3652
|
## `@threenative/core/spells`
|
|
3373
3653
|
|
|
3374
3654
|
### `CastPool`
|
|
@@ -3757,6 +4037,21 @@ const handle = startWorkerGame(new Worker(new URL("./worker.ts", import.meta.url
|
|
|
3757
4037
|
|
|
3758
4038
|
## `@threenative/core/world`
|
|
3759
4039
|
|
|
4040
|
+
### `AdmissionBudget`
|
|
4041
|
+
|
|
4042
|
+
`class` — One frame's admission allowance, shared by every path that puts streamed content on screen. A streaming world has no frame-time ceiling anywhere else: a cell row arriving builds a batch per asset run over every placement in it, a terrain tile builds every LOD level, and the game's `createCollider` runs for every resident tile — all in the one frame that discovers them. That is the 100-330 ms hitch a 60 m/s camera feels every time the ring moves, and it is admission cost, not streaming: the loads never fail. The budget is opened once per `update` and drawn down by the units it admits. A unit always finishes, so a frame spends at most the limit plus the unit that crossed it, and the rest of the backlog waits for the next frame rather than being dropped.
|
|
4043
|
+
|
|
4044
|
+
```ts
|
|
4045
|
+
export class AdmissionBudget implements IAdmissionBudget { … }
|
|
4046
|
+
```
|
|
4047
|
+
|
|
4048
|
+
- **Use when:** streamed terrain tiles or cells hitch the frame that admits them · cap how many milliseconds a frame spends building streamed content
|
|
4049
|
+
- **Constraints:** open a new budget each frame; a unit always finishes, so one unit can cross the limit
|
|
4050
|
+
|
|
4051
|
+
```ts
|
|
4052
|
+
tiles.follow(player.position, new AdmissionBudget(2, () => performance.now()));
|
|
4053
|
+
```
|
|
4054
|
+
|
|
3760
4055
|
### `applyTerrainSurface`
|
|
3761
4056
|
|
|
3762
4057
|
`function` — Apply a cooked GLB's package-authored layered surface to its marked terrain meshes. `url` is the loaded GLB URL; extras pointers are relative to it. Uses the same asset/fetch path as loadTerrainSplat on web and native. The caller owns the assigned materials' lifetime.
|
|
@@ -3804,6 +4099,21 @@ export function bakedNoise( p: Node<"vec3">, amplitude: Scalar = 1, pivot: Scala
|
|
|
3804
4099
|
const patch = smoothstep(-0.35, 0.35, bakedNoise(positionWorld.mul(0.025)));
|
|
3805
4100
|
```
|
|
3806
4101
|
|
|
4102
|
+
### `baseRingGap`
|
|
4103
|
+
|
|
4104
|
+
`function` — The highest gap between a wide model's rim and the ground, one sample per angular sector: in each sector, the lowest vertex beyond `rim` of that sector's reach. A narrow buried stem then cannot hold a wide base up in the air on the downhill side. Sink the pose by `gap` (plus any burial the game wants) to close it.
|
|
4105
|
+
|
|
4106
|
+
```ts
|
|
4107
|
+
export function baseRingGap( geometry: BufferGeometry, matrix: Matrix4, ground: StaticGroundQuery, options: { … }
|
|
4108
|
+
```
|
|
4109
|
+
|
|
4110
|
+
- **Use when:** a cliff or crag model rests on a buried stem while its wide base hangs over the downhill ground
|
|
4111
|
+
- **Constraints:** throws `TN_STATIC_POSE_GROUND` where the ground does not answer; check `samples` before trusting `gap`
|
|
4112
|
+
|
|
4113
|
+
```ts
|
|
4114
|
+
const ring = baseRingGap(geometry, matrix, ground); if (ring.samples >= 4) matrix.elements[13] -= ring.gap + 0.5;
|
|
4115
|
+
```
|
|
4116
|
+
|
|
3807
4117
|
### `cellPlacements`
|
|
3808
4118
|
|
|
3809
4119
|
`function` — Borrow the run's placement records as a live view over the placement buffer.
|
|
@@ -3819,6 +4129,21 @@ export function cellPlacements(placements: ArrayBuffer, run: IWorldRun): Float32
|
|
|
3819
4129
|
const records = cellPlacements(buffer, { asset: "tree", offset: 0, count: 120 });
|
|
3820
4130
|
```
|
|
3821
4131
|
|
|
4132
|
+
### `footprintGap`
|
|
4133
|
+
|
|
4134
|
+
`function` — How far the flat underside of a static geometry rises above the ground at its highest point. Snapping the lowest point leaves the downhill side of a flat-bottomed rock hanging; sinking the pose by this much buries the whole footprint. Returns 0 when the footprint is already buried.
|
|
4135
|
+
|
|
4136
|
+
```ts
|
|
4137
|
+
export function footprintGap( geometry: BufferGeometry, matrix: Matrix4, ground: StaticGroundQuery, margin = 0, ): number { … }
|
|
4138
|
+
```
|
|
4139
|
+
|
|
4140
|
+
- **Use when:** a rock snapped to a slope shows a lip or a gap under its downhill side
|
|
4141
|
+
- **Constraints:** the footprint is every vertex at the geometry's lowest local y; throws `TN_STATIC_POSE_GROUND` where the ground does not answer
|
|
4142
|
+
|
|
4143
|
+
```ts
|
|
4144
|
+
matrix.elements[13] -= footprintGap(geometry, matrix, ground, 0.08);
|
|
4145
|
+
```
|
|
4146
|
+
|
|
3822
4147
|
### `getWorldCapabilities`
|
|
3823
4148
|
|
|
3824
4149
|
`function` — Resolve the active world-generation path from host capability facts. The function accepts the adapter facts instead of reaching through a renderer-specific global, so browser and native hosts can report the same object. Missing limits are not treated as infinite: a host must either provide a valid GPU limit report or explicitly choose CPU fallback. GPU generation remains unavailable until a GPU readback can own the canonical field; a host adapter report therefore never upgrades a CPU fallback into a GPU generation claim.
|
|
@@ -3910,6 +4235,21 @@ export function lakeReach(field: Heightfield, lake: IWaterLake): number { … }
|
|
|
3910
4235
|
const reach = lakeReach(field, { ...lake, margin: 1.12 });
|
|
3911
4236
|
```
|
|
3912
4237
|
|
|
4238
|
+
### `lakeSurfaceGeometry`
|
|
4239
|
+
|
|
4240
|
+
`function` — A lake's water surface: a level disc out to `lakeReach`, the footprint `WaterBodies` floods, with a `metres` attribute (water depth over the ground). Only cells with water at a corner get triangles, so the surface does not hover over dry hillside and the shore follows the ground's contour. The rings pack towards the middle, so an irregular basin costs vertices where the camera sees them. Returns `undefined` when the basin holds no water at its level.
|
|
4241
|
+
|
|
4242
|
+
```ts
|
|
4243
|
+
export function lakeSurfaceGeometry( lake: IWaterLake, field: Heightfield, options: ILakeSurfaceOptions = { … }
|
|
4244
|
+
```
|
|
4245
|
+
|
|
4246
|
+
- **Use when:** draw a lake's water surface from the baked level and seed · a lake's drawn water and the swimmer's water disagree
|
|
4247
|
+
- **Constraints:** the lake row and field come from the game's bake; the game's material shades the geometry
|
|
4248
|
+
|
|
4249
|
+
```ts
|
|
4250
|
+
const geometry = lakeSurfaceGeometry({ ...lake, margin: 1.12 }, field, { maxDepth: 1.6 });
|
|
4251
|
+
```
|
|
4252
|
+
|
|
3913
4253
|
### `loadTerrainSplat`
|
|
3914
4254
|
|
|
3915
4255
|
`function` — The splat terrain surface a world package describes, for `WorldCells.load({ surface })`. Layers blend over a base by mask channels read as linear data (the masks ship raw, beside the heightmap, so no cook moves a blend threshold), with noise-broken edges and macro brightness variation. Texture sets tile in world metres on the package's ground plane (x, -z: a Z-up authoring tool's x and y), cliffs can be triplanar, and the base plus any layer that asks carries a normal map. Each layer answers light from its own ORM map where the table ships one and from the table's own roughness and metalness where it does not; a layer that states neither is matte and dielectric, and named in a warning. Nothing here is a look choice: textures, tiles, tints, thresholds, surface response and noise scales all come from the package's table, which the game authors once and its DCC shares.
|
|
@@ -3942,6 +4282,21 @@ export async function loadWorldHeightmap(url: string): Promise<Uint16Array> {
|
|
|
3942
4282
|
const data = await loadWorldHeightmap("/world/terrain/heightmap.u16");
|
|
3943
4283
|
```
|
|
3944
4284
|
|
|
4285
|
+
### `meshSections`
|
|
4286
|
+
|
|
4287
|
+
`function` — A mesh's material sections: one per geometry group for a material array, else the whole mesh. Instanced props draw one batch per material, so an imported model splits here first.
|
|
4288
|
+
|
|
4289
|
+
```ts
|
|
4290
|
+
export function meshSections(mesh: Mesh): IMeshSection[] { … }
|
|
4291
|
+
```
|
|
4292
|
+
|
|
4293
|
+
- **Use when:** scatter or instance an imported glTF model that has several materials
|
|
4294
|
+
- **Constraints:** a section's `material` can be `undefined` for a group naming a missing material slot; skip it
|
|
4295
|
+
|
|
4296
|
+
```ts
|
|
4297
|
+
for (const section of meshSections(mesh)) parts.push(sectionGeometry(mesh, box, section));
|
|
4298
|
+
```
|
|
4299
|
+
|
|
3945
4300
|
### `noiseVolume`
|
|
3946
4301
|
|
|
3947
4302
|
`function` — The one volume every material shares: baked on first use, 1 MiB of RGBA8 (it stays in L2).
|
|
@@ -3957,6 +4312,66 @@ export function noiseVolume(): Data3DTexture { … }
|
|
|
3957
4312
|
const volume = noiseVolume();
|
|
3958
4313
|
```
|
|
3959
4314
|
|
|
4315
|
+
### `repairZeroNormals`
|
|
4316
|
+
|
|
4317
|
+
`function` — Recompute the normals of a geometry whose normals are missing, zero or not finite, and leave authored normals alone. Some exported art ships zero normals and draws black under any light. Run it after any reshape, so the recomputed normals fit the final shape.
|
|
4318
|
+
|
|
4319
|
+
```ts
|
|
4320
|
+
export function repairZeroNormals(geometry: BufferGeometry): boolean { … }
|
|
4321
|
+
```
|
|
4322
|
+
|
|
4323
|
+
- **Use when:** an imported model draws black or unlit because it ships zero normals
|
|
4324
|
+
- **Constraints:** one bad normal recomputes them all; an intentionally hard-edged model loses its authored split normals only if one is bad
|
|
4325
|
+
|
|
4326
|
+
```ts
|
|
4327
|
+
geometry.scale(1.1, 1, 1.1); repairZeroNormals(geometry);
|
|
4328
|
+
```
|
|
4329
|
+
|
|
4330
|
+
### `riverRibbonGeometry`
|
|
4331
|
+
|
|
4332
|
+
`function` — The water surface of every river, as one geometry with one group per river. Each station is a row across the river at its own surface height, out to `reach` widths either side of the centreline, the reach `WaterBodies` floods; one more row a reach past each end stands where `WaterBodies` clamps a segment, so the water a swimmer finds past a river's end is drawn there too (cut at the end station, the surface stopped in a straight edge with its carved bed dry beyond). Quads dry on both rows against `field` are dropped, so the surface ends at the shore. Past an end where the ground falls below the end's bed, the water would run off: that cap is not drawn, and the end stays cut at its last station. Attributes for the game's water material: `flow` (the unit downstream heading), `flowUv` (metres down the centreline, metres across it) and `metres` (water depth over the ground). It decides no colour, ripple or opacity: the game shades it.
|
|
4333
|
+
|
|
4334
|
+
```ts
|
|
4335
|
+
export function riverRibbonGeometry( rivers: readonly { … }
|
|
4336
|
+
```
|
|
4337
|
+
|
|
4338
|
+
- **Use when:** draw a river's water surface from the baked stations · a river's water stops in a straight edge, or a swimmer floats where no water is drawn · share one river shape between the drawn water and the swimmer · river water hangs over dry ground past the river's head or tail
|
|
4339
|
+
- **Constraints:** stations, width and reach come from the game's bake; the game's material shades the geometry
|
|
4340
|
+
|
|
4341
|
+
```ts
|
|
4342
|
+
const geometry = riverRibbonGeometry(rivers, field, { maxDepth: 1.6 });
|
|
4343
|
+
```
|
|
4344
|
+
|
|
4345
|
+
### `sectionGeometry`
|
|
4346
|
+
|
|
4347
|
+
`function` — One section's geometry in model space, standing on y = 0. Every section of a model takes the same base from the whole model's `box`, so a crown keeps its place on its trunk: basing each section on its own bounds detaches them. The mesh's LOD0 geometry is cloned under its world matrix, and a group becomes the clone's draw range.
|
|
4348
|
+
|
|
4349
|
+
```ts
|
|
4350
|
+
export function sectionGeometry( mesh: Mesh, box: Box3, section: IMeshSection, options: { … }
|
|
4351
|
+
```
|
|
4352
|
+
|
|
4353
|
+
- **Use when:** the crown of an instanced tree floats off its trunk, or the parts of a model separate · turn each part of an imported model into a geometry for an instanced prop batch
|
|
4354
|
+
- **Constraints:** `box` is the whole model's world bounds after any unit normalisation; call `mesh.updateWorldMatrix` first
|
|
4355
|
+
|
|
4356
|
+
```ts
|
|
4357
|
+
const box = new Box3().setFromObject(root); const geometry = sectionGeometry(mesh, box, section);
|
|
4358
|
+
```
|
|
4359
|
+
|
|
4360
|
+
### `shoreField`
|
|
4361
|
+
|
|
4362
|
+
`function` — Distance to the shore and open-sea exposure for every node of a square height grid, measured once from the bake. `distance` is a two-pass chamfer distance to the nearest node at or above `level` (0 on dry ground). `exposed` floods from the grid's edge through water deeper than `openDepth`, then `carry` metres further into shallow water, so a sheltered lagoon behind a sand bar stays out of it. Both feed the game's surf and shore masks; neither decides a colour.
|
|
4363
|
+
|
|
4364
|
+
```ts
|
|
4365
|
+
export function shoreField( heights: ArrayLike<number>, resolution: number, size: number, level: number, options: IShoreFieldOptions = { … }
|
|
4366
|
+
```
|
|
4367
|
+
|
|
4368
|
+
- **Use when:** surf breaks only on water open to the sea, not in a sheltered lagoon · distance from each water cell to the shore, for a foam or depth mask
|
|
4369
|
+
- **Constraints:** heights are row-major, `resolution` by `resolution`, across `size` metres; measured once, never per frame
|
|
4370
|
+
|
|
4371
|
+
```ts
|
|
4372
|
+
const { distance, exposed } = shoreField(world.heights, world.resolution, world.size, world.waterLevel);
|
|
4373
|
+
```
|
|
4374
|
+
|
|
3960
4375
|
### `snowDiscFootprint`
|
|
3961
4376
|
|
|
3962
4377
|
`function` — A circular contact footprint, sized from a radius the caller measures. The shape a sphere, a ball, a wheel or a probe presses into snow, and the default the physics binding derives from a sphere's contact geometry. Flat inside the radius, eased over the softness band, with a raised rim just outside it.
|
|
@@ -3981,7 +4396,7 @@ const footprint = snowDiscFootprint(0.25);
|
|
|
3981
4396
|
export class SnowField { … }
|
|
3982
4397
|
```
|
|
3983
4398
|
|
|
3984
|
-
- **Use when:** leave footprints, tracks and tyre ruts in snow that persist and fill in over time · let a pushed sphere carve a connected track and a dropped one settle into a crater · store snow deformation that rendered geometry and collision both read · reset a snowfield between rounds or change its depth at runtime · show how packed the snow is where people have walked or objects have rested
|
|
4399
|
+
- **Use when:** leave footprints, tracks and tyre ruts in snow that persist and fill in over time · let a fresh snowfall slowly fill older tracks back in as the field recovers · let a pushed sphere carve a connected track and a dropped one settle into a crater · store snow deformation that rendered geometry and collision both read · reset a snowfield between rounds or change its depth at runtime · show how packed the snow is where people have walked or objects have rested
|
|
3985
4400
|
- **Constraints:** the field composes onto a Heightfield; construct the terrain first and let this own the surface · zero depth is bare ground: contacts register no indentation at all · out-of-region heightAt and normalAt follow Heightfield's error contract; sample returns zeros
|
|
3986
4401
|
- **Requires:** @threenative/core/world Heightfield as the canonical terrain and surface
|
|
3987
4402
|
- **Overrides:** depth, hardness, yieldFraction, maxBank and responseTime name the response coefficients
|
|
@@ -3994,6 +4409,36 @@ snow.stamp({ x: 0, z: 0, area: 0.074, load: 784, duration: 0.1, footprint: snowD
|
|
|
3994
4409
|
snow.recover(1 / 60, 0.0012, 0.4);
|
|
3995
4410
|
```
|
|
3996
4411
|
|
|
4412
|
+
### `staticLowestY`
|
|
4413
|
+
|
|
4414
|
+
`function` — Exact lowest world Y of a static geometry under `matrix`, the precise measurement `GroundSnap` audits against, cheap enough for a load that poses hundreds of thousands of props. An upright pose reads the bounding box. A tilted pose scans the vertices bottom first (sorted once per geometry) and stops once no later vertex can be lower: `|x e1 + z e9| <= reach * hypot(e1, e9)`.
|
|
4415
|
+
|
|
4416
|
+
```ts
|
|
4417
|
+
export function staticLowestY(geometry: BufferGeometry, matrix: Matrix4): number { … }
|
|
4418
|
+
```
|
|
4419
|
+
|
|
4420
|
+
- **Use when:** stand a scattered rock, tree or crate on the ground by its lowest point, not its origin · props hover or sink because their pivot is not at their base
|
|
4421
|
+
- **Constraints:** static geometry only; a skinned model uses `GroundSnap`; the sort is cached per geometry, so do not mutate its positions
|
|
4422
|
+
|
|
4423
|
+
```ts
|
|
4424
|
+
placed.position.y += ground - staticLowestY(geometry, matrix);
|
|
4425
|
+
```
|
|
4426
|
+
|
|
4427
|
+
### `surfaceSampler`
|
|
4428
|
+
|
|
4429
|
+
`function` — `Heightfield.surfaceAt` under the transform the game draws the field's mesh with, so a prop or a player stands on the triangles the eye sees rather than on the bilinear field between them. Answers `null` outside the field and for a transform it does not model (any rotation, or an unequal scale), so the caller keeps its own fallback there.
|
|
4430
|
+
|
|
4431
|
+
```ts
|
|
4432
|
+
export function surfaceSampler(field: Heightfield, matrixWorld: Matrix4): SurfaceSampler { … }
|
|
4433
|
+
```
|
|
4434
|
+
|
|
4435
|
+
- **Use when:** stand props or a player on the drawn terrain triangles under a moved or scaled mesh · props float or sink where the terrain mesh is drawn under a transform
|
|
4436
|
+
- **Constraints:** the mesh is `field.toGeometry()` drawn upright under a uniform scale; read `matrixWorld` after it settles
|
|
4437
|
+
|
|
4438
|
+
```ts
|
|
4439
|
+
const ground = surfaceSampler(field, mesh.matrixWorld); const y = ground(x, z) ?? fallback;
|
|
4440
|
+
```
|
|
4441
|
+
|
|
3997
4442
|
### `TerrainTiles`
|
|
3998
4443
|
|
|
3999
4444
|
`class` — Stream a bounded square of game-authored heightfields and keep their render and physics units together. The class composes ordinary THREE.LOD objects and leaves frustum/projection culling to the renderer's existing scene path.
|
|
@@ -4002,7 +4447,7 @@ snow.recover(1 / 60, 0.0012, 0.4);
|
|
|
4002
4447
|
export class TerrainTiles extends Object3D implements IComputeDriven { … }
|
|
4003
4448
|
```
|
|
4004
4449
|
|
|
4005
|
-
- **Use when:** stream terrain without cracks · keep generated terrain resident around a moving player · put a generated terrain tile into a game-owned physics world
|
|
4450
|
+
- **Use when:** stream terrain without cracks · keep generated terrain resident around a moving player · put a generated terrain tile into a game-owned physics world · a hole or a flicker where streamed terrain tiles are still building (`settledHalf`) · split the ground between streamed tiles and a far mesh around the player (`settledHalf`)
|
|
4006
4451
|
- **Constraints:** sampleHeight and surface are required game choices; no landform or surface preset is installed · residentTileBudget and residentByteBudget are hard caps; a tile that cannot fit throws · seam gap, LOD pop and the rendered-vertex finiteness scan are measurements that are off by default; TN_TERRAIN_VALIDATE=1, ?tnTerrainValidate=1 or validate: true runs them, and maxSeamGap, maxVisualSeamGap and maxLodPop report undefined while they are off
|
|
4007
4452
|
- **Overrides:** tileSize, tileResolution, lodFactors, lodDistances, skirtDepth, streamRadius, colliderRadius, mergeTiles, validate, and budgets
|
|
4008
4453
|
|
|
@@ -4043,6 +4488,21 @@ export function validateWorldPackage( manifest: unknown, options: IWorldPackageV
|
|
|
4043
4488
|
const { ok, errors } = validateWorldPackage(json, { placementsByteLength: buffer.byteLength });
|
|
4044
4489
|
```
|
|
4045
4490
|
|
|
4491
|
+
### `warmUnculled`
|
|
4492
|
+
|
|
4493
|
+
`function` — Draw `root` with frustum culling off until it has drawn `draws` times, then cull it again and resolve. A pipeline is built by its first real draw (a startup warm-up compiles a different pass), so content the spawn view does not see — streamed tiles behind the player, a mirror that draws only when its water does — builds its pipelines after the reveal and hitches the first frames that see it. Join the promise to the loading curtain to build them behind it. Objects that join `root` while it warms draw unculled too.
|
|
4494
|
+
|
|
4495
|
+
```ts
|
|
4496
|
+
export function warmUnculled( ctx: { … }
|
|
4497
|
+
```
|
|
4498
|
+
|
|
4499
|
+
- **Use when:** the first frames after the loading curtain hitch on pipeline builds for content behind the camera · streamed terrain or a lake compiles its pipelines after the reveal
|
|
4500
|
+
- **Constraints:** `ctx.beforeRender` runs on every world draw, also behind the curtain; join the promise to the curtain's hold
|
|
4501
|
+
|
|
4502
|
+
```ts
|
|
4503
|
+
const warm = warmUnculled(ctx, lake.mesh); ctx.startup.hold("lake", () => warm);
|
|
4504
|
+
```
|
|
4505
|
+
|
|
4046
4506
|
### `WaterBodies`
|
|
4047
4507
|
|
|
4048
4508
|
`class` — One world's water, queried: surface height, current and footprint from the baked arrays. Rendering and physics read the same store, as they do for `Heightfield`, so the surface a player sees and the surface a swimmer rests on cannot disagree. Every station, level, extent and speed comes from the game, and the shading stays in the game's own `src/render/`. A river's segments sit in a uniform grid, so a query tests the few that can reach its cell instead of every station of every river.
|
|
@@ -4371,7 +4831,7 @@ export function rapier(options: IPhysicsOptions = { … }
|
|
|
4371
4831
|
```
|
|
4372
4832
|
|
|
4373
4833
|
- **Use when:** add physics to a portable game · provide the context used by character and rigid bodies
|
|
4374
|
-
- **Constraints:** place rapier() before recast() in the plugin list
|
|
4834
|
+
- **Constraints:** place rapier() before recast() in the plugin list · ctx.physics is set before Scene.enter(), not during load(): Rapier initializes while the scene loads, so create bodies in enter() or later (TN_PHYSICS_NOT_READY)
|
|
4375
4835
|
- **Requires:** npm i @threenative/physics
|
|
4376
4836
|
|
|
4377
4837
|
```ts
|
|
@@ -4974,6 +5434,23 @@ if (requestedPlaytestClockMode() === "wall-clock") host.pumpDrivesTheSimulation(
|
|
|
4974
5434
|
|
|
4975
5435
|
## `@threenative/playtest/runner`
|
|
4976
5436
|
|
|
5437
|
+
### `absolutesVerdict`
|
|
5438
|
+
|
|
5439
|
+
`function` — The host-load reading and the rule that decides whether absolute milliseconds are trustworthy: absolutes are invalid once the one-minute load passes half the cores.
|
|
5440
|
+
|
|
5441
|
+
```ts
|
|
5442
|
+
export function absolutesVerdict(reading: IPerfHostLoadReading): IPerfHostLoad["absolutes"] { … }
|
|
5443
|
+
```
|
|
5444
|
+
|
|
5445
|
+
- **Use when:** mark a benchmark run invalid because the machine was busy
|
|
5446
|
+
- **Constraints:** an unreadable load is a refusal, not a silence: an unmeasured machine cannot vouch
|
|
5447
|
+
|
|
5448
|
+
```ts
|
|
5449
|
+
import { absolutesVerdict, readHostLoad } from "@threenative/playtest/runner";
|
|
5450
|
+
const load = readHostLoad();
|
|
5451
|
+
if (absolutesVerdict(load) === "invalid-absolute") ignoreAbsoluteMilliseconds();
|
|
5452
|
+
```
|
|
5453
|
+
|
|
4977
5454
|
### `AdbAndroidDriver`
|
|
4978
5455
|
|
|
4979
5456
|
`class` — Drive and inspect Android playtest transport.
|
|
@@ -5606,6 +6083,23 @@ export function preflightDisplay( config: Pick<IStandalonePlaytestConfig, "headl
|
|
|
5606
6083
|
const report = await runStandalonePlaytest(options);
|
|
5607
6084
|
```
|
|
5608
6085
|
|
|
6086
|
+
### `readHostLoad`
|
|
6087
|
+
|
|
6088
|
+
`function` — The host-load reading and the rule that decides whether absolute milliseconds are trustworthy: absolutes are invalid once the one-minute load passes half the cores.
|
|
6089
|
+
|
|
6090
|
+
```ts
|
|
6091
|
+
export function readHostLoad( source: IPerfHostLoadSource = { … }
|
|
6092
|
+
```
|
|
6093
|
+
|
|
6094
|
+
- **Use when:** mark a benchmark run invalid because the machine was busy
|
|
6095
|
+
- **Constraints:** an unreadable load is a refusal, not a silence: an unmeasured machine cannot vouch
|
|
6096
|
+
|
|
6097
|
+
```ts
|
|
6098
|
+
import { absolutesVerdict, readHostLoad } from "@threenative/playtest/runner";
|
|
6099
|
+
const load = readHostLoad();
|
|
6100
|
+
if (absolutesVerdict(load) === "invalid-absolute") ignoreAbsoluteMilliseconds();
|
|
6101
|
+
```
|
|
6102
|
+
|
|
5609
6103
|
### `reconcileBrowserPointers`
|
|
5610
6104
|
|
|
5611
6105
|
`function` — Compare pointer snapshots and produce down, move, and up transitions.
|
|
@@ -5745,17 +6239,17 @@ await runDesktopPlaytest(options);
|
|
|
5745
6239
|
|
|
5746
6240
|
### `runDevicePlaytest`
|
|
5747
6241
|
|
|
5748
|
-
`function` — Run a playtest on Android through
|
|
6242
|
+
`function` — Run a playtest on any device lane (Android, desktop or iOS) through its driver and transport.
|
|
5749
6243
|
|
|
5750
6244
|
```ts
|
|
5751
6245
|
export async function runDevicePlaytest( config: IStandalonePlaytestConfig, target: IDevicePlaytestTarget, ): Promise<IStandalonePlaytestReport> { … }
|
|
5752
6246
|
```
|
|
5753
6247
|
|
|
5754
|
-
- **Use when:** execute a scenario on
|
|
5755
|
-
- **Constraints:** the app bundle and
|
|
6248
|
+
- **Use when:** execute a scenario on a device target with a custom driver
|
|
6249
|
+
- **Constraints:** the driver must prepare the app bundle and the transport must answer the handshake
|
|
5756
6250
|
|
|
5757
6251
|
```ts
|
|
5758
|
-
await
|
|
6252
|
+
await runDevicePlaytest(config, { name: "android", driver, transport, processName, mailboxPaths });
|
|
5759
6253
|
```
|
|
5760
6254
|
|
|
5761
6255
|
### `runIosPlaytest`
|
|
@@ -6649,13 +7143,13 @@ const state = applyPlacementOverrides(terrain.evaluate(), document.placementOver
|
|
|
6649
7143
|
|
|
6650
7144
|
### `bakeBiome`
|
|
6651
7145
|
|
|
6652
|
-
`function` — Bake one biome: the recipe's evaluated state and the world package it streams. This is the composition `terrain_generate` and a game's build script both call, so the file layout a player streams is decided in one place. The biome is validated first — an inline spec from a request is checked here, not trusted — and the package's own placement runs are checked against the state they came from, so a bake can never ship a cell list that lost instances.
|
|
7146
|
+
`function` — Bake one biome: the recipe's evaluated state and the world package it streams. This is the composition `terrain_generate` and a game's build script both call, so the file layout a player streams is decided in one place. The biome is validated first — an inline spec from a request is checked here, not trusted — and the package's own placement runs are checked against the state they came from, so a bake can never ship a cell list that lost instances. An agent does not write this call to get a world: the `threenative-terrain` MCP tool `terrain_generate` takes the request in words ("a pine forest under snowy mountains with a river", "a volcanic island", or `ground: { location }` for a real place) and cooks the world.glb, recipe.json and world.json a game loads with `ctx.assets.model`.
|
|
6653
7147
|
|
|
6654
7148
|
```ts
|
|
6655
7149
|
export function bakeBiome(options: IBakeBiomeOptions): IBakedBiome { … }
|
|
6656
7150
|
```
|
|
6657
7151
|
|
|
6658
|
-
- **Use when:** bake one biome's world package from an evaluated recipe and a biome file
|
|
7152
|
+
- **Use when:** bake one biome's world package from an evaluated recipe and a biome file · generate terrain with mountains, hills, a river, a lake or an island from a request in words · generate a landscape or open world map for a game · procedural terrain for a level: a volcanic island, a mountain valley or a coast · make a canyon, a volcano, a fjord, a desert, a tundra or a forest world · cook the real terrain of a place on Earth from its latitude and longitude
|
|
6659
7153
|
- **Constraints:** every instance's asset must be in `assets`; every instance must land in exactly one cell run
|
|
6660
7154
|
- **Requires:** npm i -D @threenative/terrain
|
|
6661
7155
|
|
|
@@ -6779,6 +7273,22 @@ export async function decodeHeightPNG( input: Uint8Array | ArrayBuffer, options:
|
|
|
6779
7273
|
const png = await encodeHeightPNG(new Terrain({ resolution: 17 }).evaluate()); const heights = await decodeHeightPNG(png);
|
|
6780
7274
|
```
|
|
6781
7275
|
|
|
7276
|
+
### `decodePropBucket`
|
|
7277
|
+
|
|
7278
|
+
`function` — The records of one compiled prop bucket, read back in record order: the inverse of `compilePropBuckets`, so a loader that fetched a bake's files gets each record's ID, model, pose and reach without re-deriving the container layout.
|
|
7279
|
+
|
|
7280
|
+
```ts
|
|
7281
|
+
export function decodePropBucket(bucket: IPropBucketPackage): IPropBucketRecord[] { … }
|
|
7282
|
+
```
|
|
7283
|
+
|
|
7284
|
+
- **Use when:** read a baked prop bucket back into placements to ground them on this machine's terrain
|
|
7285
|
+
- **Constraints:** throws `TN_PROP_BUCKET_INVALID` when the record buffer, the IDs and the runs disagree
|
|
7286
|
+
- **Requires:** npm i -D @threenative/terrain
|
|
7287
|
+
|
|
7288
|
+
```ts
|
|
7289
|
+
for (const record of decodePropBucket(bucket)) pose(record.key, record.position, record.quaternion);
|
|
7290
|
+
```
|
|
7291
|
+
|
|
6782
7292
|
### `decodeRAW16`
|
|
6783
7293
|
|
|
6784
7294
|
`function` — Validates dimensions and range before decoding numerical height samples.
|
|
@@ -6957,6 +7467,22 @@ export function landformBackdrop( kind: LandformKind, options: IBackdropOptions
|
|
|
6957
7467
|
const { size, resolution, heights } = landformBackdrop("temperateMountains", { seed: 7, centerHeight: 13 });
|
|
6958
7468
|
```
|
|
6959
7469
|
|
|
7470
|
+
### `liftMassif`
|
|
7471
|
+
|
|
7472
|
+
`function` — A tile's mountain above its own foot: the heights minus a smooth surface through its border, so its edge is exactly zero and stands on any ground with no wall or ramp. Signed: a valley inside the mountain cuts below the foot, as it does in the survey.
|
|
7473
|
+
|
|
7474
|
+
```ts
|
|
7475
|
+
export function liftMassif(tile: IMassifTile): Float32Array { … }
|
|
7476
|
+
```
|
|
7477
|
+
|
|
7478
|
+
- **Use when:** measure how tall a surveyed mountain stands above the valley floor around it
|
|
7479
|
+
- **Constraints:** the tile must cover the whole mountain; a summit crop lifts as a cone
|
|
7480
|
+
- **Requires:** npm i -D @threenative/terrain
|
|
7481
|
+
|
|
7482
|
+
```ts
|
|
7483
|
+
const lifted = liftMassif({ id: "hill", size: 400, resolution: 3, heights: [0, 0, 0, 0, 90, 0, 0, 0, 0] });
|
|
7484
|
+
```
|
|
7485
|
+
|
|
6960
7486
|
### `makeExport`
|
|
6961
7487
|
|
|
6962
7488
|
`function` — Recovered numerical/project exports; GLB/runtime outputs contain terrain only.
|
|
@@ -7005,6 +7531,23 @@ export function orderedScatterRules(spec: IBiomeSpec): IOrderedScatterRules {
|
|
|
7005
7531
|
const rules = orderedScatterRules(spec);
|
|
7006
7532
|
```
|
|
7007
7533
|
|
|
7534
|
+
### `placeMassif`
|
|
7535
|
+
|
|
7536
|
+
`function` — Stands one surveyed mountain behind a world, chosen and posed by a seed: the tile from a list, a point on a bearing and distance, a turn that faces its steepest wall to the centre within 20 degrees, a mirror and a summit height. It stands on the host's own foot (a smooth surface through the host under its border), replacing the host's hills inside its square, and leaves the centre square untouched. Appends one `heightmap` layer; the placement carries the tile-spacing heights a relief map reads.
|
|
7537
|
+
|
|
7538
|
+
```ts
|
|
7539
|
+
export function placeMassif( terrain: Terrain, options: IPlaceMassifOptions, ): { … }
|
|
7540
|
+
```
|
|
7541
|
+
|
|
7542
|
+
- **Use when:** put a real-shaped mountain behind a generated world, a different one per seed
|
|
7543
|
+
- **Constraints:** the tile must be a whole mountain whose border is valley floor; erosion after it carves the survey
|
|
7544
|
+
- **Requires:** npm i -D @threenative/terrain
|
|
7545
|
+
- **Overrides:** `at`, `bearing`, `distance`, `height`, `top`, `face` and `keepOut` on the same call
|
|
7546
|
+
|
|
7547
|
+
```ts
|
|
7548
|
+
const { terrain, placement } = placeMassif(new Terrain({ size: 5000, resolution: 129 }), { seed: 3, tile: { id: "cone", size: 2000, resolution: 3, heights: [0, 0, 0, 0, 900, 0, 0, 0, 0] } });
|
|
7549
|
+
```
|
|
7550
|
+
|
|
7008
7551
|
### `propAssetOf`
|
|
7009
7552
|
|
|
7010
7553
|
`function` — The asset a package run names. A prop run names the model it draws, `asset:variant[@shape]`; a container written by `bakeWorldPackage` names the asset alone. Both reduce to the asset here, which is what a count, a material or a placement's own `asset` field holds.
|
|
@@ -7265,6 +7808,21 @@ export function createEditorSelection( { … }
|
|
|
7265
7808
|
const selection = createEditorSelection({ gizmo, proxy, controller, grounding, surface, defaultFootprintSize, refreshPose, drawFootprint, restorePlacement, previewPlacement, setSaving, selectedChanged, setNavigation, message });
|
|
7266
7809
|
```
|
|
7267
7810
|
|
|
7811
|
+
### `createTweakBox`
|
|
7812
|
+
|
|
7813
|
+
`function` — A box of range bars and colour pickers over the running game, for tuning numbers by eye. The game names its knobs and applies each change itself; the box owns the page elements, the stored values and the Copy button, whose JSON is what gets pasted back and written into the game's own source. With no `document` (a native launch, a test) it draws nothing and still holds the values, so the game code that reads them is the same on every target.
|
|
7814
|
+
|
|
7815
|
+
```ts
|
|
7816
|
+
export function createTweakBox<K extends string>(options: ITweakBoxOptions<K>): ITweakBox<K> { … }
|
|
7817
|
+
```
|
|
7818
|
+
|
|
7819
|
+
- **Use when:** tune look numbers by eye with live range bars and colour pickers while the game runs
|
|
7820
|
+
- **Requires:** npm i -D @threenative/terrain
|
|
7821
|
+
|
|
7822
|
+
```ts
|
|
7823
|
+
const box = createTweakBox({ title: "Fog", knobs: { density: { min: 0, max: 0.1, value: 0.02 } }, onChange: (name, value) => console.info(name, value) });
|
|
7824
|
+
```
|
|
7825
|
+
|
|
7268
7826
|
### `editorPlacementCenter`
|
|
7269
7827
|
|
|
7270
7828
|
`function` — Transform the caller's measured geometry centre into the evaluated placement's world space.
|