@dcl/ecs 7.12.3-19242573384.commit-09d14b4 → 7.12.3-19269914897.commit-1299cf2

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.
Files changed (49) hide show
  1. package/dist/components/extended/TriggerArea.d.ts +22 -0
  2. package/dist/components/extended/TriggerArea.js +27 -0
  3. package/dist/components/extended/Tween.d.ts +94 -5
  4. package/dist/components/extended/Tween.js +119 -1
  5. package/dist/components/generated/CameraLayer.gen.js +1 -1
  6. package/dist/components/generated/component-names.gen.js +1 -1
  7. package/dist/components/generated/global.gen.d.ts +1 -1
  8. package/dist/components/generated/index.gen.d.ts +2 -2
  9. package/dist/components/generated/index.gen.js +4 -2
  10. package/dist/components/index.d.ts +4 -0
  11. package/dist/components/index.js +6 -0
  12. package/dist/components/manual/Tags.d.ts +34 -0
  13. package/dist/components/manual/Tags.js +37 -0
  14. package/dist/components/types.d.ts +3 -0
  15. package/dist/engine/index.js +10 -0
  16. package/dist/engine/types.d.ts +7 -0
  17. package/dist/index.d.ts +6 -5
  18. package/dist/index.js +4 -3
  19. package/dist/runtime/initialization/index.d.ts +7 -0
  20. package/dist/runtime/initialization/index.js +6 -0
  21. package/dist/systems/crdt/index.d.ts +1 -0
  22. package/dist/systems/crdt/index.js +17 -5
  23. package/dist/systems/triggerArea.d.ts +50 -0
  24. package/dist/systems/triggerArea.js +113 -0
  25. package/dist-cjs/components/extended/TriggerArea.d.ts +22 -0
  26. package/dist-cjs/components/extended/TriggerArea.js +31 -0
  27. package/dist-cjs/components/extended/Tween.d.ts +94 -5
  28. package/dist-cjs/components/extended/Tween.js +119 -1
  29. package/dist-cjs/components/generated/CameraLayer.gen.js +1 -1
  30. package/dist-cjs/components/generated/component-names.gen.js +1 -1
  31. package/dist-cjs/components/generated/global.gen.d.ts +1 -1
  32. package/dist-cjs/components/generated/index.gen.d.ts +2 -2
  33. package/dist-cjs/components/generated/index.gen.js +4 -2
  34. package/dist-cjs/components/index.d.ts +4 -0
  35. package/dist-cjs/components/index.js +9 -1
  36. package/dist-cjs/components/manual/Tags.d.ts +34 -0
  37. package/dist-cjs/components/manual/Tags.js +39 -0
  38. package/dist-cjs/components/types.d.ts +3 -0
  39. package/dist-cjs/engine/index.js +10 -0
  40. package/dist-cjs/engine/types.d.ts +7 -0
  41. package/dist-cjs/index.d.ts +6 -5
  42. package/dist-cjs/index.js +5 -4
  43. package/dist-cjs/runtime/initialization/index.d.ts +7 -0
  44. package/dist-cjs/runtime/initialization/index.js +7 -1
  45. package/dist-cjs/systems/crdt/index.d.ts +1 -0
  46. package/dist-cjs/systems/crdt/index.js +18 -6
  47. package/dist-cjs/systems/triggerArea.d.ts +50 -0
  48. package/dist-cjs/systems/triggerArea.js +140 -0
  49. package/package.json +2 -2
