@woosh/meep-engine 2.64.0 → 2.66.0
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-terrain.js +1 -1
- package/build/meep.cjs +33388 -34714
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +33388 -34714
- package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +4 -10
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +7 -7
- package/editor/tools/SelectionTool.js +6 -95
- package/package.json +1 -1
- package/src/core/bvh2/BinaryNode.js +14 -14
- package/src/core/bvh2/LeafNode.js +4 -4
- package/src/core/bvh2/binary/2/BinaryUint32BVH.js +118 -113
- package/src/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
- package/src/core/bvh2/binary/2/bvh32_query_user_data_ray.js +98 -0
- package/src/core/bvh2/bvh3/{ExplicitBinaryBoundingVolumeHierarchy.d.ts → BVH.d.ts} +1 -1
- package/src/core/bvh2/bvh3/{ExplicitBinaryBoundingVolumeHierarchy.js → BVH.js} +2 -2
- package/src/core/bvh2/bvh3/{ExplicitBinaryBoundingVolumeHierarchy.spec.js → BVH.spec.js} +20 -20
- package/src/core/bvh2/bvh3/BvhClient.d.ts +11 -0
- package/src/core/bvh2/bvh3/{EBBVHLeafProxy.js → BvhClient.js} +22 -3
- package/src/core/bvh2/bvh3/BvhClient.spec.js +51 -0
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.js +2 -2
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +4 -4
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.spec.js +3 -3
- package/src/core/bvh2/bvh3/ebvh_sort_for_traversal_depth_first.js +2 -8
- package/src/core/bvh2/bvh3/query/BVHQuery.js +1 -1
- package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.spec.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +3 -8
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.spec.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.spec.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_nearest_to_point.js +3 -3
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_nearest_to_point.spec.js +3 -3
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js +3 -3
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +4 -4
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.spec.js +3 -3
- package/src/core/collection/array/array_copy.js +6 -0
- package/src/core/geom/3d/aabb/aabb3_array_combine.js +17 -8
- package/src/core/geom/3d/aabb/aabb3_array_intersects_ray.js +5 -2
- package/src/core/geom/3d/aabb/aabb3_array_set.js +25 -0
- package/src/core/geom/3d/aabb/aabb3_compute_half_surface_area.js +3 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +8 -1
- package/src/engine/EngineHarness.js +23 -25
- package/src/engine/ecs/renderable/RenderSystem.js +44 -32
- package/src/engine/ecs/renderable/Renderable.d.ts +2 -2
- package/src/engine/ecs/renderable/Renderable.js +12 -11
- package/src/engine/ecs/terrain/ecs/Terrain.js +83 -87
- package/src/engine/ecs/terrain/ecs/TerrainSystem.js +106 -57
- package/src/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +5 -2
- package/src/engine/ecs/terrain/tiles/TerrainTile.js +122 -67
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +162 -146
- package/src/engine/ecs/terrain/tiles/TileBuildWorker.js +16 -5
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +3 -6
- package/src/engine/graphics/debug/VisualSymbolLine.js +1 -0
- package/src/engine/graphics/ecs/camera/CameraSystem.js +9 -9
- package/src/engine/graphics/ecs/camera/auto_set_camera_clipping_planes.js +3 -23
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +22 -24
- package/src/engine/graphics/ecs/light/LightSystem.js +12 -48
- package/src/engine/graphics/ecs/mesh/Mesh.js +8 -8
- package/src/engine/graphics/ecs/mesh/MeshSystem.js +12 -36
- package/src/engine/graphics/ecs/mesh/updateNodeByTransformAndBBB.js +3 -43
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +6 -6
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +3 -3
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +16 -18
- package/src/engine/graphics/ecs/mesh-v2/render/ShadedGeometryRendererContext.js +5 -5
- package/src/engine/graphics/ecs/trail2d/Trail2D.js +105 -106
- package/src/engine/graphics/ecs/trail2d/Trail2DSystem.js +60 -61
- package/src/engine/graphics/ecs/trail2d/makeGradientTrail.js +3 -3
- package/src/engine/graphics/ecs/water/WATER_SIZE.js +1 -0
- package/src/engine/graphics/ecs/water/Water.js +84 -42
- package/src/engine/graphics/ecs/water/WaterSystem.js +53 -105
- package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +13 -7
- package/src/engine/graphics/geometry/bvh/buffered/bvh32_from_indexed_geometry.js +58 -0
- package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.js +32 -62
- package/src/engine/graphics/particles/particular/engine/ParticularEngine.js +9 -11
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +4 -4
- package/src/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +8 -11
- package/src/engine/graphics/render/forward_plus/LightManager.js +30 -32
- package/src/engine/graphics/render/forward_plus/LightRenderMetadata.js +3 -3
- package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +21 -19
- package/src/engine/graphics/render/layers/RenderLayer.d.ts +8 -2
- package/src/engine/graphics/render/layers/RenderLayer.js +7 -65
- package/src/engine/graphics/render/make_bvh_visibility_builder.js +64 -0
- package/src/engine/graphics/sh3/LightProbeVolume.js +19 -19
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +4 -6
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +17 -19
- package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +4 -4
- package/src/engine/graphics/trail/x/RibbonX.js +26 -5
- package/src/engine/sound/ecs/emitter/SoundEmitter.js +18 -16
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +3 -5
- package/src/core/bvh2/binary/tiny/TinyBVH.js +0 -221
- package/src/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +0 -138
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BVH } from "../BVH.js";
|
|
2
2
|
import { bvh_query_user_data_nearest_to_point } from "./bvh_query_user_data_nearest_to_point.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @param {number[]} boxes
|
|
7
|
-
* @return {
|
|
7
|
+
* @return {BVH}
|
|
8
8
|
*/
|
|
9
9
|
function makeBvh(...boxes) {
|
|
10
|
-
const r = new
|
|
10
|
+
const r = new BVH();
|
|
11
11
|
|
|
12
12
|
for (let i = 0; i < boxes.length; i++) {
|
|
13
13
|
const box = boxes[i];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//
|
|
2
|
-
import {
|
|
2
|
+
import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
3
3
|
import { aabb3_array_intersects_frustum_degree } from "../../../geom/3d/aabb/aabb3_array_intersects_frustum_degree.js";
|
|
4
|
+
import { NULL_NODE } from "../BVH.js";
|
|
4
5
|
import { bvh_collect_user_data } from "./bvh_collect_user_data.js";
|
|
5
|
-
import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
6
6
|
|
|
7
7
|
const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ const scratch_aabb = new Float32Array(6);
|
|
|
12
12
|
*
|
|
13
13
|
* @param {number[]} result
|
|
14
14
|
* @param {number} result_offset
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {BVH} bvh
|
|
16
16
|
* @param {number[]|Float32Array} frustum
|
|
17
17
|
*/
|
|
18
18
|
export function bvh_query_user_data_overlaps_frustum(
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import { array_copy } from "../../../collection/array/array_copy.js";
|
|
5
|
-
import {
|
|
5
|
+
import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
6
6
|
import { aabb3_array_intersects_frustum_degree } from "../../../geom/3d/aabb/aabb3_array_intersects_frustum_degree.js";
|
|
7
|
-
import { bvh_collect_user_data } from "./bvh_collect_user_data.js";
|
|
8
7
|
import { v3_distance_above_plane } from "../../../geom/vec3/v3_distance_above_plane.js";
|
|
9
|
-
import {
|
|
8
|
+
import { NULL_NODE } from "../BVH.js";
|
|
9
|
+
import { bvh_collect_user_data } from "./bvh_collect_user_data.js";
|
|
10
10
|
|
|
11
11
|
const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
12
12
|
|
|
@@ -17,7 +17,7 @@ const scratch_aabb = [];
|
|
|
17
17
|
* @param {number[]} result
|
|
18
18
|
* @param {number} result_offset
|
|
19
19
|
* @param {number} constrained_planes_mask if bit is set to 1, that plane is not allowed to move
|
|
20
|
-
* @param {
|
|
20
|
+
* @param {BVH} bvh
|
|
21
21
|
* @param {number[]|ArrayLike<number>|Float32Array} frustum
|
|
22
22
|
*/
|
|
23
23
|
export function compute_tight_near_far_clipping_planes(result, result_offset, constrained_planes_mask, bvh, frustum) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BVH } from "../BVH.js";
|
|
2
2
|
import { compute_tight_near_far_clipping_planes } from "./compute_tight_near_far_clipping_planes.js";
|
|
3
3
|
|
|
4
4
|
|
|
@@ -14,7 +14,7 @@ function orthographic_frustum(left, right, up, down, near, far) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
test('Empty does not throw', () => {
|
|
17
|
-
const bvh = new
|
|
17
|
+
const bvh = new BVH();
|
|
18
18
|
|
|
19
19
|
const res = [];
|
|
20
20
|
|
|
@@ -26,7 +26,7 @@ test('Empty does not throw', () => {
|
|
|
26
26
|
test.skip('Axis-aligned, orthographic tight fit around a single small node', () => {
|
|
27
27
|
const frustum = orthographic_frustum(-1, 1, -1, 1, -1, 1);
|
|
28
28
|
|
|
29
|
-
const bvh = new
|
|
29
|
+
const bvh = new BVH();
|
|
30
30
|
|
|
31
31
|
const leaf = bvh.allocate_node();
|
|
32
32
|
bvh.node_set_aabb(leaf, [-0.1, -0.1, -0.1, 0.1, 0.1, 0.1]);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Copy data from one array to another
|
|
3
5
|
* Follows Java System.arraycopy interface
|
|
@@ -15,6 +17,10 @@ export function array_copy(
|
|
|
15
17
|
destination_position,
|
|
16
18
|
length
|
|
17
19
|
) {
|
|
20
|
+
assert.isNonNegativeInteger(source_position, 'source_position');
|
|
21
|
+
assert.isNonNegativeInteger(destination_position, 'destination_position');
|
|
22
|
+
assert.isNonNegativeInteger(length, 'length');
|
|
23
|
+
|
|
18
24
|
let i, j, k;
|
|
19
25
|
|
|
20
26
|
for (k = 0; k < length; k++) {
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
|
-
import { min2 } from "../../../math/min2.js";
|
|
4
3
|
import { max2 } from "../../../math/max2.js";
|
|
4
|
+
import { min2 } from "../../../math/min2.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Merge bounds of two axis-aligned bounding boxes, the result is a box that tightly bounds inputs
|
|
8
8
|
* @param {ArrayLike<number>|number[]|Float32Array} result where resulting value is written to
|
|
9
|
+
* @param {number} result_offset
|
|
9
10
|
* @param {ArrayLike<number>|number[]|Float32Array} a
|
|
11
|
+
* @param {number} a_offset
|
|
10
12
|
* @param {ArrayLike<number>|number[]|Float32Array} b
|
|
13
|
+
* @param {number} b_offset
|
|
11
14
|
*/
|
|
12
|
-
export function aabb3_array_combine(
|
|
13
|
-
result
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
export function aabb3_array_combine(
|
|
16
|
+
result, result_offset,
|
|
17
|
+
a, a_offset,
|
|
18
|
+
b, b_offset
|
|
19
|
+
) {
|
|
20
|
+
|
|
21
|
+
result[result_offset + 0] = min2(a[a_offset + 0], b[b_offset + 0]);
|
|
22
|
+
result[result_offset + 1] = min2(a[a_offset + 1], b[b_offset + 1]);
|
|
23
|
+
result[result_offset + 2] = min2(a[a_offset + 2], b[b_offset + 2]);
|
|
24
|
+
|
|
25
|
+
result[result_offset + 3] = max2(a[a_offset + 3], b[b_offset + 3]);
|
|
26
|
+
result[result_offset + 4] = max2(a[a_offset + 4], b[b_offset + 4]);
|
|
27
|
+
result[result_offset + 5] = max2(a[a_offset + 5], b[b_offset + 5]);
|
|
16
28
|
|
|
17
|
-
result[3] = max2(a[3], b[3]);
|
|
18
|
-
result[4] = max2(a[4], b[4]);
|
|
19
|
-
result[5] = max2(a[5], b[5]);
|
|
20
29
|
}
|
|
@@ -5,6 +5,7 @@ import { aabb3_intersects_ray } from "./aabb3_intersects_ray.js";
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
7
7
|
* @param {ArrayLike<number>|number[]|Float32Array} aabb bounding box, order: x0,y0,z0,x1,y1,z1
|
|
8
|
+
* @param {number} aabb_offset
|
|
8
9
|
* @param {number} origin_x
|
|
9
10
|
* @param {number} origin_y
|
|
10
11
|
* @param {number} origin_z
|
|
@@ -13,11 +14,13 @@ import { aabb3_intersects_ray } from "./aabb3_intersects_ray.js";
|
|
|
13
14
|
* @param {number} direction_z
|
|
14
15
|
*/
|
|
15
16
|
export function aabb3_array_intersects_ray(
|
|
16
|
-
aabb,
|
|
17
|
+
aabb, aabb_offset,
|
|
17
18
|
origin_x, origin_y, origin_z,
|
|
18
19
|
direction_x, direction_y, direction_z
|
|
19
20
|
) {
|
|
20
|
-
return aabb3_intersects_ray(
|
|
21
|
+
return aabb3_intersects_ray(
|
|
22
|
+
aabb[aabb_offset], aabb[aabb_offset+1], aabb[aabb_offset+2],
|
|
23
|
+
aabb[aabb_offset+3], aabb[aabb_offset+4], aabb[aabb_offset+5],
|
|
21
24
|
origin_x, origin_y, origin_z,
|
|
22
25
|
direction_x, direction_y, direction_z
|
|
23
26
|
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {ArrayLike<number>|Float32Array|number[]} result
|
|
4
|
+
* @param {number} result_offset
|
|
5
|
+
* @param {number} x0
|
|
6
|
+
* @param {number} y0
|
|
7
|
+
* @param {number} z0
|
|
8
|
+
* @param {number} x1
|
|
9
|
+
* @param {number} y1
|
|
10
|
+
* @param {number} z1
|
|
11
|
+
*/
|
|
12
|
+
export function aabb3_array_set(
|
|
13
|
+
result, result_offset,
|
|
14
|
+
x0, y0, z0,
|
|
15
|
+
x1, y1, z1
|
|
16
|
+
) {
|
|
17
|
+
|
|
18
|
+
result[result_offset + 0] = x0;
|
|
19
|
+
result[result_offset + 1] = y0;
|
|
20
|
+
result[result_offset + 2] = z0;
|
|
21
|
+
|
|
22
|
+
result[result_offset + 3] = x1;
|
|
23
|
+
result[result_offset + 4] = y1;
|
|
24
|
+
result[result_offset + 5] = z1;
|
|
25
|
+
}
|
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
* @returns {number}
|
|
10
10
|
*/
|
|
11
11
|
export function aabb3_compute_half_surface_area(x0, y0, z0, x1, y1, z1) {
|
|
12
|
+
|
|
12
13
|
const dx = x1 - x0;
|
|
13
14
|
const dy = y1 - y0;
|
|
14
15
|
const dz = z1 - z0;
|
|
16
|
+
|
|
15
17
|
return dy * (dx + dz) + dz * dx; //1 side, since it's a heuristic only
|
|
18
|
+
|
|
16
19
|
}
|
|
@@ -83,5 +83,12 @@ export function computeTriangleRayIntersectionBarycentric(
|
|
|
83
83
|
const edge2_y = cy - ay;
|
|
84
84
|
const edge2_z = cz - az;
|
|
85
85
|
|
|
86
|
-
return computeTriangleRayIntersectionBarycentricEdge(
|
|
86
|
+
return computeTriangleRayIntersectionBarycentricEdge(
|
|
87
|
+
result,
|
|
88
|
+
origin_x, origin_y, origin_z,
|
|
89
|
+
direction_x, direction_y, direction_z,
|
|
90
|
+
ax, ay, az,
|
|
91
|
+
edge1_x, edge1_y, edge1_z,
|
|
92
|
+
edge2_x, edge2_y, edge2_z
|
|
93
|
+
);
|
|
87
94
|
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { Transform } from "./ecs/transform/Transform.js";
|
|
4
|
-
import TopDownCameraController from "./graphics/ecs/camera/topdown/TopDownCameraController.js";
|
|
5
|
-
import { Camera } from "./graphics/ecs/camera/Camera.js";
|
|
6
|
-
import Entity from "./ecs/Entity.js";
|
|
7
|
-
import { Light } from "./graphics/ecs/light/Light.js";
|
|
8
|
-
import Vector3 from "../core/geom/Vector3.js";
|
|
9
|
-
import Terrain from "./ecs/terrain/ecs/Terrain.js";
|
|
1
|
+
import Stats from "three/examples/jsm/libs/stats.module.js";
|
|
2
|
+
import { noop } from "../core/function/Functions.js";
|
|
10
3
|
import Vector2 from "../core/geom/Vector2.js";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
4
|
+
import Vector3 from "../core/geom/Vector3.js";
|
|
5
|
+
import EmptyView from "../view/elements/EmptyView.js";
|
|
6
|
+
import { JsonAssetLoader } from "./asset/loaders/JsonAssetLoader.js";
|
|
14
7
|
import { SerializationMetadata } from "./ecs/components/SerializationMetadata.js";
|
|
8
|
+
import Tag from "./ecs/components/Tag.js";
|
|
9
|
+
import Entity from "./ecs/Entity.js";
|
|
15
10
|
import { TerrainLayer } from "./ecs/terrain/ecs/layers/TerrainLayer.js";
|
|
11
|
+
import Terrain from "./ecs/terrain/ecs/Terrain.js";
|
|
12
|
+
import TerrainSystem from "./ecs/terrain/ecs/TerrainSystem.js";
|
|
13
|
+
import { Transform } from "./ecs/transform/Transform.js";
|
|
14
|
+
import Engine from "./Engine.js";
|
|
15
|
+
import { EngineConfiguration } from "./EngineConfiguration.js";
|
|
16
16
|
import { makeOrbitalCameraController } from "./graphics/camera/makeOrbitalCameraController.js";
|
|
17
|
-
import
|
|
17
|
+
import { Camera } from "./graphics/ecs/camera/Camera.js";
|
|
18
18
|
import { CameraSystem } from "./graphics/ecs/camera/CameraSystem.js";
|
|
19
|
+
import TopDownCameraController from "./graphics/ecs/camera/topdown/TopDownCameraController.js";
|
|
20
|
+
import TopDownCameraControllerSystem from "./graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
|
|
21
|
+
import { Light } from "./graphics/ecs/light/Light.js";
|
|
19
22
|
import LightSystem from "./graphics/ecs/light/LightSystem.js";
|
|
20
|
-
import
|
|
21
|
-
import TerrainSystem from "./ecs/terrain/ecs/TerrainSystem.js";
|
|
23
|
+
import Water from "./graphics/ecs/water/Water.js";
|
|
22
24
|
import WaterSystem from "./graphics/ecs/water/WaterSystem.js";
|
|
25
|
+
import { MouseEvents } from "./input/devices/events/MouseEvents.js";
|
|
23
26
|
import KeyboardCameraController from "./input/ecs/controllers/KeyboardCameraController.js";
|
|
24
|
-
import
|
|
25
|
-
import { JsonAssetLoader } from "./asset/loaders/JsonAssetLoader.js";
|
|
26
|
-
import { logger } from "./logging/GlobalLogger.js";
|
|
27
|
+
import InputControllerSystem from "./input/ecs/systems/InputControllerSystem.js";
|
|
27
28
|
import { ConsoleLoggerBackend } from "./logging/ConsoleLoggerBackend.js";
|
|
28
|
-
import {
|
|
29
|
-
import SoundListenerSystem from "./sound/ecs/SoundListenerSystem.js";
|
|
30
|
-
import SoundListener from "./sound/ecs/SoundListener.js";
|
|
29
|
+
import { logger } from "./logging/GlobalLogger.js";
|
|
31
30
|
import { getURLHash } from "./platform/GetURLHash.js";
|
|
32
|
-
import
|
|
33
|
-
import
|
|
31
|
+
import { WebEnginePlatform } from "./platform/WebEnginePlatform.js";
|
|
32
|
+
import SoundListener from "./sound/ecs/SoundListener.js";
|
|
33
|
+
import SoundListenerSystem from "./sound/ecs/SoundListenerSystem.js";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
*
|
|
@@ -438,7 +438,6 @@ export class EngineHarness {
|
|
|
438
438
|
engine,
|
|
439
439
|
size = new Vector2(10, 10),
|
|
440
440
|
diffuse0 = "data/textures/utility/checkers_dark_grey_256x256.png",
|
|
441
|
-
heightMap = "data/textures/utility/white_pixel.png",
|
|
442
441
|
heightRange = 0,
|
|
443
442
|
resolution = 10,
|
|
444
443
|
waterLevel = 0,
|
|
@@ -464,7 +463,6 @@ export class EngineHarness {
|
|
|
464
463
|
));
|
|
465
464
|
terrain.splat.resize(1, 1, 1);
|
|
466
465
|
terrain.splat.fillLayerWeights(0, 255);
|
|
467
|
-
terrain.heightMapURL = heightMap;
|
|
468
466
|
|
|
469
467
|
terrain.build(engine.assetManager);
|
|
470
468
|
|
|
@@ -1,22 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Created by Alex on 01/04/2014.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import Renderable from './Renderable.js';
|
|
6
|
-
import { Transform } from '../transform/Transform.js';
|
|
4
|
+
import { BVH } from "../../../core/bvh2/bvh3/BVH.js";
|
|
7
5
|
import { SignalBinding } from "../../../core/events/signal/SignalBinding.js";
|
|
8
|
-
import { RenderableFlags } from "./RenderableFlags.js";
|
|
9
|
-
import { rootObject3DFastMatrixUpdate } from "../../graphics/ecs/mesh/rootObject3DFastMatrixUpdate.js";
|
|
10
|
-
import { updateNodeByTransformAndBBB } from "../../graphics/ecs/mesh/updateNodeByTransformAndBBB.js";
|
|
11
|
-
import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
|
|
12
6
|
import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
|
|
7
|
+
import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
|
|
13
8
|
import { copy_transform_to_threejs_object } from "../../graphics/copy_transform_to_threejs_object.js";
|
|
9
|
+
import { rootObject3DFastMatrixUpdate } from "../../graphics/ecs/mesh/rootObject3DFastMatrixUpdate.js";
|
|
10
|
+
import { updateNodeByTransformAndBBB } from "../../graphics/ecs/mesh/updateNodeByTransformAndBBB.js";
|
|
11
|
+
import { make_bvh_visibility_builder } from "../../graphics/render/make_bvh_visibility_builder.js";
|
|
12
|
+
import { System } from '../System.js';
|
|
13
|
+
import { Transform } from '../transform/Transform.js';
|
|
14
|
+
import Renderable from './Renderable.js';
|
|
15
|
+
import { RenderableFlags } from "./RenderableFlags.js";
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* @deprecated use {@link ShadedGeometry} instead
|
|
18
20
|
*/
|
|
19
21
|
class RenderSystem extends System {
|
|
22
|
+
dependencies = [Renderable, Transform];
|
|
23
|
+
|
|
24
|
+
components_used = [
|
|
25
|
+
ResourceAccessSpecification.from(Renderable, ResourceAccessKind.Read | ResourceAccessKind.Write)
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
entityData = [];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @type {RenderLayer|null}
|
|
33
|
+
*/
|
|
34
|
+
renderLayer = null;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @type {BVH}
|
|
39
|
+
*/
|
|
40
|
+
bvh = new BVH();
|
|
41
|
+
|
|
20
42
|
/**
|
|
21
43
|
*
|
|
22
44
|
* @param {GraphicsEngine} graphicsEngine
|
|
@@ -29,26 +51,6 @@ class RenderSystem extends System {
|
|
|
29
51
|
* @type {GraphicsEngine}
|
|
30
52
|
*/
|
|
31
53
|
this.graphics = graphicsEngine;
|
|
32
|
-
|
|
33
|
-
this.dependencies = [Renderable, Transform];
|
|
34
|
-
|
|
35
|
-
this.components_used = [
|
|
36
|
-
ResourceAccessSpecification.from(Renderable, ResourceAccessKind.Read | ResourceAccessKind.Write)
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
this.entityData = [];
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
* @type {RenderLayer|null}
|
|
44
|
-
*/
|
|
45
|
-
this.renderLayer = null;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
* @type {BinaryNode}
|
|
50
|
-
*/
|
|
51
|
-
this.bvh = null;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
startup(entityManager, readyCallback, errorCallback) {
|
|
@@ -56,7 +58,19 @@ class RenderSystem extends System {
|
|
|
56
58
|
|
|
57
59
|
this.renderLayer = this.graphics.layers.create('render-system');
|
|
58
60
|
|
|
59
|
-
this.
|
|
61
|
+
this.renderLayer.buildVisibleSet = make_bvh_visibility_builder(
|
|
62
|
+
this.entityManager, this.bvh,
|
|
63
|
+
(destination, offset, entity, ecd) => {
|
|
64
|
+
const component = ecd.getComponent(entity, Renderable);
|
|
65
|
+
|
|
66
|
+
if (component.object === null) {
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
destination[offset] = component.object;
|
|
71
|
+
return 1;
|
|
72
|
+
}
|
|
73
|
+
)
|
|
60
74
|
|
|
61
75
|
const visibleSet = this.renderLayer.visibleSet;
|
|
62
76
|
|
|
@@ -102,8 +116,6 @@ class RenderSystem extends System {
|
|
|
102
116
|
* @param {int} entity
|
|
103
117
|
*/
|
|
104
118
|
link(renderable, transform, entity) {
|
|
105
|
-
//remember entity for fast lookup
|
|
106
|
-
renderable.bvh.entity = entity;
|
|
107
119
|
|
|
108
120
|
// create back-links to ECS
|
|
109
121
|
renderable.object.__meep_ecs_component = renderable;
|
|
@@ -139,7 +151,7 @@ class RenderSystem extends System {
|
|
|
139
151
|
|
|
140
152
|
handle_transform_change();
|
|
141
153
|
|
|
142
|
-
|
|
154
|
+
renderable.bvh.link(this.bvh,entity);
|
|
143
155
|
}
|
|
144
156
|
|
|
145
157
|
/**
|
|
@@ -158,7 +170,7 @@ class RenderSystem extends System {
|
|
|
158
170
|
|
|
159
171
|
delete this.entityData[entity];
|
|
160
172
|
|
|
161
|
-
renderable.bvh.
|
|
173
|
+
renderable.bvh.unlink();
|
|
162
174
|
|
|
163
175
|
// cleanup resources
|
|
164
176
|
renderable.dispose();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Object3D} from "three";
|
|
2
|
+
import {BvhClient} from "../../../core/bvh2/bvh3/BvhClient";
|
|
2
3
|
import {AABB3} from "../../../core/geom/3d/aabb/AABB3";
|
|
3
|
-
import {LeafNode} from "../../../core/bvh2/LeafNode";
|
|
4
4
|
|
|
5
5
|
export default class Renderable {
|
|
6
6
|
readonly object: Object3D
|
|
@@ -9,7 +9,7 @@ export default class Renderable {
|
|
|
9
9
|
matrixAutoUpdate: boolean
|
|
10
10
|
boundingBoxNeedsUpdate: boolean
|
|
11
11
|
|
|
12
|
-
readonly bvh:
|
|
12
|
+
readonly bvh: BvhClient
|
|
13
13
|
|
|
14
14
|
constructor(object: Object3D)
|
|
15
15
|
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { BvhClient } from "../../../core/bvh2/bvh3/BvhClient.js";
|
|
7
7
|
import { AABB3 } from "../../../core/geom/3d/aabb/AABB3.js";
|
|
8
|
-
import { RenderableFlags } from "./RenderableFlags.js";
|
|
9
8
|
import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
|
|
10
9
|
import {
|
|
11
10
|
expand_aabb_by_transformed_three_object
|
|
12
11
|
} from "../../graphics/three/expand_aabb_by_transformed_three_object.js";
|
|
12
|
+
import { RenderableFlags } from "./RenderableFlags.js";
|
|
13
13
|
|
|
14
14
|
const DEFAULT_FLAGS = RenderableFlags.UpdateMatrix | RenderableFlags.BoundingBoxNeedsUpdate;
|
|
15
15
|
|
|
@@ -18,18 +18,19 @@ const DEFAULT_FLAGS = RenderableFlags.UpdateMatrix | RenderableFlags.BoundingBox
|
|
|
18
18
|
@deprecated use {@link ShadedGeometry} instead
|
|
19
19
|
*/
|
|
20
20
|
class Renderable {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
boundingBox = new AABB3(0, 0, 0, 0, 0, 0);
|
|
22
|
+
|
|
23
|
+
bvh = new BvhClient();
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @type {number}
|
|
28
|
+
*/
|
|
29
|
+
flags = DEFAULT_FLAGS;
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
constructor(object) {
|
|
32
|
+
this.object = object;
|
|
27
33
|
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @type {number}
|
|
31
|
-
*/
|
|
32
|
-
this.flags = DEFAULT_FLAGS;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
dispose() {
|