@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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
import { mat4 } from "gl-matrix";
|
|
6
7
|
import {
|
|
7
8
|
ClampToEdgeWrapping,
|
|
8
9
|
DataTexture,
|
|
@@ -12,82 +13,105 @@ import {
|
|
|
12
13
|
RedFormat,
|
|
13
14
|
UnsignedByteType
|
|
14
15
|
} from 'three';
|
|
16
|
+
import { assert } from "../../../../core/assert.js";
|
|
17
|
+
import { BvhClient } from "../../../../core/bvh2/bvh3/BvhClient.js";
|
|
18
|
+
import { IllegalStateException } from "../../../../core/fsm/exceptions/IllegalStateException.js";
|
|
19
|
+
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
20
|
+
import Vector2 from '../../../../core/geom/Vector2.js';
|
|
15
21
|
import { clamp } from "../../../../core/math/clamp.js";
|
|
22
|
+
import { GameAssetType } from "../../../asset/GameAssetType.js";
|
|
23
|
+
import { SplatMaterial } from "../../../graphics/material/SplatMaterial.js";
|
|
16
24
|
import { Sampler2D } from '../../../graphics/texture/sampler/Sampler2D.js';
|
|
17
|
-
import {
|
|
18
|
-
import Vector2 from '../../../../core/geom/Vector2.js';
|
|
25
|
+
import { WHITE_PIXEL_DATA_URL } from "../../../graphics/WHITE_PIXEL_DATA_URL.js";
|
|
19
26
|
import { TerrainOverlay } from '../overlay/TerrainOverlay.js';
|
|
20
27
|
|
|
21
28
|
import Clouds from '../TerrainClouds.js';
|
|
29
|
+
import { TerrainPreview } from "../TerrainPreview.js";
|
|
22
30
|
|
|
23
31
|
import TerrainTileManager from '../tiles/TerrainTileManager.js';
|
|
24
|
-
import {
|
|
25
|
-
import { assert } from "../../../../core/assert.js";
|
|
26
|
-
import { GameAssetType } from "../../../asset/GameAssetType.js";
|
|
27
|
-
import { TerrainLayers } from "./layers/TerrainLayers.js";
|
|
28
|
-
import { SplatMaterial } from "../../../graphics/material/SplatMaterial.js";
|
|
29
|
-
import { SplatMapping } from "./splat/SplatMapping.js";
|
|
30
|
-
import { OffsetScaleTransform2D } from "./OffsetScaleTransform2D.js";
|
|
32
|
+
import { buildLightTexture } from "./BuildLightTexture.js";
|
|
31
33
|
import { GridTransformKind } from "./GridTransformKind.js";
|
|
34
|
+
import { TerrainLayers } from "./layers/TerrainLayers.js";
|
|
32
35
|
import { makeTerrainWorkerProxy } from "./makeTerrainWorkerProxy.js";
|
|
36
|
+
import { OffsetScaleTransform2D } from "./OffsetScaleTransform2D.js";
|
|
37
|
+
import { SplatMapping } from "./splat/SplatMapping.js";
|
|
33
38
|
import { TerrainFlags } from "./TerrainFlags.js";
|
|
34
|
-
import { IllegalStateException } from "../../../../core/fsm/exceptions/IllegalStateException.js";
|
|
35
|
-
import { buildLightTexture } from "./BuildLightTexture.js";
|
|
36
|
-
import { WHITE_PIXEL_DATA_URL } from "../../../graphics/WHITE_PIXEL_DATA_URL.js";
|
|
37
|
-
import { mat4 } from "gl-matrix";
|
|
38
|
-
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
39
39
|
|
|
40
40
|
let idCounter = 0;
|
|
41
41
|
|
|
42
42
|
class Terrain {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this.id = idCounter++;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @type {number}
|
|
46
|
+
*/
|
|
47
|
+
id = idCounter++;
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
/**
|
|
50
|
+
* @private
|
|
51
|
+
* @type {number|TerrainFlags}
|
|
52
|
+
*/
|
|
53
|
+
flags = 0;
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @type {number}
|
|
58
|
+
*/
|
|
59
|
+
gridScale = 1;
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Transform from grid coordinate system to world coordinate system
|
|
63
|
+
* @type {OffsetScaleTransform2D}
|
|
64
|
+
*/
|
|
65
|
+
gridTransform = new OffsetScaleTransform2D();
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @type {number}
|
|
70
|
+
*/
|
|
71
|
+
gridTransformKind = GridTransformKind.Direct;
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Number of geometric subdivisions per single terrain tile
|
|
75
|
+
* @example if value is set to 4, each tile will be split into 4x4 quads
|
|
76
|
+
* @type {number}
|
|
77
|
+
*/
|
|
78
|
+
resolution = 4;
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
/**
|
|
81
|
+
* @readonly
|
|
82
|
+
* @type {Vector2}
|
|
83
|
+
*/
|
|
84
|
+
size = new Vector2(0, 0);
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @type {TerrainPreview}
|
|
88
|
+
*/
|
|
89
|
+
preview = new TerrainPreview();
|
|
90
|
+
/**
|
|
91
|
+
* @readonly
|
|
92
|
+
* @type {SplatMapping}
|
|
93
|
+
*/
|
|
94
|
+
splat = new SplatMapping();
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @readonly
|
|
98
|
+
* @type {TerrainLayers}
|
|
99
|
+
*/
|
|
100
|
+
layers = new TerrainLayers();
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @readonly
|
|
104
|
+
* @type {WorkerProxy}
|
|
105
|
+
*/
|
|
106
|
+
__buildWorker = makeTerrainWorkerProxy();
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @readonly
|
|
110
|
+
* @type {BvhClient}
|
|
111
|
+
*/
|
|
112
|
+
bvh = new BvhClient();
|
|
113
|
+
|
|
114
|
+
constructor() {
|
|
91
115
|
|
|
92
116
|
/**
|
|
93
117
|
*
|
|
@@ -96,23 +120,12 @@ class Terrain {
|
|
|
96
120
|
this.clouds = new Clouds();
|
|
97
121
|
this.clouds.enabled = true;
|
|
98
122
|
|
|
99
|
-
/**
|
|
100
|
-
* @deprecated
|
|
101
|
-
* @type {String}
|
|
102
|
-
*/
|
|
103
|
-
this.heightMapURL = null;
|
|
104
|
-
|
|
105
123
|
/**
|
|
106
124
|
* @deprecated
|
|
107
125
|
* @type {number}
|
|
108
126
|
*/
|
|
109
127
|
this.heightRange = 0;
|
|
110
128
|
|
|
111
|
-
/**
|
|
112
|
-
*
|
|
113
|
-
* @type {SplatMapping}
|
|
114
|
-
*/
|
|
115
|
-
this.splat = new SplatMapping();
|
|
116
129
|
|
|
117
130
|
/**
|
|
118
131
|
*
|
|
@@ -139,12 +152,6 @@ class Terrain {
|
|
|
139
152
|
this.heightTexture.internalFormat = 'R32F';
|
|
140
153
|
|
|
141
154
|
|
|
142
|
-
/**
|
|
143
|
-
*
|
|
144
|
-
* @type {TerrainLayers}
|
|
145
|
-
*/
|
|
146
|
-
this.layers = new TerrainLayers();
|
|
147
|
-
|
|
148
155
|
/**
|
|
149
156
|
* @type {ShaderMaterial}
|
|
150
157
|
*/
|
|
@@ -170,18 +177,6 @@ class Terrain {
|
|
|
170
177
|
*/
|
|
171
178
|
this.overlay = new TerrainOverlay(this.size);
|
|
172
179
|
|
|
173
|
-
/**
|
|
174
|
-
*
|
|
175
|
-
* @type {BinaryNode}
|
|
176
|
-
*/
|
|
177
|
-
this.bvh = new BinaryNode();
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
*
|
|
181
|
-
* @type {WorkerProxy}
|
|
182
|
-
*/
|
|
183
|
-
this.__buildWorker = makeTerrainWorkerProxy();
|
|
184
|
-
|
|
185
180
|
/**
|
|
186
181
|
*
|
|
187
182
|
* @type {TerrainTileManager}
|
|
@@ -332,6 +327,8 @@ class Terrain {
|
|
|
332
327
|
|
|
333
328
|
this.heightTexture.dispose();
|
|
334
329
|
|
|
330
|
+
this.bvh.unlink();
|
|
331
|
+
|
|
335
332
|
this.clearFlag(TerrainFlags.Linked);
|
|
336
333
|
}
|
|
337
334
|
|
|
@@ -769,8 +766,7 @@ class Terrain {
|
|
|
769
766
|
|
|
770
767
|
this.buildGridTransform();
|
|
771
768
|
|
|
772
|
-
this.bvh.
|
|
773
|
-
this.bvh.setNegativelyInfiniteBounds();
|
|
769
|
+
this.bvh.resize(0, 0, 0, 0, 0, 0);
|
|
774
770
|
|
|
775
771
|
//
|
|
776
772
|
this.overlay.size.copy(this.size);
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { System } from '../../System.js';
|
|
2
|
-
import Terrain from './Terrain.js';
|
|
3
|
-
import { CameraSystem } from '../../../graphics/ecs/camera/CameraSystem.js';
|
|
4
1
|
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
|
|
3
|
+
import {
|
|
4
|
+
bvh_query_user_data_overlaps_frustum
|
|
5
|
+
} from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
5
6
|
import { noop } from "../../../../core/function/Functions.js";
|
|
6
|
-
import {
|
|
7
|
+
import { read_frustum_planes_to_array } from "../../../../core/geom/3d/frustum/read_frustum_planes_to_array.js";
|
|
8
|
+
import { MATRIX_4_IDENTITY } from "../../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
|
|
7
9
|
import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
|
|
10
|
+
import { CameraSystem } from '../../../graphics/ecs/camera/CameraSystem.js';
|
|
11
|
+
import { System } from '../../System.js';
|
|
8
12
|
import { Transform } from "../../transform/Transform.js";
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
13
|
+
import Terrain from './Terrain.js';
|
|
14
|
+
import { TerrainFlags } from "./TerrainFlags.js";
|
|
11
15
|
|
|
12
16
|
/**
|
|
13
17
|
*
|
|
@@ -24,6 +28,30 @@ function ensureTileBuilt(tile, tileManager) {
|
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
class TerrainSystem extends System {
|
|
31
|
+
dependencies = [Terrain];
|
|
32
|
+
|
|
33
|
+
gridScaleX = 1;
|
|
34
|
+
gridScaleY = 1;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @type {number}
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
__time_delta = 0;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @type {RenderLayer|null}
|
|
46
|
+
*/
|
|
47
|
+
renderLayer = null;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @type {BVH}
|
|
52
|
+
*/
|
|
53
|
+
bvh = new BVH();
|
|
54
|
+
|
|
27
55
|
/**
|
|
28
56
|
*
|
|
29
57
|
* @param {GraphicsEngine} graphics
|
|
@@ -44,30 +72,7 @@ class TerrainSystem extends System {
|
|
|
44
72
|
|
|
45
73
|
this.graphics = graphics;
|
|
46
74
|
|
|
47
|
-
this.dependencies = [Terrain];
|
|
48
75
|
this.assetManager = assetManager;
|
|
49
|
-
|
|
50
|
-
this.gridScaleX = 1;
|
|
51
|
-
this.gridScaleY = 1;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
* @type {RenderLayer|null}
|
|
56
|
-
*/
|
|
57
|
-
this.renderLayer = null;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
* @type {BinaryNode}
|
|
62
|
-
*/
|
|
63
|
-
this.bvh = null;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
*
|
|
67
|
-
* @type {number}
|
|
68
|
-
* @private
|
|
69
|
-
*/
|
|
70
|
-
this.__time_delta = 0;
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
mapPointGrid2World(x, y, v3) {
|
|
@@ -83,18 +88,51 @@ class TerrainSystem extends System {
|
|
|
83
88
|
|
|
84
89
|
this.renderLayer = this.graphics.layers.create('terrain-system');
|
|
85
90
|
|
|
86
|
-
/**
|
|
87
|
-
*
|
|
88
|
-
* @param {TerrainTile} tile
|
|
89
|
-
* @returns {THREE.Object3D}
|
|
90
|
-
*/
|
|
91
|
-
function extractRenderable(tile) {
|
|
92
|
-
return tile.mesh;
|
|
93
|
-
}
|
|
94
91
|
|
|
95
|
-
this.renderLayer.
|
|
92
|
+
this.renderLayer.buildVisibleSet = (destination, destination_offset, view) => {
|
|
93
|
+
const em = this.entityManager;
|
|
94
|
+
|
|
95
|
+
if (em === null) {
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const ecd = em.dataset;
|
|
100
|
+
|
|
101
|
+
if (ecd === null) {
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const tiles = [];
|
|
106
|
+
|
|
107
|
+
let match_count = 0;
|
|
96
108
|
|
|
97
|
-
|
|
109
|
+
ecd.traverseComponents(Terrain, (component, entity) => {
|
|
110
|
+
const tile_manager = component.tiles;
|
|
111
|
+
|
|
112
|
+
const hit_count = bvh_query_user_data_overlaps_frustum(
|
|
113
|
+
tiles, 0,
|
|
114
|
+
tile_manager.bvh, view.frustum
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
for (let i = 0; i < hit_count; i++) {
|
|
118
|
+
|
|
119
|
+
const tile_index = tiles[i];
|
|
120
|
+
|
|
121
|
+
const tile = tile_manager.tiles[tile_index];
|
|
122
|
+
|
|
123
|
+
if (!tile.isBuilt) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
destination[destination_offset + match_count] = tile.mesh;
|
|
128
|
+
|
|
129
|
+
match_count++;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
return match_count;
|
|
135
|
+
};
|
|
98
136
|
|
|
99
137
|
const am = this.assetManager;
|
|
100
138
|
|
|
@@ -133,14 +171,7 @@ class TerrainSystem extends System {
|
|
|
133
171
|
|
|
134
172
|
component.link(this.graphics);
|
|
135
173
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
//record entity for editor
|
|
140
|
-
bvh.entity = entity;
|
|
141
|
-
|
|
142
|
-
//set render layer BVH to one maintained by TilesEngine
|
|
143
|
-
this.renderLayer.bvh = bvh;
|
|
174
|
+
component.bvh.link(this.bvh, entity);
|
|
144
175
|
}
|
|
145
176
|
|
|
146
177
|
/**
|
|
@@ -149,12 +180,6 @@ class TerrainSystem extends System {
|
|
|
149
180
|
* @param entity
|
|
150
181
|
*/
|
|
151
182
|
unlink(component, entity) {
|
|
152
|
-
|
|
153
|
-
if (this.renderLayer.bvh === component.__tiles.bvh) {
|
|
154
|
-
// remove from render index
|
|
155
|
-
this.renderLayer.bvh = new BinaryNode();
|
|
156
|
-
}
|
|
157
|
-
|
|
158
183
|
component.unlink();
|
|
159
184
|
}
|
|
160
185
|
|
|
@@ -217,12 +242,36 @@ class TerrainSystem extends System {
|
|
|
217
242
|
assert.notEqual(terrain, undefined, 'terrain is undefined');
|
|
218
243
|
|
|
219
244
|
const tileManager = terrain.__tiles;
|
|
245
|
+
|
|
246
|
+
const tiles = [];
|
|
247
|
+
const set = new Set();
|
|
248
|
+
let tile_count = 0;
|
|
249
|
+
|
|
250
|
+
const frustum = new Float32Array(24);
|
|
251
|
+
|
|
220
252
|
if (tileManager !== undefined) {
|
|
221
253
|
CameraSystem.getActiveFrustums(ecd, function (frustums) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
254
|
+
let found_tiles = 0;
|
|
255
|
+
|
|
256
|
+
for (let i = 0; i < frustums.length; i++) {
|
|
257
|
+
|
|
258
|
+
read_frustum_planes_to_array(frustums[i].planes, frustum);
|
|
259
|
+
|
|
260
|
+
found_tiles += bvh_query_user_data_overlaps_frustum(tiles, tile_count, tileManager.bvh, frustum);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
for (let i = 0; i < found_tiles; i++) {
|
|
264
|
+
const tile_index = tiles[i];
|
|
265
|
+
|
|
266
|
+
if (!set.has(tile_index)) {
|
|
267
|
+
const tile = tileManager.tiles[tile_index];
|
|
268
|
+
|
|
269
|
+
callback(tile, tileManager);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
set.add(tile_index);
|
|
273
|
+
}
|
|
274
|
+
|
|
226
275
|
});
|
|
227
276
|
}
|
|
228
277
|
}
|
|
@@ -64,12 +64,15 @@ export function makeTerrainWorkerProxy() {
|
|
|
64
64
|
|
|
65
65
|
// var timerName = 'building bvh '+(geometry.indices.length/3);
|
|
66
66
|
// console.time(timerName);
|
|
67
|
-
const bvh = Lib.
|
|
67
|
+
const bvh = Lib.build_bvh(geometry.vertices, geometry.indices);
|
|
68
68
|
// console.timeEnd(timerName);
|
|
69
69
|
|
|
70
70
|
resolve({
|
|
71
71
|
geometry: geometry,
|
|
72
|
-
bvh:
|
|
72
|
+
bvh: {
|
|
73
|
+
leaf_count: bvh.getLeafNodeCount(),
|
|
74
|
+
data: bvh.data
|
|
75
|
+
}
|
|
73
76
|
});
|
|
74
77
|
} catch (e) {
|
|
75
78
|
reject(e);
|