@woosh/meep-engine 2.75.4 → 2.75.5
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/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +35 -21
- package/package.json +2 -2
- package/src/core/collection/array/array_compute_min_max.js +20 -0
- package/src/core/collection/map/HashMap.js +16 -14
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +23 -13
- package/src/core/geom/2d/intersect_ray_2d.js +7 -14
- package/src/core/geom/3d/aabb/AABB3.js +13 -0
- package/src/core/geom/3d/topology/samples/sampleFloodFill.js +21 -21
- package/src/core/geom/3d/topology/tm_face_area.js +1 -1
- package/src/core/geom/3d/triangle/computeTriangleSurfaceArea.js +39 -0
- package/src/core/process/task/util/countTask.js +1 -2
- package/src/engine/EngineBootstrapper.js +15 -7
- package/src/engine/animation/curve/AnimationCurve.js +50 -31
- package/src/engine/animation/curve/AnimationCurve.spec.js +9 -1
- package/src/engine/animation/curve/compression/prototypeCurveCompression.js +20 -11
- package/src/engine/animation/curve/compute_curve_aabb.js +26 -0
- package/src/engine/animation/curve/draw/build_curve_editor.js +82 -42
- package/src/engine/animation/curve/draw/build_plot_entity_from_array.js +5 -5
- package/src/engine/animation/curve/preset/CURVE_EASE_IN.js +8 -0
- package/src/engine/animation/curve/preset/CURVE_EASE_IN_OUT.js +7 -0
- package/src/engine/animation/curve/preset/CURVE_EASE_OUT.js +7 -0
- package/src/engine/asset/loaders/image/png/PNGReader.js +119 -1
- package/src/engine/graphics/GraphicsEngine.d.ts +6 -3
- package/src/engine/graphics/canvas/canvas2d_draw_grid.js +42 -0
- package/src/engine/{animation/curve/draw/draw_label.js → graphics/canvas/canvas2d_draw_label.js} +6 -1
- package/src/engine/graphics/canvas/canvas2d_draw_linear_scale.js +64 -0
- package/src/engine/graphics/canvas/canvas2d_draw_path.js +60 -0
- package/src/engine/graphics/canvas/canvas2d_plot_data_line.js +84 -0
- package/src/engine/{animation/curve/draw/plot_array.js → graphics/canvas/canvas2d_plot_line_array.js} +8 -25
- package/src/engine/graphics/geometry/computeMeshSurfaceArea.js +2 -37
- package/src/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +8 -26
- package/src/engine/graphics/material/manager/MaterialManager.d.ts +6 -0
- package/src/engine/graphics/sh3/LightProbeVolume.js +38 -17
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +26 -35
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +166 -100
- package/src/engine/graphics/texture/makeOnePixelTexture.js +19 -0
- package/src/engine/graphics/texture/sprite/prototypeSpriteCutoutGeometry.js +5 -68
- package/src/engine/input/devices/PointerDevice.js +6 -3
- package/src/engine/makeSimpleTaskProgressView.js +33 -0
- package/src/engine/scene/transitionToScene.js +9 -10
- package/src/view/task/TaskLoadingScreen.js +5 -12
- package/src/view/task/TaskProgressView.js +9 -9
- package/src/engine/animation/curve/draw/draw_grid.js +0 -27
- package/src/engine/animation/curve/draw/plot_data.js +0 -49
- package/src/engine/graphics/geometry/QuadGeometry.js +0 -13
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { EngineHarness } from "../../EngineHarness.js";
|
|
2
|
-
import { seededRandom } from "../../../core/math/random/seededRandom.js";
|
|
3
|
-
import { ShadedGeometrySystem } from "../ecs/mesh-v2/ShadedGeometrySystem.js";
|
|
4
|
-
import { GizmoRenderingPlugin } from "../render/gizmo/GizmoRenderingPlugin.js";
|
|
5
|
-
import { LightProbeVolume } from "./LightProbeVolume.js";
|
|
6
|
-
import Entity from "../../ecs/Entity.js";
|
|
7
|
-
import { ShadedGeometry } from "../ecs/mesh-v2/ShadedGeometry.js";
|
|
8
1
|
import {
|
|
9
2
|
ClampToEdgeWrapping,
|
|
10
3
|
DataTexture,
|
|
@@ -15,23 +8,38 @@ import {
|
|
|
15
8
|
RGBAFormat,
|
|
16
9
|
UnsignedByteType
|
|
17
10
|
} from "three";
|
|
18
|
-
import
|
|
19
|
-
import Vector3 from "../../../core/geom/Vector3.js";
|
|
11
|
+
import '../../../../../../../css/game.scss';
|
|
20
12
|
import { BinaryBuffer } from "../../../core/binary/BinaryBuffer.js";
|
|
21
|
-
import { is_typed_array_equals } from "../../../core/collection/array/typed/is_typed_array_equals.js";
|
|
22
13
|
import { array_copy } from "../../../core/collection/array/array_copy.js";
|
|
14
|
+
import { is_typed_array_equals } from "../../../core/collection/array/typed/is_typed_array_equals.js";
|
|
15
|
+
import { AABB3 } from "../../../core/geom/3d/aabb/AABB3.js";
|
|
16
|
+
import { make_justified_point_grid } from "../../../core/geom/3d/util/make_justified_point_grid.js";
|
|
17
|
+
import Vector2 from "../../../core/geom/Vector2.js";
|
|
18
|
+
import Vector3 from "../../../core/geom/Vector3.js";
|
|
23
19
|
import { randomFloatBetween } from "../../../core/math/random/randomFloatBetween.js";
|
|
20
|
+
import { seededRandom } from "../../../core/math/random/seededRandom.js";
|
|
21
|
+
import { delay } from "../../../core/process/delay.js";
|
|
24
22
|
import { GLTFAssetLoader } from "../../asset/loaders/GLTFAssetLoader.js";
|
|
25
|
-
import
|
|
23
|
+
import Entity from "../../ecs/Entity.js";
|
|
24
|
+
import GUIElement from "../../ecs/gui/GUIElement.js";
|
|
25
|
+
import GUIElementSystem from "../../ecs/gui/GUIElementSystem.js";
|
|
26
|
+
import ViewportPosition from "../../ecs/gui/position/ViewportPosition.js";
|
|
27
|
+
import ViewportPositionSystem from "../../ecs/gui/position/ViewportPositionSystem.js";
|
|
26
28
|
import { TransformAttachmentSystem } from "../../ecs/transform-attachment/TransformAttachmentSystem.js";
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import { make_justified_point_grid } from "../../../core/geom/3d/util/make_justified_point_grid.js";
|
|
31
|
-
import LightSystem from "../ecs/light/LightSystem.js";
|
|
29
|
+
import { Transform } from "../../ecs/transform/Transform.js";
|
|
30
|
+
import { EngineHarness } from "../../EngineHarness.js";
|
|
31
|
+
import { makeSimpleTaskProgressView } from "../../makeSimpleTaskProgressView.js";
|
|
32
32
|
import { Light } from "../ecs/light/Light.js";
|
|
33
|
+
import LightSystem from "../ecs/light/LightSystem.js";
|
|
33
34
|
import { LightType } from "../ecs/light/LightType.js";
|
|
34
|
-
import {
|
|
35
|
+
import { SGMesh } from "../ecs/mesh-v2/aggregate/SGMesh.js";
|
|
36
|
+
import { SGMeshSystem } from "../ecs/mesh-v2/aggregate/SGMeshSystem.js";
|
|
37
|
+
import { ShadedGeometry } from "../ecs/mesh-v2/ShadedGeometry.js";
|
|
38
|
+
import { ShadedGeometryFlags } from "../ecs/mesh-v2/ShadedGeometryFlags.js";
|
|
39
|
+
import { ShadedGeometrySystem } from "../ecs/mesh-v2/ShadedGeometrySystem.js";
|
|
40
|
+
import { three_object_to_entity_composition } from "../ecs/mesh-v2/three_object_to_entity_composition.js";
|
|
41
|
+
import { GizmoRenderingPlugin } from "../render/gizmo/GizmoRenderingPlugin.js";
|
|
42
|
+
import { LightProbeVolume } from "./LightProbeVolume.js";
|
|
35
43
|
|
|
36
44
|
/**
|
|
37
45
|
*
|
|
@@ -174,6 +182,118 @@ function make_test_texture(t = 1) {
|
|
|
174
182
|
return tex;
|
|
175
183
|
}
|
|
176
184
|
|
|
185
|
+
/**
|
|
186
|
+
*
|
|
187
|
+
* @param {Engine} engine
|
|
188
|
+
* @param {EntityComponentDataset} ecd
|
|
189
|
+
* @param {AABB3} bounds
|
|
190
|
+
*/
|
|
191
|
+
async function build_probes(engine, ecd, bounds) {
|
|
192
|
+
|
|
193
|
+
const lpv = new LightProbeVolume();
|
|
194
|
+
|
|
195
|
+
// lpv.add_point(10, 5, 10);
|
|
196
|
+
|
|
197
|
+
const desired_density = 10;
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
// const light_volume_bounds = new AABB3(-10, 0.5, -10, 10, 11, 10);
|
|
201
|
+
const probe_grid_spacing_dense = Math.min(bounds.getExtentsX(), bounds.getExtentsY(), bounds.getExtentsZ()) / desired_density;
|
|
202
|
+
const probe_grid_spacing_sparse = Math.max(bounds.getExtentsX(), bounds.getExtentsY(), bounds.getExtentsZ()) / desired_density;
|
|
203
|
+
|
|
204
|
+
const probe_grid_spacing = (probe_grid_spacing_sparse / probe_grid_spacing_dense) < 2 ? probe_grid_spacing_dense : probe_grid_spacing_sparse * 0.5;
|
|
205
|
+
//
|
|
206
|
+
// const probe_grid_spacing =desired_density/ (mesh_asset.boundingBox.getExtentsX()* mesh_asset.boundingBox.getExtentsY()* mesh_asset.boundingBox.getExtentsZ());
|
|
207
|
+
|
|
208
|
+
const model_bounds = new AABB3(-10, 0.5, -10, 10, 11, 10);
|
|
209
|
+
model_bounds.copy(bounds);
|
|
210
|
+
// model_bounds._translate(composition.transform.position.x, composition.transform.position.y, composition.transform.position.z);
|
|
211
|
+
model_bounds.grow(probe_grid_spacing * 1.1);
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
// sg_hierarchy_compute_bounding_box_via_parent_entity(light_volume_bounds, composition.entity.entity, ecd);
|
|
215
|
+
|
|
216
|
+
// for (let i = 0; i < 100; i++) {
|
|
217
|
+
// lpv.add_point(
|
|
218
|
+
// randomFloatBetween(random, light_volume_bounds.x0, light_volume_bounds.x1),
|
|
219
|
+
// randomFloatBetween(random, light_volume_bounds.y0, light_volume_bounds.y1),
|
|
220
|
+
// randomFloatBetween(random, light_volume_bounds.z0, light_volume_bounds.z1),
|
|
221
|
+
// );
|
|
222
|
+
// }
|
|
223
|
+
|
|
224
|
+
make_justified_point_grid(model_bounds, probe_grid_spacing, (x, y, z) => {
|
|
225
|
+
lpv.add_point(x, y, z);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// lpv.add_point(10, 1, -10);
|
|
229
|
+
|
|
230
|
+
await delay(2000);
|
|
231
|
+
|
|
232
|
+
//
|
|
233
|
+
// console.profile('lpv build');
|
|
234
|
+
//
|
|
235
|
+
const task = lpv.build(engine);
|
|
236
|
+
// console.profileEnd('lpv build');
|
|
237
|
+
|
|
238
|
+
const progress = makeSimpleTaskProgressView({
|
|
239
|
+
task,
|
|
240
|
+
localization: engine.localization,
|
|
241
|
+
size: new Vector2(512, 64)
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const progress_entity = new Entity();
|
|
245
|
+
progress_entity
|
|
246
|
+
.add(GUIElement.fromView(progress))
|
|
247
|
+
.add(ViewportPosition.fromJSON({
|
|
248
|
+
position: new Vector2(0, 1),
|
|
249
|
+
anchor: new Vector2(0, 1),
|
|
250
|
+
offset: new Vector2(16, -16)
|
|
251
|
+
}))
|
|
252
|
+
.build(ecd);
|
|
253
|
+
|
|
254
|
+
task.promise().finally(() => progress_entity.destroy())
|
|
255
|
+
|
|
256
|
+
engine.executor.runGroup(task);
|
|
257
|
+
|
|
258
|
+
// fill probes with random data
|
|
259
|
+
// for (let i = 0; i < lpv.__length * 27; i++) {
|
|
260
|
+
// lpv.__probe_data[i] = random();
|
|
261
|
+
// }
|
|
262
|
+
|
|
263
|
+
// for (let i = 0; i < lpv.__length; i++) {
|
|
264
|
+
//
|
|
265
|
+
// for (let j = 0; j < 9; j++) {
|
|
266
|
+
// lpv.__probe_data[(i * 9 + j) * 3] = max2(0, (lpv.__positions[i * 3] + 10) / 20);
|
|
267
|
+
// lpv.__probe_data[(i * 9 + j) * 3 + 1] = max2(0, (lpv.__positions[i * 3 + 1] - 0.5) / 10.5);
|
|
268
|
+
// lpv.__probe_data[(i * 9 + j) * 3 + 2] = max2(0, (lpv.__positions[i * 3 + 2] + 10) / 20);
|
|
269
|
+
// }
|
|
270
|
+
// }
|
|
271
|
+
|
|
272
|
+
// lpv.white_probe(0, [
|
|
273
|
+
// 0.7953949, 0.4405923, 0.5459412,
|
|
274
|
+
// 0.3981450, 0.3526911, 0.6097158,
|
|
275
|
+
// -0.3424573, -0.1838151, -0.2715583,
|
|
276
|
+
//
|
|
277
|
+
// -0.2944621, -0.0560606, 0.0095193,
|
|
278
|
+
// -0.1123051, -0.0513088, -0.1232869,
|
|
279
|
+
// -0.2645007, -0.2257996, -0.4785847,
|
|
280
|
+
//
|
|
281
|
+
// -0.1569444, -0.0954703, -0.1485053,
|
|
282
|
+
// 0.5646247, 0.2161586, 0.1402643,
|
|
283
|
+
// 0.2137442, -0.0547578, -0.3061700], 0);
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
// lpv.visualize_mesh({ ecd: ecd });
|
|
287
|
+
|
|
288
|
+
task.promise().then(() => {
|
|
289
|
+
|
|
290
|
+
lpv.visualize_probes({ ecd: ecd, size: probe_grid_spacing * 0.08 });
|
|
291
|
+
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
console.log(lpv);
|
|
295
|
+
}
|
|
296
|
+
|
|
177
297
|
/**
|
|
178
298
|
*
|
|
179
299
|
* @param {Engine} engine
|
|
@@ -184,30 +304,41 @@ async function main(engine) {
|
|
|
184
304
|
engine,
|
|
185
305
|
enableWater: false,
|
|
186
306
|
enableTerrain: false,
|
|
187
|
-
enableLights: false,
|
|
188
|
-
|
|
307
|
+
// enableLights: false,
|
|
308
|
+
enableLights: true,
|
|
189
309
|
cameraFarDistance: 200,
|
|
190
310
|
focus: { x: 0, y: 0, z: 0 },
|
|
191
311
|
pitch: 1,
|
|
192
312
|
yaw: -1.54,
|
|
193
313
|
distance: 54,
|
|
194
|
-
shadowmapResolution: 4096
|
|
314
|
+
// shadowmapResolution: 4096
|
|
195
315
|
});
|
|
196
|
-
|
|
316
|
+
|
|
317
|
+
engine.graphics.getRenderer().setClearColor('#1e3441', 1);
|
|
318
|
+
|
|
319
|
+
// load_and_set_cubemap_v0(engine.graphics, 'data/textures/cubemaps/hip_miramar/32/', '.png');
|
|
197
320
|
|
|
198
321
|
const ecd = engine.entityManager.dataset;
|
|
199
322
|
|
|
200
323
|
|
|
201
324
|
// const path = 'data/models/LowPolyTownshipSet/Small_house/Small_house.gltf';
|
|
202
|
-
const path = 'data/models/sibenik/model.gltf';
|
|
325
|
+
// const path = 'data/models/sibenik/2/model.gltf';
|
|
326
|
+
const path = 'data/models/vokselia_spawn/model.gltf';
|
|
203
327
|
// const path = 'data/models/sponza-pbr/gltf/sponza.glb';
|
|
204
328
|
// const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
|
|
205
329
|
// const path = 'data/models/Slaughter Mech/Slaugter Mech.gltf';
|
|
206
330
|
|
|
207
|
-
const mesh_asset = await engine.assetManager.promise(path, 'gltf');
|
|
331
|
+
const mesh_asset = await engine.assetManager.promise(path, 'model/gltf+json');
|
|
208
332
|
const gltf = mesh_asset.gltf;
|
|
209
333
|
|
|
210
334
|
|
|
335
|
+
const mesh_entity = new Entity();
|
|
336
|
+
mesh_entity
|
|
337
|
+
.add(new Transform())
|
|
338
|
+
.add(SGMesh.fromURL(path))
|
|
339
|
+
;
|
|
340
|
+
|
|
341
|
+
|
|
211
342
|
const composition = three_object_to_entity_composition(gltf.scene);
|
|
212
343
|
|
|
213
344
|
composition.traverse(n => {
|
|
@@ -241,7 +372,7 @@ async function main(engine) {
|
|
|
241
372
|
// })
|
|
242
373
|
|
|
243
374
|
composition.transform.scale.setScalar(1);
|
|
244
|
-
composition.transform.position.set(0, -mesh_asset.boundingBox.y0, 0);
|
|
375
|
+
// composition.transform.position.set(0, -mesh_asset.boundingBox.y0, 0);
|
|
245
376
|
|
|
246
377
|
composition.build(ecd);
|
|
247
378
|
|
|
@@ -318,7 +449,7 @@ async function main(engine) {
|
|
|
318
449
|
|
|
319
450
|
const random = seededRandom();
|
|
320
451
|
|
|
321
|
-
for (let i = 0; i <
|
|
452
|
+
for (let i = 0; i < 0; i++) {
|
|
322
453
|
|
|
323
454
|
new Entity()
|
|
324
455
|
.add(Transform.fromJSON({
|
|
@@ -337,84 +468,16 @@ async function main(engine) {
|
|
|
337
468
|
.build(ecd);
|
|
338
469
|
}
|
|
339
470
|
|
|
471
|
+
function build() {
|
|
340
472
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
// lpv.add_point(10, 5, 10);
|
|
344
|
-
|
|
345
|
-
const desired_density = 10;
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
// const light_volume_bounds = new AABB3(-10, 0.5, -10, 10, 11, 10);
|
|
349
|
-
const probe_grid_spacing_dense = Math.min(mesh_asset.boundingBox.getExtentsX(), mesh_asset.boundingBox.getExtentsY(), mesh_asset.boundingBox.getExtentsZ()) / desired_density;
|
|
350
|
-
const probe_grid_spacing_sparse = Math.max(mesh_asset.boundingBox.getExtentsX(), mesh_asset.boundingBox.getExtentsY(), mesh_asset.boundingBox.getExtentsZ()) / desired_density;
|
|
351
|
-
|
|
352
|
-
const probe_grid_spacing = (probe_grid_spacing_sparse / probe_grid_spacing_dense) < 2 ? probe_grid_spacing_dense : probe_grid_spacing_sparse * 0.5;
|
|
353
|
-
//
|
|
354
|
-
// const probe_grid_spacing =desired_density/ (mesh_asset.boundingBox.getExtentsX()* mesh_asset.boundingBox.getExtentsY()* mesh_asset.boundingBox.getExtentsZ());
|
|
355
|
-
|
|
356
|
-
const model_bounds = new AABB3(-10, 0.5, -10, 10, 11, 10);
|
|
357
|
-
model_bounds.copy(mesh_asset.boundingBox);
|
|
358
|
-
model_bounds.grow(probe_grid_spacing * 1.1);
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
// sg_hierarchy_compute_bounding_box_via_parent_entity(light_volume_bounds, composition.entity.entity, ecd);
|
|
362
|
-
|
|
363
|
-
// for (let i = 0; i < 100; i++) {
|
|
364
|
-
// lpv.add_point(
|
|
365
|
-
// randomFloatBetween(random, light_volume_bounds.x0, light_volume_bounds.x1),
|
|
366
|
-
// randomFloatBetween(random, light_volume_bounds.y0, light_volume_bounds.y1),
|
|
367
|
-
// randomFloatBetween(random, light_volume_bounds.z0, light_volume_bounds.z1),
|
|
368
|
-
// );
|
|
369
|
-
// }
|
|
370
|
-
|
|
371
|
-
make_justified_point_grid(model_bounds, probe_grid_spacing, (x, y, z) => {
|
|
372
|
-
lpv.add_point(x, y, z);
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
// lpv.add_point(10, 1, -10);
|
|
376
|
-
|
|
377
|
-
await delay(2000);
|
|
378
|
-
|
|
379
|
-
//
|
|
380
|
-
// console.profile('lpv build');
|
|
381
|
-
//
|
|
382
|
-
lpv.build(engine);
|
|
383
|
-
// console.profileEnd('lpv build');
|
|
384
|
-
|
|
385
|
-
// fill probes with random data
|
|
386
|
-
// for (let i = 0; i < lpv.__length * 27; i++) {
|
|
387
|
-
// lpv.__probe_data[i] = random();
|
|
388
|
-
// }
|
|
473
|
+
build_probes(engine, ecd, mesh_asset.boundingBox);
|
|
474
|
+
}
|
|
389
475
|
|
|
390
|
-
|
|
391
|
-
//
|
|
392
|
-
// for (let j = 0; j < 9; j++) {
|
|
393
|
-
// lpv.__probe_data[(i * 9 + j) * 3] = max2(0, (lpv.__positions[i * 3] + 10) / 20);
|
|
394
|
-
// lpv.__probe_data[(i * 9 + j) * 3 + 1] = max2(0, (lpv.__positions[i * 3 + 1] - 0.5) / 10.5);
|
|
395
|
-
// lpv.__probe_data[(i * 9 + j) * 3 + 2] = max2(0, (lpv.__positions[i * 3 + 2] + 10) / 20);
|
|
396
|
-
// }
|
|
397
|
-
// }
|
|
476
|
+
build();
|
|
398
477
|
|
|
399
|
-
//
|
|
400
|
-
// 0.7953949, 0.4405923, 0.5459412,
|
|
401
|
-
// 0.3981450, 0.3526911, 0.6097158,
|
|
402
|
-
// -0.3424573, -0.1838151, -0.2715583,
|
|
403
|
-
//
|
|
404
|
-
// -0.2944621, -0.0560606, 0.0095193,
|
|
405
|
-
// -0.1123051, -0.0513088, -0.1232869,
|
|
406
|
-
// -0.2645007, -0.2257996, -0.4785847,
|
|
478
|
+
// mesh_entity.addEventListener(SGMeshEvents.AssetLoaded, build);
|
|
407
479
|
//
|
|
408
|
-
//
|
|
409
|
-
// 0.5646247, 0.2161586, 0.1402643,
|
|
410
|
-
// 0.2137442, -0.0547578, -0.3061700], 0);
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
// lpv.visualize_mesh({ ecd: ecd });
|
|
414
|
-
lpv.visualize_probes({ ecd: ecd, size: probe_grid_spacing * 0.08 });
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
console.log(lpv);
|
|
480
|
+
// mesh_entity.build(ecd);
|
|
418
481
|
}
|
|
419
482
|
|
|
420
483
|
new EngineHarness().initialize({
|
|
@@ -424,8 +487,11 @@ new EngineHarness().initialize({
|
|
|
424
487
|
config.addSystem(new LightSystem(engine, {
|
|
425
488
|
shadowResolution: 2048
|
|
426
489
|
}));
|
|
490
|
+
config.addSystem(new SGMeshSystem(engine));
|
|
491
|
+
config.addSystem(new GUIElementSystem(engine.gui.view, engine));
|
|
492
|
+
config.addSystem(new ViewportPositionSystem(engine.gui.view.size));
|
|
427
493
|
|
|
428
|
-
config.addLoader('gltf', new GLTFAssetLoader());
|
|
494
|
+
config.addLoader('model/gltf+json', new GLTFAssetLoader());
|
|
429
495
|
|
|
430
496
|
config.addPlugin(GizmoRenderingPlugin);
|
|
431
497
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DataTexture, UnsignedByteType } from "three";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {ArrayLike<number>|Uint8Array} contents
|
|
6
|
+
* @param {Signal} cleanup_signal can be called to dispose of the texture
|
|
7
|
+
* @returns {DataTexture}
|
|
8
|
+
*/
|
|
9
|
+
export function makeOnePixelTexture(contents, cleanup_signal) {
|
|
10
|
+
const t = new DataTexture(new Uint8Array(contents), 1, 1);
|
|
11
|
+
|
|
12
|
+
t.generateMipmaps = false;
|
|
13
|
+
t.needsUpdate = true;
|
|
14
|
+
t.type = UnsignedByteType;
|
|
15
|
+
|
|
16
|
+
cleanup_signal.addOne(t.dispose, t);
|
|
17
|
+
|
|
18
|
+
return t;
|
|
19
|
+
}
|
|
@@ -11,14 +11,12 @@ import GUIElementSystem from "../../../ecs/gui/GUIElementSystem.js";
|
|
|
11
11
|
import ViewportPosition from "../../../ecs/gui/position/ViewportPosition.js";
|
|
12
12
|
import ViewportPositionSystem from "../../../ecs/gui/position/ViewportPositionSystem.js";
|
|
13
13
|
import { EngineHarness } from "../../../EngineHarness.js";
|
|
14
|
+
import { canvas2d_draw_path } from "../../canvas/canvas2d_draw_path.js";
|
|
14
15
|
import { Sampler2D } from "../sampler/Sampler2D.js";
|
|
15
16
|
import sampler2D2Canvas from "../sampler/Sampler2D2Canvas.js";
|
|
16
17
|
import { make_edge_condition_channel_threshold } from "../sampler/search/make_edge_condition_channel_threshold.js";
|
|
17
18
|
import { sampler2d_find_pixels } from "../sampler/search/sampler2d_find_pixels.js";
|
|
18
19
|
|
|
19
|
-
const edge_condition_alpha0 = make_edge_condition_channel_threshold(3, 0);
|
|
20
|
-
|
|
21
|
-
|
|
22
20
|
function sampler_as_view(sampler) {
|
|
23
21
|
|
|
24
22
|
const vSpriteSource = new CanvasView();
|
|
@@ -33,67 +31,6 @@ function sampler_as_view(sampler) {
|
|
|
33
31
|
return vSpriteSource;
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* @param {number[]} vertices
|
|
39
|
-
* @param {CanvasRenderingContext2D} ctx
|
|
40
|
-
* @param [fillColor]
|
|
41
|
-
* @param [strokeColor]
|
|
42
|
-
* @param [highlight_vertices]
|
|
43
|
-
* @param [vertex_draw_size]
|
|
44
|
-
* @param {number} [offset] in pixels
|
|
45
|
-
*/
|
|
46
|
-
function drawPath({
|
|
47
|
-
vertices,
|
|
48
|
-
ctx,
|
|
49
|
-
fillColor = 'transparent',
|
|
50
|
-
strokeColor = 'red',
|
|
51
|
-
highlight_vertices = true,
|
|
52
|
-
vertex_draw_size = 8,
|
|
53
|
-
offset = [0, 0]
|
|
54
|
-
}) {
|
|
55
|
-
|
|
56
|
-
function draw_point(x, y) {
|
|
57
|
-
ctx.fillStyle = 'rgba(255,255,255,0.8)';
|
|
58
|
-
ctx.strokeStyle = 'black';
|
|
59
|
-
ctx.lineWidth = "1px";
|
|
60
|
-
|
|
61
|
-
const x1 = x - vertex_draw_size / 2 + offset[0];
|
|
62
|
-
const y1 = y - vertex_draw_size / 2 + offset[1];
|
|
63
|
-
|
|
64
|
-
ctx.fillRect(x1, y1, vertex_draw_size, vertex_draw_size);
|
|
65
|
-
|
|
66
|
-
ctx.strokeRect(x1, y1, vertex_draw_size, vertex_draw_size);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (highlight_vertices) {
|
|
70
|
-
for (let i = 0; i < vertices.length / 2; i++) {
|
|
71
|
-
draw_point(vertices[i * 2], vertices[i * 2 + 1]);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
ctx.fillStyle = fillColor;
|
|
76
|
-
ctx.strokeStyle = strokeColor;
|
|
77
|
-
ctx.lineWidth = "1px";
|
|
78
|
-
|
|
79
|
-
ctx.beginPath();
|
|
80
|
-
|
|
81
|
-
ctx.moveTo(vertices[0] + offset[0], vertices[1] + offset[1]);
|
|
82
|
-
// drawPoint(jarvis_vertices[0].x, jarvis_vertices[0].y, jarvis_vertices[0].z, 'red');
|
|
83
|
-
|
|
84
|
-
for (let i = 1; i < vertices.length / 2; i++) {
|
|
85
|
-
|
|
86
|
-
ctx.lineTo(vertices[i * 2] + offset[0], vertices[i * 2 + 1] + offset[1]);
|
|
87
|
-
|
|
88
|
-
// drawPoint(last.x, last.y, last.z, 'red');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
ctx.closePath();
|
|
92
|
-
ctx.stroke();
|
|
93
|
-
ctx.fill();
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
34
|
/**
|
|
98
35
|
*
|
|
99
36
|
* @param {Engine} engine
|
|
@@ -104,10 +41,10 @@ async function main(engine) {
|
|
|
104
41
|
// const path = "data/textures/particle/UETools/Bones_01.png";
|
|
105
42
|
// const path = "data/textures/particle/UETools/x64/Bones_01.png";
|
|
106
43
|
// const path = "data/textures/particle/KriptoFX/x256/SmokeTile2.png";
|
|
107
|
-
const path = "data/textures/particle/KriptoFX/CloudMask.png";
|
|
44
|
+
// const path = "data/textures/particle/KriptoFX/CloudMask.png";
|
|
108
45
|
// const path = "data/textures/particle/travnik/arrow_2_64.png";
|
|
109
46
|
// const path = "data/textures/particle/travnik/leaf_01.png";
|
|
110
|
-
|
|
47
|
+
const path = "data/textures/particle/travnik/portal_2_blue_64.png";
|
|
111
48
|
// const path = "data/textures/particle/travnik/flake.png";
|
|
112
49
|
|
|
113
50
|
const asset = await engine.assetManager.promise(path, 'image')
|
|
@@ -147,7 +84,7 @@ async function main(engine) {
|
|
|
147
84
|
// we make it a bit larger to fit markers drawn at the edges of the image
|
|
148
85
|
vHull.size.set(sampler.width + 32, sampler.height + 32);
|
|
149
86
|
|
|
150
|
-
|
|
87
|
+
canvas2d_draw_path({
|
|
151
88
|
vertices: convex_hull_vertices,
|
|
152
89
|
ctx: vHull.context2d,
|
|
153
90
|
offset: [16, 16]
|
|
@@ -184,7 +121,7 @@ async function main(engine) {
|
|
|
184
121
|
|
|
185
122
|
vOptimalPoly.size.set(sampler.width + 100, sampler.height + 100);
|
|
186
123
|
|
|
187
|
-
|
|
124
|
+
canvas2d_draw_path({
|
|
188
125
|
vertices: optimal_poly,
|
|
189
126
|
ctx: vOptimalPoly.context2d,
|
|
190
127
|
strokeColor: '#30c0ff',
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Created by Alex on 29/01/2015.
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import { assert } from "../../../core/assert.js";
|
|
5
5
|
import Signal from "../../../core/events/signal/Signal.js";
|
|
6
|
+
import Vector2 from "../../../core/geom/Vector2.js";
|
|
6
7
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
7
|
-
import {
|
|
8
|
+
import { sign } from "../../../core/math/sign.js";
|
|
8
9
|
import { MouseEvents } from "./events/MouseEvents.js";
|
|
9
10
|
import { TouchEvents } from "./events/TouchEvents.js";
|
|
10
|
-
import { sign } from "../../../core/math/sign.js";
|
|
11
11
|
import { InputDeviceSwitch } from "./InputDeviceSwitch.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -353,6 +353,9 @@ export class PointerDevice {
|
|
|
353
353
|
down: new Signal(),
|
|
354
354
|
up: new Signal(),
|
|
355
355
|
move: new Signal(),
|
|
356
|
+
/**
|
|
357
|
+
* @type {Signal<Vector2, (MouseEvent|TouchEvent)>}
|
|
358
|
+
*/
|
|
356
359
|
tap: new Signal(),
|
|
357
360
|
drag: new Signal(),
|
|
358
361
|
dragStart: new Signal(),
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Vector2 from "../core/geom/Vector2.js";
|
|
2
|
+
import TaskProgressView from "../view/task/TaskProgressView.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Task|TaskGroup} task
|
|
7
|
+
* @param {Localization} localization
|
|
8
|
+
* @param {Vector2} [size]
|
|
9
|
+
* @returns {TaskProgressView}
|
|
10
|
+
*/
|
|
11
|
+
export function makeSimpleTaskProgressView({
|
|
12
|
+
task,
|
|
13
|
+
localization,
|
|
14
|
+
size = new Vector2(256, 32)
|
|
15
|
+
}) {
|
|
16
|
+
|
|
17
|
+
const vProgress = new TaskProgressView({
|
|
18
|
+
task,
|
|
19
|
+
localization
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
vProgress.size.copy(size);
|
|
23
|
+
vProgress.css({
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
top: 0,
|
|
26
|
+
left: 0,
|
|
27
|
+
pointerEvents: "none"
|
|
28
|
+
});
|
|
29
|
+
vProgress.el.querySelector('.fill').style.background = 'rgb(255,220,94)';
|
|
30
|
+
vProgress.el.querySelector('.progress-bar').style.height = '8px';
|
|
31
|
+
|
|
32
|
+
return vProgress;
|
|
33
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { assert } from "../../core/assert.js";
|
|
2
|
+
import { noop } from "../../core/function/Functions.js";
|
|
2
3
|
import Task from "../../core/process/task/Task.js";
|
|
4
|
+
import TaskGroup from "../../core/process/task/TaskGroup.js";
|
|
3
5
|
import TaskState from "../../core/process/task/TaskState.js";
|
|
4
|
-
import { noop } from "../../core/function/Functions.js";
|
|
5
|
-
import { compileAllMaterials } from "../graphics/ecs/compileAllMaterials.js";
|
|
6
|
-
import { createTaskWaitForMeshesToLoad } from "../graphics/ecs/mesh/createTaskWaitForMeshesToLoad.js";
|
|
7
|
-
import { loadVisibleTerrainTiles } from "../ecs/terrain/util/loadVisibleTerrainTiles.js";
|
|
8
|
-
import { TaskLoadingScreen } from "../../view/task/TaskLoadingScreen.js";
|
|
9
6
|
import { actionTask } from "../../core/process/task/util/actionTask.js";
|
|
10
7
|
import { delayTask } from "../../core/process/task/util/delayTask.js";
|
|
11
8
|
import { wrapTaskIgnoreFailure } from "../../core/process/task/util/wrapTaskIgnoreFailure.js";
|
|
12
|
-
import {
|
|
9
|
+
import { TaskLoadingScreen } from "../../view/task/TaskLoadingScreen.js";
|
|
10
|
+
import { loadVisibleTerrainTiles } from "../ecs/terrain/util/loadVisibleTerrainTiles.js";
|
|
11
|
+
import { compileAllMaterials } from "../graphics/ecs/compileAllMaterials.js";
|
|
12
|
+
import { createTaskWaitForMeshesToLoad } from "../graphics/ecs/mesh/createTaskWaitForMeshesToLoad.js";
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -117,7 +117,6 @@ export function transitionToScene({
|
|
|
117
117
|
|
|
118
118
|
Task.joinAll(allTasks,
|
|
119
119
|
() => {
|
|
120
|
-
cleanup();
|
|
121
120
|
|
|
122
121
|
taskGroup.state.set(TaskState.SUCCEEDED);
|
|
123
122
|
|
|
@@ -126,8 +125,6 @@ export function transitionToScene({
|
|
|
126
125
|
},
|
|
127
126
|
() => {
|
|
128
127
|
|
|
129
|
-
cleanup();
|
|
130
|
-
|
|
131
128
|
taskGroup.state.set(TaskState.FAILED);
|
|
132
129
|
|
|
133
130
|
taskGroup.on.failed.send0();
|
|
@@ -140,5 +137,7 @@ export function transitionToScene({
|
|
|
140
137
|
engine.executor.runMany(extraTasks);
|
|
141
138
|
}, noop);
|
|
142
139
|
|
|
140
|
+
promise.finally(cleanup);
|
|
141
|
+
|
|
143
142
|
return promise;
|
|
144
143
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import TaskProgressView from "./TaskProgressView.js";
|
|
2
|
-
import { AssetLoaderStatusView } from "../asset/AssetLoaderStatusView.js";
|
|
3
|
-
import { logger } from "../../engine/logging/GlobalLogger.js";
|
|
4
|
-
import { array_remove_first } from "../../core/collection/array/array_remove_first.js";
|
|
5
1
|
import { assert } from "../../core/assert.js";
|
|
2
|
+
import { array_remove_first } from "../../core/collection/array/array_remove_first.js";
|
|
3
|
+
import { logger } from "../../engine/logging/GlobalLogger.js";
|
|
4
|
+
import { AssetLoaderStatusView } from "../asset/AssetLoaderStatusView.js";
|
|
5
|
+
import TaskProgressView from "./TaskProgressView.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @type {TaskLoadingScreen}
|
|
@@ -133,14 +133,7 @@ export class TaskLoadingScreen {
|
|
|
133
133
|
|
|
134
134
|
this._pending_cleanup.push(cleanup);
|
|
135
135
|
|
|
136
|
-
const promise =
|
|
137
|
-
|
|
138
|
-
const p = task.promise();
|
|
139
|
-
|
|
140
|
-
p.finally(attempt_cleanup);
|
|
141
|
-
p.then(resolve, reject);
|
|
142
|
-
|
|
143
|
-
});
|
|
136
|
+
const promise = task.promise().finally(attempt_cleanup);
|
|
144
137
|
|
|
145
138
|
this._active_promise = promise;
|
|
146
139
|
|
|
@@ -3,26 +3,26 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import LabelView from '../common/LabelView.js';
|
|
6
|
+
import Vector1 from "../../core/geom/Vector1.js";
|
|
7
|
+
import { RemainingTimeEstimator } from "../../core/process/task/RemainingTimeEstimator.js";
|
|
9
8
|
|
|
10
9
|
import TaskState from '../../core/process/task/TaskState.js';
|
|
11
|
-
|
|
12
|
-
import dom from '../DOM.js';
|
|
13
10
|
import Clock from "../../engine/Clock.js";
|
|
14
|
-
import
|
|
11
|
+
import LabelView from '../common/LabelView.js';
|
|
15
12
|
import { LocalizedLabelView } from "../common/LocalizedLabelView.js";
|
|
16
|
-
|
|
13
|
+
|
|
14
|
+
import dom from '../DOM.js';
|
|
15
|
+
import SmoothProgressBar from '../elements/progress/SmoothProgressBar.js';
|
|
16
|
+
import View from '../View.js';
|
|
17
17
|
|
|
18
18
|
class TaskProgressView extends View {
|
|
19
19
|
/**
|
|
20
20
|
*
|
|
21
21
|
* @param {Task|TaskGroup} task
|
|
22
|
-
* @param {Localization} localization
|
|
22
|
+
* @param {Localization} [localization]
|
|
23
23
|
* @constructor
|
|
24
24
|
*/
|
|
25
|
-
constructor({ task, localization }) {
|
|
25
|
+
constructor({ task, localization=null }) {
|
|
26
26
|
super();
|
|
27
27
|
|
|
28
28
|
function makeNameId() {
|