@dcl/sdk 7.0.0-3548419522.commit-ddcf4b7 → 7.0.0
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/ecs.d.ts +1 -0
- package/ecs.js +2 -0
- package/index.d.ts +1 -0
- package/index.js +11 -0
- package/internal/Observable.d.ts +36 -0
- package/internal/Observable.js +190 -0
- package/internal/transports/networkTransport.d.ts +2 -0
- package/internal/transports/networkTransport.js +16 -0
- package/internal/transports/rendererTransport.d.ts +7 -0
- package/internal/transports/rendererTransport.js +39 -0
- package/math.d.ts +3 -0
- package/math.js +4 -0
- package/messageBus.d.ts +10 -0
- package/messageBus.js +43 -0
- package/observables.d.ts +225 -0
- package/observables.js +75 -0
- package/package.json +12 -18
- package/react-ecs.d.ts +3 -0
- package/react-ecs.js +4 -0
- package/src/ecs.ts +1 -0
- package/src/index.ts +18 -0
- package/src/internal/Observable.ts +425 -0
- package/src/internal/transports/networkTransport.ts +24 -0
- package/src/internal/transports/rendererTransport.ts +60 -0
- package/src/math.ts +3 -0
- package/src/messageBus.ts +62 -0
- package/src/observables.ts +579 -0
- package/src/react-ecs.ts +3 -0
- package/tsconfig.json +11 -0
- package/types/tsconfig.ecs7.json +3 -8
- package/dist/ecs7/index.d.ts +0 -4679
- package/dist/ecs7/index.js +0 -15202
- package/dist/ecs7/index.min.js +0 -1
- package/dist/ecs7/index.min.js.map +0 -1
- package/dist/ecs7/proto-definitions/README.md +0 -32
- package/dist/ecs7/proto-definitions/Transform.md +0 -25
- package/dist/ecs7/proto-definitions/animator.proto +0 -19
- package/dist/ecs7/proto-definitions/audio_source.proto +0 -13
- package/dist/ecs7/proto-definitions/audio_stream.proto +0 -11
- package/dist/ecs7/proto-definitions/avatar_attach.proto +0 -19
- package/dist/ecs7/proto-definitions/avatar_modifier_area.proto +0 -19
- package/dist/ecs7/proto-definitions/avatar_shape.proto +0 -32
- package/dist/ecs7/proto-definitions/billboard.proto +0 -17
- package/dist/ecs7/proto-definitions/camera_mode.proto +0 -10
- package/dist/ecs7/proto-definitions/camera_mode_area.proto +0 -14
- package/dist/ecs7/proto-definitions/common/camera_type.proto +0 -8
- package/dist/ecs7/proto-definitions/common/id.md +0 -2
- package/dist/ecs7/proto-definitions/common/id.proto +0 -8
- package/dist/ecs7/proto-definitions/common/input_action.proto +0 -20
- package/dist/ecs7/proto-definitions/common/texts.proto +0 -20
- package/dist/ecs7/proto-definitions/gltf_container.proto +0 -13
- package/dist/ecs7/proto-definitions/material.proto +0 -56
- package/dist/ecs7/proto-definitions/mesh_collider.proto +0 -35
- package/dist/ecs7/proto-definitions/mesh_renderer.proto +0 -30
- package/dist/ecs7/proto-definitions/nft_shape.proto +0 -40
- package/dist/ecs7/proto-definitions/pointer_events_result.proto +0 -25
- package/dist/ecs7/proto-definitions/pointer_hover_feedback.proto +0 -31
- package/dist/ecs7/proto-definitions/pointer_lock.proto +0 -9
- package/dist/ecs7/proto-definitions/raycast.proto +0 -20
- package/dist/ecs7/proto-definitions/raycast_result.proto +0 -25
- package/dist/ecs7/proto-definitions/text_shape.proto +0 -33
- package/dist/ecs7/proto-definitions/ui_background.proto +0 -11
- package/dist/ecs7/proto-definitions/ui_text.proto +0 -17
- package/dist/ecs7/proto-definitions/ui_transform.proto +0 -141
- package/dist/ecs7/proto-definitions/visibility_component.proto +0 -9
- package/dist/playground/snippets/billboard.ts +0 -108
- package/dist/playground/snippets/cube-spawner.ts +0 -39
- package/dist/playground/snippets/info.json +0 -1
- package/dist/playground/snippets/material.ts +0 -48
- package/dist/playground/snippets/mesh.ts +0 -68
- package/dist/playground/snippets/pointer-events.ts +0 -50
- package/dist/playground/snippets/raycast-hit-many.ts +0 -63
- package/dist/playground/snippets/raycast-hit.ts +0 -62
- package/dist/playground/snippets/ui.tsx +0 -134
- package/types/ecs7/index.d.ts +0 -4679
@@ -0,0 +1,579 @@
|
|
1
|
+
import { Observable } from './internal/Observable'
|
2
|
+
import { QuaternionType, Vector3Type } from '@dcl/ecs'
|
3
|
+
import { ManyEntityAction, SendBatchResponse } from '~system/EngineApi'
|
4
|
+
|
5
|
+
let subscribeFunction: (event: {
|
6
|
+
eventId: string
|
7
|
+
}) => Promise<any> = async () => {}
|
8
|
+
|
9
|
+
/** @public */
|
10
|
+
export type InputEventResult = {
|
11
|
+
/** Origin of the ray, relative to the scene */
|
12
|
+
origin: Vector3Type
|
13
|
+
/** Direction vector of the ray (normalized) */
|
14
|
+
direction: Vector3Type
|
15
|
+
/** ID of the pointer that triggered the event */
|
16
|
+
buttonId: number
|
17
|
+
/** Does this pointer event hit any object? */
|
18
|
+
hit?: {
|
19
|
+
/** Length of the ray */
|
20
|
+
length: number
|
21
|
+
/** If the ray hits a mesh the intersection point will be this */
|
22
|
+
hitPoint: Vector3Type
|
23
|
+
/** If the mesh has a name, it will be assigned to meshName */
|
24
|
+
meshName: string
|
25
|
+
/** Normal of the hit */
|
26
|
+
normal: Vector3Type
|
27
|
+
/** Normal of the hit, in world space */
|
28
|
+
worldNormal: Vector3Type
|
29
|
+
/** Hit entity ID if any */
|
30
|
+
entityId: unknown
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
/** @public */
|
35
|
+
export type GlobalInputEventResult = InputEventResult & {
|
36
|
+
/**
|
37
|
+
* DOWN = 0,
|
38
|
+
* UP = 1
|
39
|
+
*/
|
40
|
+
type: 0 | 1
|
41
|
+
}
|
42
|
+
|
43
|
+
/** @public */
|
44
|
+
export type RaycastResponsePayload<T> = {
|
45
|
+
queryId: string
|
46
|
+
queryType: string
|
47
|
+
payload: T
|
48
|
+
}
|
49
|
+
|
50
|
+
/** @public */
|
51
|
+
export type GizmoDragEndEvent = {
|
52
|
+
type: 'gizmoDragEnded'
|
53
|
+
transforms: Array<{
|
54
|
+
position: Vector3Type
|
55
|
+
rotation: QuaternionType
|
56
|
+
scale: Vector3Type
|
57
|
+
entityId: unknown
|
58
|
+
}>
|
59
|
+
}
|
60
|
+
|
61
|
+
/** @public */
|
62
|
+
export type GizmoSelectedEvent = {
|
63
|
+
type: 'gizmoSelected'
|
64
|
+
gizmoType: 'MOVE' | 'ROTATE' | 'SCALE' | 'NONE'
|
65
|
+
entities: string[]
|
66
|
+
}
|
67
|
+
|
68
|
+
/// --- EVENTS ---
|
69
|
+
|
70
|
+
/** @public */
|
71
|
+
export type IEventNames = keyof IEvents
|
72
|
+
|
73
|
+
/** @public */
|
74
|
+
export type EngineEvent<T extends IEventNames = IEventNames, V = IEvents[T]> = {
|
75
|
+
/** eventName */
|
76
|
+
type: T
|
77
|
+
data: Readonly<V>
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* @public
|
82
|
+
* Note: Don't use `on` prefix for IEvents to avoid redundancy with `event.on("onEventName")` syntax.
|
83
|
+
*/
|
84
|
+
export interface IEvents {
|
85
|
+
/**
|
86
|
+
* `positionChanged` is triggered when the position of the camera changes
|
87
|
+
* This event is throttled to 10 times per second.
|
88
|
+
*/
|
89
|
+
positionChanged: {
|
90
|
+
/** Camera position relative to the base parcel of the scene */
|
91
|
+
position: Vector3Type
|
92
|
+
|
93
|
+
/** Camera position, this is a absolute world position */
|
94
|
+
cameraPosition: Vector3Type
|
95
|
+
|
96
|
+
/** Eye height, in meters. */
|
97
|
+
playerHeight: number
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* `rotationChanged` is triggered when the rotation of the camera changes.
|
102
|
+
* This event is throttled to 10 times per second.
|
103
|
+
*/
|
104
|
+
rotationChanged: {
|
105
|
+
/** Degree vector. Same as entities */
|
106
|
+
rotation: Vector3Type
|
107
|
+
/** Rotation quaternion, useful in some scenarios. */
|
108
|
+
quaternion: QuaternionType
|
109
|
+
}
|
110
|
+
|
111
|
+
/**
|
112
|
+
* `cameraModeChanged` is triggered when the user changes the camera mode
|
113
|
+
*/
|
114
|
+
cameraModeChanged: {
|
115
|
+
/**
|
116
|
+
* FIRST_PERSON = 0,
|
117
|
+
* THIRD_PERSON = 1,
|
118
|
+
* FREE_CAMERA = 2
|
119
|
+
*/
|
120
|
+
cameraMode: 0 | 1 | 2
|
121
|
+
}
|
122
|
+
|
123
|
+
/**
|
124
|
+
* `idleStateChanged` is triggered when the user not moves for a defined period of time
|
125
|
+
*/
|
126
|
+
idleStateChanged: {
|
127
|
+
isIdle: boolean
|
128
|
+
}
|
129
|
+
|
130
|
+
playerExpression: {
|
131
|
+
expressionId: string
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
* `pointerUp` is triggered when the user releases an input pointer.
|
136
|
+
* It could be a VR controller, a touch screen or the mouse.
|
137
|
+
*/
|
138
|
+
pointerUp: InputEventResult
|
139
|
+
|
140
|
+
/**
|
141
|
+
* `pointerDown` is triggered when the user press an input pointer.
|
142
|
+
* It could be a VR controller, a touch screen or the mouse.
|
143
|
+
*/
|
144
|
+
pointerDown: InputEventResult
|
145
|
+
|
146
|
+
/**
|
147
|
+
* `pointerEvent` is triggered when the user press or releases an input pointer.
|
148
|
+
* It could be a VR controller, a touch screen or the mouse.
|
149
|
+
*
|
150
|
+
* @deprecated use actionButtonEvent instead
|
151
|
+
*/
|
152
|
+
pointerEvent: GlobalInputEventResult
|
153
|
+
|
154
|
+
/**
|
155
|
+
* `actionButtonEvent` is triggered when the user press or releases an input pointer.
|
156
|
+
* It could be a VR controller, a touch screen or the mouse.
|
157
|
+
*
|
158
|
+
* This event is exactly the same as `pointerEvent` but the logic in the ECS had an unsolvable
|
159
|
+
* condition that required us to create this new event to handle more cases for new buttons.
|
160
|
+
*/
|
161
|
+
actionButtonEvent: GlobalInputEventResult
|
162
|
+
|
163
|
+
/**
|
164
|
+
* `raycastResponse` is triggered in response to a raycast query
|
165
|
+
*/
|
166
|
+
raycastResponse: RaycastResponsePayload<any>
|
167
|
+
|
168
|
+
/**
|
169
|
+
* `chatMessage` is triggered when the user sends a message through chat entity.
|
170
|
+
*/
|
171
|
+
chatMessage: {
|
172
|
+
id: string
|
173
|
+
sender: string
|
174
|
+
message: string
|
175
|
+
isCommand: boolean
|
176
|
+
}
|
177
|
+
|
178
|
+
/**
|
179
|
+
* `onChange` is triggered when an entity changes its own internal state.
|
180
|
+
* Dispatched by the `ui-*` entities when their value is changed. It triggers a callback.
|
181
|
+
* Notice: Only entities with ID will be listening for click events.
|
182
|
+
*/
|
183
|
+
onChange: {
|
184
|
+
value?: any
|
185
|
+
/** ID of the pointer that triggered the event */
|
186
|
+
pointerId?: number
|
187
|
+
}
|
188
|
+
|
189
|
+
/**
|
190
|
+
* `onEnter` is triggered when the user hits the "Enter" key from the keyboard
|
191
|
+
* Used principally by the Chat internal scene
|
192
|
+
*/
|
193
|
+
onEnter: unknown
|
194
|
+
|
195
|
+
/**
|
196
|
+
* `onPointerLock` is triggered when the user clicks the world canvas and the
|
197
|
+
* pointer locks to it so the pointer moves the camera
|
198
|
+
*/
|
199
|
+
onPointerLock: {
|
200
|
+
locked?: boolean
|
201
|
+
}
|
202
|
+
|
203
|
+
/**
|
204
|
+
* `onAnimationEnd` is triggered when an animation clip gets finish
|
205
|
+
*/
|
206
|
+
onAnimationEnd: {
|
207
|
+
clipName: string
|
208
|
+
}
|
209
|
+
|
210
|
+
/**
|
211
|
+
* `onFocus` is triggered when an entity focus is active.
|
212
|
+
* Dispatched by the `ui-input` and `ui-password` entities when the value is changed.
|
213
|
+
* It triggers a callback.
|
214
|
+
*
|
215
|
+
* Notice: Only entities with ID will be listening for click events.
|
216
|
+
*/
|
217
|
+
onFocus: {
|
218
|
+
/** ID of the entitiy of the event */
|
219
|
+
entityId: unknown
|
220
|
+
/** ID of the pointer that triggered the event */
|
221
|
+
pointerId: number
|
222
|
+
}
|
223
|
+
|
224
|
+
/**
|
225
|
+
* `onBlur` is triggered when an entity loses its focus.
|
226
|
+
* Dispatched by the `ui-input` and `ui-password` entities when the value is changed.
|
227
|
+
* It triggers a callback.
|
228
|
+
*
|
229
|
+
* Notice: Only entities with ID will be listening for click events.
|
230
|
+
*/
|
231
|
+
onBlur: {
|
232
|
+
/** ID of the entitiy of the event */
|
233
|
+
entityId: unknown
|
234
|
+
/** ID of the pointer that triggered the event */
|
235
|
+
pointerId: number
|
236
|
+
}
|
237
|
+
|
238
|
+
/** The onClick event is only used for UI elements */
|
239
|
+
onClick: {
|
240
|
+
entityId: unknown
|
241
|
+
}
|
242
|
+
|
243
|
+
/**
|
244
|
+
* This event gets triggered when an entity leaves the scene fences.
|
245
|
+
*/
|
246
|
+
entityOutOfScene: {
|
247
|
+
entityId: unknown
|
248
|
+
}
|
249
|
+
|
250
|
+
/**
|
251
|
+
* This event gets triggered when an entity enters the scene fences.
|
252
|
+
*/
|
253
|
+
entityBackInScene: {
|
254
|
+
entityId: unknown
|
255
|
+
}
|
256
|
+
|
257
|
+
/**
|
258
|
+
* This event gets triggered when the user enters the scene
|
259
|
+
*/
|
260
|
+
onEnterScene: {
|
261
|
+
userId: string
|
262
|
+
}
|
263
|
+
|
264
|
+
/**
|
265
|
+
* This event gets triggered when the user leaves the scene
|
266
|
+
*/
|
267
|
+
onLeaveScene: {
|
268
|
+
userId: string
|
269
|
+
}
|
270
|
+
|
271
|
+
/**
|
272
|
+
* This event gets triggered after receiving a comms message.
|
273
|
+
*/
|
274
|
+
comms: {
|
275
|
+
sender: string
|
276
|
+
message: string
|
277
|
+
}
|
278
|
+
|
279
|
+
/**
|
280
|
+
* This is triggered once the scene should start.
|
281
|
+
*/
|
282
|
+
sceneStart: unknown
|
283
|
+
|
284
|
+
/**
|
285
|
+
* This is triggered once the builder scene is loaded.
|
286
|
+
*/
|
287
|
+
builderSceneStart: unknown
|
288
|
+
|
289
|
+
/**
|
290
|
+
* This is triggered once the builder scene is unloaded.
|
291
|
+
*/
|
292
|
+
builderSceneUnloaded: unknown
|
293
|
+
|
294
|
+
/**
|
295
|
+
* After checking entities outside the fences, if any is outside, this event
|
296
|
+
* will be triggered with all the entities outside the scene.
|
297
|
+
*/
|
298
|
+
entitiesOutOfBoundaries: {
|
299
|
+
entities: string[]
|
300
|
+
}
|
301
|
+
|
302
|
+
uuidEvent: {
|
303
|
+
uuid: string
|
304
|
+
payload: any
|
305
|
+
}
|
306
|
+
|
307
|
+
onTextSubmit: {
|
308
|
+
text: string
|
309
|
+
}
|
310
|
+
|
311
|
+
metricsUpdate: {
|
312
|
+
given: Record<string, number>
|
313
|
+
limit: Record<string, number>
|
314
|
+
}
|
315
|
+
|
316
|
+
limitsExceeded: {
|
317
|
+
given: Record<string, number>
|
318
|
+
limit: Record<string, number>
|
319
|
+
}
|
320
|
+
|
321
|
+
/** For gizmos */
|
322
|
+
gizmoEvent: GizmoDragEndEvent | GizmoSelectedEvent
|
323
|
+
|
324
|
+
externalAction: {
|
325
|
+
type: string
|
326
|
+
[key: string]: any
|
327
|
+
}
|
328
|
+
|
329
|
+
stateEvent: {
|
330
|
+
type: string
|
331
|
+
payload: any
|
332
|
+
}
|
333
|
+
|
334
|
+
/** This is triggered at least for each videoStatus change */
|
335
|
+
videoEvent: {
|
336
|
+
componentId: string
|
337
|
+
videoClipId: string
|
338
|
+
/** Status, can be NONE = 0, ERROR = 1, LOADING = 2, READY = 3, PLAYING = 4,BUFFERING = 5 */
|
339
|
+
videoStatus: number
|
340
|
+
/** Current offset position in seconds */
|
341
|
+
currentOffset: number
|
342
|
+
/** Video length in seconds. Can be -1 */
|
343
|
+
totalVideoLength: number
|
344
|
+
}
|
345
|
+
|
346
|
+
/** This is trigger everytime a profile is changed */
|
347
|
+
profileChanged: {
|
348
|
+
ethAddress: string
|
349
|
+
version: number
|
350
|
+
}
|
351
|
+
|
352
|
+
/** Triggered when peer's avatar is connected and visible */
|
353
|
+
playerConnected: {
|
354
|
+
userId: string
|
355
|
+
}
|
356
|
+
|
357
|
+
/** Triggered when peer disconnect and/or it avatar is set invisible by comms */
|
358
|
+
playerDisconnected: {
|
359
|
+
userId: string
|
360
|
+
}
|
361
|
+
|
362
|
+
/** Triggered when current realm or island changes */
|
363
|
+
onRealmChanged: {
|
364
|
+
domain: string
|
365
|
+
room: string
|
366
|
+
serverName: string
|
367
|
+
displayName: string
|
368
|
+
}
|
369
|
+
|
370
|
+
/** Triggered when other player's avatar is clicked */
|
371
|
+
playerClicked: {
|
372
|
+
userId: string
|
373
|
+
ray: {
|
374
|
+
origin: Vector3Type
|
375
|
+
direction: Vector3Type
|
376
|
+
distance: number
|
377
|
+
}
|
378
|
+
}
|
379
|
+
|
380
|
+
/** Triggered when pointer start hovering an entities' shape */
|
381
|
+
pointerHoverEnter: unknown
|
382
|
+
|
383
|
+
/** Triggered when pointer stop hovering an entities' shape */
|
384
|
+
pointerHoverExit: unknown
|
385
|
+
}
|
386
|
+
|
387
|
+
/**
|
388
|
+
* @internal
|
389
|
+
* This function generates a callback that is passed to the Observable
|
390
|
+
* constructor to subscribe to the events of the DecentralandInterface
|
391
|
+
*/
|
392
|
+
function createSubscriber(eventName: string) {
|
393
|
+
return () => {
|
394
|
+
subscribeFunction({ eventId: eventName }).catch(console.error)
|
395
|
+
}
|
396
|
+
}
|
397
|
+
|
398
|
+
/**
|
399
|
+
* These events are triggered after your character enters the scene.
|
400
|
+
* @public
|
401
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
402
|
+
*/
|
403
|
+
export const onEnterSceneObservable = new Observable<IEvents['onEnterScene']>(
|
404
|
+
createSubscriber('onEnterScene')
|
405
|
+
)
|
406
|
+
|
407
|
+
/** @public
|
408
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
409
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed. Use onEnterSceneObservable instead. */
|
410
|
+
export const onEnterScene = onEnterSceneObservable
|
411
|
+
|
412
|
+
/**
|
413
|
+
* These events are triggered after your character leaves the scene.
|
414
|
+
* @public
|
415
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
416
|
+
*/
|
417
|
+
export const onLeaveSceneObservable = new Observable<IEvents['onLeaveScene']>(
|
418
|
+
createSubscriber('onLeaveScene')
|
419
|
+
)
|
420
|
+
|
421
|
+
/** @public
|
422
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
423
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed. Use onLeaveSceneObservable instead. */
|
424
|
+
export const onLeaveScene = onLeaveSceneObservable
|
425
|
+
|
426
|
+
/**
|
427
|
+
* This event is triggered after all the resources of the scene were loaded (models, textures, etc...)
|
428
|
+
* @public
|
429
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
430
|
+
*/
|
431
|
+
export const onSceneReadyObservable = new Observable<IEvents['sceneStart']>(
|
432
|
+
createSubscriber('sceneStart')
|
433
|
+
)
|
434
|
+
|
435
|
+
/**
|
436
|
+
* @public
|
437
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
438
|
+
*/
|
439
|
+
export const onPlayerExpressionObservable = new Observable<
|
440
|
+
IEvents['playerExpression']
|
441
|
+
>(createSubscriber('playerExpression'))
|
442
|
+
|
443
|
+
/**
|
444
|
+
* @public
|
445
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
446
|
+
*/
|
447
|
+
export const onVideoEvent = new Observable<IEvents['videoEvent']>(
|
448
|
+
createSubscriber('videoEvent')
|
449
|
+
)
|
450
|
+
|
451
|
+
/**
|
452
|
+
* @public
|
453
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
454
|
+
*/
|
455
|
+
export const onProfileChanged = new Observable<IEvents['profileChanged']>(
|
456
|
+
createSubscriber('profileChanged')
|
457
|
+
)
|
458
|
+
|
459
|
+
/**
|
460
|
+
* @public
|
461
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
462
|
+
*/
|
463
|
+
export const onPlayerConnectedObservable = new Observable<
|
464
|
+
IEvents['playerConnected']
|
465
|
+
>(createSubscriber('playerConnected'))
|
466
|
+
|
467
|
+
/**
|
468
|
+
* @public
|
469
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
470
|
+
*/
|
471
|
+
export const onPlayerDisconnectedObservable = new Observable<
|
472
|
+
IEvents['playerDisconnected']
|
473
|
+
>(createSubscriber('playerDisconnected'))
|
474
|
+
|
475
|
+
/**
|
476
|
+
* @public
|
477
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
478
|
+
*/
|
479
|
+
export const onRealmChangedObservable = new Observable<
|
480
|
+
IEvents['onRealmChanged']
|
481
|
+
>(createSubscriber('onRealmChanged'))
|
482
|
+
|
483
|
+
/**
|
484
|
+
* @public
|
485
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
486
|
+
*/
|
487
|
+
export const onPlayerClickedObservable = new Observable<
|
488
|
+
IEvents['playerClicked']
|
489
|
+
>(createSubscriber('playerClicked'))
|
490
|
+
|
491
|
+
/**
|
492
|
+
* @interternal
|
493
|
+
* @deprecated This function is an inheritance of ECS6, it's here temporary for the feature parity, please read the news and docs to know how handle when it's removed.
|
494
|
+
*/
|
495
|
+
export const onCommsMessage = new Observable<IEvents['comms']>(
|
496
|
+
createSubscriber('comms')
|
497
|
+
)
|
498
|
+
|
499
|
+
/**
|
500
|
+
* @internal
|
501
|
+
*/
|
502
|
+
export function setSubscribeFunction(
|
503
|
+
fn: (event: { eventId: string }) => Promise<any>
|
504
|
+
) {
|
505
|
+
subscribeFunction = fn
|
506
|
+
}
|
507
|
+
|
508
|
+
/**
|
509
|
+
* @internal
|
510
|
+
* @deprecated this is an OLD API.
|
511
|
+
* This function uses the SDK6 sendBatch to poll events from the renderer
|
512
|
+
*/
|
513
|
+
export async function pollEvents(
|
514
|
+
sendBatch: (body: ManyEntityAction) => Promise<SendBatchResponse>
|
515
|
+
) {
|
516
|
+
const { events } = await sendBatch({ actions: [] })
|
517
|
+
for (const e of events) {
|
518
|
+
if (e.generic) {
|
519
|
+
const data = JSON.parse(e.generic.eventData)
|
520
|
+
switch (e.generic.eventId) {
|
521
|
+
case 'onEnterScene': {
|
522
|
+
onEnterSceneObservable.notifyObservers(
|
523
|
+
data as IEvents['onEnterScene']
|
524
|
+
)
|
525
|
+
break
|
526
|
+
}
|
527
|
+
case 'onLeaveScene': {
|
528
|
+
onLeaveSceneObservable.notifyObservers(
|
529
|
+
data as IEvents['onLeaveScene']
|
530
|
+
)
|
531
|
+
break
|
532
|
+
}
|
533
|
+
case 'sceneStart': {
|
534
|
+
onSceneReadyObservable.notifyObservers(data as IEvents['sceneStart'])
|
535
|
+
break
|
536
|
+
}
|
537
|
+
case 'playerExpression': {
|
538
|
+
onPlayerExpressionObservable.notifyObservers(
|
539
|
+
data as IEvents['playerExpression']
|
540
|
+
)
|
541
|
+
break
|
542
|
+
}
|
543
|
+
case 'videoEvent': {
|
544
|
+
const videoData = data as IEvents['videoEvent']
|
545
|
+
onVideoEvent.notifyObservers(videoData)
|
546
|
+
break
|
547
|
+
}
|
548
|
+
case 'profileChanged': {
|
549
|
+
onProfileChanged.notifyObservers(data as IEvents['profileChanged'])
|
550
|
+
break
|
551
|
+
}
|
552
|
+
case 'playerConnected': {
|
553
|
+
onPlayerConnectedObservable.notifyObservers(
|
554
|
+
data as IEvents['playerConnected']
|
555
|
+
)
|
556
|
+
break
|
557
|
+
}
|
558
|
+
case 'playerDisconnected': {
|
559
|
+
onPlayerDisconnectedObservable.notifyObservers(
|
560
|
+
data as IEvents['playerDisconnected']
|
561
|
+
)
|
562
|
+
break
|
563
|
+
}
|
564
|
+
case 'onRealmChanged': {
|
565
|
+
onRealmChangedObservable.notifyObservers(
|
566
|
+
data as IEvents['onRealmChanged']
|
567
|
+
)
|
568
|
+
break
|
569
|
+
}
|
570
|
+
case 'playerClicked': {
|
571
|
+
onPlayerClickedObservable.notifyObservers(
|
572
|
+
data as IEvents['playerClicked']
|
573
|
+
)
|
574
|
+
break
|
575
|
+
}
|
576
|
+
}
|
577
|
+
}
|
578
|
+
}
|
579
|
+
}
|
package/src/react-ecs.ts
ADDED
package/tsconfig.json
ADDED
package/types/tsconfig.ecs7.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
3
|
"target": "es2020",
|
4
|
-
"module": "
|
5
|
-
"moduleResolution": "
|
4
|
+
"module": "esnext",
|
5
|
+
"moduleResolution": "node",
|
6
6
|
"pretty": true,
|
7
7
|
"forceConsistentCasingInFileNames": true,
|
8
8
|
"allowSyntheticDefaultImports": true,
|
@@ -23,11 +23,6 @@
|
|
23
23
|
],
|
24
24
|
"types": [
|
25
25
|
"@dcl/js-runtime",
|
26
|
-
"ecs7"
|
27
|
-
],
|
28
|
-
"typeRoots": [
|
29
|
-
"./../node_modules",
|
30
|
-
"."
|
31
26
|
]
|
32
27
|
}
|
33
|
-
}
|
28
|
+
}
|