@woosh/meep-engine 2.33.49 → 2.33.53

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.
@@ -16,7 +16,7 @@ export function read_property(root, parts, part_offset, part_count) {
16
16
 
17
17
  const part = parts[i + part_offset];
18
18
 
19
- if (thing.hasOwnProperty(part)) {
19
+ if (typeof thing[part] !== 'undefined') {
20
20
  thing = thing[part];
21
21
  } else {
22
22
  const getter_name = `get${capitalize(part)}`;
@@ -17,7 +17,7 @@ export function write_property(root, parts, part_offset, part_count, value) {
17
17
 
18
18
  const part = parts[i + part_offset];
19
19
 
20
- if (thing.hasOwnProperty(part)) {
20
+ if (typeof thing[part] !== 'undefined') {
21
21
  thing = thing[part];
22
22
  } else {
23
23
 
@@ -42,11 +42,9 @@ export function write_property(root, parts, part_offset, part_count, value) {
42
42
  if (typeof setter === "function") {
43
43
  // resolve via setter
44
44
  setter.call(thing, value);
45
- } else if (thing.hasOwnProperty(last_part)) {
46
- thing[last_part] = value;
47
45
  } else {
48
- // no setter
49
- throw new Error(`No no property or getter found for '${last_part}' on [${part_count - 1}]'${parts.slice(part_offset, part_offset + part_count).join('/')}'`);
46
+ // write directly to the field
47
+ thing[last_part] = value;
50
48
  }
51
49
  }
52
50
 
@@ -7,10 +7,8 @@ import { removeComponentsExcept } from "../ecs/util/removeComponentsExcept.js";
7
7
  import { createSound, createTimer } from "../EntityCreator.js";
8
8
  import Mesh from "../graphics/ecs/mesh/Mesh.js";
9
9
  import Trail2D, { Trail2DFlags } from "../graphics/ecs/trail2d/Trail2D.js";
10
- import { ParticleEmitterSystem } from "../graphics/particles/ecs/ParticleEmitterSystem.js";
11
10
  import { ParticleEmitter } from "../graphics/particles/particular/engine/emitter/ParticleEmitter.js";
12
11
  import { ParticleEmitterFlag } from "../graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js";
13
- import { distributeParticlesOnObject3D } from "../graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js";
14
12
  import { SequenceBehavior } from "../intelligence/behavior/composite/SequenceBehavior.js";
15
13
  import { BehaviorComponent } from "../intelligence/behavior/ecs/BehaviorComponent.js";
16
14
  import { ActionBehavior } from "../intelligence/behavior/primitive/ActionBehavior.js";
@@ -118,124 +116,6 @@ export function stopEmitterAndNotifyOnceFinished(entity, ecd) {
118
116
  }
119
117
 
120
118
 
121
- /**
122
- *
123
- * @param {EntityManager} entityManager
124
- * @param {EntityComponentDataset} ecd
125
- * @param {number} entity
126
- * @param {string} particles
127
- * @returns {Promise<any>}
128
- */
129
- export function removeEntityWithMeshParticlesEffect(
130
- {
131
- entityManager,
132
- ecd,
133
- entity,
134
- particles = 'mesh-cloud-puff-0'
135
- }
136
- ) {
137
-
138
- /**
139
- *
140
- * @type {ParticleEmitterSystem}
141
- */
142
- const sPE = entityManager.getSystem(ParticleEmitterSystem);
143
-
144
- /**
145
- *
146
- * @type {ParticleEmitterLibrary}
147
- */
148
- const emitterLibrary = sPE.library;
149
-
150
- const emitter = emitterLibrary.create(particles);
151
-
152
- //get entity mesh
153
-
154
- const cMesh = ecd.getComponent(entity, Mesh);
155
-
156
- if (cMesh !== undefined) {
157
- if (cMesh.mesh !== null) {
158
- const randomSeed = Math.random() * 1000000;
159
-
160
- distributeParticlesOnObject3D(emitter, randomSeed, cMesh.mesh);
161
- }
162
- }
163
-
164
- //prevent further interactions
165
- removeComponentsExcept(ecd, entity, [Mesh, ParticleEmitter, Trail2D, Transform]);
166
-
167
- /**
168
- *
169
- * @type {Transform}
170
- */
171
- const originalTransform = ecd.getComponent(entity, Transform);
172
-
173
- if (originalTransform === undefined) {
174
- throw new Error(`entity ${entity} doesn't have Transform`);
175
- }
176
-
177
- //create particle emitter
178
- const effectBuilder = new EntityBuilder();
179
- const effectEntity = effectBuilder
180
- .add(emitter)
181
- .add(originalTransform.clone())
182
- .build(ecd);
183
-
184
- Promise.all([
185
- stopEntityAndNotifyWhenStopped(effectEntity, ecd)
186
- ])
187
- .then(() => effectBuilder.destroy());
188
-
189
- return stopEntityAndNotifyWhenStopped(entity, ecd)
190
- .then(() => {
191
- ecd.removeEntity(entity);
192
- });
193
-
194
- }
195
-
196
- /**
197
- *
198
- * @param {Engine} engine
199
- * @param {EntityComponentDataset} ecd
200
- * @param {number} entity
201
- * @param {string} [particles]
202
- * @param {string} [sound]
203
- * @returns {Promise<any>}
204
- */
205
- export function removeEntityGenericEffect(
206
- {
207
- engine,
208
- ecd,
209
- entity,
210
- particles = 'cloud-puff',
211
- sound = "data/sounds/effects/Magic_Game_Essentials/Magic_Vanish_3.wav"
212
- }
213
- ) {
214
-
215
- /**
216
- *
217
- * @type {ParticleEmitterSystem}
218
- */
219
- const sPE = engine.entityManager.getSystem(ParticleEmitterSystem);
220
-
221
- /**
222
- *
223
- * @type {ParticleEmitterLibrary}
224
- */
225
- const emitterLibrary = sPE.library;
226
-
227
- const emitter = emitterLibrary.create(particles);
228
-
229
- const result = removeEntityWithEffect({
230
- entity,
231
- ecd,
232
- emitter,
233
- soundEffect: sound
234
- });
235
-
236
- return result;
237
- }
238
-
239
119
  /**
240
120
  *
241
121
  * @param {number} entity
@@ -0,0 +1,168 @@
1
+ import { removeEntityWithEffect } from "./AnimationUtils.js";
2
+ import { ParticleEmitter } from "../graphics/particles/particular/engine/emitter/ParticleEmitter.js";
3
+
4
+ const lib = {
5
+ 'cloud-puff': {
6
+ "position": {
7
+ "x": 56.41791044776119,
8
+ "y": -8.887834661270745,
9
+ "z": 223.65671641791042
10
+ },
11
+ "scale": {
12
+ "x": 1,
13
+ "y": 1,
14
+ "z": 1
15
+ },
16
+ "rotation": {
17
+ "x": 0,
18
+ "y": 0,
19
+ "z": 0,
20
+ "w": 1
21
+ },
22
+ "parameters": [
23
+ {
24
+ "name": "scale",
25
+ "itemSize": 1,
26
+ "defaultTrackValue": {
27
+ "itemSize": 1,
28
+ "data": [
29
+ 1
30
+ ],
31
+ "positions": [
32
+ 0
33
+ ]
34
+ }
35
+ },
36
+ {
37
+ "name": "color",
38
+ "itemSize": 4,
39
+ "defaultTrackValue": {
40
+ "itemSize": 4,
41
+ "data": [
42
+ 1,
43
+ 1,
44
+ 1,
45
+ 1
46
+ ],
47
+ "positions": [
48
+ 0
49
+ ]
50
+ }
51
+ }
52
+ ],
53
+ "blendingMode": 0,
54
+ "layers": [
55
+ {
56
+ "imageURL": "data/textures/particle/smokeparticle.png",
57
+ "particleLife": {
58
+ "min": 1.2,
59
+ "max": 1.5
60
+ },
61
+ "particleSize": {
62
+ "min": 1,
63
+ "max": 1.2
64
+ },
65
+ "particleRotation": {
66
+ "min": 0,
67
+ "max": 0
68
+ },
69
+ "particleRotationSpeed": {
70
+ "min": 0,
71
+ "max": 0
72
+ },
73
+ "emissionShape": 1,
74
+ "emissionFrom": 1,
75
+ "emissionRate": 0,
76
+ "emissionImmediate": 25,
77
+ "parameterTracks": [
78
+ {
79
+ "name": "color",
80
+ "track": {
81
+ "itemSize": 4,
82
+ "data": [
83
+ 0.9803921568627451,
84
+ 0.9803921568627451,
85
+ 0.9803921568627451,
86
+ 0.3,
87
+
88
+ 0.9882352941176471,
89
+ 0.9882352941176471,
90
+ 0.9882352941176471,
91
+ 0.9880952380952381,
92
+
93
+ 0.9882352941176471,
94
+ 0.9882352941176471,
95
+ 0.9882352941176471,
96
+ 0.5,
97
+
98
+ 0.9882352941176471,
99
+ 0.9882352941176471,
100
+ 0.9882352941176471,
101
+ 0
102
+ ],
103
+ "positions": [
104
+ 0,
105
+ 0.07,
106
+ 0.8097826086956522,
107
+ 1
108
+ ]
109
+ }
110
+ }
111
+ ],
112
+ "position": {
113
+ "x": 0,
114
+ "y": 0.6,
115
+ "z": 0
116
+ },
117
+ "scale": {
118
+ "x": 0.9,
119
+ "y": 0.5,
120
+ "z": 0.65
121
+ },
122
+ "particleVelocityDirection": {
123
+ "direction": {
124
+ "x": 0,
125
+ "y": 1,
126
+ "z": 0
127
+ },
128
+ "angle": 1.5
129
+ },
130
+ "particleSpeed": {
131
+ "min": 0.2,
132
+ "max": 0.5
133
+ }
134
+ }
135
+ ]
136
+ }
137
+ };
138
+
139
+ /**
140
+ *
141
+ * @param {Engine} engine
142
+ * @param {EntityComponentDataset} ecd
143
+ * @param {number} entity
144
+ * @param {string} [particles]
145
+ * @param {string} [sound]
146
+ * @returns {Promise<any>}
147
+ */
148
+ export function removeEntityGenericEffect(
149
+ {
150
+ engine,
151
+ ecd,
152
+ entity,
153
+ particles = 'cloud-puff',
154
+ sound = "data/sounds/effects/Magic_Game_Essentials/Magic_Vanish_3.wav"
155
+ }
156
+ ) {
157
+
158
+ const emitter = ParticleEmitter.fromJSON(lib[particles]);
159
+
160
+ const result = removeEntityWithEffect({
161
+ entity,
162
+ ecd,
163
+ emitter,
164
+ soundEffect: sound
165
+ });
166
+
167
+ return result;
168
+ }
@@ -0,0 +1,201 @@
1
+ import Mesh from "../graphics/ecs/mesh/Mesh.js";
2
+ import { distributeParticlesOnObject3D } from "../graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js";
3
+ import { removeComponentsExcept } from "../ecs/util/removeComponentsExcept.js";
4
+ import { ParticleEmitter } from "../graphics/particles/particular/engine/emitter/ParticleEmitter.js";
5
+ import Trail2D from "../graphics/ecs/trail2d/Trail2D.js";
6
+ import { Transform } from "../ecs/transform/Transform.js";
7
+ import EntityBuilder from "../ecs/EntityBuilder.js";
8
+ import { stopEntityAndNotifyWhenStopped } from "./AnimatedActions.js";
9
+
10
+ const lib = {
11
+ 'mesh-cloud-puff-0': {
12
+ "position": {
13
+ "x": 9.17416,
14
+ "y": -1.90031,
15
+ "z": 12.06082
16
+ },
17
+ "scale": {
18
+ "x": 1,
19
+ "y": 1,
20
+ "z": 1
21
+ },
22
+ "rotation": {
23
+ "x": 0,
24
+ "y": 0,
25
+ "z": 0,
26
+ "w": 1
27
+ },
28
+ "parameters": [
29
+ {
30
+ "name": "scale",
31
+ "itemSize": 1,
32
+ "defaultTrackValue": {
33
+ "itemSize": 1,
34
+ "data": [
35
+ 1
36
+ ],
37
+ "positions": [
38
+ 0
39
+ ]
40
+ }
41
+ },
42
+ {
43
+ "name": "color",
44
+ "itemSize": 4,
45
+ "defaultTrackValue": {
46
+ "itemSize": 4,
47
+ "data": [
48
+ 1,
49
+ 1,
50
+ 1,
51
+ 1
52
+ ],
53
+ "positions": [
54
+ 0
55
+ ]
56
+ }
57
+ }
58
+ ],
59
+ "preWarm": false,
60
+ "readDepth": true,
61
+ "softDepth": true,
62
+ "blendingMode": 0,
63
+ "layers": [
64
+ {
65
+ "imageURL": "data/textures/particle/smokeparticle.png",
66
+ "particleLife": {
67
+ "min": 0.6,
68
+ "max": 1.2
69
+ },
70
+ "particleSize": {
71
+ "min": 0.2,
72
+ "max": 0.3
73
+ },
74
+ "particleRotation": {
75
+ "min": 0,
76
+ "max": 0
77
+ },
78
+ "particleRotationSpeed": {
79
+ "min": 0,
80
+ "max": 0
81
+ },
82
+ "emissionShape": 1,
83
+ "emissionFrom": 1,
84
+ "emissionRate": 0,
85
+ "emissionImmediate": 1200,
86
+ "parameterTracks": [
87
+ {
88
+ "name": "color",
89
+ "track": {
90
+ "itemSize": 4,
91
+ "data": [
92
+ 0.9803921568627451,
93
+ 0.9803921568627451,
94
+ 0.9803921568627451,
95
+ 0.3,
96
+ 0.9882352941176471,
97
+ 0.9882352941176471,
98
+ 0.9882352941176471,
99
+ 0.265,
100
+ 0.9882352941176471,
101
+ 0.9882352941176471,
102
+ 0.9882352941176471,
103
+ 0
104
+ ],
105
+ "positions": [
106
+ 0,
107
+ 0.7957639171068672,
108
+ 1
109
+ ]
110
+ }
111
+ }
112
+ ],
113
+ "position": {
114
+ "x": 0,
115
+ "y": 0.6,
116
+ "z": 0
117
+ },
118
+ "scale": {
119
+ "x": 0.9,
120
+ "y": 0.5,
121
+ "z": 0.65
122
+ },
123
+ "particleVelocityDirection": {
124
+ "direction": {
125
+ "x": 0,
126
+ "y": 1,
127
+ "z": 0
128
+ },
129
+ "angle": 0
130
+ },
131
+ "particleSpeed": {
132
+ "min": 0.6,
133
+ "max": 1.1
134
+ }
135
+ }
136
+ ]
137
+ }
138
+ };
139
+
140
+ /**
141
+ *
142
+ * @param {EntityManager} entityManager
143
+ * @param {EntityComponentDataset} ecd
144
+ * @param {number} entity
145
+ * @param {string} particles
146
+ * @returns {Promise<any>}
147
+ */
148
+ export function removeEntityWithMeshParticlesEffect(
149
+ {
150
+ entityManager,
151
+ ecd,
152
+ entity,
153
+ particles = 'mesh-cloud-puff-0'
154
+ }
155
+ ) {
156
+
157
+ const emitter = ParticleEmitter.fromJSON(lib[particles]);
158
+
159
+ //get entity mesh
160
+
161
+ const cMesh = ecd.getComponent(entity, Mesh);
162
+
163
+ if (cMesh !== undefined) {
164
+ if (cMesh.mesh !== null) {
165
+ const randomSeed = Math.random() * 1000000;
166
+
167
+ distributeParticlesOnObject3D(emitter, randomSeed, cMesh.mesh);
168
+ }
169
+ }
170
+
171
+ //prevent further interactions
172
+ removeComponentsExcept(ecd, entity, [Mesh, ParticleEmitter, Trail2D, Transform]);
173
+
174
+ /**
175
+ *
176
+ * @type {Transform}
177
+ */
178
+ const originalTransform = ecd.getComponent(entity, Transform);
179
+
180
+ if (originalTransform === undefined) {
181
+ throw new Error(`entity ${entity} doesn't have Transform`);
182
+ }
183
+
184
+ //create particle emitter
185
+ const effectBuilder = new EntityBuilder();
186
+ const effectEntity = effectBuilder
187
+ .add(emitter)
188
+ .add(originalTransform.clone())
189
+ .build(ecd);
190
+
191
+ Promise.all([
192
+ stopEntityAndNotifyWhenStopped(effectEntity, ecd)
193
+ ])
194
+ .then(() => effectBuilder.destroy());
195
+
196
+ return stopEntityAndNotifyWhenStopped(entity, ecd)
197
+ .then(() => {
198
+ ecd.removeEntity(entity);
199
+ });
200
+
201
+ }
@@ -715,7 +715,7 @@ EntityManager.prototype.startup = function (readyCallback, errorCallback) {
715
715
  let firstFailure = true;
716
716
 
717
717
  function systemError(system, error) {
718
- console.error("Failed to start system", system);
718
+ console.error("Failed to start system", system, 'Error:', error);
719
719
 
720
720
  if (firstFailure) {
721
721
  firstFailure = false;
@@ -1,6 +1,7 @@
1
1
  import { ParticleEmitter } from "./particular/engine/emitter/ParticleEmitter.js";
2
2
  import { GameAssetType } from "../../asset/GameAssetType.js";
3
3
  import { assert } from "../../../core/assert.js";
4
+ import { JsonAssetLoader } from "../../asset/loaders/JsonAssetLoader.js";
4
5
 
5
6
  /**
6
7
  * @deprecated Use "Effect" API to achieve the same results
@@ -20,6 +21,26 @@ export class ParticleEmitterLibrary {
20
21
  this.data = {};
21
22
  }
22
23
 
24
+ /**
25
+ *
26
+ * @param {string} path
27
+ * @returns {Promise<void>}
28
+ */
29
+ async load_from_registry_file(path) {
30
+
31
+ const am = this.assetManager;
32
+
33
+ if (am.getLoaderByType(GameAssetType.JSON) === undefined) {
34
+ // add missing loader
35
+ await am.registerLoader(GameAssetType.JSON, new JsonAssetLoader());
36
+ }
37
+
38
+ const asset = await am.promise(path, GameAssetType.JSON)
39
+ const particleSet = asset.create();
40
+
41
+ await this.load(particleSet);
42
+ }
43
+
23
44
  /**
24
45
  * @param {Object} listing
25
46
  * @returns {Promise}
@@ -0,0 +1,7 @@
1
+ import {System} from "../../../ecs/System";
2
+ import Engine from "../../../Engine";
3
+ import {ParticleEmitter} from "../particular/engine/emitter/ParticleEmitter";
4
+
5
+ export class ParticleEmitterSystem extends System<ParticleEmitter> {
6
+ constructor(engine: Engine)
7
+ }
@@ -4,8 +4,6 @@ import { ParticularEngine } from "../particular/engine/ParticularEngine.js";
4
4
  import { Transform } from "../../../ecs/transform/Transform.js";
5
5
  import { ParticleEmitterFlag } from "../particular/engine/emitter/ParticleEmitterFlag.js";
6
6
  import { RenderPassType } from "../../render/RenderPassType.js";
7
- import { ParticleEmitterLibrary } from "../ParticleEmitterLibrary.js";
8
- import { GameAssetType } from "../../../asset/GameAssetType.js";
9
7
  import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
10
8
  import { StandardFrameBuffers } from "../../StandardFrameBuffers.js";
11
9
  import { assert } from "../../../../core/assert.js";
@@ -16,18 +14,9 @@ import { assert } from "../../../../core/assert.js";
16
14
  * @returns {Group|Object3D}
17
15
  */
18
16
  function extractRenderable(emitter) {
19
-
20
-
21
17
  return emitter.mesh;
22
18
  }
23
19
 
24
- /**
25
- *
26
- * @param {ParticleEmitter} emitter
27
- */
28
- function putEmitterToSleep(emitter) {
29
- emitter.setFlag(ParticleEmitterFlag.Sleeping);
30
- }
31
20
 
32
21
  export class ParticleEmitterSystem extends System {
33
22
  /**
@@ -74,20 +63,9 @@ export class ParticleEmitterSystem extends System {
74
63
  */
75
64
  this.bvh = null;
76
65
 
77
- /**
78
- * @deprecated Use "Effect" API to achieve the same results
79
- * @type {ParticleEmitterLibrary}
80
- */
81
- this.__library = new ParticleEmitterLibrary(engine.assetManager);
82
-
83
66
  this.__handlers = [];
84
67
  }
85
68
 
86
- get library() {
87
- console.warn('Deprecated, use "Effect" API to achieve the same results');
88
- return this.__library;
89
- }
90
-
91
69
  get componentClass() {
92
70
  return ParticleEmitter;
93
71
  }
@@ -209,15 +187,7 @@ export class ParticleEmitterSystem extends System {
209
187
 
210
188
  graphicsEngine.on.preRender.add(preRenderHook);
211
189
 
212
- const library = this.library;
213
-
214
- am.promise('data/database/particles/data.json', GameAssetType.JSON)
215
- .then(asset => {
216
- const particleSet = asset.create();
217
-
218
- return library.load(particleSet);
219
- })
220
- .then(readyCallback, errorCallback);
190
+ readyCallback();
221
191
  }
222
192
 
223
193
  shutdown(entityManager, readyCallback, errorCallback) {
@@ -0,0 +1,2 @@
1
+ export class ParticleEmitter {
2
+ }
@@ -154,28 +154,13 @@ export class ParticleVolume {
154
154
  "track": {
155
155
  "itemSize": 4,
156
156
  "data": [
157
- 0.5764705882352941,
158
- 0.5764705882352941,
159
- 0.5764705882352941,
160
- 0,
161
- 0.803921568627451,
162
- 0.803921568627451,
163
- 0.803921568627451,
164
- 0.28160919540229884,
165
- 0.803921568627451,
166
- 0.803921568627451,
167
- 0.803921568627451,
168
- 0.21264367816091953,
169
- 0.803921568627451,
170
- 0.803921568627451,
171
- 0.803921568627451,
172
- 0
157
+ 1,
158
+ 1,
159
+ 1,
160
+ 1,
173
161
  ],
174
162
  "positions": [
175
- 0,
176
- 0.18085106382978725,
177
- 0.7074468085106383,
178
- 1
163
+ 0
179
164
  ]
180
165
  }
181
166
  },
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "productName": "Meep",
6
6
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.33.49",
8
+ "version": "2.33.53",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",