littlejsengine 1.24.2 → 1.24.3

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.
@@ -550,7 +550,7 @@ declare module "littlejsengine" {
550
550
  * ['tiles.png', 'tilesLevel.png'] // images to load
551
551
  * );
552
552
  * @memberof Engine */
553
- export function engineInit(gameInit?: GameInitCallback, gameUpdate?: GameCallback, gameUpdatePost?: GameCallback, gameRender?: GameCallback, gameRenderPost?: GameCallback, imageSources?: Array<string>, rootElement?: HTMLElement): Promise<void>;
553
+ export function engineInit(gameInit?: GameInitCallback, gameUpdate?: GameCallback, gameUpdatePost?: GameCallback, gameRender?: GameCallback, gameRenderPost?: GameCallback, imageSources?: string[], rootElement?: HTMLElement): Promise<void>;
554
554
  /** Advance the engine by a number of frames
555
555
  * Requires setEngineManualStep(true), before engineInit or while running; it stops early if an update turns it off
556
556
  * Respects paused exactly as the normal update loop does
@@ -584,7 +584,7 @@ declare module "littlejsengine" {
584
584
  * @param {boolean} [testCenters] - Test only each object's center, a little faster, and ignores object sizes
585
585
  * @return {Array<EngineObject>} - List of collected objects
586
586
  * @memberof Engine */
587
- export function engineObjectsCollect(pos?: Vector2, size?: Vector2 | number, objects?: Array<EngineObject>, testCenters?: boolean): Array<EngineObject>;
587
+ export function engineObjectsCollect(pos?: Vector2, size?: number | Vector2, objects?: EngineObject[], testCenters?: boolean): Array<EngineObject>;
588
588
  /**
589
589
  * @callback ObjectCallbackFunction - Function that processes an object
590
590
  * @param {EngineObject} object
@@ -598,7 +598,7 @@ declare module "littlejsengine" {
598
598
  * @param {Array<EngineObject>} [objects=engineObjects] - List of objects to check
599
599
  * @param {boolean} [testCenters] - Test only each object's center, see engineObjectsCollect
600
600
  * @memberof Engine */
601
- export function engineObjectsCallback(pos?: Vector2, size?: Vector2 | number, callbackFunction?: ObjectCallbackFunction, objects?: Array<EngineObject>, testCenters?: boolean): void;
601
+ export function engineObjectsCallback(pos?: Vector2, size?: number | Vector2, callbackFunction?: ObjectCallbackFunction, objects?: EngineObject[], testCenters?: boolean): void;
602
602
  /** Return a list of objects intersecting a ray, objects destroyed this frame left out
603
603
  * - Only objects with collideRaycast set are hit, which setCollision turns on
604
604
  * @param {Vector2} start
@@ -606,7 +606,7 @@ declare module "littlejsengine" {
606
606
  * @param {Array<EngineObject>} [objects=engineObjects] - List of objects to check
607
607
  * @return {Array<EngineObject>} - List of objects hit
608
608
  * @memberof Engine */
609
- export function engineObjectsRaycast(start: Vector2, end: Vector2, objects?: Array<EngineObject>): Array<EngineObject>;
609
+ export function engineObjectsRaycast(start: Vector2, end: Vector2, objects?: EngineObject[]): Array<EngineObject>;
610
610
  /**
611
611
  * @callback PluginCallback - Update or render function for a plugin
612
612
  * @memberof Engine
@@ -868,7 +868,7 @@ declare module "littlejsengine" {
868
868
  * place(type, pos3D); setTransform(object, pos3D, rotationDegrees, scale3D); setProperty(object, name, value);
869
869
  * pos(object), rotation(object) and scale(object); mousePoint(); undo(redo); toJSON()
870
870
  * @return {EditorEdit3D|undefined} */
871
- get edit3D(): EditorEdit3D;
871
+ get edit3D(): EditorEdit3D | undefined;
872
872
  /** Add a key of the game's own to the editor, the 2D and the 3D one
873
873
  * - Escape and 0 are the editor's own, to play and to exit, and Ctrl is the one modifier: Shift is given to
874
874
  * the action
@@ -929,7 +929,7 @@ declare module "littlejsengine" {
929
929
  * @param {boolean} [fill]
930
930
  * @param {boolean} [screenSpace=drawScreenSpace]
931
931
  * @memberof Debug */
932
- export function debugRect(pos: Vector2, size?: Vector2, color?: Color | string, time?: number, angle?: number, fill?: boolean, screenSpace?: boolean): void;
932
+ export function debugRect(pos: Vector2, size?: Vector2, color?: string | Color, time?: number, angle?: number, fill?: boolean, screenSpace?: boolean): void;
933
933
  /** Draw a debug poly in world space, or on the screen with screenSpace
934
934
  * @param {Vector2} pos
935
935
  * @param {Array<Vector2>} points
@@ -939,7 +939,7 @@ declare module "littlejsengine" {
939
939
  * @param {boolean} [fill]
940
940
  * @param {boolean} [screenSpace=drawScreenSpace]
941
941
  * @memberof Debug */
942
- export function debugPoly(pos: Vector2, points: Array<Vector2>, color?: Color | string, time?: number, angle?: number, fill?: boolean, screenSpace?: boolean): void;
942
+ export function debugPoly(pos: Vector2, points: Array<Vector2>, color?: string | Color, time?: number, angle?: number, fill?: boolean, screenSpace?: boolean): void;
943
943
  /** Draw a debug circle in world space, or on the screen with screenSpace
944
944
  * @param {Vector2} pos
945
945
  * @param {number} [size] - diameter
@@ -948,7 +948,7 @@ declare module "littlejsengine" {
948
948
  * @param {boolean} [fill]
949
949
  * @param {boolean} [screenSpace=drawScreenSpace]
950
950
  * @memberof Debug */
951
- export function debugCircle(pos: Vector2, size?: number, color?: Color | string, time?: number, fill?: boolean, screenSpace?: boolean): void;
951
+ export function debugCircle(pos: Vector2, size?: number, color?: string | Color, time?: number, fill?: boolean, screenSpace?: boolean): void;
952
952
  /** Draw a debug point in world space, or on the screen with screenSpace
953
953
  * @param {Vector2} pos
954
954
  * @param {Color|string} [color]
@@ -956,7 +956,7 @@ declare module "littlejsengine" {
956
956
  * @param {number} [angle]
957
957
  * @param {boolean} [screenSpace=drawScreenSpace]
958
958
  * @memberof Debug */
959
- export function debugPoint(pos: Vector2, color?: Color | string, time?: number, angle?: number, screenSpace?: boolean): void;
959
+ export function debugPoint(pos: Vector2, color?: string | Color, time?: number, angle?: number, screenSpace?: boolean): void;
960
960
  /** Draw a debug line in world space, or on the screen with screenSpace
961
961
  * @param {Vector2} posA
962
962
  * @param {Vector2} posB
@@ -965,7 +965,7 @@ declare module "littlejsengine" {
965
965
  * @param {number} [time]
966
966
  * @param {boolean} [screenSpace=drawScreenSpace]
967
967
  * @memberof Debug */
968
- export function debugLine(posA: Vector2, posB: Vector2, color?: Color | string, width?: number, time?: number, screenSpace?: boolean): void;
968
+ export function debugLine(posA: Vector2, posB: Vector2, color?: string | Color, width?: number, time?: number, screenSpace?: boolean): void;
969
969
  /** Draw a debug combined axis aligned bounding box in world space, or on the screen with screenSpace
970
970
  * @param {Vector2} posA
971
971
  * @param {Vector2} sizeA
@@ -975,7 +975,7 @@ declare module "littlejsengine" {
975
975
  * @param {number} [time]
976
976
  * @param {boolean} [screenSpace=drawScreenSpace]
977
977
  * @memberof Debug */
978
- export function debugOverlap(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB: Vector2, color?: Color | string, time?: number, screenSpace?: boolean): void;
978
+ export function debugOverlap(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB: Vector2, color?: string | Color, time?: number, screenSpace?: boolean): void;
979
979
  /** Draw debug text in world space, or on the screen with screenSpace
980
980
  * @param {string|number} text
981
981
  * @param {Vector2} pos
@@ -986,7 +986,7 @@ declare module "littlejsengine" {
986
986
  * @param {string} [font]
987
987
  * @param {boolean} [screenSpace=drawScreenSpace]
988
988
  * @memberof Debug */
989
- export function debugText(text: string | number, pos: Vector2, size?: number, color?: Color | string, time?: number, angle?: number, font?: string, screenSpace?: boolean): void;
989
+ export function debugText(text: string | number, pos: Vector2, size?: number, color?: string | Color, time?: number, angle?: number, font?: string, screenSpace?: boolean): void;
990
990
  /** Clear all debug primitives in the list
991
991
  * @memberof Debug */
