@dcl/playground-assets 7.22.5 → 7.22.6-25007982108.commit-83012ab

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,39 +0,0 @@
1
- {
2
- "name": "@dcl/sdk",
3
- "description": "",
4
- "version": "7.22.5",
5
- "author": "Decentraland",
6
- "dependencies": {
7
- "@dcl/ecs": "file:../ecs",
8
- "@dcl/ecs-math": "2.1.0",
9
- "@dcl/explorer": "1.0.164509-20240802172549.commit-fb95b9b",
10
- "@dcl/js-runtime": "file:../js-runtime",
11
- "@dcl/react-ecs": "file:../react-ecs",
12
- "@dcl/sdk-commands": "file:../sdk-commands",
13
- "text-encoding": "0.7.0"
14
- },
15
- "keywords": [],
16
- "license": "Apache-2.0",
17
- "main": "./index.js",
18
- "minCliVersion": "3.14.1",
19
- "repository": {
20
- "url": "git+https://github.com/decentraland/js-sdk-toolchain",
21
- "directory": "packages/@dcl/sdk"
22
- },
23
- "scripts": {
24
- "build": "tsc -p tsconfig.json",
25
- "start": "npm run build && tsc -p tsconfig.json --watch"
26
- },
27
- "tsdoc": {
28
- "tsdocFlavor": "AEDoc"
29
- },
30
- "typedoc": {
31
- "entryPoint": "./src/index.ts",
32
- "readmeFile": "./README.md",
33
- "displayName": "SDK",
34
- "tsconfig": "./tsconfig.json"
35
- },
36
- "types": "./index.d.ts",
37
- "typings": "./index.d.ts",
38
- "commit": "b6da827dbab8b88795119b50ab578d457e552d0c"
39
- }
@@ -1,111 +0,0 @@
1
- import {
2
- Entity,
3
- engine,
4
- Material,
5
- Transform,
6
- MeshRenderer,
7
- Billboard,
8
- BillboardMode,
9
- TextShape,
10
- Schemas
11
- } from '@dcl/sdk/ecs'
12
- import { Vector3, Color3, Color4 } from '@dcl/sdk/math'
13
-
14
- function createPlaneTexture(x: number, y: number, z: number): Entity {
15
- const meshEntity = engine.addEntity()
16
-
17
- Material.create(meshEntity, {
18
- material: {
19
- $case: 'pbr',
20
- pbr: {
21
- texture: {
22
- tex: {
23
- $case: 'texture',
24
- texture: { src: 'models/polaroid2.png' }
25
- }
26
- }
27
- }
28
- }
29
- })
30
- Transform.create(meshEntity, {
31
- position: { x, y, z },
32
- scale: Vector3.create(2, 2, 2)
33
- })
34
- MeshRenderer.create(meshEntity, {
35
- mesh: {
36
- $case: 'plane',
37
- plane: {
38
- uvs: [...Array.from({ length: 40 }, () => 0), 0, 1, 1, 1, 1, 0, 0, 0]
39
- }
40
- }
41
- })
42
- return meshEntity
43
- }
44
-
45
- function createBillboards() {
46
- const plane1 = createPlaneTexture(8, 3, 1)
47
- const plane2 = createPlaneTexture(12, 3, 1)
48
- createPlaneTexture(4, 3, 1)
49
-
50
- const plane5 = createPlaneTexture(8, 3, 8)
51
- const plane4 = createPlaneTexture(12, 3, 8)
52
- createPlaneTexture(4, 3, 8)
53
-
54
- Billboard.create(plane1, {
55
- billboardMode: BillboardMode.BM_Y
56
- })
57
- Billboard.create(plane2)
58
- Billboard.create(plane4, {
59
- billboardMode: BillboardMode.BM_ALL
60
- })
61
- Billboard.create(plane5, {
62
- billboardMode: BillboardMode.BM_Y
63
- })
64
- }
65
-
66
- function createTextShape(text: string, position: Vector3, textColor: Color4) {
67
- const entity = engine.addEntity()
68
- Transform.create(entity, { position })
69
- return TextShape.create(entity, {
70
- text,
71
- fontSize: 3,
72
- outlineWidth: 0.1,
73
- outlineColor: Color3.Black(),
74
- textColor
75
- })
76
- }
77
-
78
- function createTextShapes() {
79
- const regularColor = Color4.create(1, 0.2, 0.8, 0.8)
80
- const oppositeColor = Color4.create(0.8, 0.2, 1, 0.8)
81
-
82
- createTextShape('Regular, only Y-rotation', Vector3.create(8, 1, 1), regularColor)
83
- createTextShape('Regular', Vector3.create(12, 1, 1), regularColor)
84
- createTextShape('Without billboard', Vector3.create(4, 1, 1), regularColor)
85
- createTextShape('Opposite, only Y', Vector3.create(8, 1, 8), oppositeColor)
86
- createTextShape('Opposite', Vector3.create(12, 1, 8), oppositeColor)
87
- createTextShape('Without billboard', Vector3.create(4, 1, 8), oppositeColor)
88
- }
89
-
90
- createBillboards()
91
- createTextShapes()
92
-
93
- const BouncingBillboard = engine.defineComponent('bouncing billboard', {
94
- t: Schemas.Number,
95
- originalPosition: Schemas.Vector3
96
- })
97
-
98
- engine.addSystem((dt: number) => {
99
- for (const [entity] of engine.getEntitiesWith(Billboard, Transform)) {
100
- if (BouncingBillboard.getOrNull(entity) === null) {
101
- BouncingBillboard.create(entity, {
102
- originalPosition: Transform.get(entity).position
103
- })
104
- }
105
-
106
- const bounce = BouncingBillboard.getMutable(entity)
107
- bounce.t += dt
108
-
109
- Transform.getMutable(entity).position.y = bounce.originalPosition.y + 0.05 * Math.sin(10 * bounce.t)
110
- }
111
- })
@@ -1,38 +0,0 @@
1
- import { Entity, engine, pointerEventsSystem, Transform, MeshRenderer, MeshCollider, InputAction } from '@dcl/sdk/ecs'
2
- import { Quaternion, Vector3 } from '@dcl/sdk/math'
3
-
4
- // Cube factory
5
- function createCube(x: number, y: number, z: number): Entity {
6
- const meshEntity = engine.addEntity()
7
- Transform.create(meshEntity, { position: { x, y, z } })
8
- MeshRenderer.create(meshEntity, { mesh: { $case: 'box', box: { uvs: [] } } })
9
- MeshCollider.create(meshEntity, { mesh: { $case: 'box', box: {} } })
10
-
11
- return meshEntity
12
- }
13
-
14
- // Systems
15
- function circularSystem(dt: number) {
16
- const entitiesWithMeshRenderer = engine.getEntitiesWith(MeshRenderer, Transform)
17
- for (const [entity, _meshRenderer, _transform] of entitiesWithMeshRenderer) {
18
- const mutableTransform = Transform.getMutable(entity)
19
-
20
- mutableTransform.rotation = Quaternion.multiply(
21
- mutableTransform.rotation,
22
- Quaternion.fromAngleAxis(dt * 10, Vector3.Up())
23
- )
24
- }
25
- }
26
-
27
- // Init
28
- const initEntity = createCube(8, 1, 8)
29
- pointerEventsSystem.onPointerDown(
30
- { entity: initEntity, opts: { button: InputAction.IA_PRIMARY, hoverText: 'Press E to spawn' } },
31
- () => {
32
- createCube(1 + Math.random() * 8, Math.random() * 8, 1 + Math.random() * 8)
33
- }
34
- )
35
-
36
- engine.addSystem(circularSystem)
37
-
38
- export {}
@@ -1 +0,0 @@
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"}]
@@ -1,50 +0,0 @@
1
- import { Entity, engine, Transform, MeshRenderer, Material, MaterialTransparencyMode } from '@dcl/sdk/ecs'
2
-
3
- function createSphere(x: number, y: number, z: number): Entity {
4
- const meshEntity = engine.addEntity()
5
- Transform.create(meshEntity, { position: { x, y, z } })
6
- MeshRenderer.create(meshEntity, { mesh: { $case: 'sphere', sphere: {} } })
7
- return meshEntity
8
- }
9
-
10
- Material.create(createSphere(15, 1, 15), {
11
- material: {
12
- $case: 'pbr',
13
- pbr: {
14
- albedoColor: { r: 0, g: 0, b: 1, a: 1 },
15
- reflectivityColor: { r: 0.5, g: 0.5, b: 0.5 },
16
- metallic: 0.8,
17
- roughness: 0.1
18
- }
19
- }
20
- })
21
-
22
- Material.create(createSphere(13, 1, 15), {
23
- material: {
24
- $case: 'pbr',
25
- pbr: {
26
- albedoColor: { r: 1, g: 1, b: 0, a: 1 },
27
- reflectivityColor: { r: 0.5, g: 0.5, b: 0.5 },
28
- metallic: 0.1,
29
- roughness: 0.8,
30
-
31
- alphaTest: 0.2,
32
- transparencyMode: MaterialTransparencyMode.MTM_ALPHA_TEST
33
- }
34
- }
35
- })
36
-
37
- Material.create(createSphere(11, 1, 15), {
38
- material: {
39
- $case: 'pbr',
40
- pbr: {
41
- albedoColor: { r: 0, g: 0, b: 1, a: 1 },
42
- reflectivityColor: { r: 0.5, g: 0.5, b: 0.5 },
43
- metallic: 0.1,
44
- roughness: 0.1
45
- }
46
- }
47
- })
48
-
49
- // add textures
50
- export {}
@@ -1,63 +0,0 @@
1
- import { engine, Transform, MeshRenderer, MeshCollider } from '@dcl/sdk/ecs'
2
-
3
- enum Mesh {
4
- BOX,
5
- CYLINDER,
6
- SPHERE,
7
- CONE
8
- }
9
-
10
- function createMesh(x: number, y: number, z: number, mesh: Mesh, withCollider: boolean = false) {
11
- const meshEntity = engine.addEntity()
12
- Transform.create(meshEntity, { position: { x, y, z } })
13
-
14
- switch (mesh) {
15
- case Mesh.BOX:
16
- MeshRenderer.create(meshEntity, {
17
- mesh: { $case: 'box', box: { uvs: [] } }
18
- })
19
- if (withCollider) MeshCollider.create(meshEntity, { mesh: { $case: 'box', box: {} } })
20
- break
21
- case Mesh.SPHERE:
22
- MeshRenderer.create(meshEntity, { mesh: { $case: 'sphere', sphere: {} } })
23
- if (withCollider)
24
- MeshCollider.create(meshEntity, {
25
- mesh: { $case: 'sphere', sphere: {} }
26
- })
27
- break
28
- case Mesh.CONE:
29
- case Mesh.CYLINDER:
30
- MeshRenderer.create(meshEntity, {
31
- mesh: {
32
- $case: 'cylinder',
33
- cylinder: {
34
- radiusBottom: 1,
35
- radiusTop: mesh === Mesh.CONE ? 0 : 1
36
- }
37
- }
38
- })
39
- if (withCollider)
40
- MeshCollider.create(meshEntity, {
41
- mesh: {
42
- $case: 'cylinder',
43
- cylinder: {
44
- radiusBottom: 1,
45
- radiusTop: mesh === Mesh.CONE ? 0 : 1
46
- }
47
- }
48
- })
49
- break
50
- }
51
- return meshEntity
52
- }
53
-
54
- createMesh(15, 1, 15, Mesh.BOX)
55
- createMesh(12, 1, 15, Mesh.CONE)
56
- createMesh(9, 1, 15, Mesh.SPHERE)
57
- createMesh(6, 1, 15, Mesh.CYLINDER)
58
- createMesh(15, 1, 1, Mesh.BOX, true)
59
- createMesh(12, 1, 1, Mesh.CONE, true)
60
- createMesh(9, 1, 1, Mesh.SPHERE, true)
61
- createMesh(6, 1, 1, Mesh.CYLINDER, true)
62
-
63
- export {}
@@ -1,66 +0,0 @@
1
- import {
2
- Entity,
3
- engine,
4
- Transform,
5
- MeshRenderer,
6
- MeshCollider,
7
- InputAction,
8
- PBPointerEvents_Entry,
9
- PointerEvents,
10
- PointerEventType,
11
- InteractionType
12
- } from '@dcl/sdk/ecs'
13
-
14
- // Cube factory
15
- function createCube(x: number, y: number, z: number, pointerEvents: PBPointerEvents_Entry[]): Entity {
16
- const meshEntity = engine.addEntity()
17
- Transform.create(meshEntity, { position: { x, y, z } })
18
- MeshRenderer.create(meshEntity, { mesh: { $case: 'box', box: { uvs: [] } } })
19
- MeshCollider.create(meshEntity, { mesh: { $case: 'box', box: {} } })
20
-
21
- PointerEvents.create(meshEntity, { pointerEvents })
22
-
23
- return meshEntity
24
- }
25
-
26
- createCube(15, 1, 15, [
27
- {
28
- eventType: PointerEventType.PET_DOWN,
29
- eventInfo: {
30
- button: InputAction.IA_PRIMARY,
31
- hoverText: 'PrimaryDown',
32
- maxDistance: 5,
33
- showFeedback: true,
34
- priority: 0
35
- },
36
- interactionType: InteractionType.CURSOR
37
- }
38
- ])
39
-
40
- createCube(13, 1, 15, [
41
- {
42
- eventType: PointerEventType.PET_UP,
43
- eventInfo: {
44
- button: InputAction.IA_SECONDARY,
45
- hoverText: 'Secondary Up',
46
- maxDistance: 5,
47
- showFeedback: true,
48
- priority: 0
49
- },
50
- interactionType: InteractionType.CURSOR
51
- }
52
- ])
53
-
54
- createCube(11, 1, 15, [
55
- {
56
- eventType: PointerEventType.PET_HOVER_ENTER,
57
- eventInfo: {
58
- button: InputAction.IA_ANY,
59
- hoverText: 'Infinity Hover',
60
- maxDistance: 10000000,
61
- showFeedback: true,
62
- priority: 0
63
- },
64
- interactionType: InteractionType.PROXIMITY
65
- }
66
- ])
@@ -1,64 +0,0 @@
1
- import {
2
- engine,
3
- Transform,
4
- MeshRenderer,
5
- MeshCollider,
6
- InputAction,
7
- pointerEventsSystem,
8
- Raycast,
9
- RaycastQueryType,
10
- RaycastResult
11
- } from '@dcl/sdk/ecs'
12
- import { Vector3 } from '@dcl/sdk/math'
13
-
14
- function createCube(x: number, y: number, z: number, scaleMultiplier: number = 1) {
15
- const cubeEntity = engine.addEntity()
16
-
17
- Transform.create(cubeEntity, {
18
- position: { x, y, z },
19
- scale: { x: scaleMultiplier, y: scaleMultiplier, z: scaleMultiplier }
20
- })
21
-
22
- MeshRenderer.create(cubeEntity, { mesh: { $case: 'box', box: { uvs: [] } } })
23
- MeshCollider.create(cubeEntity, { mesh: { $case: 'box', box: {} } })
24
-
25
- return cubeEntity
26
- }
27
-
28
- // Create cube to hit
29
- const cubeEntity = createCube(8, 1, 8)
30
- const _cubeEntity2 = createCube(8, 1, 13)
31
- const raycastEntity = engine.addEntity()
32
-
33
- // Add OnPointerDown component to cube entity to trigger ray casting on interaction
34
- pointerEventsSystem.onPointerDown(
35
- { entity: cubeEntity, opts: { button: InputAction.IA_POINTER, hoverText: 'CAST RAY' } },
36
- () => {
37
- Raycast.createOrReplace(raycastEntity, {
38
- direction: {
39
- $case: 'localDirection',
40
- localDirection: Vector3.Forward()
41
- },
42
- maxDistance: 16,
43
- queryType: RaycastQueryType.RQT_QUERY_ALL
44
- })
45
- }
46
- )
47
-
48
- // System to detect new raycast responses and instantiate a cube where the ray hits
49
- let lastRaycastTimestamp = -1
50
- engine.addSystem(() => {
51
- for (const [_entity, result] of engine.getEntitiesWith(RaycastResult)) {
52
- const timestamp = result.timestamp ?? 0
53
- if (result.hits?.length === 0 || timestamp <= lastRaycastTimestamp) continue
54
- lastRaycastTimestamp = timestamp
55
-
56
- if (result.hits[0] && result.hits[0].position) {
57
- createCube(result.hits[0].position.x, result.hits[0].position.y, result.hits[0].position.z, 0.3)
58
- }
59
-
60
- console.log(`Hits (this should be '2' the first time): '${result.hits.length}'`)
61
- }
62
- })
63
-
64
- export {}
@@ -1,65 +0,0 @@
1
- import {
2
- engine,
3
- Transform,
4
- MeshRenderer,
5
- MeshCollider,
6
- InputAction,
7
- pointerEventsSystem,
8
- Raycast,
9
- RaycastQueryType,
10
- RaycastResult
11
- } from '@dcl/sdk/ecs'
12
- import { Vector3 } from '@dcl/sdk/math'
13
-
14
- function createCube(x: number, y: number, z: number, scaleMultiplier: number = 1) {
15
- const cubeEntity = engine.addEntity()
16
-
17
- Transform.create(cubeEntity, {
18
- position: { x, y, z },
19
- scale: { x: scaleMultiplier, y: scaleMultiplier, z: scaleMultiplier }
20
- })
21
-
22
- MeshRenderer.create(cubeEntity, { mesh: { $case: 'box', box: { uvs: [] } } })
23
- MeshCollider.create(cubeEntity, { mesh: { $case: 'box', box: {} } })
24
-
25
- return cubeEntity
26
- }
27
-
28
- // Create cube to hit
29
- const cubeEntity = createCube(8, 1, 8)
30
- const raycastEntity = engine.addEntity()
31
-
32
- // Add OnPointerDown component to cube entity to trigger ray casting on interaction
33
- pointerEventsSystem.onPointerDown(
34
- { entity: cubeEntity, opts: { button: InputAction.IA_POINTER, hoverText: 'CAST RAY' } },
35
- () => {
36
- Raycast.createOrReplace(raycastEntity, {
37
- continuous: true,
38
- timestamp: 0,
39
- direction: {
40
- $case: 'localDirection',
41
- localDirection: Vector3.Forward()
42
- },
43
- maxDistance: 16,
44
- queryType: RaycastQueryType.RQT_HIT_FIRST
45
- })
46
- }
47
- )
48
-
49
- // System to detect new raycast responses and instantiate a cube where the ray hits
50
- let lastRaycastTimestamp = -1
51
- engine.addSystem(() => {
52
- for (const [_entity, result] of engine.getEntitiesWith(RaycastResult)) {
53
- const timestamp = result.timestamp ?? 0
54
- if (result.hits?.length === 0 || timestamp <= lastRaycastTimestamp) continue
55
- lastRaycastTimestamp = timestamp
56
-
57
- if (result.hits[0] && result.hits[0].position) {
58
- createCube(result.hits[0].position.x, result.hits[0].position.y, result.hits[0].position.z, 0.3)
59
- }
60
-
61
- console.log(`Hits (this should be '1'): '${result.hits.length}'`)
62
- }
63
- })
64
-
65
- export {}
@@ -1,170 +0,0 @@
1
- import { engine } from '@dcl/sdk/ecs'
2
- import { Color4 } from '@dcl/sdk/math'
3
- import ReactEcs, { UiEntity, Label, ReactEcsRenderer, Dropdown } from '@dcl/sdk/react-ecs'
4
-
5
- const src = 'images/rounded_alpha_square.png'
6
- const centeredImage = 'images/ui_beam_up_bg.png'
7
-
8
- let dt = 0
9
- let userId: string | undefined
10
-
11
- engine.addSystem((t) => {
12
- dt += t
13
- })
14
-
15
- let currentValue = 0
16
- const options = [
17
- function StretchAndTint() {
18
- const tint2 = Color4.lerp(Color4.Red(), Color4.Blue(), 1 + Math.sin(dt + Math.cos(dt * 0.3)) * 0.5)
19
- return (
20
- <UiEntity
21
- uiTransform={{
22
- width: `${(1 + Math.sin(dt) * 0.5) * 50}%`,
23
- height: 244
24
- }}
25
- uiBackground={{
26
- color: tint2,
27
- textureMode: 'stretch',
28
- texture: {
29
- src
30
- }
31
- }}
32
- >
33
- <Label value="STRETCH + TINT\n(borders are deformed)" fontSize={29} />
34
- </UiEntity>
35
- )
36
- },
37
- function NineSlicesAndTint() {
38
- const tint = Color4.lerp(Color4.Red(), Color4.Blue(), 1 + Math.sin(dt + Math.cos(dt * 0.3)) * 0.5)
39
- return (
40
- <UiEntity
41
- uiTransform={{
42
- width: `${(1 + Math.sin(dt) * 0.5) * 50}%`,
43
- height: 128
44
- }}
45
- uiBackground={{
46
- color: tint,
47
- textureMode: 'nine-slices',
48
- texture: {
49
- src
50
- }
51
- }}
52
- >
53
- <Label value="NINE_SLICES + TINT" color={Color4.Black()} fontSize={29} />
54
- </UiEntity>
55
- )
56
- },
57
- function NineSlicesAndTint() {
58
- const tint = Color4.lerp(
59
- Color4.fromHexString('#336613ff'),
60
- Color4.fromHexString('#f099f3ff'),
61
- 1 + Math.sin(dt) * 0.5
62
- )
63
-
64
- return (
65
- <UiEntity
66
- uiTransform={{
67
- width: 200,
68
- height: (1 + Math.sin(dt) * 0.5) * 200
69
- }}
70
- uiBackground={{
71
- color: tint,
72
- textureMode: 'nine-slices',
73
- texture: {
74
- src: centeredImage
75
- }
76
- }}
77
- >
78
- <Label value="NINE_SLICES + TINT" color={Color4.Red()} fontSize={29} />
79
- </UiEntity>
80
- )
81
- },
82
- function NineSlicesAndMargin() {
83
- const margin = (1 + Math.cos(dt * 0.3)) * 0.1
84
-
85
- return (
86
- <UiEntity
87
- uiTransform={{
88
- width: 256,
89
- height: 256
90
- }}
91
- uiBackground={{
92
- textureMode: 'nine-slices',
93
- texture: {
94
- src: centeredImage
95
- },
96
- textureSlices: {
97
- top: margin,
98
- bottom: margin,
99
- left: margin,
100
- right: margin
101
- }
102
- }}
103
- >
104
- <Label value={`NINE_SLICES (with margins ${margin.toFixed(2)})`} color={Color4.Red()} fontSize={29} />
105
- </UiEntity>
106
- )
107
- },
108
- function Center() {
109
- return (
110
- <UiEntity
111
- uiTransform={{
112
- width: 250 + Math.cos(dt) * 100,
113
- height: 128 + Math.sin(dt * 0.2) * 64
114
- }}
115
- uiBackground={{
116
- textureMode: 'center',
117
- texture: {
118
- src: centeredImage
119
- }
120
- }}
121
- >
122
- <Label value="CENTER" color={Color4.Green()} fontSize={29} />
123
- </UiEntity>
124
- )
125
- },
126
- function AvatarTexture() {
127
- return (
128
- <UiEntity
129
- uiTransform={{
130
- width: 250 + Math.cos(dt) * 100,
131
- height: 128 + Math.sin(dt * 0.2) * 64
132
- }}
133
- uiBackground={{
134
- textureMode: 'center',
135
- avatarTexture: {
136
- userId: userId ?? ''
137
- }
138
- }}
139
- >
140
- <Label value="CENTER" color={Color4.Green()} fontSize={29} />
141
- </UiEntity>
142
- )
143
- }
144
- ]
145
-
146
- function selectOption(index: number) {
147
- currentValue = index
148
- }
149
-
150
- export const ui = () => {
151
- const Renderer = options[currentValue] || (() => null)
152
-
153
- return (
154
- <UiEntity
155
- uiTransform={{
156
- width: '100%',
157
- height: '50%',
158
- flexDirection: 'column',
159
- margin: { left: 300 }
160
- }}
161
- uiBackground={{ color: Color4.Black() }}
162
- >
163
- <Label value="Select an example from below" />
164
- <Dropdown options={options.map(($) => $.name)} onChange={selectOption} />
165
- <Renderer />
166
- </UiEntity>
167
- )
168
- }
169
-
170
- ReactEcsRenderer.setUiRenderer(ui)
@@ -1,28 +0,0 @@
1
- import { Color4 } from '@dcl/sdk/math'
2
- import ReactEcs, { UiEntity, Label, ReactEcsRenderer, Dropdown } from '@dcl/sdk/react-ecs'
3
-
4
- const colorList = ['Red', 'Green', 'Blue', 'Black', 'White', 'Purple', 'Magenta', 'Yellow', 'Gray', 'Teal', 'Clear']
5
-
6
- let selectedColorIndex = 0
7
-
8
- function selectOption(index: number) {
9
- selectedColorIndex = index
10
- }
11
-
12
- export const ui = () => {
13
- return (
14
- <UiEntity
15
- uiTransform={{
16
- width: '100%',
17
- height: '3000px',
18
- flexDirection: 'column'
19
- }}
20
- uiBackground={{ color: (Color4 as any)[colorList[selectedColorIndex]]() }}
21
- >
22
- <Label value="Select a color" fontSize={29} />
23
- <Dropdown options={colorList} onChange={selectOption} />
24
- </UiEntity>
25
- )
26
- }
27
-
28
- ReactEcsRenderer.setUiRenderer(ui)