@dcl/playground-assets 7.18.2-21450088960.commit-3c16004 → 7.18.2-21457748765.commit-7ae2e38

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.
@@ -1619,6 +1619,27 @@ export declare function createPointerEventsSystem(engine: IEngine, inputSystem:
1619
1619
  */
1620
1620
  export declare function createReactBasedUiSystem(engine: IEngine, pointerSystem: PointerEventsSystem): ReactBasedUiSystem;
1621
1621
 
1622
+ /**
1623
+ * Creates a timer system bound to a specific engine instance.
1624
+ *
1625
+ * @param targetEngine - The engine instance to bind timers to
1626
+ * @returns A Timers object with setTimeout, clearTimeout, setInterval, and clearInterval methods
1627
+ *
1628
+ * @example
1629
+ * ```ts
1630
+ * import { Engine } from '@dcl/sdk/ecs'
1631
+ * import { createTimers } from '@dcl/sdk/ecs'
1632
+ *
1633
+ * const engine = Engine()
1634
+ * const timers = createTimers(engine)
1635
+ *
1636
+ * timers.setTimeout(() => console.log('done'), 1000)
1637
+ * ```
1638
+ *
1639
+ * @public
1640
+ */
1641
+ export declare function createTimers(targetEngine: IEngine): Timers;
1642
+
1622
1643
  /**
1623
1644
  * @public
1624
1645
  * @returns tween helper to be used on the scene
@@ -1983,6 +2004,7 @@ export declare type EventSystemOptions = {
1983
2004
  maxDistance?: number;
1984
2005
  showFeedback?: boolean;
1985
2006
  showHighlight?: boolean;
2007
+ maxPlayerDistance?: number;
1986
2008
  };
1987
2009
 
1988
2010
  /**
@@ -1999,6 +2021,90 @@ export declare type ExcludeUndefined<T> = {
1999
2021
  */
2000
2022
  export declare const executeTask: (task: Task<unknown>) => void;
2001
2023
 
2024
+ /**
2025
+ * Flattened material interface for simplified property access
2026
+ * @public
2027
+ */
2028
+ export declare interface FlatMaterial {
2029
+ /**
2030
+ * Access to the main texture properties (works for both PBR and Unlit materials)
2031
+ */
2032
+ readonly texture: FlatTexture;
2033
+ /**
2034
+ * Access to the alpha texture properties (works for both PBR and Unlit materials)
2035
+ */
2036
+ readonly alphaTexture: FlatTexture;
2037
+ /**
2038
+ * Access to the emissive texture properties (PBR only - returns undefined for Unlit materials)
2039
+ */
2040
+ readonly emissiveTexture: FlatTexture | undefined;
2041
+ /**
2042
+ * Access to the bump/normal texture properties (PBR only - returns undefined for Unlit materials)
2043
+ */
2044
+ readonly bumpTexture: FlatTexture | undefined;
2045
+ /**
2046
+ * Alpha test threshold (0-1). Default: 0.5
2047
+ */
2048
+ alphaTest: number | undefined;
2049
+ /**
2050
+ * Whether the material casts shadows. Default: true
2051
+ */
2052
+ castShadows: boolean | undefined;
2053
+ /**
2054
+ * Albedo/base color (PBR only). Default: white
2055
+ */
2056
+ albedoColor: PBColor4 | undefined;
2057
+ /**
2058
+ * Emissive color (PBR only). Default: black
2059
+ */
2060
+ emissiveColor: PBColor3 | undefined;
2061
+ /**
2062
+ * Reflectivity color (PBR only). Default: white
2063
+ */
2064
+ reflectivityColor: PBColor3 | undefined;
2065
+ /**
2066
+ * Transparency mode (PBR only). Default: MTM_AUTO
2067
+ */
2068
+ transparencyMode: MaterialTransparencyMode | undefined;
2069
+ /**
2070
+ * Metallic value 0-1 (PBR only). Default: 0.5
2071
+ */
2072
+ metallic: number | undefined;
2073
+ /**
2074
+ * Roughness value 0-1 (PBR only). Default: 0.5
2075
+ */
2076
+ roughness: number | undefined;
2077
+ /**
2078
+ * Specular intensity (PBR only). Default: 1
2079
+ */
2080
+ specularIntensity: number | undefined;
2081
+ /**
2082
+ * Emissive intensity (PBR only). Default: 2
2083
+ */
2084
+ emissiveIntensity: number | undefined;
2085
+ /**
2086
+ * Direct light intensity (PBR only). Default: 1
2087
+ */
2088
+ directIntensity: number | undefined;
2089
+ /**
2090
+ * Diffuse color (Unlit only). Default: white
2091
+ */
2092
+ diffuseColor: PBColor4 | undefined;
2093
+ }
2094
+
2095
+ /**
2096
+ * Flattened texture interface for simplified property access
2097
+ * @public
2098
+ */
2099
+ export declare interface FlatTexture {
2100
+ /** Path to the texture file */
2101
+ src: string | undefined;
2102
+ /** Texture wrapping behavior */
2103
+ wrapMode: TextureWrapMode | undefined;
2104
+ /** Texture filtering mode */
2105
+ filterMode: TextureFilterMode | undefined;
2106
+ }
2107
+
2002
2108
  /**
2003
2109
  * @public
2004
2110
  */
@@ -2053,6 +2159,66 @@ export declare function getCompositeRootComponent(engine: IEngine): LastWriteWin
2053
2159
 
2054
2160
  export declare const getDefaultOpts: (opts?: Partial<EventSystemOptions>) => EventSystemOptions;
2055
2161
 
2162
+ /**
2163
+ * Get all entities that have the given entity as their parent
2164
+ * @public
2165
+ * @param engine - the engine running the entities
2166
+ * @param parent - the parent entity to find children for
2167
+ * @returns An array of entities that have the given parent
2168
+ *
2169
+ * Example:
2170
+ * ```ts
2171
+ * const children = getEntitiesWithParent(engine, myEntity)
2172
+ * for (const child of children) {
2173
+ * // process each child entity
2174
+ * }
2175
+ * ```
2176
+ */
2177
+ export declare function getEntitiesWithParent(engine: Pick<IEngine, 'getEntitiesWith' | 'defineComponentFromSchema'>, parent: Entity): Entity[];
2178
+
2179
+ /**
2180
+ * Get the world position of an entity, taking into account the full parent hierarchy.
2181
+ * This computes the world-space position by accumulating all parent transforms
2182
+ * (position, rotation, and scale).
2183
+ *
2184
+ * When the entity has AvatarAttach and Transform, the renderer updates the Transform
2185
+ * with avatar-relative values (including the exact anchor point offset for hand, head, etc.).
2186
+ * This function combines the player's transform with those values to compute the world position.
2187
+ *
2188
+ * @public
2189
+ * @param engine - the engine running the entities
2190
+ * @param entity - the entity to get the world position for
2191
+ * @returns The entity's position in world space. Returns `{x: 0, y: 0, z: 0}` if the entity has no Transform.
2192
+ *
2193
+ * Example:
2194
+ * ```ts
2195
+ * const worldPos = getWorldPosition(engine, childEntity)
2196
+ * console.log(`World position: ${worldPos.x}, ${worldPos.y}, ${worldPos.z}`)
2197
+ * ```
2198
+ */
2199
+ export declare function getWorldPosition(engine: WorldTransformEngine, entity: Entity): Vector3Type;
2200
+
2201
+ /**
2202
+ * Get the world rotation of an entity, taking into account the full parent hierarchy.
2203
+ * This computes the world-space rotation by combining all parent rotations.
2204
+ *
2205
+ * When the entity has AvatarAttach and Transform, the renderer updates the Transform
2206
+ * with avatar-relative values (including the exact anchor point rotation for hand, head, etc.).
2207
+ * This function combines the player's rotation with those values to compute the world rotation.
2208
+ *
2209
+ * @public
2210
+ * @param engine - the engine running the entities
2211
+ * @param entity - the entity to get the world rotation for
2212
+ * @returns The entity's rotation in world space as a quaternion. Returns identity quaternion `{x: 0, y: 0, z: 0, w: 1}` if the entity has no Transform.
2213
+ *
2214
+ * Example:
2215
+ * ```ts
2216
+ * const worldRot = getWorldRotation(engine, childEntity)
2217
+ * console.log(`World rotation: ${worldRot.x}, ${worldRot.y}, ${worldRot.z}, ${worldRot.w}`)
2218
+ * ```
2219
+ */
2220
+ export declare function getWorldRotation(engine: WorldTransformEngine, entity: Entity): QuaternionType;
2221
+
2056
2222
  export declare type GlobalDirectionRaycastOptions = RaycastSystemOptions & GlobalDirectionRaycastSystemOptions;
2057
2223
 
2058
2224
  export declare type GlobalDirectionRaycastSystemOptions = {
@@ -2795,6 +2961,42 @@ export declare interface MaterialComponentDefinitionExtended extends LastWriteWi
2795
2961
  * @param material - the PBR data for this material
2796
2962
  */
2797
2963
  setPbrMaterial: (entity: Entity, material: PBMaterial_PbrMaterial) => void;
2964
+ /**
2965
+ * Get a readonly flattened accessor for the material's properties.
2966
+ * Simplifies reading material properties without navigating nested unions.
2967
+ * Works for both PBR and Unlit materials.
2968
+ * Throws if the entity does not have a Material component.
2969
+ * @param entity - Entity with the Material component
2970
+ * @returns A readonly accessor object with direct access to material properties
2971
+ *
2972
+ */
2973
+ getFlat: (entity: Entity) => ReadonlyFlatMaterial;
2974
+ /**
2975
+ * Get a readonly flattened accessor for the material's properties, or null if the entity
2976
+ * does not have a Material component.
2977
+ * @param entity - Entity to check for Material component
2978
+ * @returns A readonly accessor object, or null if no Material component exists
2979
+ *
2980
+ */
2981
+ getFlatOrNull: (entity: Entity) => ReadonlyFlatMaterial | null;
2982
+ /**
2983
+ * Get a mutable flattened accessor for the material's properties.
2984
+ * Simplifies reading/writing material properties without navigating nested unions.
2985
+ * Works for both PBR and Unlit materials.
2986
+ * Throws if the entity does not have a Material component.
2987
+ * @param entity - Entity with the Material component
2988
+ * @returns A mutable accessor object with direct access to material properties
2989
+ *
2990
+ */
2991
+ getFlatMutable: (entity: Entity) => FlatMaterial;
2992
+ /**
2993
+ * Get a mutable flattened accessor for the material's properties, or null if the entity
2994
+ * does not have a Material component.
2995
+ * @param entity - Entity to check for Material component
2996
+ * @returns A mutable accessor object, or null if no Material component exists
2997
+ *
2998
+ */
2999
+ getFlatMutableOrNull: (entity: Entity) => FlatMaterial | null;
2798
3000
  }
2799
3001
 
2800
3002
  /**
@@ -5084,6 +5286,29 @@ export declare namespace PBPlayerIdentityData {
5084
5286
  *
5085
5287
  * It also supports simple visual feedback when interactions occur, by showing floating text.
5086
5288
  * More sophisticated feedback requires the use of other components.
5289
+ *
5290
+ * Distance rules
5291
+ * --------------
5292
+ * PointerEvents can enforce interaction range using two independent distance checks:
5293
+ *
5294
+ * - Camera distance (`max_distance`): distance from the active camera to the target entity.
5295
+ * - Player distance (`max_player_distance`): distance from the avatar/player position to the target entity.
5296
+ *
5297
+ * How the interaction checks are combined:
5298
+ *
5299
+ * 1) Only `max_distance` is present
5300
+ * - The interaction is allowed only if the camera distance is <= `max_distance`.
5301
+ *
5302
+ * 2) Only `max_player_distance` is present
5303
+ * - The interaction is allowed only if the player distance is <= `max_player_distance`.
5304
+ *
5305
+ * 3) Both `max_distance` and `max_player_distance` are present
5306
+ * - The interaction is allowed if ANY of the checks passes (OR logic):
5307
+ * (camera distance <= `max_distance`) OR (player distance <= `max_player_distance`).
5308
+ *
5309
+ * 4) Neither `max_distance` nor `max_player_distance` is present
5310
+ * - The system behaves as if `max_distance` were set to its default value (10),
5311
+ * i.e., it uses the camera distance check with a threshold of 10.
5087
5312
  */
5088
5313
  /**
5089
5314
  * @public
@@ -5133,6 +5358,8 @@ export declare interface PBPointerEvents_Info {
5133
5358
  showFeedback?: boolean | undefined;
5134
5359
  /** enable or disable hover highlight (default true) */
5135
5360
  showHighlight?: boolean | undefined;
5361
+ /** range of interaction from the avatar's position (default 0) */
5362
+ maxPlayerDistance?: number | undefined;
5136
5363
  }