992
992
  export function debugClear(): void;
@@ -2524,7 +2524,7 @@ declare module "littlejsengine" {
2524
2524
  * tile(1, 16, 3) // a tile at index 1 of size 16 on texture 3
2525
2525
  * tile(vec2(4,8), vec2(30,10)) // a tile at index (4,8) with a size of (30,10)
2526
2526
  * @memberof Draw */
2527
- export function tile(index?: Vector2 | number, size?: Vector2 | number, texture?: TextureInfo | number, padding?: number, bleed?: number): TileInfo;
2527
+ export function tile(index?: number | Vector2, size?: number | Vector2, texture?: number | TextureInfo, padding?: number, bleed?: number): TileInfo;
2528
2528
  /**
2529
2529
  * Tile Info - Stores info about how to draw a tile
2530
2530
  * @memberof Draw
@@ -2577,7 +2577,7 @@ declare module "littlejsengine" {
2577
2577
  * @param {Vector2|number} [index=0]
2578
2578
  * @return {TileInfo}
2579
2579
  */
2580
- index(index?: Vector2 | number): TileInfo;
2580
+ index(index?: number | Vector2): TileInfo;
2581
2581
  /**
2582
2582
  * Set this tile to use a full image in a texture info
2583
2583
  * @param {TextureInfo} [textureInfo]
@@ -2598,7 +2598,7 @@ declare module "littlejsengine" {
2598
2598
  * modes across and down, like [gl.CLAMP_TO_EDGE, gl.MIRRORED_REPEAT], as a glTF sampler gives them
2599
2599
  * @param {boolean} [pixelated] - Hard edged or smooth for this texture alone, undefined follows tilesPixelated
2600
2600
  */
2601
- constructor(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, useWebGL?: boolean, wrap?: boolean | Array<number>, pixelated?: boolean);
2601
+ constructor(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, useWebGL?: boolean, wrap?: boolean | number[], pixelated?: boolean);
2602
2602
  /** @property {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} - image source */
2603
2603
  image: OffscreenCanvas | ImageBitmap | HTMLCanvasElement | HTMLImageElement;
2604
2604
  /** @property {Vector2} - size of the image */
@@ -2626,7 +2626,7 @@ declare module "littlejsengine" {
2626
2626
  /** Set the wrap mode for this texture
2627
2627
  * @param {boolean|Array<number>} [wrap] - true for REPEAT, false for CLAMP_TO_EDGE, or the WebGL modes across
2628
2628
  * and down */
2629
- setWrap(wrap?: boolean | Array<number>): void;
2629
+ setWrap(wrap?: boolean | number[]): void;
2630
2630
  /** Make this texture hard edged or smooth on its own, whatever tilesPixelated says for the rest; it is made again
2631
2631
  * with the new filtering
2632
2632
  * @param {boolean} [pixelated] - undefined follows tilesPixelated again */
@@ -2957,7 +2957,7 @@ declare module "littlejsengine" {
2957
2957
  * @param {boolean} [screenSpace=drawScreenSpace] - Are pos and size in screen space?
2958
2958
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
2959
2959
  * @memberof Draw */
2960
- export function drawTextureWrapped(pos: Vector2, size: Vector2, wrapCount: Vector2, texture?: TextureInfo | number, color?: Color, angle?: number, additiveColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
2960
+ export function drawTextureWrapped(pos: Vector2, size: Vector2, wrapCount: Vector2, texture?: number | TextureInfo, color?: Color, angle?: number, additiveColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
2961
2961
  /** Draw connected lines between a series of points
2962
2962
  * @param {Array<Vector2>} points
2963
2963
  * @param {number} [width]
@@ -3092,7 +3092,7 @@ declare module "littlejsengine" {
3092
3092
  * @param {number} [angle]
3093
3093
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
3094
3094
  * @memberof Draw */
3095
- export function drawText(text: string | number, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: 'left' | 'center' | 'right', font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
3095
+ export function drawText(text: string | number, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: "center" | "left" | "right", font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
3096
3096
  /** Draw text in screen space
3097
3097
  * Automatically splits new lines into rows
3098
3098
  * @param {string|number} text
@@ -3108,7 +3108,7 @@ declare module "littlejsengine" {
3108
3108
  * @param {number} [angle] - Clockwise, like the other screen space draws
3109
3109
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
3110
3110
  * @memberof Draw */
3111
- export function drawTextScreen(text: string | number, pos: Vector2, size: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: 'left' | 'center' | 'right', font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
3111
+ export function drawTextScreen(text: string | number, pos: Vector2, size: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: "center" | "left" | "right", font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
3112
3112
  /** Enable additive blending
3113
3113
  * @param {boolean} [additive]
3114
3114
  * @memberof Draw */
@@ -3164,7 +3164,7 @@ declare module "littlejsengine" {
3164
3164
  * @param {boolean} [useWebGL=glEnable]
3165
3165
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
3166
3166
  */
3167
- drawText(text: string | number, pos: Vector2, size?: Vector2 | number, center?: boolean, color?: Color, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
3167
+ drawText(text: string | number, pos: Vector2, size?: number | Vector2, center?: boolean, color?: Color, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
3168
3168
  /** Draw text in screen space using the image font
3169
3169
  * @param {string|number} text
3170
3170
  * @param {Vector2} pos
@@ -3224,7 +3224,7 @@ declare module "littlejsengine" {
3224
3224
  * @param {Vector2|number} [size] - world space size or diameter
3225
3225
  * @return {boolean}
3226
3226
  * @memberof Draw */
3227
- export function isOnScreen(pos: Vector2, size?: Vector2 | number): boolean;
3227
+ export function isOnScreen(pos: Vector2, size?: number | Vector2): boolean;
3228
3228
  /**
3229
3229
  * LittleJS WebGL Interface
3230
3230
  * - WebGL2 rendering engine for high-performance graphics
@@ -3266,27 +3266,27 @@ declare module "littlejsengine" {
3266
3266
  * @param {boolean|Array<number>} [wrap] - true for REPEAT, false for CLAMP_TO_EDGE, or the WebGL modes across and
3267
3267
  * down, like [gl.CLAMP_TO_EDGE, gl.MIRRORED_REPEAT]
3268
3268
  * @memberof WebGL */
3269
- export function glSetTextureWrap(texture: WebGLTexture, wrap?: boolean | Array<number>): void;
3269
+ export function glSetTextureWrap(texture: WebGLTexture, wrap?: boolean | number[]): void;
3270
3270
  /** Compile WebGL shader of the given type, will throw errors if in debug mode
3271
3271
  * @param {string} source
3272
3272
  * @param {number} type
3273
- * @return {WebGLShader}
3273
+ * @return {WebGLShader|undefined} - undefined with no WebGL
3274
3274
  * @memberof WebGL */
3275
- export function glCompileShader(source: string, type: number): WebGLShader;
3275
+ export function glCompileShader(source: string, type: number): WebGLShader | undefined;
3276
3276
  /** Create WebGL program with given shaders
3277
3277
  * @param {string} vsSource
3278
3278
  * @param {string} fsSource
3279
- * @return {WebGLProgram}
3279
+ * @return {WebGLProgram|undefined} - undefined with no WebGL
3280
3280
  * @memberof WebGL */
3281
- export function glCreateProgram(vsSource: string, fsSource: string): WebGLProgram;
3281
+ export function glCreateProgram(vsSource: string, fsSource: string): WebGLProgram | undefined;
3282
3282
  /** Create WebGL texture from an image and init the texture settings
3283
3283
  * Restores the active texture when done
3284
3284
  * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} [image]
3285
3285
  * @param {boolean|Array<number>} [wrap] - true for REPEAT, false for CLAMP_TO_EDGE, or the WebGL modes across and down
3286
3286
  * @param {boolean} [pixelated] - Hard edged or smooth, undefined follows tilesPixelated
3287
- * @return {WebGLTexture}
3287
+ * @return {WebGLTexture|undefined} - undefined with no WebGL
3288
3288
  * @memberof WebGL */
3289
- export function glCreateTexture(image?: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, wrap?: boolean | Array<number>, pixelated?: boolean): WebGLTexture;
3289
+ export function glCreateTexture(image?: OffscreenCanvas | ImageBitmap | HTMLCanvasElement | HTMLImageElement, wrap?: boolean | number[], pixelated?: boolean): WebGLTexture | undefined;
3290
3290
  /** Deletes a WebGL texture
3291
3291
  * @param {WebGLTexture} [texture]
3292
3292
  * @memberof WebGL */
@@ -3692,7 +3692,7 @@ declare module "littlejsengine" {
3692
3692
  * @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
3693
3693
  * @param {SoundLoadCallback} [onloadCallback] - callback function to call when sound is loaded
3694
3694
  */
3695
- constructor(asset?: string | URL | any[], randomness?: number, range?: number, taper?: number, onloadCallback?: SoundLoadCallback);
3695
+ constructor(asset?: string | any[] | URL, randomness?: number, range?: number, taper?: number, onloadCallback?: SoundLoadCallback);
3696
3696
  loadedPercent: number;
3697
3697
  set range(arg: number);
3698
3698
  /** World space max range of sound, 0 for no limit; a range that is set is the sound's own, in 3D too
@@ -3700,16 +3700,16 @@ declare module "littlejsengine" {
3700
3700
  get range(): number;
3701
3701
  /** @property {boolean} - No range was given, so it got soundDefaultRange; played in 3D such a sound is heard
3702
3702
  * to render3D.soundDefaultRange instead, which is further; setting range makes it false */
3703
- rangeIsDefault: boolean;
3703
+ rangeIsDefault: boolean | undefined;
3704
3704
  /** @property {number} - At what percentage of range should it start tapering */
3705
- taper: number;
3705
+ taper: number | undefined;
3706
3706
  /** @property {number} - How much to randomize frequency each time sound plays
3707
3707
  * @type {number} */
3708
3708
  randomness: number;
3709
3709
  /** @property {number} - Sample rate for this sound */
3710
- sampleRate: number;
3710
+ sampleRate: number | undefined;
3711
3711
  /** @property {number} - How many samples per channel this sound has */
3712
- sampleLength: number;
3712
+ sampleLength: number | undefined;
3713
3713
  /** @property {AudioBuffer|undefined} - Decoded audio shared by every play of this sound
3714
3714
  * @type {AudioBuffer|undefined} */
3715
3715
  sampleBuffer: AudioBuffer | undefined;
@@ -3724,14 +3724,14 @@ declare module "littlejsengine" {
3724
3724
  * @type {AudioNode|AudioEffectNodes|undefined} */
3725
3725
  output: AudioNode | AudioEffectNodes | undefined;
3726
3726
  /** @param {Array<Array<number>|Float32Array>} sampleChannels */
3727
- set sampleChannels(arg: (number[] | Float32Array)[]);
3727
+ set sampleChannels(arg: (number[] | Float32Array)[] | undefined);
3728
3728
  /** Sample data for each channel
3729
3729
  * Sounds keep their samples in an audio buffer, so reading this rebuilds
3730
3730
  * the arrays from it and caches them. The copies are safe to hold onto,
3731
3731
  * playing a sound detaches the buffer's own channel arrays.
3732
3732
  * @return {Array<Array<number>|Float32Array>|undefined} */
3733
- get sampleChannels(): (number[] | Float32Array)[];
3734
- rangeValue: number;
3733
+ get sampleChannels(): (number[] | Float32Array)[] | undefined;
3734
+ rangeValue: number | undefined;
3735
3735
  /** Move this sound's samples into an audio buffer that every play can share
3736
3736
  * Does nothing if there is already a buffer or no samples to build one from */
3737
3737
  buildSampleBuffer(): void;
@@ -4303,7 +4303,7 @@ declare module "littlejsengine" {
4303
4303
  * @return {Array<TileCollisionLayer>} - It throws for a map that is not whole cells, or a layer whose tiles do not
4304
4304
  * fill it, before it makes any layer
4305
4305
  * @memberof TileLayers */
4306
- export function tileLayersLoad(tileMapData: any, tileInfo?: TileInfo, renderOrder?: number, collisionLayer?: number | string, draw?: boolean): Array<TileCollisionLayer>;
4306
+ export function tileLayersLoad(tileMapData: any, tileInfo?: TileInfo, renderOrder?: number, collisionLayer?: string | number, draw?: boolean): Array<TileCollisionLayer>;
4307
4307
  /**
4308
4308
  * Make a Tiled map of a level of an LDtk project, to load with tileLayersLoad and objectLayersLoad
4309
4309
  * - Each Tiles, AutoLayer and IntGrid layer is a tile layer, the bottom one first as in Tiled; where LDtk stacks
@@ -4330,7 +4330,7 @@ declare module "littlejsengine" {
4330
4330
  * const layers = tileLayersLoad(map, tile(0, 16), 0, 'Collisions'); // its IntGrid layer is solid
4331
4331
  * objectLayersLoad(map);
4332
4332
  * @memberof TileLayers */
4333
- export function tileLayersFromLDtk(ldtk: any, level?: number | string): any;
4333
+ export function tileLayersFromLDtk(ldtk: any, level?: string | number): any;
4334
4334
  /** Add a type of object, so objectLayersLoad makes one wherever a map's object layer has an object of that type
4335
4335
  * - The name is the object's type in Tiled (its class in Tiled 1.9); it is a string because minified builds
4336
4336
  * rename classes
@@ -4411,9 +4411,9 @@ declare module "littlejsengine" {
4411
4411
  */
4412
4412
  constructor(pos?: Vector2, size?: Vector2, angle?: number, renderOrder?: number, canvasSize?: Vector2, useWebGL?: boolean);
4413
4413
  /** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
4414
- context: OffscreenCanvasRenderingContext2D;
4414
+ context: OffscreenCanvasRenderingContext2D | undefined;
4415
4415
  /** @property {OffscreenCanvas} - The canvas used by this layer */
4416
- canvas: OffscreenCanvas;
4416
+ canvas: OffscreenCanvas | undefined;
4417
4417
  /** @property {TextureInfo} - Texture info to use for this object rendering */
4418
4418
  textureInfo: TextureInfo;
4419
4419
  /** Draw this canvas layer centered in world space
@@ -4456,7 +4456,7 @@ declare module "littlejsengine" {
4456
4456
  data: TileLayerData[];
4457
4457
  /** @property {boolean} - Is this layer using a webgl texture? */
4458
4458
  isUsingWebGL: boolean;
4459
- tilesInWebGL: boolean;
4459
+ tilesInWebGL: boolean | undefined;
4460
4460
  /** @property {boolean} - Show this layer's bounds and values when the debug overlay's Debug Tiles is on,
4461
4461
  * turn it off for layers that only add noise */
4462
4462
  debugShow: boolean;
@@ -4535,8 +4535,8 @@ declare module "littlejsengine" {
4535
4535
  onRedraw(): void;
4536
4536
  redrawIfSwitched(): void;
4537
4537
  /** @type {[CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, number, Color, Shader|undefined]} */
4538
- savedRenderSettings: [CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, number, Color, Shader | undefined];
4539
- savedRenderTarget: any[];
4538
+ savedRenderSettings: [CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, number, Color, Shader | undefined] | undefined;
4539
+ savedRenderTarget: any[] | undefined;
4540
4540
  }
4541
4541
  /**
4542
4542
  * Tile Collision Layer - a tile layer with collision
@@ -5263,7 +5263,7 @@ declare module "littlejsengine" {
5263
5263
  /** @property {Color} - Baseline color applied to unlit areas of the scene. Defaults to BLACK (pitch dark). Set to a small RGB for a faint ambient. The lightmap is cleared to this color each frame, then lights add on top, then the result multiplies the scene. */
5264
5264
  ambientColor: Color;
5265
5265
  /** @property {Vector2} - Size of the lightmap texture, follows mainCanvasSize (css pixels, so it is not scaled by canvasPixelRatio) unless a size was passed */
5266
- textureSize: Vector2;
5266
+ textureSize: Vector2 | undefined;
5267
5267
  /** @property {boolean} - True when no size was passed, so the lightmap follows mainCanvasSize */
5268
5268
  textureSizeAuto: boolean;
5269
5269
  /** @property {WebGLTexture|undefined} - The lightmap texture
@@ -5416,14 +5416,14 @@ declare module "littlejsengine" {
5416
5416
  /** @property {number} - Wet/dry balance, 0 is fully dry and 1 is fully wet */
5417
5417
  mix: number;
5418
5418
  /** @property {GainNode} - Connect sounds to this node */
5419
- input: GainNode;
5419
+ input: GainNode | undefined;
5420
5420
  /** @property {GainNode} - This node carries the mixed result, send it somewhere with connect(), never by assigning here
5421
5421
  * - Unlike sound.output, which is where a sound's audio goes and can be set to an effect */
5422
- output: GainNode;
5422
+ output: GainNode | undefined;
5423
5423
  /** @property {GainNode} - Level of the unprocessed signal */
5424
- dryGain: GainNode;
5424
+ dryGain: GainNode | undefined;
5425
5425
  /** @property {GainNode} - Level of the processed signal */
5426
- wetGain: GainNode;
5426
+ wetGain: GainNode | undefined;
5427
5427
  /** Set the wet/dry balance
5428
5428
  * @param {number} mix - 0 is fully dry and 1 is fully wet
5429
5429
  * @param {number} [fadeTime] - Seconds to ramp over so the change doesn't click */
@@ -5466,7 +5466,7 @@ declare module "littlejsengine" {
5466
5466
  * @param {number} [mix] - Wet/dry balance, 0 is fully dry and 1 is fully wet */
5467
5467
  constructor(type?: BiquadFilterType, frequency?: number, q?: number, mix?: number);
5468
5468
  /** @property {BiquadFilterNode} - The filter node */
5469
- node: BiquadFilterNode;
5469
+ node: BiquadFilterNode | undefined;
5470
5470
  /** Set the cutoff or center frequency
5471
5471
  * @param {number} frequency - Frequency in Hz
5472
5472
  * @param {number} [fadeTime] - Seconds to sweep over */
@@ -5492,7 +5492,7 @@ declare module "littlejsengine" {
5492
5492
  * @param {number} [mix] - Wet/dry balance, 0 is fully dry and 1 is fully wet */
5493
5493
  constructor(duration?: number, decay?: number, mix?: number);
5494
5494
  /** @property {ConvolverNode} - The convolver node */
5495
- node: ConvolverNode;
5495
+ node: ConvolverNode | undefined;
5496
5496
  /** Change the room by rebuilding the impulse response
5497
5497
  * @param {number} duration - Seconds until the reverb tail is silent
5498
5498
  * @param {number} [decay] - How quickly the tail fades, higher is faster */
@@ -5518,9 +5518,9 @@ declare module "littlejsengine" {
5518
5518
  * @param {number} [mix] - Wet/dry balance, 0 is fully dry and 1 is fully wet */
5519
5519
  constructor(time?: number, feedback?: number, mix?: number);
5520
5520
  /** @property {DelayNode} - The delay node */
5521
- node: DelayNode;
5521
+ node: DelayNode | undefined;
5522
5522
  /** @property {GainNode} - How much of the delayed signal feeds back in */
5523
- feedbackGain: GainNode;
5523
+ feedbackGain: GainNode | undefined;
5524
5524
  /** Set the time between echoes
5525
5525
  * - Browsers hold a delay in a feedback loop to at least one render quantum, so 0 is not a bypass
5526
5526
  * @param {number} time - Seconds, up to 5
@@ -5547,7 +5547,7 @@ declare module "littlejsengine" {
5547
5547
  /** @property {number} - How hard the signal is driven, 0 is clean and 1 is crushed */
5548
5548
  amount: number;
5549
5549
  /** @property {WaveShaperNode} - The wave shaper node */
5550
- node: WaveShaperNode;
5550
+ node: WaveShaperNode | undefined;
5551
5551
  /** Set how hard to drive the signal, rebuilds the shaping curve
5552
5552
  * @param {number} amount - 0 is clean and 1 is crushed */
5553
5553
  setAmount(amount: number): void;
@@ -5568,7 +5568,7 @@ declare module "littlejsengine" {
5568
5568
  * @param {number} [mix] - Wet/dry balance, 0 is fully dry and 1 is fully wet */
5569
5569
  constructor(threshold?: number, ratio?: number, mix?: number);
5570
5570
  /** @property {DynamicsCompressorNode} - The compressor node */
5571
- node: DynamicsCompressorNode;
5571
+ node: DynamicsCompressorNode | undefined;
5572
5572
  /** Set the level above which the signal is reduced
5573
5573
  * @param {number} threshold - Level in dB
5574
5574
  * @param {number} [fadeTime] - Seconds to ramp over */
@@ -5753,7 +5753,7 @@ declare module "littlejsengine" {
5753
5753
  * @param {Color} [shadowColor]
5754
5754
  * @param {number} [shadowBlur]
5755
5755
  * @param {Vector2} [shadowOffset] */
5756
- drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: 'left' | 'center' | 'right', font?: string, fontStyle?: string, applyMaxWidth?: boolean, textShadow?: Vector2, shadowColor?: Color, shadowBlur?: number, shadowOffset?: Vector2): void;
5756
+ drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: "center" | "left" | "right", font?: string, fontStyle?: string, applyMaxWidth?: boolean, textShadow?: Vector2, shadowColor?: Color, shadowBlur?: number, shadowOffset?: Vector2): void;
5757
5757
  /**
5758
5758
  * @callback DragAndDropCallback - Callback for drag and drop events
5759
5759
  * @param {DragEvent} event - The drag event
@@ -5770,13 +5770,13 @@ declare module "littlejsengine" {
5770
5770
  * @param {Vector2} pos
5771
5771
  * @return {Vector2} */
5772
5772
  screenToNative(pos: Vector2): Vector2;
5773
- set keyInputObject(arg: UIObject);
5773
+ set keyInputObject(arg: UIObject | undefined);
5774
5774
  /** Object to send keyboard input to (typically a UITextInput), which keeps the keys from the game while set.
5775
5775
  * The keyboard listeners are only attached while this is set,
5776
5776
  * so games that never use text input pay no event-handling cost.
5777
5777
  * To end typing in a field, call its stopEditing(), which also fires its onChange and release sound
5778
5778
  * @type {UIObject|undefined} */
5779
- get keyInputObject(): UIObject;
5779
+ get keyInputObject(): UIObject | undefined;
5780
5780
  /** Destroy and remove all objects */
5781
5781
  destroyObjects(): void;
5782
5782
  /** Get all navigable UI objects sorted by navigationIndex
@@ -6004,7 +6004,8 @@ declare module "littlejsengine" {
6004
6004
  * @param {'left'|'center'|'right'} [align]
6005
6005
  * @param {string} [font=uiSystem.defaultFont]
6006
6006
  */
6007
- constructor(pos?: Vector2, size?: Vector2, text?: string, align?: 'left' | 'center' | 'right', font?: string);
6007
+ constructor(pos?: Vector2, size?: Vector2, text?: string, align?: "center" | "left" | "right", font?: string);
6008
+ text: string;
6008
6009
  }
6009
6010
  /**
6010
6011
  * UITextInput - An editable text input field
@@ -6024,6 +6025,7 @@ declare module "littlejsengine" {
6024
6025
  constructor(pos?: Vector2, size?: Vector2, text?: string);
6025
6026
  /** @property {number} - Max length of input (0 = no limit) */
6026
6027
  maxLength: number;
6028
+ text: string;
6027
6029
  /** Stop editing the text */
6028
6030
  stopEditing(): void;
6029
6031
  }
@@ -6064,6 +6066,7 @@ declare module "littlejsengine" {
6064
6066
  constructor(pos?: Vector2, size?: Vector2, text?: string, color?: Color);
6065
6067
  /** @property {Vector2} - Text offset for the button */
6066
6068
  textOffset: Vector2;
6069
+ text: string;
6067
6070
  }
6068
6071
  /**
6069
6072
  * UICheckbox - A UI object that acts as a checkbox
@@ -6081,6 +6084,7 @@ declare module "littlejsengine" {
6081
6084
  constructor(pos?: Vector2, size?: Vector2, checked?: boolean, text?: string, color?: Color);
6082
6085
  /** @property {boolean} - Is the checkbox currently checked? */
6083
6086
  checked: boolean;
6087
+ text: string;
6084
6088
  }
6085
6089
  /**
6086
6090
  * UISlider - A UI object that acts as a slider or scrollbar
@@ -6107,6 +6111,7 @@ declare module "littlejsengine" {
6107
6111
  handleSlice: TileSlice | undefined;
6108
6112
  /** @property {boolean} - Should it fill up like a progress bar? */
6109
6113
  fillMode: boolean;
6114
+ text: string;
6110
6115
  /** Draw the handle, or the fill of a fill mode slider, with the handle slice, the slider's own, or a rectangle
6111
6116
  * @param {Vector2} pos
6112
6117
  * @param {Vector2} size
@@ -6290,13 +6295,15 @@ declare module "littlejsengine" {
6290
6295
  * @param {boolean} [includeSensors] - Also hit sensors, trigger zones are passed through by default
6291
6296
  * @return {Box2dRaycastResult|undefined} */
6292
6297
  raycast(start: Vector2, end: Vector2, includeSensors?: boolean): Box2dRaycastResult | undefined;
6293
- /** box aabb cast and return all the objects
6298
+ /** Every object whose shapes' bounding boxes overlap a box, not the shapes themselves, so near the corner of a
6299
+ * turned box or a circle it finds one the box does not touch; use pointCast or a raycast for exact
6294
6300
  * @param {Vector2} pos
6295
6301
  * @param {Vector2} size
6296
6302
  * @param {boolean} [includeSensors] - Also find sensors, trigger zones are passed through by default
6297
6303
  * @return {Array<Box2dObject>} */
6298
6304
  boxCastAll(pos: Vector2, size: Vector2, includeSensors?: boolean): Array<Box2dObject>;
6299
- /** box aabb cast and return the first object
6305
+ /** The first object whose shapes' bounding boxes overlap a box, not the shapes themselves, so near the corner of
6306
+ * a turned box or a circle it finds one the box does not touch; use pointCast or a raycast for exact
6300
6307
  * @param {Vector2} pos
6301
6308
  * @param {Vector2} size
6302
6309
  * @param {boolean} [includeSensors] - Also find sensors, trigger zones are passed through by default
@@ -7281,7 +7288,7 @@ declare module "littlejsengine" {
7281
7288
  * @param {boolean} [useWebGL] - Use WebGL for rendering
7282
7289
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas context to use
7283
7290
  * @memberof DrawUtilities */
7284
- export function drawNineSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, color?: Color | number, borderSize?: number, additiveColor?: Color, extraSpace?: number, angle?: number, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, ...args: any[]): void;
7291
+ export function drawNineSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, color?: number | Color, borderSize?: number, additiveColor?: Color, extraSpace?: number, angle?: number, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, ...args: any[]): void;
7285
7292
  /** Draw a scalable three-slice UI element in world space
7286
7293
  * Color and additive color apply in WebGL and Canvas2D (with canvasColorTiles)
7287
7294
  * The three-slice samples 3 consecutive tiles from the tilesheet, it does not
@@ -7317,7 +7324,7 @@ declare module "littlejsengine" {
7317
7324
  * @param {boolean} [useWebGL] - Use WebGL for rendering
7318
7325
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas context to use
7319
7326
  * @memberof DrawUtilities */
7320
- export function drawThreeSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, color?: Color | number, borderSize?: number, additiveColor?: Color, extraSpace?: number, angle?: number, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, ...args: any[]): void;
7327
+ export function drawThreeSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, color?: number | Color, borderSize?: number, additiveColor?: Color, extraSpace?: number, angle?: number, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, ...args: any[]): void;
7321
7328
  /**
7322
7329
  * A tile drawn as a box of any size, kept as a style to draw with, like a UI skin
7323
7330
  * - 9 slices is a nine-slice from the 3x3 block of tiles at tileInfo, see drawNineSlice
@@ -8171,7 +8178,7 @@ declare module "littlejsengine" {
8171
8178
  static lookAt(eye: Vector3, target: Vector3, up?: Vector3): Matrix4;
8172
8179
  /** Create a matrix, identity by default
8173
8180
  * @param {Float32Array|Array<number>} [m] - 16 column major values */
8174
- constructor(m?: Float32Array | Array<number>);
8181
+ constructor(m?: number[] | Float32Array);
8175
8182
  /** @property {Float32Array} - The 16 column major values */
8176
8183
  m: Float32Array;
8177
8184
  /** Returns a new matrix that is a copy of this
@@ -8640,10 +8647,10 @@ declare module "littlejsengine" {
8640
8647
  * like polished metal; set from each object's shininess
8641
8648
  * @return {number} */
8642
8649
  get shininess(): number;
8643
- set normalMap(arg: TextureInfo);
8650
+ set normalMap(arg: TextureInfo | undefined);
8644
8651
  /** Normal map for the next draws, set from each object's normalMap
8645
8652
  * @return {TextureInfo|undefined} */
8646
- get normalMap(): TextureInfo;
8653
+ get normalMap(): TextureInfo | undefined;
8647
8654
  set normalScale(arg: number);
8648
8655
  /** How strongly the normal map bends the surface, set from each object's normalScale
8649
8656
  * @return {number} */
@@ -8652,20 +8659,20 @@ declare module "littlejsengine" {
8652
8659
  /** How much the surface reflects the sky, 0 to 1, set from each object's reflectivity
8653
8660
  * @return {number} */
8654
8661
  get reflectivity(): number;
8655
- set emissiveMap(arg: TextureInfo);
8662
+ set emissiveMap(arg: TextureInfo | undefined);
8656
8663
  /** Emissive map for the next draws, set from each object's emissiveMap
8657
8664
  * @return {TextureInfo|undefined} */
8658
- get emissiveMap(): TextureInfo;
8665
+ get emissiveMap(): TextureInfo | undefined;
8659
8666
  set emissiveMapColor(arg: Color);
8660
8667
  /** Multiplies the emissive map, set from each object's emissiveMapColor; compared by its rgb, so a Color
8661
8668
  * changed in place is seen when it is set again, and undefined is white
8662
8669
  * @return {Color} */
8663
8670
  get emissiveMapColor(): Color;
8664
- set shader(arg: Shader);
8671
+ set shader(arg: Shader | undefined);
8665
8672
  /** Custom Shader for the next draws, set from each object's shader; undefined draws
8666
8673
  * with the plugin's own
8667
8674
  * @return {Shader|undefined} */
8668
- get shader(): Shader;
8675
+ get shader(): Shader | undefined;
8669
8676
  set receiveShadow(arg: boolean);
8670
8677
  /** Darken by the shadow map when shadows are on, turn it off for things that should
8671
8678
  * stay lit inside a shadow
@@ -8715,7 +8722,7 @@ declare module "littlejsengine" {
8715
8722
  * @param {Vector2|Ray3D} from - A screen position like mousePosScreen, or a ray to look along
8716
8723
  * @param {Array<EngineObject>} [objects] - Defaults to every object; only those with a mesh or a sprite count
8717
8724
  * @return {{object: EngineObject3D, distance: number}|undefined} */
8718
- pick(from: Vector2 | Ray3D, objects?: Array<EngineObject>): {
8725
+ pick(from: Vector2 | Ray3D, objects?: EngineObject[]): {
8719
8726
  object: EngineObject3D;
8720
8727
  distance: number;
8721
8728
  } | undefined;
@@ -8752,7 +8759,7 @@ declare module "littlejsengine" {
8752
8759
  * @param {TileInfo|TextureInfo} [tileInfo] - Texture, mesh uvs map across the tile or the whole texture
8753
8760
  * @param {Color} [color] - Tint
8754
8761
  * @return {void} */
8755
- drawMesh(mesh: Mesh, matrix?: Matrix4 | Vector3, tileInfo?: TileInfo | TextureInfo, color?: Color): void;
8762
+ drawMesh(mesh: Mesh, matrix?: Vector3 | Matrix4, tileInfo?: TileInfo | TextureInfo, color?: Color): void;
8756
8763
  /** Draw a triangle strip, batched into the stream with the current draw state
8757
8764
  * - Strip order: the first three points make a triangle, then each point makes another with the two before it
8758
8765
  * - List the first three points counter clockwise as seen from the front, or the face points away
@@ -8765,14 +8772,14 @@ declare module "littlejsengine" {
8765
8772
  * @param {Color|Array<Color>} [colors] - One for all or one per point, vertex colors come before the texture
8766
8773
  * @param {TileInfo|TextureInfo} [tileInfo] - Texture for this strip
8767
8774
  * @return {void} */
8768
- drawStrip(points: Array<Vector3>, normals?: Vector3 | Array<Vector3>, uvs?: Vector2 | Array<Vector2>, colors?: Color | Array<Color>, tileInfo?: TileInfo | TextureInfo): void;
8775
+ drawStrip(points: Array<Vector3>, normals?: Vector3 | Vector3[], uvs?: Vector2 | Vector2[], colors?: Color | Color[], tileInfo?: TileInfo | TextureInfo): void;
8769
8776
  /** Draw a strip with lighting off, for camera facing shapes where the light direction means nothing
8770
8777
  * @param {Array<Vector3>} points - Strip order
8771
8778
  * @param {Vector3|Array<Vector3>} [normals]
8772
8779
  * @param {Vector2|Array<Vector2>} [uvs]
8773
8780
  * @param {Color|Array<Color>} [colors]
8774
8781
  * @param {TileInfo|TextureInfo} [tileInfo] */
8775
- drawStripUnlit(points: Array<Vector3>, normals?: Vector3 | Array<Vector3>, uvs?: Vector2 | Array<Vector2>, colors?: Color | Array<Color>, tileInfo?: TileInfo | TextureInfo): void;
8782
+ drawStripUnlit(points: Array<Vector3>, normals?: Vector3 | Vector3[], uvs?: Vector2 | Vector2[], colors?: Color | Color[], tileInfo?: TileInfo | TextureInfo): void;
8776
8783
  /** Draw the pending stream vertices as one strip with the state they were drawn under, called automatically when needed */
8777
8784
  flush(): void;
8778
8785
  /** Build a mesh once out of draw calls, instead of redrawing the shapes every frame
@@ -8820,7 +8827,7 @@ declare module "littlejsengine" {
8820
8827
  * @param {Vector3|number} [size] - Full size, a number for a cube
8821
8828
  * @param {Color} [color]
8822
8829
  * @param {Vector3} [rotation] - vec3(pitch, yaw, roll) */
8823
- drawBox(pos: Vector3, size?: Vector3 | number, color?: Color, rotation?: Vector3): void;
8830
+ drawBox(pos: Vector3, size?: number | Vector3, color?: Color, rotation?: Vector3): void;
8824
8831
  /** Draw a sphere, untextured and smooth shaded
8825
8832
  * @param {Vector3} pos - Center
8826
8833
  * @param {number} [size] - Diameter
@@ -8843,7 +8850,7 @@ declare module "littlejsengine" {
8843
8850
  * @param {Vector3} d
8844
8851
  * @param {TileInfo|TextureInfo} [tileInfo]
8845
8852
  * @param {Color|Array<Color>} [color] - One for all or one per corner */
8846
- drawQuad(a: Vector3, b: Vector3, c: Vector3, d: Vector3, tileInfo?: TileInfo | TextureInfo, color?: Color | Array<Color>): void;
8853
+ drawQuad(a: Vector3, b: Vector3, c: Vector3, d: Vector3, tileInfo?: TileInfo | TextureInfo, color?: Color | Color[]): void;
8847
8854
  /** Draw a triangle, counter clockwise from outside is the front
8848
8855
  * @param {Vector3} a
8849
8856
  * @param {Vector3} b
@@ -8865,7 +8872,7 @@ declare module "littlejsengine" {
8865
8872
  * @param {Color|Array<Color>} [color] - One for all or one per point
8866
8873
  * @param {Vector3|Array<Vector3>} [side] - Direction across the ribbon, one for all or one per point, default
8867
8874
  * faces the camera */
8868
- drawRibbon(points: Array<Vector3>, width?: number | Array<number>, tileInfo?: TileInfo | TextureInfo, color?: Color | Array<Color>, side?: Vector3 | Array<Vector3>): void;
8875
+ drawRibbon(points: Array<Vector3>, width?: number | number[], tileInfo?: TileInfo | TextureInfo, color?: Color | Color[], side?: Vector3 | Vector3[]): void;
8869
8876
  /** Draw a disc that fades to transparent at the rim, unlit, for glows, puffs and sky dots
8870
8877
  * @param {Vector3} pos - Center
8871
8878
  * @param {number} [size] - Diameter
@@ -9184,7 +9191,7 @@ declare module "littlejsengine" {
9184
9191
  * @param {Vector2|Array<Vector2>} [uvs] - One for all or one per point, default zero
9185
9192
  * @param {Color|Array<Color>} [colors] - One for all or one per point, default white
9186
9193
  * @return {Mesh} */
9187
- addStrip(points: Array<Vector3>, normals?: Vector3 | Array<Vector3>, uvs?: Vector2 | Array<Vector2>, colors?: Color | Array<Color>): Mesh;
9194
+ addStrip(points: Array<Vector3>, normals?: Vector3 | Vector3[], uvs?: Vector2 | Vector2[], colors?: Color | Color[]): Mesh;
9188
9195
  /** Add triangles over their own vertices, the indexed form a model file comes in
9189
9196
  * - The mesh becomes indexed: a strip mesh is turned into triangles first, and strips added later join as triangles
9190
9197
  * - List each triangle counter clockwise as seen from the front, like a strip's first triangle
@@ -9194,7 +9201,7 @@ declare module "littlejsengine" {
9194
9201
  * @param {Vector2|Array<Vector2>} [uvs] - One for all or one per point, default zero
9195
9202
  * @param {Color|Array<Color>} [colors] - One for all or one per point, default white
9196
9203
  * @return {Mesh} */
9197
- addTriangles(points: Array<Vector3>, indices: Array<number>, normals?: Vector3 | Array<Vector3>, uvs?: Vector2 | Array<Vector2>, colors?: Color | Array<Color>): Mesh;
9204
+ addTriangles(points: Array<Vector3>, indices: Array<number>, normals?: Vector3 | Vector3[], uvs?: Vector2 | Vector2[], colors?: Color | Color[]): Mesh;
9198
9205
  /** Turn a strip mesh into the indexed form, each distinct vertex once and the real triangles over them, in place
9199
9206
  * - An indexed mesh is left as it is; the builders make strips and a loader makes this, and either draws the same
9200
9207
  * @return {Mesh} */
@@ -9207,13 +9214,13 @@ declare module "littlejsengine" {
9207
9214
  * @param {Color|Array<Color>} [color] - One for all or one per corner
9208
9215
  * @param {Array<Vector2>} [uvs] - One per corner, default across the tile
9209
9216
  * @return {Mesh} */
9210
- addQuad(a: Vector3, b: Vector3, c: Vector3, d: Vector3, color?: Color | Array<Color>, uvs?: Array<Vector2>): Mesh;
9217
+ addQuad(a: Vector3, b: Vector3, c: Vector3, d: Vector3, color?: Color | Color[], uvs?: Vector2[]): Mesh;
9211
9218
  /** Append another mesh transformed by a matrix, for building one shape out of several
9212
9219
  * @param {Mesh} mesh
9213
9220
  * @param {Matrix4|Vector3} [matrix] - Transform, or just a position to move it to
9214
9221
  * @param {Color} [color] - Multiplies the appended vertex colors
9215
9222
  * @return {Mesh} */
9216
- combine(mesh: Mesh, matrix?: Matrix4 | Vector3, color?: Color): Mesh;
9223
+ combine(mesh: Mesh, matrix?: Vector3 | Matrix4, color?: Color): Mesh;
9217
9224
  /** Returns a new mesh: this one and its mirror image across the plane through the origin facing axis
9218
9225
  * - For modeling half a shape against that plane, a part that crosses it overlaps its image
9219
9226
  * @param {Vector3} [axis] - Faces the mirror plane, vec3(1,0,0) mirrors across x
@@ -9228,7 +9235,7 @@ declare module "littlejsengine" {
9228
9235
  * @param {Mesh} mesh - Closed, as the builders make them apart from the open ones like buildGrid
9229
9236
  * @param {Matrix4|Vector3} [matrix] - Places the other mesh, or just a position to move it to
9230
9237
  * @return {Mesh} */
9231
- union(mesh: Mesh, matrix?: Matrix4 | Vector3): Mesh;
9238
+ union(mesh: Mesh, matrix?: Vector3 | Matrix4): Mesh;
9232
9239
  /** Returns a new mesh of this one with the other cut out of it, CSG with BSP trees
9233
9240
  * - Both must be closed, every edge shared by two triangles, as the builders make them apart from the open
9234
9241
  * ones like buildGrid and buildRibbon; the result is closed and indexed, and neither mesh changes
@@ -9245,12 +9252,12 @@ declare module "littlejsengine" {
9245
9252
  * @return {Mesh}
9246
9253
  * @example
9247
9254
  * const wall = buildBox(vec3(4, 3, .5)).subtract(buildBox(vec3(1, 2, 1)), vec3(0, -.5, 0)); // a doorway */
9248
- subtract(mesh: Mesh, matrix?: Matrix4 | Vector3): Mesh;
9255
+ subtract(mesh: Mesh, matrix?: Vector3 | Matrix4): Mesh;
9249
9256
  /** Returns a new mesh of only what is in both this mesh and the other, see subtract
9250
9257
  * @param {Mesh} mesh - Closed, as the builders make them apart from the open ones like buildGrid
9251
9258
  * @param {Matrix4|Vector3} [matrix] - Places the other mesh, or just a position to move it to
9252
9259
  * @return {Mesh} */
9253
- intersect(mesh: Mesh, matrix?: Matrix4 | Vector3): Mesh;
9260
+ intersect(mesh: Mesh, matrix?: Vector3 | Matrix4): Mesh;
9254
9261
  /** Scale every uv, so a whole texture repeats across the mesh when its TextureInfo wraps
9255
9262
  * @param {Vector2|number} scale - Repeats across and up, a number for both
9256
9263
  * @return {Mesh} */
@@ -9303,7 +9310,7 @@ declare module "littlejsengine" {
9303
9310
  * @param {Matrix4|Vector3} [matrix] - Object transform, or just a position to draw it at
9304
9311
  * @param {TileInfo|TextureInfo} [tileInfo] - Texture, mesh uvs map across the tile or the whole texture
9305
9312
  * @param {Color} [color] - Tint */
9306
- render(matrix?: Matrix4 | Vector3, tileInfo?: TileInfo | TextureInfo, color?: Color): void;
9313
+ render(matrix?: Vector3 | Matrix4, tileInfo?: TileInfo | TextureInfo, color?: Color): void;
9307
9314
  /** Delete the GPU buffer now, the CPU arrays stay so the mesh can be rendered again
9308
9315
  * - Optional, the buffer is freed anyway once the mesh is garbage collected, this frees it right away */
9309
9316
  dispose(): void;
@@ -9362,11 +9369,11 @@ declare module "littlejsengine" {
9362
9369
  boundsEnd: number;
9363
9370
  /** @type {number|undefined} */
9364
9371
  fixedRadius: number | undefined;
9365
- buffer: WebGLBuffer;
9372
+ buffer: WebGLBuffer | null | undefined;
9366
9373
  /** @type {WebGLBuffer|undefined} */
9367
9374
  colorBuffer: WebGLBuffer | undefined;
9368
9375
  bufferGeneration: number;
9369
- uvTileInfo: TileInfo | TextureInfo;
9376
+ uvTileInfo: TileInfo | TextureInfo | undefined;
9370
9377
  /** Place an instance by its position, rotation and scale, what buildMatrix takes, written straight in with no
9371
9378
  * matrix made; in world space
9372
9379
  * @param {number} i
@@ -9507,7 +9514,7 @@ declare module "littlejsengine" {
9507
9514
  * @return {Mesh}
9508
9515
  * @memberof Render3D
9509
9516
  */
9510
- export function buildBox(size?: Vector3 | number, bevel?: number, bevelSegments?: number): Mesh;
9517
+ export function buildBox(size?: number | Vector3, bevel?: number, bevelSegments?: number): Mesh;
9511
9518
  /**
9512
9519
  * Build a heightfield grid in the XZ plane centered on the origin
9513
9520
  * - smooth rounds the lighting across cells and colors each corner
@@ -9525,7 +9532,7 @@ declare module "littlejsengine" {
9525
9532
  * @example
9526
9533
  * const ground = buildGrid(vec2(20), 10, (x, z)=> (floor(x / 2) + floor(z / 2)) & 1 ? GRAY : WHITE); // 2 unit checks
9527
9534
  */
9528
- export function buildGrid(size?: Vector2 | number, segments?: Vector2 | number, color?: Color | ((arg0: number, arg1: number) => Color), heightFunction?: (arg0: number, arg1: number) => number, smooth?: boolean): Mesh;
9535
+ export function buildGrid(size?: number | Vector2, segments?: number | Vector2, color?: Color | ((arg0: number, arg1: number) => Color), heightFunction?: (arg0: number, arg1: number) => number, smooth?: boolean): Mesh;
9529
9536
  /**
9530
9537
  * Build a lit ribbon along a path, for roads, tracks and walls
9531
9538
  * - Each segment is a flat quad, the sides are across the path in the plane of the up vector
@@ -9540,7 +9547,7 @@ declare module "littlejsengine" {
9540
9547
  * @example
9541
9548
  * const road = buildRibbon(trackPoints, 8, GRAY, true); // a loop of road
9542
9549
  */
9543
- export function buildRibbon(points: Array<Vector3>, width?: number | Array<number>, color?: Color | Array<Color>, closed?: boolean, up?: Vector3): Mesh;
9550
+ export function buildRibbon(points: Array<Vector3>, width?: number | number[], color?: Color | Color[], closed?: boolean, up?: Vector3): Mesh;
9544
9551
  /**
9545
9552
  * Build a hull from a row of diamond shaped slices along Z, for ships, planes and cars
9546
9553
  * - Each slice is [z, width, top, bottom, sideHeight]
@@ -9632,7 +9639,7 @@ declare module "littlejsengine" {
9632
9639
  * @param {Array<Array<Color>>|HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|TextureInfo} [colors]
9633
9640
  * @param {Vector3} [pos3D] - Center of the map
9634
9641
  * @param {boolean} [smooth] - Defaults to render3D.smoothShading */
9635
- constructor(heights: Array<Array<number>> | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | TextureInfo, mapSize?: Vector2, height?: number, colors?: Array<Array<Color>> | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | TextureInfo, pos3D?: Vector3, smooth?: boolean);
9642
+ constructor(heights: Array<Array<number>> | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | TextureInfo, mapSize?: Vector2, height?: number, colors?: OffscreenCanvas | HTMLCanvasElement | HTMLImageElement | TextureInfo | Color[][], pos3D?: Vector3, smooth?: boolean);
9636
9643
  /** @property {Array<Array<number>>} - Heights 0-1 as [row][column], rows along Z, rebuild() after changing them */
9637
9644
  heights: number[][];
9638
9645
  /** @property {Array<Array<Color>>|undefined} - Vertex colors as [row][column], undefined for white
@@ -9692,7 +9699,7 @@ declare module "littlejsengine" {
9692
9699
  levelSegment3D(from: Vector3, to: Vector3): {
9693
9700
  distance: number;
9694
9701
  normal: Vector3;
9695
- };
9702
+ } | undefined;
9696
9703
  /** Keep an object above the ground, called by the engine for each object with collideLevel
9697
9704
  * @param {EngineObject3D} o
9698
9705
  * @param {Vector3} oldPos - Where it was before it moved
@@ -9731,6 +9738,8 @@ declare module "littlejsengine" {
9731
9738
  constructor(pos3D?: Vector3, mapSize?: Vector3, tileInfo?: TileInfo);
9732
9739
  /** @property {Vector3} - Cells along X, Y and Z */
9733
9740
  mapSize: Vector3;
9741
+ /** @property {TileInfo} - The sheet's first tile, rebuild() after changing it or resizing its texture */
9742
+ tileInfo: TileInfo;
9734
9743
  /** @property {Uint8Array} - The block type of each cell, x + mapSize.x * (y + mapSize.y * z), 0 empty; call
9735
9744
  * rebuild() after changing it directly */
9736
9745
  data: Uint8Array;
@@ -9920,13 +9929,13 @@ declare module "littlejsengine" {
9920
9929
  * @param {Color} [color] - Tints the flare, with the light's own color
9921
9930
  * @return {LensFlare3D} - The flare, to change: light.addFlare().shapes = ['hex'] */
9922
9931
  addFlare(size?: number, count?: number, intensity?: number, saturation?: number, color?: Color): LensFlare3D;
9923
- set flare(arg: LensFlare3D);
9932
+ set flare(arg: LensFlare3D | undefined);
9924
9933
  /** The light's lens flare, undefined for none: addFlare makes it, or set a LensFlare3D of your own, and
9925
9934
  * destroying the flare takes it away
9926
9935
  * - The flare is the light's: it is attached to the light as its child, so it stays through a scene change
9927
9936
  * when the light does, and is destroyed with the light or when another takes its place
9928
9937
  * @type {LensFlare3D|undefined} */
9929
- get flare(): LensFlare3D;
9938
+ get flare(): LensFlare3D | undefined;
9930
9939
  }
9931
9940
  /**
9932
9941
  * DirectionalLight3D - A Light3D that shines from far away with no falloff, like sunlight
@@ -10220,7 +10229,7 @@ declare module "littlejsengine" {
10220
10229
  }>;
10221
10230
  /** Forget the trail so far, for when the object teleports */
10222
10231
  clear(): void;
10223
- worldPos3D: Vector3;
10232
+ worldPos3D: Vector3 | undefined;
10224
10233
  }
10225
10234
  /**
10226
10235
  * A part of a lens flare
@@ -10308,18 +10317,28 @@ declare module "littlejsengine" {
10308
10317
  * glowSize and ghostSize, a glow and a core at the sun and the ghosts, made again when one of those changes
10309
10318
  * @return {Array<LensFlareElement>} */
10310
10319
  getElements(): Array<LensFlareElement>;
10320
+ /** What the flare is of, seen from the camera: the way to it, how far it is, Infinity for the sun and for a
10321
+ * directional light, which shines from its place toward the origin, and a point to find it on the screen by;
10322
+ * undefined with no direction, or a light that is gone or at the camera
10323
+ * @return {{direction: Vector3, distance: number, pos: Vector3}|undefined}
10324
+ * @ignore */
10311
10325
  flareSource(): {
10312
10326
  direction: Vector3;
10313
10327
  distance: number;
10314
10328
  pos: Vector3;
10315
- };
10329
+ } | undefined;
10330
+ /** How the flare would show with nothing in the way: where its source is on the screen, how strong it is there,
10331
+ * fading as it leaves the screen, its tint and the height its sizes are parts of; undefined when it would not
10332
+ * show at all, behind the camera, off the screen, or of a light that is off or seen from outside its cone
10333
+ * @return {{sun: Vector2, center: Vector2, strength: number, tint: Color, height: number}|undefined}
10334
+ * @ignore */
10316
10335
  flareLook(): {
10317
10336
  sun: Vector2;
10318
10337
  center: Vector2;
10319
10338
  strength: number;
10320
10339
  tint: Color;
10321
10340
  height: number;
10322
- };
10341
+ } | undefined;
10323
10342
  /** Where the sun, or the flare's light, is on the screen, in pixels like mousePosScreen, undefined when it is
10324
10343
  * behind the camera
10325
10344
  * @return {Vector2|undefined} */
@@ -10353,7 +10372,7 @@ declare module "littlejsengine" {
10353
10372
  * @return {Array<EngineObject3D>}
10354
10373
  * @memberof Render3D
10355
10374
  */
10356
- export function engineObjectsCollect3D(pos: Vector3, size: Vector3 | number, objects?: Array<EngineObject>, testCenters?: boolean): Array<EngineObject3D>;
10375
+ export function engineObjectsCollect3D(pos: Vector3, size: Vector3 | number, objects?: EngineObject[], testCenters?: boolean): Array<EngineObject3D>;
10357
10376
  /**
10358
10377
  * Call a function for each EngineObject3D whose box overlaps a sphere or a box
10359
10378
  * - An object destroyed by an earlier callback is skipped
@@ -10364,7 +10383,7 @@ declare module "littlejsengine" {
10364
10383
  * @param {boolean} [testCenters] - Test only each object's center, see engineObjectsCollect3D
10365
10384
  * @memberof Render3D
10366
10385
  */
10367
- export function engineObjectsCallback3D(pos: Vector3, size: Vector3 | number, callback: (arg0: EngineObject3D) => void, objects?: Array<EngineObject>, testCenters?: boolean): void;
10386
+ export function engineObjectsCallback3D(pos: Vector3, size: Vector3 | number, callback: (arg0: EngineObject3D) => void, objects?: EngineObject[], testCenters?: boolean): void;
10368
10387
  /**
10369
10388
  * Collect every EngineObject3D a ray passes through, nearest first, the 3D twin of engineObjectsRaycast
10370
10389
  * - The ray has no end, so everything along it counts however far away it is
@@ -10374,7 +10393,7 @@ declare module "littlejsengine" {
10374
10393
  * @return {Array<EngineObject3D>}
10375
10394
  * @memberof Render3D
10376
10395
  */
10377
- export function engineObjectsRaycast3D(ray: Ray3D, objects?: Array<EngineObject>): Array<EngineObject3D>;
10396
+ export function engineObjectsRaycast3D(ray: Ray3D, objects?: EngineObject[]): Array<EngineObject3D>;
10378
10397
  /**
10379
10398
  * Parse Wavefront OBJ text into a Mesh
10380
10399
  * - Reads v, vt, vn and f lines with convex polygons of any size, materials and groups are ignored
@@ -10405,7 +10424,7 @@ declare module "littlejsengine" {
10405
10424
  */
10406
10425
  export class GLTFModel {
10407
10426
  /** @param {Array<GLTFPart>} parts @param {Array<GLTFAnimation>} [animations] @param {Object} [nodeTree] */
10408
- constructor(parts: Array<GLTFPart>, animations?: Array<GLTFAnimation>, nodeTree?: any);
10427
+ constructor(parts: Array<GLTFPart>, animations?: GLTFAnimation[], nodeTree?: any);
10409
10428
  /** @property {Array<GLTFPart>} - One per primitive of every node that has a mesh */
10410
10429
  parts: GLTFPart[];
10411
10430
  /** @property {Array<GLTFAnimation>} - The animations, play one through createObject's GLTFObject
@@ -10623,7 +10642,7 @@ declare module "littlejsengine" {
10623
10642
  * @param {number} [time] - How long to show it, 0 is one frame
10624
10643
  * @param {Vector3} [rotation] - vec3(pitch, yaw, roll)
10625
10644
  * @memberof Render3D */
10626
- export function debugBox3D(pos: Vector3, size?: Vector3 | number, color?: Color, time?: number, rotation?: Vector3): void;
10645
+ export function debugBox3D(pos: Vector3, size?: number | Vector3, color?: Color, time?: number, rotation?: Vector3): void;
10627
10646
  /** Draw a debug wireframe sphere as three rings
10628
10647
  * @param {Vector3} pos - Center
10629
10648
  * @param {number} [size] - Diameter
@@ -10825,7 +10844,7 @@ declare module "littlejsengine" {
10825
10844
  /** @property {Object} - The three.js perspective camera */
10826
10845
  camera: any;
10827
10846
  /** @property {boolean} - Lock the camera to the LittleJS 2D camera so the z=0 plane matches world space */
10828
- cameraAlign2D: boolean;
10847
+ cameraAlign2D: boolean | undefined;
10829
10848
  /** @property {number|undefined} - Near plane of the aligned camera before any zoom out, from camera.near on the
10830
10849
  * first aligned frame; while aligned, change this rather than camera.near
10831
10850
  * @type {number|undefined} */
@@ -10907,9 +10926,9 @@ declare module "littlejsengine" {
10907
10926
  /** @property {number} - Width and height of the sheet in pixels */
10908
10927
  size: number;
10909
10928
  /** @property {OffscreenCanvasRenderingContext2D} - 2d context for the canvas */
10910
- context: OffscreenCanvasRenderingContext2D;
10929
+ context: OffscreenCanvasRenderingContext2D | undefined;
10911
10930
  /** @property {OffscreenCanvas} - Canvas holding the packed images */
10912
- canvas: OffscreenCanvas;
10931
+ canvas: OffscreenCanvas | undefined;
10913
10932
  /** @property {TextureInfo} - The texture info for this sheet */
10914
10933
  textureInfo: TextureInfo;
10915
10934
  /** @property {Vector2} - Where the next image will be packed */
@@ -10941,7 +10960,8 @@ declare module "littlejsengine" {
10941
10960
  * - Pass frameSize for animations, then step through them with TileInfo.frame
10942
10961
  * - Grid images keep their layout and frames wrap down to the next row
10943
10962
  * - Pass sourcePadding if the source image has padding baked in around frames
10944
- * - The same image loaded again with the same settings gives back what the first load did, packed once
10963
+ * - The same image loaded again with the same settings gives back what the first load did, packed once, unless
10964
+ * that load failed
10945
10965
  * @param {string} src - Image source path
10946
10966
  * @param {Vector2|number} [frameSize] - Size of each animation frame in pixels, or the whole image less its
10947
10967
  * source padding if not passed
@@ -10952,7 +10972,7 @@ declare module "littlejsengine" {
10952
10972
  * const playerTile = loadSprite('player.png'); // a single sprite
10953
10973
  * const runTile = loadSprite('run.png', vec2(16)); // a 16x16 frame animation
10954
10974
  * @memberof TextureSheets */
10955
- export function loadSprite(src: string, frameSize?: Vector2 | number, padding?: number, sourcePadding?: number | Vector2): TileInfo;
10975
+ export function loadSprite(src: string, frameSize?: number | Vector2, padding?: number, sourcePadding?: number | Vector2): TileInfo;
10956
10976
  /** Load tile images and pack them into texture sheets as one tile set, for tile layers and maps
10957
10977
  * - Each image is cut into tiles of tileSize, left to right then down, so an image of one tile is one tile and a
10958
10978
  * sheet is all of its tiles; the tiles are numbered from 0 in the order the images are given
@@ -10964,7 +10984,8 @@ declare module "littlejsengine" {
10964
10984
  * is not read, cut it into its tiles first
10965
10985
  * - An image that fails to load, or that no sheet can hold, adds no tiles and says so in the console, so the tiles
10966
10986
  * of the images after it move up
10967
- * - The same images loaded again with the same settings give back what the first load did, packed once
10987
+ * - The same images loaded again with the same settings give back what the first load did, packed once, unless
10988
+ * an image of it failed
10968
10989
  * @param {Array<string>} sources - Image source paths
10969
10990
  * @param {Vector2|number} [tileSize] - Size of a tile in pixels
10970
10991
  * @param {number} [padding] - How many pixels padding around each tile on the sheet
@@ -10974,7 +10995,7 @@ declare module "littlejsengine" {
10974
10995
  * await spritesReady();
10975
10996
  * tileLayersLoad(map, tiles); // tile 0 is grass, 1 dirt, 2 water, then the tiles of props.png
10976
10997
  * @memberof TextureSheets */
10977
- export function loadTiles(sources: Array<string>, tileSize?: Vector2 | number, padding?: number): TileInfo;
10998
+ export function loadTiles(sources: Array<string>, tileSize?: number | Vector2, padding?: number): TileInfo;
10978
10999
  /** Load a pre-packed texture atlas and repack it onto texture sheets
10979
11000
  * - Supports TexturePacker json (hash and array) and Aseprite json
10980
11001
  * - Returns an empty object which is filled with TileInfos when loaded
@@ -10982,7 +11003,8 @@ declare module "littlejsengine" {
10982
11003
  * - Aseprite frame tags become animations, so do names like run_0, run_1
10983
11004
  * - Trimmed frames are restored to their full source size when packed
10984
11005
  * - Rotated frames are rotated back upright when packed
10985
- * - The same atlas loaded again by its paths, with the same padding, gives back what the first load did, packed once
11006
+ * - The same atlas loaded again by its paths, with the same padding, gives back what the first load did, packed
11007
+ * once, unless that load failed
10986
11008
  * @param {string} imageSrc - Atlas image path
10987
11009
  * @param {string|Object} jsonSrc - Atlas json path, or already parsed json data
10988
11010
  * @param {number} [padding] - How many pixels padding around each frame