@woosh/meep-engine 2.88.4 → 2.89.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.
@@ -63677,13 +63677,13 @@ function makeTerrainWorkerProxy() {
63677
63677
  }
63678
63678
 
63679
63679
  class OffsetScaleTransform2D {
63680
- constructor() {
63681
- this.offset_x = 0;
63682
- this.offset_y = 0;
63683
63680
 
63684
- this.scale_x = 1;
63685
- this.scale_y = 1;
63686
- }
63681
+ offset_x = 0;
63682
+ offset_y = 0;
63683
+
63684
+ scale_x = 1;
63685
+ scale_y = 1;
63686
+
63687
63687
  }
63688
63688
 
63689
63689
  /**
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.88.4",
8
+ "version": "2.89.0",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -6,10 +6,7 @@ import Entity from "../../ecs/Entity.js";
6
6
  import { Transform } from "../../ecs/transform/Transform.js";
7
7
  import { EngineHarness } from "../../EngineHarness.js";
8
8
  import { SGMesh } from "../../graphics/ecs/mesh-v2/aggregate/SGMesh.js";
9
- import {
10
- AnimationPlayback,
11
- SGMeshAnimationController
12
- } from "../../graphics/ecs/mesh-v2/aggregate/SGMeshAnimationController.js";
9
+ import { SGMeshAnimationController } from "../../graphics/ecs/mesh-v2/aggregate/SGMeshAnimationController.js";
13
10
  import {
14
11
  SGMeshAnimationControllerSystem
15
12
  } from "../../graphics/ecs/mesh-v2/aggregate/SGMeshAnimationControllerSystem.js";
@@ -55,11 +52,7 @@ async function main(engine) {
55
52
  'Linear Translation'
56
53
  ].forEach(name => {
57
54
 
58
- const playback = new AnimationPlayback();
59
- playback.clip_name = name;
60
- playback.loop = true;
61
-
62
- controller.active.push(playback)
55
+ controller.start(name,true);
63
56
 
64
57
  })
65
58
 
@@ -1 +1 @@
1
- {"version":3,"file":"OffsetScaleTransform2D.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/terrain/ecs/OffsetScaleTransform2D.js"],"names":[],"mappings":"AAAA;IAEQ,iBAAiB;IACjB,iBAAiB;IAEjB,gBAAgB;IAChB,gBAAgB;CAEvB"}
1
+ {"version":3,"file":"OffsetScaleTransform2D.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/terrain/ecs/OffsetScaleTransform2D.js"],"names":[],"mappings":"AAAA;IAEI,iBAAa;IACb,iBAAa;IAEb,gBAAY;IACZ,gBAAY;CAEf"}
@@ -1,9 +1,9 @@
1
1
  export class OffsetScaleTransform2D {
2
- constructor() {
3
- this.offset_x = 0;
4
- this.offset_y = 0;
5
2
 
6
- this.scale_x = 1;
7
- this.scale_y = 1;
8
- }
3
+ offset_x = 0;
4
+ offset_y = 0;
5
+
6
+ scale_x = 1;
7
+ scale_y = 1;
8
+
9
9
  }
@@ -9,7 +9,32 @@ export class SGMeshAnimationController {
9
9
  * @type {EntityNodeAnimationClip[]}
10
10
  */
11
11
  bound: EntityNodeAnimationClip[];
12
- getBoundByName(name: any): EntityNodeAnimationClip;
12
+ /**
13
+ *
14
+ * @param {string} name
15
+ * @return {EntityNodeAnimationClip|undefined}
16
+ */
17
+ getBoundByName(name: string): EntityNodeAnimationClip | undefined;
18
+ /**
19
+ *
20
+ * @param {string} name
21
+ * @return {AnimationPlayback|undefined}
22
+ */
23
+ getActiveByName(name: string): AnimationPlayback | undefined;
24
+ /**
25
+ *
26
+ * @param {string} name
27
+ * @param {boolean} loop
28
+ * @param {number} time_offset
29
+ * @returns {AnimationPlayback}
30
+ */
31
+ start(name: string, loop?: boolean, time_offset?: number): AnimationPlayback;
32
+ /**
33
+ *
34
+ * @param {AnimationPlayback} playback
35
+ * @return {boolean}
36
+ */
37
+ stop(playback: AnimationPlayback): boolean;
13
38
  }
