littlejsengine 1.24.1 → 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.
Files changed (44) hide show
  1. package/CHANGELOG.md +78 -1
  2. package/EDITOR.md +2 -0
  3. package/FAQ.md +13 -2
  4. package/README.md +1 -1
  5. package/REFERENCE.md +22 -7
  6. package/dist/littlejs.d.ts +204 -118
  7. package/dist/littlejs.esm.js +2479 -1983
  8. package/dist/littlejs.esm.min.js +3 -3
  9. package/dist/littlejs.js +2476 -1983
  10. package/dist/littlejs.min.js +2 -2
  11. package/dist/littlejs.release.js +2434 -1990
  12. package/package.json +1 -1
  13. package/plugins/box2d.js +9 -5
  14. package/plugins/gltf.js +67 -9
  15. package/plugins/lightSystem.js +1 -1
  16. package/plugins/math3d.js +1014 -1013
  17. package/plugins/medalSystem.js +7 -11
  18. package/plugins/particleEffects.js +2 -2
  19. package/plugins/pathFinder.js +2 -2
  20. package/plugins/pluginExport.js +1 -0
  21. package/plugins/render3d.js +131 -55
  22. package/plugins/render3dEditor.js +24 -10
  23. package/plugins/render3dExtras.js +41 -25
  24. package/plugins/render3dLevel.js +21 -12
  25. package/plugins/render3dVoxels.js +2 -2
  26. package/plugins/textureSheet.js +109 -7
  27. package/plugins/tweakables.js +1 -1
  28. package/plugins/tweenSystem.js +2 -2
  29. package/plugins/uiSystem.js +6 -2
  30. package/src/engine.js +60 -23
  31. package/src/engineAudio.js +16 -6
  32. package/src/engineBuild.mjs +49 -2
  33. package/src/engineDebug.js +4 -1
  34. package/src/engineDraw.js +40 -25
  35. package/src/engineEditor.js +82 -50
  36. package/src/engineExport.js +2 -0
  37. package/src/engineInput.js +21 -4
  38. package/src/engineMath.js +6 -2
  39. package/src/engineObject.js +675 -675
  40. package/src/engineParticles.js +1 -1
  41. package/src/engineSettings.js +16 -0
  42. package/src/engineTileLayer.js +85 -22
  43. package/src/engineUtilities.js +20 -8
  44. package/src/engineWebGL.js +15 -11
