Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(examples): add the Wilds example, a lake under mountains with terrain, water, foliage and cloud shadows

yhh119942211c88
diff --git a/examples/README.md b/examples/README.md
index 7fd5571ca..c9ca942b4 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -40,6 +40,7 @@ for your own game.
| **effects-gallery** | Rendering | The built-in material effect templates — hit flash, outline, dissolve, pixelate, UV scroll — with params driven from code. |
| **render-texture** | Rendering | Render-to-texture — a live minimap painted with the `Draw` API into a `RenderTexture`, resolution cycling on R. |
| **drawing-demo** | Rendering | The three drawing tiers — immediate `Draw` radar overlay, retained `Graphics` vector star, procedural `Mesh2D` ribbon. |
+| **wilds** | Rendering | A lake under mountains at dusk — a generated `Terrain` from a heightmap, `Water` with measured depth and shore foam, `Foliage` grass and pines swaying in the wind, and clouds that cast shadows. Everything is made from numbers by `tools/build.mjs`. |
| **video-playback** | Rendering | Play a video on a Sprite with the declarative `Video` component — "a Sprite whose texture is alive". |
| **tilemap-demo** | Tilemap | Two scenes: a Tiled `.tmj` import and an engine-native `.estileset` — multi-tileset, parallax, animated water, per-tile collision. |
| **ui-controls** | UI | Every built-in widget, authored in the scene: button, toggle, toggle group, slider, progress, dropdown, text input, a modal and a scroll view. |
diff --git a/examples/wilds/README.md b/examples/wilds/README.md
new file mode 100644
index 000000000..262572689
--- /dev/null
+++ b/examples/wilds/README.md
@@ -0,0 +1,17 @@
+# Wilds
+
+A lake under mountains at dusk, made to show what the ground, the water, the plants and the sky can do together.
+
+- **`Terrain`** reads `assets/textures/height.png` (sixteen bits packed in red and green) and cuts it into sixteen by sixteen chunks, each at four levels of detail, painted by height and slope through the **Terrain** material.
+- **`Water`** is a plane on the **Water** material: the depth is measured against the scene behind it, so the lake goes from pale teal at the shore to deep blue, with foam where it is shallow.
+- **`Foliage`** grows a meadow of grass round the camera and a forest of pines over the foothills. Both sway through the **Foliage** material; far pines are drawn as cards.
+- **The sky** is the Sky Atmosphere effect, with clouds that cast shadows on the land, and a `TimeOfDay` that holds the sun low.
+
+There is no source art: the four ground textures, the pine and the heightmap are made from numbers.
+
+```
+node build-tools/cli.js sdk
+node examples/wilds/tools/build.mjs
+```
+
+The numbers are at the top of `tools/build.mjs`: change the lake's level or place, the heights, the tree counts, and run it again. The ground and the plants are built a few chunks a frame, so the picture fills in over its first second.
diff --git a/examples/wilds/assets/materials/grass.esmaterial b/examples/wilds/assets/materials/grass.esmaterial
new file mode 100644
index 000000000..387b427a1
--- /dev/null
+++ b/examples/wilds/assets/materials/grass.esmaterial
@@ -0,0 +1,29 @@
+{
+ "version": "1.0",
+ "type": "material",
+ "shader": "builtin:foliage",
+ "blendMode": 0,
+ "depthTest": true,
+ "depthWrite": true,
+ "cull": 0,
+ "properties": {
+ "u_baseColor": {
+ "r": 0.1,
+ "g": 0.22,
+ "b": 0.05,
+ "a": 1
+ },
+ "u_tipColor": {
+ "r": 0.5,
+ "g": 0.66,
+ "b": 0.2,
+ "a": 1
+ },
+ "u_windStrength": 3,
+ "u_windSpeed": 1.3,
+ "u_windDirection": 30,
+ "u_gustScale": 0.012,
+ "u_flutter": 0.35,
+ "u_translucency": 0.5
+ }
+}
diff --git a/examples/wilds/assets/materials/grass.esmaterial.meta b/examples/wilds/assets/materials/grass.esmaterial.meta
new file mode 100644
index 000000000..2c2f3781a
--- /dev/null
+++ b/examples/wilds/assets/materials/grass.esmaterial.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "94c98077-fb90-4230-a04c-61079e70a7b8",
+ "version": "2.0",
+ "type": "material",
+ "importer": {}
+}
diff --git a/examples/wilds/assets/materials/pine.esmaterial b/examples/wilds/assets/materials/pine.esmaterial
new file mode 100644
index 000000000..a4b582cd8
--- /dev/null
+++ b/examples/wilds/assets/materials/pine.esmaterial
@@ -0,0 +1,32 @@
+{
+ "version": "1.0",
+ "type": "material",
+ "shader": "builtin:foliage",
+ "blendMode": 0,
+ "depthTest": true,
+ "depthWrite": true,
+ "cull": 0,
+ "properties": {
+ "u_albedo": "assets/textures/pine.png",
+ "u_useTexture": 1,
+ "u_baseColor": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "u_tipColor": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "u_windStrength": 0.9,
+ "u_windSpeed": 0.9,
+ "u_windDirection": 30,
+ "u_gustScale": 0.006,
+ "u_flutter": 0.1,
+ "u_translucency": 0.15,
+ "u_roughness": 0.9
+ }
+}
diff --git a/examples/wilds/assets/materials/pine.esmaterial.meta b/examples/wilds/assets/materials/pine.esmaterial.meta
new file mode 100644
index 000000000..364f97016
--- /dev/null
+++ b/examples/wilds/assets/materials/pine.esmaterial.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "7e05d689-8bbf-4a57-98f1-96ba95af9262",
+ "version": "2.0",
+ "type": "material",
+ "importer": {}
+}
diff --git a/examples/wilds/assets/materials/terrain.esmaterial b/examples/wilds/assets/materials/terrain.esmaterial
new file mode 100644
index 000000000..3d76a8750
--- /dev/null
+++ b/examples/wilds/assets/materials/terrain.esmaterial
@@ -0,0 +1,46 @@
+{
+ "version": "1.0",
+ "type": "material",
+ "shader": "builtin:terrain",
+ "blendMode": 0,
+ "depthTest": true,
+ "depthWrite": true,
+ "cull": 0,
+ "properties": {
+ "u_layer0": "assets/textures/grass.png",
+ "u_layer1": "assets/textures/dirt.png",
+ "u_layer2": "assets/textures/snow.png",
+ "u_layer3": "assets/textures/rock.png",
+ "u_tint0": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "u_tint1": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "u_tint2": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "u_tint3": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "u_tile0": 60,
+ "u_tile1": 70,
+ "u_tile2": 90,
+ "u_tile3": 120,
+ "u_macroVariation": 0.5,
+ "u_sharpness": 2.2,
+ "u_roughness": 0.93
+ }
+}
diff --git a/examples/wilds/assets/materials/terrain.esmaterial.meta b/examples/wilds/assets/materials/terrain.esmaterial.meta
new file mode 100644
index 000000000..b9db28f89
--- /dev/null
+++ b/examples/wilds/assets/materials/terrain.esmaterial.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "ef7d6778-5201-4d27-8a0a-7546b4da2db3",
+ "version": "2.0",
+ "type": "material",
+ "importer": {}
+}
diff --git a/examples/wilds/assets/materials/water.esmaterial b/examples/wilds/assets/materials/water.esmaterial
new file mode 100644
index 000000000..df7c408c0
--- /dev/null
+++ b/examples/wilds/assets/materials/water.esmaterial
@@ -0,0 +1,35 @@
+{
+ "version": "1.0",
+ "type": "material",
+ "shader": "builtin:water",
+ "blendMode": 0,
+ "depthTest": true,
+ "depthWrite": true,
+ "cull": 0,
+ "properties": {
+ "u_waveLength": 220,
+ "u_waveHeight": 5,
+ "u_waveSpeed": 0.8,
+ "u_waveDirection": 25,
+ "u_rippleLength": 26,
+ "u_rippleStrength": 0.34,
+ "u_density": 0.009,
+ "u_foamWidth": 34,
+ "u_foamCrest": 0.35,
+ "u_distortionRange": 180,
+ "u_fallbackDepth": 120,
+ "u_roughness": 0.03,
+ "u_shallowColor": {
+ "r": 0.14,
+ "g": 0.46,
+ "b": 0.46,
+ "a": 1
+ },
+ "u_deepColor": {
+ "r": 0.012,
+ "g": 0.07,
+ "b": 0.13,
+ "a": 1
+ }
+ }
+}
diff --git a/examples/wilds/assets/materials/water.esmaterial.meta b/examples/wilds/assets/materials/water.esmaterial.meta
new file mode 100644
index 000000000..3acbf303c
--- /dev/null
+++ b/examples/wilds/assets/materials/water.esmaterial.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "03a1d0c2-e619-482e-8248-cd2293c578f2",
+ "version": "2.0",
+ "type": "material",
+ "importer": {}
+}
diff --git a/examples/wilds/assets/models/pine.esmesh b/examples/wilds/assets/models/pine.esmesh
new file mode 100644
index 000000000..8835e07e1
Binary files /dev/null and b/examples/wilds/assets/models/pine.esmesh differ
diff --git a/examples/wilds/assets/models/pine.esmesh.meta b/examples/wilds/assets/models/pine.esmesh.meta
new file mode 100644
index 000000000..1b37e3017
--- /dev/null
+++ b/examples/wilds/assets/models/pine.esmesh.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "e5fc7807-fe1c-48d4-b985-331319c686d0",
+ "version": "2.0",
+ "type": "mesh",
+ "importer": {}
+}
diff --git a/examples/wilds/assets/scenes/main.esscene b/examples/wilds/assets/scenes/main.esscene
new file mode 100644
index 000000000..123958331
--- /dev/null
+++ b/examples/wilds/assets/scenes/main.esscene
@@ -0,0 +1,390 @@
+{
+ "version": 4,
+ "name": "Wilds",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -170,
+ "y": 298.7795329024739,
+ "z": 800
+ },
+ "rotation": {
+ "x": -0.01999866669333308,
+ "y": 0,
+ "z": 0,
+ "w": 0.9998000066665778
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 0,
+ "fov": 52,
+ "nearPlane": 2,
+ "farPlane": 20000,
+ "isActive": true,
+ "priority": 0
+ }
+ },
+ {
+ "type": "PostProcessVolume",
+ "data": {
+ "isGlobal": true,
+ "priority": 0,
+ "weight": 1,
+ "effects": [
+ {
+ "type": "skyAtmosphere",
+ "enabled": true,
+ "uniforms": {
+ "u_intensity": 1.05,
+ "u_haze": 1.1,
+ "u_sunBrightness": 40,
+ "u_clouds": 0.5,
+ "u_cloudShadow": 0.7,
+ "u_unitsPerKm": 1000,
+ "u_windSpeed": 0.03
+ }
+ },
+ {
+ "type": "gtao",
+ "enabled": true,
+ "uniforms": {
+ "u_radius": 60,
+ "u_intensity": 1
+ }
+ },
+ {
+ "type": "ssr",
+ "enabled": false,
+ "uniforms": {
+ "u_intensity": 0.7,
+ "u_maxDistance": 900,
+ "u_thickness": 10
+ }
+ },
+ {
+ "type": "heightFog",
+ "enabled": true,
+ "colors": {
+ "u_fogColor": {
+ "r": 0.62,
+ "g": 0.72,
+ "b": 0.84,
+ "a": 1
+ },
+ "u_sunColor": {
+ "r": 1,
+ "g": 0.86,
+ "b": 0.62,
+ "a": 1
+ }
+ },
+ "uniforms": {
+ "u_density": 0.00012,
+ "u_heightFalloff": 0.0014,
+ "u_baseHeight": 112,
+ "u_inscatter": 0.6,
+ "u_skyFog": 0.5,
+ "u_volumetric": 0.5,
+ "u_volumeRange": 4000
+ }
+ },
+ {
+ "type": "lightShafts",
+ "enabled": true,
+ "uniforms": {
+ "u_intensity": 0.35
+ }
+ },
+ {
+ "type": "taa",
+ "enabled": true,
+ "uniforms": {
+ "u_blend": 0.1
+ }
+ },
+ {
+ "type": "autoExposure",
+ "enabled": true,
+ "uniforms": {
+ "u_bias": -0.1,
+ "u_minEV": -2,
+ "u_maxEV": 2
+ }
+ },
+ {
+ "type": "colorGrade",
+ "enabled": true,
+ "uniforms": {
+ "u_contrast": 1.08,
+ "u_saturation": 1.12
+ }
+ },
+ {
+ "type": "bloom",
+ "enabled": true,
+ "uniforms": {
+ "u_threshold": 0.9,
+ "u_intensity": 0.4,
+ "u_radius": 1.1
+ }
+ },
+ {
+ "type": "fxaa",
+ "enabled": true,
+ "uniforms": {
+ "u_intensity": 1
+ }
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Clock",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "TimeOfDay",
+ "data": {
+ "hour": 17,
+ "daySeconds": 0,
+ "latitude": 45,
+ "declination": 15,
+ "north": 0,
+ "drive": 31
+ }
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "name": "Sun",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "Light",
+ "data": {
+ "type": 1,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "intensity": 3,
+ "enabled": true,
+ "meshShadows": true,
+ "shadowExtent": 3000,
+ "shadowStrength": 1,
+ "sourceAngle": 0.5
+ }
+ }
+ ]
+ },
+ {
+ "id": 3,
+ "name": "Sky",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "Light",
+ "data": {
+ "type": 2,
+ "color": {
+ "r": 0.8,
+ "g": 0.88,
+ "b": 1,
+ "a": 1
+ },
+ "intensity": 0.55,
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 4,
+ "name": "Terrain",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "Terrain",
+ "data": {
+ "sizeX": 3200,
+ "sizeZ": 3200,
+ "height": 560,
+ "chunks": 16,
+ "chunkCells": 32,
+ "lodLevels": 4,
+ "detail": 1.4,
+ "heightmap": "assets/textures/height.png",
+ "rockSlope": 0.34,
+ "dirtHeight": 0.5,
+ "snowHeight": 0.84,
+ "material": "assets/materials/terrain.esmaterial"
+ }
+ }
+ ]
+ },
+ {
+ "id": 5,
+ "name": "Lake",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 112,
+ "z": 0
+ },
+ "scale": {
+ "x": 32,
+ "y": 1,
+ "z": 32
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "builtin:plane",
+ "lit": true,
+ "opaque": false,
+ "cullBackfaces": false,
+ "material": "assets/materials/water.esmaterial",
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 6,
+ "name": "Meadow",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -170,
+ "y": 0,
+ "z": 540
+ }
+ }
+ },
+ {
+ "type": "Foliage",
+ "data": {
+ "material": "assets/materials/grass.esmaterial",
+ "sizeX": 420,
+ "sizeZ": 420,
+ "cellSize": 30,
+ "count": 1400,
+ "seed": 3,
+ "minScale": 0.7,
+ "maxScale": 1.3,
+ "minUp": 0.8,
+ "heightMin": 118,
+ "heightMax": 392,
+ "bladeHeight": 46,
+ "bladeWidth": 4.2,
+ "lodDistance": 160,
+ "drawDistance": 420
+ }
+ }
+ ]
+ },
+ {
+ "id": 7,
+ "name": "Pines",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Foliage",
+ "data": {
+ "mesh": "assets/models/pine.esmesh",
+ "material": "assets/materials/pine.esmaterial",
+ "sizeX": 2560,
+ "sizeZ": 2560,
+ "cellSize": 160,
+ "count": 16,
+ "seed": 8,
+ "minScale": 0.7,
+ "maxScale": 1.6,
+ "minUp": 0.8,
+ "heightMin": 154,
+ "heightMax": 369.6,
+ "lodDistance": 650,
+ "drawDistance": 3600,
+ "cardU0": 0.2,
+ "cardV0": 0.22,
+ "cardU1": 0.8,
+ "cardV1": 0.95,
+ "cardTent": 1
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/examples/wilds/assets/scenes/main.esscene.meta b/examples/wilds/assets/scenes/main.esscene.meta
new file mode 100644
index 000000000..d8750fbfe
--- /dev/null
+++ b/examples/wilds/assets/scenes/main.esscene.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "8ba85cd5-448f-4412-b9f7-501b1daafc28",
+ "version": "2.0",
+ "type": "scene",
+ "importer": {}
+}
diff --git a/examples/wilds/assets/textures/dirt.png b/examples/wilds/assets/textures/dirt.png
new file mode 100644
index 000000000..7f0b45481
Binary files /dev/null and b/examples/wilds/assets/textures/dirt.png differ
diff --git a/examples/wilds/assets/textures/dirt.png.meta b/examples/wilds/assets/textures/dirt.png.meta
new file mode 100644
index 000000000..7efea68e1
--- /dev/null
+++ b/examples/wilds/assets/textures/dirt.png.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "4cb2207f-9288-461c-9ccb-307e0d4097cd",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {}
+}
diff --git a/examples/wilds/assets/textures/grass.png b/examples/wilds/assets/textures/grass.png
new file mode 100644
index 000000000..4faefd158
Binary files /dev/null and b/examples/wilds/assets/textures/grass.png differ
diff --git a/examples/wilds/assets/textures/grass.png.meta b/examples/wilds/assets/textures/grass.png.meta
new file mode 100644
index 000000000..413b69ad9
--- /dev/null
+++ b/examples/wilds/assets/textures/grass.png.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "6fd01e31-d9ff-4083-901f-182ee813faa3",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {}
+}
diff --git a/examples/wilds/assets/textures/height.png b/examples/wilds/assets/textures/height.png
new file mode 100644
index 000000000..f6898dec6
Binary files /dev/null and b/examples/wilds/assets/textures/height.png differ
diff --git a/examples/wilds/assets/textures/height.png.meta b/examples/wilds/assets/textures/height.png.meta
new file mode 100644
index 000000000..76d5086a3
--- /dev/null
+++ b/examples/wilds/assets/textures/height.png.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "dbf3429e-8a64-40e3-b75d-6a58dcd4b695",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {}
+}
diff --git a/examples/wilds/assets/textures/pine.png b/examples/wilds/assets/textures/pine.png
new file mode 100644
index 000000000..90a41eccb
Binary files /dev/null and b/examples/wilds/assets/textures/pine.png differ
diff --git a/examples/wilds/assets/textures/pine.png.meta b/examples/wilds/assets/textures/pine.png.meta
new file mode 100644
index 000000000..bd0371e2c
--- /dev/null
+++ b/examples/wilds/assets/textures/pine.png.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "dd06005d-e872-45b9-bca8-e3f6af3ee1b9",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {}
+}
diff --git a/examples/wilds/assets/textures/rock.png b/examples/wilds/assets/textures/rock.png
new file mode 100644
index 000000000..e782f73b0
Binary files /dev/null and b/examples/wilds/assets/textures/rock.png differ
diff --git a/examples/wilds/assets/textures/rock.png.meta b/examples/wilds/assets/textures/rock.png.meta
new file mode 100644
index 000000000..b3c1c7f05
--- /dev/null
+++ b/examples/wilds/assets/textures/rock.png.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "e304edee-2b9f-47f0-86a3-604b9315891e",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {}
+}
diff --git a/examples/wilds/assets/textures/snow.png b/examples/wilds/assets/textures/snow.png
new file mode 100644
index 000000000..34a3897f4
Binary files /dev/null and b/examples/wilds/assets/textures/snow.png differ
diff --git a/examples/wilds/assets/textures/snow.png.meta b/examples/wilds/assets/textures/snow.png.meta
new file mode 100644
index 000000000..3f03f3e7e
--- /dev/null
+++ b/examples/wilds/assets/textures/snow.png.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "d7b144bf-06ad-41d2-997f-a45bea7ece63",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {}
+}
diff --git a/examples/wilds/project.esproject b/examples/wilds/project.esproject
new file mode 100644
index 000000000..e3d3b41be
--- /dev/null
+++ b/examples/wilds/project.esproject
@@ -0,0 +1,19 @@
+{
+ "formatVersion": "1",
+ "name": "Wilds",
+ "description": "A lake under mountains at dusk — generated terrain, water that is measured, grass and pines in the wind, and clouds that cast shadows.",
+ "tag": "3D",
+ "version": "0.1.0",
+ "defaultScene": "assets/scenes/main.esscene",
+ "designResolution": {
+ "width": 1480,
+ "height": 920
+ },
+ "spineVersion": "none",
+ "features": {
+ "rendering": {
+ "colorSpace": "linear",
+ "outputTransform": "neutral"
+ }
+ }
+}
diff --git a/examples/wilds/src/main.ts b/examples/wilds/src/main.ts
new file mode 100644
index 000000000..bba2c3e92
--- /dev/null
+++ b/examples/wilds/src/main.ts
@@ -0,0 +1,3 @@
+// Everything is authored in the scene: the ground, the lake, the grass and the pines are components, and the sun is the clock's.
+// A game that only lights and draws needs no code — the packager just looks for this file.
+export {};
diff --git a/examples/wilds/thumbnail.png b/examples/wilds/thumbnail.png
new file mode 100644
index 000000000..71b4bcc38
Binary files /dev/null and b/examples/wilds/thumbnail.png differ
diff --git a/examples/wilds/thumbnail.png.meta b/examples/wilds/thumbnail.png.meta
new file mode 100644
index 000000000..4a7ab4e31
--- /dev/null
+++ b/examples/wilds/thumbnail.png.meta
@@ -0,0 +1,17 @@
+{
+ "uuid": "1d3fc7a3-7fc2-417e-b10b-73793feb6c36",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {
+ "maxSize": 2048,
+ "filterMode": "linear",
+ "wrapMode": "repeat",
+ "premultiplyAlpha": false,
+ "sliceBorder": {
+ "left": 0,
+ "right": 0,
+ "top": 0,
+ "bottom": 0
+ }
+ }
+}
diff --git a/examples/wilds/tools/build.mjs b/examples/wilds/tools/build.mjs
new file mode 100644
index 000000000..b998c00cc
--- /dev/null
+++ b/examples/wilds/tools/build.mjs
@@ -0,0 +1,384 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file build.mjs — writes the Wilds project's generated assets and scene.
+ *
+ * Everything in the project is made here from numbers, so there is no source art to credit: four tileable ground textures, one pine tree
+ * (a mesh and its colour strip), the materials, and the scene. Run it after changing a number:
+ *
+ * node examples/wilds/tools/build.mjs
+ *
+ * It needs the SDK built (`node build-tools/cli.js sdk`), for the mesh format and the terrain's own noise.
+ */
+import { mkdirSync, writeFileSync } from 'node:fs';
+import { randomUUID } from 'node:crypto';
+import path from 'node:path';
+import zlib from 'node:zlib';
+import { fileURLToPath } from 'node:url';
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const PROJECT = path.resolve(HERE, '..');
+const { MeshChannel, MeshChannelType, packChannels, encodeMesh } =
+ await import(new URL('../../../sdk/dist/index.node.js', import.meta.url).href);
+
+/** The look of the place, in one table. Lengths are the scene's units: a pine is about ninety of them tall. */
+const WORLD = {
+ size: 3200,
+ height: 560,
+ resolution: 513,
+ /** The lake's surface, as a share of the terrain's height, and where its middle is, as shares of the size. */
+ water: 0.2,
+ lake: { u: 0.5, v: 0.42 },
+};
+
+// ── files ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
+
+function write(rel, data) {
+ const file = path.join(PROJECT, rel);
+ mkdirSync(path.dirname(file), { recursive: true });
+ writeFileSync(file, data);
+ return file;
+}
+
+/** The `.meta` an asset carries once the editor has seen it: a stable name for the file. */
+function meta(rel, type, importer = {}) {
+ write(`${rel}.meta`, `${JSON.stringify({ uuid: randomUUID(), version: '2.0', type, importer }, null, 2)}\n`);
+}
+
+// ── images ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
+
+function png(width, height, pixel) {
+ const raw = Buffer.alloc((width * 4 + 1) * height);
+ for (let y = 0; y < height; y++) {
+ const row = y * (width * 4 + 1);
+ for (let x = 0; x < width; x++) {
+ const p = pixel(x, y);
+ for (let k = 0; k < 4; k++) raw[row + 1 + x * 4 + k] = Math.max(0, Math.min(255, Math.round(p[k])));
+ }
+ }
+ const table = new Int32Array(256).map((_, n) => { let c = n; for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; return c; });
+ const crc = (buf) => { let c = -1; for (const b of buf) c = table[(c ^ b) & 255] ^ (c >>> 8); return (c ^ -1) >>> 0; };
+ const chunk = (type, data) => {
+ const head = Buffer.alloc(8); head.writeUInt32BE(data.length, 0); head.write(type, 4);
+ const tail = Buffer.alloc(4); tail.writeUInt32BE(crc(Buffer.concat([head.subarray(4), data])), 0);
+ return Buffer.concat([head, data, tail]);
+ };
+ const header = Buffer.alloc(13); header.writeUInt32BE(width, 0); header.writeUInt32BE(height, 4); header[8] = 8; header[9] = 6;
+ return Buffer.concat([Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]), chunk('IHDR', header), chunk('IDAT', zlib.deflateSync(raw, { level: 9 })), chunk('IEND', Buffer.alloc(0))]);
+}
+
+const hash = (x, y, s) => {
+ let h = (Math.imul(x, 374761393) + Math.imul(y, 668265263) + Math.imul(s, 2147483647)) | 0;
+ h = Math.imul(h ^ (h >>> 13), 1274126177);
+ return ((h ^ (h >>> 16)) >>> 0) / 4294967295;
+};
+
+/** Value noise that wraps every `period` cells, so the picture tiles without a seam. */
+function tiled(x, y, period, seed) {
+ const ix = Math.floor(x), iy = Math.floor(y);
+ const fx = x - ix, fy = y - iy;
+ const sx = fx * fx * (3 - 2 * fx), sy = fy * fy * (3 - 2 * fy);
+ const at = (i, j) => hash(((i % period) + period) % period, ((j % period) + period) % period, seed);
+ const a = at(ix, iy), b = at(ix + 1, iy), c = at(ix, iy + 1), d = at(ix + 1, iy + 1);
+ return a + (b - a) * sx + (c - a) * sy + (a - b - c + d) * sx * sy;
+}
+
+function fractal(u, v, seed, octaves = 5, base = 4) {
+ let sum = 0, amp = 0.5, norm = 0;
+ for (let o = 0; o < octaves; o++) {
+ const period = base << o;
+ sum += amp * tiled(u * period, v * period, period, seed + o * 17);
+ norm += amp;
+ amp *= 0.5;
+ }
+ return sum / norm;
+}
+
+// ── the ground ─────────────────────────────────────────────────────────────────────────────────────────────────────────
+
+const smooth = (a, b, x) => { const t = Math.min(Math.max((x - a) / (b - a), 0), 1); return t * t * (3 - 2 * t); };
+
+/** Value noise from lattice hashes, not tiled: the ground does not repeat. */
+function noise(x, y, seed) {
+ const ix = Math.floor(x), iy = Math.floor(y);
+ const fx = x - ix, fy = y - iy;
+ const sx = fx * fx * (3 - 2 * fx), sy = fy * fy * (3 - 2 * fy);
+ const a = hash(ix, iy, seed), b = hash(ix + 1, iy, seed), c = hash(ix, iy + 1, seed), d = hash(ix + 1, iy + 1, seed);
+ return a + (b - a) * sx + (c - a) * sy + (a - b - c + d) * sx * sy;
+}
+
+function fbm(x, y, seed, octaves, ridged) {
+ let sum = 0, amp = 0.5, norm = 0;
+ for (let o = 0; o < octaves; o++) {
+ let n = noise(x, y, seed + o * 31);
+ if (ridged) n = 1 - Math.abs(n * 2 - 1);
+ sum += n * amp; norm += amp; amp *= 0.5; x *= 2.07; y *= 2.07;
+ }
+ return sum / norm;
+}
+
+/**
+ * The land, 0 to 1 over the whole square: a lake with a shore that wanders, meadows and low hills round it, and mountains that rise
+ * toward the rim and close the picture on every side.
+ */
+function landHeight(u, v) {
+ const dx = u - WORLD.lake.u, dz = v - WORLD.lake.v;
+ const warp = (fbm(u * 5, v * 5, 5, 3, false) - 0.5) * 0.16;
+ const r = Math.hypot(dx, dz) + warp;
+ const mountains = 0.3 + 0.7 * Math.pow(fbm(u * 3.1 + 7, v * 3.1 + 3, 21, 6, true), 1.25) * 1.15;
+ const meadow = 0.235 + 0.07 * fbm(u * 9, v * 9, 33, 4, false) + 0.03 * fbm(u * 2, v * 2, 40, 2, false);
+ let h = meadow + (mountains - meadow) * smooth(0.34, 0.62, r);
+ // The basin: it deepens toward the middle and meets the shore at the water's own height, a little above it.
+ const basin = 0.045 + 0.19 * smooth(0.05, 0.27, r);
+ h = basin + (h - basin) * smooth(0.22, 0.3, r);
+ // Mountains close the edge of the world.
+ const edge = Math.max(Math.abs(u - 0.5), Math.abs(v - 0.5)) * 2;
+ const wall = smooth(0.72, 1, edge);
+ const rim = 0.5 + 0.5 * fbm(u * 4 + 11, v * 4 + 5, 61, 5, true);
+ return Math.min(1, Math.max(h, h + (rim - h) * wall));
+}
+
+/** The heightmap: sixteen bits across red (high) and green (low), which the Terrain component reads back as one number. */
+function heightmap() {
+ const n = WORLD.resolution;
+ const image = png(n, n, (x, y) => {
+ const value = Math.round(Math.min(1, Math.max(0, landHeight(x / (n - 1), y / (n - 1)))) * 65535);
+ return [value >> 8, value & 255, 0, 255];
+ });
+ write('assets/textures/height.png', image);
+ // A heightmap is data, read raw: it must not be colour-managed or compressed on the way in.
+ meta('assets/textures/height.png', 'texture');
+}
+
+const mix = (a, b, t) => a.map((v, i) => v + (b[i] - v) * t);
+
+function texture(name, seed, shade) {
+ const size = 512;
+ const image = png(size, size, (x, y) => {
+ const u = x / size, v = y / size;
+ const rgb = shade(u, v, (s, o, b) => fractal(u, v, seed + s, o, b));
+ return [rgb[0], rgb[1], rgb[2], 255];
+ });
+ write(`assets/textures/${name}.png`, image);
+ meta(`assets/textures/${name}.png`, 'texture');
+}
+
+function textures() {
+ texture('grass', 1, (u, v, n) => {
+ const broad = n(0, 4, 3), fine = n(40, 5, 24), blade = n(80, 2, 96);
+ return mix(mix([46, 72, 28], [92, 128, 46], broad), [64, 98, 34], fine * 0.6).map((c) => c * (0.78 + 0.45 * blade));
+ });
+ texture('dirt', 2, (u, v, n) => {
+ const broad = n(0, 4, 3), fine = n(30, 5, 16);
+ return mix([84, 64, 44], [128, 100, 70], broad).map((c) => c * (0.8 + 0.4 * fine));
+ });
+ texture('snow', 3, (u, v, n) => {
+ const fine = n(0, 4, 8);
+ return mix([226, 232, 242], [250, 252, 255], fine);
+ });
+ texture('rock', 4, (u, v, n) => {
+ const broad = n(0, 4, 4), ridge = 1 - Math.abs(n(20, 5, 6) * 2 - 1), fine = n(60, 4, 32);
+ return mix([70, 66, 64], [138, 130, 122], broad * 0.7 + ridge * 0.4).map((c) => c * (0.82 + 0.36 * fine));
+ });
+ // The tree's colour: bark at the foot, then needles that darken toward the shade under each tier.
+ const strip = png(8, 128, (x, y) => {
+ const v = 1 - y / 127;
+ if (v < 0.2) return mix([70, 50, 34], [96, 70, 48], hash(x, y, 7))
+ .concat(255);
+ const t = (v - 0.2) / 0.8;
+ const needles = 0.8 + 0.4 * hash(x, y, 9);
+ return mix([22, 52, 30], [58, 104, 52], t).map((c) => c * needles).concat(255);
+ });
+ write('assets/textures/pine.png', strip);
+ meta('assets/textures/pine.png', 'texture');
+}
+
+// ── the tree ───────────────────────────────────────────────────────────────────────────────────────────────────────────
+
+/** A pine: a trunk and five tiers of cone, about ninety units tall, with uv.y running up it (the strip's bark is the first fifth). */
+function tree() {
+ const pos = [], uv = [], nrm = [], idx = [];
+ const vert = (x, y, z, nx, ny, nz, v) => { pos.push(x, y, z); uv.push(0.5, v); nrm.push(nx, ny, nz); return pos.length / 3 - 1; };
+ const SIDES = 10;
+ const H = 90;
+ // The trunk: a tapered column up to two thirds of the height.
+ const trunk = [[0, 4.2], [20, 3.4], [60, 1.8]];
+ const rings = trunk.map(([y, r]) => {
+ const ring = [];
+ for (let k = 0; k <= SIDES; k++) {
+ const a = (k / SIDES) * Math.PI * 2;
+ ring.push(vert(Math.sin(a) * r, y, Math.cos(a) * r, Math.sin(a), 0.1, Math.cos(a), (y / H) * 0.19));
+ }
+ return ring;
+ });
+ for (let i = 0; i < rings.length - 1; i++) for (let k = 0; k < SIDES; k++) {
+ const a = rings[i][k], b = rings[i][k + 1], c = rings[i + 1][k], d = rings[i + 1][k + 1];
+ idx.push(a, c, b, b, c, d);
+ }
+ // The needles: each tier a cone, wide at its skirt and sharp at the top.
+ const tiers = [[16, 30, 26], [30, 44, 21], [44, 58, 16.5], [58, 72, 12], [70, 90, 7.5]];
+ for (const [low, high, radius] of tiers) {
+ const skirt = [];
+ for (let k = 0; k <= SIDES; k++) {
+ const a = (k / SIDES) * Math.PI * 2;
+ const slope = radius / (high - low);
+ const len = Math.hypot(1, slope);
+ skirt.push(vert(Math.sin(a) * radius, low, Math.cos(a) * radius, Math.sin(a) / len, slope / len, Math.cos(a) / len, 0.22 + (low / H) * 0.75));
+ }
+ const tip = [];
+ for (let k = 0; k <= SIDES; k++) {
+ const a = (k / SIDES) * Math.PI * 2;
+ const slope = radius / (high - low);
+ const len = Math.hypot(1, slope);
+ tip.push(vert(0, high, 0, Math.sin(a) / len, slope / len, Math.cos(a) / len, 0.22 + (high / H) * 0.77));
+ }
+ for (let k = 0; k < SIDES; k++) idx.push(skirt[k], tip[k], skirt[k + 1]);
+ // The underside, dark, so a tier has a shade under it.
+ const centre = vert(0, low, 0, 0, -1, 0, 0.22);
+ const under = [];
+ for (let k = 0; k <= SIDES; k++) {
+ const a = (k / SIDES) * Math.PI * 2;
+ under.push(vert(Math.sin(a) * radius, low, Math.cos(a) * radius, 0, -1, 0, 0.22));
+ }
+ for (let k = 0; k < SIDES; k++) idx.push(centre, under[k], under[k + 1]);
+ }
+ const { channels, vertexStride } = packChannels([
+ { semantic: MeshChannel.Position, components: 3, type: MeshChannelType.Float32 },
+ { semantic: MeshChannel.TexCoord0, components: 2, type: MeshChannelType.Float32 },
+ { semantic: MeshChannel.Color, components: 4, type: MeshChannelType.UNorm8 },
+ { semantic: MeshChannel.Normal, components: 3, type: MeshChannelType.Float32 },
+ ]);
+ const count = pos.length / 3;
+ const vertices = new Uint8Array(count * vertexStride);
+ const view = new DataView(vertices.buffer);
+ const min = [Infinity, Infinity, Infinity], max = [-Infinity, -Infinity, -Infinity];
+ for (let i = 0; i < count; i++) {
+ const at = i * vertexStride;
+ for (let k = 0; k < 3; k++) {
+ view.setFloat32(at + channels[0].offset + k * 4, pos[i * 3 + k], true);
+ view.setFloat32(at + channels[3].offset + k * 4, nrm[i * 3 + k], true);
+ min[k] = Math.min(min[k], pos[i * 3 + k]);
+ max[k] = Math.max(max[k], pos[i * 3 + k]);
+ }
+ view.setFloat32(at + channels[1].offset, uv[i * 2], true);
+ view.setFloat32(at + channels[1].offset + 4, uv[i * 2 + 1], true);
+ view.setUint32(at + channels[2].offset, 0xffffffff, true);
+ }
+ const bytes = encodeMesh({ channels, vertexStride, vertexCount: count, vertices, indices: new Uint32Array(idx), aabbMin: min, aabbMax: max });
+ write('assets/models/pine.esmesh', Buffer.from(bytes));
+ meta('assets/models/pine.esmesh', 'mesh');
+}
+
+// ── materials ──────────────────────────────────────────────────────────────────────────────────────────────────────────
+
+function material(name, shader, properties, extra = {}) {
+ write(`assets/materials/${name}.esmaterial`, `${JSON.stringify({ version: '1.0', type: 'material', shader, blendMode: 0, depthTest: true, depthWrite: true, cull: 0, properties, ...extra }, null, 2)}\n`);
+ meta(`assets/materials/${name}.esmaterial`, 'material');
+}
+
+function materials() {
+ material('terrain', 'builtin:terrain', {
+ u_layer0: 'assets/textures/grass.png', u_layer1: 'assets/textures/dirt.png', u_layer2: 'assets/textures/snow.png', u_layer3: 'assets/textures/rock.png',
+ u_tint0: { r: 1, g: 1, b: 1, a: 1 }, u_tint1: { r: 1, g: 1, b: 1, a: 1 }, u_tint2: { r: 1, g: 1, b: 1, a: 1 }, u_tint3: { r: 1, g: 1, b: 1, a: 1 },
+ u_tile0: 60, u_tile1: 70, u_tile2: 90, u_tile3: 120, u_macroVariation: 0.5, u_sharpness: 2.2, u_roughness: 0.93,
+ });
+ material('water', 'builtin:water', {
+ u_waveLength: 220, u_waveHeight: 5, u_waveSpeed: 0.8, u_waveDirection: 25, u_rippleLength: 26, u_rippleStrength: 0.34,
+ u_density: 0.009, u_foamWidth: 34, u_foamCrest: 0.35, u_distortionRange: 180, u_fallbackDepth: 120, u_roughness: 0.03,
+ u_shallowColor: { r: 0.14, g: 0.46, b: 0.46, a: 1 }, u_deepColor: { r: 0.012, g: 0.07, b: 0.13, a: 1 },
+ });
+ material('grass', 'builtin:foliage', {
+ u_baseColor: { r: 0.1, g: 0.22, b: 0.05, a: 1 }, u_tipColor: { r: 0.5, g: 0.66, b: 0.2, a: 1 },
+ u_windStrength: 3, u_windSpeed: 1.3, u_windDirection: 30, u_gustScale: 0.012, u_flutter: 0.35, u_translucency: 0.5,
+ });
+ material('pine', 'builtin:foliage', {
+ u_albedo: 'assets/textures/pine.png', u_useTexture: 1, u_baseColor: { r: 1, g: 1, b: 1, a: 1 }, u_tipColor: { r: 1, g: 1, b: 1, a: 1 },
+ u_windStrength: 0.9, u_windSpeed: 0.9, u_windDirection: 30, u_gustScale: 0.006, u_flutter: 0.1, u_translucency: 0.15, u_roughness: 0.9,
+ });
+}
+
+// ── the scene ──────────────────────────────────────────────────────────────────────────────────────────────────────────
+
+function scene() {
+ const waterY = WORLD.water * WORLD.height;
+ const groundAt = (x, z) => landHeight(x / WORLD.size + 0.5, z / WORLD.size + 0.5) * WORLD.height;
+
+ // The camera stands on the lake's south shore and looks north across the water to the mountains.
+ const eyeZ = (WORLD.lake.v - 0.5) * WORLD.size + 0.33 * WORLD.size;
+ const eye = { x: -170, z: eyeZ, y: groundAt(-170, eyeZ) };
+ console.log(`wilds: water at ${waterY.toFixed(0)}, camera on the shore at (${eye.x}, ${eye.y.toFixed(0)}, ${eye.z.toFixed(0)})`);
+ const yaw = 0;
+ const pitch = Number(process.env.WILDS_PITCH ?? -0.04);
+ const qx = { w: Math.cos(pitch / 2), x: Math.sin(pitch / 2) };
+ const aim = { x: qx.x, y: 0, z: 0, w: qx.w };
+
+ const entity = (id, name, components) => ({ id, name, parent: null, children: [], visible: true, components });
+ const white = { r: 1, g: 1, b: 1, a: 1 };
+ const post = [
+ { type: 'skyAtmosphere', enabled: true, uniforms: { u_intensity: 1.05, u_haze: 1.1, u_sunBrightness: 40, u_clouds: 0.5, u_cloudShadow: 0.7, u_unitsPerKm: 1000, u_windSpeed: 0.03 } },
+ { type: 'gtao', enabled: true, uniforms: { u_radius: 60, u_intensity: 1 } },
+ { type: 'ssr', enabled: false, uniforms: { u_intensity: 0.7, u_maxDistance: 900, u_thickness: 10 } },
+ { type: 'heightFog', enabled: true, colors: { u_fogColor: { r: 0.62, g: 0.72, b: 0.84, a: 1 }, u_sunColor: { r: 1, g: 0.86, b: 0.62, a: 1 } },
+ uniforms: { u_density: 0.00012, u_heightFalloff: 0.0014, u_baseHeight: waterY, u_inscatter: 0.6, u_skyFog: 0.5, u_volumetric: 0.5, u_volumeRange: 4000 } },
+ { type: 'lightShafts', enabled: true, uniforms: { u_intensity: 0.35 } },
+ { type: 'taa', enabled: true, uniforms: { u_blend: 0.1 } },
+ { type: 'autoExposure', enabled: true, uniforms: { u_bias: -0.1, u_minEV: -2, u_maxEV: 2 } },
+ { type: 'colorGrade', enabled: true, uniforms: { u_contrast: 1.08, u_saturation: 1.12 } },
+ { type: 'bloom', enabled: true, uniforms: { u_threshold: 0.9, u_intensity: 0.4, u_radius: 1.1 } },
+ { type: 'fxaa', enabled: true, uniforms: { u_intensity: 1 } },
+ ];
+ const entities = [
+ entity(0, 'Camera', [
+ { type: 'Transform', data: { ...(process.env.WILDS_TOP ? { position: { x: 0, y: 4200, z: 0 }, rotation: { x: -0.7071, y: 0, z: 0, w: 0.7071 } } : { position: { x: eye.x, y: eye.y + 150, z: eye.z }, rotation: aim }) } },
+ { type: 'Camera', data: { projectionType: 0, fov: 52, nearPlane: 2, farPlane: 20000, isActive: true, priority: 0 } },
+ { type: 'PostProcessVolume', data: { isGlobal: true, priority: 0, weight: 1, effects: post } },
+ ]),
+ entity(1, 'Clock', [
+ { type: 'Transform', data: {} },
+ { type: 'TimeOfDay', data: { hour: 17, daySeconds: 0, latitude: 45, declination: 15, north: 0, drive: 31 } },
+ ]),
+ entity(2, 'Sun', [
+ { type: 'Transform', data: {} },
+ { type: 'Light', data: { type: 1, color: white, intensity: 3, enabled: true, meshShadows: true, shadowExtent: 3000, shadowStrength: 1, sourceAngle: 0.5 } },
+ ]),
+ entity(3, 'Sky', [
+ { type: 'Transform', data: {} },
+ { type: 'Light', data: { type: 2, color: { r: 0.8, g: 0.88, b: 1, a: 1 }, intensity: 0.55, enabled: true } },
+ ]),
+ entity(4, 'Terrain', [
+ { type: 'Transform', data: {} },
+ { type: 'Terrain', data: {
+ sizeX: WORLD.size, sizeZ: WORLD.size, height: WORLD.height, chunks: 16, chunkCells: 32, lodLevels: 4, detail: 1.4,
+ heightmap: 'assets/textures/height.png', rockSlope: 0.34, dirtHeight: 0.5, snowHeight: 0.84, material: 'assets/materials/terrain.esmaterial' } },
+ ]),
+ entity(5, 'Lake', [
+ { type: 'Transform', data: { position: { x: 0, y: waterY, z: 0 }, scale: { x: WORLD.size / 100, y: 1, z: WORLD.size / 100 } } },
+ { type: 'MeshRenderer', data: { mesh: 'builtin:plane', lit: true, opaque: false, cullBackfaces: false, material: 'assets/materials/water.esmaterial', color: white } },
+ ]),
+ entity(6, 'Meadow', [
+ { type: 'Transform', data: { position: { x: eye.x, y: 0, z: eye.z - 260 } } },
+ { type: 'Foliage', data: {
+ material: 'assets/materials/grass.esmaterial', sizeX: 420, sizeZ: 420, cellSize: 30, count: 1400, seed: 3, minScale: 0.7, maxScale: 1.3, minUp: 0.8,
+ heightMin: waterY + 6, heightMax: WORLD.height * 0.7, bladeHeight: 46, bladeWidth: 4.2, lodDistance: 160, drawDistance: 420 } },
+ ]),
+ entity(7, 'Pines', [
+ { type: 'Transform', data: { position: { x: 0, y: 0, z: 0 } } },
+ { type: 'Foliage', data: {
+ mesh: 'assets/models/pine.esmesh', material: 'assets/materials/pine.esmaterial', sizeX: WORLD.size * 0.8, sizeZ: WORLD.size * 0.8, cellSize: 160, count: 16, seed: 8,
+ minScale: 0.7, maxScale: 1.6, minUp: 0.8, heightMin: waterY + 42, heightMax: WORLD.height * 0.66, lodDistance: 650, drawDistance: 3600,
+ cardU0: 0.2, cardV0: 0.22, cardU1: 0.8, cardV1: 0.95, cardTent: 1 } },
+ ]),
+ ];
+ // For looking at one thing at a time: WILDS_DROP=Lake,Pines leaves those out.
+ const drop = (process.env.WILDS_DROP ?? '').split(',');
+ const kept = entities.filter((e) => !drop.includes(e.name));
+ if (drop.includes('Post')) kept[0].components = kept[0].components.filter((c) => c.type !== 'PostProcessVolume');
+ write('assets/scenes/main.esscene', `${JSON.stringify({ version: 4, name: 'Wilds', entities: kept }, null, 1)}\n`);
+ meta('assets/scenes/main.esscene', 'scene');
+}
+
+heightmap();
+textures();
+tree();
+materials();
+scene();
diff --git a/examples/wilds/tsconfig.json b/examples/wilds/tsconfig.json
new file mode 100644
index 000000000..105dd19fa
--- /dev/null
+++ b/examples/wilds/tsconfig.json
@@ -0,0 +1,21 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "module": "ESNext",
+ "moduleResolution": "bundler",
+ "strict": true,
+ "esModuleInterop": true,
+ "skipLibCheck": true,
+ "forceConsistentCasingInFileNames": true,
+ "declaration": false,
+ "outDir": "./dist",
+ "rootDir": ".",
+ "paths": {
+ "esengine": ["./.esengine/sdk/index.d.ts"],
+ "estella-plugin-*": ["./.esengine/packages/*"],
+ "esengine/wasm": ["./.esengine/sdk/wasm.d.ts"]
+ }
+ },
+ "include": ["src/**/*"],
+ "exclude": ["node_modules"]
+}