@woosh/meep-engine 2.67.0 → 2.68.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 (50) hide show
  1. package/build/meep.cjs +0 -1
  2. package/build/meep.module.js +0 -1
  3. package/package.json +1 -1
  4. package/src/engine/graphics/ecs/mesh/Mesh.d.ts +0 -1
  5. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +0 -5
  6. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +0 -1
  7. package/src/engine/graphics/material/optimization/prototypeMaterialOptimizer.js +16 -19
  8. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +46 -47
  9. package/src/core/bvh2/BVHTasks.js +0 -65
  10. package/src/core/bvh2/BinaryNode.d.ts +0 -13
  11. package/src/core/bvh2/BinaryNode.js +0 -1188
  12. package/src/core/bvh2/BinaryNode.spec.js +0 -309
  13. package/src/core/bvh2/LeafNode.d.ts +0 -7
  14. package/src/core/bvh2/LeafNode.js +0 -147
  15. package/src/core/bvh2/Node.d.ts +0 -9
  16. package/src/core/bvh2/Node.js +0 -196
  17. package/src/core/bvh2/NodeValidator.js +0 -197
  18. package/src/core/bvh2/StacklessTraverser.js +0 -154
  19. package/src/core/bvh2/StacklessTraverser.spec.js +0 -109
  20. package/src/core/bvh2/serialization/deserializeBinaryNode.js +0 -40
  21. package/src/core/bvh2/serialization/deserializeBinaryNodeFromBinaryBuffer.js +0 -90
  22. package/src/core/bvh2/serialization/serializeBinaryNode.js +0 -31
  23. package/src/core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js +0 -86
  24. package/src/core/bvh2/transform/BottomUpOptimizingRebuilder.js +0 -144
  25. package/src/core/bvh2/transform/RotationOptimizer.js +0 -123
  26. package/src/core/bvh2/transform/RotationOptimizer.spec.js +0 -303
  27. package/src/core/bvh2/transform/tryRotateSingleNode.js +0 -260
  28. package/src/core/bvh2/traversal/BVHVisitor.js +0 -30
  29. package/src/core/bvh2/traversal/RaycastBVHVisitor.js +0 -66
  30. package/src/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +0 -384
  31. package/src/core/bvh2/traversal/ThreeFrustumsIntersectionBVHVisitor.js +0 -52
  32. package/src/core/bvh2/traversal/bvh_traverse_pre_order_using_stack.js +0 -43
  33. package/src/core/bvh2/traversal/queryBinaryNode_ClippingPlanes.d.ts +0 -5
  34. package/src/core/bvh2/traversal/queryBinaryNode_ClippingPlanes.js +0 -66
  35. package/src/core/bvh2/traversal/queryBinaryNode_CollectData.js +0 -49
  36. package/src/core/bvh2/traversal/queryBinaryNode_CollectLeaves.js +0 -51
  37. package/src/core/bvh2/traversal/queryBinaryNode_FrustumIntersections.js +0 -77
  38. package/src/core/bvh2/traversal/queryBinaryNode_SphereIntersections.js +0 -63
  39. package/src/core/bvh2/traversal/traverseBinaryNodeUsingVisitor.js +0 -50
  40. package/src/core/bvh2/traversal/traverseBinaryNodeUsingVisitor_DepthFirst_PreOrder.js +0 -34
  41. package/src/core/bvh2/util/find_least_common_ancestor.js +0 -34
  42. package/src/core/bvh2/visual/convert_bvh_to_dot_format_string.js +0 -50
  43. package/src/core/geom/2d/bvh/BinaryNode2.js +0 -152
  44. package/src/core/geom/2d/bvh/LeafNode2.js +0 -11
  45. package/src/core/geom/2d/bvh/Node2.js +0 -51
  46. package/src/engine/ecs/terrain/tiles/FirstRayIntersectionTerrainBVHVisitor.js +0 -74
  47. package/src/engine/graphics/geometry/bvh/BVHFromGeometry.js +0 -72
  48. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +0 -240
  49. package/src/engine/graphics/geometry/bvh/buffered/IndexedTraingleBoundsComputer.js +0 -43
  50. package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +0 -133
