@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.
package/dist/alpha.d.ts CHANGED
@@ -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 = {
@@ -2804,6 +2970,42 @@ export declare interface MaterialComponentDefinitionExtended extends LastWriteWi
2804
2970
  * @param material - the PBR data for this material
2805
2971
  */
2806
2972
  setPbrMaterial: (entity: Entity, material: PBMaterial_PbrMaterial) => void;
2973
+ /**
2974
+ * Get a readonly flattened accessor for the material's properties.
2975
+ * Simplifies reading material properties without navigating nested unions.
2976
+ * Works for both PBR and Unlit materials.
2977
+ * Throws if the entity does not have a Material component.
2978
+ * @param entity - Entity with the Material component
2979
+ * @returns A readonly accessor object with direct access to material properties
2980
+ *
2981
+ */
2982
+ getFlat: (entity: Entity) => ReadonlyFlatMaterial;
2983
+ /**
2984
+ * Get a readonly flattened accessor for the material's properties, or null if the entity
2985
+ * does not have a Material component.
2986
+ * @param entity - Entity to check for Material component
2987
+ * @returns A readonly accessor object, or null if no Material component exists
2988
+ *
2989
+ */
2990
+ getFlatOrNull: (entity: Entity) => ReadonlyFlatMaterial | null;
2991
+ /**
2992
+ * Get a mutable flattened accessor for the material's properties.
2993
+ * Simplifies reading/writing material properties without navigating nested unions.
2994
+ * Works for both PBR and Unlit materials.
2995
+ * Throws if the entity does not have a Material component.
2996
+ * @param entity - Entity with the Material component
2997
+ * @returns A mutable accessor object with direct access to material properties
2998
+ *
2999
+ */
3000
+ getFlatMutable: (entity: Entity) => FlatMaterial;
3001
+ /**
3002
+ * Get a mutable flattened accessor for the material's properties, or null if the entity
3003
+ * does not have a Material component.
3004
+ * @param entity - Entity to check for Material component
3005
+ * @returns A mutable accessor object, or null if no Material component exists
3006
+ *
3007
+ */
3008
+ getFlatMutableOrNull: (entity: Entity) => FlatMaterial | null;
2807
3009
  }
2808
3010
 
2809
3011
  /**
@@ -5112,6 +5314,29 @@ export declare namespace PBPlayerIdentityData {
5112
5314
  *
5113
5315
  * It also supports simple visual feedback when interactions occur, by showing floating text.
5114
5316
  * More sophisticated feedback requires the use of other components.
5317
+ *
5318
+ * Distance rules
5319
+ * --------------
5320
+ * PointerEvents can enforce interaction range using two independent distance checks:
5321
+ *
5322
+ * - Camera distance (`max_distance`): distance from the active camera to the target entity.
5323
+ * - Player distance (`max_player_distance`): distance from the avatar/player position to the target entity.
5324
+ *
5325
+ * How the interaction checks are combined:
5326
+ *
5327
+ * 1) Only `max_distance` is present
5328
+ * - The interaction is allowed only if the camera distance is <= `max_distance`.
5329
+ *
5330
+ * 2) Only `max_player_distance` is present
5331
+ * - The interaction is allowed only if the player distance is <= `max_player_distance`.
5332
+ *
5333
+ * 3) Both `max_distance` and `max_player_distance` are present
5334
+ * - The interaction is allowed if ANY of the checks passes (OR logic):
5335
+ * (camera distance <= `max_distance`) OR (player distance <= `max_player_distance`).
5336
+ *
5337
+ * 4) Neither `max_distance` nor `max_player_distance` is present
5338
+ * - The system behaves as if `max_distance` were set to its default value (10),
5339
+ * i.e., it uses the camera distance check with a threshold of 10.
5115
5340
  */
5116
5341
  /**
5117
5342
  * @public
@@ -5161,6 +5386,8 @@ export declare interface PBPointerEvents_Info {
5161
5386
  showFeedback?: boolean | undefined;
5162
5387
  /** enable or disable hover highlight (default true) */