5137
5364
 
5138
5365
  /**
@@ -6993,6 +7220,90 @@ export declare type ReadonlyComponentSchema<T extends [ComponentDefinition<unkno
6993
7220
  [K in keyof T]: T[K] extends ComponentDefinition<unknown> ? ReturnType<T[K]['get']> : never;
6994
7221
  };
6995
7222
 
7223
+ /**
7224
+ * Readonly flattened material interface for read-only property access
7225
+ * @public
7226
+ */
7227
+ export declare interface ReadonlyFlatMaterial {
7228
+ /**
7229
+ * Access to the main texture properties (works for both PBR and Unlit materials)
7230
+ */
7231
+ readonly texture: ReadonlyFlatTexture;
7232
+ /**
7233
+ * Access to the alpha texture properties (works for both PBR and Unlit materials)
7234
+ */
7235
+ readonly alphaTexture: ReadonlyFlatTexture;
7236
+ /**
7237
+ * Access to the emissive texture properties (PBR only - returns undefined for Unlit materials)
7238
+ */
7239
+ readonly emissiveTexture: ReadonlyFlatTexture | undefined;
7240
+ /**
7241
+ * Access to the bump/normal texture properties (PBR only - returns undefined for Unlit materials)
7242
+ */
7243
+ readonly bumpTexture: ReadonlyFlatTexture | undefined;
7244
+ /**
7245
+ * Alpha test threshold (0-1). Default: 0.5
7246
+ */
7247
+ readonly alphaTest: number | undefined;
7248
+ /**
7249
+ * Whether the material casts shadows. Default: true
7250
+ */
7251
+ readonly castShadows: boolean | undefined;
7252
+ /**
7253
+ * Albedo/base color (PBR only). Default: white
7254
+ */
7255
+ readonly albedoColor: PBColor4 | undefined;
7256
+ /**
7257
+ * Emissive color (PBR only). Default: black
7258
+ */
7259
+ readonly emissiveColor: PBColor3 | undefined;
7260
+ /**
7261
+ * Reflectivity color (PBR only). Default: white
7262
+ */
7263
+ readonly reflectivityColor: PBColor3 | undefined;
7264
+ /**
7265
+ * Transparency mode (PBR only). Default: MTM_AUTO
7266
+ */
7267
+ readonly transparencyMode: MaterialTransparencyMode | undefined;
7268
+ /**
7269
+ * Metallic value 0-1 (PBR only). Default: 0.5
7270
+ */
7271
+ readonly metallic: number | undefined;
7272
+ /**
7273
+ * Roughness value 0-1 (PBR only). Default: 0.5
7274
+ */
7275
+ readonly roughness: number | undefined;
7276
+ /**
7277
+ * Specular intensity (PBR only). Default: 1
7278
+ */
7279
+ readonly specularIntensity: number | undefined;
7280
+ /**
7281
+ * Emissive intensity (PBR only). Default: 2
7282
+ */
7283
+ readonly emissiveIntensity: number | undefined;
7284
+ /**
7285
+ * Direct light intensity (PBR only). Default: 1
7286
+ */
7287
+ readonly directIntensity: number | undefined;
7288
+ /**
7289
+ * Diffuse color (Unlit only). Default: white
7290
+ */
7291
+ readonly diffuseColor: PBColor4 | undefined;
7292
+ }
7293
+
7294
+ /**
7295
+ * Readonly flattened texture interface for read-only property access
7296
+ * @public
7297
+ */
7298
+ export declare interface ReadonlyFlatTexture {
7299
+ /** Path to the texture file */
7300
+ readonly src: string | undefined;
7301
+ /** Texture wrapping behavior */
7302
+ readonly wrapMode: TextureWrapMode | undefined;
7303
+ /** Texture filtering mode */
7304
+ readonly filterMode: TextureFilterMode | undefined;
7305
+ }
7306
+
6996
7307
  /**
6997
7308
  * @public
6998
7309
  */