@@ -0,0 +1,22 @@
1
+ import { Entity, IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine';
2
+ import { ColliderLayer, PBTriggerArea } from '../generated/index.gen';
3
+ /**
4
+ * @public
5
+ */
6
+ export interface TriggerAreaComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBTriggerArea> {
7
+ /**
8
+ * @public
9
+ * Set a box in the MeshCollider component
10
+ * @param entity - entity to create or replace the TriggerArea component
11
+ * @param collisionMask - the collision layers mask for the trigger to react, default: Player
12
+ */
13
+ setBox(entity: Entity, collisionMask?: ColliderLayer | ColliderLayer[]): void;
14
+ /**
15
+ * @public
16
+ * Set a sphere in the MeshCollider component
17
+ * @param entity - entity to create or replace the TriggerArea component
18
+ * @param collisionMask - the collision layers mask for the trigger to react, default: Player
19
+ */
20
+ setSphere(entity: Entity, collisionMask?: ColliderLayer | ColliderLayer[]): void;
21
+ }
22
+ export declare function defineTriggerAreaComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): TriggerAreaComponentDefinitionExtended;
@@ -0,0 +1,27 @@
1
+ import { TriggerArea } from '../generated/index.gen';
2
+ export function defineTriggerAreaComponent(engine) {
3
+ const theComponent = TriggerArea(engine);
4
+ function getCollisionMask(layers) {
5
+ if (Array.isArray(layers)) {
6
+ return layers.map((item) => item).reduce((prev, item) => prev | item, 0);
7
+ }
8
+ else if (layers) {
9
+ return layers;
10
+ }
11
+ }
12
+ return {
13
+ ...theComponent,
14
+ setBox(entity, collisionMask) {
15
+ theComponent.createOrReplace(entity, {
16
+ mesh: 0 /* TriggerAreaMeshType.TAMT_BOX */,
17
+ collisionMask: getCollisionMask(collisionMask)
18
+ });
19
+ },
20
+ setSphere(entity, collisionMask) {
21
+ theComponent.createOrReplace(entity, {
22
+ mesh: 1 /* TriggerAreaMeshType.TAMT_SPHERE */,
23
+ collisionMask: getCollisionMask(collisionMask)
24
+ });
25
+ }
26
+ };
27
+ }
@@ -1,5 +1,6 @@
1
- import { IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine';
2
- import { PBTween, Move, Rotate, Scale, TextureMove } from '../generated/index.gen';
1
+ import { Entity, IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine';
2
+ import { Quaternion, Vector2, Vector3 } from '../generated/pb/decentraland/common/vectors.gen';
3
+ import { EasingFunction, Move, MoveContinuous, PBTween, Rotate, RotateContinuous, Scale, TextureMove, TextureMoveContinuous, TextureMovementType } from '../generated/index.gen';
3
4
  /**
4
5
  * @public
5
6
  */
@@ -9,17 +10,29 @@ export interface TweenHelper {
9
10
  */
10
11
  Move: (move: Move) => PBTween['mode'];
11
12
  /**
12
- * @returns a move mode tween
13
+ * @returns a move-continuous mode tween
14
+ */
15
+ MoveContinuous: (move: MoveContinuous) => PBTween['mode'];
16
+ /**
17
+ * @returns a rotate mode tween
13
18
  */
14
19
  Rotate: (rotate: Rotate) => PBTween['mode'];
15
20
  /**
16
- * @returns a move mode tween
21
+ * @returns a rotate-continuous mode tween
22
+ */
23
+ RotateContinuous: (rotate: RotateContinuous) => PBTween['mode'];
24
+ /**
25
+ * @returns a scale mode tween
17
26
  */
18
27
  Scale: (scale: Scale) => PBTween['mode'];
19
28
  /**
20
- * @returns a texture move mode tween
29
+ * @returns a texture-move mode tween
21
30
  */
22
31
  TextureMove: (textureMove: TextureMove) => PBTween['mode'];
32
+ /**
33
+ * @returns a texture-move-continuous mode tween
34
+ */
35
+ TextureMoveContinuous: (textureMove: TextureMoveContinuous) => PBTween['mode'];
23
36
  }
24
37
  /**
25
38
  * @public
@@ -29,5 +42,81 @@ export interface TweenComponentDefinitionExtended extends LastWriteWinElementSet
29
42
  * Texture helpers with constructor
30
43
  */
31
44
  Mode: TweenHelper;
45
+ /**
46
+ * @public
47
+ *
48
+ * Creates or replaces a move tween component that animates an entity's position from start to end
49
+ * @param entity - entity to apply the tween to
50
+ * @param start - starting position vector
51
+ * @param end - ending position vector
52
+ * @param duration - duration of the tween in milliseconds
53
+ * @param easingFunction - easing function to use (defaults to EF_LINEAR)
54
+ */
55
+ setMove(entity: Entity, start: Vector3, end: Vector3, duration: number, easingFunction?: EasingFunction): void;
56
+ /**
57
+ * @public
58
+ *
59
+ * Creates or replaces a scale tween component that animates an entity's scale from start to end
60
+ * @param entity - entity to apply the tween to
61
+ * @param start - starting scale vector
62
+ * @param end - ending scale vector
63
+ * @param duration - duration of the tween in milliseconds
64
+ * @param easingFunction - easing function to use (defaults to EF_LINEAR)
65
+ */
66
+ setScale(entity: Entity, start: Vector3, end: Vector3, duration: number, easingFunction?: EasingFunction): void;
67
+ /**
68
+ * @public
69
+ *
70
+ * Creates or replaces a rotation tween component that animates an entity's rotation from start to end
71
+ * @param entity - entity to apply the tween to
72
+ * @param start - starting rotation quaternion
73
+ * @param end - ending rotation quaternion
74
+ * @param duration - duration of the tween in milliseconds
75
+ * @param easingFunction - easing function to use (defaults to EF_LINEAR)
76
+ */
77
+ setRotate(entity: Entity, start: Quaternion, end: Quaternion, duration: number, easingFunction?: EasingFunction): void;
78
+ /**
79
+ * @public
80
+ *
81
+ * Creates or replaces a texture move tween component that animates texture UV coordinates from start to end
82
+ * @param entity - entity to apply the tween to
83
+ * @param start - starting UV coordinates
84
+ * @param end - ending UV coordinates
85
+ * @param duration - duration of the tween in milliseconds
86
+ * @param movementType - type of texture movement (defaults to TMT_OFFSET)
87
+ * @param easingFunction - easing function to use (defaults to EF_LINEAR)
88
+ */
89
+ setTextureMove(entity: Entity, start: Vector2, end: Vector2, duration: number, movementType?: TextureMovementType, easingFunction?: EasingFunction): void;
90
+ /**
91
+ * @public
92
+ *
93
+ * Creates or replaces a continuous move tween component that moves an entity continuously in a direction
94
+ * @param entity - entity to apply the tween to
95
+ * @param direction - direction vector to move towards
96
+ * @param speed - speed of movement per second
97
+ * @param duration - duration of the tween in milliseconds (defaults to 0 for infinite)
98
+ */
99
+ setMoveContinuous(entity: Entity, direction: Vector3, speed: number, duration?: number): void;
100
+ /**
101
+ * @public
102
+ *
103
+ * Creates or replaces a continuous rotation tween component that rotates an entity continuously
104
+ * @param entity - entity to apply the tween to
105
+ * @param direction - rotation direction quaternion
106
+ * @param speed - speed of rotation per second
107
+ * @param duration - duration of the tween in milliseconds (defaults to 0 for infinite)
108
+ */
109
+ setRotateContinuous(entity: Entity, direction: Quaternion, speed: number, duration?: number): void;
110
+ /**
111
+ * @public
112
+ *
113
+ * Creates or replaces a continuous texture move tween component that moves texture UV coordinates continuously
114
+ * @param entity - entity to apply the tween to
115
+ * @param direction - direction vector for UV movement
116
+ * @param speed - speed of UV movement per second
117
+ * @param movementType - type of texture movement (defaults to TMT_OFFSET)
118
+ * @param duration - duration of the tween in milliseconds (defaults to 0 for infinite)
119
+ */
120
+ setTextureMoveContinuous(entity: Entity, direction: Vector2, speed: number, movementType?: TextureMovementType, duration?: number): void;
32
121
  }
33
122
  export declare function defineTweenComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): TweenComponentDefinitionExtended;