14
39
  export class AnimationPlayback {
15
40
  clip_name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"SGMeshAnimationController.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationController.js"],"names":[],"mappings":"AAAA;IACI;;;OAGG;IACH,QAFU,iBAAiB,EAAE,CAElB;IAEX;;;OAGG;IACH,OAFU,yBAAyB,CAEzB;IAEV,mDAEC;CACJ;AAED;IACI,kBAAc;IACd,aAAQ;IACR,cAAY;CACf"}
1
+ {"version":3,"file":"SGMeshAnimationController.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationController.js"],"names":[],"mappings":"AAGA;IACI;;;OAGG;IACH,QAFU,iBAAiB,EAAE,CAElB;IAEX;;;OAGG;IACH,OAFU,yBAAyB,CAEzB;IAEV;;;;OAIG;IACH,qBAHW,MAAM,GACL,0BAAwB,SAAS,CAM5C;IAED;;;;OAIG;IACH,sBAHW,MAAM,GACL,iBAAiB,GAAC,SAAS,CAMtC;IAGD;;;;;;OAMG;IACH,YALW,MAAM,SACN,OAAO,gBACP,MAAM,GACJ,iBAAiB,CAgB7B;IAED;;;;OAIG;IACH,eAHW,iBAAiB,GAChB,OAAO,CAQlB;CACJ;AAED;IACI,kBAAc;IACd,aAAQ;IACR,cAAY;CACf"}
@@ -1,3 +1,6 @@
1
+ import { assert } from "../../../../../core/assert.js";
2
+ import { array_remove_first } from "../../../../../core/collection/array/array_remove_first.js";
3
+
1
4
  export class SGMeshAnimationController {
2
5
  /**
3
6
  *
@@ -11,9 +14,64 @@ export class SGMeshAnimationController {
11
14
  */
12
15
  bound = []
13
16
 
17
+ /**
18
+ *
19
+ * @param {string} name
20
+ * @return {EntityNodeAnimationClip|undefined}
21
+ */
14
22
  getBoundByName(name) {
23
+ assert.isString(name, 'name');
24
+
15
25
  return this.bound.find(b => b.name === name);
16
26
  }
27
+
28
+ /**
29
+ *
30
+ * @param {string} name
31
+ * @return {AnimationPlayback|undefined}
32
+ */
33
+ getActiveByName(name) {
34
+ assert.isString(name, 'name');
35
+
36
+ return this.active.find(a => a.clip_name === name);
37
+ }
38
+
39
+
40
+ /**
41
+ *
42
+ * @param {string} name
43
+ * @param {boolean} loop
44
+ * @param {number} time_offset
45
+ * @returns {AnimationPlayback}
46
+ */
47
+ start(name, loop = false, time_offset = 0) {
48
+ assert.isString(name, 'name');
49
+ assert.isBoolean(loop, 'loop');
50
+ assert.isNumber(time_offset, 'time_offset');
51
+
52
+ const playback = new AnimationPlayback();
53
+
54
+ playback.clip_name = name;
55
+ playback.loop = loop;
56
+ playback.time = time_offset;
57
+
58
+ this.active.push(playback);
59
+
60
+ return playback;
61
+ }
62
+
63
+ /**
64
+ *
65
+ * @param {AnimationPlayback} playback
66
+ * @return {boolean}
67
+ */
68
+ stop(playback) {
69
+
70
+ assert.defined(playback, 'playback');
71
+ assert.notNull(playback, 'playback');
72
+
73
+ return array_remove_first(this.active, playback)
74
+ }
17
75
  }
18
76
 
