@dcl/sdk 7.0.0-3349175623.commit-522e724 → 7.0.0-3380949689.commit-663e9f5
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 +18 -58
- package/dist/ecs7/index.js +30 -36
- package/dist/ecs7/index.min.js +1 -1
- package/dist/ecs7/index.min.js.map +1 -1
- package/dist/playground/snippets/cube-spawner.ts +11 -32
- package/dist/playground/snippets/ui.tsx +7 -1
- package/package.json +4 -4
- package/types/ecs7/index.d.ts +18 -58
- package/types/rpc-modules/EngineApi/index.d.ts +13 -1
- package/types/tsconfig.ecs7.json +0 -1
- package/types/rpc-modules/ExperimentalApi/index.d.ts +0 -20
@@ -1,24 +1,10 @@
|
|
1
1
|
// Cube factory
|
2
|
-
function createCube(x: number, y: number, z: number
|
2
|
+
function createCube(x: number, y: number, z: number): Entity {
|
3
3
|
const meshEntity = engine.addEntity()
|
4
4
|
Transform.create(meshEntity, { position: { x, y, z } })
|
5
5
|
MeshRenderer.create(meshEntity, { mesh: { $case: 'box', box: { uvs: [] } } })
|
6
6
|
MeshCollider.create(meshEntity, { mesh: { $case: 'box', box: {} } })
|
7
|
-
|
8
|
-
PointerHoverFeedback.create(meshEntity, {
|
9
|
-
pointerEvents: [
|
10
|
-
{
|
11
|
-
eventType: PointerEventType.PET_DOWN,
|
12
|
-
eventInfo: {
|
13
|
-
button: InputAction.IA_PRIMARY,
|
14
|
-
hoverText: 'Press E to spawn',
|
15
|
-
maxDistance: 100,
|
16
|
-
showFeedback: true
|
17
|
-
}
|
18
|
-
}
|
19
|
-
]
|
20
|
-
})
|
21
|
-
}
|
7
|
+
|
22
8
|
return meshEntity
|
23
9
|
}
|
24
10
|
|
@@ -38,23 +24,16 @@ function circularSystem(dt: number) {
|
|
38
24
|
}
|
39
25
|
}
|
40
26
|
|
41
|
-
function spawnerSystem() {
|
42
|
-
const clickedCubes = engine.getEntitiesWith(PointerHoverFeedback)
|
43
|
-
for (const [entity] of clickedCubes) {
|
44
|
-
if (Input.wasJustClicked(InputAction.IA_PRIMARY, entity)) {
|
45
|
-
createCube(
|
46
|
-
1 + Math.random() * 8,
|
47
|
-
Math.random() * 8,
|
48
|
-
1 + Math.random() * 8,
|
49
|
-
false
|
50
|
-
)
|
51
|
-
}
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
27
|
// Init
|
56
|
-
createCube(8, 1, 8)
|
28
|
+
const initEntity = createCube(8, 1, 8)
|
29
|
+
EventsSystem.onPointerDown(
|
30
|
+
initEntity,
|
31
|
+
() => {
|
32
|
+
createCube(1 + Math.random() * 8, Math.random() * 8, 1 + Math.random() * 8)
|
33
|
+
},
|
34
|
+
{ button: InputAction.IA_PRIMARY, hoverText: 'Press E to spawn' }
|
35
|
+
)
|
36
|
+
|
57
37
|
engine.addSystem(circularSystem)
|
58
|
-
engine.addSystem(spawnerSystem)
|
59
38
|
|
60
39
|
|
@@ -114,7 +114,13 @@ function circularSystem(dt: number) {
|
|
114
114
|
function spawnerSystem() {
|
115
115
|
const clickedCubes = engine.getEntitiesWith(PointerHoverFeedback)
|
116
116
|
for (const [entity] of clickedCubes) {
|
117
|
-
if (
|
117
|
+
if (
|
118
|
+
Input.isTriggered(
|
119
|
+
InputAction.IA_PRIMARY,
|
120
|
+
PointerEventType.PET_DOWN,
|
121
|
+
entity
|
122
|
+
)
|
123
|
+
) {
|
118
124
|
counter++
|
119
125
|
}
|
120
126
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dcl/sdk",
|
3
|
-
"version": "7.0.0-
|
3
|
+
"version": "7.0.0-3380949689.commit-663e9f5",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/src/index.js",
|
6
6
|
"typings": "dist/index.d.ts",
|
@@ -23,12 +23,12 @@
|
|
23
23
|
"artifacts"
|
24
24
|
],
|
25
25
|
"dependencies": {
|
26
|
-
"@dcl/amd": "6.11.11-
|
27
|
-
"@dcl/build-ecs": "6.11.11-
|
26
|
+
"@dcl/amd": "6.11.11-3380949689.commit-663e9f5",
|
27
|
+
"@dcl/build-ecs": "6.11.11-3380949689.commit-663e9f5",
|
28
28
|
"@dcl/kernel": "^1.0.0-3339209749.commit-fa9e5d7",
|
29
29
|
"@dcl/posix": "^1.0.4",
|
30
30
|
"@dcl/unity-renderer": "^1.0.59980-20221027151836.commit-cc26142"
|
31
31
|
},
|
32
32
|
"minCliVersion": "3.12.3",
|
33
|
-
"commit": "
|
33
|
+
"commit": "663e9f55b50e559eb3e2ba7d2f4168623bcc6d92"
|
34
34
|
}
|
package/types/ecs7/index.d.ts
CHANGED
@@ -1218,42 +1218,37 @@ declare const entitySymbol: unique symbol;
|
|
1218
1218
|
*/
|
1219
1219
|
declare const error: (message: string | Error, data?: any) => void;
|
1220
1220
|
|
1221
|
+
declare type EventsSystem = typeof EventsSystem;
|
1222
|
+
|
1221
1223
|
declare namespace EventsSystem {
|
1222
1224
|
export type Callback = (event: PBPointerEventsResult_PointerCommand) => void | Promise<void>;
|
1223
1225
|
export type Options = {
|
1224
1226
|
button?: InputAction;
|
1225
1227
|
hoverText?: string;
|
1228
|
+
maxDistance?: number;
|
1226
1229
|
};
|
1227
1230
|
/**
|
1228
|
-
*
|
1229
|
-
* @param entity Entity where the callback was attached
|
1230
|
-
*/
|
1231
|
-
export function removeOnClick(entity: Entity): void;
|
1232
|
-
/**
|
1231
|
+
* @public
|
1233
1232
|
* Remove the callback for onPointerDown event
|
1234
1233
|
* @param entity Entity where the callback was attached
|
1235
1234
|
*/
|
1236
1235
|
export function removeOnPointerDown(entity: Entity): void;
|
1237
1236
|
/**
|
1237
|
+
* @public
|
1238
1238
|
* Remove the callback for onPointerUp event
|
1239
1239
|
* @param entity Entity where the callback was attached
|
1240
1240
|
*/
|
1241
1241
|
export function removeOnPointerUp(entity: Entity): void;
|
1242
1242
|
/**
|
1243
|
-
*
|
1244
|
-
*
|
1245
|
-
* @param cb Function to execute when onPointerDown fires
|
1246
|
-
* @param opts Opts to trigger Feedback and Button
|
1247
|
-
*/
|
1248
|
-
export function onClick(entity: Entity, cb: Callback, opts?: Options): void;
|
1249
|
-
/**
|
1250
|
-
* Execute callback when the user a the entity
|
1243
|
+
* @public
|
1244
|
+
* Execute callback when the user press the InputButton pointing at the entity
|
1251
1245
|
* @param entity Entity to attach the callback
|
1252
1246
|
* @param cb Function to execute when click fires
|
1253
1247
|
* @param opts Opts to trigger Feedback and Button
|
1254
1248
|
*/
|
1255
1249
|
export function onPointerDown(entity: Entity, cb: Callback, opts?: Options): void;
|
1256
1250
|
/**
|
1251
|
+
* @public
|
1257
1252
|
* Execute callback when the user releases the InputButton pointing at the entity
|
1258
1253
|
* @param entity Entity to attach the callback
|
1259
1254
|
* @param cb Function to execute when click fires
|
@@ -1430,40 +1425,24 @@ declare function IEnum<T>(type: ISchema<any>): ISchema<T>;
|
|
1430
1425
|
*/
|
1431
1426
|
declare type IInput = {
|
1432
1427
|
/**
|
1433
|
-
*
|
1434
|
-
*
|
1435
|
-
* @param inputAction - the input action to query
|
1436
|
-
* @param entity - the entity to query, ignore for global events.
|
1437
|
-
* @returns true if the entity was clicked in the last tick-update
|
1438
|
-
*/
|
1439
|
-
wasJustClicked: (inputAction: InputAction, entity?: Entity) => boolean;
|
1440
|
-
/**
|
1441
|
-
* Check if a pointer event has been emited in the last tick-update.
|
1428
|
+
* @public
|
1429
|
+
* Check if a pointer event has been emitted in the last tick-update.
|
1442
1430
|
* @param inputAction - the input action to query
|
1443
1431
|
* @param pointerEventType - the pointer event type to query
|
1444
1432
|
* @param entity - the entity to query, ignore for global
|
1445
|
-
* @returns
|
1433
|
+
* @returns boolean
|
1446
1434
|
*/
|
1447
|
-
|
1435
|
+
isTriggered: (inputAction: InputAction, pointerEventType: PointerEventType, entity?: Entity) => boolean;
|
1448
1436
|
/**
|
1449
|
-
*
|
1450
|
-
*
|
1451
|
-
* @returns true if the input action is being pressed
|
1452
|
-
*/
|
1453
|
-
isActionDown: (inputAction: InputAction) => boolean;
|
1454
|
-
/**
|
1455
|
-
* Get the click info if a click was emmited in the current tick for the input action.
|
1456
|
-
* This is defined when an UP event is triggered with a previously DOWN state.
|
1437
|
+
* @public
|
1438
|
+
* Check if an input action is currently being pressed.
|
1457
1439
|
* @param inputAction - the input action to query
|
1458
|
-
* @
|
1459
|
-
* @returns the click info or undefined if there is no command in the last tick-update
|
1440
|
+
* @returns boolean
|
1460
1441
|
*/
|
1461
|
-
|
1462
|
-
up: PBPointerEventsResult_PointerCommand;
|
1463
|
-
down: PBPointerEventsResult_PointerCommand;
|
1464
|
-
} | null;
|
1442
|
+
isPressed: (inputAction: InputAction) => boolean;
|
1465
1443
|
/**
|
1466
|
-
*
|
1444
|
+
* @public
|
1445
|
+
* Get the input command info if a pointer event has been emitted in the last tick-update.
|
1467
1446
|
* @param inputAction - the input action to query
|
1468
1447
|
* @param pointerEventType - the pointer event type to query
|
1469
1448
|
* @param entity - the entity to query, ignore for global
|
@@ -1525,25 +1504,6 @@ declare type ISchema<T = any> = {
|
|
1525
1504
|
*/
|
1526
1505
|
declare const log: (...a: any[]) => void;
|
1527
1506
|
|
1528
|
-
/**
|
1529
|
-
* @public
|
1530
|
-
* Make the collision mask with some collider layers
|
1531
|
-
* @param layers a array layers to be assigned
|
1532
|
-
* @returns collisionMask to be used in the MeshCollider field
|
1533
|
-
* @example
|
1534
|
-
* ```ts
|
1535
|
-
* // Physics and Pointer are the defaults
|
1536
|
-
* MeshCollider.create(entity, {
|
1537
|
-
* collisionMask: makeCollisionMask(
|
1538
|
-
* ColliderLayer.Physics,
|
1539
|
-
* ColliderLayer.Pointer
|
1540
|
-
* ),
|
1541
|
-
* box: {}
|
1542
|
-
* })
|
1543
|
-
* ```
|
1544
|
-
*/
|
1545
|
-
declare function makeCollisionMask(...layers: ColliderLayer[]): number;
|
1546
|
-
|
1547
1507
|
/** @public */
|
1548
1508
|
declare const Material: ComponentDefinition<ISchema<PBMaterial>, PBMaterial>;
|
1549
1509
|
|
@@ -149,12 +149,24 @@ declare module "~system/EngineApi" {
|
|
149
149
|
positionChanged?: PositionChangedPayload | undefined;
|
150
150
|
rotationChanged?: RotationChangedPayload | undefined;
|
151
151
|
}
|
152
|
+
export interface CrdtSendToRendererRequest {
|
153
|
+
data: Uint8Array;
|
154
|
+
}
|
155
|
+
export interface CrdtSendToResponse {
|
156
|
+
}
|
157
|
+
export interface CrdtMessageFromRendererRequest {
|
158
|
+
}
|
159
|
+
export interface CrdtMessageFromRendererResponse {
|
160
|
+
data: Uint8Array[];
|
161
|
+
}
|
152
162
|
|
153
163
|
// ########### BLOCK
|
154
164
|
|
155
|
-
// importtype { ManyEntityAction, SendBatchResponse, SubscribeRequest, SubscribeResponse, UnsubscribeRequest, UnsubscribeResponse } from "proto/decentraland/kernel/apis/engine_api.gen";
|
165
|
+
// importtype { ManyEntityAction, SendBatchResponse, SubscribeRequest, SubscribeResponse, UnsubscribeRequest, UnsubscribeResponse, CrdtSendToRendererRequest, CrdtSendToResponse, CrdtMessageFromRendererRequest, CrdtMessageFromRendererResponse } from "proto/decentraland/kernel/apis/engine_api.gen";
|
156
166
|
export function sendBatch(body: ManyEntityAction): Promise<SendBatchResponse>;
|
157
167
|
export function subscribe(body: SubscribeRequest): Promise<SubscribeResponse>;
|
158
168
|
export function unsubscribe(body: UnsubscribeRequest): Promise<UnsubscribeResponse>;
|
169
|
+
export function crdtSendToRenderer(body: CrdtSendToRendererRequest): Promise<CrdtSendToResponse>;
|
170
|
+
export function crdtGetMessageFromRenderer(body: CrdtMessageFromRendererRequest): Promise<CrdtMessageFromRendererResponse>;
|
159
171
|
|
160
172
|
}
|
package/types/tsconfig.ecs7.json
CHANGED
@@ -1,20 +0,0 @@
|
|
1
|
-
declare module "~system/ExperimentalApi" {
|
2
|
-
|
3
|
-
export interface SendToRendererRequest {
|
4
|
-
data: Uint8Array;
|
5
|
-
}
|
6
|
-
export interface SendToResponse {
|
7
|
-
}
|
8
|
-
export interface MessageFromRendererRequest {
|
9
|
-
}
|
10
|
-
export interface MessageFromRendererResponse {
|
11
|
-
data: Uint8Array[];
|
12
|
-
}
|
13
|
-
|
14
|
-
// ########### BLOCK
|
15
|
-
|
16
|
-
// importtype { SendToRendererRequest, SendToResponse, MessageFromRendererRequest, MessageFromRendererResponse } from "proto/decentraland/kernel/apis/experimental_api.gen";
|
17
|
-
export function sendToRenderer(body: SendToRendererRequest): Promise<SendToResponse>;
|
18
|
-
export function messageFromRenderer(body: MessageFromRendererRequest): Promise<MessageFromRendererResponse>;
|
19
|
-
|
20
|
-
}
|