@@ -6,12 +6,24 @@ const TweenHelper = {
6
6
  move
7
7
  };
8
8
  },
9
+ MoveContinuous(moveContinuous) {
10
+ return {
11
+ $case: 'moveContinuous',
12
+ moveContinuous
13
+ };
14
+ },
9
15
  Rotate(rotate) {
10
16
  return {
11
17
  $case: 'rotate',
12
18
  rotate
13
19
  };
14
20
  },
21
+ RotateContinuous(rotateContinuous) {
22
+ return {
23
+ $case: 'rotateContinuous',
24
+ rotateContinuous
25
+ };
26
+ },
15
27
  Scale(scale) {
16
28
  return {
17
29
  $case: 'scale',
@@ -23,12 +35,118 @@ const TweenHelper = {
23
35
  $case: 'textureMove',
24
36
  textureMove
25
37
  };
38
+ },
39
+ TextureMoveContinuous(textureMoveContinuous) {
40
+ return {
41
+ $case: 'textureMoveContinuous',
42
+ textureMoveContinuous
43
+ };
26
44
  }
27
45
  };
28
46
  export function defineTweenComponent(engine) {
29
47
  const theComponent = Tween(engine);
30
48
  return {
31
49
  ...theComponent,
32
- Mode: TweenHelper
50
+ Mode: TweenHelper,
51
+ setMove(entity, start, end, duration, easingFunction = 0 /* EasingFunction.EF_LINEAR */) {
52
+ theComponent.createOrReplace(entity, {
53
+ mode: {
54
+ $case: 'move',
55
+ move: {
56
+ start,
57
+ end
58
+ }
59
+ },
60
+ duration,
61
+ easingFunction,
62
+ playing: true
63
+ });
64
+ },
65
+ setScale(entity, start, end, duration, easingFunction = 0 /* EasingFunction.EF_LINEAR */) {
66
+ theComponent.createOrReplace(entity, {
67
+ mode: {
68
+ $case: 'scale',
69
+ scale: {
70
+ start,
71
+ end
72
+ }
73
+ },
74
+ duration,
75
+ easingFunction,
76
+ playing: true
77
+ });
78
+ },
79
+ setRotate(entity, start, end, duration, easingFunction = 0 /* EasingFunction.EF_LINEAR */) {
80
+ theComponent.createOrReplace(entity, {
81
+ mode: {
82
+ $case: 'rotate',
83
+ rotate: {
84
+ start,
85
+ end
86
+ }
87
+ },
88
+ duration,
89
+ easingFunction,
90
+ playing: true
91
+ });
92
+ },
93
+ setTextureMove(entity, start, end, duration, movementType = 0 /* TextureMovementType.TMT_OFFSET */, easingFunction = 0 /* EasingFunction.EF_LINEAR */) {
94
+ theComponent.createOrReplace(entity, {
95
+ mode: {
96
+ $case: 'textureMove',
97
+ textureMove: {
98
+ start,
99
+ end,
100
+ movementType
101
+ }
102
+ },
103
+ duration,
104
+ easingFunction,
105
+ playing: true
106
+ });
107
+ },
108
+ setMoveContinuous(entity, direction, speed, duration = 0) {
109
+ theComponent.createOrReplace(entity, {
110
+ mode: {
111
+ $case: 'moveContinuous',
112
+ moveContinuous: {
113
+ direction,
114
+ speed
115
+ }
116
+ },
117
+ duration,
118
+ easingFunction: 0 /* EasingFunction.EF_LINEAR */,
119
+ playing: true
120
+ });
121
+ },
122
+ setRotateContinuous(entity, direction, speed, duration = 0) {
123
+ theComponent.createOrReplace(entity, {
124
+ mode: {
125
+ $case: 'rotateContinuous',
126
+ rotateContinuous: {
127
+ direction,
128
+ speed
129
+ }
130
+ },
131
+ duration,
132
+ easingFunction: 0 /* EasingFunction.EF_LINEAR */,
133
+ playing: true
134
+ });
135
+ },
136
+ setTextureMoveContinuous(entity, direction, speed, movementType = 0 /* TextureMovementType.TMT_OFFSET */, duration = 0) {
137
+ theComponent.createOrReplace(entity, {
138
+ mode: {
139
+ $case: 'textureMoveContinuous',
140
+ textureMoveContinuous: {
141
+ direction,
142
+ speed,
143
+ movementType
144
+ }
145
+ },
146
+ duration,
147
+ easingFunction: 0 /* EasingFunction.EF_LINEAR */,
148
+ playing: true
149
+ });
150
+ }
33
151
  };
34
152
  }
