Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Merge branch 'worktree-agent-ade18716ac9c6ea04' into feat/scene-kits

Nguyen Xuan An92af5df48a23
diff --cc docs/guide.md
index dd6673f8,326ec16f..316cd739
--- a/docs/guide.md
+++ b/docs/guide.md
@@@ -209,8 -209,18 +209,18 @@@ The [vehicle contract](/vehicle.md) lis
2. Pick detail per camera with `selectLevels(forest.instances, eye)`.
3. Pass `view.parts` to `Renderer67` and rebuild when `view.changed` is true.
-Cards (`leaves: 'cards'`, the default) use alpha-masked, double-sided textures; `'mesh'` leaves cost more triangles but sway with the `foliage` wind. The [Vegetation contract](/vegetation.md) lists species, triangle budgets and limits.
+Cards (`leaves: 'cards'`, the default) are single-sided, alpha-masked, double-sided `foliage` textures that sway with the wind; `'mesh'` leaves cost about twice the triangles. Pass `barkTextures` for scanned bark. The [Vegetation contract](/vegetation.md) lists species, triangle budgets and limits.
+ ## Terrain and ground textures
+
+ `67js/addons/terrain` and `67js/addons/texture-set` are in the current source and not yet published. They build a chunked, seeded heightfield with distance level of detail and a four-layer ground material (slope, height and mask rules, height-based edge blending, triplanar cliffs, anti-tiling) from CC0 scans.
+
+ 1. `const set = await loadTextureSet('/textures/leafy_grass')` per layer, then `material.layers = [{ ...set, scale: 3 }, ...]` and `material.splat = { rules }`.
+ 2. `const terrain = createTerrain({ size, chunks, resolution, levels, seed })`; give every `terrain.parts` entry the one shared material.
+ 3. Pass `terrain.heightAt` to `scatterVegetation` and vehicles, and call `renderer.replaceParts` when `terrain.update(eye)` returns parts.
+
+ The [Terrain contract](/terrain.md) lists every option, the texture-array memory and the limits.
+
## Retained surface attachments
`createSurfaceAttachment` is introduced in `0.4.1`. Published npm `0.4.0` does not include this addon.
diff --cc skills/build-67js-scene/references/scene-contract.md
index d1bac895,9dfbe984..b3ea925b
--- a/skills/build-67js-scene/references/scene-contract.md
+++ b/skills/build-67js-scene/references/scene-contract.md
@@@ -47,8 -47,9 +47,9 @@@ The material tags select renderer behav
| `water` | Flat ponds and streams only: replaces normals with a near-horizontal ripple field. |
| `liquid` | Shaped water (jets, sheets, splashes): refracts the opaque scene, absorbs by thickness, Fresnel reflection. `color` is what one metre lets through. |
| `foam` | Soft alpha-blended whitewater droplets drawn after liquids. Set `castShadow: false`. |
-| `foliage`, `grass` | Wind movement and backlighting. |
+| `foliage`, `grass` | Wind movement (also in the shadow pass) and backlighting. Accept a base-colour `map` with `alphaMode: 'mask'` and `doubleSided` for leaf cards. |
| `terrain` | Subtle natural surface variation. |
+ | Standard tag with `layers` and `splat` | Four-layer scanned ground blended by slope, height and mask; see `docs/terrain.md`. Rejects the procedural tags and single PBR maps. |
| `fire`, `smoke` | Film ignition expansion and procedural shading. |
| `unlit` | Flat linear color for vector scenes. |
| Other tags | Standard metallic/roughness shading. |
diff --cc src/renderer.js
index 077c1f82,f4bab200..f1bfbebe
--- a/src/renderer.js
+++ b/src/renderer.js
@@@ -306,9 -311,9 +314,10 @@@ export class Renderer67
this.influenceTextures = new Map();
this.morphTextures = new Map();
this.textures = new Map();
+ this.splatResources = new Map();
this.textureBytes = 4;
this.shadowsDirty = true;
+ this.windState = { time: 0, strength: 0.3 };
const groups = groupParts(this.groundPart ? [...parts, this.groundPart] : parts, batching);
const textureLimit = this.context.getParameter(this.context.MAX_TEXTURE_SIZE);
this.hasSkins = groups.some(group => group[0].skin);