@dcl/sdk 7.0.0-3277074139.commit-6059d49 → 7.0.0-3290193397.commit-3ca136b

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.
@@ -6,32 +6,123 @@ import ReactEcs, {
6
6
  YGJustify
7
7
  } from '@dcl/react-ecs'
8
8
 
9
+ let counter = 0
10
+
9
11
  export const uiComponent = () => (
10
12
  <UiEntity
11
13
  uiTransform={{
12
- width: 500,
13
- height: 500,
14
- padding: { top: 10, right: 10, bottom: 10, left: 10 }
14
+ width: 700,
15
+ height: 400,
16
+ margin: { top: '35px', left: '500px' }
15
17
  }}
16
- uiBackground={{ backgroundColor: { r: 10, g: 10, b: 10, a: 0.2 } }}
18
+ uiBackground={{ backgroundColor: Color4.create(0.5, 0.8, 0.1, 0.6) }}
17
19
  >
18
20
  <UiEntity
19
21
  uiTransform={{
20
- width: 100,
21
- height: 100,
22
- display: YGDisplay.YGD_FLEX,
22
+ width: '100%',
23
+ height: '20%',
23
24
  justifyContent: YGJustify.YGJ_CENTER,
24
- alignItems: YGAlign.YGA_CENTER
25
+ alignItems: YGAlign.YGA_CENTER,
26
+ display: YGDisplay.YGD_FLEX
25
27
  }}
26
- uiBackground={{ backgroundColor: { r: 255, g: 45, b: 85, a: 0.2 } }}
27
28
  >
28
29
  <UiEntity
29
- uiTransform={{ width: 80, height: 20 }}
30
- uiText={{ value: 'Boedo', textAlign: 0, fontSize: 12 }}
31
- uiBackground={{ backgroundColor: { r: 255, g: 45, b: 85, a: 1 } }}
30
+ uiText={{ value: 'SDK 7', fontSize: 80 }}
31
+ uiBackground={{ backgroundColor: Color4.fromHexString('#fbf0f0') }}
32
+ />
33
+ </UiEntity>
34
+ <UiEntity
35
+ uiTransform={{
36
+ width: '100%',
37
+ height: '20%',
38
+ justifyContent: YGJustify.YGJ_CENTER,
39
+ alignItems: YGAlign.YGA_CENTER,
40
+ display: YGDisplay.YGD_FLEX
41
+ }}
42
+ >
43
+ <UiEntity
44
+ uiText={{ value: `Counter: ${counter}`, fontSize: 60 }}
45
+ uiBackground={{ backgroundColor: Color4.fromHexString('#fbf0f0') }}
46
+ />
47
+ </UiEntity>
48
+ <UiEntity
49
+ uiTransform={{
50
+ width: '100%',
51
+ height: '100px',
52
+ justifyContent: YGJustify.YGJ_CENTER,
53
+ alignItems: YGAlign.YGA_CENTER,
54
+ display: YGDisplay.YGD_FLEX
55
+ }}
56
+ >
57
+ <UiEntity
58
+ uiText={{ value: `Player: ${getPlayerPosition()}`, fontSize: 40 }}
59
+ uiBackground={{ backgroundColor: Color4.fromHexString('#fbf0f0') }}
32
60
  />
33
61
  </UiEntity>
34
62
  </UiEntity>
35
63
  )
36
64
 
65
+ function getPlayerPosition() {
66
+ const playerPosition = Transform.getOrNull(engine.PlayerEntity)
67
+ if (!playerPosition) return ''
68
+ const { x, y, z } = playerPosition.position
69
+ return `{x: ${x.toFixed(2)}, y: ${y.toFixed(2)}, z: ${z.toFixed(2)} }`
70
+ }
71
+
37
72
  renderUi(uiComponent)