@@ -3,7 +3,7 @@ import { PBCameraLayer } from './pb/decentraland/sdk/components/camera_layer.gen
3
3
  * @internal
4
4
  */
5
5
  export const CameraLayerSchema = {
6
- COMPONENT_ID: 1210,
6
+ COMPONENT_ID: 1211,
7
7
  serialize(value, builder) {
8
8
  const writer = PBCameraLayer.encode(value);
9
9
  const buffer = new Uint8Array(writer.finish(), 0, writer.len);
@@ -14,7 +14,7 @@ export const coreComponentMappings = {
14
14
  "core::AvatarModifierArea": 1070,
15
15
  "core::AvatarShape": 1080,
16
16
  "core::Billboard": 1090,
17
- "core::CameraLayer": 1210,
17
+ "core::CameraLayer": 1211,
18
18
  "core::CameraLayers": 1208,
19
19
  "core::CameraMode": 1072,
20
20
  "core::CameraModeArea": 1071,
@@ -91,7 +91,7 @@ import { PBVisibilityComponent } from './pb/decentraland/sdk/components/visibili
91
91
  /** @public */ export declare const TextShape: LastWriteWinElementSetComponentDefinition<PBTextShape>;
92
92
  /** @public */ export declare const TextureCamera: LastWriteWinElementSetComponentDefinition<PBTextureCamera>;
93
93
  /** @public */ export declare const TriggerArea: LastWriteWinElementSetComponentDefinition<PBTriggerArea>;
94
- /** @public */ export declare const TriggerAreaResult: LastWriteWinElementSetComponentDefinition<PBTriggerAreaResult>;
94
+ /** @public */ export declare const TriggerAreaResult: GrowOnlyValueSetComponentDefinition<PBTriggerAreaResult>;
95
95
  /** @public */ export declare const TweenSequence: LastWriteWinElementSetComponentDefinition<PBTweenSequence>;
96
96
  /** @public */ export declare const TweenState: LastWriteWinElementSetComponentDefinition<PBTweenState>;
97
97
  /** @public */ export declare const UiBackground: LastWriteWinElementSetComponentDefinition<PBUiBackground>;
@@ -161,7 +161,7 @@ export type GSetComponentGetter<T extends GrowOnlyValueSetComponentDefinition<an
161
161
  /** @public */ export declare const TextShape: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTextShape>>;
162
162
  /** @public */ export declare const TextureCamera: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTextureCamera>>;
163
163
  /** @public */ export declare const TriggerArea: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTriggerArea>>;
164
- /** @public */ export declare const TriggerAreaResult: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTriggerAreaResult>>;
164
+ /** @public */ export declare const TriggerAreaResult: GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBTriggerAreaResult>>;
165
165
  /** @public */ export declare const Tween: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTween>>;
166
166
  /** @public */ export declare const TweenSequence: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTweenSequence>>;
167
167
  /** @public */ export declare const TweenState: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTweenState>>;
@@ -222,7 +222,7 @@ export declare const componentDefinitionByName: {
222
222
  "core::TextShape": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTextShape>>;
223
223
  "core::TextureCamera": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTextureCamera>>;
224
224
  "core::TriggerArea": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTriggerArea>>;
225
- "core::TriggerAreaResult": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTriggerAreaResult>>;
225
+ "core::TriggerAreaResult": GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBTriggerAreaResult>>;
226
226
  "core::Tween": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTween>>;
227
227
  "core::TweenSequence": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTweenSequence>>;
228
228
  "core::TweenState": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTweenState>>;
@@ -204,8 +204,10 @@ export * from './pb/decentraland/sdk/components/visibility_component.gen';
204
204
  /* @__PURE__ */ engine.defineComponentFromSchema("core::TextureCamera", TextureCameraSchema);
205
205
  /** @public */ export const TriggerArea = engine =>
206
206
  /* @__PURE__ */ engine.defineComponentFromSchema("core::TriggerArea", TriggerAreaSchema);
207
- /** @public */ export const TriggerAreaResult = engine =>
208
- /* @__PURE__ */ engine.defineComponentFromSchema("core::TriggerAreaResult", TriggerAreaResultSchema);
207
+ /** @public */ export const TriggerAreaResult = (engine) => /* @__PURE__ */ engine.defineValueSetComponentFromSchema("core::TriggerAreaResult", TriggerAreaResultSchema, {
208
+ timestampFunction: (t) => t.timestamp,
209
+ maxElements: 100
210
+ });
209
211
  /** @public */ export const Tween = engine =>
210
212
  /* @__PURE__ */ engine.defineComponentFromSchema("core::Tween", TweenSchema);
211
213
  /** @public */ export const TweenSequence = engine =>
@@ -19,6 +19,8 @@ import { INetowrkParentType } from './manual/NetworkParent';
19
19
  import { ISyncComponentsType } from './manual/SyncComponents';
20
20
  import { TransformComponentExtended } from './manual/Transform';
21
21
  import { LightSourceComponentDefinitionExtended } from './extended/LightSource';
22
+ import { TriggerAreaComponentDefinitionExtended } from './extended/TriggerArea';
23
+ import { TagsComponentDefinitionExtended } from './manual/Tags';
22
24
  export * from './generated/index.gen';
23
25
  export type { GrowOnlyValueSetComponentDefinition, GSetComponentGetter, LastWriteWinElementSetComponentDefinition, LwwComponentGetter };
24
26
  export declare const Transform: LwwComponentGetter<TransformComponentExtended>;
@@ -34,10 +36,12 @@ export declare const AvatarEquippedData: LwwComponentGetter<AvatarEquippedDataCo
34
36
  export declare const VirtualCamera: LwwComponentGetter<VirtualCameraComponentDefinitionExtended>;
35
37
  export declare const InputModifier: LwwComponentGetter<InputModifierComponentDefinitionExtended>;
36
38
  export declare const LightSource: LwwComponentGetter<LightSourceComponentDefinitionExtended>;
39
+ export declare const TriggerArea: LwwComponentGetter<TriggerAreaComponentDefinitionExtended>;
37
40
  /**
38
41
  * @alpha
39
42
  */
40
43
  export declare const Name: (engine: Pick<IEngine, 'defineComponent'>) => LastWriteWinElementSetComponentDefinition<NameType>;
44
+ export declare const Tags: (engine: Pick<IEngine, 'defineComponent'>) => TagsComponentDefinitionExtended;
41
45
  /**
42
46
  * @alpha
43
47
  */
@@ -16,6 +16,8 @@ import defineNetworkParent from './manual/NetworkParent';
16
16
  import defineSyncComponent from './manual/SyncComponents';
17
17
  import { defineTransformComponent } from './manual/Transform';
18
18
  import { defineLightSourceComponent } from './extended/LightSource';
19
+ import { defineTriggerAreaComponent } from './extended/TriggerArea';
20
+ import defineTagsComponent from './manual/Tags';
19
21
  export * from './generated/index.gen';
20
22
  /* @__PURE__ */
21
23
  export const Transform = (engine) => defineTransformComponent(engine);
@@ -43,11 +45,15 @@ export const VirtualCamera = (engine) => defineVirtualCameraComponent(engine);
43
45
  export const InputModifier = (engine) => defineInputModifierComponent(engine);
44
46
  /* @__PURE__ */
45
47
  export const LightSource = (engine) => defineLightSourceComponent(engine);
48
+ /* @__PURE__ */
49
+ export const TriggerArea = (engine) => defineTriggerAreaComponent(engine);
46
50
  /**
47
51
  * @alpha
48
52
  */
49
53
  /* @__PURE__ */
50
54
  export const Name = (engine) => defineNameComponent(engine);
55
+ /* @__PURE__ */
56
+ export const Tags = (engine) => defineTagsComponent(engine);
51
57
  /**
52
58
  * @alpha
53
59
  */
@@ -0,0 +1,34 @@
1
+ import { IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine/types';
2
+ import { Entity } from '../../engine';
3
+ export interface TagsType {
4
+ tags: string[];
5
+ }
6
+ export interface TagsComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<TagsType> {
7
+ /**
8
+ * @public
9
+ *
10
+ * Add a tag to the entity's Tags component or create the component if it doesn't exist and add the tag
11
+ * @param entity - entity to add the tag to
12
+ * @param tagName - the tag name to add
13
+ * @returns true
14
+ */
15
+ add(entity: Entity, tagName: string): boolean;
16
+ /**
17
+ * @public
18
+ *
19
+ * Remove a tag from the entity's Tags component
20
+ * @param entity - entity to remove the tag from
21
+ * @param tagName - the tag name to remove
22
+ * @returns true if successful, false if the entity doesn't have a Tags component or the tag doesn't exist
23
+ */
24
+ remove(entity: Entity, tagName: string): boolean;
25
+ }
26
+ /**
27
+ * @public
28
+ *
29
+ * Define the Tags component
30
+ * @param engine - the engine to define the component on
31
+ * @returns the Tags component definition
32
+ */
33
+ declare function defineTagsComponent(engine: Pick<IEngine, 'defineComponent'>): TagsComponentDefinitionExtended;
34
+ export default defineTagsComponent;
@@ -0,0 +1,37 @@
1
+ import { Schemas } from '../../schemas';
2
+ /**
3
+ * @public
4
+ *
5
+ * Define the Tags component
6
+ * @param engine - the engine to define the component on
7
+ * @returns the Tags component definition
8
+ */
9
+ function defineTagsComponent(engine) {
10
+ const Tags = engine.defineComponent('core-schema::Tags', {
11
+ tags: Schemas.Array(Schemas.String)
12
+ });
13
+ return {
14
+ ...Tags,
15
+ add(entity, tagName) {
16
+ const tagsComponent = Tags.getMutableOrNull(entity);
17
+ if (tagsComponent) {
18
+ tagsComponent.tags.push(tagName);
19
+ }
20
+ else {
21
+ Tags.createOrReplace(entity, { tags: [tagName] });
22
+ }
23
+ return true;
24
+ },
25
+ remove(entity, tagName) {
26
+ const tagsComponent = Tags.getMutableOrNull(entity);
27
+ if (!tagsComponent || !tagsComponent.tags)
28
+ return false;
29
+ const newTags = tagsComponent.tags.filter((tag) => tag !== tagName);
30
+ if (newTags.length === tagsComponent.tags.length)
31
+ return false;
32
+ tagsComponent.tags = newTags;
33
+ return true;
34
+ }
35
+ };
36
+ }
37
+ export default defineTagsComponent;
@@ -10,7 +10,10 @@ export type { TweenHelper, TweenComponentDefinitionExtended } from './extended/T
10
10
  export type { CameraTransitionHelper, VirtualCameraComponentDefinitionExtended } from './extended/VirtualCamera';
11
11
  export type { TransformComponentExtended, TransformTypeWithOptionals } from './manual/Transform';
12
12
  export type { NameComponent, NameType } from './manual/Name';
13
+ export type { TagsComponentDefinitionExtended, TagsType } from './manual/Tags';
13
14
  export type { ISyncComponents, ISyncComponentsType } from './manual/SyncComponents';
14
15
  export type { INetowrkEntity, INetowrkEntityType } from './manual/NetworkEntity';
15
16
  export type { INetowrkParent, INetowrkParentType } from './manual/NetworkParent';
16
17
  export type { InputModifierHelper, InputModifierComponentDefinitionExtended } from './extended/InputModifier';
18
+ export type { LightSourceHelper, LightSourceComponentDefinitionExtended } from './extended/LightSource';
19
+ export type { TriggerAreaComponentDefinitionExtended } from './extended/TriggerArea';
@@ -143,6 +143,14 @@ function preEngine(options) {
143
143
  const entity = getEntityOrNullByName(value);
144
144
  return entity;
145
145
  }
146
+ function* getEntitiesByTag(tagName) {
147
+ const TagComponent = components.Tags({ defineComponent });
148
+ for (const [entity, component] of getEntitiesWith(TagComponent)) {
149
+ if (entity !== 0 && component.tags?.some((tag) => tag === tagName)) {
150
+ yield entity;
151
+ }
152
+ }
153
+ }
146
154
  function* getComponentDefGroup(...args) {
147
155
  const [firstComponentDef, ...componentDefinitions] = args;
148
156
  for (const [entity] of firstComponentDef.iterator()) {
@@ -191,6 +199,7 @@ function preEngine(options) {
191
199
  getComponentOrNull: getComponentOrNull,
192
200
  getEntityOrNullByName,
193
201
  getEntityByName,
202
+ getEntitiesByTag,
194
203
  removeComponentDefinition,
195
204
  registerComponentDefinition,
196
205
  entityContainer,
@@ -246,6 +255,7 @@ export function Engine(options) {
246
255
  seal: partialEngine.seal,
247
256
  getEntityOrNullByName: partialEngine.getEntityOrNullByName,
248
257
  getEntityByName: partialEngine.getEntityByName,
258
+ getEntitiesByTag: partialEngine.getEntitiesByTag,
249
259
  update,
250
260
  RootEntity: 0,
251
261
  PlayerEntity: 1,
@@ -196,6 +196,13 @@ export interface IEngine {
196
196
  * @typeParam T - The type of the entity name value
197
197
  */
198
198
  getEntityByName<T = never, K = T>(value: K & (T extends never ? never : string)): Entity;
199
+ /**
200
+ * @public
201
+ * Get all entities that have a specific tag in their Tag component
202
+ * @param tag - Tag to search
203
+ * @returns Iterator of entities that have the given tag
204
+ */
205
+ getEntitiesByTag(tagName: string): Iterable<Entity>;
199
206
  /**
200
207
  * @public
201
208
  * @param deltaTime - deltaTime in seconds
package/dist/index.d.ts CHANGED
@@ -9,12 +9,12 @@ export * from './systems/raycast';
9
9
  export * from './systems/videoEvents';
10
10
  export * from './systems/async-task';
11
11
  export * from './systems/tween';
12
+ export * from './systems/triggerArea';
12
13
  export * from './engine/entity';
13
14
  export * from './components/types';
14
- import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended, AudioSourceComponentDefinitionExtended, AudioStreamComponentDefinitionExtended, ISyncComponents, TweenComponentDefinitionExtended, INetowrkEntity, INetowrkParent, VirtualCameraComponentDefinitionExtended, InputModifierComponentDefinitionExtended } from './components/types';
15
+ import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended, AudioSourceComponentDefinitionExtended, AudioStreamComponentDefinitionExtended, ISyncComponents, TweenComponentDefinitionExtended, INetowrkEntity, INetowrkParent, VirtualCameraComponentDefinitionExtended, InputModifierComponentDefinitionExtended, LightSourceComponentDefinitionExtended, TriggerAreaComponentDefinitionExtended } from './components/types';
15
16
  import { NameComponent } from './components/manual/Name';
16
- import { AvatarEquippedDataComponentDefinitionExtended } from './components/extended/AvatarEquippedData';
17
- import { AvatarShapeComponentDefinitionExtended } from './components/extended/AvatarShape';
17
+ import { TagsComponentDefinitionExtended } from './components/manual/Tags';
18
18
  export declare const Transform: TransformComponentExtended;
19
19
  export declare const Animator: AnimatorComponentDefinitionExtended;
20
20
  export declare const AudioSource: AudioSourceComponentDefinitionExtended;
@@ -22,12 +22,13 @@ export declare const AudioStream: AudioStreamComponentDefinitionExtended;
22
22
  export declare const Material: MaterialComponentDefinitionExtended;
23
23
  export declare const MeshRenderer: MeshRendererComponentDefinitionExtended;
24
24
  export declare const MeshCollider: MeshColliderComponentDefinitionExtended;
25
- export declare const AvatarEquippedData: AvatarEquippedDataComponentDefinitionExtended;
26
- export declare const AvatarShape: AvatarShapeComponentDefinitionExtended;
27
25
  export declare const Name: NameComponent;
26
+ export declare const Tags: TagsComponentDefinitionExtended;
28
27
  export declare const Tween: TweenComponentDefinitionExtended;
29
28
  export declare const VirtualCamera: VirtualCameraComponentDefinitionExtended;
30
29
  export declare const InputModifier: InputModifierComponentDefinitionExtended;
30
+ export declare const LightSource: LightSourceComponentDefinitionExtended;
31
+ export declare const TriggerArea: TriggerAreaComponentDefinitionExtended;
31
32
  /**
32
33
  * @alpha
33
34
  * This is going to be used for sync components through a server.
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ export * from './systems/raycast';
10
10
  export * from './systems/videoEvents';
11
11
  export * from './systems/async-task';
12
12
  export * from './systems/tween';
13
+ export * from './systems/triggerArea';
13
14
  export * from './engine/entity';
14
15
  export * from './components/types';
15
16
  // @internal
@@ -25,13 +26,13 @@ export const AudioStream = /* @__PURE__*/ components.AudioStream(engine);
25
26
  export const Material = /* @__PURE__*/ components.Material(engine);
26
27
  export const MeshRenderer = /* @__PURE__*/ components.MeshRenderer(engine);
27
28
  export const MeshCollider = /* @__PURE__*/ components.MeshCollider(engine);
28
- export const AvatarEquippedData =
29
- /* @__PURE__*/ components.AvatarEquippedData(engine);
30
- export const AvatarShape = /* @__PURE__*/ components.AvatarShape(engine);
31
29
  export const Name = components.Name(engine);
30
+ export const Tags = components.Tags(engine);
32
31
  export const Tween = /* @__PURE__*/ components.Tween(engine);
33
32
  export const VirtualCamera = /* @__PURE__*/ components.VirtualCamera(engine);
34
33
  export const InputModifier = /* @__PURE__*/ components.InputModifier(engine);
34
+ export const LightSource = /* @__PURE__*/ components.LightSource(engine);
35
+ export const TriggerArea = /* @__PURE__*/ components.TriggerArea(engine);
35
36
  /**
36
37
  * @alpha
37
38
  * This is going to be used for sync components through a server.
@@ -9,6 +9,7 @@ import { IInputSystem } from './../../engine/input';
9
9
  import { RaycastSystem } from '../../systems/raycast';
10
10
  import { VideoEventsSystem } from '../../systems/videoEvents';
11
11
  import { TweenSystem } from '../../systems/tween';
12
+ import { TriggerAreaEventsSystem } from '../../systems/triggerArea';
12
13
  /**
13
14
  * @public
14
15
  * The engine is the part of the scene that sits in the middle and manages all of the other parts.
@@ -56,6 +57,12 @@ export { VideoEventsSystem };
56
57
  */
57
58
  export declare const tweenSystem: TweenSystem;
58
59
  export { TweenSystem };
60
+ /**
61
+ * @public
62
+ * Register callback functions for trigger area results.
63
+ */
64
+ export declare const triggerAreaEventsSystem: TriggerAreaEventsSystem;
65
+ export { TriggerAreaEventsSystem };
59
66
  /**
60
67
  * @public
61
68
  * Runs an async function