@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/beta.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 = {
@@ -2795,6 +2960,42 @@ export declare interface MaterialComponentDefinitionExtended extends LastWriteWi
2795
2960
  * @param material - the PBR data for this material
2796
2961
  */
2797
2962
  setPbrMaterial: (entity: Entity, material: PBMaterial_PbrMaterial) => void;
2963
+ /**
2964
+ * Get a readonly flattened accessor for the material's properties.
2965
+ * Simplifies reading material properties without navigating nested unions.
2966
+ * Works for both PBR and Unlit materials.
2967
+ * Throws if the entity does not have a Material component.
2968
+ * @param entity - Entity with the Material component
2969
+ * @returns A readonly accessor object with direct access to material properties
2970
+ *
2971
+ */
2972
+ getFlat: (entity: Entity) => ReadonlyFlatMaterial;
2973
+ /**
2974
+ * Get a readonly flattened accessor for the material's properties, or null if the entity
2975
+ * does not have a Material component.
2976
+ * @param entity - Entity to check for Material component
2977
+ * @returns A readonly accessor object, or null if no Material component exists
2978
+ *
2979
+ */
2980
+ getFlatOrNull: (entity: Entity) => ReadonlyFlatMaterial | null;
2981
+ /**
2982
+ * Get a mutable flattened accessor for the material's properties.
2983
+ * Simplifies reading/writing material properties without navigating nested unions.
2984
+ * Works for both PBR and Unlit materials.
2985
+ * Throws if the entity does not have a Material component.
2986
+ * @param entity - Entity with the Material component
2987
+ * @returns A mutable accessor object with direct access to material properties
2988
+ *
2989
+ */
2990
+ getFlatMutable: (entity: Entity) => FlatMaterial;
2991
+ /**
2992
+ * Get a mutable flattened accessor for the material's properties, or null if the entity
2993
+ * does not have a Material component.
2994
+ * @param entity - Entity to check for Material component
2995
+ * @returns A mutable accessor object, or null if no Material component exists
2996
+ *
2997
+ */
2998
+ getFlatMutableOrNull: (entity: Entity) => FlatMaterial | null;
2798
2999
  }
2799
3000
 
2800
3001
  /**
@@ -6993,6 +7194,90 @@ export declare type ReadonlyComponentSchema<T extends [ComponentDefinition<unkno
6993
7194
  [K in keyof T]: T[K] extends ComponentDefinition<unknown> ? ReturnType<T[K]['get']> : never;
6994
7195
  };
6995
7196
 
7197
+ /**
7198
+ * Readonly flattened material interface for read-only property access
7199
+ * @public
7200
+ */
7201
+ export declare interface ReadonlyFlatMaterial {
7202
+ /**
7203
+ * Access to the main texture properties (works for both PBR and Unlit materials)
7204
+ */
7205
+ readonly texture: ReadonlyFlatTexture;
7206
+ /**
7207
+ * Access to the alpha texture properties (works for both PBR and Unlit materials)
7208
+ */
7209
+ readonly alphaTexture: ReadonlyFlatTexture;
7210
+ /**
7211
+ * Access to the emissive texture properties (PBR only - returns undefined for Unlit materials)
7212
+ */
7213
+ readonly emissiveTexture: ReadonlyFlatTexture | undefined;
7214
+ /**
7215
+ * Access to the bump/normal texture properties (PBR only - returns undefined for Unlit materials)
7216
+ */
7217
+ readonly bumpTexture: ReadonlyFlatTexture | undefined;
7218
+ /**
7219
+ * Alpha test threshold (0-1). Default: 0.5
7220
+ */
7221
+ readonly alphaTest: number | undefined;
7222
+ /**
7223
+ * Whether the material casts shadows. Default: true
7224
+ */
7225
+ readonly castShadows: boolean | undefined;
7226
+ /**
7227
+ * Albedo/base color (PBR only). Default: white
7228
+ */
7229
+ readonly albedoColor: PBColor4 | undefined;
7230
+ /**
7231
+ * Emissive color (PBR only). Default: black
7232
+ */
7233
+ readonly emissiveColor: PBColor3 | undefined;
7234
+ /**
7235
+ * Reflectivity color (PBR only). Default: white
7236
+ */
7237
+ readonly reflectivityColor: PBColor3 | undefined;
7238
+ /**
7239
+ * Transparency mode (PBR only). Default: MTM_AUTO
7240
+ */
7241
+ readonly transparencyMode: MaterialTransparencyMode | undefined;
7242
+ /**
7243
+ * Metallic value 0-1 (PBR only). Default: 0.5
7244
+ */
7245
+ readonly metallic: number | undefined;
7246
+ /**
7247
+ * Roughness value 0-1 (PBR only). Default: 0.5
7248
+ */
7249
+ readonly roughness: number | undefined;
7250
+ /**
7251
+ * Specular intensity (PBR only). Default: 1
7252
+ */
7253
+ readonly specularIntensity: number | undefined;
7254
+ /**
7255
+ * Emissive intensity (PBR only). Default: 2
7256
+ */
7257
+ readonly emissiveIntensity: number | undefined;
7258
+ /**
7259
+ * Direct light intensity (PBR only). Default: 1
7260
+ */
7261
+ readonly directIntensity: number | undefined;
7262
+ /**
7263
+ * Diffuse color (Unlit only). Default: white
7264
+ */
7265
+ readonly diffuseColor: PBColor4 | undefined;
7266
+ }
7267
+
7268
+ /**
7269
+ * Readonly flattened texture interface for read-only property access
7270
+ * @public
7271
+ */
7272
+ export declare interface ReadonlyFlatTexture {
7273
+ /** Path to the texture file */
7274
+ readonly src: string | undefined;
7275
+ /** Texture wrapping behavior */
7276
+ readonly wrapMode: TextureWrapMode | undefined;
7277
+ /** Texture filtering mode */
7278
+ readonly filterMode: TextureFilterMode | undefined;
7279
+ }
7280
+
6996
7281
  /**
6997
7282
  * @public
6998
7283
  */
