@woosh/meep-engine 2.46.24 → 2.46.26

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.
@@ -99861,25 +99861,34 @@ class RepeatBehavior extends AbstractDecoratorBehavior {
99861
99861
 
99862
99862
  RepeatBehavior.typeName = "RepeatBehavior";
99863
99863
 
99864
+ /**
99865
+ * @template CTX
99866
+ * @extends {Behavior<CTX>}
99867
+ */
99864
99868
  class ActionBehavior extends Behavior {
99865
99869
  /**
99866
99870
  *
99867
- * @param {function(timeDelta:number)} action
99868
- * @param {*} [context]
99871
+ * @param {function(timeDelta:number, context:CTX)} func
99872
+ * @param {*} [thisArg] defaults to behavior itself if not specified
99869
99873
  */
99870
- constructor(action, context) {
99874
+ constructor(func, thisArg) {
99871
99875
  super();
99872
99876
 
99873
- assert.typeOf(action, 'function', "action");
99877
+ assert.typeOf(func, 'function', "action");
99874
99878
 
99875
- this.__action = action;
99876
- this.__context = context;
99879
+ this.__action = func;
99880
+
99881
+ if (thisArg === undefined) {
99882
+ this.__context = this;
99883
+ } else {
99884
+ this.__context = thisArg;
99885
+ }
99877
99886
  }
99878
99887
 
99879
99888
  tick(timeDelta) {
99880
99889
 
99881
99890
  try {
99882
- this.__action.call(this.__context, timeDelta);
99891
+ this.__action.call(this.__context, timeDelta, this.context);
99883
99892
 
99884
99893
  return BehaviorStatus.Succeeded;
99885
99894
 
@@ -120309,7 +120318,7 @@ class LightManager {
120309
120318
  */
120310
120319
  this.__visible_bvh_needs_update = true;
120311
120320
 
120312
- window.light_manager = this; // DEBUG
120321
+ // window.light_manager = this; // DEBUG
120313
120322
  }
120314
120323
 
120315
120324
  /**
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.46.24",
8
+ "version": "2.46.26",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -112,7 +112,7 @@ export class NodeGraphVisualData {
112
112
  *
113
113
  * @param {NodeInstancePortReference} ref
114
114
  */
115
- const getEndpointLayputSpec = (ref) => {
115
+ const getEndpointLayoutSpec = (ref) => {
116
116
  const endpoint = endpoints.get(ref);
117
117
 
118
118
  if (endpoint !== undefined) {
@@ -141,8 +141,8 @@ export class NodeGraphVisualData {
141
141
  }
142
142
 
143
143
  graph.traverseConnections(connection => {
144
- const source = getEndpointLayputSpec(connection.source);
145
- const target = getEndpointLayputSpec(connection.target);
144
+ const source = getEndpointLayoutSpec(connection.source);
145
+ const target = getEndpointLayoutSpec(connection.target);
146
146
 
147
147
  const spec = ConnectionLayoutSpec.from(
148
148
  source,
@@ -0,0 +1,4 @@
1
+ export class LightShadow {
2
+ resolution = 32
3
+
4
+ }
@@ -326,7 +326,7 @@ export class LightManager {
326
326
  */
327
327
  this.__visible_bvh_needs_update = true;
328
328
 
329
- window.light_manager = this; // DEBUG
329
+ // window.light_manager = this; // DEBUG
330
330
  }
331
331
 
332
332
  /**
@@ -2,25 +2,34 @@ import { Behavior } from "../Behavior.js";
2
2
  import { BehaviorStatus } from "../BehaviorStatus.js";
3
3
  import { assert } from "../../../../core/assert.js";
4
4
 
5
+ /**
6
+ * @template CTX
7
+ * @extends {Behavior<CTX>}
8
+ */
5
9
  export class ActionBehavior extends Behavior {
6
10
  /**
7
11
  *
8
- * @param {function(timeDelta:number)} action
9
- * @param {*} [context]
12
+ * @param {function(timeDelta:number, context:CTX)} func
13
+ * @param {*} [thisArg] defaults to behavior itself if not specified
10
14
  */
11
- constructor(action, context) {
15
+ constructor(func, thisArg) {
12
16
  super();
13
17
 
14
- assert.typeOf(action, 'function', "action");
18
+ assert.typeOf(func, 'function', "action");
15
19
 
16
- this.__action = action;
17
- this.__context = context;
20
+ this.__action = func;
21
+
22
+ if (thisArg === undefined) {
23
+ this.__context = this;
24
+ } else {
25
+ this.__context = thisArg;
26
+ }
18
27
  }
19
28
 
20
29
  tick(timeDelta) {
21
30
 
22
31
  try {
23
- this.__action.call(this.__context, timeDelta);
32
+ this.__action.call(this.__context, timeDelta, this.context);
24
33
 
25
34
  return BehaviorStatus.Succeeded;
26
35
 
@@ -0,0 +1,97 @@
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
+ export class BranchBehavior extends Behavior {
9
+ #successBranch = DEFAULT
10
+ #failureBranch = DEFAULT
11
+ #condition = DEFAULT
12
+
13
+ /**
14
+ *
15
+ * @type {Behavior|null}
16
+ */
17
+ #current = null;
18
+
19
+ /**
20
+ *
21
+ * @param {Behavior} condition
22
+ * @param {Behavior} successBranch
23
+ * @param {Behavior} failureBranch
24
+ */
25
+ static from(
26
+ condition,
27
+ successBranch = DEFAULT,
28
+ failureBranch = DEFAULT
29
+ ) {
30
+ assert.defined(condition, 'condition');
31
+ assert.notNull(condition, 'condition');
32
+ assert.equal(condition.isBehavior, true, 'condition.isBehavior !== true');
33
+
34
+ assert.defined(successBranch, 'successBranch');
35
+ assert.notNull(successBranch, 'successBranch');
36
+ assert.equal(successBranch.isBehavior, true, 'successBranch.isBehavior !== true');
37
+
38
+ assert.defined(failureBranch, 'failureBranch');
39
+ assert.notNull(failureBranch, 'failureBranch');
40
+ assert.equal(failureBranch.isBehavior, true, 'failureBranch.isBehavior !== true');
41
+
42
+
43
+ const r = new BranchBehavior();
44
+
45
+ r.#condition = condition;
46
+ r.#successBranch = successBranch;
47
+ r.#failureBranch = failureBranch;
48
+
49
+ return r;
50
+ }
51
+
52
+
53
+ initialize(context) {
54
+ super.initialize(context);
55
+
56
+ this.#current = this.#condition;
57
+ this.#current.initialize(context);
58
+ }
59
+
60
+ tick(timeDelta) {
61
+ const s = this.#current.tick(timeDelta);
62
+
63
+ if (s !== BehaviorStatus.Succeeded && s !== BehaviorStatus.Failed) {
64
+
65
+ // current behavior was not resolved, continue
66
+ return s;
67
+
68
+ }
69
+
70
+ if (this.#current !== this.#condition) {
71
+ // underlying branch was resolved
72
+ return s;
73
+ }
74
+
75
+ // condition was resolved, move onto a branch
76
+ this.#current.finalize();
77
+
78
+ if (s === BehaviorStatus.Succeeded) {
79
+ this.#current = this.#successBranch;
80
+ } else {
81
+ this.#current = this.#failureBranch;
82
+ }
83
+
84
+ this.#current.initialize(this.context);
85
+
86
+ return this.#current.tick(timeDelta);
87
+ }
88
+
89
+ finalize() {
90
+ super.finalize();
91
+
92
+ if (this.#current !== null) {
93
+ this.#current.finalize()
94
+ }
95
+ }
96
+
97
+ }