@@ -7654,6 +7965,79 @@ export declare const enum TextWrap {
7654
7965
  TW_NO_WRAP = 1
7655
7966
  }
7656
7967
 
7968
+ export declare type TimerCallback = () => void;
7969
+
7970
+ export declare type TimerId = number;
7971
+
7972
+ export declare type Timers = {
7973
+ /**
7974
+ * Delays the execution of a function by a given amount of milliseconds.
7975
+ *
7976
+ * @param callback - The function to execute after the delay
7977
+ * @param ms - The delay in milliseconds
7978
+ * @returns A TimerId that can be used to cancel the timeout
7979
+ *
7980
+ * @example
7981
+ * ```ts
7982
+ * const timeoutId = timers.setTimeout(() => {
7983
+ * console.log('1 second passed')
7984
+ * }, 1000)
7985
+ * ```
7986
+ */
7987
+ setTimeout(callback: TimerCallback, ms: number): TimerId;
7988
+ /**
7989
+ * Cancels a timeout previously established by setTimeout.
7990
+ *
7991
+ * @param timerId - The TimerId returned by setTimeout
7992
+ *
7993
+ * @example
7994
+ * ```ts
7995
+ * const timeoutId = timers.setTimeout(() => {
7996
+ * console.log('This will not run')
7997
+ * }, 1000)
7998
+ *
7999
+ * timers.clearTimeout(timeoutId)
8000
+ * ```
8001
+ */
8002
+ clearTimeout(timerId: TimerId): void;
8003
+ /**
8004
+ * Repeatedly executes a function at specified intervals.
8005
+ *
8006
+ * @param callback - The function to execute at each interval
8007
+ * @param ms - The interval in milliseconds
8008
+ * @returns A TimerId that can be used to cancel the interval
8009
+ *
8010
+ * @example
8011
+ * ```ts
8012
+ * const intervalId = timers.setInterval(() => {
8013
+ * console.log('Printing this every 1 second')
8014
+ * }, 1000)
8015
+ * ```
8016
+ */
8017
+ setInterval(callback: TimerCallback, ms: number): TimerId;
8018
+ /**
8019
+ * Cancels an interval previously established by setInterval.
8020
+ *
8021
+ * @param timerId - The TimerId returned by setInterval
8022
+ *
8023
+ * @example
8024
+ * ```ts
8025
+ * const intervalId = timers.setInterval(() => {
8026
+ * console.log('This will stop')
8027
+ * }, 1000)
8028
+ *
8029
+ * timers.clearInterval(intervalId)
8030
+ * ```
8031
+ */
8032
+ clearInterval(timerId: TimerId): void;
8033
+ };
8034
+
8035
+ /**
8036
+ * @public
8037
+ * Timer utilities for delayed and repeated execution.
8038
+ */
8039
+ export declare const timers: Timers;
8040
+
7657
8041
  /**
7658
8042
  * Constant used to convert a value to gamma space
7659
8043
  * @public
@@ -8999,6 +9383,9 @@ export declare interface VirtualCameraComponentDefinitionExtended extends LastWr
8999
9383
  /** @public */
9000
9384
  export declare const VisibilityComponent: LastWriteWinElementSetComponentDefinition<PBVisibilityComponent>;
9001
9385
 
9386
+ /** @public Engine type for world transform functions */
9387
+ export declare type WorldTransformEngine = Pick<IEngine, 'getEntitiesWith' | 'defineComponentFromSchema' | 'PlayerEntity'>;
9388
+
9002
9389
  /**
9003
9390
  * @public
9004
9391
  */