@dcl/playground-assets 7.0.6-3807227301.commit-1045452 → 7.0.6-3808564125.commit-7a2650b

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/sdk",
3
- "version": "7.0.6-3807227301.commit-1045452",
3
+ "version": "7.0.6-3808564125.commit-7a2650b",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",
@@ -25,5 +25,5 @@
25
25
  "@dcl/unity-renderer": "1.0.68557-20221221195847.commit-f743b85"
26
26
  },
27
27
  "minCliVersion": "3.14.1",
28
- "commit": "104545291581dd38595dbfc46135d0f573d306ff"
28
+ "commit": "7a2650b741ac5f5a5d3f00ac1c955e5f773d679a"
29
29
  }
@@ -1 +1 @@
1
- [{"name":"Billboard","category":"sample","path":"billboard.ts"},{"name":"Cube Spawner","category":"sample","path":"cube-spawner.ts"},{"name":"Material","category":"component","path":"material.ts"},{"name":"Mesh","category":"component","path":"mesh.ts"},{"name":"Pointer Events","category":"sample","path":"pointer-events.ts"},{"name":"Raycast Hit","category":"component","path":"raycast-hit.ts"},{"name":"Raycast Hit many","category":"sample","path":"raycast-hit-many.ts"},{"name":"Container","category":"ui","path":"ui.tsx"}]
1
+ [{"name":"Billboard","category":"sample","path":"billboard.ts"},{"name":"Cube Spawner","category":"sample","path":"cube-spawner.ts"},{"name":"Material","category":"component","path":"material.ts"},{"name":"Mesh","category":"component","path":"mesh.ts"},{"name":"Pointer Events","category":"sample","path":"pointer-events.ts"},{"name":"Raycast Hit","category":"component","path":"raycast-hit.ts"},{"name":"Raycast Hit many","category":"sample","path":"raycast-hit-many.ts"},{"name":"Container","category":"ui","path":"ui.tsx"},{"name":"UiBackground component","category":"ui","path":"ui-backgrounds.tsx"},{"name":"Dropdown element","category":"ui","path":"ui-dropdown.tsx"}]
@@ -5,8 +5,8 @@ import {
5
5
  MeshRenderer,
6
6
  MeshCollider,
7
7
  InputAction,
8
- PBPointerHoverFeedback_Entry,
9
- PointerHoverFeedback,
8
+ PBPointerEvents_Entry,
9
+ PointerEvents,
10
10
  PointerEventType
11
11
  } from '@dcl/sdk/ecs'
12
12
 
@@ -15,13 +15,15 @@ function createCube(
15
15
  x: number,
16
16
  y: number,
17
17
  z: number,
18
- pointerEvents: PBPointerHoverFeedback_Entry[]
18
+ pointerEvents: PBPointerEvents_Entry[]
19
19
  ): Entity {
20
20
  const meshEntity = engine.addEntity()
21
21
  Transform.create(meshEntity, { position: { x, y, z } })
22
22
  MeshRenderer.create(meshEntity, { mesh: { $case: 'box', box: { uvs: [] } } })
23
23
  MeshCollider.create(meshEntity, { mesh: { $case: 'box', box: {} } })
24
- PointerHoverFeedback.create(meshEntity, { pointerEvents })
24
+
25
+ PointerEvents.create(meshEntity, { pointerEvents })
26
+
25
27
  return meshEntity
26
28
  }
27
29
 
