@woosh/meep-engine 2.33.51 → 2.33.52

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.
@@ -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
+ }
@@ -4,7 +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
7
  import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
9
8
  import { StandardFrameBuffers } from "../../StandardFrameBuffers.js";
10
9
  import { assert } from "../../../../core/assert.js";
@@ -15,18 +14,9 @@ import { assert } from "../../../../core/assert.js";
15
14
  * @returns {Group|Object3D}
16
15
  */
17
16
  function extractRenderable(emitter) {
18
-
19
-
20
17
  return emitter.mesh;
21
18
  }
22
19
 
23
- /**
24
- *
25
- * @param {ParticleEmitter} emitter
26
- */
27
- function putEmitterToSleep(emitter) {
28
- emitter.setFlag(ParticleEmitterFlag.Sleeping);
29
- }
30
20
 
31
21
  export class ParticleEmitterSystem extends System {
32
22
  /**
@@ -73,20 +63,9 @@ export class ParticleEmitterSystem extends System {
73
63
  */
74
64
  this.bvh = null;
75
65
 
76
- /**
77
- * @deprecated Use "Effect" API to achieve the same results
78
- * @type {ParticleEmitterLibrary}
79
- */
80
- this.__library = new ParticleEmitterLibrary(engine.assetManager);
81
-
82
66
  this.__handlers = [];
83
67
  }
84
68
 
85
- get library() {
86
- console.warn('Deprecated, use "Effect" API to achieve the same results');
87
- return this.__library;
88
- }
89
-
90
69
  get componentClass() {
91
70
  return ParticleEmitter;
92
71
  }
@@ -208,7 +187,7 @@ export class ParticleEmitterSystem extends System {
208
187
 
209
188
  graphicsEngine.on.preRender.add(preRenderHook);
210
189
 
211
- this.library.load_from_registry_file('data/database/particles/data.json').then(readyCallback, errorCallback);
190
+ readyCallback();
212
191
  }
213
192
 
214
193
  shutdown(entityManager, readyCallback, errorCallback) {
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.51",
8
+ "version": "2.33.52",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",