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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(examples): Terrain & Water draws its trees as models out to 380 metres, and their cards are lit as crowns
yhhac014766ffe2
diff --git a/examples/terrain-water/assets/worlds/plants.esworld b/examples/terrain-water/assets/worlds/plants.esworldindex 8d4d1d3ed..2fd926744 100644--- a/examples/terrain-water/assets/worlds/plants.esworld+++ b/examples/terrain-water/assets/worlds/plants.esworld@@ -56,7 +56,7 @@}],"lodDistance": 6000,- "drawDistance": 16000,+ "drawDistance": 38000,"far": [{"mesh": "assets/plants/models/tree-oak-dense/far/tree-oak-dense.esmesh",@@ -69,7 +69,8 @@1,1],- "opaque": true+ "opaque": true,+ "soft": 0.85}],"farDistance": 200000,@@ -123,7 +124,7 @@}],"lodDistance": 6000,- "drawDistance": 16000,+ "drawDistance": 38000,"far": [{"mesh": "assets/plants/models/tree-beech-dense/far/tree-beech-dense.esmesh",@@ -136,7 +137,8 @@1,1],- "opaque": true+ "opaque": true,+ "soft": 0.85}],"farDistance": 200000,@@ -190,7 +192,7 @@}],"lodDistance": 6000,- "drawDistance": 16000,+ "drawDistance": 38000,"far": [{"mesh": "assets/plants/models/tree-birch/far/tree-birch.esmesh",@@ -203,7 +205,8 @@1,1],- "opaque": true+ "opaque": true,+ "soft": 0.85}],"farDistance": 200000,@@ -257,7 +260,7 @@}],"lodDistance": 6000,- "drawDistance": 16000,+ "drawDistance": 38000,"far": [{"mesh": "assets/plants/models/tree-willow/far/tree-willow.esmesh",@@ -270,7 +273,8 @@1,1],- "opaque": true+ "opaque": true,+ "soft": 0.85}],"farDistance": 200000,@@ -324,7 +328,7 @@}],"lodDistance": 6000,- "drawDistance": 16000,+ "drawDistance": 38000,"far": [{"mesh": "assets/plants/models/tree-pine-ridge/far/tree-pine-ridge.esmesh",@@ -337,7 +341,8 @@1,1],- "opaque": true+ "opaque": true,+ "soft": 0.85}],"farDistance": 200000,@@ -391,7 +396,7 @@}],"lodDistance": 6000,- "drawDistance": 16000,+ "drawDistance": 38000,"far": [{"mesh": "assets/plants/models/tree-pine-lakeside/far/tree-pine-lakeside.esmesh",@@ -404,7 +409,8 @@1,1],- "opaque": true+ "opaque": true,+ "soft": 0.85}],"farDistance": 200000,diff --git a/examples/terrain-water/tools/plants.mjs b/examples/terrain-water/tools/plants.mjsindex 7ba456337..6127806cc 100644--- a/examples/terrain-water/tools/plants.mjs+++ b/examples/terrain-water/tools/plants.mjs@@ -27,6 +27,9 @@ function partsOf(project, file) {.flatMap((e) => e.components.filter((c) => c.type === 'MeshRenderer').map((c) => c.data));}+/** How far a crown's card has its normals turned to face up: it is lit as a rounded crown, and not as the two flat boards it is. */+const SOFT_CARDS = 0.85;+const asPart = (d, lod1Mesh = '') => ({mesh: d.mesh, lod1Mesh, material: d.material ?? '', texture: d.texture ?? '',tint: [d.color?.r ?? 1, d.color?.g ?? 1, d.color?.b ?? 1, d.color?.a ?? 1], opaque: d.opaque !== false,@@ -50,12 +53,12 @@ const TINTS = {/** The kinds of plant: the prefab each is made of, how far it is drawn (metres: the cheaper mesh from `lod`, nothing past `draw`, the far version out to `far`). */const KINDS = {- oak: { prefab: 'tree-oak-dense', lod: 60, draw: 160, far: 2000, tints: TINTS.oak },- beech: { prefab: 'tree-beech-dense', lod: 60, draw: 160, far: 2000, tints: TINTS.beech },- birch: { prefab: 'tree-birch', lod: 60, draw: 160, far: 2000, tints: TINTS.birch },- willow: { prefab: 'tree-willow', lod: 60, draw: 160, far: 2000, tints: TINTS.willow },- 'pine-ridge': { prefab: 'tree-pine-ridge', lod: 60, draw: 160, far: 2000, tints: TINTS.conifer },- 'pine-lakeside': { prefab: 'tree-pine-lakeside', lod: 60, draw: 160, far: 2000, tints: TINTS.conifer },+ oak: { prefab: 'tree-oak-dense', lod: 60, draw: 380, far: 2000, tints: TINTS.oak },+ beech: { prefab: 'tree-beech-dense', lod: 60, draw: 380, far: 2000, tints: TINTS.beech },+ birch: { prefab: 'tree-birch', lod: 60, draw: 380, far: 2000, tints: TINTS.birch },+ willow: { prefab: 'tree-willow', lod: 60, draw: 380, far: 2000, tints: TINTS.willow },+ 'pine-ridge': { prefab: 'tree-pine-ridge', lod: 60, draw: 380, far: 2000, tints: TINTS.conifer },+ 'pine-lakeside': { prefab: 'tree-pine-lakeside', lod: 60, draw: 380, far: 2000, tints: TINTS.conifer },hazel: { prefab: 'shrub-hazel', lod: 40, draw: 120, tints: TINTS.shrub },coppice: { prefab: 'shrub-woodland-coppice', lod: 40, draw: 120, tints: TINTS.shrub },lowleaf: { prefab: 'woodland-lowleaf', lod: 30, draw: 100, tints: TINTS.fern },@@ -99,7 +102,7 @@ function plants(project) {const cheaper = near.length === parts.length;const cover = COVER[name];// Ground cover: the cheaper mesh stands for it far off, thinned; trees: the art's cards.- const far = cover ? (cheaper ? near : parts).map((d) => asPart(d)) : cards.map((d) => asPart(d));+ const far = cover ? (cheaper ? near : parts).map((d) => asPart(d)) : cards.map((d) => ({ ...asPart(d), soft: SOFT_CARDS }));out[name] = {parts: parts.map((d, j) => asPart(d, cheaper ? near[j].mesh : '')),lodDistance: cheaper ? k.lod * M : 0, drawDistance: k.draw * M,