@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.
- package/etc/playground-assets.api.md +567 -391
- package/package.json +4 -4
- package/dist/alpha.d.ts +0 -10246
- package/dist/beta.d.ts +0 -10213
- package/dist/index.bundled.d.ts +0 -10213
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -47
- package/dist/playground/sdk/apis.d.ts +0 -1671
- package/dist/playground/sdk/dcl-sdk.package.json +0 -39
- package/dist/playground/snippets/billboard.ts +0 -111
- package/dist/playground/snippets/cube-spawner.ts +0 -38
- package/dist/playground/snippets/info.json +0 -1
- package/dist/playground/snippets/material.ts +0 -50
- package/dist/playground/snippets/mesh.ts +0 -63
- package/dist/playground/snippets/pointer-events.ts +0 -66
- package/dist/playground/snippets/raycast-hit-many.ts +0 -64
- package/dist/playground/snippets/raycast-hit.ts +0 -65
- package/dist/playground/snippets/ui-backgrounds.tsx +0 -170
- package/dist/playground/snippets/ui-dropdown.tsx +0 -28
- package/dist/playground/snippets/ui.tsx +0 -132
- package/dist/playground-assets.d.ts +0 -10246
- package/dist/tsdoc-metadata.json +0 -11
- package/etc/playground-assets.api.json +0 -96462
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import {
|
|
3
|
-
Entity,
|
|
4
|
-
engine,
|
|
5
|
-
Transform,
|
|
6
|
-
MeshRenderer,
|
|
7
|
-
MeshCollider,
|
|
8
|
-
InputAction,
|
|
9
|
-
PointerEvents,
|
|
10
|
-
PointerEventType
|
|
11
|
-
} from '@dcl/sdk/ecs'
|
|
12
|
-
import { Vector3, Color4, Quaternion } from '@dcl/sdk/math'
|
|
13
|
-
import { ReactEcs, UiEntity, Label, ReactEcsRenderer, Button } from '@dcl/sdk/react-ecs'
|
|
14
|
-
|
|
15
|
-
// Cube factory
|
|
16
|
-
function createCube(x: number, y: number, z: number, spawner = true): Entity {
|
|
17
|
-
const meshEntity = engine.addEntity()
|
|
18
|
-
Transform.create(meshEntity, { position: { x, y, z } })
|
|
19
|
-
MeshRenderer.create(meshEntity, { mesh: { $case: 'box', box: { uvs: [] } } })
|
|
20
|
-
MeshCollider.create(meshEntity, { mesh: { $case: 'box', box: {} } })
|
|
21
|
-
if (spawner) {
|
|
22
|
-
PointerEvents.create(meshEntity, {
|
|
23
|
-
pointerEvents: [
|
|
24
|
-
{
|
|
25
|
-
eventType: PointerEventType.PET_DOWN,
|
|
26
|
-
eventInfo: {
|
|
27
|
-
button: InputAction.IA_PRIMARY,
|
|
28
|
-
hoverText: 'Press E to spawn',
|
|
29
|
-
maxDistance: 100,
|
|
30
|
-
showFeedback: true
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
return meshEntity
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Systems
|
|
40
|
-
function circularSystem(dt: number) {
|
|
41
|
-
const entitiesWithMeshRenderer = engine.getEntitiesWith(MeshRenderer, Transform)
|
|
42
|
-
for (const [entity, _meshRenderer, _transform] of entitiesWithMeshRenderer) {
|
|
43
|
-
const mutableTransform = Transform.getMutable(entity)
|
|
44
|
-
|
|
45
|
-
mutableTransform.rotation = Quaternion.multiply(
|
|
46
|
-
mutableTransform.rotation,
|
|
47
|
-
Quaternion.fromAngleAxis(dt * 10, Vector3.Up())
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Init
|
|
53
|
-
createCube(8, 1, 8)
|
|
54
|
-
engine.addSystem(circularSystem)
|
|
55
|
-
|
|
56
|
-
const sceneThumbnail = 'models/Magazinev1.png'
|
|
57
|
-
|
|
58
|
-
const uiComponent = () => (
|
|
59
|
-
<UiEntity
|
|
60
|
-
uiTransform={{
|
|
61
|
-
width: 400,
|
|
62
|
-
height: 230,
|
|
63
|
-
// { top: 16, right: 0, bottom: 8 left: 270 },
|
|
64
|
-
margin: '16px 0 8px 270px',
|
|
65
|
-
// { top: 4, bottom: 4, left: 4, right: 4 },
|
|
66
|
-
padding: 4
|
|
67
|
-
}}
|
|
68
|
-
uiBackground={{ color: Color4.create(0.5, 0.8, 0.1, 0.6) }}
|
|
69
|
-
>
|
|
70
|
-
<UiEntity
|
|
71
|
-
uiTransform={{
|
|
72
|
-
width: '100%',
|
|
73
|
-
height: '100%',
|
|
74
|
-
flexDirection: 'column',
|
|
75
|
-
alignItems: 'center',
|
|
76
|
-
justifyContent: 'space-between'
|
|
77
|
-
}}
|
|
78
|
-
uiBackground={{ color: Color4.fromHexString('#70ac76ff') }}
|
|
79
|
-
>
|
|
80
|
-
<UiEntity
|
|
81
|
-
uiTransform={{
|
|
82
|
-
width: '100%',
|
|
83
|
-
height: 50,
|
|
84
|
-
margin: '8px 0'
|
|
85
|
-
}}
|
|
86
|
-
uiBackground={{
|
|
87
|
-
textureMode: 'center',
|
|
88
|
-
texture: {
|
|
89
|
-
src: sceneThumbnail
|
|
90
|
-
}
|
|
91
|
-
}}
|
|
92
|
-
uiText={{ value: 'SDK7', fontSize: 18 }}
|
|
93
|
-
/>
|
|
94
|
-
<Label
|
|
95
|
-
onMouseDown={() => {
|
|
96
|
-
console.log('Player Position clicked !')
|
|
97
|
-
}}
|
|
98
|
-
value={`Player: ${getPlayerPosition()}`}
|
|
99
|
-
fontSize={18}
|
|
100
|
-
uiTransform={{ width: '100%', height: 30 }}
|
|
101
|
-
/>
|
|
102
|
-
<Label
|
|
103
|
-
onMouseDown={() => {
|
|
104
|
-
console.log('# Cubes clicked !')
|
|
105
|
-
}}
|
|
106
|
-
value={`# Cubes: ${[...engine.getEntitiesWith(MeshRenderer)].length}`}
|
|
107
|
-
fontSize={18}
|
|
108
|
-
uiTransform={{ width: '100%', height: 30 }}
|
|
109
|
-
/>
|
|
110
|
-
<Button
|
|
111
|
-
uiTransform={{ width: 100, height: 40, margin: 8 }}
|
|
112
|
-
value="Spawn cube"
|
|
113
|
-
variant="primary"
|
|
114
|
-
fontSize={14}
|
|
115
|
-
onMouseDown={() => {
|
|
116
|
-
createCube(1 + Math.random() * 8, Math.random() * 8, 1 + Math.random() * 8, false)
|
|
117
|
-
}}
|
|
118
|
-
/>
|
|
119
|
-
</UiEntity>
|
|
120
|
-
</UiEntity>
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
function getPlayerPosition() {
|
|
124
|
-
const playerPosition = Transform.getOrNull(engine.PlayerEntity)
|
|
125
|
-
if (!playerPosition) return ' no data yet'
|
|
126
|
-
const { x, y, z } = playerPosition.position
|
|
127
|
-
return `{X: ${x.toFixed(2)}, Y: ${y.toFixed(2)}, z: ${z.toFixed(2)} }`
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
ReactEcsRenderer.setUiRenderer(uiComponent)
|
|
131
|
-
|
|
132
|
-
export {}
|