@@ -0,0 +1,192 @@
1
+ import { engine, YGFlexDirection, BackgroundTextureMode } from '@dcl/sdk/ecs'
2
+ import { Color4 } from '@dcl/sdk/math'
3
+ import ReactEcs, {
4
+ UiEntity,
5
+ Label,
6
+ ReactEcsRenderer,
7
+ Dropdown
8
+ } from '@dcl/sdk/react-ecs'
9
+
10
+ type GenesisPlazaContent = string
11
+ const src: GenesisPlazaContent = 'images/rounded_alpha_square.png'
12
+ const centeredImage: GenesisPlazaContent = 'images/ui_beam_up_bg.png'
13
+
14
+ let dt = 0
15
+ let userId: string | undefined
16
+
17
+ engine.addSystem((t) => {
18
+ dt += t
19
+ })
20
+
21
+ let currentValue = 0
22
+ const options = [
23
+ function StretchAndTint() {
24
+ const tint2 = Color4.lerp(
25
+ Color4.Red(),
26
+ Color4.Blue(),
27
+ 1 + Math.sin(dt + Math.cos(dt * 0.3)) * 0.5
28
+ )
29
+ return (
30
+ <UiEntity
31
+ uiTransform={{
32
+ width: `${(1 + Math.sin(dt) * 0.5) * 50}%`,
33
+ height: 244
34
+ }}
35
+ uiBackground={{
36
+ color: tint2,
37
+ textureMode: BackgroundTextureMode.STRETCH,
38
+ texture: {
39
+ src
40
+ }
41
+ }}
42
+ >
43
+ <Label value="STRETCH + TINT\n(borders are deformed)" fontSize={29} />
44
+ </UiEntity>
45
+ )
46
+ },
47
+ function NineSlicesAndTint() {
48
+ const tint = Color4.lerp(
49
+ Color4.Red(),
50
+ Color4.Blue(),
51
+ 1 + Math.sin(dt + Math.cos(dt * 0.3)) * 0.5
52
+ )
53
+ return (
54
+ <UiEntity
55
+ uiTransform={{
56
+ width: `${(1 + Math.sin(dt) * 0.5) * 50}%`,
57
+ height: 128
58
+ }}
59
+ uiBackground={{
60
+ color: tint,
61
+ textureMode: BackgroundTextureMode.NINE_SLICES,
62
+ texture: {
63
+ src
64
+ }
65
+ }}
66
+ >
67
+ <Label
68
+ value="NINE_SLICES + TINT"
69
+ color={Color4.Black()}
70
+ fontSize={29}
71
+ />
72
+ </UiEntity>
73
+ )
74
+ },
75
+ function NineSlicesAndTint() {
76
+ const tint = Color4.lerp(
77
+ Color4.fromHexString('#336613ff'),
78
+ Color4.fromHexString('#f099f3ff'),
79
+ 1 + Math.sin(dt) * 0.5
80
+ )
81
+
82
+ return (
83
+ <UiEntity
84
+ uiTransform={{
85
+ width: 200,
86
+ height: (1 + Math.sin(dt) * 0.5) * 200
87
+ }}
88
+ uiBackground={{
89
+ color: tint,
90
+ textureMode: BackgroundTextureMode.NINE_SLICES,
91
+ texture: {
92
+ src: centeredImage
93
+ }
94
+ }}
95
+ >
96
+ <Label value="NINE_SLICES + TINT" color={Color4.Red()} fontSize={29} />
97
+ </UiEntity>
98
+ )
99
+ },
100
+ function NineSlicesAndMargin() {
101
+ const margin = (1 + Math.cos(dt * 0.3)) * 0.1
102
+
103
+ return (
104
+ <UiEntity
105
+ uiTransform={{
106
+ width: 256,
107
+ height: 256
108
+ }}
109
+ uiBackground={{
110
+ textureMode: BackgroundTextureMode.NINE_SLICES,
111
+ texture: {
112
+ src: centeredImage
113
+ },
114
+ textureSlices: {
115
+ top: margin,
116
+ bottom: margin,
117
+ left: margin,
118
+ right: margin
119
+ }
120
+ }}
121
+ >
122
+ <Label
123
+ value={`NINE_SLICES (with margins ${margin.toFixed(2)})`}
124
+ color={Color4.Red()}
125
+ fontSize={29}
126
+ />
127
+ </UiEntity>
128
+ )
129
+ },
130
+ function Center() {
131
+ return (
132
+ <UiEntity
133
+ uiTransform={{
134
+ width: 250 + Math.cos(dt) * 100,
135
+ height: 128 + Math.sin(dt * 0.2) * 64
136
+ }}
137
+ uiBackground={{
138
+ textureMode: BackgroundTextureMode.CENTER,
139
+ texture: {
140
+ src: centeredImage
141
+ }
142
+ }}
143
+ >
144
+ <Label value="CENTER" color={Color4.Green()} fontSize={29} />
145
+ </UiEntity>
146
+ )
147
+ },
148
+ function AvatarTexture() {
149
+ return (
150
+ <UiEntity
151
+ uiTransform={{
152
+ width: 250 + Math.cos(dt) * 100,
153
+ height: 128 + Math.sin(dt * 0.2) * 64
154
+ }}
155
+ uiBackground={{
156
+ textureMode: BackgroundTextureMode.CENTER,
157
+ avatarTexture: {
158
+ userId: userId ?? ''
159
+ }
160
+ }}
161
+ >
162
+ <Label value="CENTER" color={Color4.Green()} fontSize={29} />
163
+ </UiEntity>
164
+ )
165
+ }
166
+ ]
167
+
168
+ function selectOption(index: number) {
169
+ currentValue = index
170
+ }
171
+
172
+ export const ui = () => {
173
+ const Renderer = options[currentValue] || (() => null)
174
+
175
+ return (
176
+ <UiEntity
177
+ uiTransform={{
178
+ width: '100%',
179
+ height: '50%',
180
+ flexDirection: YGFlexDirection.YGFD_COLUMN,
181
+ margin: { left: 300 }
182
+ }}
183
+ uiBackground={{ color: Color4.Black() }}
184
+ >
185
+ <Label value="Select an example from below" />
186
+ <Dropdown options={options.map(($) => $.name)} onChange={selectOption} />
187
+ <Renderer />
188
+ </UiEntity>
189
+ )
190
+ }
191
+
192
+ ReactEcsRenderer.setUiRenderer(ui)
@@ -0,0 +1,32 @@
1
+ import {
2
+ YGFlexDirection,
3
+ } from '@dcl/sdk/ecs'
4
+ import { Color4 } from '@dcl/sdk/math'
5
+ import ReactEcs, { UiEntity, Label, ReactEcsRenderer, Dropdown } from '@dcl/sdk/react-ecs'
6
+
7
+ const colorList = ['Red', 'Green', 'Blue', 'Black', 'White', 'Purple', 'Magenta', 'Yellow', 'Gray', 'Teal', 'Clear']
8
+
9
+ let selectedColorIndex = 0
10
+
11
+ function selectOption(index: number) {
12
+ selectedColorIndex = index
13
+ }
14
+
15
+ export const ui = () => {
16
+ return (
17
+ <UiEntity
18
+ uiTransform={{
19
+ width: "100%",
20
+ height: "3000px",
21
+ flexDirection: YGFlexDirection.YGFD_COLUMN
22
+ }}
23
+ uiBackground={{ color: (Color4 as any)[colorList[selectedColorIndex]]() }}
24
+ >
25
+ <Label value="Select a color" fontSize={29} />
26
+ <Dropdown options={colorList} onChange={selectOption} />
27
+ </UiEntity>
28
+ )
29
+ }
30
+
31
+
32
+ ReactEcsRenderer.setUiRenderer(ui)
@@ -6,14 +6,14 @@ import {
6
6
  MeshCollider,
7
7
  InputAction,
8
8
  inputSystem,
9
- PointerHoverFeedback,
9
+ PointerEvents,
10
10
  YGAlign,
11
11
  YGDisplay,
12
12
  YGJustify,
13
13
  PointerEventType
14
14
  } from '@dcl/sdk/ecs'