19
77
  export class AnimationPlayback {
@@ -1 +1 @@
1
- {"version":3,"file":"SGMeshAnimationControllerSystem.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationControllerSystem.js"],"names":[],"mappings":"AAQA;IAII;;;OAGG;IACH,4BAeC;IAZG,eAAoB;IAEpB,mEAGC;IAED,gIAGC;IAuCL;;;;;OAKG;IACH,WAJW,yBAAyB,QACzB,MAAM,UACN,MAAM,iBAUhB;IAED,sBA8CC;;CACJ;uBAhIsB,2BAA2B;uBAE3B,aAAa;0CACM,gCAAgC;4CAL9B,0DAA0D"}
1
+ {"version":3,"file":"SGMeshAnimationControllerSystem.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationControllerSystem.js"],"names":[],"mappings":"AAQA;IAaI;;;OAGG;IACH,4BAeC;IAZG,eAAoB;IAEpB,mEAGC;IAED,gIAGC;IA2CL;;;;;OAKG;IACH,WAJW,yBAAyB,QACzB,MAAM,UACN,MAAM,iBAUhB;IA6CD,sBAoBC;;CACJ;uBA9JsB,2BAA2B;uBAE3B,aAAa;0CACM,gCAAgC;4CAL9B,0DAA0D"}
@@ -7,7 +7,16 @@ import { SGMesh } from "./SGMesh.js";
7
7
  import { SGMeshAnimationController } from "./SGMeshAnimationController.js";
8
8
 
9
9
  export class SGMeshAnimationControllerSystem extends System {
10
+ /**
11
+ * Current time delta
12
+ * @type {number}
13
+ */
14
+ #time_delta = 0;
10
15
 
16
+ /**
17
+ * Entity queue
18
+ * @type {number[]}
19
+ */
11
20
  #queue = [];
12
21
 
13
22
  /**
@@ -62,6 +71,10 @@ export class SGMeshAnimationControllerSystem extends System {
62
71
  console.log(asset, animations);
63
72
  }
64
73
 
74
+ /**
75
+ *
76
+ * @param {number} entity
77
+ */
65
78
  #enqueue(entity) {
66
79
  this.#queue.push(entity);
67
80
  }
@@ -82,7 +95,51 @@ export class SGMeshAnimationControllerSystem extends System {
82
95
  await this.#process(entity);
83
96
  }
84
97
 
