@woosh/meep-engine 2.65.0 → 2.67.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.
Files changed (60) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +51290 -54244
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +51290 -54244
  5. package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +4 -10
  6. package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +7 -7
  7. package/editor/tools/SelectionTool.js +6 -95
  8. package/package.json +1 -1
  9. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +118 -113
  10. package/src/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
  11. package/src/core/bvh2/binary/2/bvh32_query_user_data_ray.js +98 -0
  12. package/src/core/bvh2/bvh3/BVH.d.ts +1 -1
  13. package/src/core/bvh2/bvh3/BvhClient.d.ts +11 -0
  14. package/src/core/bvh2/bvh3/BvhClient.js +19 -0
  15. package/src/core/collection/array/array_copy.js +6 -0
  16. package/src/core/geom/3d/aabb/aabb3_array_combine.js +17 -8
  17. package/src/core/geom/3d/aabb/aabb3_array_intersects_ray.js +5 -2
  18. package/src/core/geom/3d/aabb/aabb3_array_set.js +25 -0
  19. package/src/core/geom/3d/aabb/aabb3_compute_half_surface_area.js +3 -0
  20. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +8 -1
  21. package/src/engine/EngineHarness.js +23 -25
  22. package/src/engine/ecs/renderable/RenderSystem.js +44 -32
  23. package/src/engine/ecs/renderable/Renderable.d.ts +2 -2
  24. package/src/engine/ecs/renderable/Renderable.js +12 -11
  25. package/src/engine/ecs/terrain/ecs/Terrain.js +83 -87
  26. package/src/engine/ecs/terrain/ecs/TerrainSystem.js +106 -57
  27. package/src/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +5 -2
  28. package/src/engine/ecs/terrain/tiles/TerrainTile.js +122 -67
  29. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +162 -146
  30. package/src/engine/ecs/terrain/tiles/TileBuildWorker.js +16 -5
  31. package/src/engine/graphics/GraphicsEngine.js +16 -25
  32. package/src/engine/graphics/camera/testClippingPlaneComputation.js +8 -11
  33. package/src/engine/graphics/debug/VisualSymbolLine.js +1 -0
  34. package/src/engine/graphics/ecs/camera/CameraSystem.js +9 -9
  35. package/src/engine/graphics/ecs/camera/auto_set_camera_clipping_planes.js +3 -23
  36. package/src/engine/graphics/ecs/compileAllMaterials.js +5 -12
  37. package/src/engine/graphics/ecs/light/LightSystem.js +12 -48
  38. package/src/engine/graphics/ecs/mesh/MeshSystem.js +9 -31
  39. package/src/engine/graphics/ecs/mesh/updateNodeByTransformAndBBB.js +3 -43
  40. package/src/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +22 -24
  41. package/src/engine/graphics/ecs/mesh-v2/sample/prototype_sg_raycast.js +21 -23
  42. package/src/engine/graphics/ecs/trail2d/Trail2D.js +105 -106
  43. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.js +60 -61
  44. package/src/engine/graphics/ecs/trail2d/makeGradientTrail.js +3 -3
  45. package/src/engine/graphics/ecs/water/WATER_SIZE.js +1 -0
  46. package/src/engine/graphics/ecs/water/Water.js +84 -42
  47. package/src/engine/graphics/ecs/water/WaterSystem.js +53 -105
  48. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +13 -7
  49. package/src/engine/graphics/geometry/bvh/buffered/bvh32_from_indexed_geometry.js +58 -0
  50. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.js +32 -62
  51. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1 -1
  52. package/src/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +8 -11
  53. package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +21 -19
  54. package/src/engine/graphics/render/layers/RenderLayer.d.ts +4 -3
  55. package/src/engine/graphics/render/layers/RenderLayer.js +34 -108
  56. package/src/engine/graphics/render/make_bvh_visibility_builder.js +64 -0
  57. package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +4 -4
  58. package/src/engine/graphics/trail/x/RibbonX.js +26 -5
  59. package/src/core/bvh2/binary/tiny/TinyBVH.js +0 -221
  60. package/src/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +0 -138
