@woosh/meep-engine 2.46.25 → 2.46.27

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 (30) hide show
  1. package/package.json +1 -1
  2. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +9 -12
  3. package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +60 -0
  4. package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -0
  5. package/src/core/collection/HashMap.js +21 -5
  6. package/src/core/events/signal/Signal.js +3 -3
  7. package/src/core/geom/3d/cone/computeConeBoundingBox.js +7 -10
  8. package/src/core/geom/3d/ray/ray3_array_apply_matrix4.js +15 -13
  9. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +6 -24
  10. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +4 -25
  11. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +2 -6
  12. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
  13. package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.d.ts +1 -1
  14. package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +10 -43
  15. package/src/engine/graphics/render/forward_plus/LightManager.js +164 -56
  16. package/src/engine/graphics/render/forward_plus/{PointLightData.js → LightRenderMetadata.js} +18 -11
  17. package/src/engine/graphics/render/forward_plus/cluster/compute_light_data_hash.js +1 -1
  18. package/src/engine/graphics/render/forward_plus/model/AbstractLight.js +1 -1
  19. package/src/engine/graphics/render/forward_plus/model/Decal.js +1 -4
  20. package/src/engine/graphics/render/forward_plus/model/PointLight.js +6 -12
  21. package/src/engine/graphics/render/forward_plus/model/SpotLight.js +0 -4
  22. package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.d.ts +3 -0
  23. package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +12 -0
  24. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +3 -2
  25. package/src/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +1 -1
  26. package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +3 -3
  27. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +1 -1
  28. package/src/engine/graphics/texture/atlas/CachingTextureAtlas.js +0 -1
  29. package/src/engine/intelligence/behavior/util/BranchBehavior.js +102 -0
  30. package/src/engine/intelligence/behavior/util/SelectorBehavior.js +0 -83
@@ -0,0 +1,102 @@
1
+ import { Behavior } from "../Behavior.js";
2
+ import { SucceedingBehavior } from "../primitive/SucceedingBehavior.js";
3
+ import { assert } from "../../../../core/assert.js";
4
+ import { BehaviorStatus } from "../BehaviorStatus.js";
5
+
6
+ const DEFAULT = new SucceedingBehavior();
7
+
8
+ /**
9
+ * Utility behavior that works just like an IF/ELSE statement
10
+ * If you are not sure if this is the right behavior for your use-case, consider using a selector behavior instead,
11
+ * as selector is a more commonly applicable behavior type
12
+ */
13
+ export class BranchBehavior extends Behavior {
14
+ #successBranch = DEFAULT
15
+ #failureBranch = DEFAULT
16
+ #condition = DEFAULT
17
+
18
+ /**
19
+ *
20
+ * @type {Behavior|null}
21
+ */
22
+ #current = null;
23
+
24
+ /**
25
+ *
26
+ * @param {Behavior} condition
27
+ * @param {Behavior} successBranch
28
+ * @param {Behavior} failureBranch
29
+ */
30
+ static from(
31
+ condition,
32
+ successBranch = DEFAULT,
33
+ failureBranch = DEFAULT
34
+ ) {
35
+ assert.defined(condition, 'condition');
36
+ assert.notNull(condition, 'condition');
37
+ assert.equal(condition.isBehavior, true, 'condition.isBehavior !== true');
38
+
39
+ assert.defined(successBranch, 'successBranch');
40
+ assert.notNull(successBranch, 'successBranch');
41
+ assert.equal(successBranch.isBehavior, true, 'successBranch.isBehavior !== true');
42
+
43
+ assert.defined(failureBranch, 'failureBranch');
44
+ assert.notNull(failureBranch, 'failureBranch');
45
+ assert.equal(failureBranch.isBehavior, true, 'failureBranch.isBehavior !== true');
46
+
47
+
48
+ const r = new BranchBehavior();
49
+
50
+ r.#condition = condition;
51
+ r.#successBranch = successBranch;
52
+ r.#failureBranch = failureBranch;
53
+
54
+ return r;
55
+ }
56
+
57
+
58
+ initialize(context) {
59
+ super.initialize(context);
60
+
61
+ this.#current = this.#condition;
62
+ this.#current.initialize(context);
63
+ }
64
+
65
+ tick(timeDelta) {
66
+ const s = this.#current.tick(timeDelta);
67
+
68
+ if (s !== BehaviorStatus.Succeeded && s !== BehaviorStatus.Failed) {
69
+
70
+ // current behavior was not resolved, continue
71
+ return s;
72
+
73
+ }
74
+
75
+ if (this.#current !== this.#condition) {
76
+ // underlying branch was resolved
77
+ return s;
78
+ }
79
+
80
+ // condition was resolved, move onto a branch
81
+ this.#current.finalize();
82
+
83
+ if (s === BehaviorStatus.Succeeded) {
84
+ this.#current = this.#successBranch;
85
+ } else {
86
+ this.#current = this.#failureBranch;
87
+ }
88
+
89
+ this.#current.initialize(this.context);
90
+
91
+ return this.#current.tick(timeDelta);
92
+ }
93
+
94
+ finalize() {
95
+ super.finalize();
96
+
97
+ if (this.#current !== null) {
98
+ this.#current.finalize()
99
+ }
100
+ }
101
+
102
+ }
@@ -1,83 +0,0 @@
1
- import { CompositeBehavior } from "../composite/CompositeBehavior.js";
2
- import { BehaviorStatus } from "../BehaviorStatus.js";
3
-
4
- export class SelectorBehavior extends CompositeBehavior {
5
- constructor() {
6
- super();
7
-
8
- this.__index = 0;
9
- }
10
-
11
- /**
12
- *
13
- * @param {Behavior[]} children
14
- * @return {SelectorBehavior}
15
- */
16
- static from(children) {
17
- const r = new SelectorBehavior();
18
-
19
- r.__children = children.slice();
20
-
21
- return r;
22
- }
23
-
24
- tick(timeDelta) {
25
- const children = this.__children;
26
- const child_count = children.length;
27
-
28
- if (child_count === 0) {
29
- // arbitrarily decide success
30
- return BehaviorStatus.Succeeded;
31
- }
32
-
33
- for (; ;) {
34
- const child = children[this.__index];
35
-
36
- const s = child.tick(timeDelta);
37
-
38
- //if child succeeds or keeps running, do the same
39
- if (s !== BehaviorStatus.Failed) {
40
- return s;
41
- }
42
-
43
-
44
- //continue search for fallback behavior until the last child
45
- this.__index++;
46
-
47
- if (this.__index >= child_count) {
48
- return BehaviorStatus.Failed;
49
- }
50
-
51
- //initialize new child
52
- const next = children[this.__index];
53
-
54
- child.finalize();
55
- next.initialize(this.context);
56
- }
57
-
58
- //we should never reach this point
59
- return BehaviorStatus.Invalid;
60
- }
61
-
62
- finalize() {
63
- super.finalize();
64
-
65
- if (this.__children.length > 0) {
66
- const b = this.__children[this.__index];
67
-
68
- b.finalize();
69
- }
70
- }
71
-
72
-
73
- initialize(context) {
74
- super.initialize(context);
75
-
76
- this.__index = 0;
77
-
78
- if (this.__children.length > 0) {
79
- this.__children[0].initialize(context);
80
- }
81
- }
82
-
83
- }