@woosh/meep-engine 2.75.4 → 2.75.6
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/build/bundle-worker-image-decoder.js +1 -1
- package/build/meep.cjs +91 -74
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +91 -74
- 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
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
LinearEncoding,
|
|
4
4
|
LinearFilter,
|
|
5
5
|
LineBasicMaterial,
|
|
6
|
+
MeshStandardMaterial,
|
|
6
7
|
RGBAFormat,
|
|
7
8
|
Scene,
|
|
8
9
|
WebGLCubeRenderTarget
|
|
@@ -19,6 +20,9 @@ import {
|
|
|
19
20
|
} from "../../../core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js";
|
|
20
21
|
import { TetrahedralMesh } from "../../../core/geom/3d/tetrahedra/TetrahedralMesh.js";
|
|
21
22
|
import { v3_length_sqr } from "../../../core/geom/vec3/v3_length_sqr.js";
|
|
23
|
+
import TaskGroup from "../../../core/process/task/TaskGroup.js";
|
|
24
|
+
import { actionTask } from "../../../core/process/task/util/actionTask.js";
|
|
25
|
+
import { countTask } from "../../../core/process/task/util/countTask.js";
|
|
22
26
|
import Entity from "../../ecs/Entity.js";
|
|
23
27
|
import { Transform } from "../../ecs/transform/Transform.js";
|
|
24
28
|
import { threeMakeLight } from "../ecs/light/binding/three/threeMakeLight.js";
|
|
@@ -229,15 +233,15 @@ class CubeRenderer {
|
|
|
229
233
|
const source_material = sg.material;
|
|
230
234
|
|
|
231
235
|
//
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
236
|
+
if (source_material.isMeshStandardMaterial === true) {
|
|
237
|
+
object3D.material = new MeshStandardMaterial({
|
|
238
|
+
map: source_material.map,
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
object3D.material.color.copy(source_material.color);
|
|
242
|
+
} else {
|
|
243
|
+
object3D.material = source_material.clone();
|
|
244
|
+
}
|
|
241
245
|
|
|
242
246
|
applyTransformToThreeObject(object3D, t);
|
|
243
247
|
|
|
@@ -507,30 +511,46 @@ export class LightProbeVolume {
|
|
|
507
511
|
/**
|
|
508
512
|
* Bake light probes
|
|
509
513
|
* @param {Engine} engine
|
|
514
|
+
* @returns {TaskGroup}
|
|
510
515
|
*/
|
|
511
516
|
bake(engine) {
|
|
512
517
|
const baker = new Baker();
|
|
513
518
|
// baker.set_bvh(entityManager.getSystem(ShadedGeometrySystem).__bvh_binary);
|
|
514
519
|
|
|
515
|
-
baker.prepare(engine);
|
|
516
520
|
|
|
517
|
-
const
|
|
521
|
+
const tPrepare = actionTask(() => {
|
|
522
|
+
baker.prepare(engine);
|
|
523
|
+
});
|
|
518
524
|
|
|
519
525
|
|
|
520
|
-
|
|
526
|
+
const probe_count = this.__length;
|
|
527
|
+
const tBake = countTask(0, probe_count, (i) => {
|
|
521
528
|
|
|
522
529
|
baker.bake_sh3_cube(
|
|
523
530
|
this.__positions, i * 3,
|
|
524
531
|
this.__probe_data, i * 9 * 3
|
|
525
532
|
);
|
|
526
533
|
|
|
527
|
-
}
|
|
534
|
+
});
|
|
528
535
|
|
|
529
|
-
|
|
536
|
+
tBake.promise().then(()=>{
|
|
537
|
+
|
|
538
|
+
const duration =tBake.__executedCpuTime;
|
|
539
|
+
|
|
540
|
+
console.log(`Baked ${probe_count} probes in ${duration}ms, ~${(duration / probe_count).toFixed(2)}ms per probe`);
|
|
541
|
+
|
|
542
|
+
})
|
|
543
|
+
|
|
544
|
+
const tFinish = actionTask(() => {
|
|
545
|
+
baker.finish();
|
|
546
|
+
});
|
|
530
547
|
|
|
531
|
-
|
|
548
|
+
tFinish.addDependency(tBake);
|
|
549
|
+
tBake.addDependency(tPrepare);
|
|
532
550
|
|
|
533
|
-
|
|
551
|
+
return new TaskGroup([
|
|
552
|
+
tPrepare, tBake, tFinish
|
|
553
|
+
]);
|
|
534
554
|
}
|
|
535
555
|
|
|
536
556
|
/**
|
|
@@ -580,9 +600,10 @@ export class LightProbeVolume {
|
|
|
580
600
|
/**
|
|
581
601
|
*
|
|
582
602
|
* @param {Engine} engine
|
|
603
|
+
* @returns {TaskGroup}
|
|
583
604
|
*/
|
|
584
605
|
build(engine) {
|
|
585
606
|
this.build_mesh();
|
|
586
|
-
this.bake(engine);
|
|
607
|
+
return this.bake(engine);
|
|
587
608
|
}
|
|
588
609
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CanvasView } from "../../../../view/elements/CanvasView.js";
|
|
3
|
-
import { PathTracer } from "./PathTracer.js";
|
|
1
|
+
import { mat4, vec3 } from "gl-matrix";
|
|
4
2
|
import {
|
|
5
3
|
Box3,
|
|
6
4
|
MeshStandardMaterial,
|
|
@@ -9,35 +7,37 @@ import {
|
|
|
9
7
|
PlaneBufferGeometry,
|
|
10
8
|
Sphere
|
|
11
9
|
} from "three";
|
|
12
|
-
import { Sampler2D } from "../../texture/sampler/Sampler2D.js";
|
|
13
|
-
import sampler2D2Canvas from "../../texture/sampler/Sampler2D2Canvas.js";
|
|
14
|
-
import { ray3_array_compose } from "../../../../core/geom/3d/ray/ray3_array_compose.js";
|
|
15
|
-
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
16
|
-
import { float2uint8 } from "../../../../core/binary/float2uint8.js";
|
|
17
10
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
18
|
-
import {
|
|
11
|
+
import { PLYLoader } from "three/examples/jsm/loaders/PLYLoader.js";
|
|
12
|
+
|
|
13
|
+
import '../../../../../../../../css/game.scss';
|
|
14
|
+
import { float2uint8 } from "../../../../core/binary/float2uint8.js";
|
|
15
|
+
import { Color } from "../../../../core/color/Color.js";
|
|
16
|
+
import { kelvin_to_rgb } from "../../../../core/color/kelvin/kelvin_to_rgb.js";
|
|
17
|
+
import { noop } from "../../../../core/function/Functions.js";
|
|
18
|
+
import { ray3_array_compose } from "../../../../core/geom/3d/ray/ray3_array_compose.js";
|
|
19
|
+
import Quaternion from "../../../../core/geom/Quaternion.js";
|
|
20
|
+
import { v3_distance } from "../../../../core/geom/vec3/v3_distance.js";
|
|
19
21
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
20
|
-
import {
|
|
22
|
+
import { Localization } from "../../../../core/localization/Localization.js";
|
|
23
|
+
import { min2 } from "../../../../core/math/min2.js";
|
|
21
24
|
import { seededRandom } from "../../../../core/math/random/seededRandom.js";
|
|
22
|
-
import {
|
|
23
|
-
import { v3_distance } from "../../../../core/geom/vec3/v3_distance.js";
|
|
25
|
+
import { number_pretty_print } from "../../../../core/primitives/numbers/number_pretty_print.js";
|
|
24
26
|
import ConcurrentExecutor from "../../../../core/process/executor/ConcurrentExecutor.js";
|
|
25
27
|
import Task from "../../../../core/process/task/Task.js";
|
|
26
28
|
import { TaskSignal } from "../../../../core/process/task/TaskSignal.js";
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
import '../../../../../../../../css/game.scss';
|
|
29
|
+
import { CanvasView } from "../../../../view/elements/CanvasView.js";
|
|
30
|
+
import EmptyView from "../../../../view/elements/EmptyView.js";
|
|
31
|
+
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
32
32
|
import { MouseEvents } from "../../../input/devices/events/MouseEvents.js";
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import { Color } from "../../../../core/color/Color.js";
|
|
36
|
-
import { min2 } from "../../../../core/math/min2.js";
|
|
33
|
+
import { makeSimpleTaskProgressView } from "../../../makeSimpleTaskProgressView.js";
|
|
34
|
+
import { Camera } from "../../ecs/camera/Camera.js";
|
|
37
35
|
import { makeGeometryIndexed } from "../../geometry/buffered/makeGeometryIndexed.js";
|
|
38
36
|
import { DirectionalLight } from "../../render/forward_plus/model/DirectionalLight.js";
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
37
|
+
import { sampler2d_scale } from "../../texture/sampler/resize/sampler2d_scale.js";
|
|
38
|
+
import { Sampler2D } from "../../texture/sampler/Sampler2D.js";
|
|
39
|
+
import sampler2D2Canvas from "../../texture/sampler/Sampler2D2Canvas.js";
|
|
40
|
+
import { PathTracer } from "./PathTracer.js";
|
|
41
41
|
|
|
42
42
|
document.body.style.margin = 0;
|
|
43
43
|
document.body.style.overflow = "hidden";
|
|
@@ -569,20 +569,11 @@ async function start_renderer(camera) {
|
|
|
569
569
|
const t = make_render_task();
|
|
570
570
|
|
|
571
571
|
|
|
572
|
-
const vProgress =
|
|
572
|
+
const vProgress =makeSimpleTaskProgressView({
|
|
573
573
|
task: t,
|
|
574
|
+
size:vContainer.size,
|
|
574
575
|
localization: loc
|
|
575
|
-
})
|
|
576
|
-
|
|
577
|
-
vProgress.size.set(vContainer.size.x, vContainer.size.y);
|
|
578
|
-
vProgress.css({
|
|
579
|
-
position: 'absolute',
|
|
580
|
-
top: 0,
|
|
581
|
-
left: 0,
|
|
582
|
-
pointerEvents: "none"
|
|
583
|
-
});
|
|
584
|
-
vProgress.el.querySelector('.fill').style.background = 'rgb(255,220,94)';
|
|
585
|
-
vProgress.el.querySelector('.progress-bar').style.height = '8px';
|
|
576
|
+
})
|
|
586
577
|
|
|
587
578
|
vContainer.addChild(vProgress);
|
|
588
579
|
|
|
@@ -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
|
+
}
|