@@ -1,21 +1,42 @@
1
1
  /**
2
2
  * Created by Alex on 17/02/2017.
3
3
  */
4
- import { BackSide, Plane, PlaneBufferGeometry, Vector3 as ThreeVector3 } from 'three';
4
+ import { BackSide, PlaneBufferGeometry } from 'three';
5
+ import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
5
6
  import { System } from '../../../ecs/System.js';
6
- import Water from './Water.js';
7
- import { LeafNode } from '../../../../core/bvh2/LeafNode.js';
8
- import { buildPlanarRenderLayerClipPlaneComputationMethod } from "../../render/layers/RenderLayerUtils.js";
7
+ import { obtainTerrain } from "../../../ecs/terrain/util/obtainTerrain.js";
8
+ import { make_bvh_visibility_builder } from "../../render/make_bvh_visibility_builder.js";
9
+ import { StandardFrameBuffers } from "../../StandardFrameBuffers.js";
9
10
  import ThreeFactory from "../../three/ThreeFactory.js";
10
- import { RenderPassType } from "../../render/RenderPassType.js";
11
11
  import { makeAlexWaterMaterial } from "../water2/shader/AlexWaterShader.js";
12
- import { threeUpdateTransform } from "../../util/threeUpdateTransform.js";
13
- import { StandardFrameBuffers } from "../../StandardFrameBuffers.js";
14
- import { obtainTerrain } from "../../../ecs/terrain/util/obtainTerrain.js";
15
-
16
- const WATER_SIZE = 800;
12
+ import Water from './Water.js';
13
+ import { WATER_SIZE } from "./WATER_SIZE.js";
17
14
 
18
15
  class WaterSystem extends System {
16
+ dependencies = [Water];
17
+
18
+ /**
19
+ * @readonly
20
+ * @type {BVH}
21
+ */
22
+ bvh = new BVH();
23
+
24
+
25
+ cleaup = [];
26
+
27
+ /**
28
+ *
29
+ * @type {Water[]}
30
+ */
31
+ updateQueue = [];
32
+
33
+ /**
34
+ *
35
+ * @type {number}
36
+ * @private
37
+ */
38
+ __time_delta = 0;
39
+
19
40
  /**
20
41
  *
21
42
  * @param {GraphicsEngine} graphics
@@ -24,7 +45,6 @@ class WaterSystem extends System {
24
45
  constructor(graphics) {
25
46
  super();
26
47
 
27
- this.dependencies = [Water];
28
48
 
29
49
  this.graphicsEngine = graphics;
30
50
 
@@ -34,29 +54,6 @@ class WaterSystem extends System {
34
54
  */
35
55
  this.renderLayer = null;
36
56
 
37
- /**
38
- *
39
- * @type {BinaryNode}
40
- */
41
- this.bvh = null;
42
-
43
- //TODO override "computeFrustumClippingPlanes", this is a hack to get camera system to work as indeded when computing clipping planes
44
- //TODO come up with a less convoluted design
45
-
46
- this.cleaup = [];
47
-
48
- /**
49
- *
50
- * @type {Water[]}
51
- */
52
- this.updateQueue = [];
53
-
54
- /**
55
- *
56
- * @type {number}
57
- * @private
58
- */
59
- this.__time_delta = 0;
60
57
  }
61
58
 
62
59
 