@@ -7654,6 +7939,79 @@ export declare const enum TextWrap {
7654
7939
  TW_NO_WRAP = 1
7655
7940
  }
7656
7941
 
7942
+ export declare type TimerCallback = () => void;
7943
+
7944
+ export declare type TimerId = number;
7945
+
7946
+ export declare type Timers = {
7947
+ /**
7948
+ * Delays the execution of a function by a given amount of milliseconds.
7949
+ *
7950
+ * @param callback - The function to execute after the delay
7951
+ * @param ms - The delay in milliseconds
7952
+ * @returns A TimerId that can be used to cancel the timeout
7953
+ *
7954
+ * @example
7955
+ * ```ts
7956
+ * const timeoutId = timers.setTimeout(() => {
7957
+ * console.log('1 second passed')
7958
+ * }, 1000)
7959
+ * ```
7960
+ */
7961
+ setTimeout(callback: TimerCallback, ms: number): TimerId;
7962
+ /**
7963
+ * Cancels a timeout previously established by setTimeout.
7964
+ *
7965
+ * @param timerId - The TimerId returned by setTimeout
7966
+ *
7967
+ * @example
7968
+ * ```ts
7969
+ * const timeoutId = timers.setTimeout(() => {
7970
+ * console.log('This will not run')
7971
+ * }, 1000)
7972
+ *
7973
+ * timers.clearTimeout(timeoutId)
7974
+ * ```
7975
+ */
7976
+ clearTimeout(timerId: TimerId): void;
7977
+ /**
7978
+ * Repeatedly executes a function at specified intervals.
7979
+ *
7980
+ * @param callback - The function to execute at each interval
7981
+ * @param ms - The interval in milliseconds
7982
+ * @returns A TimerId that can be used to cancel the interval
7983
+ *
7984
+ * @example
7985
+ * ```ts
7986
+ * const intervalId = timers.setInterval(() => {
7987
+ * console.log('Printing this every 1 second')
7988
+ * }, 1000)
7989
+ * ```
7990
+ */
7991
+ setInterval(callback: TimerCallback, ms: number): TimerId;
7992
+ /**
7993
+ * Cancels an interval previously established by setInterval.
7994
+ *
7995
+ * @param timerId - The TimerId returned by setInterval
7996
+ *
7997
+ * @example
7998
+ * ```ts
7999
+ * const intervalId = timers.setInterval(() => {
8000
+ * console.log('This will stop')
8001
+ * }, 1000)
8002
+ *
8003
+ * timers.clearInterval(intervalId)
8004
+ * ```
8005
+ */
8006
+ clearInterval(timerId: TimerId): void;
8007
+ };
8008
+
8009
+ /**
8010
+ * @public
8011
+ * Timer utilities for delayed and repeated execution.
8012
+ */
8013
+ export declare const timers: Timers;
8014
+
7657
8015
  /**
7658
8016
  * Constant used to convert a value to gamma space
7659
8017
  * @public
@@ -8999,6 +9357,9 @@ export declare interface VirtualCameraComponentDefinitionExtended extends LastWr
8999
9357
  /** @public */
9000
9358
  export declare const VisibilityComponent: LastWriteWinElementSetComponentDefinition<PBVisibilityComponent>;
9001
9359
 
9360
+ /** @public Engine type for world transform functions */
9361
+ export declare type WorldTransformEngine = Pick<IEngine, 'getEntitiesWith' | 'defineComponentFromSchema' | 'PlayerEntity'>;
9362
+
9002
9363
  /**
9003
9364
  * @public
9004
9365
  */