73
+
74
+ // Cube factory
75
+ function createCube(x: number, y: number, z: number, spawner = true): Entity {
76
+ const meshEntity = engine.addEntity()
77
+ Transform.create(meshEntity, { position: { x, y, z } })
78
+ MeshRenderer.create(meshEntity, { box: { uvs: [] } })
79
+ MeshCollider.create(meshEntity, { box: {} })
80
+ if (spawner) {
81
+ PointerEvents.create(meshEntity, {
82
+ pointerEvents: [
83
+ {
84
+ eventType: PointerEventType.PET_DOWN,
85
+ eventInfo: {
86
+ button: InputAction.IA_PRIMARY,
87
+ hoverText: 'Press E to spawn',
88
+ maxDistance: 100,
89
+ showFeedback: true
90
+ }
91
+ }
92
+ ]
93
+ })
94
+ }
95
+ return meshEntity
96
+ }
97
+
98
+ // Systems
99
+ function circularSystem(dt: number) {
100
+ const entitiesWithMeshRenderer = engine.getEntitiesWith(
101
+ MeshRenderer,
102
+ Transform
103
+ )
104
+ for (const [entity, _meshRenderer, _transform] of entitiesWithMeshRenderer) {
105
+ const mutableTransform = Transform.getMutable(entity)
106
+
107
+ mutableTransform.rotation = Quaternion.multiply(
108
+ mutableTransform.rotation,
109
+ Quaternion.fromAngleAxis(dt * 10, Vector3.Up())
110
+ )
111
+ }
112
+ }
113
+
114
+ function spawnerSystem() {
115
+ const clickedCubes = engine.getEntitiesWith(PointerEvents)
116
+ for (const [entity] of clickedCubes) {
117
+ if (wasEntityClicked(entity, InputAction.IA_PRIMARY)) {
118
+ counter++
119
+ }
120
+ }
121
+ }
122
+
123
+ // Init
124
+ createCube(8, 1, 8)
125
+ engine.addSystem(circularSystem)
126
+ engine.addSystem(spawnerSystem)
127
+
128
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/sdk",
3
- "version": "7.0.0-3277074139.commit-6059d49",
3
+ "version": "7.0.0-3290193397.commit-3ca136b",
4
4
  "description": "",
5
5
  "main": "dist/src/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -27,8 +27,8 @@
27
27
  "src/cli/**/*.js"
28
28
  ],
29
29
  "dependencies": {
30
- "@dcl/amd": "6.11.9-3277074139.commit-6059d49",
31
- "@dcl/build-ecs": "6.11.9-3277074139.commit-6059d49",
30
+ "@dcl/amd": "6.11.9-3290193397.commit-3ca136b",
31
+ "@dcl/build-ecs": "6.11.9-3290193397.commit-3ca136b",
32
32
  "@dcl/kernel": "1.0.0-2994874542.commit-c3ae489",
33
33
  "@dcl/posix": "^1.0.4",
34
34
  "@dcl/schemas": "4.8.0",
@@ -38,5 +38,5 @@
38
38
  "ignore": "^5.1.8"
39
39
  },
40
40
  "minCliVersion": "3.10.2",
41
- "commit": "6059d491b1dcc382a88775d5c532e6b84fe79538"
41
+ "commit": "3ca136b3d2dc1145d3abbe3811086970a56f7c6f"
42
42
  }
@@ -1190,6 +1190,8 @@ declare type ExcludeUndefined<T> = {
1190
1190
  [P in keyof T]: undefined extends T[P] ? never : P;
1191
1191
  }[keyof T];
1192
1192
 
1193
+ declare const executeTask: (task: Task<unknown>) => void;
1194
+
1193
1195
  /** @public */
1194
1196
  declare type FloatArray = number[];
1195
1197
 
@@ -1372,14 +1374,7 @@ declare type ISchema<T = any> = {
1372
1374
  create(): T;
1373
1375
  };
1374
1376
 
1375
- /**
1376
- * Check if a pointer event has been emited in the last tick-update.
1377
- * @param entity the entity to query, for global clicks use `engine.RootEntity`
1378
- * @param actionButton
1379
- * @param pointerEventType
1380
- * @returns
1381
- */
1382
- declare function isPointerEventActive(entity: Entity, actionButton: InputAction, pointerEventType: PointerEventType): boolean;
1377
+ declare const isPointerEventActive: (entity: Entity, actionButton: InputAction, pointerEventType: PointerEventType) => boolean;
1383
1378
 
1384
1379
  declare function isPointerEventActiveGenerator(engine: IEngine): (entity: Entity, actionButton: InputAction, pointerEventType: PointerEventType) => boolean;
1385
1380
 
@@ -3564,6 +3559,8 @@ declare interface Spec {
3564
3559
  */
3565
3560
  declare type SystemFn = (dt: number) => void;
3566
3561
 
3562
+ declare type Task<T = unknown> = () => Promise<T>;
3563
+
3567
3564
  declare const enum TextAlignMode {
3568
3565
  TAM_TOP_LEFT = 0,
3569
3566
  TAM_TOP_CENTER = 1,
@@ -4248,13 +4245,7 @@ declare interface Vector3_2 {
4248
4245
  /** @public */
4249
4246
  declare const VisibilityComponent: ComponentDefinition<ISchema<PBVisibilityComponent>, PBVisibilityComponent>;
4250
4247
 
4251
- /**
4252
- * Check if an entity emitted a clicked event
4253
- * @param entity the entity to query, for global clicks use `engine.RootEntity`
4254
- * @param actionButton
4255
- * @returns true if the entity was clicked in the last tick-update
4256
- */
4257
- declare function wasEntityClicked(entity: Entity, actionButton: InputAction): boolean;
4248
+ declare const wasEntityClicked: (entity: Entity, actionButton: InputAction) => boolean;
4258
4249
 
4259
4250
  declare function wasEntityClickedGenerator(engine: IEngine): (entity: Entity, actionButton: InputAction) => boolean;
4260
4251