@woosh/meep-engine 2.33.74 → 2.34.1
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/core/collection/Set.js +0 -61
- package/core/collection/array/arrayIndexByEquality.js +20 -0
- package/core/collection/array/arraySetDiff.js +42 -0
- package/core/collection/array/arraySetSortingDiff.js +67 -0
- package/core/collection/array/arraySetSortingDiff.spec.js +74 -0
- package/core/collection/array/array_filter_by_multiple.js +36 -0
- package/core/collection/array/weightedRandomFromArray.js +9 -5
- package/core/collection/list/FilteredListProjection.js +1 -1
- package/core/collection/list/List.js +2 -1
- package/core/geom/3d/topology/compareEdges.js +16 -0
- package/core/geom/3d/topology/compareFaces.js +9 -0
- package/core/geom/3d/topology/compareVertices.js +9 -0
- package/core/geom/3d/topology/computeTopoMeshVertexDuplicates.js +25 -6
- package/core/geom/3d/topology/expandConnectivityByLocality.js +35 -19
- package/core/geom/Vector2.js +7 -2
- package/core/geom/Vector3.js +2 -2
- package/core/geom/v3_angle_between.js +3 -1
- package/editor/view/ecs/components/items/ItemContainerController.stories.js +1 -1
- package/engine/asset/loaders/image/ImageDecoderWorker.js +3 -2
- package/engine/asset/loaders/image/ImageRGBADataAsset.js +2 -6
- package/engine/asset/loaders/image/ImageRGBADataLoader.js +18 -2
- package/engine/asset/loaders/image/codec/NativeImageDecoder.js +2 -1
- package/engine/asset/loaders/image/png/PNG.js +3 -2
- package/engine/asset/loaders/image/png/PNGReader.js +1 -0
- package/engine/ecs/EntityComponentDataset.js +1 -1
- package/engine/ecs/terrain/ecs/splat/SplatMapping.js +39 -26
- package/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +3 -4
- package/engine/graphics/ecs/highlight/system/MeshHighlightSystem.d.ts +3 -2
- package/engine/graphics/ecs/highlight/system/RenderableHighlightSystem.d.ts +3 -1
- package/engine/graphics/ecs/highlight/system/ShadedGeometryHighlightSystem.d.ts +8 -0
- package/engine/graphics/ecs/highlight/system/ShadedGeometryHighlightSystem.js +180 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +74 -16
- package/engine/graphics/ecs/mesh-v2/ShadedGeometryFlags.js +7 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +9 -0
- package/engine/graphics/ecs/mesh-v2/prototypeShadedGeometry.js +4 -2
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +41 -1
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +10 -1
- package/engine/graphics/particles/particular/engine/parameter/ParticleParameter.js +7 -2
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +3 -2
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +7 -3
- package/engine/graphics/texture/sampler/Sampler2D.js +2 -0
- package/engine/graphics/texture/sampler/downsampleSampler2D.js +3 -1
- package/engine/graphics/texture/sampler/genericResampleSampler2D.js +67 -0
- package/engine/graphics/texture/sampler/scaleSampler2D.js +29 -35
- package/engine/graphics/texture/sampler/upsampleSampler2D.js +47 -0
- package/generation/filtering/numeric/CellFilterReadGridLayer.js +2 -2
- package/generation/filtering/numeric/math/CellFilterSaturate.js +24 -0
- package/package.json +1 -1
- package/samples/terrain/from_image.js +289 -0
- package/samples/terrain/from_image_2.js +219 -0
- package/view/elements/radial/RadialMenu.js +1 -1
- package/generation/theme/TerrainThemeApplicator.js +0 -6
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { EngineConfiguration } from "../../engine/EngineConfiguration.js";
|
|
2
|
+
import { EngineHarness } from "../../engine/EngineHarness.js";
|
|
3
|
+
import { GameAssetType } from "../../engine/asset/GameAssetType.js";
|
|
4
|
+
import { TextureAssetLoader } from "../../engine/asset/loaders/texture/TextureAssetLoader.js";
|
|
5
|
+
import Vector3 from "../../core/geom/Vector3.js";
|
|
6
|
+
import EntityBuilder from "../../engine/ecs/EntityBuilder.js";
|
|
7
|
+
import Terrain from "../../engine/ecs/terrain/ecs/Terrain.js";
|
|
8
|
+
import { ImageRGBADataLoader } from "../../engine/asset/loaders/image/ImageRGBADataLoader.js";
|
|
9
|
+
import TerrainSystem from "../../engine/ecs/terrain/ecs/TerrainSystem.js";
|
|
10
|
+
import WaterSystem from "../../engine/graphics/ecs/water/WaterSystem.js";
|
|
11
|
+
import Water from "../../engine/graphics/ecs/water/Water.js";
|
|
12
|
+
import { AmbientOcclusionPostProcessEffect } from "../../engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js";
|
|
13
|
+
import { TerrainLayer } from "../../engine/ecs/terrain/ecs/layers/TerrainLayer.js";
|
|
14
|
+
import Mesh from "../../engine/graphics/ecs/mesh/Mesh.js";
|
|
15
|
+
import { Transform } from "../../engine/ecs/transform/Transform.js";
|
|
16
|
+
import { MeshSystem } from "../../engine/graphics/ecs/mesh/MeshSystem.js";
|
|
17
|
+
import { enableEditor } from "../../editor/enableEditor.js";
|
|
18
|
+
|
|
19
|
+
const HEIGHT_RANGE = 64;
|
|
20
|
+
|
|
21
|
+
const eh = new EngineHarness();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param {Engine} engine
|
|
26
|
+
* @return {EngineConfiguration}
|
|
27
|
+
*/
|
|
28
|
+
function makeConfig(engine) {
|
|
29
|
+
const r = new EngineConfiguration();
|
|
30
|
+
|
|
31
|
+
// configure engine here, add systems, loaders etc.
|
|
32
|
+
r.addLoader(GameAssetType.Texture, new TextureAssetLoader());
|
|
33
|
+
r.addLoader(GameAssetType.Image, new ImageRGBADataLoader());
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
r.addSystem(new TerrainSystem(engine.graphics, engine.assetManager));
|
|
37
|
+
r.addSystem(new WaterSystem(engine.graphics));
|
|
38
|
+
r.addSystem(new MeshSystem(engine));
|
|
39
|
+
|
|
40
|
+
r.addPlugin(AmbientOcclusionPostProcessEffect);
|
|
41
|
+
|
|
42
|
+
return r;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param {string} path
|
|
48
|
+
* @param {AssetManager} am
|
|
49
|
+
*/
|
|
50
|
+
async function load_sampler(path, am) {
|
|
51
|
+
|
|
52
|
+
const asset = await am.promise(path, 'image');
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @type {Sampler2D}
|
|
57
|
+
*/
|
|
58
|
+
const sampler = asset.create();
|
|
59
|
+
|
|
60
|
+
return sampler;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param {string} path
|
|
66
|
+
* @param {Engine} engine
|
|
67
|
+
* @param {Transform} transform
|
|
68
|
+
*/
|
|
69
|
+
async function load_gltf(path, engine, transform) {
|
|
70
|
+
const em = engine.entityManager;
|
|
71
|
+
|
|
72
|
+
const ecd = em.dataset;
|
|
73
|
+
|
|
74
|
+
new EntityBuilder()
|
|
75
|
+
.add(Mesh.fromJSON({
|
|
76
|
+
url: path
|
|
77
|
+
}))
|
|
78
|
+
.add(transform)
|
|
79
|
+
.build(ecd);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @param {Engine} engine
|
|
85
|
+
*/
|
|
86
|
+
async function main(engine) {
|
|
87
|
+
const TERRAIN_SIZE_X = 1024;
|
|
88
|
+
const TERRAIN_SIZE_Y = 512;
|
|
89
|
+
|
|
90
|
+
await EngineHarness.buildBasics({
|
|
91
|
+
engine,
|
|
92
|
+
enableWater: false,
|
|
93
|
+
enableTerrain: false,
|
|
94
|
+
focus: new Vector3(250, 40, 128),
|
|
95
|
+
yaw: -Math.PI,
|
|
96
|
+
pitch: 0.91,
|
|
97
|
+
distance: 100
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @type {EntityComponentDataset}
|
|
103
|
+
*/
|
|
104
|
+
const ecd = engine.entityManager.dataset;
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
const terrain = new Terrain();
|
|
108
|
+
terrain.size.set(TERRAIN_SIZE_X / 4, TERRAIN_SIZE_Y / 4);
|
|
109
|
+
terrain.resolution = 4;
|
|
110
|
+
terrain.gridScale = 2;
|
|
111
|
+
terrain.splat.resize(TERRAIN_SIZE_X, TERRAIN_SIZE_Y, 3);
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
// load height map
|
|
115
|
+
const am = engine.assetManager;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
*
|
|
119
|
+
* @type {Sampler2D}
|
|
120
|
+
*/
|
|
121
|
+
const sampler = await load_sampler('moicon/23_Nov_21_Skogplanter/01/splat_height_2.png', am);
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
async function load_splat_layer(path, index) {
|
|
125
|
+
|
|
126
|
+
const sampler = await load_sampler(path, am);
|
|
127
|
+
|
|
128
|
+
terrain.splat.writeLayerFromSampler(sampler, index, 0);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
await load_splat_layer("moicon/23_Nov_21_Skogplanter/01/splat_green.png", 0);
|
|
132
|
+
await load_splat_layer("moicon/23_Nov_21_Skogplanter/01/splat_dirt.png", 1);
|
|
133
|
+
await load_splat_layer("moicon/23_Nov_21_Skogplanter/01/splat_stone.png", 2);
|
|
134
|
+
|
|
135
|
+
terrain.samplerHeight.resize(sampler.width, sampler.height);
|
|
136
|
+
const source_height_data = sampler.data;
|
|
137
|
+
const sampler_pixel_count = source_height_data.length;
|
|
138
|
+
const terrain_height_data = terrain.samplerHeight.data;
|
|
139
|
+
|
|
140
|
+
let divisor;
|
|
141
|
+
if (source_height_data instanceof Uint8Array) {
|
|
142
|
+
divisor = 255;
|
|
143
|
+
} else if (source_height_data instanceof Uint16Array) {
|
|
144
|
+
divisor = 65536 - 1;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
for (let i = 0; i < sampler_pixel_count; i++) {
|
|
148
|
+
const source_v = source_height_data[i];
|
|
149
|
+
|
|
150
|
+
const b0 = source_v & 0xFF;
|
|
151
|
+
const b1 = (source_v >> 8) & 0xFF;
|
|
152
|
+
|
|
153
|
+
let rotated_v;
|
|
154
|
+
rotated_v = b1 | (b0 << 8);
|
|
155
|
+
|
|
156
|
+
terrain_height_data[i] = (rotated_v / divisor) * HEIGHT_RANGE
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
terrain.layers.resolution.set(1024, 1024);
|
|
160
|
+
|
|
161
|
+
terrain.layers.addLayer(TerrainLayer.from(
|
|
162
|
+
"data/textures/materials/terrain_township_set/Grass_2.png",
|
|
163
|
+
20,
|
|
164
|
+
20
|
|
165
|
+
));
|
|
166
|
+
terrain.layers.addLayer(TerrainLayer.from(
|
|
167
|
+
"data/textures/materials/terrain_township_set/1024/Ground_1_dark.png",
|
|
168
|
+
20,
|
|
169
|
+
20
|
|
170
|
+
));
|
|
171
|
+
terrain.layers.addLayer(TerrainLayer.from(
|
|
172
|
+
"data/textures/materials/Sci-Fi Planet/Sand_01.png",
|
|
173
|
+
20,
|
|
174
|
+
20
|
|
175
|
+
));
|
|
176
|
+
|
|
177
|
+
terrain.build(am);
|
|
178
|
+
|
|
179
|
+
const water = new Water();
|
|
180
|
+
|
|
181
|
+
water.level.set(5);
|
|
182
|
+
water.shoreDepthTransition.set(0.1, 0.3);
|
|
183
|
+
water.scattering.set(3);
|
|
184
|
+
|
|
185
|
+
new EntityBuilder()
|
|
186
|
+
.add(terrain)
|
|
187
|
+
// .add(water)
|
|
188
|
+
.build(ecd);
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
await terrain.buildLightMap(1);
|
|
192
|
+
|
|
193
|
+
const transform = Transform.fromJSON({
|
|
194
|
+
position: new Vector3(256, 45, 128),
|
|
195
|
+
scale: new Vector3(0.54, 0.54, 0.54)
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
load_gltf("moicon/23_Nov_21_Skogplanter/02/model.gltf", engine, transform);
|
|
199
|
+
// load_gltf("moicon/23_Nov_21_Skogplanter/03/model.gltf", engine, transform);
|
|
200
|
+
// load_gltf("moicon/23_Nov_21_Skogplanter/04/model.gltf", engine, transform);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
*
|
|
205
|
+
* @param {EngineHarness} harness
|
|
206
|
+
*/
|
|
207
|
+
async function init(harness) {
|
|
208
|
+
const engine = eh.engine;
|
|
209
|
+
|
|
210
|
+
await makeConfig(engine).apply(engine);
|
|
211
|
+
|
|
212
|
+
enableEditor(engine);
|
|
213
|
+
|
|
214
|
+
await eh.initialize();
|
|
215
|
+
|
|
216
|
+
main(engine);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
init(eh);
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
import List from "../../../core/collection/list/List.js";
|
|
7
|
-
import { arraySetDiff } from "../../../core/collection/Set.js";
|
|
8
7
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
9
8
|
import SVG from "../../SVG.js";
|
|
10
9
|
|
|
@@ -12,6 +11,7 @@ import View from "../../View.js";
|
|
|
12
11
|
import EmptyView from "../EmptyView.js";
|
|
13
12
|
import { makeDonut } from "./makeDonut.js";
|
|
14
13
|
import RadialMenuElement from "./RadialMenuElement.js";
|
|
14
|
+
import { arraySetDiff } from "../../../core/collection/array/arraySetDiff.js";
|
|
15
15
|
|
|
16
16
|
const PI2 = Math.PI * 2;
|
|
17
17
|
|