5163
5388
  showHighlight?: boolean | undefined;
5389
+ /** range of interaction from the avatar's position (default 0) */
5390
+ maxPlayerDistance?: number | undefined;
5164
5391
  }
5165
5392
 
5166
5393
  /**
@@ -7021,6 +7248,90 @@ export declare type ReadonlyComponentSchema<T extends [ComponentDefinition<unkno
7021
7248
  [K in keyof T]: T[K] extends ComponentDefinition<unknown> ? ReturnType<T[K]['get']> : never;
7022
7249
  };
7023
7250
 
7251
+ /**
7252
+ * Readonly flattened material interface for read-only property access
7253
+ * @public
7254
+ */
7255
+ export declare interface ReadonlyFlatMaterial {
7256
+ /**
7257
+ * Access to the main texture properties (works for both PBR and Unlit materials)
7258
+ */
7259
+ readonly texture: ReadonlyFlatTexture;
7260
+ /**
7261
+ * Access to the alpha texture properties (works for both PBR and Unlit materials)
7262
+ */
7263
+ readonly alphaTexture: ReadonlyFlatTexture;
7264
+ /**
7265
+ * Access to the emissive texture properties (PBR only - returns undefined for Unlit materials)
7266
+ */
7267
+ readonly emissiveTexture: ReadonlyFlatTexture | undefined;
7268
+ /**
7269
+ * Access to the bump/normal texture properties (PBR only - returns undefined for Unlit materials)
7270
+ */
7271
+ readonly bumpTexture: ReadonlyFlatTexture | undefined;
7272
+ /**
7273
+ * Alpha test threshold (0-1). Default: 0.5
7274
+ */
7275
+ readonly alphaTest: number | undefined;
7276
+ /**
7277
+ * Whether the material casts shadows. Default: true
7278
+ */
7279
+ readonly castShadows: boolean | undefined;
7280
+ /**
7281
+ * Albedo/base color (PBR only). Default: white
7282
+ */
7283
+ readonly albedoColor: PBColor4 | undefined;
7284
+ /**
7285
+ * Emissive color (PBR only). Default: black
7286
+ */
7287
+ readonly emissiveColor: PBColor3 | undefined;
7288
+ /**
7289
+ * Reflectivity color (PBR only). Default: white
7290
+ */
7291
+ readonly reflectivityColor: PBColor3 | undefined;
7292
+ /**
7293
+ * Transparency mode (PBR only). Default: MTM_AUTO
7294
+ */
7295
+ readonly transparencyMode: MaterialTransparencyMode | undefined;
7296
+ /**
7297
+ * Metallic value 0-1 (PBR only). Default: 0.5
7298
+ */
7299
+ readonly metallic: number | undefined;
7300
+ /**
7301
+ * Roughness value 0-1 (PBR only). Default: 0.5
7302
+ */
7303
+ readonly roughness: number | undefined;
7304
+ /**
7305
+ * Specular intensity (PBR only). Default: 1
7306
+ */
7307
+ readonly specularIntensity: number | undefined;
7308
+ /**
7309
+ * Emissive intensity (PBR only). Default: 2
7310
+ */
7311
+ readonly emissiveIntensity: number | undefined;
7312
+ /**
7313
+ * Direct light intensity (PBR only). Default: 1
7314
+ */
7315
+ readonly directIntensity: number | undefined;
7316
+ /**
7317
+ * Diffuse color (Unlit only). Default: white
7318
+ */
7319
+ readonly diffuseColor: PBColor4 | undefined;
7320
+ }
7321
+
7322
+ /**
7323
+ * Readonly flattened texture interface for read-only property access
7324
+ * @public
7325
+ */
7326
+ export declare interface ReadonlyFlatTexture {
7327
+ /** Path to the texture file */
7328
+ readonly src: string | undefined;
7329
+ /** Texture wrapping behavior */
7330
+ readonly wrapMode: TextureWrapMode | undefined;
7331
+ /** Texture filtering mode */
7332
+ readonly filterMode: TextureFilterMode | undefined;
7333
+ }
7334
+
7024
7335
  /**
7025
7336
  * @public
7026
7337
  */
