@dcl/sdk 7.0.0-3008112906.commit-524d1bd → 7.0.0-3015711272.commit-6716e5a

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.
@@ -0,0 +1,28 @@
1
+ syntax = "proto3";
2
+
3
+ import "common/id.proto";
4
+ option (ecs_component_id) = 1062;
5
+ import "common/ActionButton.proto";
6
+
7
+ enum PointerEventType {
8
+ UP = 0;
9
+ DOWN = 1;
10
+ HOVER_ENTER = 2;
11
+ HOVER_LEAVE = 3;
12
+ }
13
+
14
+ message PBPointerEvents {
15
+ message Info {
16
+ optional ActionButton button = 1; // default=ActionButton.ANY
17
+ optional string hover_text = 2; // default='Interact'
18
+ optional float max_distance = 3; // default=10
19
+ optional bool show_feedback = 4; // default=true
20
+ }
21
+
22
+ message Entry {
23
+ PointerEventType eventType = 1;
24
+ Info eventInfo = 2;
25
+ }
26
+
27
+ repeated Entry pointerEvents = 1;
28
+ }
@@ -0,0 +1,22 @@
1
+ syntax = "proto3";
2
+
3
+ import "common/id.proto";
4
+ import "RaycastResult.proto";
5
+ import "PointerEvents.proto";
6
+ option (ecs_component_id) = 1063;
7
+ import "common/ActionButton.proto";
8
+
9
+ // the renderer will set this component to the root entity once per frame with all the events
10
+ message PBPointerEventsResult {
11
+ // a list of the last N pointer commands (from the engine)
12
+ repeated PointerCommand commands = 1;
13
+
14
+ // this message represents a pointer event, used both for UP and DOWN actions
15
+ message PointerCommand {
16
+ ActionButton button = 1; // identifier of the input
17
+ RaycastHit hit = 2;
18
+ PointerEventType state = 4;
19
+ int32 timestamp = 5; // could be a Lamport timestamp
20
+ optional float analog = 6; // if the input is analog then we store it here
21
+ }
22
+ }
@@ -0,0 +1,23 @@
1
+ syntax = "proto3";
2
+
3
+ import "common/id.proto";
4
+ option (ecs_component_id) = 1064;
5
+ import "common/Vector3.proto";
6
+
7
+ message PBRaycastResult {
8
+ int32 timestamp = 1;
9
+ Vector3 origin = 2;
10
+ Vector3 direction = 3;
11
+ repeated RaycastHit hits = 4;
12
+ }
13
+
14
+ // Position will be relative to the scene
15
+ message RaycastHit {
16
+ Vector3 position = 1;
17
+ Vector3 origin = 2;
18
+ Vector3 direction = 3;
19
+ Vector3 normal_hit = 4;
20
+ float length = 5;
21
+ optional string mesh_name = 6;
22
+ optional int64 entity_id = 7;
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/sdk",
3
- "version": "7.0.0-3008112906.commit-524d1bd",
3
+ "version": "7.0.0-3015711272.commit-6716e5a",
4
4
  "description": "",
5
5
  "main": "dist/src/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -27,8 +27,8 @@
27
27
  "src/cli/**/*.js"
28
28
  ],
29
29
  "dependencies": {
30
- "@dcl/amd": "6.11.7-3008112906.commit-524d1bd",
31
- "@dcl/build-ecs": "6.11.7-3008112906.commit-524d1bd",
30
+ "@dcl/amd": "6.11.7-3015711272.commit-6716e5a",
31
+ "@dcl/build-ecs": "6.11.7-3015711272.commit-6716e5a",
32
32
  "@dcl/kernel": "1.0.0-2994874542.commit-c3ae489",
33
33
  "@dcl/posix": "^1.0.4",
34
34
  "@dcl/schemas": "4.8.0",
@@ -38,5 +38,5 @@
38
38
  "ignore": "^5.1.8"
39
39
  },
40
40
  "minCliVersion": "3.10.2",
41
- "commit": "524d1bd3c7f72f177f73f7cf5298aaaf1d79f4c7"
41
+ "commit": "6716e5a85afe478f7187bd7a3e3825035172462c"
42
42
  }