package/build/meep.cjs CHANGED
@@ -68779,7 +68779,6 @@ class ShadedGeometry {
68779
68779
 
68780
68780
  /**
68781
68781
  * @deprecated
68782
- * @returns {LeafNode<ShadedGeometry>}
68783
68782
  */
68784
68783
  get bvh() {
68785
68784
  throw new Error('Deprecated, use #getBoundingBox method instead');
@@ -68777,7 +68777,6 @@ class ShadedGeometry {
68777
68777
 
68778
68778
  /**
68779
68779
  * @deprecated
68780
- * @returns {LeafNode<ShadedGeometry>}
68781
68780
  */
68782
68781
  get bvh() {
68783
68782
  throw new Error('Deprecated, use #getBoundingBox method instead');
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.67.0",
8
+ "version": "2.68.0",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,6 +1,5 @@
1
1
  import {Object3D} from "three";
2
2
  import {AABB3} from "../../../../core/geom/3d/aabb/AABB3";
3
- import {LeafNode} from "../../../../core/bvh2/LeafNode";
4
3
 
5
4
  export default class Mesh {
6
5
  url: string
@@ -7,11 +7,6 @@ export class ShadedGeometry {
7
7
  material: Material
8
8
  readonly mode: DrawMode
9
9
 
10
- /**
11
- * @deprecated
12
- */
13
- readonly bvh: Readonly<AABB3>
14
-
15
10
  getBoundingBox(destination: AABB3): void
16
11
 
17
12
  from(geometry: BufferGeometry, material: Material, draw_mode?: DrawMode): void
@@ -215,7 +215,6 @@ export class ShadedGeometry {
215
215
 
216
216
  /**
217
217
  * @deprecated
218
- * @returns {LeafNode<ShadedGeometry>}
219
218
  */
220
219
  get bvh() {
221
220
  throw new Error('Deprecated, use #getBoundingBox method instead');
@@ -1,15 +1,12 @@
1
- import { EngineHarness } from "../../../EngineHarness.js";
2
- import { EngineConfiguration } from "../../../EngineConfiguration.js";
3
- import { ShadedGeometrySystem } from "../../ecs/mesh-v2/ShadedGeometrySystem.js";
4
- import { AttachmentSystem } from "../../../ecs/attachment/AttachmentSystem.js";
5
- import { TransformAttachmentSystem } from "../../../ecs/transform-attachment/TransformAttachmentSystem.js";
6
1
  import { GameAssetType } from "../../../asset/GameAssetType.js";
7
2
  import { GLTFAssetLoader } from "../../../asset/loaders/GLTFAssetLoader.js";
3
+ import { AttachmentSystem } from "../../../ecs/attachment/AttachmentSystem.js";
4
+ import { TransformAttachmentSystem } from "../../../ecs/transform-attachment/TransformAttachmentSystem.js";
5
+ import { EngineConfiguration } from "../../../EngineConfiguration.js";
6
+ import { EngineHarness } from "../../../EngineHarness.js";
7
+ import { ShadedGeometrySystem } from "../../ecs/mesh-v2/ShadedGeometrySystem.js";
8
8
  import { three_object_to_entity_composition } from "../../ecs/mesh-v2/three_object_to_entity_composition.js";
9
9
  import { MaterialOptimizationContext } from "./MaterialOptimizationContext.js";
10
- import {
11
- bvh_traverse_pre_order_using_stack
12
- } from "../../../../core/bvh2/traversal/bvh_traverse_pre_order_using_stack.js";
13
10
 
14
11
  const eh = new EngineHarness();
15
12
 
@@ -23,17 +20,17 @@ function optimize(engine) {
23
20
 
24
21
  const optimizer = new MaterialOptimizationContext();
25
22
 
26
- engine.graphics.layers.layers.forEach(l => {
27
- bvh_traverse_pre_order_using_stack(l.bvh, node => {
28
- if (node.isLeafNode) {
29
- const object = l.extractRenderable(node.object);
30
-
31
- if (object) {
32
- optimizer.addObject(object);
33
- }
34
- }
35
- });
36
- });
23
+ // engine.graphics.layers.layers.forEach(l => {
24
+ // bvh_traverse_pre_order_using_stack(l.bvh, node => {
25
+ // if (node.isLeafNode) {
26
+ // const object = l.extractRenderable(node.object);
27
+ //
28
+ // if (object) {
29
+ // optimizer.addObject(object);
30
+ // }
31
+ // }
32
+ // });
33
+ // });
37
34
 
38
35
  optimizer.update();
39
36
 
@@ -1,3 +1,5 @@
1
+ import { mat4 } from "gl-matrix";
2
+ import SimplexNoise from "simplex-noise";
1
3
  import {
2
4
  AmbientLight,
3
5
  BoxBufferGeometry,
@@ -16,56 +18,53 @@ import {
16
18
  Vector2,
17
19
  WebGLRenderer,
18
20
  } from "three";
19
- import { min2 } from "../../../../../core/math/min2.js";
20
- import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
21
- import { PointLight } from "../model/PointLight.js";
22
- import { makeHelperSphereGeometry } from "../../../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
23
21
  import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
24
- import { MouseEvents } from "../../../../input/devices/events/MouseEvents.js";
25
- import { RingBuffer } from "../../../../../core/collection/RingBuffer.js";
26
- import { query_bvh_frustum_from_objects } from "../query/query_bvh_frustum_from_objects.js";
27
- import { FPlusDebugMaterial } from "../materials/FPlusDebugMaterial.js";
28
- import { parse_color } from "../../../../../core/color/parse_color.js";
29
- import { buildLightClusterWidget } from "../debug/buildLightClusterWidget.js";
30
- import domify from "../../../../../view/DOM.js";
31
- import { createScreenGrid } from "../debug/createScreenGrid.js";
32
- import { createLayerSwitcher } from "../debug/createLayerSwitcher.js";
33
- import { FPlusStandardMaterial } from "../materials/FPlusStandardMaterial.js";
34
- import { LightManager } from "../LightManager.js";
35
- import ButtonView from "../../../../../view/elements/button/ButtonView.js";
36
- import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
37
- import { traverseMaterialTextures } from "../../../../asset/loaders/material/traverseMaterialTextures.js";
38
- import Vector3 from "../../../../../core/geom/Vector3.js";
39
- import { MetricCollection } from "../../../../development/performance/MetricCollection.js";
40
- import { MetricStatistics } from "../../../../development/performance/MetricStatistics.js";
41
- import { SpotLight } from "../model/SpotLight.js";
42
- import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
43
- import Signal from "../../../../../core/events/signal/Signal.js";
44
- import SimplexNoise from "simplex-noise";
45
22
  import Stats from "three/examples/jsm/libs/stats.module.js";
46
- import { threeUpdateTransform } from "../../../util/threeUpdateTransform.js";
47
- import { Decal } from "../model/Decal.js";
48
- import { mat4 } from "gl-matrix";
49
- import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
23
+ import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
24
+ import { Float32BufferAttribute } from "three/src/core/BufferAttribute.js";
25
+ import { BufferGeometry } from "three/src/core/BufferGeometry.js";
26
+ import { DEG2RAD, smoothstep } from "three/src/math/MathUtils.js";
27
+ import '../../../../../../../../../css/game.scss'
50
28
  import { makeHelperBoxGeometry } from "../../../../../../editor/process/symbolic/makeHelperBoxGeometry.js";
29
+ import { makeHelperSphereGeometry } from "../../../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
51
30
  import { array_copy } from "../../../../../core/collection/array/array_copy.js";
52
- import { BufferGeometry } from "three/src/core/BufferGeometry.js";
53
- import { Float32BufferAttribute } from "three/src/core/BufferAttribute.js";
31
+ import { RingBuffer } from "../../../../../core/collection/RingBuffer.js";
32
+ import { Color } from "../../../../../core/color/Color.js";
33
+ import { parse_color } from "../../../../../core/color/parse_color.js";
34
+ import Signal from "../../../../../core/events/signal/Signal.js";
54
35
  import Quaternion from "../../../../../core/geom/Quaternion.js";
55
36
  import { v2_distance } from "../../../../../core/geom/Vector2.js";
56
- import { DEG2RAD, smoothstep } from "three/src/math/MathUtils.js";
37
+ import Vector3 from "../../../../../core/geom/Vector3.js";
38
+ import { Localization } from "../../../../../core/localization/Localization.js";
39
+ import { min2 } from "../../../../../core/math/min2.js";
40
+ import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
41
+ import { randomFromArray } from "../../../../../core/math/random/randomFromArray.js";
42
+ import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
43
+ import { number_pretty_print } from "../../../../../core/primitives/numbers/number_pretty_print.js";
44
+ import domify from "../../../../../view/DOM.js";
45
+ import ButtonView from "../../../../../view/elements/button/ButtonView.js";
46
+ import { GMLEngine } from "../../../../../view/tooltip/gml/GMLEngine.js";
47
+ import { TooltipManager } from "../../../../../view/tooltip/TooltipManager.js";
57
48
  import { AssetManager } from "../../../../asset/AssetManager.js";
58
49
  import { ImageRGBADataLoader } from "../../../../asset/loaders/image/ImageRGBADataLoader.js";
59
- import { Color } from "../../../../../core/color/Color.js";
60
- import { TooltipManager } from "../../../../../view/tooltip/TooltipManager.js";
61
- import { GMLEngine } from "../../../../../view/tooltip/gml/GMLEngine.js";
50
+ import { traverseMaterialTextures } from "../../../../asset/loaders/material/traverseMaterialTextures.js";
51
+ import { MetricCollection } from "../../../../development/performance/MetricCollection.js";
52
+ import { MetricStatistics } from "../../../../development/performance/MetricStatistics.js";
53
+ import { MouseEvents } from "../../../../input/devices/events/MouseEvents.js";
62
54
  import { PointerDevice } from "../../../../input/devices/PointerDevice.js";
63
55
  import { StaticKnowledgeDatabase } from "../../../../knowledge/database/StaticKnowledgeDatabase.js";
64
- import { Localization } from "../../../../../core/localization/Localization.js";
65
- import '../../../../../../../../../css/game.scss'
66
- import { randomFromArray } from "../../../../../core/math/random/randomFromArray.js";
67
56
  import { debugAtlas } from "../../../particles/particular/engine/shader/debugAtlas.js";
68
- import { number_pretty_print } from "../../../../../core/primitives/numbers/number_pretty_print.js";
57
+ import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
58
+ import { threeUpdateTransform } from "../../../util/threeUpdateTransform.js";
59
+ import { buildLightClusterWidget } from "../debug/buildLightClusterWidget.js";
60
+ import { createLayerSwitcher } from "../debug/createLayerSwitcher.js";
61
+ import { createScreenGrid } from "../debug/createScreenGrid.js";
62
+ import { LightManager } from "../LightManager.js";
63
+ import { FPlusDebugMaterial } from "../materials/FPlusDebugMaterial.js";
64
+ import { FPlusStandardMaterial } from "../materials/FPlusStandardMaterial.js";
65
+ import { Decal } from "../model/Decal.js";
66
+ import { PointLight } from "../model/PointLight.js";
67
+ import { SpotLight } from "../model/SpotLight.js";
69
68
 
70
69
  document.body.style.margin = 0;
71
70
 
@@ -1532,20 +1531,20 @@ function print_perf_stats() {
1532
1531
  setInterval(print_perf_stats, 2000);
1533
1532
 
1534
1533
  function do_sample() {
1535
- query_bvh_frustum_from_objects.iteration_count = 0;
1536
- query_bvh_frustum_from_objects.rejection_count = 0;
1537
- query_bvh_frustum_from_objects.rejection_sphere_count = 0;
1538
- query_bvh_frustum_from_objects.plane_tests = 0;
1539
- query_bvh_frustum_from_objects.plane_tests_early_exits = 0;
1534
+ // query_bvh_frustum_from_objects.iteration_count = 0;
1535
+ // query_bvh_frustum_from_objects.rejection_count = 0;
1536
+ // query_bvh_frustum_from_objects.rejection_sphere_count = 0;
1537
+ // query_bvh_frustum_from_objects.plane_tests = 0;
1538
+ // query_bvh_frustum_from_objects.plane_tests_early_exits = 0;
1540
1539
 
1541
1540
  const t0 = performance.now();
1542
1541
  lm.buildTiles(camera);
1543
1542
  const t1 = performance.now();
1544
1543
 
1545
1544
  metrics.get("time").record(t1 - t0);
1546
- metrics.get("iterations").record(query_bvh_frustum_from_objects.iteration_count);
1547
- metrics.get("rejections").record(query_bvh_frustum_from_objects.rejection_count);
1548
- metrics.get("sphere_rejections").record(query_bvh_frustum_from_objects.rejection_sphere_count);
1545
+ // metrics.get("iterations").record(query_bvh_frustum_from_objects.iteration_count);
1546
+ // metrics.get("rejections").record(query_bvh_frustum_from_objects.rejection_count);
1547
+ // metrics.get("sphere_rejections").record(query_bvh_frustum_from_objects.rejection_sphere_count);
1549
1548
  }
1550
1549
 
1551
1550
  function draw_camera_view_planes() {
@@ -1,65 +0,0 @@
1
- import { RingBuffer } from "../collection/RingBuffer.js";
2
- import Task from "../process/task/Task.js";
3
- import { TaskSignal } from "../process/task/TaskSignal.js";
4
- import { optimize } from "./transform/RotationOptimizer.js";
5
-
6
-
7
- /**
8
- *
9
- * @param {BinaryNode} bvh
10
- * @param {number} iterationLength
11
- * @returns {Task}
12
- */
13
- export function buildTreeOptimizationTask(bvh, iterationLength) {
14
-
15
- const buffer = new RingBuffer(10);
16
-
17
- let cycles = 0;
18
- let sameChangeCountCycles = 0;
19
-
20
- //optimize bvh
21
- const task = new Task({
22
- name: "Optimization of Bounding Volume Hierarchy",
23
-
24
- initializer(task, executor) {
25
- cycles = 0;
26
- sameChangeCountCycles = 0;
27
- buffer.clear();
28
- },
29
-
30
- cycleFunction() {
31
- const optimizationsDone = optimize(bvh, iterationLength);
32
- if (optimizationsDone > 0) {
33
- console.log('otimization step.. changes: ', optimizationsDone);
34
-
35
- cycles += optimizationsDone;
36
- if (buffer.contains(optimizationsDone)) {
37
- sameChangeCountCycles++;
38
- if (sameChangeCountCycles > 100) {
39
- console.warn("detected optimization oscillation after 100 cycles, terminating");
40
- //stuck in oscillation, probably
41
- return TaskSignal.EndSuccess;
42
- }
43
- } else {
44
- //reset counter
45
- sameChangeCountCycles = 0;
46
- }
47
-
48
- buffer.push(optimizationsDone);
49
-
50
- return TaskSignal.Continue;
51
- } else {
52
- return TaskSignal.EndSuccess;
53
- }
54
- },
55
- computeProgress: function () {
56
- if (iterationLength <= 0) {
57
- return 0;
58
- } else {
59
- return cycles / iterationLength;
60
- }
61
- }
62
- });
63
-
64
- return task;
65
- }
@@ -1,13 +0,0 @@
1
- import {Node} from "./Node";
2
- import {LeafNode} from "./LeafNode";
3
-
4
- export class BinaryNode<T = any> extends Node<T> {
5
- left: Node<T>
6
- right: Node<T>
7
-
8
- traversePreOrderUsingStack(visitor: (node: Node<T>) => boolean, thisArg?: any): void
9
-
10
- insert(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, value: T): LeafNode<T>
11
-
12
- traverseRayLeafIntersections(startX: number, startY: number, startZ: number, directionX: number, directionY: number, directionZ: number, visitor: (node: LeafNode<T>) => any, thisArg?: any);
13
- }