@@ -81,43 +78,21 @@ class WaterSystem extends System {
81
78
 
82
79
  const viewport_size = graphicsEngine.viewport.size;
83
80
 
84
- this.renderLayer.extractRenderable = function (component) {
85
- return component.__threeObject;
86
- };
81
+ this.renderLayer.buildVisibleSet = make_bvh_visibility_builder(
82
+ this.entityManager, this.bvh,
83
+ (destination, offset, entity, ecd) => {
84
+ const component = ecd.getComponent(entity, Water);
87
85
 
88
- this.renderLayer.renderPass = RenderPassType.Transparent;
86
+ const mesh = component.__threeObject;
89
87
 
90
- /**
91
- *
92
- * @param {Frustum} frustum
93
- * @param {function(near:number, far:number)} visitor
94
- */
95
- this.renderLayer.computeNearFarClippingPlanes = buildPlanarRenderLayerClipPlaneComputationMethod(function (visitor) {
88
+ if (mesh === null) {
89
+ return 0
90
+ }
96
91
 
97
- /**
98
- *
99
- * @type {EntityComponentDataset}
100
- */
101
- const dataset = entityManager.dataset;
102
-
103
- /**
104
- *
105
- * @param {Water} water
106
- * @param entity
107
- */
108
- function componentVisitor(water, entity) {
109
-
110
- //determinate the plane
111
- const plane = new Plane(new ThreeVector3(0, 1, 0), water.level.getValue());
112
-
113
- visitor(plane);
92
+ destination[offset] = mesh;
93
+ return 1;
114
94
  }
115
-
116
- dataset.traverseComponents(Water, componentVisitor);
117
- });
118
-
119
-
120
- this.bvh = this.renderLayer.bvh;
95
+ )
121
96
 
122
97
 
123
98
  const self = this;
@@ -191,64 +166,37 @@ class WaterSystem extends System {
191
166
 
192
167
  water.side = BackSide;
193
168
 
194
- /**
195
- * @type {Object3D}
196
- */
197
- let mesh;
198
169
  if (component.__threeObject === null) {
199
170
  const geometry = new PlaneBufferGeometry(width, height, 1, 1);
200
171
 
201
- mesh = ThreeFactory.createMesh(
172
+ const mesh = ThreeFactory.createMesh(
202
173
  geometry,
203
174
  water
204
175
  );
205
176
 
206
-
207
177
  component.__threeObject = mesh;
208
- } else {
209
- mesh = component.__threeObject;
210
178
  }
211
179
 
212
- mesh.rotation.x = Math.PI * 0.5;
213
- mesh.position.x = width / 4;
214
- mesh.position.z = height / 4;
215
- mesh.position.y = component.level.getValue();
216
-
217
- threeUpdateTransform(mesh);
180
+ component.updateTransform();
218
181
 
219
- const leafNode = new LeafNode(
220
- component,
182
+ component.level.onChanged.add(component.updateTransform, component);
221
183
 
222
- -width / 4,
223
- component.level.getValue(),
224
- -height / 4,
225
- width * (3 / 4),
226
- component.level.getValue(),
227
- height * (3 / 4)
228
- );
229
-
230
- component.bvh = leafNode;
231
-
232
- function processLevelValue(v, oldV) {
233
- mesh.position.y = v;
234
- threeUpdateTransform(mesh);
235
-
236
- leafNode.move(0, 0, v - oldV);
237
- }
238
-
239
- component.level.onChanged.add(processLevelValue);
240
-
241
- this.bvh.insertNode(leafNode);
184
+ component.bvh.link(this.bvh, entity);
242
185
 
243
186
  this.cleaup[entity] = function () {
244
- component.level.onChanged.remove(processLevelValue);
187
+ component.level.onChanged.remove(component.updateTransform, component);
245
188
  };
246
189
 
247
190
  this.updateQueue.push(component);
248
191
  }
249
192
 
193
+ /**
194
+ *
195
+ * @param {Water} component
196
+ * @param {number} entity
197
+ */
250
198
  unlink(component, entity) {
251
- component.bvh.disconnect();
199
+ component.bvh.unlink();
252
200
 
253
201
  const cleaup = this.cleaup[entity];
254
202
  cleaup();
@@ -1,15 +1,15 @@
1
- import Vector3 from "../../../../../core/geom/Vector3.js";
1
+ import { mat4 } from "gl-matrix";
2
2
 
3
3
  import { Vector3 as ThreeVector3 } from 'three';
4
- import { rayTriangleIntersection } from "../../../../../core/geom/3d/triangle/rayTriangleIntersection.js";
5
- import { SurfacePoint3 } from "../../../../../core/geom/3d/SurfacePoint3.js";
6
4
  import { assert } from "../../../../../core/assert.js";
7
- import { v3_length } from "../../../../../core/geom/vec3/v3_length.js";
8
- import { ray3_array_apply_matrix4 } from "../../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
9
- import { mat4 } from "gl-matrix";
10
- import { ray3_array_compose } from "../../../../../core/geom/3d/ray/ray3_array_compose.js";
11
5
  import { array_copy } from "../../../../../core/collection/array/array_copy.js";
12
6
  import { MATRIX_4_IDENTITY } from "../../../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
7
+ import { ray3_array_apply_matrix4 } from "../../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
8
+ import { ray3_array_compose } from "../../../../../core/geom/3d/ray/ray3_array_compose.js";
9
+ import { SurfacePoint3 } from "../../../../../core/geom/3d/SurfacePoint3.js";
10
+ import { rayTriangleIntersection } from "../../../../../core/geom/3d/triangle/rayTriangleIntersection.js";
11
+ import { v3_length } from "../../../../../core/geom/vec3/v3_length.js";
12
+ import Vector3 from "../../../../../core/geom/Vector3.js";
13
13
 
14
14
  const hit = new ThreeVector3();
15
15
 
@@ -42,6 +42,12 @@ function bindGeometryFace(indices, vertices, index) {
42
42
 
43
43
  const vNormal = new Vector3();
44
44
 
45
+ /**
46
+ *
47
+ * @param {number[]} indices
48
+ * @param {number[]} normals
49
+ * @param {number} index
50
+ */
45
51
  function bindGeometryFaceNormal(indices, normals, index) {
46
52
 
47
53
  const index3 = index * 3;
@@ -0,0 +1,58 @@
1
+ import { max3 } from "../../../../../core/math/max3.js";
2
+ import { min3 } from "../../../../../core/math/min3.js";
3
+
4
+ /**
5
+ *
6
+ * @param {BinaryUint32BVH} bvh
7
+ * @param {Float32Array} vertices
8
+ * @param {Uint32Array} indices
9
+ */
10
+ export function bvh32_from_indexed_geometry(bvh, vertices, indices) {
11
+
12
+ const triangle_count = indices.length / 3;
13
+
14
+ bvh.setLeafCount(triangle_count);
15
+ bvh.initialize_structure();
16
+
17
+ for (let i = 0; i < triangle_count; i++) {
18
+
19
+ const index3 = i * 3;
20
+
21
+ // read triangle vertex indices
22
+ const iA = indices[index3];
23
+ const iB = indices[index3 + 1];
24
+ const iC = indices[index3 + 2];
25
+
26
+ const a = iA * 3;
27
+ const b = iB * 3;
28
+ const c = iC * 3;
29
+
30
+ // read actual positions of each vertex
31
+ const aX = vertices[a];
32
+ const aY = vertices[a + 1];
33
+ const aZ = vertices[a + 2];
34
+
35
+ const bX = vertices[b];
36
+ const bY = vertices[b + 1];
37
+ const bZ = vertices[b + 2];
38
+
39
+ const cX = vertices[c];
40
+ const cY = vertices[c + 1];
41
+ const cZ = vertices[c + 2];
42
+
43
+ // compute bounds of the triangle
44
+ const x0 = min3(aX, bX, cX);
45
+ const y0 = min3(aY, bY, cY);
46
+ const z0 = min3(aZ, bZ, cZ);
47
+
48
+ const x1 = max3(aX, bX, cX);
49
+ const y1 = max3(aY, bY, cY);
50
+ const z1 = max3(aZ, bZ, cZ);
51
+
52
+ bvh.setLeafData(i, i, x0, y0, z0, x1, y1, z1)
53
+ }
54
+
55
+ // finalize build
56
+ // bvh.sort_morton(MATRIX_4_IDENTITY);
57
+ bvh.build();
58
+ }
@@ -1,30 +1,30 @@
1
- import {assert} from "../../../../core/assert.js";
2
- import {
3
- bvh_query_user_data_overlaps_frustum
4
- } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
5
- import {ResourceAccessKind} from "../../../../core/model/ResourceAccessKind.js";
6
- import {ResourceAccessSpecification} from "../../../../core/model/ResourceAccessSpecification.js";
7
- import {ImageRGBADataLoader} from "../../../asset/loaders/image/ImageRGBADataLoader.js";
8
- import {System} from "../../../ecs/System.js";
9
- import {Transform} from "../../../ecs/transform/Transform.js";
10
- import {RenderPassType} from "../../render/RenderPassType.js";
11
- import {StandardFrameBuffers} from "../../StandardFrameBuffers.js";
12
- import {ParticleEmitter} from "../particular/engine/emitter/ParticleEmitter.js";
13
- import {ParticleEmitterFlag} from "../particular/engine/emitter/ParticleEmitterFlag.js";
14
- import {ParticularEngine} from "../particular/engine/ParticularEngine.js";
15
-
16
- /**
17
- *
18
- * @param {ParticleEmitter} emitter
19
- * @returns {Group|Object3D}
20
- */
21
- function extractRenderable(emitter) {
22
- return emitter.mesh;
23
- }
24
-
25
- const scratch_array = [];
1
+ import { assert } from "../../../../core/assert.js";
2
+ import { ResourceAccessKind } from "../../../../core/model/ResourceAccessKind.js";
3
+ import { ResourceAccessSpecification } from "../../../../core/model/ResourceAccessSpecification.js";
4
+ import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
5
+ import { System } from "../../../ecs/System.js";
6
+ import { Transform } from "../../../ecs/transform/Transform.js";
7
+ import { make_bvh_visibility_builder } from "../../render/make_bvh_visibility_builder.js";
8
+ import { StandardFrameBuffers } from "../../StandardFrameBuffers.js";
9
+ import { ParticleEmitter } from "../particular/engine/emitter/ParticleEmitter.js";
10
+ import { ParticleEmitterFlag } from "../particular/engine/emitter/ParticleEmitterFlag.js";
11
+ import { ParticularEngine } from "../particular/engine/ParticularEngine.js";
26
12
 
27
13
  export class ParticleEmitterSystem extends System {
14
+ dependencies = [ParticleEmitter, Transform];
15
+
16
+ components_used = [
17
+ ResourceAccessSpecification.from(ParticleEmitter, ResourceAccessKind.Read | ResourceAccessKind.Write)
18
+ ];
19
+
20
+ /**
21
+ *
22
+ * @type {RenderLayer|null}
23
+ */
24
+ renderLayer = null;
25
+
26
+ __handlers = [];
27
+
28
28
  /**
29
29
  *
30
30
  * @extends {System.<ParticleEmitter>}
@@ -37,12 +37,6 @@ export class ParticleEmitterSystem extends System {
37
37
  assert.defined(engine, 'engine');
38
38
  assert.equal(engine.isEngine, true, 'engine.isEngine !== true');
39
39
 
40
- this.dependencies = [ParticleEmitter, Transform];
41
-
42
- this.components_used = [
43
- ResourceAccessSpecification.from(ParticleEmitter, ResourceAccessKind.Read | ResourceAccessKind.Write)
44
- ];
45
-
46
40
  /**
47
41
  *
48
42
  * @type {GraphicsEngine}
@@ -61,13 +55,6 @@ export class ParticleEmitterSystem extends System {
61
55
  */
62
56
  this.particleEngine = new ParticularEngine(engine.assetManager, engine.graphics.getMaterialManager());
63
57
 
64
- /**
65
- *
66
- * @type {RenderLayer|null}
67
- */
68
- this.renderLayer = null;
69
-
70
- this.__handlers = [];
71
58
  }
72
59
 
73
60
  async startup(entityManager, readyCallback, errorCallback) {
@@ -87,33 +74,16 @@ export class ParticleEmitterSystem extends System {
87
74
 
88
75
  this.renderLayer = renderLayer;
89
76
 
90
- renderLayer.renderPass = RenderPassType.Transparent;
91
-
92
- renderLayer.buildVisibleSet = (destination, destination_offset, view) => {
77
+ renderLayer.buildVisibleSet = make_bvh_visibility_builder(
78
+ this.entityManager, this.particleEngine.bvh,
79
+ (destination, offset, entity, ecd) => {
80
+ const component = ecd.getComponent(entity, ParticleEmitter);
93
81
 
94
- const ecd = entityManager.dataset;
95
82
 
96
- if (ecd === null) {
97
- return 0;
83
+ destination[offset] = component.mesh;
84
+ return 1;
98
85
  }
99
-
100
- const view_frustum = view.frustum;
101
-
102
- const hit_count = bvh_query_user_data_overlaps_frustum(scratch_array, 0, this.particleEngine.bvh, view_frustum);
103
-
104
- for (let i = 0; i < hit_count; i++) {
105
- const id = scratch_array[i];
106
-
107
- /**
108
- * @type {ParticleEmitter}
109
- */
110
- const emitter = ecd.getComponent(id, ParticleEmitter);
111
-
112
- destination[destination_offset + i] = emitter.mesh;
113
- }
114
-
115
- return hit_count;
116
- };
86
+ );
117
87
 
118
88
  renderLayer.visibleSet.onAdded.add((points) => {
119
89
  /**
@@ -516,7 +516,7 @@ export class ParticleEmitter {
516
516
  const ebb = this.emissionBounds;
517
517
  const pbb = this.particleBounds;
518
518
 
519
- aabb3_array_combine(this.bvh_leaf.bounds, ebb, pbb);
519
+ aabb3_array_combine(this.bvh_leaf.bounds,0, ebb,0, pbb,0);
520
520
 
521
521
  this.bvh_leaf.write_bounds();
522
522
 
@@ -1,18 +1,16 @@
1
- import { EngineHarness } from "../../../../../../EngineHarness.js";
2
- import { ParticlePool } from "../../emitter/ParticlePool.js";
3
- import { make_particle_billboard_shader } from "./ParticleBillboardMaterial.js";
4
1
  import { DataTexture, LinearFilter, LinearMipMapLinearFilter, Matrix4, Points } from "three";
5
- import { ManagedAtlas } from "../../../../../texture/atlas/ManagedTextureAtlas.js";
6
- import { writeSample2DDataToDataTexture } from "../../../../../texture/sampler/writeSampler2DDataToDataTexture.js";
2
+ import Vector3 from "../../../../../../../core/geom/Vector3.js";
7
3
  import { ImageRGBADataLoader } from "../../../../../../asset/loaders/image/ImageRGBADataLoader.js";
8
- import { EngineConfiguration } from "../../../../../../EngineConfiguration.js";
9
- import { MeshSystem } from "../../../../../ecs/mesh/MeshSystem.js";
10
4
  import Entity from "../../../../../../ecs/Entity.js";
11
5
  import { Transform } from "../../../../../../ecs/transform/Transform.js";
6
+ import { EngineConfiguration } from "../../../../../../EngineConfiguration.js";
7
+ import { EngineHarness } from "../../../../../../EngineHarness.js";
12
8
  import Mesh from "../../../../../ecs/mesh/Mesh.js";
13
- import Vector3 from "../../../../../../../core/geom/Vector3.js";
14
- import { RenderPassType } from "../../../../../render/RenderPassType.js";
9
+ import { MeshSystem } from "../../../../../ecs/mesh/MeshSystem.js";
15
10
  import { StandardFrameBuffers } from "../../../../../StandardFrameBuffers.js";
11
+ import { ManagedAtlas } from "../../../../../texture/atlas/ManagedTextureAtlas.js";
12
+ import { writeSample2DDataToDataTexture } from "../../../../../texture/sampler/writeSampler2DDataToDataTexture.js";
13
+ import { ParticlePool } from "../../emitter/ParticlePool.js";
16
14
  import {
17
15
  BILLBOARD_PARTICLE_ATTRIBUTE_BLEND,
18
16
  BILLBOARD_PARTICLE_ATTRIBUTE_COLOR,
@@ -21,6 +19,7 @@ import {
21
19
  BILLBOARD_PARTICLE_ATTRIBUTE_UV,
22
20
  BILLBOARD_PARTICLE_SPECIFICATION
23
21
  } from "./BILLBOARD_PARTICLE_SPECIFICATION.js";
22
+ import { make_particle_billboard_shader } from "./ParticleBillboardMaterial.js";
24
23
 
25
24
 
26
25
  const engineHarness = new EngineHarness();
@@ -113,8 +112,6 @@ async function main(engine) {
113
112
  layer.visibleSet.push(points);
114
113
  layer.visibleSet.finalizeUpdate();
115
114
 
116
- layer.renderPass = RenderPassType.Transparent;
117
-
118
115
  engine.graphics.on.visibilityConstructionStarted.add((renderer, camera, scene) => {
119
116
  renderer.getSize(shaderMaterial.uniforms.resolution.value);
120
117
 
@@ -1,27 +1,27 @@
1
+ import { BVH_BINARY_NODE_SIZE, BVH_LEAF_NODE_SIZE } from "../../../../../core/bvh2/binary/2/BinaryUint32BVH.js";
2
+ import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../../../core/collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
1
3
  import {
2
4
  aabb3_compute_distance_above_plane_max
3
5
  } from "../../../../../core/geom/3d/aabb/aabb3_compute_distance_above_plane_max.js";
4
6
  import { point_light_inside_volume } from "./point_light_inside_volume.js";
5
- import { BVH_BINARY_NODE_SIZE, BVH_LEAF_NODE_SIZE } from "../../../../../core/bvh2/binary/2/BinaryUint32BVH.js";
6
- import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../../../core/collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
7
7
 
8
8
  const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
9
9
 
10
10
  /**
11
11
  *
12
- * @param {DataView} data_view
12
+ * @param {Float32Array} data
13
13
  * @param {number} address
14
14
  * @param {ArrayLike<number>|number[]} planes
15
15
  * @return {boolean}
16
16
  */
17
- function frustum_check(data_view, address, planes) {
18
- const n_x0 = data_view.getFloat32(address);
19
- const n_y0 = data_view.getFloat32(address + 4);
20
- const n_z0 = data_view.getFloat32(address + 8);
17
+ function frustum_check(data, address, planes) {
18
+ const n_x0 = data[address];
19
+ const n_y0 = data[address + 1];
20
+ const n_z0 = data[address + 2];
21
21
 
22
- const n_x1 = data_view.getFloat32(address + 12);
23
- const n_y1 = data_view.getFloat32(address + 16);
24
- const n_z1 = data_view.getFloat32(address + 20);
22
+ const n_x1 = data[address + 3];
23
+ const n_y1 = data[address + 4];
24
+ const n_z1 = data[address + 5];
25
25
 
26
26
  for (let plane_address = 0; plane_address < 24; plane_address += 4) {
27
27
 
@@ -54,7 +54,7 @@ function frustum_check(data_view, address, planes) {
54
54
  * Most of the data is in flat continuous array for cache coherence
55
55
  * @param {number[]} destination
56
56
  * @param {number} destination_offset
57
- * @param {BinaryUint32BVH} root
57
+ * @param {BinaryUint32BVH} bvh
58
58
  * @param {number[]|Uint8ClampedArray} source_data
59
59
  * @param {number[]|Float32Array|Float64Array} planes
60
60
  * @param {number[]|Float32Array|Float64Array} points
@@ -63,13 +63,13 @@ function frustum_check(data_view, address, planes) {
63
63
  export function query_bvh_frustum_from_texture(
64
64
  destination,
65
65
  destination_offset,
66
- root,
66
+ bvh,
67
67
  source_data,
68
68
  planes, points
69
69
  ) {
70
70
  let result = 0;
71
71
 
72
- const binary_node_count = root.getBinaryNodeCount();
72
+ const binary_node_count = bvh.getBinaryNodeCount();
73
73
 
74
74
  if (binary_node_count <= 0) {
75
75
  // this should not happen
@@ -88,8 +88,10 @@ export function query_bvh_frustum_from_texture(
88
88
  */
89
89
  stack[stack_top] = 0;
90
90
 
91
- const last_valid_index = binary_node_count + root.getLeafNodeCount();
92
- const data_view = root.getDataView();
91
+ const last_valid_index = binary_node_count + bvh.getLeafNodeCount();
92
+
93
+ const float32 = bvh.float32;
94
+ const uint32 = bvh.uint32;
93
95
 
94
96
  do {
95
97
  stack.pointer--;
@@ -101,7 +103,7 @@ export function query_bvh_frustum_from_texture(
101
103
  // is intermediate node
102
104
  const node_address = node_index * BVH_BINARY_NODE_SIZE;
103
105
 
104
- if (!frustum_check(data_view, node_address, planes)) {
106
+ if (!frustum_check(float32, node_address, planes)) {
105
107
  continue;
106
108
  }
107
109
 
@@ -124,7 +126,7 @@ export function query_bvh_frustum_from_texture(
124
126
 
125
127
  const node_address = leaf_index * BVH_LEAF_NODE_SIZE + binary_node_count * BVH_BINARY_NODE_SIZE;
126
128
 
127
- const light_descriptor = data_view.getUint32(node_address + 24);
129
+ const light_descriptor = uint32[node_address + 6];
128
130
 
129
131
  const light_type = light_descriptor & 3;
130
132
 
@@ -148,7 +150,7 @@ export function query_bvh_frustum_from_texture(
148
150
  } else if (light_type === 3) {
149
151
  // decal
150
152
 
151
- if (!frustum_check(data_view, node_address, planes)) {
153
+ if (!frustum_check(float32, node_address, planes)) {
152
154
  continue;
153
155
  }
154
156
 
@@ -162,7 +164,7 @@ export function query_bvh_frustum_from_texture(
162
164
  result++;
163
165
  }
164
166
 
165
- }while (stack.pointer > stack_top)
167
+ } while (stack.pointer > stack_top)
166
168
 
167
169
  return result;
168
170
  }
@@ -1,15 +1,16 @@
1
- import {BinaryNode} from "../../../../core/bvh2/BinaryNode";
2
- import {RenderLayerState} from "./RenderLayerState";
3
1
  import {Object3D} from "three";
4
2
  import {IncrementalDeltaSet} from "../visibility/IncrementalDeltaSet";
3
+ import {RenderLayerState} from "./RenderLayerState";
5
4
 
6
5
  export class RenderLayer {
7
- bvh: BinaryNode
8
6
  name: string
9
7
  state: RenderLayerState
10
8
 
11
9
  managed: boolean
12
10
 
11
+ /**
12
+ * @deprecated
13
+ */
13
14
  extractRenderable(leafData: any): Object3D
14
15
 
15
16
  /**