@dcl/ecs 7.18.2-21446464873.commit-2a583c0 → 7.18.2-21453292414.commit-1da934f

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.
@@ -3,7 +3,7 @@ export type { AudioSourceComponentDefinitionExtended } from './extended/AudioSou
3
3
  export type { AudioStreamComponentDefinitionExtended } from './extended/AudioStream';
4
4
  export type { MeshRendererComponentDefinitionExtended } from './extended/MeshRenderer';
5
5
  export type { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
6
- export type { TextureHelper, MaterialComponentDefinitionExtended } from './extended/Material';
6
+ export type { TextureHelper, MaterialComponentDefinitionExtended, FlatTexture, ReadonlyFlatMaterial, ReadonlyFlatTexture, FlatMaterial } from './extended/Material';
7
7
  export type { TweenHelper, TweenComponentDefinitionExtended } from './extended/Tween';
8
8
  export type { CameraTransitionHelper, VirtualCameraComponentDefinitionExtended } from './extended/VirtualCamera';
9
9
  export type { TransformComponentExtended, TransformTypeWithOptionals } from './manual/Transform';
@@ -1,2 +1,3 @@
1
1
  export * from './coordinates';
2
2
  export * from './tree';
3
+ export { createTimers, Timers, TimerId, TimerCallback } from './timers';
@@ -14,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createTimers = void 0;
17
18
  __exportStar(require("./coordinates"), exports);
18
19
  __exportStar(require("./tree"), exports);
20
+ var timers_1 = require("./timers");
21
+ Object.defineProperty(exports, "createTimers", { enumerable: true, get: function () { return timers_1.createTimers; } });
@@ -0,0 +1,85 @@
1
+ import { IEngine } from '../../engine/types';
2
+ export type TimerId = number;
3
+ export type TimerCallback = () => void;
4
+ export type Timers = {
5
+ /**
6
+ * Delays the execution of a function by a given amount of milliseconds.
7
+ *
8
+ * @param callback - The function to execute after the delay
9
+ * @param ms - The delay in milliseconds
10
+ * @returns A TimerId that can be used to cancel the timeout
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const timeoutId = timers.setTimeout(() => {
15
+ * console.log('1 second passed')
16
+ * }, 1000)
17
+ * ```
18
+ */
19
+ setTimeout(callback: TimerCallback, ms: number): TimerId;
20
+ /**
21
+ * Cancels a timeout previously established by setTimeout.
22
+ *
23
+ * @param timerId - The TimerId returned by setTimeout
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const timeoutId = timers.setTimeout(() => {
28
+ * console.log('This will not run')
29
+ * }, 1000)
30
+ *
31
+ * timers.clearTimeout(timeoutId)
32
+ * ```
33
+ */
34
+ clearTimeout(timerId: TimerId): void;
35
+ /**
36
+ * Repeatedly executes a function at specified intervals.
37
+ *
38
+ * @param callback - The function to execute at each interval
39
+ * @param ms - The interval in milliseconds
40
+ * @returns A TimerId that can be used to cancel the interval
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const intervalId = timers.setInterval(() => {
45
+ * console.log('Printing this every 1 second')
46
+ * }, 1000)
47
+ * ```
48
+ */
49
+ setInterval(callback: TimerCallback, ms: number): TimerId;
50
+ /**
51
+ * Cancels an interval previously established by setInterval.
52
+ *
53
+ * @param timerId - The TimerId returned by setInterval
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const intervalId = timers.setInterval(() => {
58
+ * console.log('This will stop')
59
+ * }, 1000)
60
+ *
61
+ * timers.clearInterval(intervalId)
62
+ * ```
63
+ */
64
+ clearInterval(timerId: TimerId): void;
65
+ };
66
+ /**
67
+ * Creates a timer system bound to a specific engine instance.
68
+ *
69
+ * @param targetEngine - The engine instance to bind timers to
70
+ * @returns A Timers object with setTimeout, clearTimeout, setInterval, and clearInterval methods
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * import { Engine } from '@dcl/sdk/ecs'
75
+ * import { createTimers } from '@dcl/sdk/ecs'
76
+ *
77
+ * const engine = Engine()
78
+ * const timers = createTimers(engine)
79
+ *
80
+ * timers.setTimeout(() => console.log('done'), 1000)
81
+ * ```
82
+ *
83
+ * @public
84
+ */
85
+ export declare function createTimers(targetEngine: IEngine): Timers;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTimers = void 0;
4
+ /**
5
+ * Creates a timer system bound to a specific engine instance.
6
+ *
7
+ * @param targetEngine - The engine instance to bind timers to
8
+ * @returns A Timers object with setTimeout, clearTimeout, setInterval, and clearInterval methods
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { Engine } from '@dcl/sdk/ecs'
13
+ * import { createTimers } from '@dcl/sdk/ecs'
14
+ *
15
+ * const engine = Engine()
16
+ * const timers = createTimers(engine)
17
+ *
18
+ * timers.setTimeout(() => console.log('done'), 1000)
19
+ * ```
20
+ *
21
+ * @public
22
+ */
23
+ function createTimers(targetEngine) {
24
+ const timers = new Map();
25
+ let timerIdCounter = 0;
26
+ function system(dt) {
27
+ for (const [timerId, timerData] of timers) {
28
+ timerData.accumulatedTime += 1000 * dt;
29
+ if (timerData.accumulatedTime < timerData.interval) {
30
+ continue;
31
+ }
32
+ if (timerData.recurrent) {
33
+ // For intervals, subtract full interval periods to handle accumulated time
34
+ const fullIntervals = Math.floor(timerData.accumulatedTime / timerData.interval);
35
+ timerData.accumulatedTime -= fullIntervals * timerData.interval;
36
+ }
37
+ else {
38
+ timers.delete(timerId);
39
+ }
40
+ timerData.callback();
41
+ }
42
+ }
43
+ targetEngine.addSystem(system, Number.MAX_SAFE_INTEGER, '@dcl/ecs/timers');
44
+ return {
45
+ setTimeout(callback, ms) {
46
+ const timerId = timerIdCounter++;
47
+ timers.set(timerId, {
48
+ callback,
49
+ interval: ms,
50
+ recurrent: false,
51
+ accumulatedTime: 0
52
+ });
53
+ return timerId;
54
+ },
55
+ clearTimeout(timerId) {
56
+ timers.delete(timerId);
57
+ },
58
+ setInterval(callback, ms) {
59
+ const timerId = timerIdCounter++;
60
+ timers.set(timerId, {
61
+ callback,
62
+ interval: ms,
63
+ recurrent: true,
64
+ accumulatedTime: 0
65
+ });
66
+ return timerId;
67
+ },
68
+ clearInterval(timerId) {
69
+ timers.delete(timerId);
70
+ }
71
+ };
72
+ }
73
+ exports.createTimers = createTimers;
@@ -1,5 +1,7 @@
1
1
  import { Entity } from '../../engine/entity';
2
2
  import { ComponentDefinition, IEngine } from '../../engine';
3
+ import { Vector3Type } from '../../schemas/custom/Vector3';
4
+ import { QuaternionType } from '../../schemas/custom/Quaternion';
3
5
  /**
4
6
  * Get an iterator of entities that follow a tree structure for a component
5
7
  * @public
@@ -30,3 +32,62 @@ export declare function getComponentEntityTree<T>(engine: Pick<IEngine, 'getEnti
30
32
  * @public
31
33
  */
32
34
  export declare function removeEntityWithChildren(engine: Pick<IEngine, 'getEntitiesWith' | 'defineComponentFromSchema' | 'removeEntity' | 'defineComponent'>, entity: Entity): void;
35
+ /**
36
+ * Get all entities that have the given entity as their parent
37
+ * @public
38
+ * @param engine - the engine running the entities
39
+ * @param parent - the parent entity to find children for
40
+ * @returns An array of entities that have the given parent
41
+ *
42
+ * Example:
43
+ * ```ts
44
+ * const children = getEntitiesWithParent(engine, myEntity)
45
+ * for (const child of children) {
46
+ * // process each child entity
47
+ * }
48
+ * ```
49
+ */
50
+ export declare function getEntitiesWithParent(engine: Pick<IEngine, 'getEntitiesWith' | 'defineComponentFromSchema'>, parent: Entity): Entity[];
51
+ /** @public Engine type for world transform functions */
52
+ export type WorldTransformEngine = Pick<IEngine, 'getEntitiesWith' | 'defineComponentFromSchema' | 'PlayerEntity'>;
53
+ /**
54
+ * Get the world position of an entity, taking into account the full parent hierarchy.
55
+ * This computes the world-space position by accumulating all parent transforms
56
+ * (position, rotation, and scale).
57
+ *
58
+ * When the entity has AvatarAttach and Transform, the renderer updates the Transform
59
+ * with avatar-relative values (including the exact anchor point offset for hand, head, etc.).
60
+ * This function combines the player's transform with those values to compute the world position.
61
+ *
62
+ * @public
63
+ * @param engine - the engine running the entities
64
+ * @param entity - the entity to get the world position for
65
+ * @returns The entity's position in world space. Returns `{x: 0, y: 0, z: 0}` if the entity has no Transform.
66
+ *
67
+ * Example:
68
+ * ```ts
69
+ * const worldPos = getWorldPosition(engine, childEntity)
70
+ * console.log(`World position: ${worldPos.x}, ${worldPos.y}, ${worldPos.z}`)
71
+ * ```
72
+ */
73
+ export declare function getWorldPosition(engine: WorldTransformEngine, entity: Entity): Vector3Type;
74
+ /**
75
+ * Get the world rotation of an entity, taking into account the full parent hierarchy.
76
+ * This computes the world-space rotation by combining all parent rotations.
77
+ *
78
+ * When the entity has AvatarAttach and Transform, the renderer updates the Transform
79
+ * with avatar-relative values (including the exact anchor point rotation for hand, head, etc.).
80
+ * This function combines the player's rotation with those values to compute the world rotation.
81
+ *
82
+ * @public
83
+ * @param engine - the engine running the entities
84
+ * @param entity - the entity to get the world rotation for
85
+ * @returns The entity's rotation in world space as a quaternion. Returns identity quaternion `{x: 0, y: 0, z: 0, w: 1}` if the entity has no Transform.
86
+ *
87
+ * Example:
88
+ * ```ts
89
+ * const worldRot = getWorldRotation(engine, childEntity)
90
+ * console.log(`World rotation: ${worldRot.x}, ${worldRot.y}, ${worldRot.z}, ${worldRot.w}`)
91
+ * ```
92
+ */
93
+ export declare function getWorldRotation(engine: WorldTransformEngine, entity: Entity): QuaternionType;
@@ -23,8 +23,165 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.removeEntityWithChildren = exports.getComponentEntityTree = void 0;
26
+ exports.getWorldRotation = exports.getWorldPosition = exports.getEntitiesWithParent = exports.removeEntityWithChildren = exports.getComponentEntityTree = void 0;
27
27
  const components = __importStar(require("../../components"));
28
+ /**
29
+ * @internal
30
+ * Add two Vector3 values
31
+ */
32
+ function addVectors(v1, v2) {
33
+ return {
34
+ x: v1.x + v2.x,
35
+ y: v1.y + v2.y,
36
+ z: v1.z + v2.z
37
+ };
38
+ }
39
+ /**
40
+ * @internal
41
+ * Multiply two Vector3 values element-wise (used for scaling)
42
+ */
43
+ function multiplyVectors(v1, v2) {
44
+ return {
45
+ x: v1.x * v2.x,
46
+ y: v1.y * v2.y,
47
+ z: v1.z * v2.z
48
+ };
49
+ }
50
+ /**
51
+ * @internal
52
+ * Multiply two quaternions (combines rotations)
53
+ * Result represents applying q1 first, then q2
54
+ */
55
+ function multiplyQuaternions(q1, q2) {
56
+ return {
57
+ x: q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y,
58
+ y: q1.w * q2.y - q1.x * q2.z + q1.y * q2.w + q1.z * q2.x,
59
+ z: q1.w * q2.z + q1.x * q2.y - q1.y * q2.x + q1.z * q2.w,
60
+ w: q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z
61
+ };
62
+ }
63
+ /**
64
+ * @internal
65
+ * Rotate a vector by a quaternion
66
+ * Uses the formula: v' = q * v * q^(-1), optimized version
67
+ */
68
+ function rotateVectorByQuaternion(v, q) {
69
+ // Extract quaternion components
70
+ const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
71
+ // Calculate cross product terms (q.xyz × v) * 2
72
+ const ix = qw * v.x + qy * v.z - qz * v.y;
73
+ const iy = qw * v.y + qz * v.x - qx * v.z;
74
+ const iz = qw * v.z + qx * v.y - qy * v.x;
75
+ const iw = -qx * v.x - qy * v.y - qz * v.z;
76
+ // Calculate final rotated vector
77
+ return {
78
+ x: ix * qw + iw * -qx + iy * -qz - iz * -qy,
79
+ y: iy * qw + iw * -qy + iz * -qx - ix * -qz,
80
+ z: iz * qw + iw * -qz + ix * -qy - iy * -qx
81
+ };
82
+ }
83
+ /** @internal Identity transform values */
84
+ const IDENTITY_POSITION = { x: 0, y: 0, z: 0 };
85
+ const IDENTITY_ROTATION = { x: 0, y: 0, z: 0, w: 1 };
86
+ const IDENTITY_SCALE = { x: 1, y: 1, z: 1 };
87
+ /**
88
+ * @internal
89
+ * Computes the world transform for an entity with AvatarAttach.
90
+ * If the entity has a Transform, the avatar-relative values (set by the renderer)
91
+ * are combined with the player's transform. Otherwise, returns the player's transform
92
+ * with identity scale.
93
+ */
94
+ function computeAvatarAttachedWorldTransform(playerTransform, entityTransform) {
95
+ if (!entityTransform) {
96
+ return {
97
+ position: { ...playerTransform.position },
98
+ rotation: { ...playerTransform.rotation },
99
+ scale: { ...IDENTITY_SCALE }
100
+ };
101
+ }
102
+ const rotatedPosition = rotateVectorByQuaternion(entityTransform.position, playerTransform.rotation);
103
+ return {
104
+ position: addVectors(playerTransform.position, rotatedPosition),
105
+ rotation: multiplyQuaternions(playerTransform.rotation, entityTransform.rotation),
106
+ scale: entityTransform.scale
107
+ };
108
+ }
109
+ /**
110
+ * @internal
111
+ * Finds the transform of a player by their avatar ID.
112
+ * Returns the local player's transform if avatarId is undefined,
113
+ * or searches for a remote player by matching their address.
114
+ */
115
+ function findPlayerTransform(Transform, PlayerIdentityData, localPlayerEntity, avatarId) {
116
+ // Local player (avatarId undefined)
117
+ if (avatarId === undefined) {
118
+ return Transform.getOrNull(localPlayerEntity);
119
+ }
120
+ // Remote player - find their entity by matching address
121
+ if (!PlayerIdentityData) {
122
+ return null;
123
+ }
124
+ for (const [playerEntity, identityData] of PlayerIdentityData.iterator()) {
125
+ if (identityData.address === avatarId) {
126
+ return Transform.getOrNull(playerEntity);
127
+ }
128
+ }
129
+ return null;
130
+ }
131
+ /**
132
+ * @internal
133
+ * Computes world position, rotation, and scale in a single hierarchy traversal.
134
+ * This is O(n) where n is the depth of the hierarchy.
135
+ *
136
+ * When an entity has AvatarAttach and Transform, the renderer updates the Transform
137
+ * with avatar-relative values (including the exact anchor point offset). This function
138
+ * combines the player's transform with the entity's avatar-relative transform to
139
+ * compute the world-space position.
140
+ *
141
+ * @throws Error if a circular dependency is detected in the entity hierarchy
142
+ */
143
+ function getWorldTransformInternal(Transform, AvatarAttach, PlayerIdentityData, PlayerEntity, entity, visited = new Set()) {
144
+ const transform = Transform.getOrNull(entity);
145
+ const avatarAttach = AvatarAttach?.getOrNull(entity);
146
+ // Handle AvatarAttach: combine player's transform with the entity's avatar-relative transform
147
+ // (which the renderer updates with the exact anchor point offset for hand, head, etc.)
148
+ if (avatarAttach) {
149
+ const playerTransform = findPlayerTransform(Transform, PlayerIdentityData, PlayerEntity, avatarAttach.avatarId);
150
+ if (playerTransform) {
151
+ return computeAvatarAttachedWorldTransform(playerTransform, transform);
152
+ }
153
+ // Player's Transform not available, fall through to normal Transform handling
154
+ }
155
+ if (!transform) {
156
+ return {
157
+ position: { ...IDENTITY_POSITION },
158
+ rotation: { ...IDENTITY_ROTATION },
159
+ scale: { ...IDENTITY_SCALE }
160
+ };
161
+ }
162
+ if (!transform.parent) {
163
+ return {
164
+ position: { ...transform.position },
165
+ rotation: { ...transform.rotation },
166
+ scale: { ...transform.scale }
167
+ };
168
+ }
169
+ visited.add(entity);
170
+ if (visited.has(transform.parent)) {
171
+ throw new Error(`Circular dependency detected in entity hierarchy: entity ${entity} has ancestor ${transform.parent} which creates a cycle`);
172
+ }
173
+ const parentWorld = getWorldTransformInternal(Transform, AvatarAttach, PlayerIdentityData, PlayerEntity, transform.parent, visited);
174
+ const worldScale = multiplyVectors(parentWorld.scale, transform.scale);
175
+ const worldRotation = multiplyQuaternions(parentWorld.rotation, transform.rotation);
176
+ const scaledPosition = multiplyVectors(transform.position, parentWorld.scale);
177
+ const rotatedPosition = rotateVectorByQuaternion(scaledPosition, parentWorld.rotation);
178
+ const worldPosition = addVectors(parentWorld.position, rotatedPosition);
179
+ return {
180
+ position: worldPosition,
181
+ rotation: worldRotation,
182
+ scale: worldScale
183
+ };
184
+ }
28
185
  function* genEntityTree(entity, entities) {
29
186
  // This avoid infinite loop when there is a cyclic parenting
30
187
  if (!entities.has(entity))
@@ -98,3 +255,87 @@ function removeEntityWithChildren(engine, entity) {
98
255
  }
99
256
  }
100
257
  exports.removeEntityWithChildren = removeEntityWithChildren;
258
+ /**
259
+ * Get all entities that have the given entity as their parent
260
+ * @public
261
+ * @param engine - the engine running the entities
262
+ * @param parent - the parent entity to find children for
263
+ * @returns An array of entities that have the given parent
264
+ *
265
+ * Example:
266
+ * ```ts
267
+ * const children = getEntitiesWithParent(engine, myEntity)
268
+ * for (const child of children) {
269
+ * // process each child entity
270
+ * }
271
+ * ```
272
+ */
273
+ function getEntitiesWithParent(engine, parent) {
274
+ const Transform = components.Transform(engine);
275
+ const entitiesWithParent = [];
276
+ for (const [entity, transform] of engine.getEntitiesWith(Transform)) {
277
+ if (transform.parent === parent) {
278
+ entitiesWithParent.push(entity);
279
+ }
280
+ }
281
+ return entitiesWithParent;
282
+ }
283
+ exports.getEntitiesWithParent = getEntitiesWithParent;
284
+ /**
285
+ * @internal
286
+ * Computes the world transform for an entity using the provided engine.
287
+ * This is a convenience wrapper that initializes the required components.
288
+ */
289
+ function getWorldTransform(engine, entity) {
290
+ const Transform = components.Transform(engine);
291
+ const AvatarAttach = components.AvatarAttach(engine);
292
+ const PlayerIdentityData = components.PlayerIdentityData(engine);
293
+ return getWorldTransformInternal(Transform, AvatarAttach, PlayerIdentityData, engine.PlayerEntity, entity);
294
+ }
295
+ /**
296
+ * Get the world position of an entity, taking into account the full parent hierarchy.
297
+ * This computes the world-space position by accumulating all parent transforms
298
+ * (position, rotation, and scale).
299
+ *
300
+ * When the entity has AvatarAttach and Transform, the renderer updates the Transform
301
+ * with avatar-relative values (including the exact anchor point offset for hand, head, etc.).
302
+ * This function combines the player's transform with those values to compute the world position.
303
+ *
304
+ * @public
305
+ * @param engine - the engine running the entities
306
+ * @param entity - the entity to get the world position for
307
+ * @returns The entity's position in world space. Returns `{x: 0, y: 0, z: 0}` if the entity has no Transform.
308
+ *
309
+ * Example:
310
+ * ```ts
311
+ * const worldPos = getWorldPosition(engine, childEntity)
312
+ * console.log(`World position: ${worldPos.x}, ${worldPos.y}, ${worldPos.z}`)
313
+ * ```
314
+ */
315
+ function getWorldPosition(engine, entity) {
316
+ return getWorldTransform(engine, entity).position;
317
+ }
318
+ exports.getWorldPosition = getWorldPosition;
319
+ /**
320
+ * Get the world rotation of an entity, taking into account the full parent hierarchy.
321
+ * This computes the world-space rotation by combining all parent rotations.
322
+ *
323
+ * When the entity has AvatarAttach and Transform, the renderer updates the Transform
324
+ * with avatar-relative values (including the exact anchor point rotation for hand, head, etc.).
325
+ * This function combines the player's rotation with those values to compute the world rotation.
326
+ *
327
+ * @public
328
+ * @param engine - the engine running the entities
329
+ * @param entity - the entity to get the world rotation for
330
+ * @returns The entity's rotation in world space as a quaternion. Returns identity quaternion `{x: 0, y: 0, z: 0, w: 1}` if the entity has no Transform.
331
+ *
332
+ * Example:
333
+ * ```ts
334
+ * const worldRot = getWorldRotation(engine, childEntity)
335
+ * console.log(`World rotation: ${worldRot.x}, ${worldRot.y}, ${worldRot.z}, ${worldRot.w}`)
336
+ * ```
337
+ */
338
+ function getWorldRotation(engine, entity) {
339
+ return getWorldTransform(engine, entity).rotation;
340
+ }
341
+ exports.getWorldRotation = getWorldRotation;
@@ -10,6 +10,7 @@ import { RaycastSystem } from '../../systems/raycast';
10
10
  import { VideoEventsSystem } from '../../systems/videoEvents';
11
11
  import { TweenSystem } from '../../systems/tween';
12
12
  import { TriggerAreaEventsSystem } from '../../systems/triggerArea';
13
+ import { createTimers, Timers } from '../helpers/timers';
13
14
  /**
14
15
  * @public
15
16
  * The engine is the part of the scene that sits in the middle and manages all of the other parts.
@@ -63,6 +64,12 @@ export { TweenSystem };
63
64
  */
64
65
  export declare const triggerAreaEventsSystem: TriggerAreaEventsSystem;
65
66
  export { TriggerAreaEventsSystem };
67
+ /**
68
+ * @public
69
+ * Timer utilities for delayed and repeated execution.
70
+ */
71
+ export declare const timers: Timers;
72
+ export { Timers, createTimers };
66
73
  /**
67
74
  * @public
68
75
  * Runs an async function
@@ -4,7 +4,7 @@
4
4
  * init and it'll be changing.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.executeTask = exports.triggerAreaEventsSystem = exports.tweenSystem = exports.videoEventsSystem = exports.raycastSystem = exports.pointerEventsSystem = exports.inputSystem = exports.engine = void 0;
7
+ exports.executeTask = exports.createTimers = exports.timers = exports.triggerAreaEventsSystem = exports.tweenSystem = exports.videoEventsSystem = exports.raycastSystem = exports.pointerEventsSystem = exports.inputSystem = exports.engine = void 0;
8
8
  const engine_1 = require("../../engine");
9
9
  const async_task_1 = require("../../systems/async-task");
10
10
  const events_1 = require("../../systems/events");
@@ -14,6 +14,8 @@ const videoEvents_1 = require("../../systems/videoEvents");
14
14
  const tween_1 = require("../../systems/tween");
15
15
  const pointer_event_collider_checker_1 = require("../../systems/pointer-event-collider-checker");
16
16
  const triggerArea_1 = require("../../systems/triggerArea");
17
+ const timers_1 = require("../helpers/timers");
18
+ Object.defineProperty(exports, "createTimers", { enumerable: true, get: function () { return timers_1.createTimers; } });
17
19
  /**
18
20
  * @public
19
21
  * The engine is the part of the scene that sits in the middle and manages all of the other parts.
@@ -61,6 +63,15 @@ exports.tweenSystem = (0, tween_1.createTweenSystem)(exports.engine);
61
63
  * Register callback functions for trigger area results.
62
64
  */
63
65
  exports.triggerAreaEventsSystem = (0, triggerArea_1.createTriggerAreaEventsSystem)(exports.engine);
66
+ /**
67
+ * @public
68
+ * Timer utilities for delayed and repeated execution.
69
+ */
70
+ exports.timers = (0, timers_1.createTimers)(exports.engine);
71
+ globalThis.setTimeout = globalThis.setTimeout ?? exports.timers.setTimeout;
72
+ globalThis.clearTimeout = globalThis.clearTimeout ?? exports.timers.clearTimeout;
73
+ globalThis.setInterval = globalThis.setInterval ?? exports.timers.setInterval;
74
+ globalThis.clearInterval = globalThis.clearInterval ?? exports.timers.clearInterval;
64
75
  /**
65
76
  * Adds pointer event collider system only in DEV env
66
77
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dcl/ecs",
3
3
  "description": "Decentraland ECS",
4
- "version": "7.18.2-21446464873.commit-2a583c0",
4
+ "version": "7.18.2-21453292414.commit-1da934f",
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": "2a583c0a5c613fa8145eb30c82be7da032e2372b"
36
+ "commit": "1da934f139711792b8d2a7afb0378e8dd70ac44b"
37
37
  }