@@ -247,8 +247,14 @@ declare namespace Components {
247
247
  /** @public */
248
248
  const PlaneShape: ComponentDefinition<ISchema<PBPlaneShape>, PBPlaneShape>;
249
249
  /** @public */
250
+ const PointerEvents: ComponentDefinition<ISchema<PBPointerEvents>, PBPointerEvents>;
251
+ /** @public */
252
+ const PointerEventsResult: ComponentDefinition<ISchema<PBPointerEventsResult>, PBPointerEventsResult>;
253
+ /** @public */
250
254
  const PointerLock: ComponentDefinition<ISchema<PBPointerLock>, PBPointerLock>;
251
255
  /** @public */
256
+ const RaycastResult: ComponentDefinition<ISchema<PBRaycastResult>, PBRaycastResult>;
257
+ /** @public */
252
258
  const SphereShape: ComponentDefinition<ISchema<PBSphereShape>, PBSphereShape>;
253
259
  /** @public */
254
260
  const TextShape: ComponentDefinition<ISchema<PBTextShape>, PBTextShape>;
@@ -480,7 +486,10 @@ declare function defineSdkComponents(engine: PreEngine): {
480
486
  OnPointerUp: ComponentDefinition<ISchema<PBOnPointerUp>, PBOnPointerUp>;
481
487
  OnPointerUpResult: ComponentDefinition<ISchema<PBOnPointerUpResult>, PBOnPointerUpResult>;
482
488
  PlaneShape: ComponentDefinition<ISchema<PBPlaneShape>, PBPlaneShape>;
489
+ PointerEvents: ComponentDefinition<ISchema<PBPointerEvents>, PBPointerEvents>;
490
+ PointerEventsResult: ComponentDefinition<ISchema<PBPointerEventsResult>, PBPointerEventsResult>;
483
491
  PointerLock: ComponentDefinition<ISchema<PBPointerLock>, PBPointerLock>;
492
+ RaycastResult: ComponentDefinition<ISchema<PBRaycastResult>, PBRaycastResult>;
484
493
  SphereShape: ComponentDefinition<ISchema<PBSphereShape>, PBSphereShape>;
485
494
  TextShape: ComponentDefinition<ISchema<PBTextShape>, PBTextShape>;
486
495
  UiText: ComponentDefinition<ISchema<PBUiText>, PBUiText>;
@@ -610,7 +619,7 @@ declare type IEngine = {
610
619
  *
611
620
  * ```
612
621
  */
613
- defineComponent<T extends Spec, ConstructorType = Partial<Result<T>>>(spec: T, componentId: number, constructorDefault?: Partial<Result<T>>): ComponentDefinition<ISchema<Result<T>>, ConstructorType>;
622
+ defineComponent<T extends Spec, ConstructorType = Partial<Result<T>>>(spec: T, componentId: number, constructorDefault?: ConstructorType): ComponentDefinition<ISchema<Result<T>>, Partial<Result<T>>>;
614
623
  /**
615
624
  * Define a component and add it to the engine.
616
625
  * @param spec An object with schema fields
@@ -646,6 +655,7 @@ declare type IEngine = {
646
655
  * ```
647
656
  */
648
657
  getEntitiesWith<T extends [ComponentDefinition, ...ComponentDefinition[]]>(...components: T): Iterable<[Entity, ...ReadonlyComponentSchema<T>]>;
658
+ RootEntity: Entity;
649
659
  baseComponents: SdkComponents;
650
660
  };
651
661
 
@@ -700,6 +710,17 @@ declare interface ISize {
700
710
  height: number;
701
711
  }
702
712
 
713
+ /**
714
+ * Check if a pointer event has been emited in the last tick-update.
715
+ * @param entity the entity to query, for global clicks use `engine.RootEntity`
716
+ * @param actionButton
717
+ * @param pointerEventType
718
+ * @returns
719
+ */
720
+ declare function isPointerEventActive(entity: Entity, actionButton: ActionButton, pointerEventType: PointerEventType): boolean;
721
+
722
+ declare function isPointerEventActiveGenerator(engine: IEngine): (entity: Entity, actionButton: ActionButton, pointerEventType: PointerEventType) => boolean;
723
+
703
724
  declare const log: (...a: any[]) => void;
704
725
 
705
726
  /** @public */
@@ -2072,10 +2093,55 @@ declare interface PBPlaneShape {
2072
2093
  uvs: number[];
2073
2094
  }
2074
2095
 
2096
+ declare interface PBPointerEvents {
2097
+ pointerEvents: PBPointerEvents_Entry[];
2098
+ }
2099
+
2100
+ declare interface PBPointerEvents_Entry {
2101
+ eventType: PointerEventType;
2102
+ eventInfo: PBPointerEvents_Info | undefined;
2103
+ }
2104
+
2105
+ declare interface PBPointerEvents_Info {
2106
+ /** default=ActionButton.ANY */
2107
+ button?: ActionButton | undefined;
2108
+ /** default='Interact' */
2109
+ hoverText?: string | undefined;
2110
+ /** default=10 */
2111
+ maxDistance?: number | undefined;
2112
+ /** default=true */
2113
+ showFeedback?: boolean | undefined;
2114
+ }
2115
+
2116
+ /** the renderer will set this component to the root entity once per frame with all the events */
2117
+ declare interface PBPointerEventsResult {
2118
+ /** a list of the last N pointer commands (from the engine) */
2119
+ commands: PBPointerEventsResult_PointerCommand[];
2120
+ }
2121
+
2122
+ /** this message represents a pointer event, used both for UP and DOWN actions */
2123
+ declare interface PBPointerEventsResult_PointerCommand {
2124
+ /** identifier of the input */
2125
+ button: ActionButton;
2126
+ hit: RaycastHit | undefined;
2127
+ state: PointerEventType;
2128
+ /** could be a Lamport timestamp */
2129
+ timestamp: number;
2130
+ /** if the input is analog then we store it here */
2131
+ analog?: number | undefined;
2132
+ }
2133
+
2075
2134
  declare interface PBPointerLock {
2076
2135
  isPointerLocked: boolean;
2077
2136
  }
2078
2137
 
2138
+ declare interface PBRaycastResult {
2139
+ timestamp: number;
2140
+ origin: Vector3_2 | undefined;
2141
+ direction: Vector3_2 | undefined;
2142
+ hits: RaycastHit[];
2143
+ }
2144
+
2079
2145
  declare interface PBSphereShape {
2080
2146
  /** @deprecated use MeshCollider instead https://github.com/decentraland/sdk/issues/366 */
2081
2147
  withCollisions?: boolean | undefined;
@@ -2244,6 +2310,20 @@ declare namespace Plane {
2244
2310
  /** @public */
2245
2311
  declare const PlaneShape: ComponentDefinition<ISchema<PBPlaneShape>, PBPlaneShape>;
2246
2312
 
2313
+ /** @public */
2314
+ declare const PointerEvents: ComponentDefinition<ISchema<PBPointerEvents>, PBPointerEvents>;
2315
+
2316
+ /** @public */
2317
+ declare const PointerEventsResult: ComponentDefinition<ISchema<PBPointerEventsResult>, PBPointerEventsResult>;
2318
+
2319
+ declare const enum PointerEventType {
2320
+ UP = 0,
2321
+ DOWN = 1,
2322
+ HOVER_ENTER = 2,
2323
+ HOVER_LEAVE = 3,
2324
+ UNRECOGNIZED = -1
2325
+ }
2326
+
2247
2327
  /** @public */
2248
2328
  declare const PointerLock: ComponentDefinition<ISchema<PBPointerLock>, PBPointerLock>;
2249
2329
 
@@ -2442,6 +2522,20 @@ declare namespace Quaternion {
2442
2522
  */
2443
2523
  declare const RAD2DEG: number;
2444
2524
 
2525
+ /** Position will be relative to the scene */
2526
+ declare interface RaycastHit {
2527
+ position: Vector3_2 | undefined;
2528
+ origin: Vector3_2 | undefined;
2529
+ direction: Vector3_2 | undefined;
2530
+ normalHit: Vector3_2 | undefined;
2531
+ length: number;
2532
+ meshName?: string | undefined;
2533
+ entityId?: number | undefined;
2534
+ }
2535
+
2536
+ /** @public */
2537
+ declare const RaycastResult: ComponentDefinition<ISchema<PBRaycastResult>, PBRaycastResult>;
2538
+
2445
2539
  /**
2446
2540
  * @public
2447
2541
  */
@@ -2815,6 +2909,16 @@ declare interface Vector3_2 {
2815
2909
  /** @public */
2816
2910
  declare const VisibilityComponent: ComponentDefinition<ISchema<PBVisibilityComponent>, PBVisibilityComponent>;
2817
2911
 
2912
+ /**
2913
+ * Check if an entity emitted a clicked event
2914
+ * @param entity the entity to query, for global clicks use `engine.RootEntity`
2915
+ * @param actionButton
2916
+ * @returns true if the entity was clicked in the last tick-update
2917
+ */
2918
+ declare function wasEntityClicked(entity: Entity, actionButton: ActionButton): boolean;
2919
+
2920
+ declare function wasEntityClickedGenerator(engine: IEngine): (entity: Entity, actionButton: ActionButton) => boolean;
2921
+
2818
2922
  declare namespace WireMessage {
2819
2923
  enum Enum {
2820
2924
  RESERVED = 0,