@@ -7687,6 +7998,79 @@ export declare const enum TextWrap {
7687
7998
  TW_NO_WRAP = 1
7688
7999
  }
7689
8000
 
8001
+ export declare type TimerCallback = () => void;
8002
+
8003
+ export declare type TimerId = number;
8004
+
8005
+ export declare type Timers = {
8006
+ /**
8007
+ * Delays the execution of a function by a given amount of milliseconds.
8008
+ *
8009
+ * @param callback - The function to execute after the delay
8010
+ * @param ms - The delay in milliseconds
8011
+ * @returns A TimerId that can be used to cancel the timeout
8012
+ *
8013
+ * @example
8014
+ * ```ts
8015
+ * const timeoutId = timers.setTimeout(() => {
8016
+ * console.log('1 second passed')
8017
+ * }, 1000)
8018
+ * ```
8019
+ */
8020
+ setTimeout(callback: TimerCallback, ms: number): TimerId;
8021
+ /**
8022
+ * Cancels a timeout previously established by setTimeout.
8023
+ *
8024
+ * @param timerId - The TimerId returned by setTimeout
8025
+ *
8026
+ * @example
8027
+ * ```ts
8028
+ * const timeoutId = timers.setTimeout(() => {
8029
+ * console.log('This will not run')
8030
+ * }, 1000)
8031
+ *
8032
+ * timers.clearTimeout(timeoutId)
8033
+ * ```
8034
+ */
8035
+ clearTimeout(timerId: TimerId): void;
8036
+ /**
8037
+ * Repeatedly executes a function at specified intervals.
8038
+ *
8039
+ * @param callback - The function to execute at each interval
8040
+ * @param ms - The interval in milliseconds
8041
+ * @returns A TimerId that can be used to cancel the interval
8042
+ *
8043
+ * @example
8044
+ * ```ts
8045
+ * const intervalId = timers.setInterval(() => {
8046
+ * console.log('Printing this every 1 second')
8047
+ * }, 1000)
8048
+ * ```
8049
+ */
8050
+ setInterval(callback: TimerCallback, ms: number): TimerId;
8051
+ /**
8052
+ * Cancels an interval previously established by setInterval.
8053
+ *
8054
+ * @param timerId - The TimerId returned by setInterval
8055
+ *
8056
+ * @example
8057
+ * ```ts
8058
+ * const intervalId = timers.setInterval(() => {
8059
+ * console.log('This will stop')
8060
+ * }, 1000)
8061
+ *
8062
+ * timers.clearInterval(intervalId)
8063
+ * ```
8064
+ */
8065
+ clearInterval(timerId: TimerId): void;
8066
+ };
8067
+
8068
+ /**
8069
+ * @public
8070
+ * Timer utilities for delayed and repeated execution.
8071
+ */
8072
+ export declare const timers: Timers;
8073
+
7690
8074
  /**
7691
8075
  * Constant used to convert a value to gamma space
7692
8076
  * @public
@@ -9032,6 +9416,9 @@ export declare interface VirtualCameraComponentDefinitionExtended extends LastWr
9032
9416
  /** @public */
9033
9417
  export declare const VisibilityComponent: LastWriteWinElementSetComponentDefinition<PBVisibilityComponent>;
9034
9418
 
9419
+ /** @public Engine type for world transform functions */
9420
+ export declare type WorldTransformEngine = Pick<IEngine, 'getEntitiesWith' | 'defineComponentFromSchema' | 'PlayerEntity'>;
9421
+
9035
9422
  /**
9036
9423
  * @public
9037
9424
  */