15
15
  import { Vector3, Color4, Quaternion } from '@dcl/sdk/math'
16
- import ReactEcs, { UiEntity, ReactEcsRenderer } from '@dcl/sdk/react-ecs'
16
+ import ReactEcs, { UiEntity, Label, ReactEcsRenderer } from '@dcl/sdk/react-ecs'
17
17
 
18
18
  let counter = 0
19
19
 
@@ -24,7 +24,7 @@ export const uiComponent = () => (
24
24
  height: 400,
25
25
  margin: { top: '35px', left: '500px' }
26
26
  }}
27
- uiBackground={{ backgroundColor: Color4.create(0.5, 0.8, 0.1, 0.6) }}
27
+ uiBackground={{ color: Color4.create(0.5, 0.8, 0.1, 0.6) }}
28
28
  >
29
29
  <UiEntity
30
30
  uiTransform={{
@@ -35,9 +35,10 @@ export const uiComponent = () => (
35
35
  display: YGDisplay.YGD_FLEX
36
36
  }}
37
37
  >
38
- <UiEntity
39
- uiText={{ value: 'SDK 7', fontSize: 80 }}
40
- uiBackground={{ backgroundColor: Color4.fromHexString('#fbf0f0') }}
38
+ <Label
39
+ value="SDK 7"
40
+ fontSize={80}
41
+ uiBackground={{ color: Color4.fromHexString('#fbf0f0') }}
41
42
  />
42
43
  </UiEntity>
43
44
  <UiEntity
@@ -49,9 +50,10 @@ export const uiComponent = () => (
49
50
  display: YGDisplay.YGD_FLEX
50
51
  }}
51
52
  >
52
- <UiEntity
53
- uiText={{ value: `Counter: ${counter}`, fontSize: 60 }}
54
- uiBackground={{ backgroundColor: Color4.fromHexString('#fbf0f0') }}
53
+ <Label
54
+ value={`Counter: ${counter}`}
55
+ fontSize={60}
56
+ uiBackground={{ color: Color4.fromHexString('#fbf0f0') }}
55
57
  />
56
58
  </UiEntity>
57
59
  <UiEntity
@@ -63,9 +65,10 @@ export const uiComponent = () => (
63
65
  display: YGDisplay.YGD_FLEX
64
66
  }}
65
67
  >
66
- <UiEntity
67
- uiText={{ value: `Player: ${getPlayerPosition()}`, fontSize: 40 }}
68
- uiBackground={{ backgroundColor: Color4.fromHexString('#fbf0f0') }}
68
+ <Label
69
+ value={`Player: ${getPlayerPosition()}`}
70
+ fontSize={40}
71
+ uiBackground={{ color: Color4.fromHexString('#fbf0f0') }}
69
72
  />
70
73
  </UiEntity>
71
74
  </UiEntity>
@@ -87,7 +90,7 @@ function createCube(x: number, y: number, z: number, spawner = true): Entity {
87
90
  MeshRenderer.create(meshEntity, { mesh: { $case: 'box', box: { uvs: [] } } })
88
91
  MeshCollider.create(meshEntity, { mesh: { $case: 'box', box: {} } })
89
92
  if (spawner) {
90
- PointerHoverFeedback.create(meshEntity, {
93
+ PointerEvents.create(meshEntity, {
91
94
  pointerEvents: [
92
95
  {
93
96
  eventType: PointerEventType.PET_DOWN,
@@ -121,7 +124,7 @@ function circularSystem(dt: number) {
121
124
  }
122
125
 
123
126
  function spawnerSystem() {
124
- const clickedCubes = engine.getEntitiesWith(PointerHoverFeedback)
127
+ const clickedCubes = engine.getEntitiesWith(PointerEvents)
125
128
  for (const [entity] of clickedCubes) {
126
129
  if (
127
130
  inputSystem.isTriggered(