@@ -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;
@@ -1345,6 +1345,12 @@ declare module "littlejsengine" {
1345
1345
  * @default
1346
1346
  * @memberof Settings */
1347
1347
  export let soundEnable: boolean;
1348
+ /** Play sound with an iPhone's silent switch on, as media does; off by default, so the switch mutes the game as it
1349
+ * does a ringtone, and the player's own music keeps playing beside it; Safari 16.4 and up, elsewhere it does nothing
1350
+ * @type {boolean}
1351
+ * @default
1352
+ * @memberof Settings */
1353
+ export let soundIgnoreSilentSwitch: boolean;
1348
1354
  /** Volume scale to apply to all sound, music and speech
1349
1355
  * Use setSoundVolume to also update the audio master gain immediately
1350
1356
  * @type {number}
@@ -1614,6 +1620,10 @@ declare module "littlejsengine" {
1614
1620
  * @param {boolean} enable
1615
1621
  * @memberof Settings */
1616
1622
  export function setSoundEnable(enable: boolean): void;
1623
+ /** Set if sound plays with an iPhone's silent switch on, as media does, which also pauses the player's own music
1624
+ * @param {boolean} ignore
1625
+ * @memberof Settings */
1626
+ export function setSoundIgnoreSilentSwitch(ignore: boolean): void;
1617
1627
  /** Set volume scale to apply to all sound, music and speech
1618
1628
  * @param {number} volume
1619
1629
  * @memberof Settings */
@@ -1806,7 +1816,7 @@ declare module "littlejsengine" {
1806
1816
  * @return {number}
1807
1817
  * @memberof Math */
1808
1818
  export function smoothStep(percent: number): number;
1809
- /** Returns the nearest power of two not less than the value
1819
+ /** Returns the nearest whole power of two not less than the value, 1 for a value of 1 or less
1810
1820
  * @param {number} value
1811
1821
  * @return {number}
1812
1822
  * @memberof Math */
@@ -1899,6 +1909,7 @@ declare module "littlejsengine" {
1899
1909
  export function saveText(text: string, filename?: string, type?: string): void;
1900
1910
  /** Create an offscreen canvas to draw into, and return its 2D context
1901
1911
  * - The canvas is context.canvas, which is what TextureInfo and the like take
1912
+ * - A browser with no OffscreenCanvas, Safari before 16.4, gets a canvas element that is not on the page
1902
1913
  * @param {number} width - In pixels
1903
1914
  * @param {number} [height] - In pixels, defaults to the width for a square
1904
1915
  * @param {boolean} [willReadFrequently] - Keep it in software, faster when getImageData is called on it often
@@ -1933,11 +1944,12 @@ declare module "littlejsengine" {
1933
1944
  export function readSaveData<T extends {
1934
1945
  [x: string]: any;
1935
1946
  } = any>(saveName: string, defaultSaveData?: T): T;
1936
- /** Write save data to local storage
1947
+ /** Write save data to local storage, an object as readSaveData gives it back
1937
1948
  * @param {string} saveName - unique name for the game/save
1938
1949
  * @param {object} saveData - object containing data to be saved
1950
+ * @return {boolean} - Whether it was written, false when storage is unavailable or full
1939
1951
  * @memberof Utilities */
1940
- export function writeSaveData(saveName: string, saveData: object): void;
1952
+ export function writeSaveData(saveName: string, saveData: object): boolean;
1941
1953
  /** 1D value noise — returns a smooth value in [0, 1] for any real x.
1942
1954
  * Integer inputs land on deterministic lattice values; non-integer inputs
1943
1955
  * are interpolated with smoothStep for C1 continuity.
@@ -2512,7 +2524,7 @@ declare module "littlejsengine" {
2512
2524
  * tile(1, 16, 3) // a tile at index 1 of size 16 on texture 3
2513
2525
  * tile(vec2(4,8), vec2(30,10)) // a tile at index (4,8) with a size of (30,10)
2514
2526
  * @memberof Draw */
2515
- 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;
2516
2528
  /**
2517
2529
  * Tile Info - Stores info about how to draw a tile
2518
2530
  * @memberof Draw
@@ -2535,6 +2547,10 @@ declare module "littlejsengine" {
2535
2547
  padding: number;
2536
2548
  /** @property {TextureInfo} - The texture info for this tile */
2537
2549
  textureInfo: TextureInfo;
2550
+ /** @property {Array<TileInfo>|undefined} - A tile set's tiles, each wherever it was packed, as loadTiles makes
2551
+ * them: a tile layer given this tile info draws its tile n from tiles[n] and not from a grid on one sheet
2552
+ * @type {Array<TileInfo>|undefined} */
2553
+ tiles: Array<TileInfo> | undefined;
2538
2554
  /** @property {number} - Shrinks tile by this many pixels to prevent neighbors bleeding */
2539
2555
  bleed: number;
2540
2556
  /** @property {number} - How many frames per row for frame(), 0 to keep frames on a single row */
@@ -2561,7 +2577,7 @@ declare module "littlejsengine" {
2561
2577
  * @param {Vector2|number} [index=0]
2562
2578
  * @return {TileInfo}
2563
2579
  */
2564
- index(index?: Vector2 | number): TileInfo;
2580
+ index(index?: number | Vector2): TileInfo;
2565
2581
  /**
2566
2582
  * Set this tile to use a full image in a texture info
2567
2583
  * @param {TextureInfo} [textureInfo]
@@ -2582,7 +2598,7 @@ declare module "littlejsengine" {
2582
2598
  * modes across and down, like [gl.CLAMP_TO_EDGE, gl.MIRRORED_REPEAT], as a glTF sampler gives them
2583
2599
  * @param {boolean} [pixelated] - Hard edged or smooth for this texture alone, undefined follows tilesPixelated
2584
2600
  */
2585
- 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);
2586
2602
  /** @property {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} - image source */
2587
2603
  image: OffscreenCanvas | ImageBitmap | HTMLCanvasElement | HTMLImageElement;
2588
2604
  /** @property {Vector2} - size of the image */
@@ -2610,7 +2626,7 @@ declare module "littlejsengine" {
2610
2626
  /** Set the wrap mode for this texture
2611
2627
  * @param {boolean|Array<number>} [wrap] - true for REPEAT, false for CLAMP_TO_EDGE, or the WebGL modes across
2612
2628
  * and down */
2613
- setWrap(wrap?: boolean | Array<number>): void;
2629
+ setWrap(wrap?: boolean | number[]): void;
2614
2630
  /** Make this texture hard edged or smooth on its own, whatever tilesPixelated says for the rest; it is made again
2615
2631
  * with the new filtering
2616
2632
  * @param {boolean} [pixelated] - undefined follows tilesPixelated again */
@@ -2941,7 +2957,7 @@ declare module "littlejsengine" {
2941
2957
  * @param {boolean} [screenSpace=drawScreenSpace] - Are pos and size in screen space?
2942
2958
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
2943
2959
  * @memberof Draw */
2944
- 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;
2945
2961
  /** Draw connected lines between a series of points
2946
2962
  * @param {Array<Vector2>} points
2947
2963
  * @param {number} [width]
@@ -3076,7 +3092,7 @@ declare module "littlejsengine" {
3076
3092
  * @param {number} [angle]
3077
3093
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
3078
3094
  * @memberof Draw */
3079
- 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;
3080
3096
  /** Draw text in screen space
3081
3097
  * Automatically splits new lines into rows
3082
3098
  * @param {string|number} text
@@ -3092,7 +3108,7 @@ declare module "littlejsengine" {
3092
3108
  * @param {number} [angle] - Clockwise, like the other screen space draws
3093
3109
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
3094
3110
  * @memberof Draw */
3095
- 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;
3096
3112
  /** Enable additive blending
3097
3113
  * @param {boolean} [additive]
3098
3114
  * @memberof Draw */
@@ -3148,7 +3164,7 @@ declare module "littlejsengine" {
3148
3164
  * @param {boolean} [useWebGL=glEnable]
3149
3165
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
3150
3166
  */
3151
- 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;
3152
3168
  /** Draw text in screen space using the image font
3153
3169
  * @param {string|number} text
3154
3170
  * @param {Vector2} pos
@@ -3208,7 +3224,7 @@ declare module "littlejsengine" {
3208
3224
  * @param {Vector2|number} [size] - world space size or diameter
3209
3225
  * @return {boolean}
3210
3226
  * @memberof Draw */
3211
- export function isOnScreen(pos: Vector2, size?: Vector2 | number): boolean;
3227
+ export function isOnScreen(pos: Vector2, size?: number | Vector2): boolean;
3212
3228
  /**
3213
3229
  * LittleJS WebGL Interface
3214
3230
  * - WebGL2 rendering engine for high-performance graphics
@@ -3250,27 +3266,27 @@ declare module "littlejsengine" {
3250
3266
  * @param {boolean|Array<number>} [wrap] - true for REPEAT, false for CLAMP_TO_EDGE, or the WebGL modes across and
3251
3267
  * down, like [gl.CLAMP_TO_EDGE, gl.MIRRORED_REPEAT]
3252
3268
  * @memberof WebGL */
3253
- export function glSetTextureWrap(texture: WebGLTexture, wrap?: boolean | Array<number>): void;
3269
+ export function glSetTextureWrap(texture: WebGLTexture, wrap?: boolean | number[]): void;
3254
3270
  /** Compile WebGL shader of the given type, will throw errors if in debug mode
3255
3271
  * @param {string} source
3256
3272
  * @param {number} type
3257
- * @return {WebGLShader}
3273
+ * @return {WebGLShader|undefined} - undefined with no WebGL
3258
3274
  * @memberof WebGL */
3259
- export function glCompileShader(source: string, type: number): WebGLShader;
3275
+ export function glCompileShader(source: string, type: number): WebGLShader | undefined;
3260
3276
  /** Create WebGL program with given shaders
3261
3277
  * @param {string} vsSource
3262
3278
  * @param {string} fsSource
3263
- * @return {WebGLProgram}
3279
+ * @return {WebGLProgram|undefined} - undefined with no WebGL
3264
3280
  * @memberof WebGL */
3265
- export function glCreateProgram(vsSource: string, fsSource: string): WebGLProgram;
3281
+ export function glCreateProgram(vsSource: string, fsSource: string): WebGLProgram | undefined;
3266
3282
  /** Create WebGL texture from an image and init the texture settings
3267
3283
  * Restores the active texture when done
3268
3284
  * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} [image]
3269
3285
  * @param {boolean|Array<number>} [wrap] - true for REPEAT, false for CLAMP_TO_EDGE, or the WebGL modes across and down
3270
3286
  * @param {boolean} [pixelated] - Hard edged or smooth, undefined follows tilesPixelated
3271
- * @return {WebGLTexture}
3287
+ * @return {WebGLTexture|undefined} - undefined with no WebGL
3272
3288
  * @memberof WebGL */
3273
- 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;
3274
3290
  /** Deletes a WebGL texture
3275
3291
  * @param {WebGLTexture} [texture]
3276
3292
  * @memberof WebGL */
@@ -3660,13 +3676,13 @@ declare module "littlejsengine" {
3660
3676
  * @memberof Audio
3661
3677
  * @example
3662
3678
  * // load an audio asset file
3663
- * const sound_example = new Sound('sound.mp3');
3679
+ * const music = new Sound('sound.mp3');
3664
3680
  *
3665
3681
  * // create a zzfx sound
3666
- * const sound_example = new Sound([.5,.5]);
3682
+ * const blip = new Sound([.5,.5]);
3667
3683
  *
3668
3684
  * // play a sound
3669
- * sound_example.play();
3685
+ * blip.play();
3670
3686
  */
3671
3687
  export class Sound {
3672
3688
  /** Create a sound object and cache the audio for later use
@@ -3676,7 +3692,7 @@ declare module "littlejsengine" {
3676
3692
  * @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
3677
3693
  * @param {SoundLoadCallback} [onloadCallback] - callback function to call when sound is loaded
3678
3694
  */
3679
- 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);
3680
3696
  loadedPercent: number;
3681
3697
  set range(arg: number);
3682
3698
  /** World space max range of sound, 0 for no limit; a range that is set is the sound's own, in 3D too
@@ -3684,16 +3700,16 @@ declare module "littlejsengine" {
3684
3700
  get range(): number;
3685
3701
  /** @property {boolean} - No range was given, so it got soundDefaultRange; played in 3D such a sound is heard
3686
3702
  * to render3D.soundDefaultRange instead, which is further; setting range makes it false */
3687
- rangeIsDefault: boolean;
3703
+ rangeIsDefault: boolean | undefined;
3688
3704
  /** @property {number} - At what percentage of range should it start tapering */
3689
- taper: number;
3705
+ taper: number | undefined;
3690
3706
  /** @property {number} - How much to randomize frequency each time sound plays
3691
3707
  * @type {number} */
3692
3708
  randomness: number;
3693
3709
  /** @property {number} - Sample rate for this sound */
3694
- sampleRate: number;
3710
+ sampleRate: number | undefined;
3695
3711
  /** @property {number} - How many samples per channel this sound has */
3696
- sampleLength: number;
3712
+ sampleLength: number | undefined;
3697
3713
  /** @property {AudioBuffer|undefined} - Decoded audio shared by every play of this sound
3698
3714
  * @type {AudioBuffer|undefined} */
3699
3715
  sampleBuffer: AudioBuffer | undefined;
@@ -3708,14 +3724,14 @@ declare module "littlejsengine" {
3708
3724
  * @type {AudioNode|AudioEffectNodes|undefined} */
3709
3725
  output: AudioNode | AudioEffectNodes | undefined;
3710
3726
  /** @param {Array<Array<number>|Float32Array>} sampleChannels */
3711
- set sampleChannels(arg: (number[] | Float32Array)[]);
3727
+ set sampleChannels(arg: (number[] | Float32Array)[] | undefined);
3712
3728
  /** Sample data for each channel
3713
3729
  * Sounds keep their samples in an audio buffer, so reading this rebuilds
3714
3730
  * the arrays from it and caches them. The copies are safe to hold onto,
3715
3731
  * playing a sound detaches the buffer's own channel arrays.
3716
3732
  * @return {Array<Array<number>|Float32Array>|undefined} */
3717
- get sampleChannels(): (number[] | Float32Array)[];
3718
- rangeValue: number;
3733
+ get sampleChannels(): (number[] | Float32Array)[] | undefined;
3734
+ rangeValue: number | undefined;
3719
3735
  /** Move this sound's samples into an audio buffer that every play can share
3720
3736
  * Does nothing if there is already a buffer or no samples to build one from */
3721
3737
  buildSampleBuffer(): void;
@@ -4284,9 +4300,10 @@ declare module "littlejsengine" {
4284
4300
  * @param {number} [renderOrder] - Render order of the top layer
4285
4301
  * @param {number|string} [collisionLayer] - Layer to use for collision if any, by its index or its name
4286
4302
  * @param {boolean} [draw] - Should the layer be drawn automatically
4287
- * @return {Array<TileCollisionLayer>}
4303
+ * @return {Array<TileCollisionLayer>} - It throws for a map that is not whole cells, or a layer whose tiles do not
4304
+ * fill it, before it makes any layer
4288
4305
  * @memberof TileLayers */
4289
- 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>;
4290
4307
  /**
4291
4308
  * Make a Tiled map of a level of an LDtk project, to load with tileLayersLoad and objectLayersLoad
4292
4309
  * - Each Tiles, AutoLayer and IntGrid layer is a tile layer, the bottom one first as in Tiled; where LDtk stacks
@@ -4313,7 +4330,7 @@ declare module "littlejsengine" {
4313
4330
  * const layers = tileLayersLoad(map, tile(0, 16), 0, 'Collisions'); // its IntGrid layer is solid
4314
4331
  * objectLayersLoad(map);
4315
4332
  * @memberof TileLayers */
4316
- export function tileLayersFromLDtk(ldtk: any, level?: number | string): any;
4333
+ export function tileLayersFromLDtk(ldtk: any, level?: string | number): any;
4317
4334
  /** Add a type of object, so objectLayersLoad makes one wherever a map's object layer has an object of that type
4318
4335
  * - The name is the object's type in Tiled (its class in Tiled 1.9); it is a string because minified builds
4319
4336
  * rename classes
@@ -4394,9 +4411,9 @@ declare module "littlejsengine" {
4394
4411
  */
4395
4412
  constructor(pos?: Vector2, size?: Vector2, angle?: number, renderOrder?: number, canvasSize?: Vector2, useWebGL?: boolean);
4396
4413
  /** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
4397
- context: OffscreenCanvasRenderingContext2D;
4414
+ context: OffscreenCanvasRenderingContext2D | undefined;
4398
4415
  /** @property {OffscreenCanvas} - The canvas used by this layer */
4399
- canvas: OffscreenCanvas;
4416
+ canvas: OffscreenCanvas | undefined;
4400
4417
  /** @property {TextureInfo} - Texture info to use for this object rendering */
4401
4418
  textureInfo: TextureInfo;
4402
4419
  /** Draw this canvas layer centered in world space
@@ -4439,7 +4456,7 @@ declare module "littlejsengine" {
4439
4456
  data: TileLayerData[];
4440
4457
  /** @property {boolean} - Is this layer using a webgl texture? */
4441
4458
  isUsingWebGL: boolean;
4442
- tilesInWebGL: boolean;
4459
+ tilesInWebGL: boolean | undefined;
4443
4460
  /** @property {boolean} - Show this layer's bounds and values when the debug overlay's Debug Tiles is on,
4444
4461
  * turn it off for layers that only add noise */
4445
4462
  debugShow: boolean;
@@ -4518,8 +4535,8 @@ declare module "littlejsengine" {
4518
4535
  onRedraw(): void;
4519
4536
  redrawIfSwitched(): void;
4520
4537
  /** @type {[CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, number, Color, Shader|undefined]} */
4521
- savedRenderSettings: [CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, number, Color, Shader | undefined];
4522
- savedRenderTarget: any[];
4538
+ savedRenderSettings: [CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, number, Color, Shader | undefined] | undefined;
4539
+ savedRenderTarget: any[] | undefined;
4523
4540
  }
4524
4541
  /**
4525
4542
  * Tile Collision Layer - a tile layer with collision
@@ -4605,7 +4622,7 @@ declare module "littlejsengine" {
4605
4622
  * rgb(1,1,1,0), rgb(0,0,0,0), // colorEndA, colorEndB
4606
4623
  * 1, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
4607
4624
  * .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate
4608
- * .5, 1 // randomness, collide
4625
+ * .5, true // randomness, collide
4609
4626
  * );
4610
4627
  */
4611
4628
  export class ParticleEmitter extends EngineObject {
@@ -5246,7 +5263,7 @@ declare module "littlejsengine" {
5246
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. */
5247
5264
  ambientColor: Color;
5248
5265
  /** @property {Vector2} - Size of the lightmap texture, follows mainCanvasSize (css pixels, so it is not scaled by canvasPixelRatio) unless a size was passed */
5249
- textureSize: Vector2;
5266
+ textureSize: Vector2 | undefined;
5250
5267
  /** @property {boolean} - True when no size was passed, so the lightmap follows mainCanvasSize */
5251
5268
  textureSizeAuto: boolean;
5252
5269
  /** @property {WebGLTexture|undefined} - The lightmap texture
@@ -5399,14 +5416,14 @@ declare module "littlejsengine" {
5399
5416
  /** @property {number} - Wet/dry balance, 0 is fully dry and 1 is fully wet */
5400
5417
  mix: number;
5401
5418
  /** @property {GainNode} - Connect sounds to this node */
5402
- input: GainNode;
5419
+ input: GainNode | undefined;
5403
5420
  /** @property {GainNode} - This node carries the mixed result, send it somewhere with connect(), never by assigning here
5404
5421
  * - Unlike sound.output, which is where a sound's audio goes and can be set to an effect */
5405
- output: GainNode;
5422
+ output: GainNode | undefined;
5406
5423
  /** @property {GainNode} - Level of the unprocessed signal */
5407
- dryGain: GainNode;
5424
+ dryGain: GainNode | undefined;
5408
5425
  /** @property {GainNode} - Level of the processed signal */
5409
- wetGain: GainNode;
5426
+ wetGain: GainNode | undefined;
5410
5427
  /** Set the wet/dry balance
5411
5428
  * @param {number} mix - 0 is fully dry and 1 is fully wet
5412
5429
  * @param {number} [fadeTime] - Seconds to ramp over so the change doesn't click */
@@ -5449,7 +5466,7 @@ declare module "littlejsengine" {
5449
5466
  * @param {number} [mix] - Wet/dry balance, 0 is fully dry and 1 is fully wet */
5450
5467
  constructor(type?: BiquadFilterType, frequency?: number, q?: number, mix?: number);
5451
5468
  /** @property {BiquadFilterNode} - The filter node */
5452
- node: BiquadFilterNode;
5469
+ node: BiquadFilterNode | undefined;
5453
5470
  /** Set the cutoff or center frequency
5454
5471
  * @param {number} frequency - Frequency in Hz
5455
5472
  * @param {number} [fadeTime] - Seconds to sweep over */
@@ -5475,7 +5492,7 @@ declare module "littlejsengine" {
5475
5492
  * @param {number} [mix] - Wet/dry balance, 0 is fully dry and 1 is fully wet */
5476
5493
  constructor(duration?: number, decay?: number, mix?: number);
5477
5494
  /** @property {ConvolverNode} - The convolver node */
5478
- node: ConvolverNode;
5495
+ node: ConvolverNode | undefined;
5479
5496
  /** Change the room by rebuilding the impulse response
5480
5497
  * @param {number} duration - Seconds until the reverb tail is silent
5481
5498
  * @param {number} [decay] - How quickly the tail fades, higher is faster */
@@ -5501,9 +5518,9 @@ declare module "littlejsengine" {
5501
5518
  * @param {number} [mix] - Wet/dry balance, 0 is fully dry and 1 is fully wet */
5502
5519
  constructor(time?: number, feedback?: number, mix?: number);
5503
5520
  /** @property {DelayNode} - The delay node */
5504
- node: DelayNode;
5521
+ node: DelayNode | undefined;
5505
5522
  /** @property {GainNode} - How much of the delayed signal feeds back in */
5506
- feedbackGain: GainNode;
5523
+ feedbackGain: GainNode | undefined;
5507
5524
  /** Set the time between echoes
5508
5525
  * - Browsers hold a delay in a feedback loop to at least one render quantum, so 0 is not a bypass
5509
5526
  * @param {number} time - Seconds, up to 5
@@ -5530,7 +5547,7 @@ declare module "littlejsengine" {
5530
5547
  /** @property {number} - How hard the signal is driven, 0 is clean and 1 is crushed */
5531
5548
  amount: number;
5532
5549
  /** @property {WaveShaperNode} - The wave shaper node */
5533
- node: WaveShaperNode;
5550
+ node: WaveShaperNode | undefined;
5534
5551
  /** Set how hard to drive the signal, rebuilds the shaping curve
5535
5552
  * @param {number} amount - 0 is clean and 1 is crushed */
5536
5553
  setAmount(amount: number): void;
@@ -5551,7 +5568,7 @@ declare module "littlejsengine" {
5551
5568
  * @param {number} [mix] - Wet/dry balance, 0 is fully dry and 1 is fully wet */
5552
5569
  constructor(threshold?: number, ratio?: number, mix?: number);
5553
5570
  /** @property {DynamicsCompressorNode} - The compressor node */
5554
- node: DynamicsCompressorNode;
5571
+ node: DynamicsCompressorNode | undefined;
5555
5572
  /** Set the level above which the signal is reduced
5556
5573
  * @param {number} threshold - Level in dB
5557
5574
  * @param {number} [fadeTime] - Seconds to ramp over */
@@ -5736,7 +5753,7 @@ declare module "littlejsengine" {
5736
5753
  * @param {Color} [shadowColor]
5737
5754
  * @param {number} [shadowBlur]
5738
5755
  * @param {Vector2} [shadowOffset] */
5739
- 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;
5740
5757
  /**
5741
5758
  * @callback DragAndDropCallback - Callback for drag and drop events
5742
5759
  * @param {DragEvent} event - The drag event
@@ -5753,13 +5770,13 @@ declare module "littlejsengine" {
5753
5770
  * @param {Vector2} pos
5754
5771
  * @return {Vector2} */
5755
5772
  screenToNative(pos: Vector2): Vector2;
5756
- set keyInputObject(arg: UIObject);
5773
+ set keyInputObject(arg: UIObject | undefined);
5757
5774
  /** Object to send keyboard input to (typically a UITextInput), which keeps the keys from the game while set.
5758
5775
  * The keyboard listeners are only attached while this is set,
5759
5776
  * so games that never use text input pay no event-handling cost.
5760
5777
  * To end typing in a field, call its stopEditing(), which also fires its onChange and release sound
5761
5778
  * @type {UIObject|undefined} */
5762
- get keyInputObject(): UIObject;
5779
+ get keyInputObject(): UIObject | undefined;
5763
5780
  /** Destroy and remove all objects */
5764
5781
  destroyObjects(): void;
5765
5782
  /** Get all navigable UI objects sorted by navigationIndex
@@ -5987,7 +6004,8 @@ declare module "littlejsengine" {
5987
6004
  * @param {'left'|'center'|'right'} [align]
5988
6005
  * @param {string} [font=uiSystem.defaultFont]
5989
6006
  */
5990
- 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;
5991
6009
  }
5992
6010
  /**
5993
6011
  * UITextInput - An editable text input field
@@ -6007,6 +6025,7 @@ declare module "littlejsengine" {
6007
6025
  constructor(pos?: Vector2, size?: Vector2, text?: string);
6008
6026
  /** @property {number} - Max length of input (0 = no limit) */
6009
6027
  maxLength: number;
6028
+ text: string;
6010
6029
  /** Stop editing the text */
6011
6030
  stopEditing(): void;
6012
6031
  }
@@ -6047,6 +6066,7 @@ declare module "littlejsengine" {
6047
6066
  constructor(pos?: Vector2, size?: Vector2, text?: string, color?: Color);
6048
6067
  /** @property {Vector2} - Text offset for the button */
6049
6068
  textOffset: Vector2;
6069
+ text: string;
6050
6070
  }
6051
6071
  /**
6052
6072
  * UICheckbox - A UI object that acts as a checkbox
@@ -6064,6 +6084,7 @@ declare module "littlejsengine" {
6064
6084
  constructor(pos?: Vector2, size?: Vector2, checked?: boolean, text?: string, color?: Color);
6065
6085
  /** @property {boolean} - Is the checkbox currently checked? */
6066
6086
  checked: boolean;
6087
+ text: string;
6067
6088
  }
6068
6089
  /**
6069
6090
  * UISlider - A UI object that acts as a slider or scrollbar
@@ -6090,6 +6111,7 @@ declare module "littlejsengine" {
6090
6111
  handleSlice: TileSlice | undefined;
6091
6112
  /** @property {boolean} - Should it fill up like a progress bar? */
6092
6113
  fillMode: boolean;
6114
+ text: string;
6093
6115
  /** Draw the handle, or the fill of a fill mode slider, with the handle slice, the slider's own, or a rectangle
6094
6116
  * @param {Vector2} pos
6095
6117
  * @param {Vector2} size
@@ -6273,13 +6295,15 @@ declare module "littlejsengine" {
6273
6295
  * @param {boolean} [includeSensors] - Also hit sensors, trigger zones are passed through by default
6274
6296
  * @return {Box2dRaycastResult|undefined} */
6275
6297
  raycast(start: Vector2, end: Vector2, includeSensors?: boolean): Box2dRaycastResult | undefined;
6276
- /** 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
6277
6300
  * @param {Vector2} pos
6278
6301
  * @param {Vector2} size
6279
6302
  * @param {boolean} [includeSensors] - Also find sensors, trigger zones are passed through by default
6280
6303
  * @return {Array<Box2dObject>} */
6281
6304
  boxCastAll(pos: Vector2, size: Vector2, includeSensors?: boolean): Array<Box2dObject>;
6282
- /** 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
6283
6307
  * @param {Vector2} pos
6284
6308
  * @param {Vector2} size
6285
6309
  * @param {boolean} [includeSensors] - Also find sensors, trigger zones are passed through by default
@@ -7264,7 +7288,7 @@ declare module "littlejsengine" {
7264
7288
  * @param {boolean} [useWebGL] - Use WebGL for rendering
7265
7289
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas context to use
7266
7290
  * @memberof DrawUtilities */
7267
- 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;
7268
7292
  /** Draw a scalable three-slice UI element in world space
7269
7293
  * Color and additive color apply in WebGL and Canvas2D (with canvasColorTiles)
7270
7294
  * The three-slice samples 3 consecutive tiles from the tilesheet, it does not
@@ -7300,7 +7324,7 @@ declare module "littlejsengine" {
7300
7324
  * @param {boolean} [useWebGL] - Use WebGL for rendering
7301
7325
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas context to use
7302
7326
  * @memberof DrawUtilities */
7303
- 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;
7304
7328
  /**
7305
7329
  * A tile drawn as a box of any size, kept as a style to draw with, like a UI skin
7306
7330
  * - 9 slices is a nine-slice from the 3x3 block of tiles at tileInfo, see drawNineSlice
@@ -7681,8 +7705,8 @@ declare module "littlejsengine" {
7681
7705
  * const path = pf.findPath(player.pos, mousePos);
7682
7706
  *
7683
7707
  * // Bare grid with custom walkability:
7684
- * const pf = new PathFinder(vec2(50, 50));
7685
- * pf.isWalkable = (x, y) => myGrid[y*50 + x] === 0;
7708
+ * const gridFinder = new PathFinder(vec2(50, 50));
7709
+ * gridFinder.isWalkable = (x, y) => myGrid[y*50 + x] === 0;
7686
7710
  */
7687
7711
  export class PathFinder {
7688
7712
  /** @param {TileCollisionLayer|Vector2} source - Either a TileCollisionLayer
@@ -8154,7 +8178,7 @@ declare module "littlejsengine" {
8154
8178
  static lookAt(eye: Vector3, target: Vector3, up?: Vector3): Matrix4;
8155
8179
  /** Create a matrix, identity by default
8156
8180
  * @param {Float32Array|Array<number>} [m] - 16 column major values */
8157
- constructor(m?: Float32Array | Array<number>);
8181
+ constructor(m?: number[] | Float32Array);
8158
8182
  /** @property {Float32Array} - The 16 column major values */
8159
8183
  m: Float32Array;
8160
8184
  /** Returns a new matrix that is a copy of this
@@ -8503,6 +8527,7 @@ declare module "littlejsengine" {
8503
8527
  viewProjection: Matrix4;
8504
8528
  /** @property {Matrix4} - This frame's light view projection for the shadow map */
8505
8529
  shadowMatrix: Matrix4;
8530
+ gelAxes: number[];
8506
8531
  /** @property {Vector3} - Camera right axis this frame */
8507
8532
  cameraRight: Vector3;
8508
8533
  /** @property {Vector3} - Camera up axis this frame */
@@ -8622,10 +8647,10 @@ declare module "littlejsengine" {
8622
8647
  * like polished metal; set from each object's shininess
8623
8648
  * @return {number} */
8624
8649
  get shininess(): number;
8625
- set normalMap(arg: TextureInfo);
8650
+ set normalMap(arg: TextureInfo | undefined);
8626
8651
  /** Normal map for the next draws, set from each object's normalMap
8627
8652
  * @return {TextureInfo|undefined} */
8628
- get normalMap(): TextureInfo;
8653
+ get normalMap(): TextureInfo | undefined;
8629
8654
  set normalScale(arg: number);
8630
8655
  /** How strongly the normal map bends the surface, set from each object's normalScale
8631
8656
  * @return {number} */
@@ -8634,20 +8659,20 @@ declare module "littlejsengine" {
8634
8659
  /** How much the surface reflects the sky, 0 to 1, set from each object's reflectivity
8635
8660
  * @return {number} */
8636
8661
  get reflectivity(): number;
8637
- set emissiveMap(arg: TextureInfo);
8662
+ set emissiveMap(arg: TextureInfo | undefined);
8638
8663
  /** Emissive map for the next draws, set from each object's emissiveMap
8639
8664
  * @return {TextureInfo|undefined} */
8640
- get emissiveMap(): TextureInfo;
8665
+ get emissiveMap(): TextureInfo | undefined;
8641
8666
  set emissiveMapColor(arg: Color);
8642
8667
  /** Multiplies the emissive map, set from each object's emissiveMapColor; compared by its rgb, so a Color
8643
8668
  * changed in place is seen when it is set again, and undefined is white
8644
8669
  * @return {Color} */
8645
8670
  get emissiveMapColor(): Color;
8646
- set shader(arg: Shader);
8671
+ set shader(arg: Shader | undefined);
8647
8672
  /** Custom Shader for the next draws, set from each object's shader; undefined draws
8648
8673
  * with the plugin's own
8649
8674
  * @return {Shader|undefined} */
8650
- get shader(): Shader;
8675
+ get shader(): Shader | undefined;
8651
8676
  set receiveShadow(arg: boolean);
8652
8677
  /** Darken by the shadow map when shadows are on, turn it off for things that should
8653
8678
  * stay lit inside a shadow
@@ -8697,7 +8722,7 @@ declare module "littlejsengine" {
8697
8722
  * @param {Vector2|Ray3D} from - A screen position like mousePosScreen, or a ray to look along
8698
8723
  * @param {Array<EngineObject>} [objects] - Defaults to every object; only those with a mesh or a sprite count
8699
8724
  * @return {{object: EngineObject3D, distance: number}|undefined} */
8700
- pick(from: Vector2 | Ray3D, objects?: Array<EngineObject>): {
8725
+ pick(from: Vector2 | Ray3D, objects?: EngineObject[]): {
8701
8726
  object: EngineObject3D;
8702
8727
  distance: number;
8703
8728
  } | undefined;
@@ -8734,7 +8759,7 @@ declare module "littlejsengine" {
8734
8759
  * @param {TileInfo|TextureInfo} [tileInfo] - Texture, mesh uvs map across the tile or the whole texture
8735
8760
  * @param {Color} [color] - Tint
8736
8761
  * @return {void} */
8737
- 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;
8738
8763
  /** Draw a triangle strip, batched into the stream with the current draw state
8739
8764
  * - Strip order: the first three points make a triangle, then each point makes another with the two before it
8740
8765
  * - List the first three points counter clockwise as seen from the front, or the face points away
@@ -8747,14 +8772,14 @@ declare module "littlejsengine" {
8747
8772
  * @param {Color|Array<Color>} [colors] - One for all or one per point, vertex colors come before the texture
8748
8773
  * @param {TileInfo|TextureInfo} [tileInfo] - Texture for this strip
8749
8774
  * @return {void} */
8750
- 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;
8751
8776
  /** Draw a strip with lighting off, for camera facing shapes where the light direction means nothing
8752
8777
  * @param {Array<Vector3>} points - Strip order
8753
8778
  * @param {Vector3|Array<Vector3>} [normals]
8754
8779
  * @param {Vector2|Array<Vector2>} [uvs]
8755
8780
  * @param {Color|Array<Color>} [colors]
8756
8781
  * @param {TileInfo|TextureInfo} [tileInfo] */
8757
- 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;
8758
8783
  /** Draw the pending stream vertices as one strip with the state they were drawn under, called automatically when needed */
8759
8784
  flush(): void;
8760
8785
  /** Build a mesh once out of draw calls, instead of redrawing the shapes every frame
@@ -8802,7 +8827,7 @@ declare module "littlejsengine" {
8802
8827
  * @param {Vector3|number} [size] - Full size, a number for a cube
8803
8828
  * @param {Color} [color]
8804
8829
  * @param {Vector3} [rotation] - vec3(pitch, yaw, roll) */
8805
- drawBox(pos: Vector3, size?: Vector3 | number, color?: Color, rotation?: Vector3): void;
8830
+ drawBox(pos: Vector3, size?: number | Vector3, color?: Color, rotation?: Vector3): void;
8806
8831
  /** Draw a sphere, untextured and smooth shaded
8807
8832
  * @param {Vector3} pos - Center
8808
8833
  * @param {number} [size] - Diameter
@@ -8825,7 +8850,7 @@ declare module "littlejsengine" {
8825
8850
  * @param {Vector3} d
8826
8851
  * @param {TileInfo|TextureInfo} [tileInfo]
8827
8852
  * @param {Color|Array<Color>} [color] - One for all or one per corner */
8828
- 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;
8829
8854
  /** Draw a triangle, counter clockwise from outside is the front
8830
8855
  * @param {Vector3} a
8831
8856
  * @param {Vector3} b
@@ -8847,7 +8872,7 @@ declare module "littlejsengine" {
8847
8872
  * @param {Color|Array<Color>} [color] - One for all or one per point
8848
8873
  * @param {Vector3|Array<Vector3>} [side] - Direction across the ribbon, one for all or one per point, default
8849
8874
  * faces the camera */
8850
- 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;
8851
8876
  /** Draw a disc that fades to transparent at the rim, unlit, for glows, puffs and sky dots
8852
8877
  * @param {Vector3} pos - Center
8853
8878
  * @param {number} [size] - Diameter
@@ -9166,7 +9191,7 @@ declare module "littlejsengine" {
9166
9191
  * @param {Vector2|Array<Vector2>} [uvs] - One for all or one per point, default zero
9167
9192
  * @param {Color|Array<Color>} [colors] - One for all or one per point, default white
9168
9193
  * @return {Mesh} */
9169
- 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;
9170
9195
  /** Add triangles over their own vertices, the indexed form a model file comes in
9171
9196
  * - The mesh becomes indexed: a strip mesh is turned into triangles first, and strips added later join as triangles
9172
9197
  * - List each triangle counter clockwise as seen from the front, like a strip's first triangle
@@ -9176,7 +9201,7 @@ declare module "littlejsengine" {
9176
9201
  * @param {Vector2|Array<Vector2>} [uvs] - One for all or one per point, default zero
9177
9202
  * @param {Color|Array<Color>} [colors] - One for all or one per point, default white
9178
9203
  * @return {Mesh} */
9179
- 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;
9180
9205
  /** Turn a strip mesh into the indexed form, each distinct vertex once and the real triangles over them, in place
9181
9206
  * - An indexed mesh is left as it is; the builders make strips and a loader makes this, and either draws the same
9182
9207
  * @return {Mesh} */
@@ -9189,13 +9214,13 @@ declare module "littlejsengine" {
9189
9214
  * @param {Color|Array<Color>} [color] - One for all or one per corner
9190
9215
  * @param {Array<Vector2>} [uvs] - One per corner, default across the tile
9191
9216
  * @return {Mesh} */
9192
- 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;
9193
9218
  /** Append another mesh transformed by a matrix, for building one shape out of several
9194
9219
  * @param {Mesh} mesh
9195
9220
  * @param {Matrix4|Vector3} [matrix] - Transform, or just a position to move it to
9196
9221
  * @param {Color} [color] - Multiplies the appended vertex colors
9197
9222
  * @return {Mesh} */
9198
- combine(mesh: Mesh, matrix?: Matrix4 | Vector3, color?: Color): Mesh;
9223
+ combine(mesh: Mesh, matrix?: Vector3 | Matrix4, color?: Color): Mesh;
9199
9224
  /** Returns a new mesh: this one and its mirror image across the plane through the origin facing axis
9200
9225
  * - For modeling half a shape against that plane, a part that crosses it overlaps its image
9201
9226
  * @param {Vector3} [axis] - Faces the mirror plane, vec3(1,0,0) mirrors across x
@@ -9210,7 +9235,7 @@ declare module "littlejsengine" {
9210
9235
  * @param {Mesh} mesh - Closed, as the builders make them apart from the open ones like buildGrid
9211
9236
  * @param {Matrix4|Vector3} [matrix] - Places the other mesh, or just a position to move it to
9212
9237
  * @return {Mesh} */
9213
- union(mesh: Mesh, matrix?: Matrix4 | Vector3): Mesh;
9238
+ union(mesh: Mesh, matrix?: Vector3 | Matrix4): Mesh;
9214
9239
  /** Returns a new mesh of this one with the other cut out of it, CSG with BSP trees
9215
9240
  * - Both must be closed, every edge shared by two triangles, as the builders make them apart from the open
9216
9241
  * ones like buildGrid and buildRibbon; the result is closed and indexed, and neither mesh changes
@@ -9227,12 +9252,12 @@ declare module "littlejsengine" {
9227
9252
  * @return {Mesh}
9228
9253
  * @example
9229
9254
  * const wall = buildBox(vec3(4, 3, .5)).subtract(buildBox(vec3(1, 2, 1)), vec3(0, -.5, 0)); // a doorway */
9230
- subtract(mesh: Mesh, matrix?: Matrix4 | Vector3): Mesh;
9255
+ subtract(mesh: Mesh, matrix?: Vector3 | Matrix4): Mesh;
9231
9256
  /** Returns a new mesh of only what is in both this mesh and the other, see subtract
9232
9257
  * @param {Mesh} mesh - Closed, as the builders make them apart from the open ones like buildGrid
9233
9258
  * @param {Matrix4|Vector3} [matrix] - Places the other mesh, or just a position to move it to
9234
9259
  * @return {Mesh} */
9235
- intersect(mesh: Mesh, matrix?: Matrix4 | Vector3): Mesh;
9260
+ intersect(mesh: Mesh, matrix?: Vector3 | Matrix4): Mesh;
9236
9261
  /** Scale every uv, so a whole texture repeats across the mesh when its TextureInfo wraps
9237
9262
  * @param {Vector2|number} scale - Repeats across and up, a number for both
9238
9263
  * @return {Mesh} */
@@ -9285,7 +9310,7 @@ declare module "littlejsengine" {
9285
9310
  * @param {Matrix4|Vector3} [matrix] - Object transform, or just a position to draw it at
9286
9311
  * @param {TileInfo|TextureInfo} [tileInfo] - Texture, mesh uvs map across the tile or the whole texture
9287
9312
  * @param {Color} [color] - Tint */
9288
- render(matrix?: Matrix4 | Vector3, tileInfo?: TileInfo | TextureInfo, color?: Color): void;
9313
+ render(matrix?: Vector3 | Matrix4, tileInfo?: TileInfo | TextureInfo, color?: Color): void;
9289
9314
  /** Delete the GPU buffer now, the CPU arrays stay so the mesh can be rendered again
9290
9315
  * - Optional, the buffer is freed anyway once the mesh is garbage collected, this frees it right away */
9291
9316
  dispose(): void;
@@ -9344,11 +9369,11 @@ declare module "littlejsengine" {
9344
9369
  boundsEnd: number;
9345
9370
  /** @type {number|undefined} */
9346
9371
  fixedRadius: number | undefined;
9347
- buffer: WebGLBuffer;
9372
+ buffer: WebGLBuffer | null | undefined;
9348
9373
  /** @type {WebGLBuffer|undefined} */
9349
9374
  colorBuffer: WebGLBuffer | undefined;
9350
9375
  bufferGeneration: number;
9351
- uvTileInfo: TileInfo | TextureInfo;
9376
+ uvTileInfo: TileInfo | TextureInfo | undefined;
9352
9377
  /** Place an instance by its position, rotation and scale, what buildMatrix takes, written straight in with no
9353
9378
  * matrix made; in world space
9354
9379
  * @param {number} i
@@ -9489,7 +9514,7 @@ declare module "littlejsengine" {
9489
9514
  * @return {Mesh}
9490
9515
  * @memberof Render3D
9491
9516
  */
9492
- export function buildBox(size?: Vector3 | number, bevel?: number, bevelSegments?: number): Mesh;
9517
+ export function buildBox(size?: number | Vector3, bevel?: number, bevelSegments?: number): Mesh;
9493
9518
  /**
9494
9519
  * Build a heightfield grid in the XZ plane centered on the origin
9495
9520
  * - smooth rounds the lighting across cells and colors each corner
@@ -9507,7 +9532,7 @@ declare module "littlejsengine" {
9507
9532
  * @example
9508
9533
  * const ground = buildGrid(vec2(20), 10, (x, z)=> (floor(x / 2) + floor(z / 2)) & 1 ? GRAY : WHITE); // 2 unit checks
9509
9534
  */
9510
- 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;
9511
9536
  /**
9512
9537
  * Build a lit ribbon along a path, for roads, tracks and walls
9513
9538
  * - Each segment is a flat quad, the sides are across the path in the plane of the up vector
@@ -9522,7 +9547,7 @@ declare module "littlejsengine" {
9522
9547
  * @example
9523
9548
  * const road = buildRibbon(trackPoints, 8, GRAY, true); // a loop of road
9524
9549
  */
9525
- 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;
9526
9551
  /**
9527
9552
  * Build a hull from a row of diamond shaped slices along Z, for ships, planes and cars
9528
9553
  * - Each slice is [z, width, top, bottom, sideHeight]
@@ -9614,7 +9639,7 @@ declare module "littlejsengine" {
9614
9639
  * @param {Array<Array<Color>>|HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|TextureInfo} [colors]
9615
9640
  * @param {Vector3} [pos3D] - Center of the map
9616
9641
  * @param {boolean} [smooth] - Defaults to render3D.smoothShading */
9617
- 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);
9618
9643
  /** @property {Array<Array<number>>} - Heights 0-1 as [row][column], rows along Z, rebuild() after changing them */
9619
9644
  heights: number[][];
9620
9645
  /** @property {Array<Array<Color>>|undefined} - Vertex colors as [row][column], undefined for white
@@ -9674,7 +9699,7 @@ declare module "littlejsengine" {
9674
9699
  levelSegment3D(from: Vector3, to: Vector3): {
9675
9700
  distance: number;
9676
9701
  normal: Vector3;
9677
- };
9702
+ } | undefined;
9678
9703
  /** Keep an object above the ground, called by the engine for each object with collideLevel
9679
9704
  * @param {EngineObject3D} o
9680
9705
  * @param {Vector3} oldPos - Where it was before it moved
@@ -9713,6 +9738,8 @@ declare module "littlejsengine" {
9713
9738
  constructor(pos3D?: Vector3, mapSize?: Vector3, tileInfo?: TileInfo);
9714
9739
  /** @property {Vector3} - Cells along X, Y and Z */
9715
9740
  mapSize: Vector3;
9741
+ /** @property {TileInfo} - The sheet's first tile, rebuild() after changing it or resizing its texture */
9742
+ tileInfo: TileInfo;
9716
9743
  /** @property {Uint8Array} - The block type of each cell, x + mapSize.x * (y + mapSize.y * z), 0 empty; call
9717
9744
  * rebuild() after changing it directly */
9718
9745
  data: Uint8Array;
@@ -9885,6 +9912,13 @@ declare module "littlejsengine" {
9885
9912
  /** @property {number} - How fast the glow fades from its middle: 1 by default, .5 a wide haze, 2 a tight
9886
9913
  * bright core */
9887
9914
  glowFalloff: number;
9915
+ /** @property {TextureInfo|TileInfo|undefined} - A gel: a picture the light shines through, like a stained glass
9916
+ * window or the leaves of a tree, cast along its cone in its colors, upright as the light looks out, the whole
9917
+ * texture of a TileInfo; only the spotlight that casts the shadows has one, with render3D.shadows on and it
9918
+ * as render3D.shadowLight, and only on what takes its shadows: an object with receiveShadow off is lit
9919
+ * without the gel; its alpha is not read, see through panes are dark
9920
+ * @type {TextureInfo|TileInfo|undefined} */
9921
+ gel: TextureInfo | TileInfo | undefined;
9888
9922
  /** @type {LensFlare3D|undefined} */
9889
9923
  flareObject: LensFlare3D | undefined;
9890
9924
  /** Give the light a lens flare, made with the arguments of LensFlare3D, in place of the one it had
@@ -9895,13 +9929,13 @@ declare module "littlejsengine" {
9895
9929
  * @param {Color} [color] - Tints the flare, with the light's own color
9896
9930
  * @return {LensFlare3D} - The flare, to change: light.addFlare().shapes = ['hex'] */
9897
9931
  addFlare(size?: number, count?: number, intensity?: number, saturation?: number, color?: Color): LensFlare3D;
9898
- set flare(arg: LensFlare3D);
9932
+ set flare(arg: LensFlare3D | undefined);
9899
9933
  /** The light's lens flare, undefined for none: addFlare makes it, or set a LensFlare3D of your own, and
9900
9934
  * destroying the flare takes it away
9901
9935
  * - The flare is the light's: it is attached to the light as its child, so it stays through a scene change
9902
9936
  * when the light does, and is destroyed with the light or when another takes its place
9903
9937
  * @type {LensFlare3D|undefined} */
9904
- get flare(): LensFlare3D;
9938
+ get flare(): LensFlare3D | undefined;
9905
9939
  }
9906
9940
  /**
9907
9941
  * DirectionalLight3D - A Light3D that shines from far away with no falloff, like sunlight
@@ -10195,7 +10229,7 @@ declare module "littlejsengine" {
10195
10229
  }>;
10196
10230
  /** Forget the trail so far, for when the object teleports */
10197
10231
  clear(): void;
10198
- worldPos3D: Vector3;
10232
+ worldPos3D: Vector3 | undefined;
10199
10233
  }
10200
10234
  /**
10201
10235
  * A part of a lens flare
@@ -10219,7 +10253,8 @@ declare module "littlejsengine" {
10219
10253
  * with the sun's own color; shapes says what its ghosts are, glowSize and ghostSize how big its parts are; or
10220
10254
  * give it elements of your own, which may be tiles of the game's
10221
10255
  * - visible is how much of the sun shows, 0 to 1, eased over fadeTime, there for a game to read; it is 0 while the
10222
- * sun is too far off the screen for the flare to show, a third of the screen past its edge, where nothing is tested
10256
+ * sun is too far off the screen for the flare to show, about a seventh of the screen past its edge, where nothing
10257
+ * is tested
10223
10258
  * - What hides the sun is found with a ray from the camera, against the level and every object that is not see
10224
10259
  * through, each on the triangles of its mesh, see render3D.pick; turn it off with occlusion
10225
10260
  * - It needs WebGL, and it draws nothing in the shadow of renderAfter2D
@@ -10262,7 +10297,7 @@ declare module "littlejsengine" {
10262
10297
  elements: Array<LensFlareElement> | undefined;
10263
10298
  /** @property {Light3D|undefined} - A light the flare is of in place of the sun, a lamp or a spotlight: the
10264
10299
  * flare is at the light and in its color, smaller from farther than the light reaches, hidden by what is
10265
- * in front of the light but its lamp, a mesh around it no wider than half its radius, and a spotlight's
10300
+ * in front of the light but its lamp, a mesh around it whose surface is near it, and a spotlight's
10266
10301
  * shows from inside its beam only; a DirectionalLight3D's is far
10267
10302
  * away where it shines from, like the sun's; the flare is destroyed when its light is; light.addFlare
10268
10303
  * sets this
@@ -10282,18 +10317,28 @@ declare module "littlejsengine" {
10282
10317
  * glowSize and ghostSize, a glow and a core at the sun and the ghosts, made again when one of those changes
10283
10318
  * @return {Array<LensFlareElement>} */
10284
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 */
10285
10325
  flareSource(): {
10286
10326
  direction: Vector3;
10287
10327
  distance: number;
10288
10328
  pos: Vector3;
10289
- };
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 */
10290
10335
  flareLook(): {
10291
10336
  sun: Vector2;
10292
10337
  center: Vector2;
10293
10338
  strength: number;
10294
10339
  tint: Color;
10295
10340
  height: number;
10296
- };
10341
+ } | undefined;
10297
10342
  /** Where the sun, or the flare's light, is on the screen, in pixels like mousePosScreen, undefined when it is
10298
10343
  * behind the camera
10299
10344
  * @return {Vector2|undefined} */
@@ -10327,7 +10372,7 @@ declare module "littlejsengine" {
10327
10372
  * @return {Array<EngineObject3D>}
10328
10373
  * @memberof Render3D
10329
10374
  */
10330
- 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>;
10331
10376
  /**
10332
10377
  * Call a function for each EngineObject3D whose box overlaps a sphere or a box
10333
10378
  * - An object destroyed by an earlier callback is skipped
@@ -10338,7 +10383,7 @@ declare module "littlejsengine" {
10338
10383
  * @param {boolean} [testCenters] - Test only each object's center, see engineObjectsCollect3D
10339
10384
  * @memberof Render3D
10340
10385
  */
10341
- 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;
10342
10387
  /**
10343
10388
  * Collect every EngineObject3D a ray passes through, nearest first, the 3D twin of engineObjectsRaycast
10344
10389
  * - The ray has no end, so everything along it counts however far away it is
@@ -10348,7 +10393,7 @@ declare module "littlejsengine" {
10348
10393
  * @return {Array<EngineObject3D>}
10349
10394
  * @memberof Render3D
10350
10395
  */
10351
- export function engineObjectsRaycast3D(ray: Ray3D, objects?: Array<EngineObject>): Array<EngineObject3D>;
10396
+ export function engineObjectsRaycast3D(ray: Ray3D, objects?: EngineObject[]): Array<EngineObject3D>;
10352
10397
  /**
10353
10398
  * Parse Wavefront OBJ text into a Mesh
10354
10399
  * - Reads v, vt, vn and f lines with convex polygons of any size, materials and groups are ignored
@@ -10379,7 +10424,7 @@ declare module "littlejsengine" {
10379
10424
  */
10380
10425
  export class GLTFModel {
10381
10426
  /** @param {Array<GLTFPart>} parts @param {Array<GLTFAnimation>} [animations] @param {Object} [nodeTree] */
10382
- constructor(parts: Array<GLTFPart>, animations?: Array<GLTFAnimation>, nodeTree?: any);
10427
+ constructor(parts: Array<GLTFPart>, animations?: GLTFAnimation[], nodeTree?: any);
10383
10428
  /** @property {Array<GLTFPart>} - One per primitive of every node that has a mesh */
10384
10429
  parts: GLTFPart[];
10385
10430
  /** @property {Array<GLTFAnimation>} - The animations, play one through createObject's GLTFObject
@@ -10566,11 +10611,24 @@ declare module "littlejsengine" {
10566
10611
  duration: number;
10567
10612
  }
10568
10613
  /** Parse a model from GLB bytes or glTF JSON, fetching the buffers and images it refers to
10614
+ * - A .gltf names its .bin and image files, which are fetched from baseUrl, or found among files: what a game
10615
+ * has in hand, like the files dropped on the page, by their paths in the drop; with files, baseUrl is the
10616
+ * .gltf's own folder among them ('' or 'models/house/'), its names are read from there, and a name found nowhere
10617
+ * there is taken by its file name alone only when one file of the drop has it; only an http, https or blob uri
10618
+ * is fetched then
10619
+ * - A file the model needs that is not found is named in the error, and an image that can not be read is named in
10620
+ * a warning and left out
10569
10621
  * @param {ArrayBuffer|Object|string} data - GLB bytes, or the glTF JSON as bytes, text or an object
10570
10622
  * @param {string} [baseUrl] - Where the .bin and image files are, with its trailing slash; loadGLTF passes the file's folder
10623
+ * @param {Map<string, Blob>} [files] - The files it refers to, by their paths, in place of fetching them
10571
10624
  * @return {Promise<GLTFModel>}
10625
+ * @example
10626
+ * // the files of a drop, a .gltf with its .bin and textures, by their names
10627
+ * const files = new Map([...dataTransfer.files].map((file)=> [file.name, file]));
10628
+ * const gltf = [...files.values()].find((file)=> file.name.endsWith('.gltf'));
10629
+ * const model = await parseGLTF(await gltf.text(), '', files);
10572
10630
  * @memberof GLTF */
10573
- export function parseGLTF(data: ArrayBuffer | any | string, baseUrl?: string): Promise<GLTFModel>;
10631
+ export function parseGLTF(data: ArrayBuffer | any | string, baseUrl?: string, files?: Map<string, Blob>): Promise<GLTFModel>;
10574
10632
  /** Load a glTF or GLB model, the .bin and images of a .gltf from beside it
10575
10633
  * - A texture only OPAQUE materials use loads with its alpha set to 1, so the 3D pass cuts no holes in it
10576
10634
  * @param {string} url
@@ -10584,7 +10642,7 @@ declare module "littlejsengine" {
10584
10642
  * @param {number} [time] - How long to show it, 0 is one frame
10585
10643
  * @param {Vector3} [rotation] - vec3(pitch, yaw, roll)
10586
10644
  * @memberof Render3D */
10587
- 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;
10588
10646
  /** Draw a debug wireframe sphere as three rings
10589
10647
  * @param {Vector3} pos - Center
10590
10648
  * @param {number} [size] - Diameter
@@ -10786,7 +10844,7 @@ declare module "littlejsengine" {
10786
10844
  /** @property {Object} - The three.js perspective camera */
10787
10845
  camera: any;
10788
10846
  /** @property {boolean} - Lock the camera to the LittleJS 2D camera so the z=0 plane matches world space */
10789
- cameraAlign2D: boolean;
10847
+ cameraAlign2D: boolean | undefined;
10790
10848
  /** @property {number|undefined} - Near plane of the aligned camera before any zoom out, from camera.near on the
10791
10849
  * first aligned frame; while aligned, change this rather than camera.near
10792
10850
  * @type {number|undefined} */
@@ -10831,6 +10889,7 @@ declare module "littlejsengine" {
10831
10889
  * - Animation frames keep layout and wrap across rows as needed
10832
10890
  * - WebGL textures upload once per batch of loads
10833
10891
  * - loadAtlas imports pre-packed atlases (TexturePacker and Aseprite json)
10892
+ * - loadTiles packs separate tile images, or several tile sheets, into one tile set for tile layers and maps
10834
10893
  * @namespace TextureSheets
10835
10894
  */
10836
10895
  /** Width and height in pixels of texture sheets created by loadSprite
@@ -10867,9 +10926,9 @@ declare module "littlejsengine" {
10867
10926
  /** @property {number} - Width and height of the sheet in pixels */
10868
10927
  size: number;
10869
10928
  /** @property {OffscreenCanvasRenderingContext2D} - 2d context for the canvas */
10870
- context: OffscreenCanvasRenderingContext2D;
10929
+ context: OffscreenCanvasRenderingContext2D | undefined;
10871
10930
  /** @property {OffscreenCanvas} - Canvas holding the packed images */
10872
- canvas: OffscreenCanvas;
10931
+ canvas: OffscreenCanvas | undefined;
10873
10932
  /** @property {TextureInfo} - The texture info for this sheet */
10874
10933
  textureInfo: TextureInfo;
10875
10934
  /** @property {Vector2} - Where the next image will be packed */
@@ -10901,6 +10960,8 @@ declare module "littlejsengine" {
10901
10960
  * - Pass frameSize for animations, then step through them with TileInfo.frame
10902
10961
  * - Grid images keep their layout and frames wrap down to the next row
10903
10962
  * - Pass sourcePadding if the source image has padding baked in around frames
10963
+ * - The same image loaded again with the same settings gives back what the first load did, packed once, unless
10964
+ * that load failed
10904
10965
  * @param {string} src - Image source path
10905
10966
  * @param {Vector2|number} [frameSize] - Size of each animation frame in pixels, or the whole image less its
10906
10967
  * source padding if not passed
@@ -10911,7 +10972,30 @@ declare module "littlejsengine" {
10911
10972
  * const playerTile = loadSprite('player.png'); // a single sprite
10912
10973
  * const runTile = loadSprite('run.png', vec2(16)); // a 16x16 frame animation
10913
10974
  * @memberof TextureSheets */
10914
- 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;
10976
+ /** Load tile images and pack them into texture sheets as one tile set, for tile layers and maps
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
10978
+ * sheet is all of its tiles; the tiles are numbered from 0 in the order the images are given
10979
+ * - Returns a tile set at once, a TileInfo whose tiles fill in as the images load; wait for them with spritesReady
10980
+ * - Give it to tileLayersLoad, a TileLayer or a TileCollisionLayer as its tile info: tile n draws tiles[n],
10981
+ * wherever it was packed, and the level editor's palette offers each of them; frame and index do not read the
10982
+ * list, use set.tiles[n] for one tile; make the layers after spritesReady, a layer made before draws nothing
10983
+ * - An image that is not a whole number of tiles gives the whole tiles in it; a sheet with gaps between its tiles
10984
+ * is not read, cut it into its tiles first
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
10986
+ * of the images after it move up
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
10989
+ * @param {Array<string>} sources - Image source paths
10990
+ * @param {Vector2|number} [tileSize] - Size of a tile in pixels
10991
+ * @param {number} [padding] - How many pixels padding around each tile on the sheet
10992
+ * @return {TileInfo}
10993
+ * @example
10994
+ * const tiles = loadTiles(['grass.png', 'dirt.png', 'water.png', 'props.png'], 16);
10995
+ * await spritesReady();
10996
+ * tileLayersLoad(map, tiles); // tile 0 is grass, 1 dirt, 2 water, then the tiles of props.png
10997
+ * @memberof TextureSheets */
10998
+ export function loadTiles(sources: Array<string>, tileSize?: number | Vector2, padding?: number): TileInfo;
10915
10999
  /** Load a pre-packed texture atlas and repack it onto texture sheets
10916
11000
  * - Supports TexturePacker json (hash and array) and Aseprite json
10917
11001
  * - Returns an empty object which is filled with TileInfos when loaded
@@ -10919,6 +11003,8 @@ declare module "littlejsengine" {
10919
11003
  * - Aseprite frame tags become animations, so do names like run_0, run_1
10920
11004
  * - Trimmed frames are restored to their full source size when packed
10921
11005
  * - Rotated frames are rotated back upright when packed
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
10922
11008
  * @param {string} imageSrc - Atlas image path
10923
11009
  * @param {string|Object} jsonSrc - Atlas json path, or already parsed json data
10924
11010
  * @param {number} [padding] - How many pixels padding around each frame