98
+ /**
99
+ *
100
+ * @param {SGMeshAnimationController} controller
101
+ */
102
+ #visit_entity(controller) {
103
+
104
+ const active = controller.active;
105
+
106
+ let active_count = active.length;
107
+
108
+ for (let i = 0; i < active_count; i++) {
109
+ const playback = active[i];
110
+
111
+ playback.time += this.#time_delta;
112
+
113
+ const clip = controller.getBoundByName(playback.clip_name);
114
+
115
+ if (clip === undefined) {
116
+ // clip doesn't exist
117
+ continue;
118
+ }
119
+
120
+ let t = playback.time;
121
+
122
+ if (t > clip.duration) {
123
+ if (playback.loop) {
124
+ t = t % clip.duration;
125
+ } else {
126
+ t = clip.duration;
127
+
128
+ // remove active
129
+ active.splice(i, 1);
130
+
131
+ i--;
132
+ active_count--;
133
+ }
134
+ }
135
+
136
+ clip.writeAt(t);
137
+
138
+ }
139
+ }
140
+
85
141
  update(td) {
142
+ this.#time_delta = td;
86
143
 
87
144
  for (let i = 0; i < 1000; i++) {
88
145
  if (this.#queue.length === 0) {
@@ -100,33 +157,6 @@ export class SGMeshAnimationControllerSystem extends System {
100
157
  return;
101
158
  }
102
159
 
103
- ecd.traverseComponents(SGMeshAnimationController, (controller) => {
104
-
105
- const active = controller.active;
106
-
107
- for (let i = 0; i < active.length; i++) {
108
- const playback = active[i];
109
-
110
- playback.time += td;
111
-
112
- const clip = controller.getBoundByName(playback.clip_name);
113
-
114
- if (clip !== undefined) {
115
- let t= playback.time;
116
-
117
- if (t > clip.duration) {
118
- if (playback.loop) {
119
- t = t%clip.duration;
120
- }else{
121
- t = clip.duration;
122
- }
123
- }
124
-
125
- clip.writeAt(t);
126
- }
127
-
128
- }
129
-
130
- });
160
+ ecd.traverseComponents(SGMeshAnimationController, this.#visit_entity, this);
131
161
  }
132
162
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeEngine.d.ts","sourceRoot":"","sources":["../../../../src/generation/theme/ThemeEngine.js"],"names":[],"mappings":"AAsFA;IAEI;;;OAGG;IACH,OAFU,uBAAuB,CAEN;IAE3B;;;OAGG;IACH,cAFqB,MAAM,CAEF;IAEzB;;;;OAIG;IACH,uBAAsB;IAEtB,2BAEC;IAED;;;OAGG;IACH,sBAEC;IAED;;;OAGG;IACH,mBAEC;IAED;;;OAGG;IACH,4BAUC;IAED;;;;;;OAMG;IACH,4BALW,WAAW,KACX,MAAM,KACN,MAAM,GACJ,MAAM,CA8BlB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,gDAGJ,IAAI,CAmChB;IAED;;;;;OAKG;IACH,sDAFa,SAAS,CAiLrB;IAED;;;;;;OAMG;IACH,+DAHW,MAAM,GACJ,IAAI,GAAC,SAAS,CAoG1B;IAED;;;;OAIG;IACH,kEAqCC;IAED;;;;OAIG;IACH,iCAFa,IAAI,CAIhB;IAED;;;;OAIG;IACH,uCAHa,SAAS,CAYrB;IAED;;;;;OAKG;IACH,oDAFa,SAAS,CA2DrB;CACJ;6BAloB4B,8CAA8C;iBAK1D,iCAAiC;sBAC5B,sCAAsC"}
1
+ {"version":3,"file":"ThemeEngine.d.ts","sourceRoot":"","sources":["../../../../src/generation/theme/ThemeEngine.js"],"names":[],"mappings":"AAoFA;IAEI;;;OAGG;IACH,OAFU,uBAAuB,CAEN;IAE3B;;;OAGG;IACH,cAFqB,MAAM,CAEF;IAEzB;;;;OAIG;IACH,uBAAsB;IAEtB,2BAEC;IAED;;;OAGG;IACH,sBAEC;IAED;;;OAGG;IACH,mBAEC;IAED;;;OAGG;IACH,4BAUC;IAED;;;;;;OAMG;IACH,4BALW,WAAW,KACX,MAAM,KACN,MAAM,GACJ,MAAM,CA8BlB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,gDAGJ,IAAI,CAmChB;IAED;;;;;OAKG;IACH,sDAFa,SAAS,CAiLrB;IAED;;;;;;OAMG;IACH,+DAHW,MAAM,GACJ,IAAI,GAAC,SAAS,CAoG1B;IAED;;;;OAIG;IACH,kEAqCC;IAED;;;;OAIG;IACH,iCAFa,IAAI,CAIhB;IAED;;;;OAIG;IACH,uCAHa,SAAS,CAYrB;IAED;;;;;OAKG;IACH,oDAFa,SAAS,CA6DrB;CACJ;6BAloB4B,8CAA8C;iBAK1D,iCAAiC;sBAC5B,sCAAsC"}
@@ -70,8 +70,6 @@ function makeTaskEnsureAllTiles(terrain) {
70
70
  terrain.buildNonVisual();
71
71
  }
72
72
 
73
- terrain.__tiles.rebuild();
74
-
75
73
  terrain.promiseAllTiles()
76
74
  .then(resolve, reject)
77
75
  .finally(() => {
@@ -612,10 +610,12 @@ export class ThemeEngine {
612
610
 
613
611
  if (terrain !== null) {
614
612
  // build terrain tiles
615
- const tTerrainGeometry = makeTaskEnsureAllTiles(terrain);
616
613
  const tTerrain = this.applyTerrainThemes(grid, terrain);
617
614
  tTerrain.addDependency(tInitializeThemes);
618
615
 
616
+ const tTerrainGeometry = makeTaskEnsureAllTiles(terrain);
617
+ tTerrainGeometry.addDependency(tTerrain);
618
+
619
619
  const tUpdateTerrain = this.updateTerrain(terrain);
620
620
 
621
621
  tUpdateTerrain.addDependencies([