@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,34 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SystemEntityContext } from "../../../../ecs/system/SystemEntityContext.js";
|
|
3
|
-
import { Decal } from "./Decal.js";
|
|
4
|
-
import { Transform } from "../../../../ecs/transform/Transform.js";
|
|
5
|
-
import { ForwardPlusRenderingPlugin } from "../../../render/forward_plus/plugin/ForwardPlusRenderingPlugin.js";
|
|
6
|
-
import { Reference } from "../../../../reference/v2/Reference.js";
|
|
7
|
-
import { Decal as FPDecal } from '../../../render/forward_plus/model/Decal.js';
|
|
8
|
-
import { AssetManager } from "../../../../asset/AssetManager.js";
|
|
9
|
-
import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
|
|
10
|
-
import { GameAssetType } from "../../../../asset/GameAssetType.js";
|
|
1
|
+
import { mat4 } from "gl-matrix";
|
|
11
2
|
import { assert } from "../../../../../core/assert.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
ExplicitBinaryBoundingVolumeHierarchy
|
|
16
|
-
} from "../../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
3
|
+
import { BVH } from "../../../../../core/bvh2/bvh3/BVH.js";
|
|
4
|
+
import { BvhClient } from "../../../../../core/bvh2/bvh3/BvhClient.js";
|
|
17
5
|
import { bvh_query_leaves_ray } from "../../../../../core/bvh2/bvh3/query/bvh_query_leaves_ray.js";
|
|
18
|
-
import { ray3_array_apply_matrix4 } from "../../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
|
|
19
|
-
import { ray3_array_compose } from "../../../../../core/geom/3d/ray/ray3_array_compose.js";
|
|
20
|
-
import { mat4 } from "gl-matrix";
|
|
21
|
-
import { SurfacePoint3 } from "../../../../../core/geom/3d/SurfacePoint3.js";
|
|
22
|
-
import { EBBVHLeafProxy } from "../../../../../core/bvh2/bvh3/EBBVHLeafProxy.js";
|
|
23
|
-
import { aabb3_matrix4_project } from "../../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
|
|
24
|
-
import { aabb3_raycast } from "../../../../../core/geom/3d/aabb/aabb3_raycast.js";
|
|
25
6
|
import {
|
|
26
7
|
bvh_query_user_data_overlaps_frustum
|
|
27
8
|
} from "../../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
9
|
+
import { AsyncLoadingCache } from "../../../../../core/collection/map/AsyncLoadingCache.js";
|
|
10
|
+
import { returnTrue } from "../../../../../core/function/Functions.js";
|
|
11
|
+
import { aabb3_matrix4_project } from "../../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
|
|
12
|
+
import { aabb3_raycast } from "../../../../../core/geom/3d/aabb/aabb3_raycast.js";
|
|
28
13
|
import {
|
|
29
14
|
aabb3_transformed_compute_plane_side
|
|
30
15
|
} from "../../../../../core/geom/3d/aabb/aabb3_transformed_compute_plane_side.js";
|
|
16
|
+
import { ray3_array_apply_matrix4 } from "../../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
|
|
17
|
+
import { ray3_array_compose } from "../../../../../core/geom/3d/ray/ray3_array_compose.js";
|
|
18
|
+
import { SurfacePoint3 } from "../../../../../core/geom/3d/SurfacePoint3.js";
|
|
19
|
+
import { AssetManager } from "../../../../asset/AssetManager.js";
|
|
20
|
+
import { GameAssetType } from "../../../../asset/GameAssetType.js";
|
|
21
|
+
import { AbstractContextSystem } from "../../../../ecs/system/AbstractContextSystem.js";
|
|
22
|
+
import { SystemEntityContext } from "../../../../ecs/system/SystemEntityContext.js";
|
|
23
|
+
import { Transform } from "../../../../ecs/transform/Transform.js";
|
|
24
|
+
import { Reference } from "../../../../reference/v2/Reference.js";
|
|
25
|
+
import { Decal as FPDecal } from '../../../render/forward_plus/model/Decal.js';
|
|
26
|
+
import { ForwardPlusRenderingPlugin } from "../../../render/forward_plus/plugin/ForwardPlusRenderingPlugin.js";
|
|
27
|
+
import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
|
|
31
28
|
import { sampler2d_ensure_uint8_RGBA } from "../../../texture/sampler/sampler2d_ensure_uint8_RGBA.js";
|
|
29
|
+
import { Decal } from "./Decal.js";
|
|
32
30
|
|
|
33
31
|
const placeholder_texture = Sampler2D.uint8(4, 1, 1);
|
|
34
32
|
placeholder_texture.data.fill(255);
|
|
@@ -64,7 +62,7 @@ class Context extends SystemEntityContext {
|
|
|
64
62
|
*/
|
|
65
63
|
__fp_decal = null;
|
|
66
64
|
|
|
67
|
-
#bvh_leaf = new
|
|
65
|
+
#bvh_leaf = new BvhClient();
|
|
68
66
|
|
|
69
67
|
/**
|
|
70
68
|
* @return {ForwardPlusRenderingPlugin}
|
|
@@ -229,7 +227,7 @@ class Context extends SystemEntityContext {
|
|
|
229
227
|
*
|
|
230
228
|
*/
|
|
231
229
|
export class FPDecalSystem extends AbstractContextSystem {
|
|
232
|
-
bvh = new
|
|
230
|
+
bvh = new BVH();
|
|
233
231
|
|
|
234
232
|
/**
|
|
235
233
|
*
|
|
@@ -3,23 +3,22 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
import { assert } from "../../../../core/assert.js";
|
|
7
|
+
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
8
|
+
import { ResourceAccessKind } from "../../../../core/model/ResourceAccessKind.js";
|
|
9
|
+
import { ResourceAccessSpecification } from "../../../../core/model/ResourceAccessSpecification.js";
|
|
10
|
+
import { AbstractContextSystem } from "../../../ecs/system/AbstractContextSystem.js";
|
|
6
11
|
import { Transform } from '../../../ecs/transform/Transform.js';
|
|
7
|
-
import {
|
|
12
|
+
import { ForwardPlusRenderingPlugin } from "../../render/forward_plus/plugin/ForwardPlusRenderingPlugin.js";
|
|
8
13
|
import { Camera } from '../camera/Camera.js';
|
|
9
14
|
|
|
10
15
|
import FrustumProjector from '../camera/FrustumProjector.js';
|
|
11
|
-
import {
|
|
12
|
-
import { CameraClippingPlaneComputer } from "../camera/CameraClippingPlaneComputer.js";
|
|
13
|
-
import { assert } from "../../../../core/assert.js";
|
|
14
|
-
import { ForwardPlusRenderingPlugin } from "../../render/forward_plus/plugin/ForwardPlusRenderingPlugin.js";
|
|
15
|
-
import { ThreeLightCache } from "./three/ThreeLightCache.js";
|
|
16
|
-
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
17
|
-
import { ShadowManager } from "./shadow/ShadowManager.js";
|
|
18
|
-
import { AbstractContextSystem } from "../../../ecs/system/AbstractContextSystem.js";
|
|
16
|
+
import { Light } from './Light.js';
|
|
19
17
|
import { LightContext } from "./LightContext.js";
|
|
18
|
+
import { LightType } from "./LightType.js";
|
|
20
19
|
import { setShadowCameraDimensionsDiscrete } from "./shadow/setShadowCameraDimensionsDiscrete.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
20
|
+
import { ShadowManager } from "./shadow/ShadowManager.js";
|
|
21
|
+
import { ThreeLightCache } from "./three/ThreeLightCache.js";
|
|
23
22
|
|
|
24
23
|
class LightSystem extends AbstractContextSystem {
|
|
25
24
|
/**
|
|
@@ -265,8 +264,6 @@ class LightSystem extends AbstractContextSystem {
|
|
|
265
264
|
}
|
|
266
265
|
}
|
|
267
266
|
|
|
268
|
-
const cameraClippingPlaneComputer = new CameraClippingPlaneComputer();
|
|
269
|
-
|
|
270
267
|
const scratch_aabb3 = new AABB3();
|
|
271
268
|
|
|
272
269
|
/**
|
|
@@ -278,10 +275,6 @@ const scratch_aabb3 = new AABB3();
|
|
|
278
275
|
*/
|
|
279
276
|
function updateShadowMap(camera, light, graphics) {
|
|
280
277
|
|
|
281
|
-
/**
|
|
282
|
-
* @type {RenderLayerManager}
|
|
283
|
-
*/
|
|
284
|
-
const layers = graphics.layers;
|
|
285
278
|
|
|
286
279
|
// Fit shadow camera's ortho frustum to camera frustum
|
|
287
280
|
const shadow = light.shadow;
|
|
@@ -310,43 +303,14 @@ function updateShadowMap(camera, light, graphics) {
|
|
|
310
303
|
|
|
311
304
|
// collect all visible objects
|
|
312
305
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
cameraClippingPlaneComputer.camera = shadowCamera;
|
|
316
|
-
cameraClippingPlaneComputer.layers = layers;
|
|
317
|
-
|
|
318
|
-
cameraClippingPlaneComputer.compute();
|
|
319
|
-
|
|
320
|
-
shadowCamera.near = cameraClippingPlaneComputer.near;
|
|
321
|
-
shadowCamera.far = cameraClippingPlaneComputer.far;
|
|
306
|
+
shadowCamera.near = 0.1;
|
|
307
|
+
shadowCamera.far = 100;
|
|
322
308
|
|
|
323
309
|
shadowCamera.updateProjectionMatrix();
|
|
324
310
|
|
|
325
311
|
// small bias to prevent shadow acne
|
|
326
312
|
shadow.bias = -0.0001;
|
|
327
313
|
|
|
328
|
-
//
|
|
329
|
-
// const frustum = new Frustum();
|
|
330
|
-
// frustumFromCamera(shadowCamera, frustum);
|
|
331
|
-
// visitor.setFrustums([frustum]);
|
|
332
|
-
// visitor.collector = collector;
|
|
333
|
-
//
|
|
334
|
-
// shadow_scene.children = [];
|
|
335
|
-
//
|
|
336
|
-
// const layers_list = layers.layers;
|
|
337
|
-
// const layer_count = layers_list.length;
|
|
338
|
-
//
|
|
339
|
-
// for (let i = 0; i < layer_count; i++) {
|
|
340
|
-
// const renderLayer = layers_list.get(i);
|
|
341
|
-
//
|
|
342
|
-
// collector.callbackContext = shadow_scene.children;
|
|
343
|
-
// collector.callback = Array.prototype.push;
|
|
344
|
-
// collector.reader = renderLayer.extractRenderable;
|
|
345
|
-
//
|
|
346
|
-
// traverseBinaryNodeUsingVisitor(renderLayer.bvh, visitor);
|
|
347
|
-
// }
|
|
348
|
-
//
|
|
349
|
-
// graphics.shadowmap_renderer.update(graphics.renderer, light.shadow, shadow_scene, camera, light);
|
|
350
314
|
}
|
|
351
315
|
|
|
352
316
|
export default LightSystem;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Created by Alex Goldring on 25.02.2015.
|
|
3
3
|
*/
|
|
4
|
-
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
5
|
-
import { getSkeletonBoneByType } from "./SkeletonUtils.js";
|
|
6
4
|
import { assert } from "../../../../core/assert.js";
|
|
5
|
+
import { BvhClient } from "../../../../core/bvh2/bvh3/BvhClient.js";
|
|
6
|
+
import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
|
|
7
|
+
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
8
|
+
import { aabb3_matrix4_project } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
|
|
9
|
+
import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
|
|
7
10
|
import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
|
|
8
11
|
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
9
12
|
import { applyTransformToThreeObject } from "./applyTransformToThreeObject.js";
|
|
10
|
-
import {
|
|
11
|
-
import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
|
|
12
|
-
import { EBBVHLeafProxy } from "../../../../core/bvh2/bvh3/EBBVHLeafProxy.js";
|
|
13
|
-
import { aabb3_matrix4_project } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
|
|
13
|
+
import { getSkeletonBoneByType } from "./SkeletonUtils.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
@@ -71,9 +71,9 @@ class Mesh {
|
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
*
|
|
74
|
-
* @type {
|
|
74
|
+
* @type {BvhClient}
|
|
75
75
|
*/
|
|
76
|
-
this.__bvh_leaf = new
|
|
76
|
+
this.__bvh_leaf = new BvhClient();
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* @private
|
|
@@ -5,12 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { BoxBufferGeometry, MeshLambertMaterial } from "three";
|
|
7
7
|
import { assert } from "../../../../core/assert.js";
|
|
8
|
-
import {
|
|
9
|
-
ExplicitBinaryBoundingVolumeHierarchy
|
|
10
|
-
} from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
11
|
-
import {
|
|
12
|
-
bvh_query_user_data_overlaps_frustum
|
|
13
|
-
} from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
8
|
+
import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
|
|
14
9
|
import { SignalBinding } from "../../../../core/events/signal/SignalBinding.js";
|
|
15
10
|
|
|
16
11
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
@@ -19,6 +14,7 @@ import { ResourceAccessSpecification } from "../../../../core/model/ResourceAcce
|
|
|
19
14
|
import { GLTFAssetLoader } from "../../../asset/loaders/GLTFAssetLoader.js";
|
|
20
15
|
import { System } from "../../../ecs/System.js";
|
|
21
16
|
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
17
|
+
import { make_bvh_visibility_builder } from "../../render/make_bvh_visibility_builder.js";
|
|
22
18
|
|
|
23
19
|
import checkerTexture from "../../texture/CheckersTexture.js";
|
|
24
20
|
|
|
@@ -36,8 +32,6 @@ const PLACEHOLDER_TEXTURE = checkerTexture.create();
|
|
|
36
32
|
|
|
37
33
|
const PLACEHOLDER_MATERIAL = new MeshLambertMaterial({ map: PLACEHOLDER_TEXTURE });
|
|
38
34
|
|
|
39
|
-
const scratch_array = [];
|
|
40
|
-
|
|
41
35
|
export class MeshSystem extends System {
|
|
42
36
|
/**
|
|
43
37
|
*
|
|
@@ -97,10 +91,10 @@ export class MeshSystem extends System {
|
|
|
97
91
|
|
|
98
92
|
/**
|
|
99
93
|
*
|
|
100
|
-
* @type {
|
|
94
|
+
* @type {BVH}
|
|
101
95
|
* @private
|
|
102
96
|
*/
|
|
103
|
-
this.__bvh_binary = new
|
|
97
|
+
this.__bvh_binary = new BVH();
|
|
104
98
|
}
|
|
105
99
|
|
|
106
100
|
/**
|
|
@@ -154,37 +148,19 @@ export class MeshSystem extends System {
|
|
|
154
148
|
const graphics = this.graphics;
|
|
155
149
|
this.renderLayer = graphics.layers.create("mesh-system");
|
|
156
150
|
|
|
157
|
-
this.renderLayer.buildVisibleSet = (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (ecd === null) {
|
|
162
|
-
return 0;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const view_frustum = view.frustum;
|
|
166
|
-
|
|
167
|
-
const hit_count = bvh_query_user_data_overlaps_frustum(scratch_array, 0, this.__bvh_binary, view_frustum);
|
|
168
|
-
|
|
169
|
-
let added = 0;
|
|
170
|
-
|
|
171
|
-
for (let i = 0; i < hit_count; i++) {
|
|
172
|
-
const entity = scratch_array[i];
|
|
173
|
-
|
|
151
|
+
this.renderLayer.buildVisibleSet = make_bvh_visibility_builder(
|
|
152
|
+
this.entityManager, this.__bvh_binary,
|
|
153
|
+
(destination, offset, entity, ecd) => {
|
|
174
154
|
const component = ecd.getComponent(entity, Mesh);
|
|
175
155
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (object3D === null) {
|
|
179
|
-
continue;
|
|
156
|
+
if (component.mesh === null) {
|
|
157
|
+
return 0;
|
|
180
158
|
}
|
|
181
159
|
|
|
182
|
-
destination[
|
|
183
|
-
|
|
160
|
+
destination[offset] = component.mesh;
|
|
161
|
+
return 1;
|
|
184
162
|
}
|
|
185
|
-
|
|
186
|
-
return added;
|
|
187
|
-
};
|
|
163
|
+
)
|
|
188
164
|
|
|
189
165
|
const visibleSet = this.renderLayer.visibleSet;
|
|
190
166
|
|
|
@@ -1,54 +1,14 @@
|
|
|
1
1
|
import { aabb3_matrix4_project } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Common buffer for scratch objects for better cache locality
|
|
5
|
-
* @type {ArrayBuffer}
|
|
6
|
-
*/
|
|
7
|
-
const scratch_buffer = new ArrayBuffer(28 * 4);
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @type {Float32Array}
|
|
12
|
-
*/
|
|
13
|
-
const scratch_matrix4 = new Float32Array(scratch_buffer, 0, 16);
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @type {Float32Array}
|
|
18
|
-
*/
|
|
19
|
-
const scratch_aabb_0 = new Float32Array(scratch_buffer, 64, 6);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @type {Float32Array}
|
|
24
|
-
*/
|
|
25
|
-
const scratch_aabb_1 = new Float32Array(scratch_buffer, 88, 6);
|
|
26
|
-
|
|
27
3
|
/**
|
|
28
4
|
*
|
|
29
|
-
* @param {
|
|
5
|
+
* @param {BvhClient} bvh
|
|
30
6
|
* @param {AABB3} boundingBox
|
|
31
7
|
* @param {Transform} transform
|
|
32
8
|
*/
|
|
33
9
|
export function updateNodeByTransformAndBBB(bvh, boundingBox, transform) {
|
|
34
|
-
transform.
|
|
35
|
-
|
|
36
|
-
updateNodeByMatrix4AndBBB(bvh, boundingBox, scratch_matrix4);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* @param {LeafNode} bvh
|
|
42
|
-
* @param {AABB3} boundingBox
|
|
43
|
-
* @param {ArrayLike<number>|number[]|Float32Array} matrix4
|
|
44
|
-
*/
|
|
45
|
-
export function updateNodeByMatrix4AndBBB(bvh, boundingBox, matrix4) {
|
|
46
|
-
boundingBox.writeToArray(scratch_aabb_1, 0);
|
|
47
|
-
|
|
48
|
-
aabb3_matrix4_project(scratch_aabb_0, scratch_aabb_1, matrix4);
|
|
49
|
-
|
|
50
|
-
bvh.readFromArray(scratch_aabb_0, 0);
|
|
10
|
+
aabb3_matrix4_project(bvh.bounds, boundingBox, transform.matrix);
|
|
51
11
|
|
|
52
|
-
bvh.
|
|
12
|
+
bvh.write_bounds();
|
|
53
13
|
}
|
|
54
14
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { mat4 } from "gl-matrix";
|
|
2
|
+
import { BvhClient } from "../../../../core/bvh2/bvh3/BvhClient.js";
|
|
1
3
|
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
2
|
-
import {
|
|
3
|
-
import { ShadedGeometryFlags } from "./ShadedGeometryFlags.js";
|
|
4
|
+
import { aabb3_from_threejs_geometry } from "../../../../core/geom/3d/aabb/aabb3_from_threejs_geometry.js";
|
|
4
5
|
import { aabb3_matrix4_project } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
|
|
5
|
-
import { mat4 } from "gl-matrix";
|
|
6
6
|
import { ray3_array_apply_matrix4 } from "../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
|
|
7
7
|
import { GeometrySpatialQueryAccelerator } from "../../geometry/buffered/query/GeometrySpatialQueryAccelerator.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { DrawMode } from "./DrawMode.js";
|
|
9
|
+
import { ShadedGeometryFlags } from "./ShadedGeometryFlags.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @readonly
|
|
@@ -60,7 +60,7 @@ export class ShadedGeometry {
|
|
|
60
60
|
*/
|
|
61
61
|
this.depth_material = null;
|
|
62
62
|
|
|
63
|
-
this.__bvh_leaf = new
|
|
63
|
+
this.__bvh_leaf = new BvhClient();
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Transient, assigned in the system
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import {BVH} from "../../../../core/bvh2/bvh3/BVH";
|
|
2
|
+
import {SurfacePoint3} from "../../../../core/geom/3d/SurfacePoint3";
|
|
1
3
|
import {System} from "../../../ecs/System";
|
|
2
4
|
import Engine from "../../../Engine";
|
|
3
5
|
import {ShadedGeometry} from "./ShadedGeometry";
|
|
4
|
-
import {SurfacePoint3} from "../../../../core/geom/3d/SurfacePoint3";
|
|
5
|
-
import {ExplicitBinaryBoundingVolumeHierarchy} from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy";
|
|
6
6
|
|
|
7
7
|
export class ShadedGeometrySystem extends System<ShadedGeometry> {
|
|
8
8
|
constructor(engine: Engine)
|
|
9
9
|
|
|
10
|
-
readonly bvh:
|
|
10
|
+
readonly bvh: BVH
|
|
11
11
|
|
|
12
12
|
raycastNearest(
|
|
13
13
|
contact: SurfacePoint3,
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import { ShadedGeometry } from "./ShadedGeometry.js";
|
|
2
|
-
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
3
|
-
import { System } from "../../../ecs/System.js";
|
|
4
|
-
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
5
|
-
import { v3_distance_sqr } from "../../../../core/geom/vec3/v3_distance_sqr.js";
|
|
6
1
|
import { mat4 } from "gl-matrix";
|
|
7
|
-
import { returnTrue } from "../../../../core/function/Functions.js";
|
|
8
|
-
import { ShadedGeometryRendererContext } from "./render/ShadedGeometryRendererContext.js";
|
|
9
2
|
import { assert } from "../../../../core/assert.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
ExplicitBinaryBoundingVolumeHierarchy
|
|
13
|
-
} from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
3
|
+
import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
|
|
14
4
|
import { bvh_query_leaves_generic } from "../../../../core/bvh2/bvh3/query/bvh_query_leaves_generic.js";
|
|
5
|
+
import {
|
|
6
|
+
bvh_query_user_data_overlaps_frustum
|
|
7
|
+
} from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
15
8
|
import { BVHQueryIntersectsRay } from "../../../../core/bvh2/bvh3/query/BVHQueryIntersectsRay.js";
|
|
9
|
+
import { returnTrue } from "../../../../core/function/Functions.js";
|
|
10
|
+
import { ray3_array_compose } from "../../../../core/geom/3d/ray/ray3_array_compose.js";
|
|
11
|
+
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
12
|
+
import { v3_distance_sqr } from "../../../../core/geom/vec3/v3_distance_sqr.js";
|
|
16
13
|
import Task from "../../../../core/process/task/Task.js";
|
|
17
|
-
import { RuntimeDrawMethodOptimizer } from "./render/optimization/RuntimeDrawMethodOptimizer.js";
|
|
18
14
|
import { TaskSignal } from "../../../../core/process/task/TaskSignal.js";
|
|
19
15
|
import TaskState from "../../../../core/process/task/TaskState.js";
|
|
20
|
-
import {
|
|
21
|
-
bvh_query_user_data_overlaps_frustum
|
|
22
|
-
} from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
23
16
|
import { iteratorTask } from "../../../../core/process/task/util/iteratorTask.js";
|
|
17
|
+
import { System } from "../../../ecs/System.js";
|
|
18
|
+
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
19
|
+
import { RuntimeDrawMethodOptimizer } from "./render/optimization/RuntimeDrawMethodOptimizer.js";
|
|
20
|
+
import { ShadedGeometryRendererContext } from "./render/ShadedGeometryRendererContext.js";
|
|
21
|
+
import { ShadedGeometry } from "./ShadedGeometry.js";
|
|
24
22
|
|
|
25
23
|
|
|
26
24
|
/**
|
|
@@ -106,10 +104,10 @@ export class ShadedGeometrySystem extends System {
|
|
|
106
104
|
|
|
107
105
|
/**
|
|
108
106
|
*
|
|
109
|
-
* @type {
|
|
107
|
+
* @type {BVH}
|
|
110
108
|
* @private
|
|
111
109
|
*/
|
|
112
|
-
this.__bvh_binary = new
|
|
110
|
+
this.__bvh_binary = new BVH();
|
|
113
111
|
|
|
114
112
|
const optimizer = new RuntimeDrawMethodOptimizer();
|
|
115
113
|
|
|
@@ -137,7 +135,7 @@ export class ShadedGeometrySystem extends System {
|
|
|
137
135
|
|
|
138
136
|
/**
|
|
139
137
|
*
|
|
140
|
-
* @returns {
|
|
138
|
+
* @returns {BVH}
|
|
141
139
|
*/
|
|
142
140
|
get bvh() {
|
|
143
141
|
return this.__bvh_binary;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { AbstractRenderAdapter } from "./adapters/AbstractRenderAdapter.js";
|
|
2
|
-
import { InstancedRendererAdapter } from "./adapters/InstancedRendererAdapter.js";
|
|
3
|
-
import { GenericRendererAdapter } from "./adapters/GenericRendererAdapter.js";
|
|
4
1
|
import { assert } from "../../../../../core/assert.js";
|
|
5
|
-
import { ShadedGeometry } from "../ShadedGeometry.js";
|
|
6
2
|
import {
|
|
7
3
|
bvh_query_user_data_overlaps_frustum
|
|
8
4
|
} from "../../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
5
|
+
import { ShadedGeometry } from "../ShadedGeometry.js";
|
|
9
6
|
import { ShadedGeometryFlags } from "../ShadedGeometryFlags.js";
|
|
7
|
+
import { AbstractRenderAdapter } from "./adapters/AbstractRenderAdapter.js";
|
|
8
|
+
import { GenericRendererAdapter } from "./adapters/GenericRendererAdapter.js";
|
|
9
|
+
import { InstancedRendererAdapter } from "./adapters/InstancedRendererAdapter.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
@@ -95,7 +95,7 @@ export class ShadedGeometryRendererContext {
|
|
|
95
95
|
* @param {number} destination_offset
|
|
96
96
|
* @param {THREE.WebGLRenderer} renderer
|
|
97
97
|
* @param {CameraView} view
|
|
98
|
-
* @param {
|
|
98
|
+
* @param {BVH} bvh
|
|
99
99
|
* @param {EntityComponentDataset} ecd
|
|
100
100
|
*/
|
|
101
101
|
collect(destination, destination_offset, renderer, view, bvh, ecd) {
|