@dcl/ecs 7.4.9 → 7.4.10-8392909116.commit-6487246

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.
@@ -229,6 +229,7 @@ export function Engine(options) {
229
229
  await crdtSystem.sendMessages(deletedEntites);
230
230
  }
231
231
  return {
232
+ _id: Date.now(),
232
233
  addEntity: partialEngine.addEntity,
233
234
  removeEntity: partialEngine.removeEntity,
234
235
  removeEntityWithChildren: partialEngine.removeEntityWithChildren,
@@ -44,6 +44,7 @@ export interface IEngineOptions {
44
44
  * @public
45
45
  */
46
46
  export interface IEngine {
47
+ _id: number;
47
48
  /**
48
49
  * @public
49
50
  * Increment the used entity counter and return the next one.
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from './systems/events';
8
8
  export * from './systems/raycast';
9
9
  export * from './systems/videoEvents';
10
10
  export * from './systems/async-task';
11
+ export * from './systems/tween';
11
12
  export * from './engine/entity';
12
13
  export * from './components/types';
13
14
  import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended, ISyncComponents, TweenComponentDefinitionExtended, INetowrkEntity, INetowrkParent } from './components/types';
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ export * from './systems/events';
9
9
  export * from './systems/raycast';
10
10
  export * from './systems/videoEvents';
11
11
  export * from './systems/async-task';
12
+ export * from './systems/tween';
12
13
  export * from './engine/entity';
13
14
  export * from './components/types';
14
15
  // @internal
@@ -1,4 +1,9 @@
1
- import { Entity } from '../engine';
1
+ import { Entity, IEngine } from '../engine';
2
2
  export type TweenSystem = {
3
3
  tweenCompleted(entity: Entity): boolean;
4
4
  };
5
+ /**
6
+ * @public
7
+ * @returns tween helper to be used on the scene
8
+ */
9
+ export declare function createTweenSystem(engine: IEngine): TweenSystem;
@@ -2,10 +2,17 @@ import * as components from '../components';
2
2
  import { ReadWriteByteBuffer } from '../serialization/ByteBuffer';
3
3
  import { dataCompare } from './crdt/utils';
4
4
  /**
5
- * @internal
5
+ * Avoid creating multiple tween systems
6
+ */
7
+ const cacheTween = new Map();
8
+ /**
9
+ * @public
6
10
  * @returns tween helper to be used on the scene
7
11
  */
8
12
  export function createTweenSystem(engine) {
13
+ if (cacheTween.has(engine._id)) {
14
+ return cacheTween.get(engine._id);
15
+ }
9
16
  const Tween = components.Tween(engine);
10
17
  const TweenState = components.TweenState(engine);
11
18
  const TweenSequence = components.TweenSequence(engine);
@@ -109,8 +116,10 @@ export function createTweenSystem(engine) {
109
116
  /* istanbul ignore next */
110
117
  throw new Error('Invalid tween');
111
118
  }
112
- return {
119
+ const tweenSystem = {
113
120
  // This event is fired only once per tween
114
121
  tweenCompleted: isCompleted
115
122
  };
123
+ cacheTween.set(engine._id, tweenSystem);
124
+ return tweenSystem;
116
125
  }
@@ -258,6 +258,7 @@ function Engine(options) {
258
258
  await crdtSystem.sendMessages(deletedEntites);
259
259
  }
260
260
  return {
261
+ _id: Date.now(),
261
262
  addEntity: partialEngine.addEntity,
262
263
  removeEntity: partialEngine.removeEntity,
263
264
  removeEntityWithChildren: partialEngine.removeEntityWithChildren,
@@ -44,6 +44,7 @@ export interface IEngineOptions {
44
44
  * @public
45
45
  */
46
46
  export interface IEngine {
47
+ _id: number;
47
48
  /**
48
49
  * @public
49
50
  * Increment the used entity counter and return the next one.
@@ -8,6 +8,7 @@ export * from './systems/events';
8
8
  export * from './systems/raycast';
9
9
  export * from './systems/videoEvents';
10
10
  export * from './systems/async-task';
11
+ export * from './systems/tween';
11
12
  export * from './engine/entity';
12
13
  export * from './components/types';
13
14
  import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended, ISyncComponents, TweenComponentDefinitionExtended, INetowrkEntity, INetowrkParent } from './components/types';
package/dist-cjs/index.js CHANGED
@@ -39,6 +39,7 @@ __exportStar(require("./systems/events"), exports);
39
39
  __exportStar(require("./systems/raycast"), exports);
40
40
  __exportStar(require("./systems/videoEvents"), exports);
41
41
  __exportStar(require("./systems/async-task"), exports);
42
+ __exportStar(require("./systems/tween"), exports);
42
43
  __exportStar(require("./engine/entity"), exports);
43
44
  __exportStar(require("./components/types"), exports);
44
45
  // @internal
@@ -1,4 +1,9 @@
1
- import { Entity } from '../engine';
1
+ import { Entity, IEngine } from '../engine';
2
2
  export type TweenSystem = {
3
3
  tweenCompleted(entity: Entity): boolean;
4
4
  };
5
+ /**
6
+ * @public
7
+ * @returns tween helper to be used on the scene
8
+ */
9
+ export declare function createTweenSystem(engine: IEngine): TweenSystem;
@@ -28,10 +28,17 @@ const components = __importStar(require("../components"));
28
28
  const ByteBuffer_1 = require("../serialization/ByteBuffer");
29
29
  const utils_1 = require("./crdt/utils");
30
30
  /**
31
- * @internal
31
+ * Avoid creating multiple tween systems
32
+ */
33
+ const cacheTween = new Map();
34
+ /**
35
+ * @public
32
36
  * @returns tween helper to be used on the scene
33
37
  */
34
38
  function createTweenSystem(engine) {
39
+ if (cacheTween.has(engine._id)) {
40
+ return cacheTween.get(engine._id);
41
+ }
35
42
  const Tween = components.Tween(engine);
36
43
  const TweenState = components.TweenState(engine);
37
44
  const TweenSequence = components.TweenSequence(engine);
@@ -135,9 +142,11 @@ function createTweenSystem(engine) {
135
142
  /* istanbul ignore next */
136
143
  throw new Error('Invalid tween');
137
144
  }
138
- return {
145
+ const tweenSystem = {
139
146
  // This event is fired only once per tween
140
147
  tweenCompleted: isCompleted
141
148
  };
149
+ cacheTween.set(engine._id, tweenSystem);
150
+ return tweenSystem;
142
151
  }
143
152
  exports.createTweenSystem = createTweenSystem;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dcl/ecs",
3
3
  "description": "Decentraland ECS",
4
- "version": "7.4.9",
4
+ "version": "7.4.10-8392909116.commit-6487246",
5
5
  "author": "DCL",
6
6
  "bugs": "https://github.com/decentraland/ecs/issues",
7
7
  "files": [
@@ -33,5 +33,5 @@
33
33
  },
34
34
  "types": "./dist/index.d.ts",
35
35
  "typings": "./dist/index.d.ts",
36
- "commit": "1e8de58e5660b4247319ca8594821cd31e8e2e9a"
36
+ "commit": "64872460277fc8eeaacd25ac366eb9e22195dec5"
37
37
  }