@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.
@@ -247,8 +247,14 @@ export 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 @@ export 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 @@ export 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 @@ export 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
+ export declare function isPointerEventActive(entity: Entity, actionButton: ActionButton, pointerEventType: PointerEventType): boolean;
721
+
722
+ export declare function isPointerEventActiveGenerator(engine: IEngine): (entity: Entity, actionButton: ActionButton, pointerEventType: PointerEventType) => boolean;
723
+
703
724
  export 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
  export declare const PlaneShape: ComponentDefinition<ISchema<PBPlaneShape>, PBPlaneShape>;
2246
2312
 
2313
+ /** @public */
2314
+ export declare const PointerEvents: ComponentDefinition<ISchema<PBPointerEvents>, PBPointerEvents>;
2315
+
2316
+ /** @public */
2317
+ export 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
  export declare const PointerLock: ComponentDefinition<ISchema<PBPointerLock>, PBPointerLock>;
2249
2329
 
@@ -2442,6 +2522,20 @@ export declare namespace Quaternion {
2442
2522
  */
2443
2523
  export 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
+ export 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
  export 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
+ export declare function wasEntityClicked(entity: Entity, actionButton: ActionButton): boolean;
2919
+
2920
+ export declare function wasEntityClickedGenerator(engine: IEngine): (entity: Entity, actionButton: ActionButton) => boolean;
2921
+
2818
2922
  declare namespace WireMessage {
2819
2923
  enum Enum {
2820
2924
  RESERVED = 0,