@dcl/sdk 7.0.0-2805922413.commit-7f80d4a → 7.0.0-2884920754.commit-e7fba73
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/dist/ecs7/index.d.ts +546 -190
- package/dist/ecs7/index.js +3538 -3450
- package/dist/ecs7/index.min.js +1 -1
- package/dist/ecs7/index.min.js.map +1 -1
- package/dist/ecs7/proto-definitions/Animator.proto +5 -5
- package/dist/ecs7/proto-definitions/AudioSource.proto +4 -4
- package/dist/ecs7/proto-definitions/AudioStream.proto +2 -2
- package/dist/ecs7/proto-definitions/AvatarShape.proto +10 -10
- package/dist/ecs7/proto-definitions/Billboard.proto +3 -3
- package/dist/ecs7/proto-definitions/BoxShape.proto +6 -3
- package/dist/ecs7/proto-definitions/CylinderShape.proto +8 -5
- package/dist/ecs7/proto-definitions/GLTFShape.proto +6 -3
- package/dist/ecs7/proto-definitions/NFTShape.proto +9 -6
- package/dist/ecs7/proto-definitions/OnPointerDown.proto +4 -4
- package/dist/ecs7/proto-definitions/OnPointerUp.proto +4 -4
- package/dist/ecs7/proto-definitions/PlaneShape.proto +6 -3
- package/dist/ecs7/proto-definitions/SphereShape.proto +6 -3
- package/dist/ecs7/proto-definitions/TextShape.proto +24 -23
- package/package.json +4 -4
- package/types/ecs7/index.d.ts +543 -187
package/dist/ecs7/index.d.ts
CHANGED
@@ -16,10 +16,11 @@ declare const enum ActionButton {
|
|
16
16
|
UNRECOGNIZED = -1
|
17
17
|
}
|
18
18
|
|
19
|
-
/**
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
/** @public */
|
20
|
+
export declare const Animator: ComponentDefinition<ISchema<PBAnimator>>;
|
21
|
+
|
22
|
+
/** @public */
|
23
|
+
export declare const AudioSource: ComponentDefinition<ISchema<PBAudioSource>>;
|
23
24
|
|
24
25
|
declare const enum AvatarAnchorPoint {
|
25
26
|
POSITION = 0,
|
@@ -29,11 +30,29 @@ declare const enum AvatarAnchorPoint {
|
|
29
30
|
UNRECOGNIZED = -1
|
30
31
|
}
|
31
32
|
|
33
|
+
/** @public */
|
34
|
+
export declare const AvatarAttach: ComponentDefinition<ISchema<PBAvatarAttach>>;
|
35
|
+
|
36
|
+
/** @public */
|
37
|
+
export declare const AvatarShape: ComponentDefinition<ISchema<PBAvatarShape>>;
|
38
|
+
|
39
|
+
/** @public */
|
40
|
+
export declare const Billboard: ComponentDefinition<ISchema<PBBillboard>>;
|
41
|
+
|
42
|
+
/** @public */
|
43
|
+
export declare const BoxShape: ComponentDefinition<ISchema<PBBoxShape>>;
|
44
|
+
|
32
45
|
/**
|
33
46
|
* @public
|
34
47
|
*/
|
35
48
|
export declare type ByteBuffer = ReturnType<typeof createByteBuffer>;
|
36
49
|
|
50
|
+
/** @public */
|
51
|
+
export declare const CameraMode: ComponentDefinition<ISchema<PBCameraMode>>;
|
52
|
+
|
53
|
+
/** @public */
|
54
|
+
export declare const CameraModeArea: ComponentDefinition<ISchema<PBCameraModeArea>>;
|
55
|
+
|
37
56
|
declare const enum CameraModeValue {
|
38
57
|
FIRST_PERSON = 0,
|
39
58
|
THIRD_PERSON = 1,
|
@@ -49,36 +68,203 @@ declare interface Color3 {
|
|
49
68
|
/**
|
50
69
|
* @public
|
51
70
|
*/
|
52
|
-
export declare type ComponentDefinition<T extends
|
71
|
+
export declare type ComponentDefinition<T extends ISchema = ISchema<any>> = {
|
53
72
|
_id: number;
|
73
|
+
/**
|
74
|
+
* Return the default value of the current component
|
75
|
+
*/
|
76
|
+
default(): DeepReadonly<ComponentType<T>>;
|
77
|
+
/**
|
78
|
+
* Get if the entity has this component
|
79
|
+
* @param entity
|
80
|
+
*
|
81
|
+
* Example:
|
82
|
+
* ```ts
|
83
|
+
* const myEntity = engine.addEntity()
|
84
|
+
* Transform.has(myEntity) // return false
|
85
|
+
* Transform.create(myEntity)
|
86
|
+
* Transform.has(myEntity) // return true
|
87
|
+
* ```
|
88
|
+
*/
|
54
89
|
has(entity: Entity): boolean;
|
55
|
-
|
90
|
+
/**
|
91
|
+
* Get the readonly component of the entity (to mutate it, use getMutable instead), throw an error if the entity doesn't have the component.
|
92
|
+
* @param entity
|
93
|
+
* @return
|
94
|
+
* Example:
|
95
|
+
* ```ts
|
96
|
+
* const myEntity = engine.addEntity()
|
97
|
+
* Transform.create(myEntity)
|
98
|
+
* const transform = Transform.get(myEntity) // return true
|
99
|
+
* log(transform.position.x === 0) // log 'true'
|
100
|
+
*
|
101
|
+
* transform.position.y = 10 // illegal statement, to mutate the component use getMutable
|
102
|
+
* ```
|
103
|
+
*
|
104
|
+
* ```ts
|
105
|
+
* const otherEntity = engine.addEntity()
|
106
|
+
* Transform.get(otherEntity) // throw an error!!
|
107
|
+
* ```
|
108
|
+
*/
|
109
|
+
get(entity: Entity): DeepReadonly<ComponentType<T>>;
|
110
|
+
/**
|
111
|
+
* Get the readonly component of the entity (to mutate it, use getMutable instead), or null if the entity doesn't have the component.
|
112
|
+
* @param entity
|
113
|
+
* @return
|
114
|
+
*
|
115
|
+
* Example:
|
116
|
+
* ```ts
|
117
|
+
* const otherEntity = engine.addEntity()
|
118
|
+
* log(Transform.get(otherEntity) === null) // log 'true'
|
119
|
+
* ```
|
120
|
+
*/
|
56
121
|
getOrNull(entity: Entity): DeepReadonly<ComponentType<T>> | null;
|
122
|
+
/**
|
123
|
+
* Add the current component to an entity, throw an error if the component already exists (use `createOrReplace` instead).
|
124
|
+
* - Internal comment: This method adds the <entity,component> to the list to be reviewed next frame
|
125
|
+
* @param entity
|
126
|
+
* @param val The initial value
|
127
|
+
*
|
128
|
+
* Example:
|
129
|
+
* ```ts
|
130
|
+
* const myEntity = engine.addEntity()
|
131
|
+
* Transform.create(myEntity, { ...Transform.default(), position: {x: 4, y: 0, z: 4} }) // ok!
|
132
|
+
* Transform.create(myEntity) // throw an error, the `Transform` component already exists in `myEntity`
|
133
|
+
* ````
|
134
|
+
*/
|
57
135
|
create(entity: Entity, val?: ComponentType<T>): ComponentType<T>;
|
58
|
-
|
136
|
+
/**
|
137
|
+
* Add the current component to an entity or replace the content if the entity already has the component
|
138
|
+
* - Internal comment: This method adds the <entity,component> to the list to be reviewed next frame
|
139
|
+
* @param entity
|
140
|
+
* @param val The initial or new value
|
141
|
+
*
|
142
|
+
* Example:
|
143
|
+
* ```ts
|
144
|
+
* const myEntity = engine.addEntity()
|
145
|
+
* Transform.create(myEntity) // ok!
|
146
|
+
* Transform.createOrReplace(myEntity, { ...Transform.default(), position: {x: 4, y: 0, z: 4} }) // ok!
|
147
|
+
* ````
|
148
|
+
*/
|
59
149
|
createOrReplace(entity: Entity, val?: ComponentType<T>): ComponentType<T>;
|
150
|
+
/**
|
151
|
+
* Delete the current component to an entity, return null if the entity doesn't have the current component.
|
152
|
+
* - Internal comment: This method adds the <entity,component> to the list to be reviewed next frame
|
153
|
+
* @param entity
|
154
|
+
*
|
155
|
+
* Example:
|
156
|
+
* ```ts
|
157
|
+
* const myEntity = engine.addEntity()
|
158
|
+
* Transform.create(myEntity) // ok!
|
159
|
+
* Transform.deleteFrom(myEntity) // return the component
|
160
|
+
* Transform.deleteFrom(myEntity) // return null
|
161
|
+
* ````
|
162
|
+
*/
|
60
163
|
deleteFrom(entity: Entity): ComponentType<T> | null;
|
61
|
-
|
62
|
-
|
63
|
-
|
164
|
+
/**
|
165
|
+
* Get the mutable component of the entity, throw an error if the entity doesn't have the component.
|
166
|
+
* - Internal comment: This method adds the <entity,component> to the list to be reviewed next frame
|
167
|
+
* @param entity
|
168
|
+
*
|
169
|
+
* Example:
|
170
|
+
* ```ts
|
171
|
+
* const myEntity = engine.addEntity()
|
172
|
+
* Transform.create(myEntity)
|
173
|
+
* Transform.getMutable(myEntity).position = {x: 4, y: 0, z: 4}
|
174
|
+
* ````
|
175
|
+
*/
|
176
|
+
getMutable(entity: Entity): ComponentType<T>;
|
177
|
+
/**
|
178
|
+
* Get the mutable component of the entity, return null if the entity doesn't have the component.
|
179
|
+
* - Internal comment: This method adds the <entity,component> to the list to be reviewed next frame
|
180
|
+
* @param entity
|
181
|
+
*
|
182
|
+
* Example:
|
183
|
+
* ```ts
|
184
|
+
* const transform = Transform.getMutableOrNull(myEntity)
|
185
|
+
* if (transform) {
|
186
|
+
* transform.position = {x: 4, y: 0, z: 4}
|
187
|
+
* }
|
188
|
+
* ````
|
189
|
+
*/
|
190
|
+
getMutableOrNull(entity: Entity): ComponentType<T> | null;
|
64
191
|
writeToByteBuffer(entity: Entity, buffer: ByteBuffer): void;
|
65
|
-
iterator(): Iterable<[Entity, ComponentType<T>]>;
|
66
|
-
dirtyIterator(): Iterable<Entity>;
|
67
|
-
clearDirty(): void;
|
68
|
-
isDirty(entity: Entity): boolean;
|
69
192
|
};
|
70
193
|
|
194
|
+
/** @public */
|
195
|
+
export declare namespace Components {
|
196
|
+
/** @public */
|
197
|
+
const Transform: ComponentDefinition<ISchema< {
|
198
|
+
position: {
|
199
|
+
x: number;
|
200
|
+
y: number;
|
201
|
+
z: number;
|
202
|
+
};
|
203
|
+
rotation: {
|
204
|
+
x: number;
|
205
|
+
y: number;
|
206
|
+
z: number;
|
207
|
+
w: number;
|
208
|
+
};
|
209
|
+
scale: {
|
210
|
+
x: number;
|
211
|
+
y: number;
|
212
|
+
/** @public */
|
213
|
+
z: number;
|
214
|
+
};
|
215
|
+
parent?: Entity | undefined;
|
216
|
+
}>>;
|
217
|
+
/** @public */
|
218
|
+
const Animator: ComponentDefinition<ISchema<PBAnimator>>;
|
219
|
+
/** @public */
|
220
|
+
const AudioSource: ComponentDefinition<ISchema<PBAudioSource>>;
|
221
|
+
/** @public */
|
222
|
+
const AvatarAttach: ComponentDefinition<ISchema<PBAvatarAttach>>;
|
223
|
+
/** @public */
|
224
|
+
const AvatarShape: ComponentDefinition<ISchema<PBAvatarShape>>;
|
225
|
+
/** @public */
|
226
|
+
const Billboard: ComponentDefinition<ISchema<PBBillboard>>;
|
227
|
+
/** @public */
|
228
|
+
const BoxShape: ComponentDefinition<ISchema<PBBoxShape>>;
|
229
|
+
/** @public */
|
230
|
+
const CameraMode: ComponentDefinition<ISchema<PBCameraMode>>;
|
231
|
+
/** @public */
|
232
|
+
const CameraModeArea: ComponentDefinition<ISchema<PBCameraModeArea>>;
|
233
|
+
/** @public */
|
234
|
+
const CylinderShape: ComponentDefinition<ISchema<PBCylinderShape>>;
|
235
|
+
/** @public */
|
236
|
+
const GLTFShape: ComponentDefinition<ISchema<PBGLTFShape>>;
|
237
|
+
/** @public */
|
238
|
+
const NFTShape: ComponentDefinition<ISchema<PBNFTShape>>;
|
239
|
+
/** @public */
|
240
|
+
const OnPointerDown: ComponentDefinition<ISchema<PBOnPointerDown>>;
|
241
|
+
/** @public */
|
242
|
+
const OnPointerDownResult: ComponentDefinition<ISchema<PBOnPointerDownResult>>;
|
243
|
+
/** @public */
|
244
|
+
const OnPointerUp: ComponentDefinition<ISchema<PBOnPointerUp>>;
|
245
|
+
/** @public */
|
246
|
+
const OnPointerUpResult: ComponentDefinition<ISchema<PBOnPointerUpResult>>;
|
247
|
+
/** @public */
|
248
|
+
const PlaneShape: ComponentDefinition<ISchema<PBPlaneShape>>;
|
249
|
+
/** @public */
|
250
|
+
const PointerLock: ComponentDefinition<ISchema<PBPointerLock>>;
|
251
|
+
/** @public */
|
252
|
+
const SphereShape: ComponentDefinition<ISchema<PBSphereShape>>;
|
253
|
+
/** @public */
|
254
|
+
const TextShape: ComponentDefinition<ISchema<PBTextShape>>;
|
255
|
+
}
|
256
|
+
|
71
257
|
/**
|
72
258
|
* @public
|
73
259
|
*/
|
74
|
-
export declare type
|
75
|
-
[K in keyof T]: T[K] extends ComponentDefinition ? ReturnType<T[K]['
|
260
|
+
export declare type ComponentSchema<T extends [ComponentDefinition, ...ComponentDefinition[]]> = {
|
261
|
+
[K in keyof T]: T[K] extends ComponentDefinition ? ReturnType<T[K]['getMutable']> : never;
|
76
262
|
};
|
77
263
|
|
78
264
|
/**
|
79
265
|
* @public
|
80
266
|
*/
|
81
|
-
export declare type ComponentType<T extends
|
267
|
+
export declare type ComponentType<T extends ISchema> = EcsResult<T>;
|
82
268
|
|
83
269
|
/**
|
84
270
|
* ByteBuffer is a wrapper of DataView which also adds a read and write offset.
|
@@ -218,6 +404,9 @@ declare interface CreateByteBufferOptions {
|
|
218
404
|
initialCapacity?: number;
|
219
405
|
}
|
220
406
|
|
407
|
+
/** @public */
|
408
|
+
export declare const CylinderShape: ComponentDefinition<ISchema<PBCylinderShape>>;
|
409
|
+
|
221
410
|
/**
|
222
411
|
* Make each field readonly deeply
|
223
412
|
* @public
|
@@ -226,27 +415,45 @@ export declare type DeepReadonly<T> = {
|
|
226
415
|
readonly [P in keyof T]: DeepReadonly<T[P]>;
|
227
416
|
};
|
228
417
|
|
229
|
-
declare function
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
418
|
+
declare function defineLibraryComponents({ defineComponentFromSchema }: Pick<IEngine, 'defineComponentFromSchema'>): {
|
419
|
+
Transform: ComponentDefinition<ISchema< {
|
420
|
+
position: {
|
421
|
+
x: number;
|
422
|
+
y: number;
|
423
|
+
z: number;
|
424
|
+
};
|
425
|
+
rotation: {
|
426
|
+
x: number;
|
427
|
+
y: number;
|
428
|
+
z: number;
|
429
|
+
w: number;
|
430
|
+
};
|
431
|
+
scale: {
|
432
|
+
x: number;
|
433
|
+
y: number;
|
434
|
+
z: number;
|
435
|
+
};
|
436
|
+
parent?: Entity | undefined;
|
437
|
+
}>>;
|
438
|
+
Animator: ComponentDefinition<ISchema<PBAnimator>>;
|
439
|
+
AudioSource: ComponentDefinition<ISchema<PBAudioSource>>;
|
440
|
+
AvatarAttach: ComponentDefinition<ISchema<PBAvatarAttach>>;
|
441
|
+
AvatarShape: ComponentDefinition<ISchema<PBAvatarShape>>;
|
442
|
+
Billboard: ComponentDefinition<ISchema<PBBillboard>>;
|
443
|
+
BoxShape: ComponentDefinition<ISchema<PBBoxShape>>;
|
444
|
+
CameraMode: ComponentDefinition<ISchema<PBCameraMode>>;
|
445
|
+
CameraModeArea: ComponentDefinition<ISchema<PBCameraModeArea>>;
|
446
|
+
CylinderShape: ComponentDefinition<ISchema<PBCylinderShape>>;
|
447
|
+
GLTFShape: ComponentDefinition<ISchema<PBGLTFShape>>;
|
448
|
+
NFTShape: ComponentDefinition<ISchema<PBNFTShape>>;
|
449
|
+
OnPointerDown: ComponentDefinition<ISchema<PBOnPointerDown>>;
|
450
|
+
OnPointerDownResult: ComponentDefinition<ISchema<PBOnPointerDownResult>>;
|
451
|
+
OnPointerUp: ComponentDefinition<ISchema<PBOnPointerUp>>;
|
452
|
+
OnPointerUpResult: ComponentDefinition<ISchema<PBOnPointerUpResult>>;
|
453
|
+
PlaneShape: ComponentDefinition<ISchema<PBPlaneShape>>;
|
454
|
+
PointerLock: ComponentDefinition<ISchema<PBPointerLock>>;
|
455
|
+
SphereShape: ComponentDefinition<ISchema<PBSphereShape>>;
|
456
|
+
TextShape: ComponentDefinition<ISchema<PBTextShape>>;
|
250
457
|
};
|
251
458
|
|
252
459
|
/**
|
@@ -261,26 +468,7 @@ export declare type double = number;
|
|
261
468
|
/**
|
262
469
|
* @public
|
263
470
|
*/
|
264
|
-
|
265
|
-
|
266
|
-
/**
|
267
|
-
* @public
|
268
|
-
*/
|
269
|
-
declare type EcsResult<T extends EcsType> = T extends EcsType ? ReturnType<T['deserialize']> : never;
|
270
|
-
|
271
|
-
/**
|
272
|
-
* @public
|
273
|
-
*/
|
274
|
-
export declare const EcsString: EcsType<string>;
|
275
|
-
|
276
|
-
/**
|
277
|
-
* @public
|
278
|
-
*/
|
279
|
-
export declare type EcsType<T = any> = {
|
280
|
-
serialize(value: T, builder: ByteBuffer): void;
|
281
|
-
deserialize(reader: ByteBuffer): T;
|
282
|
-
create(): T;
|
283
|
-
};
|
471
|
+
declare type EcsResult<T extends ISchema> = T extends ISchema ? ReturnType<T['deserialize']> : never;
|
284
472
|
|
285
473
|
/**
|
286
474
|
* @public
|
@@ -302,57 +490,127 @@ export declare type Entity = number & {
|
|
302
490
|
|
303
491
|
declare const entitySymbol: unique symbol;
|
304
492
|
|
305
|
-
/**
|
306
|
-
* @public
|
307
|
-
*/
|
308
|
-
export declare function Enum<T>(type: EcsType<any>): EcsType<T>;
|
309
|
-
|
310
493
|
/**
|
311
494
|
* Constant used to define the minimal number value in Babylon.js
|
312
495
|
* @public
|
313
496
|
*/
|
314
497
|
export declare const Epsilon = 0.000001;
|
315
498
|
|
499
|
+
export declare const error: (message: string | Error, data?: any) => void;
|
500
|
+
|
316
501
|
/** Excludes property keys from T where the property is assignable to U */
|
317
502
|
declare type ExcludeUndefined<T> = {
|
318
503
|
[P in keyof T]: undefined extends T[P] ? never : P;
|
319
504
|
}[keyof T];
|
320
505
|
|
321
|
-
/**
|
322
|
-
* @public
|
323
|
-
*/
|
324
|
-
export declare const FlatString: EcsType<string>;
|
325
|
-
|
326
506
|
/** @public */
|
327
507
|
export declare type float = number;
|
328
508
|
|
329
|
-
/**
|
330
|
-
|
331
|
-
|
332
|
-
|
509
|
+
/** @public */
|
510
|
+
export declare type FloatArray = number[];
|
511
|
+
|
512
|
+
/** @public */
|
513
|
+
export declare const GLTFShape: ComponentDefinition<ISchema<PBGLTFShape>>;
|
333
514
|
|
334
515
|
/**
|
335
516
|
* @public
|
336
517
|
*/
|
337
|
-
|
338
|
-
|
339
|
-
/** @public */
|
340
|
-
export declare type FloatArray = number[];
|
518
|
+
declare function IArray<T>(type: ISchema<T>): ISchema<Array<T>>;
|
341
519
|
|
342
520
|
/**
|
343
521
|
* @public
|
344
522
|
*/
|
345
523
|
export declare type IEngine = {
|
524
|
+
/**
|
525
|
+
* Increment the used entity counter and return the next one.
|
526
|
+
* @param dynamic
|
527
|
+
* @return the next entity unused
|
528
|
+
*/
|
346
529
|
addEntity(dynamic?: boolean): Entity;
|
530
|
+
/**
|
531
|
+
* An alias of engine.addEntity(true)
|
532
|
+
*/
|
347
533
|
addDynamicEntity(): Entity;
|
534
|
+
/**
|
535
|
+
* Remove all components of an entity
|
536
|
+
* @param entity
|
537
|
+
*/
|
348
538
|
removeEntity(entity: Entity): void;
|
539
|
+
/**
|
540
|
+
* Add the system to the engine. It will be called every tick updated.
|
541
|
+
* @param system function that receives the delta time between last tick and current one.
|
542
|
+
* @param priority a number with the priority, big number are called before smaller ones
|
543
|
+
* @param name optional: a unique name to identify it
|
544
|
+
*
|
545
|
+
* Example:
|
546
|
+
* ```ts
|
547
|
+
* function mySystem(dt: number) {
|
548
|
+
* const entitiesWithBoxShapes = engine.getEntitiesWith(BoxShape, Transform)
|
549
|
+
* for (const [entity, _boxShape, _transform] of engine.getEntitiesWith(BoxShape, Transform)) {
|
550
|
+
* // do stuffs
|
551
|
+
* }
|
552
|
+
* }
|
553
|
+
* engine.addSystem(mySystem, 10)
|
554
|
+
* ```
|
555
|
+
*/
|
349
556
|
addSystem(system: Update, priority?: number, name?: string): void;
|
557
|
+
/**
|
558
|
+
* Remove a system from the engine.
|
559
|
+
* @param selector the function or the unique name to identify
|
560
|
+
* @returns if it was found and removed
|
561
|
+
*/
|
350
562
|
removeSystem(selector: string | Update): boolean;
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
563
|
+
/**
|
564
|
+
* Define a component and add it to the engine.
|
565
|
+
* @param spec An object with schema fields
|
566
|
+
* @param componentId unique id to identify the component, if the component id already exist, it will fail.
|
567
|
+
* @return The component definition
|
568
|
+
*
|
569
|
+
* ```ts
|
570
|
+
* const DoorComponentId = 10017
|
571
|
+
* const Door = engine.defineComponent({
|
572
|
+
* id: Schemas.Int,
|
573
|
+
* name: Schemas.String
|
574
|
+
* }, DoorComponentId)
|
575
|
+
*
|
576
|
+
* ```
|
577
|
+
*/
|
578
|
+
defineComponent<T extends Spec>(spec: Spec, componentId: number): ComponentDefinition<ISchema<Result<T>>>;
|
579
|
+
/**
|
580
|
+
* Define a component and add it to the engine.
|
581
|
+
* @param spec An object with schema fields
|
582
|
+
* @param componentId unique id to identify the component, if the component id already exist, it will fail.
|
583
|
+
* @return The component definition
|
584
|
+
*
|
585
|
+
* ```ts
|
586
|
+
* const StateComponentId = 10023
|
587
|
+
* const StateComponent = engine.defineComponent(Schemas.Bool, VisibleComponentId)
|
588
|
+
* ```
|
589
|
+
*/
|
590
|
+
defineComponentFromSchema<T extends ISchema>(spec: T, componentId: number): ComponentDefinition<T>;
|
591
|
+
/**
|
592
|
+
* Get the component definition from the component id.
|
593
|
+
* @param componentId
|
594
|
+
* @return the component definition, throw an error if it doesn't exist
|
595
|
+
* ```ts
|
596
|
+
* const StateComponentId = 10023
|
597
|
+
* const StateComponent = engine.getComponent(StateComponentId)
|
598
|
+
* ```
|
599
|
+
*/
|
600
|
+
getComponent<T extends ISchema>(componentId: number): ComponentDefinition<T>;
|
601
|
+
/**
|
602
|
+
* Get a iterator of entities that has all the component requested.
|
603
|
+
* @param components a list of component definitions
|
604
|
+
* @return An iterator of an array with the [entity, component1, component2, ...]
|
605
|
+
*
|
606
|
+
* Example:
|
607
|
+
* ```ts
|
608
|
+
* for (const [entity, boxShape, transform] of engine.getEntitiesWith(BoxShape, Transform)) {
|
609
|
+
* // the properties of boxShape and transform are read only
|
610
|
+
* }
|
611
|
+
* ```
|
612
|
+
*/
|
613
|
+
getEntitiesWith<T extends [ComponentDefinition, ...ComponentDefinition[]]>(...components: T): Iterable<[Entity, ...DeepReadonly<ComponentSchema<T>>]>;
|
356
614
|
baseComponents: SdkComponents;
|
357
615
|
};
|
358
616
|
|
@@ -363,30 +621,34 @@ export declare type IEngineParams = {
|
|
363
621
|
transports?: Transport[];
|
364
622
|
};
|
365
623
|
|
366
|
-
/** Include property keys from T where the property is assignable to U */
|
367
|
-
declare type IncludeUndefined<T> = {
|
368
|
-
[P in keyof T]: undefined extends T[P] ? P : never;
|
369
|
-
}[keyof T];
|
370
|
-
|
371
624
|
/**
|
372
625
|
* @public
|
373
626
|
*/
|
374
|
-
|
627
|
+
declare function IEnum<T>(type: ISchema<any>): ISchema<T>;
|
375
628
|
|
376
629
|
/**
|
377
630
|
* @public
|
378
631
|
*/
|
379
|
-
|
632
|
+
declare function IMap<T extends Spec>(spec: T): ISchema<Result<T>>;
|
633
|
+
|
634
|
+
/** Include property keys from T where the property is assignable to U */
|
635
|
+
declare type IncludeUndefined<T> = {
|
636
|
+
[P in keyof T]: undefined extends T[P] ? P : never;
|
637
|
+
}[keyof T];
|
380
638
|
|
381
639
|
/**
|
382
640
|
* @public
|
383
641
|
*/
|
384
|
-
|
642
|
+
declare function IOptional<T>(spec: ISchema<T>): ISchema<T | undefined>;
|
385
643
|
|
386
644
|
/**
|
387
645
|
* @public
|
388
646
|
*/
|
389
|
-
|
647
|
+
declare type ISchema<T = any> = {
|
648
|
+
serialize(value: T, builder: ByteBuffer): void;
|
649
|
+
deserialize(reader: ByteBuffer): T;
|
650
|
+
create(): T;
|
651
|
+
};
|
390
652
|
|
391
653
|
/**
|
392
654
|
* Interface for the size containing width and height
|
@@ -403,10 +665,7 @@ export declare interface ISize {
|
|
403
665
|
height: number;
|
404
666
|
}
|
405
667
|
|
406
|
-
|
407
|
-
* @public
|
408
|
-
*/
|
409
|
-
export declare function MapType<T extends Spec>(spec: T): EcsType<Result<T>>;
|
668
|
+
export declare const log: (...a: any[]) => void;
|
410
669
|
|
411
670
|
/**
|
412
671
|
* Class used to store matrix data (4x4)
|
@@ -1127,6 +1386,9 @@ declare namespace Matrix {
|
|
1127
1386
|
function toggleProjectionMatrixHandInPlace(self: MutableMatrix): void;
|
1128
1387
|
}
|
1129
1388
|
|
1389
|
+
/** @public */
|
1390
|
+
export declare const NFTShape: ComponentDefinition<ISchema<PBNFTShape>>;
|
1391
|
+
|
1130
1392
|
/** @public */
|
1131
1393
|
export declare type Nullable<T> = T | null;
|
1132
1394
|
|
@@ -1138,10 +1400,17 @@ declare type OnlyOptionalUndefinedTypes<T> = {
|
|
1138
1400
|
[K in IncludeUndefined<T>]?: T[K];
|
1139
1401
|
};
|
1140
1402
|
|
1141
|
-
/**
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1403
|
+
/** @public */
|
1404
|
+
export declare const OnPointerDown: ComponentDefinition<ISchema<PBOnPointerDown>>;
|
1405
|
+
|
1406
|
+
/** @public */
|
1407
|
+
export declare const OnPointerDownResult: ComponentDefinition<ISchema<PBOnPointerDownResult>>;
|
1408
|
+
|
1409
|
+
/** @public */
|
1410
|
+
export declare const OnPointerUp: ComponentDefinition<ISchema<PBOnPointerUp>>;
|
1411
|
+
|
1412
|
+
/** @public */
|
1413
|
+
export declare const OnPointerUpResult: ComponentDefinition<ISchema<PBOnPointerUpResult>>;
|
1145
1414
|
|
1146
1415
|
/**
|
1147
1416
|
* Defines potential orientation for back face culling
|
@@ -1159,11 +1428,14 @@ export declare enum Orientation {
|
|
1159
1428
|
declare interface PBAnimationState {
|
1160
1429
|
name: string;
|
1161
1430
|
clip: string;
|
1162
|
-
playing
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1431
|
+
playing?: boolean | undefined;
|
1432
|
+
/** default=1.0s */
|
1433
|
+
weight?: number | undefined;
|
1434
|
+
/** default=1.0 */
|
1435
|
+
speed?: number | undefined;
|
1436
|
+
/** default=true */
|
1437
|
+
loop?: boolean | undefined;
|
1438
|
+
shouldReset?: boolean | undefined;
|
1167
1439
|
}
|
1168
1440
|
|
1169
1441
|
declare interface PBAnimator {
|
@@ -1171,10 +1443,12 @@ declare interface PBAnimator {
|
|
1171
1443
|
}
|
1172
1444
|
|
1173
1445
|
declare interface PBAudioSource {
|
1174
|
-
playing
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1446
|
+
playing?: boolean | undefined;
|
1447
|
+
/** default=1.0f */
|
1448
|
+
volume?: number | undefined;
|
1449
|
+
loop?: boolean | undefined;
|
1450
|
+
/** default=1.0f */
|
1451
|
+
pitch?: number | undefined;
|
1178
1452
|
audioClipUrl: string;
|
1179
1453
|
}
|
1180
1454
|
|
@@ -1185,29 +1459,35 @@ declare interface PBAvatarAttach {
|
|
1185
1459
|
|
1186
1460
|
declare interface PBAvatarShape {
|
1187
1461
|
id: string;
|
1188
|
-
name
|
1189
|
-
bodyShape
|
1190
|
-
skinColor
|
1191
|
-
hairColor
|
1192
|
-
eyeColor
|
1462
|
+
name?: string | undefined;
|
1463
|
+
bodyShape?: string | undefined;
|
1464
|
+
skinColor?: Color3 | undefined;
|
1465
|
+
hairColor?: Color3 | undefined;
|
1466
|
+
eyeColor?: Color3 | undefined;
|
1193
1467
|
wearables: string[];
|
1194
|
-
expressionTriggerId
|
1195
|
-
expressionTriggerTimestamp
|
1196
|
-
stickerTriggerId
|
1197
|
-
stickerTriggerTimestamp
|
1198
|
-
talking
|
1468
|
+
expressionTriggerId?: string | undefined;
|
1469
|
+
expressionTriggerTimestamp?: number | undefined;
|
1470
|
+
stickerTriggerId?: string | undefined;
|
1471
|
+
stickerTriggerTimestamp?: number | undefined;
|
1472
|
+
talking?: boolean | undefined;
|
1199
1473
|
}
|
1200
1474
|
|
1201
1475
|
declare interface PBBillboard {
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1476
|
+
/** default=true */
|
1477
|
+
x?: boolean | undefined;
|
1478
|
+
/** default=true */
|
1479
|
+
y?: boolean | undefined;
|
1480
|
+
/** default=true */
|
1481
|
+
z?: boolean | undefined;
|
1205
1482
|
}
|
1206
1483
|
|
1207
1484
|
declare interface PBBoxShape {
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1485
|
+
/** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
|
1486
|
+
withCollisions?: boolean | undefined;
|
1487
|
+
/** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
|
1488
|
+
isPointerBlocker?: boolean | undefined;
|
1489
|
+
/** @deprecated use HiddenComponent instead https://github.com/decentraland/sdk/issues/353 */
|
1490
|
+
visible?: boolean | undefined;
|
1211
1491
|
uvs: number[];
|
1212
1492
|
}
|
1213
1493
|
|
@@ -1221,35 +1501,50 @@ declare interface PBCameraModeArea {
|
|
1221
1501
|
}
|
1222
1502
|
|
1223
1503
|
declare interface PBCylinderShape {
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1504
|
+
/** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
|
1505
|
+
withCollisions?: boolean | undefined;
|
1506
|
+
/** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
|
1507
|
+
isPointerBlocker?: boolean | undefined;
|
1508
|
+
/** @deprecated use HiddenComponent instead https://github.com/decentraland/sdk/issues/353 */
|
1509
|
+
visible?: boolean | undefined;
|
1510
|
+
/** default=1.0 */
|
1511
|
+
radiusTop?: number | undefined;
|
1512
|
+
/** default=1.0 */
|
1513
|
+
radiusBottom?: number | undefined;
|
1229
1514
|
}
|
1230
1515
|
|
1231
1516
|
declare interface PBGLTFShape {
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1517
|
+
/** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
|
1518
|
+
withCollisions?: boolean | undefined;
|
1519
|
+
/** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
|
1520
|
+
isPointerBlocker?: boolean | undefined;
|
1521
|
+
/** @deprecated use HiddenComponent instead https://github.com/decentraland/sdk/issues/353 */
|
1522
|
+
visible?: boolean | undefined;
|
1235
1523
|
src: string;
|
1236
1524
|
}
|
1237
1525
|
|
1238
1526
|
declare interface PBNFTShape {
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1527
|
+
/** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
|
1528
|
+
withCollisions?: boolean | undefined;
|
1529
|
+
/** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
|
1530
|
+
isPointerBlocker?: boolean | undefined;
|
1531
|
+
/** @deprecated use HiddenComponent instead https://github.com/decentraland/sdk/issues/353 */
|
1532
|
+
visible?: boolean | undefined;
|
1242
1533
|
src: string;
|
1243
|
-
assetId
|
1244
|
-
style
|
1245
|
-
color
|
1534
|
+
assetId?: string | undefined;
|
1535
|
+
style?: number | undefined;
|
1536
|
+
color?: Color3 | undefined;
|
1246
1537
|
}
|
1247
1538
|
|
1248
1539
|
declare interface PBOnPointerDown {
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1540
|
+
/** default=ActionButton.ANY */
|
1541
|
+
button?: ActionButton | undefined;
|
1542
|
+
/** default='Interact' */
|
1543
|
+
hoverText?: string | undefined;
|
1544
|
+
/** default=10 */
|
1545
|
+
maxDistance?: number | undefined;
|
1546
|
+
/** default=true */
|
1547
|
+
showFeedback?: boolean | undefined;
|
1253
1548
|
}
|
1254
1549
|
|
1255
1550
|
declare interface PBOnPointerDownResult {
|
@@ -1264,10 +1559,14 @@ declare interface PBOnPointerDownResult {
|
|
1264
1559
|
}
|
1265
1560
|
|
1266
1561
|
declare interface PBOnPointerUp {
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1562
|
+
/** default=ActionButton.ANY */
|
1563
|
+
button?: ActionButton | undefined;
|
1564
|
+
/** default='Interact' */
|
1565
|
+
hoverText?: string | undefined;
|
1566
|
+
/** default=10 */
|
1567
|
+
maxDistance?: number | undefined;
|
1568
|
+
/** default=true */
|
1569
|
+
showFeedback?: boolean | undefined;
|
1271
1570
|
}
|
1272
1571
|
|
1273
1572
|
declare interface PBOnPointerUpResult {
|
@@ -1282,9 +1581,12 @@ declare interface PBOnPointerUpResult {
|
|
1282
1581
|
}
|
1283
1582
|
|
1284
1583
|
declare interface PBPlaneShape {
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1584
|
+
/** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
|
1585
|
+
withCollisions?: boolean | undefined;
|
1586
|
+
/** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
|
1587
|
+
isPointerBlocker?: boolean | undefined;
|
1588
|
+
/** @deprecated use HiddenComponent instead https://github.com/decentraland/sdk/issues/353 */
|
1589
|
+
visible?: boolean | undefined;
|
1288
1590
|
uvs: number[];
|
1289
1591
|
}
|
1290
1592
|
|
@@ -1293,36 +1595,49 @@ declare interface PBPointerLock {
|
|
1293
1595
|
}
|
1294
1596
|
|
1295
1597
|
declare interface PBSphereShape {
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1598
|
+
/** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
|
1599
|
+
withCollisions?: boolean | undefined;
|
1600
|
+
/** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
|
1601
|
+
isPointerBlocker?: boolean | undefined;
|
1602
|
+
/** @deprecated use HiddenComponent instead https://github.com/decentraland/sdk/issues/353 */
|
1603
|
+
visible?: boolean | undefined;
|
1299
1604
|
}
|
1300
1605
|
|
1301
1606
|
declare interface PBTextShape {
|
1302
1607
|
text: string;
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1608
|
+
/** @deprecated use HiddenComponent instead https://github.com/decentraland/sdk/issues/353 */
|
1609
|
+
visible?: boolean | undefined;
|
1610
|
+
font?: string | undefined;
|
1611
|
+
/** default=1.0f */
|
1612
|
+
opacity?: number | undefined;
|
1613
|
+
/** default=10 */
|
1614
|
+
fontSize?: number | undefined;
|
1615
|
+
fontAutoSize?: boolean | undefined;
|
1616
|
+
/** default='center' */
|
1617
|
+
hTextAlign?: string | undefined;
|
1618
|
+
/** default='center' */
|
1619
|
+
vTextAlign?: string | undefined;
|
1620
|
+
/** default=1 */
|
1621
|
+
width?: number | undefined;
|
1622
|
+
/** default=1 */
|
1623
|
+
height?: number | undefined;
|
1624
|
+
paddingTop?: number | undefined;
|
1625
|
+
paddingRight?: number | undefined;
|
1626
|
+
paddingBottom?: number | undefined;
|
1627
|
+
paddingLeft?: number | undefined;
|
1628
|
+
lineSpacing?: number | undefined;
|
1629
|
+
lineCount?: number | undefined;
|
1630
|
+
textWrapping?: boolean | undefined;
|
1631
|
+
shadowBlur?: number | undefined;
|
1632
|
+
shadowOffsetX?: number | undefined;
|
1633
|
+
shadowOffsetY?: number | undefined;
|
1634
|
+
outlineWidth?: number | undefined;
|
1635
|
+
/** default=(1.0,1.0,1.0) */
|
1636
|
+
shadowColor?: Color3 | undefined;
|
1637
|
+
/** default=(1.0,1.0,1.0) */
|
1638
|
+
outlineColor?: Color3 | undefined;
|
1639
|
+
/** default=(1.0,1.0,1.0) */
|
1640
|
+
textColor?: Color3 | undefined;
|
1326
1641
|
}
|
1327
1642
|
|
1328
1643
|
/**
|
@@ -1434,6 +1749,12 @@ declare namespace Plane {
|
|
1434
1749
|
function signedDistanceTo(plane: ReadonlyPlane, point: Vector3.ReadonlyVector3): number;
|
1435
1750
|
}
|
1436
1751
|
|
1752
|
+
/** @public */
|
1753
|
+
export declare const PlaneShape: ComponentDefinition<ISchema<PBPlaneShape>>;
|
1754
|
+
|
1755
|
+
/** @public */
|
1756
|
+
export declare const PointerLock: ComponentDefinition<ISchema<PBPointerLock>>;
|
1757
|
+
|
1437
1758
|
/**
|
1438
1759
|
* @public
|
1439
1760
|
*/
|
@@ -1618,13 +1939,33 @@ declare type ReceiveMessage = {
|
|
1618
1939
|
* @public
|
1619
1940
|
*/
|
1620
1941
|
export declare type Result<T extends Spec> = ToOptional<{
|
1621
|
-
[K in keyof T]: T[K] extends
|
1942
|
+
[K in keyof T]: T[K] extends ISchema ? ReturnType<T[K]['deserialize']> : T[K] extends Spec ? Result<T[K]> : never;
|
1622
1943
|
}>;
|
1623
1944
|
|
1624
1945
|
/**
|
1625
1946
|
* @public
|
1626
1947
|
*/
|
1627
|
-
export declare
|
1948
|
+
export declare namespace Schemas {
|
1949
|
+
export type SchemaType = ISchema;
|
1950
|
+
const Boolean: ISchema<boolean>;
|
1951
|
+
const String: ISchema<string>;
|
1952
|
+
const Float: ISchema<number>;
|
1953
|
+
const Double: ISchema<number>;
|
1954
|
+
const Byte: ISchema<number>;
|
1955
|
+
const Short: ISchema<number>;
|
1956
|
+
const Int: ISchema<number>;
|
1957
|
+
const Int64: ISchema<number>;
|
1958
|
+
const Number: ISchema<number>;
|
1959
|
+
const Enum: typeof IEnum;
|
1960
|
+
const Array: typeof IArray;
|
1961
|
+
const Map: typeof IMap;
|
1962
|
+
const Optional: typeof IOptional;
|
1963
|
+
}
|
1964
|
+
|
1965
|
+
/**
|
1966
|
+
* @public
|
1967
|
+
*/
|
1968
|
+
export declare type SdkComponents = ReturnType<typeof defineLibraryComponents>;
|
1628
1969
|
|
1629
1970
|
/**
|
1630
1971
|
* Defines supported spaces
|
@@ -1643,9 +1984,15 @@ export declare enum Space {
|
|
1643
1984
|
* @public
|
1644
1985
|
*/
|
1645
1986
|
export declare interface Spec {
|
1646
|
-
[key: string]:
|
1987
|
+
[key: string]: ISchema;
|
1647
1988
|
}
|
1648
1989
|
|
1990
|
+
/** @public */
|
1991
|
+
export declare const SphereShape: ComponentDefinition<ISchema<PBSphereShape>>;
|
1992
|
+
|
1993
|
+
/** @public */
|
1994
|
+
export declare const TextShape: ComponentDefinition<ISchema<PBTextShape>>;
|
1995
|
+
|
1649
1996
|
/**
|
1650
1997
|
* Constant used to convert a value to gamma space
|
1651
1998
|
* @public
|
@@ -1660,26 +2007,35 @@ export declare const ToLinearSpace = 2.2;
|
|
1660
2007
|
|
1661
2008
|
declare type ToOptional<T> = OnlyOptionalUndefinedTypes<T> & OnlyNonUndefinedTypes<T>;
|
1662
2009
|
|
1663
|
-
/**
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
scale: Vector3.MutableVector3;
|
1670
|
-
parent?: Entity;
|
2010
|
+
/** @public */
|
2011
|
+
export declare const Transform: ComponentDefinition<ISchema< {
|
2012
|
+
position: {
|
2013
|
+
x: number;
|
2014
|
+
y: number;
|
2015
|
+
z: number;
|
1671
2016
|
};
|
2017
|
+
rotation: {
|
2018
|
+
x: number;
|
2019
|
+
y: number;
|
2020
|
+
z: number;
|
2021
|
+
w: number;
|
2022
|
+
};
|
2023
|
+
scale: {
|
2024
|
+
x: number;
|
2025
|
+
y: number;
|
2026
|
+
z: number;
|
2027
|
+
};
|
2028
|
+
parent?: Entity | undefined;
|
2029
|
+
}>>;
|
1672
2030
|
|
1673
|
-
declare
|
1674
|
-
|
1675
|
-
declare type Transport = {
|
2031
|
+
export declare type Transport = {
|
1676
2032
|
type: string;
|
1677
2033
|
send(message: Uint8Array): void;
|
1678
2034
|
onmessage?(message: Uint8Array): void;
|
1679
2035
|
filter(message: Omit<TransportMessage, 'messageBuffer'>): boolean;
|
1680
2036
|
};
|
1681
2037
|
|
1682
|
-
declare type TransportMessage = Omit<ReceiveMessage, 'data'>;
|
2038
|
+
export declare type TransportMessage = Omit<ReceiveMessage, 'data'>;
|
1683
2039
|
|
1684
2040
|
declare type Uint32 = number;
|
1685
2041
|
|
@@ -1691,7 +2047,7 @@ export declare type Unpacked<T> = T extends (infer U)[] ? U : T;
|
|
1691
2047
|
/**
|
1692
2048
|
* @public
|
1693
2049
|
*/
|
1694
|
-
declare type Update = (dt: number) => void;
|
2050
|
+
export declare type Update = (dt: number) => void;
|
1695
2051
|
|
1696
2052
|
/**
|
1697
2053
|
* @public
|