@dcl/playground-assets 7.18.2-21450088960.commit-3c16004 → 7.18.2-21453292414.commit-1da934f

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
@@ -1999,6 +2020,90 @@ export declare type ExcludeUndefined<T> = {
1999
2020
  */
2000
2021
  export declare const executeTask: (task: Task<unknown>) => void;
2001
2022
 
2023
+ /**
2024
+ * Flattened material interface for simplified property access
2025
+ * @public
2026
+ */
2027
+ export declare interface FlatMaterial {
2028
+ /**
2029
+ * Access to the main texture properties (works for both PBR and Unlit materials)
2030
+ */
2031
+ readonly texture: FlatTexture;
2032
+ /**
2033
+ * Access to the alpha texture properties (works for both PBR and Unlit materials)
2034
+ */
2035
+ readonly alphaTexture: FlatTexture;
2036
+ /**
2037
+ * Access to the emissive texture properties (PBR only - returns undefined for Unlit materials)
2038
+ */
2039
+ readonly emissiveTexture: FlatTexture | undefined;
2040
+ /**
2041
+ * Access to the bump/normal texture properties (PBR only - returns undefined for Unlit materials)
2042
+ */
2043
+ readonly bumpTexture: FlatTexture | undefined;
2044
+ /**
2045
+ * Alpha test threshold (0-1). Default: 0.5
2046
+ */
2047
+ alphaTest: number | undefined;
2048
+ /**
2049
+ * Whether the material casts shadows. Default: true
2050
+ */
2051
+ castShadows: boolean | undefined;
2052
+ /**
2053
+ * Albedo/base color (PBR only). Default: white
2054
+ */
2055
+ albedoColor: PBColor4 | undefined;
2056
+ /**
2057
+ * Emissive color (PBR only). Default: black
2058
+ */
2059
+ emissiveColor: PBColor3 | undefined;
2060
+ /**
2061
+ * Reflectivity color (PBR only). Default: white
2062
+ */
2063
+ reflectivityColor: PBColor3 | undefined;
2064
+ /**
2065
+ * Transparency mode (PBR only). Default: MTM_AUTO
2066
+ */
2067
+ transparencyMode: MaterialTransparencyMode | undefined;
2068
+ /**
2069
+ * Metallic value 0-1 (PBR only). Default: 0.5
2070
+ */
2071
+ metallic: number | undefined;
2072
+ /**
2073
+ * Roughness value 0-1 (PBR only). Default: 0.5
2074
+ */
2075
+ roughness: number | undefined;
2076
+ /**
2077
+ * Specular intensity (PBR only). Default: 1
2078
+ */
2079
+ specularIntensity: number | undefined;
2080
+ /**
2081
+ * Emissive intensity (PBR only). Default: 2
2082
+ */
2083
+ emissiveIntensity: number | undefined;
2084
+ /**
2085
+ * Direct light intensity (PBR only). Default: 1
2086
+ */
2087
+ directIntensity: number | undefined;
2088
+ /**
2089
+ * Diffuse color (Unlit only). Default: white
2090
+ */
2091
+ diffuseColor: PBColor4 | undefined;
2092
+ }
2093
+
2094
+ /**
2095
+ * Flattened texture interface for simplified property access
2096
+ * @public
2097
+ */
2098
+ export declare interface FlatTexture {
2099
+ /** Path to the texture file */
2100
+ src: string | undefined;
2101
+ /** Texture wrapping behavior */
2102
+ wrapMode: TextureWrapMode | undefined;
2103
+ /** Texture filtering mode */
2104
+ filterMode: TextureFilterMode | undefined;
2105
+ }
2106
+
2002
2107
  /**
2003
2108
  * @public
2004
2109
  */
@@ -2053,6 +2158,66 @@ export declare function getCompositeRootComponent(engine: IEngine): LastWriteWin
2053
2158
 
2054
2159
  export declare const getDefaultOpts: (opts?: Partial<EventSystemOptions>) => EventSystemOptions;
2055
2160
 
2161
+ /**
2162
+ * Get all entities that have the given entity as their parent
2163
+ * @public
2164
+ * @param engine - the engine running the entities
2165
+ * @param parent - the parent entity to find children for
2166
+ * @returns An array of entities that have the given parent
2167
+ *
2168
+ * Example:
2169
+ * ```ts
2170
+ * const children = getEntitiesWithParent(engine, myEntity)
2171
+ * for (const child of children) {
2172
+ * // process each child entity
2173
+ * }
2174
+ * ```
2175
+ */
2176
+ export declare function getEntitiesWithParent(engine: Pick<IEngine, 'getEntitiesWith' | 'defineComponentFromSchema'>, parent: Entity): Entity[];
2177
+
2178
+ /**
2179
+ * Get the world position of an entity, taking into account the full parent hierarchy.
2180
+ * This computes the world-space position by accumulating all parent transforms
2181
+ * (position, rotation, and scale).
2182
+ *
2183
+ * When the entity has AvatarAttach and Transform, the renderer updates the Transform
2184
+ * with avatar-relative values (including the exact anchor point offset for hand, head, etc.).
2185
+ * This function combines the player's transform with those values to compute the world position.
2186
+ *
2187
+ * @public
2188
+ * @param engine - the engine running the entities
2189
+ * @param entity - the entity to get the world position for
2190
+ * @returns The entity's position in world space. Returns `{x: 0, y: 0, z: 0}` if the entity has no Transform.
2191
+ *
2192
+ * Example:
2193
+ * ```ts
2194
+ * const worldPos = getWorldPosition(engine, childEntity)
2195
+ * console.log(`World position: ${worldPos.x}, ${worldPos.y}, ${worldPos.z}`)
2196
+ * ```
2197
+ */
2198
+ export declare function getWorldPosition(engine: WorldTransformEngine, entity: Entity): Vector3Type;
2199
+
2200
+ /**
2201
+ * Get the world rotation of an entity, taking into account the full parent hierarchy.
2202
+ * This computes the world-space rotation by combining all parent rotations.
2203
+ *
2204
+ * When the entity has AvatarAttach and Transform, the renderer updates the Transform
2205
+ * with avatar-relative values (including the exact anchor point rotation for hand, head, etc.).
2206
+ * This function combines the player's rotation with those values to compute the world rotation.
2207
+ *
2208
+ * @public
2209
+ * @param engine - the engine running the entities
2210
+ * @param entity - the entity to get the world rotation for
2211
+ * @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.
2212
+ *
2213
+ * Example:
2214
+ * ```ts
2215
+ * const worldRot = getWorldRotation(engine, childEntity)
2216
+ * console.log(`World rotation: ${worldRot.x}, ${worldRot.y}, ${worldRot.z}, ${worldRot.w}`)
2217
+ * ```
2218
+ */
2219
+ export declare function getWorldRotation(engine: WorldTransformEngine, entity: Entity): QuaternionType;
2220
+
2056
2221
  export declare type GlobalDirectionRaycastOptions = RaycastSystemOptions & GlobalDirectionRaycastSystemOptions;
2057
2222
 
2058
2223
  export declare type GlobalDirectionRaycastSystemOptions = {
@@ -2804,6 +2969,42 @@ export declare interface MaterialComponentDefinitionExtended extends LastWriteWi
2804
2969
  * @param material - the PBR data for this material
2805
2970
  */
2806
2971
  setPbrMaterial: (entity: Entity, material: PBMaterial_PbrMaterial) => void;
2972
+ /**
2973
+ * Get a readonly flattened accessor for the material's properties.
2974
+ * Simplifies reading material properties without navigating nested unions.
2975
+ * Works for both PBR and Unlit materials.
2976
+ * Throws if the entity does not have a Material component.
2977
+ * @param entity - Entity with the Material component
2978
+ * @returns A readonly accessor object with direct access to material properties
2979
+ *
2980
+ */
2981
+ getFlat: (entity: Entity) => ReadonlyFlatMaterial;
2982
+ /**
2983
+ * Get a readonly flattened accessor for the material's properties, or null if the entity
2984
+ * does not have a Material component.
2985
+ * @param entity - Entity to check for Material component
2986
+ * @returns A readonly accessor object, or null if no Material component exists
2987
+ *
2988
+ */
2989
+ getFlatOrNull: (entity: Entity) => ReadonlyFlatMaterial | null;
2990
+ /**
2991
+ * Get a mutable flattened accessor for the material's properties.
2992
+ * Simplifies reading/writing material properties without navigating nested unions.
2993
+ * Works for both PBR and Unlit materials.
2994
+ * Throws if the entity does not have a Material component.
2995
+ * @param entity - Entity with the Material component
2996
+ * @returns A mutable accessor object with direct access to material properties
2997
+ *
2998
+ */
2999
+ getFlatMutable: (entity: Entity) => FlatMaterial;
3000
+ /**
3001
+ * Get a mutable flattened accessor for the material's properties, or null if the entity
3002
+ * does not have a Material component.
3003
+ * @param entity - Entity to check for Material component
3004
+ * @returns A mutable accessor object, or null if no Material component exists
3005
+ *
3006
+ */
3007
+ getFlatMutableOrNull: (entity: Entity) => FlatMaterial | null;
2807
3008
  }
2808
3009
 
2809
3010
  /**
@@ -7021,6 +7222,90 @@ export declare type ReadonlyComponentSchema<T extends [ComponentDefinition<unkno
7021
7222
  [K in keyof T]: T[K] extends ComponentDefinition<unknown> ? ReturnType<T[K]['get']> : never;
7022
7223
  };
7023
7224
 
7225
+ /**
7226
+ * Readonly flattened material interface for read-only property access
7227
+ * @public
7228
+ */
7229
+ export declare interface ReadonlyFlatMaterial {
7230
+ /**
7231
+ * Access to the main texture properties (works for both PBR and Unlit materials)
7232
+ */
7233
+ readonly texture: ReadonlyFlatTexture;
7234
+ /**
7235
+ * Access to the alpha texture properties (works for both PBR and Unlit materials)
7236
+ */
7237
+ readonly alphaTexture: ReadonlyFlatTexture;
7238
+ /**
7239
+ * Access to the emissive texture properties (PBR only - returns undefined for Unlit materials)
7240
+ */
7241
+ readonly emissiveTexture: ReadonlyFlatTexture | undefined;
7242
+ /**
7243
+ * Access to the bump/normal texture properties (PBR only - returns undefined for Unlit materials)
7244
+ */
7245
+ readonly bumpTexture: ReadonlyFlatTexture | undefined;
7246
+ /**
7247
+ * Alpha test threshold (0-1). Default: 0.5
7248
+ */
7249
+ readonly alphaTest: number | undefined;
7250
+ /**
7251
+ * Whether the material casts shadows. Default: true
7252
+ */
7253
+ readonly castShadows: boolean | undefined;
7254
+ /**
7255
+ * Albedo/base color (PBR only). Default: white
7256
+ */
7257
+ readonly albedoColor: PBColor4 | undefined;
7258
+ /**
7259
+ * Emissive color (PBR only). Default: black
7260
+ */
7261
+ readonly emissiveColor: PBColor3 | undefined;
7262
+ /**
7263
+ * Reflectivity color (PBR only). Default: white
7264
+ */
7265
+ readonly reflectivityColor: PBColor3 | undefined;
7266
+ /**
7267
+ * Transparency mode (PBR only). Default: MTM_AUTO
7268
+ */
7269
+ readonly transparencyMode: MaterialTransparencyMode | undefined;
7270
+ /**
7271
+ * Metallic value 0-1 (PBR only). Default: 0.5
7272
+ */
7273
+ readonly metallic: number | undefined;
7274
+ /**
7275
+ * Roughness value 0-1 (PBR only). Default: 0.5
7276
+ */
7277
+ readonly roughness: number | undefined;
7278
+ /**
7279
+ * Specular intensity (PBR only). Default: 1
7280
+ */
7281
+ readonly specularIntensity: number | undefined;
7282
+ /**
7283
+ * Emissive intensity (PBR only). Default: 2
7284
+ */
7285
+ readonly emissiveIntensity: number | undefined;
7286
+ /**
7287
+ * Direct light intensity (PBR only). Default: 1
7288
+ */
7289
+ readonly directIntensity: number | undefined;
7290
+ /**
7291
+ * Diffuse color (Unlit only). Default: white
7292
+ */
7293
+ readonly diffuseColor: PBColor4 | undefined;
7294
+ }
7295
+
7296
+ /**
7297
+ * Readonly flattened texture interface for read-only property access
7298
+ * @public
7299
+ */
7300
+ export declare interface ReadonlyFlatTexture {
7301
+ /** Path to the texture file */
7302
+ readonly src: string | undefined;
7303
+ /** Texture wrapping behavior */
7304
+ readonly wrapMode: TextureWrapMode | undefined;
7305
+ /** Texture filtering mode */
7306
+ readonly filterMode: TextureFilterMode | undefined;
7307
+ }
7308
+
7024
7309
  /**
7025
7310
  * @public
7026
7311
  */
@@ -7687,6 +7972,79 @@ export declare const enum TextWrap {
7687
7972
  TW_NO_WRAP = 1
7688
7973
  }
7689
7974
 
7975
+ export declare type TimerCallback = () => void;
7976
+
7977
+ export declare type TimerId = number;
7978
+
7979
+ export declare type Timers = {
7980
+ /**
7981
+ * Delays the execution of a function by a given amount of milliseconds.
7982
+ *
7983
+ * @param callback - The function to execute after the delay
7984
+ * @param ms - The delay in milliseconds
7985
+ * @returns A TimerId that can be used to cancel the timeout
7986
+ *
7987
+ * @example
7988
+ * ```ts
7989
+ * const timeoutId = timers.setTimeout(() => {
7990
+ * console.log('1 second passed')
7991
+ * }, 1000)
7992
+ * ```
7993
+ */
7994
+ setTimeout(callback: TimerCallback, ms: number): TimerId;
7995
+ /**
7996
+ * Cancels a timeout previously established by setTimeout.
7997
+ *
7998
+ * @param timerId - The TimerId returned by setTimeout
7999
+ *
8000
+ * @example
8001
+ * ```ts
8002
+ * const timeoutId = timers.setTimeout(() => {
8003
+ * console.log('This will not run')
8004
+ * }, 1000)
8005
+ *
8006
+ * timers.clearTimeout(timeoutId)
8007
+ * ```
8008
+ */
8009
+ clearTimeout(timerId: TimerId): void;
8010
+ /**
8011
+ * Repeatedly executes a function at specified intervals.
8012
+ *
8013
+ * @param callback - The function to execute at each interval
8014
+ * @param ms - The interval in milliseconds
8015
+ * @returns A TimerId that can be used to cancel the interval
8016
+ *
8017
+ * @example
8018
+ * ```ts
8019
+ * const intervalId = timers.setInterval(() => {
8020
+ * console.log('Printing this every 1 second')
8021
+ * }, 1000)
8022
+ * ```
8023
+ */
8024
+ setInterval(callback: TimerCallback, ms: number): TimerId;
8025
+ /**
8026
+ * Cancels an interval previously established by setInterval.
8027
+ *
8028
+ * @param timerId - The TimerId returned by setInterval
8029
+ *
8030
+ * @example
8031
+ * ```ts
8032
+ * const intervalId = timers.setInterval(() => {
8033
+ * console.log('This will stop')
8034
+ * }, 1000)
8035
+ *
8036
+ * timers.clearInterval(intervalId)
8037
+ * ```
8038
+ */
8039
+ clearInterval(timerId: TimerId): void;
8040
+ };
8041
+
8042
+ /**
8043
+ * @public
8044
+ * Timer utilities for delayed and repeated execution.
8045
+ */
8046
+ export declare const timers: Timers;
8047
+
7690
8048
  /**
7691
8049
  * Constant used to convert a value to gamma space
7692
8050
  * @public
@@ -9032,6 +9390,9 @@ export declare interface VirtualCameraComponentDefinitionExtended extends LastWr
9032
9390
  /** @public */
9033
9391
  export declare const VisibilityComponent: LastWriteWinElementSetComponentDefinition<PBVisibilityComponent>;
9034
9392
 
9393
+ /** @public Engine type for world transform functions */
9394
+ export declare type WorldTransformEngine = Pick<IEngine, 'getEntitiesWith' | 'defineComponentFromSchema' | 'PlayerEntity'>;
9395
+
9035
9396
  /**
9036
9397
  * @public
9037
9398
  */