littlejsengine 1.24.3 → 1.26.0

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 (53) hide show
  1. package/CHANGELOG.md +123 -0
  2. package/EDITOR.md +2 -2
  3. package/FAQ.md +55 -11
  4. package/README.md +6 -2
  5. package/REFERENCE.md +203 -57
  6. package/dist/littlejs.d.ts +933 -313
  7. package/dist/littlejs.esm.js +5143 -2419
  8. package/dist/littlejs.esm.min.js +38 -24
  9. package/dist/littlejs.js +5132 -2416
  10. package/dist/littlejs.min.js +37 -23
  11. package/dist/littlejs.release.js +4905 -2232
  12. package/package.json +4 -4
  13. package/plugins/box2d.js +141 -56
  14. package/plugins/drawUtilities.js +374 -380
  15. package/plugins/gltf.js +383 -60
  16. package/plugins/lightSystem.js +412 -30
  17. package/plugins/math3d.js +1015 -1014
  18. package/plugins/medalSystem.js +19 -7
  19. package/plugins/newgrounds.js +5 -6
  20. package/plugins/parallax.js +1 -0
  21. package/plugins/particleEffects.js +47 -14
  22. package/plugins/pathFinder.js +60 -38
  23. package/plugins/pluginExport.js +11 -0
  24. package/plugins/postProcess.js +200 -67
  25. package/plugins/render3d.js +493 -2391
  26. package/plugins/render3dDebug.js +5 -8
  27. package/plugins/render3dEditor.js +84 -9
  28. package/plugins/render3dExtras.js +122 -33
  29. package/plugins/render3dLevel.js +67 -8
  30. package/plugins/render3dMesh.js +1158 -0
  31. package/plugins/render3dObject.js +1451 -0
  32. package/plugins/render3dVoxels.js +15 -3
  33. package/plugins/textureSheet.js +9 -8
  34. package/plugins/threejs.js +1 -1
  35. package/plugins/tweenSystem.js +117 -87
  36. package/plugins/uiSystem.js +62 -28
  37. package/plugins/wavedash.js +229 -0
  38. package/src/engine.js +192 -40
  39. package/src/engineAudio.js +47 -27
  40. package/src/engineBuild.mjs +6 -1
  41. package/src/engineDebug.js +23 -162
  42. package/src/engineDraw.js +148 -43
  43. package/src/engineEditor.js +153 -40
  44. package/src/engineExport.js +0 -3
  45. package/src/engineInput.js +31 -25
  46. package/src/engineMath.js +38 -20
  47. package/src/engineObject.js +68 -50
  48. package/src/engineParticles.js +66 -18
  49. package/src/engineRelease.js +18 -15
  50. package/src/engineSettings.js +48 -9
  51. package/src/engineTileLayer.js +44 -18
  52. package/src/engineUtilities.js +56 -11
  53. package/src/engineWebGL.js +68 -22
@@ -85,9 +85,53 @@ declare module "littlejsengine" {
85
85
  */
86
86
  export type SpriteAnimationEndCallback = () => void;
87
87
  /**
88
- * - Function called when sound is loaded
88
+ * - Function called once a sound has loaded, or failed to, which sound.isLoaded() tells
89
89
  */
90
90
  export type SoundLoadCallback = (sound: Sound) => any;
91
+ /**
92
+ * A Tiled map as Tiled saves it as JSON, what tileLayersLoad and objectLayersLoad take and tileLayersFromLDtk
93
+ * makes; the fields read are listed, and the rest of the file is kept as it is
94
+ */
95
+ export type TiledMap = {
96
+ /**
97
+ * - Cells across
98
+ */
99
+ width: number;
100
+ /**
101
+ * - Cells up
102
+ */
103
+ height: number;
104
+ /**
105
+ * - A tile's width in pixels
106
+ */
107
+ tilewidth?: number;
108
+ /**
109
+ * - A tile's height in pixels
110
+ */
111
+ tileheight?: number;
112
+ /**
113
+ * - Tile layers, object layers and groups of them, bottom first
114
+ */
115
+ layers: Array<any>;
116
+ /**
117
+ * - The first one's margin, spacing and columns are read
118
+ */
119
+ tilesets?: any[];
120
+ nextlayerid?: number;
121
+ nextobjectid?: number;
122
+ orientation?: string;
123
+ renderorder?: string;
124
+ infinite?: boolean;
125
+ type?: string;
126
+ /**
127
+ * - A number in files from Tiled before 1.6
128
+ */
129
+ version?: string | number;
130
+ tiledversion?: string;
131
+ compressionlevel?: number;
132
+ backgroundcolor?: string;
133
+ properties?: any[];
134
+ };
91
135
  /**
92
136
  * - Function that processes a particle
93
137
  */
@@ -96,6 +140,10 @@ declare module "littlejsengine" {
96
140
  * - Decides whether a particle stops at a tile, it is a filter rather than a notice
97
141
  */
98
142
  export type ParticleCollideCallback = (particle: Particle, tileData: number, pos: Vector2) => boolean;
143
+ /**
144
+ * - Callback for drag and drop events
145
+ */
146
+ export type DragAndDropCallback = (event: DragEvent) => any;
99
147
  /**
100
148
  * A scene, any object with the hooks it needs, each optional and called as a method so this is the scene
101
149
  */
@@ -143,6 +191,7 @@ declare module "littlejsengine" {
143
191
  reflectivity: number;
144
192
  emissiveMap: TextureInfo | undefined;
145
193
  emissiveMapColor: Color;
194
+ environmentMap: CubeMap | undefined;
146
195
  emissiveR: number;
147
196
  emissiveG: number;
148
197
  emissiveB: number;
@@ -234,10 +283,70 @@ declare module "littlejsengine" {
234
283
  normal: Vector3;
235
284
  type: number;
236
285
  };
286
+ /**
287
+ * A 3D level as it is saved, what level3DLoad takes and the 3D level editor edits
288
+ */
289
+ export type Level3D = {
290
+ /**
291
+ * - The format's version, 1
292
+ */
293
+ littlejs3D?: number;
294
+ /**
295
+ * - Each {id, type, pos, rotation, scale, properties}, all but type optional
296
+ */
297
+ objects: Array<any>;
298
+ /**
299
+ * - The scene block: sky, ambient, sunDirection, sunColor, fog, fogColor, shadows, lensFlare,
300
+ * skyBox, environment
301
+ */
302
+ scene?: any;
303
+ /**
304
+ * - A block map: {pos, size, blocks}
305
+ */
306
+ voxels?: any;
307
+ /**
308
+ * - A height map: {pos, size, height, color, heights, paint}
309
+ */
310
+ terrain?: any;
311
+ /**
312
+ * - The level's own prefabs by name, each {objects, attached}
313
+ */
314
+ prefabs?: any;
315
+ };
316
+ /**
317
+ * What bends a skinned part: its joints, the nodes that move it, their inverse bind matrices, and for each vertex
318
+ * of its mesh four joints and four weights, with the place and normal each pose bends from
319
+ */
320
+ export type GLTFSkin = {
321
+ /**
322
+ * - The joints, as node numbers
323
+ */
324
+ joints: Array<number>;
325
+ /**
326
+ * - Each joint's inverse bind matrix
327
+ */
328
+ inverseBind: Array<Matrix4>;
329
+ /**
330
+ * - Four joints a vertex, as places in joints
331
+ */
332
+ vertexJoints: Uint16Array;
333
+ /**
334
+ * - Four weights a vertex, summing to 1
335
+ */
336
+ vertexWeights: Float32Array;
337
+ /**
338
+ * - Each vertex's place as stored, x y z
339
+ */
340
+ bindPoints: Float32Array;
341
+ /**
342
+ * - Each vertex's normal as stored, x y z
343
+ */
344
+ bindNormals: Float32Array;
345
+ };
237
346
  /**
238
347
  * - Puts the player at a world position, for the level editor's Play from mouse
239
348
  */
240
- export type EditorPlayFromCallback = (pos: Vector2) => any;
349
+ export type EditorPlayFromCallback = (pos: any) => any;
241
350
  /**
242
351
  * - Rebuilds the level from the map the level editor changed
243
352
  */
@@ -247,14 +356,15 @@ declare module "littlejsengine" {
247
356
  */
248
357
  export type EditorTileCallback = (layer: TileLayer, pos: Vector2, tile: number | undefined) => any;
249
358
  /**
250
- * - What the level editor gives the callbacks of a tool of the game's own
359
+ * - What the level editor gives the callbacks of a tool of the game's own; P is
360
+ * the type of pos, a Vector2 for a 2D tool, the default, and Vector3|undefined for a 3D one
251
361
  */
252
- export type EditorToolAt = {
362
+ export type EditorToolAt<P = Vector2> = {
253
363
  /**
254
364
  * - Where the mouse is in the level: a Vector2 in the 2D editor; in the 3D one a Vector3 on
255
365
  * the level or the ground, undefined when the mouse is over the panel
256
366
  */
257
- pos: any;
367
+ pos: P;
258
368
  /**
259
369
  * - 2D: the tile cell under the mouse on the selected tile layer
260
370
  */
@@ -262,7 +372,7 @@ declare module "littlejsengine" {
262
372
  /**
263
373
  * - 3D: the mouse's Ray3D
264
374
  */
265
- ray: any;
375
+ ray: Ray3D | undefined;
266
376
  /**
267
377
  * - Is Shift held
268
378
  */
@@ -273,9 +383,10 @@ declare module "littlejsengine" {
273
383
  ctrl: boolean;
274
384
  };
275
385
  /**
276
- * - A tool of the game's own for the level editor, see LevelEditor.addTool
386
+ * - A tool of the game's own for the level editor, see LevelEditor.addTool; P is the
387
+ * type of its pos, as EditorToolAt has it
277
388
  */
278
- export type EditorTool = {
389
+ export type EditorTool<P = Vector2> = {
279
390
  /**
280
391
  * - The key that picks it, as addKey spells one
281
392
  */
@@ -288,19 +399,19 @@ declare module "littlejsengine" {
288
399
  * - The left button went down in the level; returning false
289
400
  * says the press was not the tool's
290
401
  */
291
- onPress?: (arg0: EditorToolAt) => any;
402
+ onPress?: (arg0: EditorToolAt<P>) => any;
292
403
  /**
293
404
  * - Each frame it is held
294
405
  */
295
- onDrag?: (arg0: EditorToolAt) => any;
406
+ onDrag?: (arg0: EditorToolAt<P>) => any;
296
407
  /**
297
408
  * - It was let go
298
409
  */
299
- onRelease?: (arg0: EditorToolAt) => any;
410
+ onRelease?: (arg0: EditorToolAt<P>) => any;
300
411
  /**
301
412
  * - Each frame the tool is on, to draw its cursor or preview
302
413
  */
303
- onDraw?: (arg0: EditorToolAt) => any;
414
+ onDraw?: (arg0: EditorToolAt<P>) => any;
304
415
  };
305
416
  /**
306
417
  * - The 2D level editor's edit functions, levelEditor.edit2D
@@ -535,7 +646,7 @@ declare module "littlejsengine" {
535
646
  * @param {GameCallback} [gameUpdatePost] - Called after physics and objects are updated, even when paused, use for UI updates
536
647
  * @param {GameCallback} [gameRender] - Called before objects are rendered, use for drawing backgrounds/world elements
537
648
  * @param {GameCallback} [gameRenderPost] - Called after objects are rendered, use for drawing UI/overlays
538
- * @param {Array<string>} [imageSources=[]] - List of image file paths to preload (e.g., ['player.png', 'tiles.png'])
649
+ * @param {Array<string>|string} [imageSources=[]] - List of image file paths to preload (e.g., ['player.png', 'tiles.png']), or one path
539
650
  * @param {HTMLElement} [rootElement] - Root DOM element to attach canvas to, defaults to document.body
540
651
  * It keeps its own inline styles and the canvas centers inside it, but the canvas is still sized from the window,
541
652
  * so set canvasFixedSize or canvasMaxSize to fit a smaller element
@@ -549,8 +660,9 @@ declare module "littlejsengine" {
549
660
  * ()=> { drawHUD(); }, // gameRenderPost
550
661
  * ['tiles.png', 'tilesLevel.png'] // images to load
551
662
  * );
552
- * @memberof Engine */
553
- export function engineInit(gameInit?: GameInitCallback, gameUpdate?: GameCallback, gameUpdatePost?: GameCallback, gameRender?: GameCallback, gameRenderPost?: GameCallback, imageSources?: string[], rootElement?: HTMLElement): Promise<void>;
663
+ * @memberof Engine
664
+ * @return {Promise<void>} - Done when the images have loaded and gameInit has run */
665
+ export function engineInit(gameInit?: GameInitCallback, gameUpdate?: GameCallback, gameUpdatePost?: GameCallback, gameRender?: GameCallback, gameRenderPost?: GameCallback, imageSources?: string | string[], rootElement?: HTMLElement): Promise<void>;
554
666
  /** Advance the engine by a number of frames
555
667
  * Requires setEngineManualStep(true), before engineInit or while running; it stops early if an update turns it off
556
668
  * Respects paused exactly as the normal update loop does
@@ -560,7 +672,7 @@ declare module "littlejsengine" {
560
672
  * setHeadlessMode(true);
561
673
  * setEngineManualStep(true);
562
674
  * await engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost);
563
- * engineStep(600); // advance 10 seconds of game time
675
+ * engineStep(600); // 600 updates of 1/60 second; the first is at time 0, so time is then 599/60
564
676
  * @memberof Engine */
565
677
  export function engineStep(frames?: number): void;
566
678
  /** Update each engine object and remove destroyed objects; time and frame are advanced by the engine loop, not here
@@ -637,7 +749,7 @@ declare module "littlejsengine" {
637
749
  * - setDebugKeysAlways lets those keys work with the overlay closed too
638
750
  * - ASSERT and LOG macros for development (removed in release builds)
639
751
  * - Debug primitive rendering (rectangles, circles, lines, points, text)
640
- * - Screenshot and video capture support
752
+ * - Screenshot support
641
753
  * - FPS counter and performance watermark
642
754
  * - Debug overlay shows mouse position and picked objects
643
755
  * @namespace Debug
@@ -688,7 +800,7 @@ declare module "littlejsengine" {
688
800
  */
689
801
  /**
690
802
  * @callback EditorPlayFromCallback - Puts the player at a world position, for the level editor's Play from mouse
691
- * @param {Vector2} pos - Where to start playing
803
+ * @param {any} pos - Where to start playing, a Vector2 from the 2D editor and a Vector3 from the 3D one
692
804
  * @memberof Editor
693
805
  */
694
806
  /**
@@ -703,24 +815,28 @@ declare module "littlejsengine" {
703
815
  * @memberof Editor
704
816
  */
705
817
  /**
706
- * @typedef {Object} EditorToolAt - What the level editor gives the callbacks of a tool of the game's own
707
- * @property {any} pos - Where the mouse is in the level: a Vector2 in the 2D editor; in the 3D one a Vector3 on
818
+ * @template [P=Vector2]
819
+ * @typedef {Object} EditorToolAt - What the level editor gives the callbacks of a tool of the game's own; P is
820
+ * the type of pos, a Vector2 for a 2D tool, the default, and Vector3|undefined for a 3D one
821
+ * @property {P} pos - Where the mouse is in the level: a Vector2 in the 2D editor; in the 3D one a Vector3 on
708
822
  * the level or the ground, undefined when the mouse is over the panel
709
823
  * @property {Vector2|undefined} cell - 2D: the tile cell under the mouse on the selected tile layer
710
- * @property {any} ray - 3D: the mouse's Ray3D
824
+ * @property {Ray3D|undefined} ray - 3D: the mouse's Ray3D
711
825
  * @property {boolean} shift - Is Shift held
712
826
  * @property {boolean} ctrl - Is Ctrl held
713
827
  * @memberof Editor
714
828
  */
715
829
  /**
716
- * @typedef {Object} EditorTool - A tool of the game's own for the level editor, see LevelEditor.addTool
830
+ * @template [P=Vector2]
831
+ * @typedef {Object} EditorTool - A tool of the game's own for the level editor, see LevelEditor.addTool; P is the
832
+ * type of its pos, as EditorToolAt has it
717
833
  * @property {string} [key] - The key that picks it, as addKey spells one
718
834
  * @property {string} [hint] - The hint line while it is on
719
- * @property {function(EditorToolAt): any} [onPress] - The left button went down in the level; returning false
835
+ * @property {function(EditorToolAt<P>): any} [onPress] - The left button went down in the level; returning false
720
836
  * says the press was not the tool's
721
- * @property {function(EditorToolAt): any} [onDrag] - Each frame it is held
722
- * @property {function(EditorToolAt): any} [onRelease] - It was let go
723
- * @property {function(EditorToolAt): any} [onDraw] - Each frame the tool is on, to draw its cursor or preview
837
+ * @property {function(EditorToolAt<P>): any} [onDrag] - Each frame it is held
838
+ * @property {function(EditorToolAt<P>): any} [onRelease] - It was let go
839
+ * @property {function(EditorToolAt<P>): any} [onDraw] - Each frame the tool is on, to draw its cursor or preview
724
840
  * @memberof Editor
725
841
  */
726
842
  /**
@@ -816,9 +932,9 @@ declare module "littlejsengine" {
816
932
  onClick: Function;
817
933
  title: string;
818
934
  }>;
819
- /** @type {Object<string, EditorTool>} */
935
+ /** @type {Object<string, EditorTool<any>>} */
820
936
  tools: {
821
- [x: string]: EditorTool;
937
+ [x: string]: EditorTool<any>;
822
938
  };
823
939
  /** What the game does when the 2D editor paints a tile, like setting its collision or its look the way the
824
940
  * game does when it loads the level; set it or override it, without one the collision layer gets collision 1
@@ -832,7 +948,7 @@ declare module "littlejsengine" {
832
948
  onRestart(): void;
833
949
  /** Put the player at a position, a Vector2 in the 2D editor and a Vector3 in the 3D one; set it or override it
834
950
  * and the editor has Play from mouse, which starts play there
835
- * @param {any} pos */
951
+ * @param {any} pos - A Vector2 from the 2D editor, a Vector3 from the 3D one */
836
952
  onPlayFrom(pos: any): void;
837
953
  /** Called when the editor opens, to set or override */
838
954
  onOpen(): void;
@@ -890,15 +1006,16 @@ declare module "littlejsengine" {
890
1006
  * in 3D
891
1007
  * - What the callbacks change through edit2D or edit3D is one undo: the editor ends the stroke at the release,
892
1008
  * and takes it back when the right button or Escape ends the press
1009
+ * @template [P=Vector2]
893
1010
  * @param {string} name
894
- * @param {EditorTool} tool - {key, hint, onPress, onDrag, onRelease, onDraw}, each optional; onPress returning
1011
+ * @param {EditorTool<P>} tool - {key, hint, onPress, onDrag, onRelease, onDraw}, each optional; onPress returning
895
1012
  * false says the press was not the tool's */
896
- addTool(name: string, tool: EditorTool): void;
1013
+ addTool<P = Vector2>(name: string, tool: EditorTool<P>): void;
897
1014
  /** Open the editor, pausing the game; until close(), Escape (the debug key) switches between playing and editing */
898
- open(): any;
1015
+ open(): void;
899
1016
  /** Close the editor and end its session, the game carries on with the changes and Escape opens the debug
900
1017
  * overlay again */
901
- close(): any;
1018
+ close(): void;
902
1019
  }
903
1020
  /** Make a level editor of the game's own the one in use: an instance of a class that extends LevelEditor, with
904
1021
  * the game's hooks as its methods; set it before the editor opens
@@ -922,7 +1039,7 @@ declare module "littlejsengine" {
922
1039
  export const debugPointSize: number;
923
1040
  /** Draw a debug rectangle in world space, or on the screen with screenSpace
924
1041
  * @param {Vector2} pos
925
- * @param {Vector2} [size=vec2(0)]
1042
+ * @param {Vector2} [size=vec2()]
926
1043
  * @param {Color|string} [color]
927
1044
  * @param {number} [time]
928
1045
  * @param {number} [angle]
@@ -998,15 +1115,6 @@ declare module "littlejsengine" {
998
1115
  * In release builds this function has no effect
999
1116
  * @memberof Debug */
1000
1117
  export function debugShowErrors(): void;
1001
- /** Start capturing video
1002
- * @memberof Debug */
1003
- export function debugVideoCaptureStart(): void;
1004
- /** Stop capturing video and save to disk
1005
- * @memberof Debug */
1006
- export function debugVideoCaptureStop(): void;
1007
- /** Check if video capture is active
1008
- * @memberof Debug */
1009
- export function debugVideoCaptureIsActive(): boolean;
1010
1118
  /**
1011
1119
  * LittleJS Engine Settings
1012
1120
  * - All settings for the engine are here
@@ -1388,6 +1496,7 @@ declare module "littlejsengine" {
1388
1496
  export function setCameraScale(scale: number): void;
1389
1497
  /** Set scale applied to engine time
1390
1498
  * - 0 freezes the game like a pause, gameUpdatePost and input still run so the game can set it back
1499
+ * - Above 1 the fixed step runs that many updates each frame, so a large scale costs as many updates
1391
1500
  * @param {number} scale - 0 or more
1392
1501
  * @memberof Settings */
1393
1502
  export function setTimeScale(scale: number): void;
@@ -1447,6 +1556,7 @@ declare module "littlejsengine" {
1447
1556
  * @memberof Settings */
1448
1557
  export function getCanvasPixelRatio(): number;
1449
1558
  /** Set default font used for text rendering
1559
+ * - A family name with spaces or digits goes in quotes, as "'Press Start 2P'", or the canvas does not take it
1450
1560
  * @param {string} font
1451
1561
  * @memberof Settings */
1452
1562
  export function setFontDefault(font: string): void;
@@ -1616,7 +1726,8 @@ declare module "littlejsengine" {
1616
1726
  * @param {boolean} enable
1617
1727
  * @memberof Settings */
1618
1728
  export function setVibrateEnable(enable: boolean): void;
1619
- /** Set if audio is enabled, false turns all sound off
1729
+ /** Set if audio is enabled, false turns all sound off; a setting for before sounds are made, since a sound made
1730
+ * while it is off has nothing to play and one already playing goes on; to mute while the game runs, setSoundVolume(0)
1620
1731
  * @param {boolean} enable
1621
1732
  * @memberof Settings */
1622
1733
  export function setSoundEnable(enable: boolean): void;
@@ -1719,7 +1830,7 @@ declare module "littlejsengine" {
1719
1830
  * @param {...number} values
1720
1831
  * @return {number}
1721
1832
  * @memberof Math */
1722
- export function hypot(...values: number[]): number;
1833
+ export const hypot: (...values: number[]) => number;
1723
1834
  /** Returns log2 of value passed in
1724
1835
  * @param {number} x
1725
1836
  * @return {number}
@@ -1898,9 +2009,9 @@ declare module "littlejsengine" {
1898
2009
  export function formatTime(t: number): string;
1899
2010
  /** Fetches a JSON file from a URL and returns the parsed JSON object. Must be used with await!
1900
2011
  * @param {string} url - URL of JSON file
1901
- * @return {Promise<object>}
2012
+ * @return {Promise<any>} - The parsed JSON, any shape, as response.json() gives it
1902
2013
  * @memberof Utilities */
1903
- export function fetchJSON(url: string): Promise<object>;
2014
+ export function fetchJSON(url: string): Promise<any>;
1904
2015
  /** Save a text file to disk
1905
2016
  * @param {string} text
1906
2017
  * @param {string} [filename]
@@ -1957,7 +2068,7 @@ declare module "littlejsengine" {
1957
2068
  * @return {number}
1958
2069
  * @memberof Utilities */
1959
2070
  export function noise1D(x: number): number;
1960
- /** 2D value noise — returns a smooth value in [0, 1] for any real (x, y).
2071
+ /** 2D value noise — returns a smooth value in [0, 1] for any real (x, y)
1961
2072
  * @param {number} x
1962
2073
  * @param {number} y
1963
2074
  * @return {number}
@@ -2512,7 +2623,7 @@ declare module "littlejsengine" {
2512
2623
  * Create a tile info object using a grid based system
2513
2624
  * - This can take vecs or floats for easier use and conversion
2514
2625
  * - If an index is passed in, the tile size and index will determine the position
2515
- * @param {Vector2|number} [index=0] - Index of the tile in 1d or 2d form
2626
+ * @param {Vector2|number} [index] - Index of the tile in 1d or 2d form
2516
2627
  * @param {Vector2|number} [size] - Size of tile in pixels
2517
2628
  * @param {TextureInfo|number} [texture] - Texture index or info to use
2518
2629
  * @param {number} [padding] - How many pixels padding around tiles
@@ -2805,6 +2916,11 @@ declare module "littlejsengine" {
2805
2916
  /** @property {WebGLProgram|undefined} - The 3D program, compiled by the 3D plugin the same way, read only
2806
2917
  * @type {WebGLProgram|undefined} */
2807
2918
  program3D: WebGLProgram | undefined;
2919
+ /** Let go of this shader: its compiled programs are freed and it leaves the engine's list of shaders, which
2920
+ * keeps every one made for a lost context, so a scene made again and again, or an editor trying snippets, does
2921
+ * not keep them all; calling it again does nothing, and a draw with it afterwards compiles it again and takes it
2922
+ * back, so only let go of one no object still draws with when it should stay freed */
2923
+ dispose(): void;
2808
2924
  }
2809
2925
  /**
2810
2926
  * LittleJS Drawing System
@@ -2915,10 +3031,10 @@ declare module "littlejsengine" {
2915
3031
  * @param {TileInfo} [tileInfo] - Tile info to use, untextured if undefined
2916
3032
  * @param {Color} [color=WHITE] - Color to modulate with
2917
3033
  * @param {number} [angle] - Angle to rotate by
2918
- * @param {boolean} [mirror] - Is image flipped along the Y axis?
3034
+ * @param {boolean} [mirror] - Is the image flipped left to right?
2919
3035
  * @param {Color} [additiveColor] - Additive color to be applied if any
2920
3036
  * @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering?
2921
- * @param {boolean} [screenSpace=drawScreenSpace] - Are the pos and size are in screen space?
3037
+ * @param {boolean} [screenSpace=drawScreenSpace] - Are the pos and size in screen space?
2922
3038
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
2923
3039
  * @memberof Draw */
2924
3040
  export function drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
@@ -2949,9 +3065,9 @@ declare module "littlejsengine" {
2949
3065
  * @param {Vector2} pos - Center of the rect in world space
2950
3066
  * @param {Vector2} size - Size of the rect in world space
2951
3067
  * @param {Vector2} wrapCount - How many times the texture repeats (x, y)
2952
- * @param {TextureInfo|number} [texture=0] - TextureInfo or texture index into textureInfos
3068
+ * @param {TextureInfo|number} [texture] - TextureInfo or texture index into textureInfos
2953
3069
  * @param {Color} [color=WHITE] - Color to modulate with
2954
- * @param {number} [angle=0] - Angle to rotate by
3070
+ * @param {number} [angle] - Angle to rotate by
2955
3071
  * @param {Color} [additiveColor] - Additive color to be applied if any
2956
3072
  * @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering?
2957
3073
  * @param {boolean} [screenSpace=drawScreenSpace] - Are pos and size in screen space?
@@ -3023,9 +3139,9 @@ declare module "littlejsengine" {
3023
3139
  export function drawEllipse(pos: Vector2, size?: Vector2, color?: Color, angle?: number, lineWidth?: number, lineColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
3024
3140
  /** Draw colored circle using passed in point
3025
3141
  * @param {Vector2} pos
3026
- * @param {number} [size=1] - Diameter
3142
+ * @param {number} [size] - Diameter
3027
3143
  * @param {Color} [color=WHITE]
3028
- * @param {number} [lineWidth=0]
3144
+ * @param {number} [lineWidth]
3029
3145
  * @param {Color} [lineColor=BLACK]
3030
3146
  * @param {boolean} [useWebGL=glEnable]
3031
3147
  * @param {boolean} [screenSpace=drawScreenSpace]
@@ -3051,7 +3167,7 @@ declare module "littlejsengine" {
3051
3167
  * - If drawing mostly textured sprites, bake the gradient into a texture and use drawTile instead
3052
3168
  * - Stacking gradients at the exact same position may show a faint vertical artifact
3053
3169
  * @param {Vector2} pos
3054
- * @param {number} [size=1] - Diameter
3170
+ * @param {number} [size] - Diameter
3055
3171
  * @param {Color} [colorInner=WHITE]
3056
3172
  * @param {Color} [colorOuter=CLEAR_WHITE]
3057
3173
  * @param {boolean} [useWebGL=glEnable]
@@ -3085,7 +3201,7 @@ declare module "littlejsengine" {
3085
3201
  * @param {Color} [color=WHITE]
3086
3202
  * @param {number} [lineWidth]
3087
3203
  * @param {Color} [lineColor=BLACK]
3088
- * @param {'left'|'center'|'right'} [textAlign='center']
3204
+ * @param {'left'|'center'|'right'} [textAlign]
3089
3205
  * @param {string} [font=fontDefault]
3090
3206
  * @param {string} [fontStyle]
3091
3207
  * @param {number} [maxWidth]
@@ -3120,7 +3236,7 @@ declare module "littlejsengine" {
3120
3236
  export function setShader(shader?: Shader): void;
3121
3237
  /** Set an extra canvas to composite behind the engine canvases when combining
3122
3238
  * Plugins that insert their own canvas below the LittleJS canvases should set
3123
- * this so it appears in screenshots and video capture
3239
+ * this so it appears in screenshots
3124
3240
  * @param {HTMLCanvasElement} [canvas]
3125
3241
  * @memberof Draw */
3126
3242
  export function setBackgroundCanvas(canvas?: HTMLCanvasElement): void;
@@ -3330,8 +3446,8 @@ declare module "littlejsengine" {
3330
3446
  * @param {number} [uv0Y]
3331
3447
  * @param {number} [uv1X]
3332
3448
  * @param {number} [uv1Y]
3333
- * @param {number} [rgba=-1] - white is -1
3334
- * @param {number} [rgbaAdditive=0] - black is 0
3449
+ * @param {number} [rgba] - white is -1
3450
+ * @param {number} [rgbaAdditive] - black is 0
3335
3451
  * @memberof WebGL */
3336
3452
  export function glDraw(x: number, y: number, sizeX: number, sizeY: number, angle?: number, uv0X?: number, uv0Y?: number, uv1X?: number, uv1Y?: number, rgba?: number, rgbaAdditive?: number): void;
3337
3453
  /** Add an untextured rect to the gl draw list
@@ -3433,19 +3549,16 @@ declare module "littlejsengine" {
3433
3549
  * @memberof Input */
3434
3550
  export function inputClearKey(key: string | number, device?: number, clearDown?: boolean, clearPressed?: boolean, clearReleased?: boolean): void;
3435
3551
  /** Returns true if mouse button is down
3436
- * @function
3437
3552
  * @param {number} button
3438
3553
  * @return {boolean}
3439
3554
  * @memberof Input */
3440
3555
  export function mouseIsDown(button: number): boolean;
3441
3556
  /** Returns true if mouse button was pressed
3442
- * @function
3443
3557
  * @param {number} button
3444
3558
  * @return {boolean}
3445
3559
  * @memberof Input */
3446
3560
  export function mouseWasPressed(button: number): boolean;
3447
3561
  /** Returns true if mouse button was released
3448
- * @function
3449
3562
  * @param {number} button
3450
3563
  * @return {boolean}
3451
3564
  * @memberof Input */
@@ -3647,7 +3760,6 @@ declare module "littlejsengine" {
3647
3760
  * - The output node is disconnected from everything else first, so it only feeds the speakers
3648
3761
  * - The two ends of a chain must already be connected to each other, like effectA.connect(effectB)
3649
3762
  * - Call with no arguments to remove the effect, an effect that was the master goes back to feeding the master gain
3650
- * - Debug video capture records the end of the master chain, but loses its tap if the effect changes mid-capture
3651
3763
  * @param {AudioNode|AudioEffectNodes} [input] - Node or effect the master gain connects to
3652
3764
  * @param {AudioNode|AudioEffectNodes} [output] - Node or effect that connects to the audio destination, defaults to the input's output
3653
3765
  * @memberof Audio */
@@ -3661,7 +3773,7 @@ declare module "littlejsengine" {
3661
3773
  * @memberof Audio */
3662
3774
  export function audioIsRunning(): boolean;
3663
3775
  /**
3664
- * @callback SoundLoadCallback - Function called when sound is loaded
3776
+ * @callback SoundLoadCallback - Function called once a sound has loaded, or failed to, which sound.isLoaded() tells
3665
3777
  * @param {Sound} sound
3666
3778
  * @memberof Audio
3667
3779
  */
@@ -3686,13 +3798,14 @@ declare module "littlejsengine" {
3686
3798
  */
3687
3799
  export class Sound {
3688
3800
  /** Create a sound object and cache the audio for later use
3689
- * @param {string|URL|Array} [asset] - Filename or URL of an audio file, or a zzfx array
3801
+ * @param {string|URL|Array<number|undefined>} [asset] - Filename or URL of an audio file, or a zzfx array
3690
3802
  * @param {number} [randomness] - How much to randomize frequency each time sound plays, for zzfx sounds it overrides the array's own randomness, which is used if undefined
3691
3803
  * @param {number} [range=soundDefaultRange] - World space max range of sound
3692
3804
  * @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
3693
- * @param {SoundLoadCallback} [onloadCallback] - callback function to call when sound is loaded
3805
+ * @param {SoundLoadCallback} [onloadCallback] - Called once the sound has loaded, or its file failed to, so a
3806
+ * game counting its sounds goes on; isLoaded says which
3694
3807
  */
3695
- constructor(asset?: string | any[] | URL, randomness?: number, range?: number, taper?: number, onloadCallback?: SoundLoadCallback);
3808
+ constructor(asset?: string | URL | (number | undefined)[], randomness?: number, range?: number, taper?: number, onloadCallback?: SoundLoadCallback);
3696
3809
  loadedPercent: number;
3697
3810
  set range(arg: number);
3698
3811
  /** World space max range of sound, 0 for no limit; a range that is set is the sound's own, in 3D too
@@ -3780,7 +3893,7 @@ declare module "littlejsengine" {
3780
3893
  * @return {boolean} - True if sound is loaded and ready to play
3781
3894
  */
3782
3895
  isLoaded(): boolean;
3783
- /** Loads a sound from a URL and decodes it into sample data.
3896
+ /** Loads a sound from a URL and decodes it into sample data
3784
3897
  * @param {string} filename
3785
3898
  * @return {Promise} */
3786
3899
  loadSound(filename: string): Promise<any>;
@@ -3812,11 +3925,11 @@ declare module "littlejsengine" {
3812
3925
  /** @property {Sound} - The sound object */
3813
3926
  sound: Sound;
3814
3927
  /** @property {number} - How much to scale volume by */
3815
- volume: number;
3928
+ volume: any;
3816
3929
  /** @property {number} - The playback rate to use */
3817
- rate: number;
3930
+ rate: any;
3818
3931
  /** @property {number} - How much to apply stereo panning */
3819
- pan: number;
3932
+ pan: any;
3820
3933
  /** @property {boolean} - Should the sound loop */
3821
3934
  loop: boolean;
3822
3935
  /** @property {number|undefined} - Where it is in the sound while not playing, in the sound's own seconds, undefined while playing
@@ -3923,7 +4036,7 @@ declare module "littlejsengine" {
3923
4036
  * @param {number} [rate] - The playback rate to use
3924
4037
  * @param {number} [pan] - How much to apply stereo panning
3925
4038
  * @param {boolean} [loop] - True if the sound should loop when it reaches the end
3926
- * @param {number} [sampleRate=44100] - Sample rate for the sound
4039
+ * @param {number} [sampleRate=audioDefaultSampleRate] - Sample rate for the sound
3927
4040
  * @param {GainNode} [gainNode] - Optional gain node for volume control while playing (disconnected when the sound ends)
3928
4041
  * @param {number} [offset] - Where to start in the sound, in its own seconds whatever the rate
3929
4042
  * @param {AudioEndedCallback} [onended] - Callback for when the sound ends
@@ -3949,7 +4062,7 @@ declare module "littlejsengine" {
3949
4062
  export function playAudioBuffer(buffer: AudioBuffer, volume?: number, rate?: number, pan?: number, loop?: boolean, gainNode?: GainNode, offset?: number, onended?: AudioEndedCallback, output?: AudioNode | AudioEffectNodes, pannerNode?: StereoPannerNode): AudioBufferSourceNode | undefined;
3950
4063
  /** Copy arrays of samples into a new audio buffer
3951
4064
  * @param {Array} sampleChannels - Array of arrays of samples (for stereo playback)
3952
- * @param {number} [sampleRate=44100] - Sample rate for the sound
4065
+ * @param {number} [sampleRate=audioDefaultSampleRate] - Sample rate for the sound
3953
4066
  * @return {AudioBuffer} - The audio buffer holding the samples
3954
4067
  * @memberof Audio */
3955
4068
  export function createAudioBuffer(sampleChannels: any[], sampleRate?: number): AudioBuffer;
@@ -3969,8 +4082,8 @@ declare module "littlejsengine" {
3969
4082
  * @param {number} [release] - Release time, how fast sound fades out (seconds)
3970
4083
  * @param {number} [shape] - Shape of the sound wave
3971
4084
  * @param {number} [shapeCurve] - Squareness of wave (0=square, 1=normal, 2=pointy)
3972
- * @param {number} [slide] - How much to slide frequency (kHz/s)
3973
- * @param {number} [deltaSlide] - How much to change slide (kHz/s/s)
4085
+ * @param {number} [slide] - How much to slide frequency, 1 is about 500 Hz a second, as ZzFX has it
4086
+ * @param {number} [deltaSlide] - How much to change slide each second, in the units of slide
3974
4087
  * @param {number} [pitchJump] - Frequency of pitch jump (Hz)
3975
4088
  * @param {number} [pitchJumpTime] - Time of pitch jump (seconds)
3976
4089
  * @param {number} [repeatTime] - Resets some parameters periodically (seconds)
@@ -3981,7 +4094,8 @@ declare module "littlejsengine" {
3981
4094
  * @param {number} [sustainVolume] - Volume level for sustain (percent)
3982
4095
  * @param {number} [decay] - Decay time, how long to reach sustain after attack (seconds)
3983
4096
  * @param {number} [tremolo] - Trembling effect, rate controlled by repeat time (percent)
3984
- * @param {number} [filter] - Filter cutoff frequency, positive for HPF, negative for LPF (Hz)
4097
+ * @param {number} [filter] - Filter cutoff, positive for HPF, negative for LPF; the cutoff is about twice this in
4098
+ * Hz, as ZzFX has it, and its resonance can take the samples past 1
3985
4099
  * @return {Float32Array} - The audio samples
3986
4100
  * @memberof Audio */
3987
4101
  export function zzfxG(volume?: number, randomness?: number, frequency?: number, attack?: number, sustain?: number, release?: number, shape?: number, shapeCurve?: number, slide?: number, deltaSlide?: number, pitchJump?: number, pitchJumpTime?: number, repeatTime?: number, noise?: number, modulation?: number, bitCrush?: number, delay?: number, sustainVolume?: number, decay?: number, tremolo?: number, filter?: number): Float32Array;
@@ -4054,6 +4168,9 @@ declare module "littlejsengine" {
4054
4168
  shader: Shader | undefined;
4055
4169
  /** @property {boolean} - Does this object draw into the light system's shadow map; false for a floor layer, a background, a pickup */
4056
4170
  castShadow: boolean;
4171
+ /** @property {boolean} - Does this object draw into the light system's background map, which a
4172
+ * DirectionalLight lights only at its edges facing the light; for a background layer, with castShadow false */
4173
+ castBackgroundShadow: boolean;
4057
4174
  /** @property {number} - With the light system, how much it lights itself: 0 lit only by the lights, 1 full
4058
4175
  * brightness in its own colors whatever the lights do, between partly; drawn into the lightmap through
4059
4176
  * renderEmissive, as 3D's emissive. Exact for solid pixels; a partly transparent one is self lit by its alpha
@@ -4117,15 +4234,19 @@ declare module "littlejsengine" {
4117
4234
  /** Update the object transform, called automatically by engine even when paused
4118
4235
  * @param {boolean} [updateChildren] - Also update the children's transforms */
4119
4236
  updateTransforms(updateChildren?: boolean): void;
4120
- /** Update the object physics, called automatically by engine once each frame. Can be overridden to stop or change how physics works for an object. */
4237
+ /** Update the object physics, called automatically by engine once each frame. Can be overridden to stop or change how physics works for an object
4238
+ * - With many solids each mover finds those near it through a grid, which follows a solid after its own physics
4239
+ * update: a solid an override moves for another object, a lift carrying a crate, is found there from the next
4240
+ * update on */
4121
4241
  updatePhysics(): void;
4122
- /** Update the object, called automatically by engine once each frame. Does nothing by default. */
4242
+ /** Update the object, called automatically by engine once each frame. Does nothing by default */
4123
4243
  update(): void;
4124
4244
  /** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
4125
4245
  render(): void;
4126
- /** Optional hook called during the light system plugin's lightmap pass to draw this object's lightmap contribution. Does nothing by default. */
4246
+ /** Optional hook called during the light system plugin's lightmap pass to draw this object's lightmap contribution. Does nothing by default */
4127
4247
  renderLight(): void;
4128
- /** Draw this object into the light system's shadow map, called during its shadow pass when castShadow is set.
4248
+ /** Draw this object into the light system's shadow map, called during its shadow pass when castShadow is set, and into
4249
+ * its background map when castBackgroundShadow is set and a DirectionalLight is out.
4129
4250
  * Calls render() by default so the object casts its own shape; override to cast a different one, like a blob at a character's feet so its body stays lit;
4130
4251
  * screen space WebGL draws in render() are skipped during the pass */
4131
4252
  renderShadow(): void;
@@ -4137,30 +4258,38 @@ declare module "littlejsengine" {
4137
4258
  * @param {boolean} [immediate] - true removes attached effects like particle emitters at once, false lets them finish first */
4138
4259
  destroy(immediate?: boolean): void;
4139
4260
  /** Convert from local space to world space
4140
- * @param {Vector2} pos - local space point */
4261
+ * @param {Vector2} pos - local space point
4262
+ * @return {Vector2} */
4141
4263
  localToWorld(pos: Vector2): Vector2;
4142
4264
  /** Convert from world space to local space
4143
- * @param {Vector2} pos - world space point */
4265
+ * @param {Vector2} pos - world space point
4266
+ * @return {Vector2} */
4144
4267
  worldToLocal(pos: Vector2): Vector2;
4145
4268
  /** Convert from local space to world space for a vector (rotation only)
4146
- * @param {Vector2} vec - local space vector */
4269
+ * @param {Vector2} vec - local space vector
4270
+ * @return {Vector2} */
4147
4271
  localToWorldVector(vec: Vector2): Vector2;
4148
4272
  /** Convert from world space to local space for a vector (rotation only)
4149
- * @param {Vector2} vec - world space vector */
4273
+ * @param {Vector2} vec - world space vector
4274
+ * @return {Vector2} */
4150
4275
  worldToLocalVector(vec: Vector2): Vector2;
4151
- /** Called to check if a tile collision should be resolved. Return true for physics to resolve the collision or false to ignore and resolve it manually.
4276
+ /** Called to check if a tile collision should be resolved. Return true for physics to resolve the collision or false to ignore and resolve it manually
4152
4277
  * - Called for each solid tile the physics tests, which can be several times a frame for the same tile, and for
4153
4278
  * positions it only tries, so keep it free of side effects or guard them to once a frame
4154
4279
  * - this.pos has already moved, so a check on where it came from, like a one way platform, needs the position
4155
4280
  * saved in update, as the platformer example does
4281
+ * - For the point of impact, like sparks where a bullet hit, raycast from where this frame's move started,
4282
+ * this.pos minus this.velocity, to this.pos with tileCollisionRaycast, as the platformer's Bullet does
4156
4283
  * @param {number} tileData - the value of the tile at the position
4157
4284
  * @param {Vector2} pos - the tile's bottom left corner in world space
4158
4285
  * @return {boolean} - true if the collision should be resolved by modifying it's position and velocity */
4159
4286
  collideWithTile(tileData: number, pos: Vector2): boolean;
4160
- /** Called by the engine to check if an object collision should be resolved. Return true for physics to resolve the collision or false to ignore and resolve it manually.
4287
+ /** Called by the engine to check if an object collision should be resolved. Return true for physics to resolve the collision or false to ignore and resolve it manually
4161
4288
  * - Both objects of a touching pair are asked once a frame, whichever order they update in; an object that
4162
4289
  * destroys itself here is gone at the end of the frame and is still asked about the pairs left this frame, so a
4163
4290
  * bullet that should hit one thing checks its own destroyed flag first
4291
+ * - With many solids each mover finds those near it through a grid, which follows the other object after this
4292
+ * returns; a third object moved here is found where it is now from the next update on
4164
4293
  * @param {EngineObject} object - the object to test against
4165
4294
  * @param {Vector3} [push] - what it would take to move this object clear, a Vector3 from the 3D plugin, undefined in 2D
4166
4295
  * @return {boolean} - true if the collision should be resolved by modifying it's position and velocity
@@ -4224,10 +4353,6 @@ declare module "littlejsengine" {
4224
4353
  * @param {boolean} [collideLevel] - Does it collide with the level, its tile collision layers?
4225
4354
  * @param {boolean} [collideRaycast] - Does it collide with raycasts? */
4226
4355
  setCollision(collideSolidObjects?: boolean, isSolid?: boolean, collideLevel?: boolean, collideRaycast?: boolean): void;
4227
- set collideTiles(arg: boolean);
4228
- /** @deprecated since 1.20, use collideLevel
4229
- * @type {boolean} */
4230
- get collideTiles(): boolean;
4231
4356
  /** Returns string containing info about this object for debugging
4232
4357
  * @return {string} */
4233
4358
  toString(): string;
@@ -4243,9 +4368,30 @@ declare module "littlejsengine" {
4243
4368
  * - TileLayer for rendering, TileCollisionLayer for physics
4244
4369
  * - Collision callbacks for tile interactions with objects
4245
4370
  * - Optimized raycast support for tile-based physics
4246
- * - Integration with Box2D physics via Box2DTileLayer plugin
4371
+ * - Integration with Box2D physics via the Box2dTileLayer plugin
4247
4372
  * @namespace TileLayers
4248
4373
  */
4374
+ /** A Tiled map as Tiled saves it as JSON, what tileLayersLoad and objectLayersLoad take and tileLayersFromLDtk
4375
+ * makes; the fields read are listed, and the rest of the file is kept as it is
4376
+ * @typedef {Object} TiledMap
4377
+ * @property {number} width - Cells across
4378
+ * @property {number} height - Cells up
4379
+ * @property {number} [tilewidth] - A tile's width in pixels
4380
+ * @property {number} [tileheight] - A tile's height in pixels
4381
+ * @property {Array<Object>} layers - Tile layers, object layers and groups of them, bottom first
4382
+ * @property {Array<Object>} [tilesets] - The first one's margin, spacing and columns are read
4383
+ * @property {number} [nextlayerid]
4384
+ * @property {number} [nextobjectid]
4385
+ * @property {string} [orientation]
4386
+ * @property {string} [renderorder]
4387
+ * @property {boolean} [infinite]
4388
+ * @property {string} [type]
4389
+ * @property {string|number} [version] - A number in files from Tiled before 1.6
4390
+ * @property {string} [tiledversion]
4391
+ * @property {number} [compressionlevel]
4392
+ * @property {string} [backgroundcolor]
4393
+ * @property {Array<Object>} [properties]
4394
+ * @memberof TileLayers */
4249
4395
  /** Keep track of all tile layers with collision
4250
4396
  * @type {Array<TileCollisionLayer>}
4251
4397
  * @memberof TileLayers */
@@ -4277,7 +4423,7 @@ declare module "littlejsengine" {
4277
4423
  * @param {Vector2} posEnd
4278
4424
  * @param {EngineObject|TileCollisionCallback} [callbackObject] - Callback, engine object, or undefined
4279
4425
  * @param {Vector2} [normal] - Optional normal of the surface hit
4280
- * @param {boolean} [solidOnly=true] - Only check solid layers?
4426
+ * @param {boolean} [solidOnly] - Only check solid layers?
4281
4427
  * @return {Vector2|undefined} - where the ray meets the first tile hit, nudged just inside it, or undefined if no hit
4282
4428
  * @memberof TileLayers */
4283
4429
  export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, callbackObject?: EngineObject | TileCollisionCallback, normal?: Vector2, solidOnly?: boolean): Vector2 | undefined;
@@ -4295,7 +4441,7 @@ declare module "littlejsengine" {
4295
4441
  * - An object or image layer keeps its index, with its slot in the returned array left empty
4296
4442
  * - A hidden layer (visible false) is loaded, its collision included, but not drawn; its render
4297
4443
  * is a no-op, delete that and call redraw() to show it
4298
- * @param {Object} tileMapData - Level data from exported data
4444
+ * @param {TiledMap} [tileMapData] - Level data from exported data, a 50 by 50 empty level when left out
4299
4445
  * @param {TileInfo} [tileInfo] - Default tile info (used for size and texture), tile() by default, none when no image is loaded
4300
4446
  * @param {number} [renderOrder] - Render order of the top layer
4301
4447
  * @param {number|string} [collisionLayer] - Layer to use for collision if any, by its index or its name
@@ -4303,7 +4449,7 @@ declare module "littlejsengine" {
4303
4449
  * @return {Array<TileCollisionLayer>} - It throws for a map that is not whole cells, or a layer whose tiles do not
4304
4450
  * fill it, before it makes any layer
4305
4451
  * @memberof TileLayers */
4306
- export function tileLayersLoad(tileMapData: any, tileInfo?: TileInfo, renderOrder?: number, collisionLayer?: string | number, draw?: boolean): Array<TileCollisionLayer>;
4452
+ export function tileLayersLoad(tileMapData?: TiledMap, tileInfo?: TileInfo, renderOrder?: number, collisionLayer?: string | number, draw?: boolean): Array<TileCollisionLayer>;
4307
4453
  /**
4308
4454
  * Make a Tiled map of a level of an LDtk project, to load with tileLayersLoad and objectLayersLoad
4309
4455
  * - Each Tiles, AutoLayer and IntGrid layer is a tile layer, the bottom one first as in Tiled; where LDtk stacks
@@ -4324,13 +4470,13 @@ declare module "littlejsengine" {
4324
4470
  * - The level editor edits the map this returns, and saves it as a Tiled map
4325
4471
  * @param {Object} ldtk - The LDtk project, its JSON
4326
4472
  * @param {number|string} [level] - Which level, by its index or its identifier
4327
- * @return {Object} - A Tiled map: width, height, tilewidth, tileheight, tilesets and layers
4473
+ * @return {TiledMap} - A Tiled map: width, height, tilewidth, tileheight, tilesets and layers
4328
4474
  * @example
4329
4475
  * const map = tileLayersFromLDtk(await fetchJSON('world.ldtk'), 'Level_0');
4330
4476
  * const layers = tileLayersLoad(map, tile(0, 16), 0, 'Collisions'); // its IntGrid layer is solid
4331
4477
  * objectLayersLoad(map);
4332
4478
  * @memberof TileLayers */
4333
- export function tileLayersFromLDtk(ldtk: any, level?: string | number): any;
4479
+ export function tileLayersFromLDtk(ldtk: any, level?: string | number): TiledMap;
4334
4480
  /** Add a type of object, so objectLayersLoad makes one wherever a map's object layer has an object of that type
4335
4481
  * - The name is the object's type in Tiled (its class in Tiled 1.9); it is a string because minified builds
4336
4482
  * rename classes
@@ -4340,13 +4486,15 @@ declare module "littlejsengine" {
4340
4486
  * - Adding a name again replaces it
4341
4487
  * @param {string} name - The type the objects have in Tiled
4342
4488
  * @param {Function} make - A class made at each object's position, or a function called with it
4343
- * @param {Object} [defaults] - Properties set on each one made, the level editor shows inputs for them
4489
+ * @param {Object<string, any>} [defaults] - Properties set on each one made, the level editor shows inputs for them
4344
4490
  * @param {TileInfo} [tileInfo] - An icon for the level editor
4345
4491
  * @memberof TileLayers
4346
4492
  * @example
4347
4493
  * objectLayersAddType('Coin', Coin, {value: 1}, tile(5, 16));
4348
4494
  * objectLayersAddType('PlayerStart', (pos)=> playerStartPos = pos); */
4349
- export function objectLayersAddType(name: string, make: Function, defaults?: any, tileInfo?: TileInfo): void;
4495
+ export function objectLayersAddType(name: string, make: Function, defaults?: {
4496
+ [x: string]: any;
4497
+ }, tileInfo?: TileInfo): void;
4350
4498
  /** Make the objects in a map's object layers, each from the type added for its name with objectLayersAddType
4351
4499
  * - An object is made at its position, the world y up as tileLayersLoad places the layers; layer offsets are
4352
4500
  * not read, and a shape or tile object is made at its position too
@@ -4354,10 +4502,10 @@ declare module "littlejsengine" {
4354
4502
  * - The object's properties in Tiled are set over the type's defaults: numbers, booleans, strings, and colors,
4355
4503
  * and for a Vector2 default the string x,y
4356
4504
  * - An object whose type was not added is skipped, with a warning in debug builds
4357
- * @param {Object} tileMapData - The same Tiled map given to tileLayersLoad
4505
+ * @param {TiledMap} tileMapData - The same Tiled map given to tileLayersLoad
4358
4506
  * @return {Array<any>} - What each object's type made, a function that made nothing is left out
4359
4507
  * @memberof TileLayers */
4360
- export function objectLayersLoad(tileMapData: any): Array<any>;
4508
+ export function objectLayersLoad(tileMapData: TiledMap): Array<any>;
4361
4509
  /**
4362
4510
  * Tile layer data object stores info about how to draw a tile
4363
4511
  * @memberof TileLayers
@@ -4373,7 +4521,7 @@ declare module "littlejsengine" {
4373
4521
  /** Create a tile layer data object, one for each tile in a TileLayer
4374
4522
  * @param {number} [tile] - The tile to use, from 0 like tile(); undefined is an empty cell that draws nothing
4375
4523
  * @param {number} [direction] - Integer direction of tile, in 90 degree increments
4376
- * @param {boolean} [mirror] - If the tile should be mirrored along the x axis
4524
+ * @param {boolean} [mirror] - If the tile is flipped left to right
4377
4525
  * @param {Color} [color] - Color of the tile */
4378
4526
  constructor(tile?: number, direction?: number, mirror?: boolean, color?: Color);
4379
4527
  /** @property {number|undefined} - The tile to use, from 0 like tile(); undefined is an empty cell that draws nothing
@@ -4381,7 +4529,7 @@ declare module "littlejsengine" {
4381
4529
  tile: number | undefined;
4382
4530
  /** @property {number} - Integer direction of tile, in 90 degree increments */
4383
4531
  direction: number;
4384
- /** @property {boolean} - If the tile should be mirrored along the x axis */
4532
+ /** @property {boolean} - If the tile is flipped left to right */
4385
4533
  mirror: boolean;
4386
4534
  /** @property {Color} - Color of the tile */
4387
4535
  color: Color;
@@ -4421,7 +4569,7 @@ declare module "littlejsengine" {
4421
4569
  * @param {Vector2} [size] - Size in world space
4422
4570
  * @param {Color} [color] - Color to modulate with
4423
4571
  * @param {number} [angle] - Angle to rotate by
4424
- * @param {boolean} [mirror] - If true image is flipped along the Y axis
4572
+ * @param {boolean} [mirror] - If true the image is flipped left to right
4425
4573
  * @param {Color} [additiveColor] - Additive color to be applied if any
4426
4574
  * @param {boolean} [screenSpace=drawScreenSpace] - If true the pos and size are in screen space
4427
4575
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to */
@@ -4489,7 +4637,7 @@ declare module "littlejsengine" {
4489
4637
  * @param {TileInfo} [tileInfo] - Tile info to use, untextured if undefined
4490
4638
  * @param {Color} [color=WHITE] - Color to modulate with
4491
4639
  * @param {number} [angle] - Angle to rotate by
4492
- * @param {boolean} [mirror] - Is image flipped along the Y axis?
4640
+ * @param {boolean} [mirror] - Is the image flipped left to right?
4493
4641
  * @param {Color} [additiveColor] - Additive color to be applied if any */
4494
4642
  drawLayerTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color): void;
4495
4643
  /** Draw a rectangle in layer space
@@ -4616,13 +4764,13 @@ declare module "littlejsengine" {
4616
4764
  * let pos = vec2(2,3);
4617
4765
  * let particleEmitter = new ParticleEmitter
4618
4766
  * (
4619
- * pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emitCone
4767
+ * pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emitConeAngle
4620
4768
  * tile(0, 16), // tileInfo
4621
4769
  * rgb(1,1,1,1), rgb(0,0,0,1), // colorStartA, colorStartB
4622
4770
  * rgb(1,1,1,0), rgb(0,0,0,0), // colorEndA, colorEndB
4623
- * 1, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
4624
- * .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate
4625
- * .5, true // randomness, collide
4771
+ * 1, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, speed, angleSpeed
4772
+ * .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleConeAngle, fadeRate
4773
+ * .5, true // randomness, collideLevel
4626
4774
  * );
4627
4775
  */
4628
4776
  export class ParticleEmitter extends EngineObject {
@@ -4645,7 +4793,7 @@ declare module "littlejsengine" {
4645
4793
  * @param {number} [angleSpeed] - How fast are particles rotating, in radians per frame (at 60fps)
4646
4794
  * @param {number} [damping] - How much to dampen particle speed, per-frame velocity multiplier (1 = no damping, .9 = lose 10% speed each frame)
4647
4795
  * @param {number} [angleDamping] - How much to dampen particle angular speed, per-frame multiplier (1 = no damping)
4648
- * @param {number} [gravityScale] - How much gravity effect particles
4796
+ * @param {number} [gravityScale] - How much gravity affects particles
4649
4797
  * @param {number} [particleConeAngle] - Half angle each side of the emitter's angle for a particle's start angle, PI is any angle
4650
4798
  * @param {number} [fadeRate] - Fraction of life spent fading: half at fade-in (start), half at fade-out (end). e.g. .2 = 10% fade-in, 80% full opacity, 10% fade-out
4651
4799
  * @param {number} [randomness] - Apply extra randomness percent
@@ -4660,7 +4808,8 @@ declare module "littlejsengine" {
4660
4808
  emitCircle: boolean;
4661
4809
  /** @property {Vector2} - World space size of the emitter, x is the diameter when emitCircle is set */
4662
4810
  emitSize: Vector2;
4663
- /** @property {number} - How long to stay alive (0 is forever) */
4811
+ /** @property {number} - How long to emit for in seconds, 0 is forever; raised while its particles are still
4812
+ * alive, it emits again for the added time */
4664
4813
  emitTime: number;
4665
4814
  /** @property {number} - How many particles per second to spawn, does not emit if 0 */
4666
4815
  emitRate: number;
@@ -4721,16 +4870,22 @@ declare module "littlejsengine" {
4721
4870
  velocityInheritance: number;
4722
4871
  /** @property {number} - Particles owed to the emit rate, starts at one so the first comes out at once */
4723
4872
  emitTimeBuffer: number;
4873
+ /** @property {number} - Seconds of its emit time it has emitted for, counted by its updates
4874
+ * @type {number} */
4875
+ emitElapsed: number;
4724
4876
  /** @property {Array<Particle>} - Array of particles for this emitter
4725
4877
  * @type {Array<Particle>} */
4726
4878
  particles: Array<Particle>;
4727
4879
  /** @type {Vector2|undefined} */
4728
4880
  previousPos: Vector2 | undefined;
4729
4881
  previousAngle: number;
4882
+ emitFrom: Vector2;
4883
+ emitBehind: number;
4730
4884
  /** Spawn one particle
4731
4885
  * @return {Particle} */
4732
4886
  emitParticle(): Particle;
4733
- /** is emitter actively spawning */
4887
+ /** is emitter actively spawning
4888
+ * @return {boolean} */
4734
4889
  isActive(): boolean;
4735
4890
  }
4736
4891
  /**
@@ -4829,6 +4984,7 @@ declare module "littlejsengine" {
4829
4984
  * - Call this after creating all medals
4830
4985
  * - Loads which medals are unlocked from the save, and writes the catalog back
4831
4986
  * - A medal a service like Newgrounds holds is left as it is, see Medal.isLocal
4987
+ * - A medal unlocked before the first call stays unlocked and is saved by it
4832
4988
  * @param {string} saveName - The localStorage key the medals are kept under, a different one from the game's own
4833
4989
  * readSaveData and writeSaveData, or each would overwrite the other
4834
4990
  * @memberof Medals */
@@ -4960,10 +5116,12 @@ declare module "littlejsengine" {
4960
5116
  cryptoKey: CryptoKey | undefined;
4961
5117
  /** @property {string} - Hostname sent with the view the plugin logs when it starts */
4962
5118
  host: string;
4963
- /** @property {Array} - Medals fetched from Newgrounds, empty until ready, with the unlocks only when logged in */
4964
- medals: any[];
4965
- /** @property {Array} - Scoreboards fetched from Newgrounds, empty until ready */
4966
- scoreboards: any[];
5119
+ /** @property {Array<Object>} - Medals fetched from Newgrounds, empty until ready, with the unlocks only when logged in
5120
+ * @type {Array<Object>} */
5121
+ medals: Array<any>;
5122
+ /** @property {Array<Object>} - Scoreboards fetched from Newgrounds, empty until ready
5123
+ * @type {Array<Object>} */
5124
+ scoreboards: Array<any>;
4967
5125
  /** @property {{id: number, name: string, url: string, supporter: boolean}|null} - The logged in player once ready, null when not logged in
4968
5126
  * @type {{id: number, name: string, url: string, supporter: boolean}|null} */
4969
5127
  user: {
@@ -4980,8 +5138,6 @@ declare module "littlejsengine" {
4980
5138
  session_id: string | null;
4981
5139
  /** @property {Promise<NewgroundsPlugin>} - Resolves once the session is checked and the lists are in, empty if the server could not be reached */
4982
5140
  ready: Promise<this>;
4983
- /** @deprecated since 1.20, the view is logged when the plugin starts, so this does nothing */
4984
- logView(): void;
4985
5141
  /** Log the view, check the session, fetch the medals and scoreboards, then keep the session alive; the constructor runs it once
4986
5142
  * @private */
4987
5143
  private init;
@@ -5041,6 +5197,123 @@ declare module "littlejsengine" {
5041
5197
  * @type {number|undefined} */
5042
5198
  value: number | undefined;
5043
5199
  }
5200
+ /**
5201
+ * LittleJS Wavedash Plugin
5202
+ * - The Wavedash twin of the Newgrounds plugin: achievements and leaderboards, the same shape so a game can switch
5203
+ * - Wavedash serves the game's page and puts its SDK in window.Wavedash before the game runs, so nothing is bundled;
5204
+ * off Wavedash (local, itch, GitHub Pages) there is none, and every call does nothing
5205
+ * - Make the plugin when the game can draw, at the end of gameInit: Wavedash.init is called then, and until it is
5206
+ * Wavedash keeps its loading screen over the game
5207
+ * - WavedashMedal is a Medal with the identifier of its Wavedash achievement; on Wavedash an unlock is sent as that
5208
+ * achievement and Wavedash shows its own toast in place of the engine's popup, off it the medal unlocks as any does
5209
+ * - Wavedash refuses an achievement until it has loaded the player's, a moment after launch, so refused and earlier
5210
+ * unlocks are sent again every two seconds until it takes them; medals unlocked before, in the save, are sent too
5211
+ * - Leaderboards are made from code: give the plugin a table of them, each with how it sorts and shows its scores,
5212
+ * and they are made at once, so each one exists from the first launch
5213
+ * - The SDK checks its arguments' types and throws on a wrong one, so every call passes real booleans and whole
5214
+ * numbers and is caught; a game built with its own minifier keeps the SDK's names, see REFERENCE
5215
+ * @namespace Wavedash
5216
+ */
5217
+ /** Global Wavedash plugin object
5218
+ * @type {WavedashPlugin}
5219
+ * @memberof Wavedash */
5220
+ export let wavedash: WavedashPlugin;
5221
+ /**
5222
+ * Wavedash plugin: starts the Wavedash SDK, sends achievements and posts and reads leaderboards
5223
+ * @memberof Wavedash
5224
+ * @example
5225
+ * // at the end of gameInit, with the leaderboards the game posts to
5226
+ * new WavedashPlugin({LEVEL_1: {lowerWins: true, display: 'milliseconds'}, HIGH_SCORE: {}});
5227
+ * wavedash.postScore('LEVEL_1', timeMs);
5228
+ */
5229
+ export class WavedashPlugin {
5230
+ /** Start the Wavedash SDK when the game is on Wavedash, and make its leaderboards
5231
+ * @param {Object<string, {lowerWins?: boolean, display?: string}>} [leaderboards] - The game's leaderboards by
5232
+ * name: lowerWins for times and golf, where a lower score is better, higher wins when left out; display how
5233
+ * Wavedash shows a score, 'number', 'seconds', 'milliseconds' or 'ticks' (60 a second), 'number' when left out
5234
+ */
5235
+ constructor(leaderboards?: {
5236
+ [x: string]: {
5237
+ lowerWins?: boolean;
5238
+ display?: string;
5239
+ };
5240
+ });
5241
+ /** @property {Object<string, Promise<string|undefined>>} - Each leaderboard's id by its name, once Wavedash
5242
+ * has made or found it, undefined when it could not
5243
+ * @type {Object<string, Promise<string|undefined>>} */
5244
+ leaderboards: {
5245
+ [x: string]: Promise<string | undefined>;
5246
+ };
5247
+ /** @type {Object<string, {lowerWins?: boolean, display?: string}>} */
5248
+ leaderboardSettings: {
5249
+ [x: string]: {
5250
+ lowerWins?: boolean;
5251
+ display?: string;
5252
+ };
5253
+ };
5254
+ /** @type {Set<string>} */
5255
+ achievementsSent: Set<string>;
5256
+ /** @type {Object<string, number>} */
5257
+ achievementTries: {
5258
+ [x: string]: number;
5259
+ };
5260
+ /** @type {number|undefined} */
5261
+ achievementRetry: number | undefined;
5262
+ /** Whether the game is on Wavedash, its SDK on the page
5263
+ * @return {boolean} */
5264
+ isActive(): boolean;
5265
+ /** Call the SDK, undefined off Wavedash; a call that throws, as on an argument of the wrong type, says so in
5266
+ * the console and gives undefined
5267
+ * @param {string} name - The SDK function
5268
+ * @param {...*} args
5269
+ * @return {*}
5270
+ * @ignore */
5271
+ call(name: string, ...args: any[]): any;
5272
+ /** A leaderboard's id by its name, made on Wavedash the first time it is asked for, with the settings it was given
5273
+ * @param {string} name
5274
+ * @return {Promise<string|undefined>}
5275
+ * @ignore */
5276
+ leaderboard(name: string): Promise<string | undefined>;
5277
+ /** Post a score to a leaderboard, Wavedash keeping the player's best; off Wavedash it does nothing
5278
+ * - A leaderboard not in the table given to the plugin is made the first time, higher wins and shown as a number
5279
+ * @param {string} name - The leaderboard's name
5280
+ * @param {number} score - A whole number, milliseconds for a time
5281
+ * @return {Promise<boolean>} - Whether it was posted */
5282
+ postScore(name: string, score: number): Promise<boolean>;
5283
+ /** Read a leaderboard's entries, undefined off Wavedash or when it could not be read
5284
+ * @param {string} name - The leaderboard's name
5285
+ * @param {number} [offset] - How many entries to skip over
5286
+ * @param {number} [limit] - How many entries to read
5287
+ * @param {boolean} [friendsOnly] - Only the player and their friends
5288
+ * @return {Promise<Array<Object>|undefined>} - The entries, as Wavedash gives them */
5289
+ getScores(name: string, offset?: number, limit?: number, friendsOnly?: boolean): Promise<Array<any> | undefined>;
5290
+ /** Send every unlocked WavedashMedal's achievement Wavedash has not taken yet, again every two seconds while it
5291
+ * refuses some, as it does until it has loaded the player's achievements; one refused for about a minute is
5292
+ * taken as an identifier Wavedash does not have, said once in the console, and not sent again this visit
5293
+ * @ignore */
5294
+ sendAchievements(): void;
5295
+ }
5296
+ /**
5297
+ * WavedashMedal: a medal that is also a Wavedash achievement, unlocked on Wavedash by its identifier
5298
+ * @extends Medal
5299
+ * @memberof Wavedash
5300
+ * @example
5301
+ * const medal_finish = new WavedashMedal(0, 'ACH_01_FINISH', 'Finish', 'Finish a level');
5302
+ * medal_finish.unlock(); // Wavedash's toast on Wavedash, the engine's popup anywhere else
5303
+ */
5304
+ export class WavedashMedal extends Medal {
5305
+ /** Create a WavedashMedal and add it to the list of medals
5306
+ * @param {number} id - The unique identifier of the medal, as for any Medal
5307
+ * @param {string} achievement - The identifier of its Wavedash achievement, as made with the Wavedash CLI
5308
+ * @param {string} name - Name of the medal
5309
+ * @param {string} [description] - Description of the medal
5310
+ * @param {string} [icon] - Icon for the medal
5311
+ * @param {string} [src] - Image location for the medal
5312
+ */
5313
+ constructor(id: number, achievement: string, name: string, description?: string, icon?: string, src?: string);
5314
+ /** @property {string} - The identifier of its Wavedash achievement */
5315
+ achievement: string;
5316
+ }
5044
5317
  /**
5045
5318
  * LittleJS Post Processing Plugin
5046
5319
  * - Supports shadertoy style post processing shaders
@@ -5077,6 +5350,18 @@ declare module "littlejsengine" {
5077
5350
  constructor(shaderCode?: string, includeMainCanvas?: boolean, feedbackTexture?: boolean);
5078
5351
  /** @property {string} - The shadertoy style mainImage code it shades with, see setShaderCode */
5079
5352
  shaderCode: string;
5353
+ /** @property {Object<string, number|Array<number>>} - The game's own values for the shader, a uniform each
5354
+ * by its name, a number a float and a list of 2 to 4 numbers a vector, set every frame as they are; an
5355
+ * effect setting can be one of these names, so it changes every frame without making the shader again, all
5356
+ * but glow's size, which sets how many samples it takes; adding or removing a name makes the shader again,
5357
+ * and the shader is first made at the first render, so values set right after the plugin are in it; a name
5358
+ * is a GLSL name not starting with an underscore, which the effects keep for their own, nor i and a capital
5359
+ * or gl_, and not c, uv or p, the names mainImage works on
5360
+ * @type {Object<string, number|Array<number>>} */
5361
+ values: {
5362
+ [x: string]: number | Array<number>;
5363
+ };
5364
+ valueNames: string;
5080
5365
  /** @property {WebGLProgram|undefined} - Shader for post processing
5081
5366
  * @type {WebGLProgram|undefined} */
5082
5367
  shader: WebGLProgram | undefined;
@@ -5096,8 +5381,8 @@ declare module "littlejsengine" {
5096
5381
  }
5097
5382
  /**
5098
5383
  * Set up post processing with a bloom effect, so bright colors and lights glow
5099
- * @param {number} [threshold] - Brightness where the glow starts, 0 is everything and 1 is only pure white
5100
- * @param {number} [strength] - How much glow to add
5384
+ * @param {number|string} [threshold] - Brightness where the glow starts, 0 is everything and 1 is only pure white
5385
+ * @param {number|string} [strength] - How much glow to add
5101
5386
  * @param {number} [size] - How far the glow spreads in pixels
5102
5387
  * @param {boolean} [includeMainCanvas] - Glow the 2D canvas too, off by default so HUD text stays crisp
5103
5388
  * (a HUD drawn with WebGL in gameRenderPost glows either way, draw it with useWebGL=false)
@@ -5106,17 +5391,18 @@ declare module "littlejsengine" {
5106
5391
  * @example
5107
5392
  * postProcessBloom(); // in gameInit, after any Render3DPlugin
5108
5393
  */
5109
- export function postProcessBloom(threshold?: number, strength?: number, size?: number, includeMainCanvas?: boolean): PostProcessPlugin;
5394
+ export function postProcessBloom(threshold?: string | number, strength?: string | number, size?: number, includeMainCanvas?: boolean): PostProcessPlugin;
5110
5395
  /**
5111
5396
  * Shader code for a bloom effect, the bright parts of the image blurred back over it
5112
5397
  * - Pass it to PostProcessPlugin, or edit the string to build an effect on top of it
5113
- * @param {number} [threshold] - Brightness where the glow starts, 0 is everything and 1 is only pure white
5114
- * @param {number} [strength] - How much glow to add
5115
- * @param {number} [size] - How far the glow spreads in pixels, which also sets how many samples it takes
5398
+ * @param {number|string} [threshold] - Brightness where the glow starts, 0 is everything and 1 is only pure white
5399
+ * @param {number|string} [strength] - How much glow to add
5400
+ * @param {number} [size] - How far the glow spreads in pixels, which also sets how many samples it takes, so a
5401
+ * number and not a value's name
5116
5402
  * @return {string}
5117
5403
  * @memberof PostProcess
5118
5404
  */
5119
- export function postProcessBloomShader(threshold?: number, strength?: number, size?: number): string;
5405
+ export function postProcessBloomShader(threshold?: string | number, strength?: string | number, size?: number): string;
5120
5406
  /**
5121
5407
  * Join effects into one post process shader, in the order given, for PostProcessPlugin or setShaderCode
5122
5408
  * - Each effect is a piece of shader code on c, the pixel's color, and uv, where it is on the screen from 0 to 1;
@@ -5132,82 +5418,109 @@ declare module "littlejsengine" {
5132
5418
  export function postProcessEffects(...effects: string[]): string;
5133
5419
  /**
5134
5420
  * Bright parts glow, the bloom as an effect to join with others; postProcessBloom sets up bloom on its own
5135
- * @param {number} [threshold] - Brightness where the glow starts, 0 is everything and 1 is only pure white
5136
- * @param {number} [strength] - How much glow to add
5137
- * @param {number} [size] - How far the glow spreads in pixels, which also sets how many samples it takes
5421
+ * @param {number|string} [threshold] - Brightness where the glow starts, 0 is everything and 1 is only pure white
5422
+ * @param {number|string} [strength] - How much glow to add
5423
+ * @param {number} [size] - How far the glow spreads in pixels, which also sets how many samples it takes, so a
5424
+ * number and not a value's name
5138
5425
  * @return {string}
5139
5426
  * @memberof PostProcess
5140
5427
  */
5141
- export function postProcessGlow(threshold?: number, strength?: number, size?: number): string;
5428
+ export function postProcessGlow(threshold?: string | number, strength?: string | number, size?: number): string;
5142
5429
  /**
5143
5430
  * Scan lines across the screen, like an old TV
5144
- * @param {number} [strength] - How dark the lines are, and how bright between them
5145
- * @param {number} [spacing] - Pixels from one line to the next
5431
+ * @param {number|string} [strength] - How dark the lines are, and how bright between them
5432
+ * @param {number|string} [spacing] - Pixels from one line to the next
5146
5433
  * @return {string}
5147
5434
  * @memberof PostProcess
5148
5435
  */
5149
- export function postProcessScanlines(strength?: number, spacing?: number): string;
5436
+ export function postProcessScanlines(strength?: string | number, spacing?: string | number): string;
5150
5437
  /**
5151
5438
  * Static noise over the picture, changing every frame
5152
- * @param {number} [strength] - How bright the static is
5153
- * @param {number} [size] - Size of a speck in pixels
5439
+ * @param {number|string} [strength] - How bright the static is
5440
+ * @param {number|string} [size] - Size of a speck in pixels
5154
5441
  * @return {string}
5155
5442
  * @memberof PostProcess
5156
5443
  */
5157
- export function postProcessNoise(strength?: number, size?: number): string;
5444
+ export function postProcessNoise(strength?: string | number, size?: string | number): string;
5158
5445
  /**
5159
5446
  * Darken toward the edges and corners
5160
- * @param {number} [strength] - How dark the corners get, 1 is black
5161
- * @param {number} [falloff] - How far in it reaches, low darkens most of the screen, high only the corners
5447
+ * @param {number|string} [strength] - How dark the corners get, 1 is black
5448
+ * @param {number|string} [falloff] - How far in it reaches, low darkens most of the screen, high only the corners
5162
5449
  * @return {string}
5163
5450
  * @memberof PostProcess
5164
5451
  */
5165
- export function postProcessVignette(strength?: number, falloff?: number): string;
5452
+ export function postProcessVignette(strength?: string | number, falloff?: string | number): string;
5166
5453
  /**
5167
5454
  * Bend the picture like the bulged glass of an old TV, black past the corners; put it first
5168
- * @param {number} [strength] - How much it bends
5455
+ * @param {number|string} [strength] - How much it bends
5169
5456
  * @return {string}
5170
5457
  * @memberof PostProcess
5171
5458
  */
5172
- export function postProcessCurve(strength?: number): string;
5459
+ export function postProcessCurve(strength?: string | number): string;
5173
5460
  /**
5174
5461
  * Split red and blue apart toward the edges, like a cheap lens; put it before what shades the picture
5175
- * @param {number} [strength] - How far apart at the edge, as a part of the screen
5462
+ * @param {number|string} [strength] - How far apart at the edge, as a part of the screen
5176
5463
  * @return {string}
5177
5464
  * @memberof PostProcess
5178
5465
  */
5179
- export function postProcessChromatic(strength?: number): string;
5466
+ export function postProcessChromatic(strength?: string | number): string;
5180
5467
  /**
5181
5468
  * Draw lines where the 3D depth jumps, around objects and along their creases; needs render3D.depthTexture on
5182
5469
  * @param {Color} [color] - The lines' color, its alpha how strong they are
5183
- * @param {number} [thickness] - How wide the lines are in pixels
5184
- * @param {number} [threshold] - How big a jump makes a line, as a part of the distance, lower draws more
5470
+ * @param {number|string} [thickness] - How wide the lines are in pixels
5471
+ * @param {number|string} [threshold] - How big a jump makes a line, as a part of the distance, lower draws more
5472
+ * @return {string}
5473
+ * @memberof PostProcess
5474
+ */
5475
+ export function postProcessOutline(color?: Color, thickness?: string | number, threshold?: string | number): string;
5476
+ /**
5477
+ * Keep a band across the screen sharp and blur the picture above and below it, as a tilt shift lens does, which
5478
+ * makes a scene look like a small model; it reads only the screen, so it works in 2D and 3D; put it first
5479
+ * @param {number|string} [focus] - Height of the middle of the sharp band, 0 the bottom of the screen and 1 the top
5480
+ * @param {number|string} [size] - Height of the sharp band, as a part of the screen
5481
+ * @param {number|string} [blur] - Widest blur in pixels, reached half the screen past the band, at most 32
5482
+ * @return {string}
5483
+ * @memberof PostProcess
5484
+ * @example
5485
+ * new PostProcessPlugin(postProcessEffects(postProcessTiltShift(.4, .2, 10), postProcessVignette(.5)));
5486
+ */
5487
+ export function postProcessTiltShift(focus?: string | number, size?: string | number, blur?: string | number): string;
5488
+ /**
5489
+ * Keep what is a distance from the camera sharp and blur what is nearer or farther, as a camera lens does; needs
5490
+ * render3D.depthTexture on, and blurs 3D only, 2D draws having no depth; put it first
5491
+ * - What is in focus stays sharp at its edges: a blur in front of or behind it leaves out what is in focus
5492
+ * @param {number|string} [focus] - Distance from the camera, along its view, that is sharpest, in world units
5493
+ * @param {number|string} [range] - How deep the sharp part is; the blur grows over as far again past it
5494
+ * @param {number|string} [blur] - Widest blur in pixels, at most 32
5185
5495
  * @return {string}
5186
5496
  * @memberof PostProcess
5497
+ * @example
5498
+ * render3D.depthTexture = true;
5499
+ * new PostProcessPlugin(postProcessEffects(postProcessDepthOfField(10, 4, 8)));
5187
5500
  */
5188
- export function postProcessOutline(color?: Color, thickness?: number, threshold?: number): string;
5501
+ export function postProcessDepthOfField(focus?: string | number, range?: string | number, blur?: string | number): string;
5189
5502
  /**
5190
5503
  * The look of an old TV, as one effect to use alone or join with others: static noise, scan lines, a soft glow and
5191
5504
  * a vignette, and a bulged screen when curve is set; any setting at 0 leaves that part out
5192
5505
  * @param {Object} [settings]
5193
- * @param {number} [settings.noise] - Static noise strength
5194
- * @param {number} [settings.scanlines] - Scan line strength
5195
- * @param {number} [settings.scanlineSpacing] - Pixels from one scan line to the next
5196
- * @param {number} [settings.glow] - Soft glow strength
5197
- * @param {number} [settings.vignette] - Vignette strength
5198
- * @param {number} [settings.curve] - How much the screen bulges, 0 by default for flat
5506
+ * @param {number|string} [settings.noise] - Static noise strength
5507
+ * @param {number|string} [settings.scanlines] - Scan line strength
5508
+ * @param {number|string} [settings.scanlineSpacing] - Pixels from one scan line to the next
5509
+ * @param {number|string} [settings.glow] - Soft glow strength
5510
+ * @param {number|string} [settings.vignette] - Vignette strength
5511
+ * @param {number|string} [settings.curve] - How much the screen bulges, 0 by default for flat
5199
5512
  * @return {string}
5200
5513
  * @example
5201
5514
  * new PostProcessPlugin(postProcessEffects(postProcessTV({scanlines: .4, curve: .1})));
5202
5515
  * @memberof PostProcess
5203
5516
  */
5204
5517
  export function postProcessTV({ noise, scanlines, scanlineSpacing, glow, vignette, curve }?: {
5205
- noise?: number;
5206
- scanlines?: number;
5207
- scanlineSpacing?: number;
5208
- glow?: number;
5209
- vignette?: number;
5210
- curve?: number;
5518
+ noise?: string | number;
5519
+ scanlines?: string | number;
5520
+ scanlineSpacing?: string | number;
5521
+ glow?: string | number;
5522
+ vignette?: string | number;
5523
+ curve?: string | number;
5211
5524
  }): string;
5212
5525
  /**
5213
5526
  * LittleJS Light System Plugin
@@ -5233,6 +5546,8 @@ declare module "littlejsengine" {
5233
5546
  * setShadowTransparent lets its color tint the light
5234
5547
  * - Set light.glow for a soft hazy glow over a light, like a lamp at night; it is added over the lit scene after the
5235
5548
  * lightmap, so it shows in the dark and sits in front of everything there
5549
+ * - A DirectionalLight is a sun: one per scene, it lights everything from one direction, foreground casters throw long
5550
+ * shadows and objects with castBackgroundShadow are lit only at their edges facing it
5236
5551
  * - Must be constructed BEFORE PostProcessPlugin so post-process sees lit pixels
5237
5552
  * @namespace LightSystem
5238
5553
  */
@@ -5250,7 +5565,7 @@ declare module "littlejsengine" {
5250
5565
  * @memberof LightSystem
5251
5566
  */
5252
5567
  export class LightSystemPlugin {
5253
- /** Create the global light system plugin.
5568
+ /** Create the global light system plugin
5254
5569
  * @param {Vector2} [textureSize] - Size of the lightmap texture (defaults to following mainCanvasSize, which is css pixels, so the lightmap is not scaled by canvasPixelRatio; pass mainCanvasSize.scale(getCanvasPixelRatio()) for a full resolution lightmap)
5255
5570
  * @param {Color} [ambientColor] - Color applied to unlit areas of the scene (defaults to BLACK = pitch dark). Set a small RGB like rgb(0.1,0.1,0.15) for a faint "moonlight" baseline so unlit areas aren't fully black.
5256
5571
  * @example
@@ -5260,6 +5575,7 @@ declare module "littlejsengine" {
5260
5575
  constructor(textureSize?: Vector2, ambientColor?: Color);
5261
5576
  /** @property {boolean} - When false, the render pass is skipped entirely */
5262
5577
  enabled: boolean;
5578
+ shadersFailed: boolean;
5263
5579
  /** @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
5580
  ambientColor: Color;
5265
5581
  /** @property {Vector2} - Size of the lightmap texture, follows mainCanvasSize (css pixels, so it is not scaled by canvasPixelRatio) unless a size was passed */
@@ -5303,6 +5619,10 @@ declare module "littlejsengine" {
5303
5619
  /** @property {WebGLTexture|undefined} - The shadow map, casters drawn black on white around the camera, read only
5304
5620
  * @type {WebGLTexture|undefined} */
5305
5621
  shadowMap: WebGLTexture | undefined;
5622
+ /** @property {WebGLTexture|undefined} - The background map, objects with castBackgroundShadow drawn black on
5623
+ * white, the shadow map's size and place, made by a directional light when something casts into it and kept while the light is, read only
5624
+ * @type {WebGLTexture|undefined} */
5625
+ backgroundMap: WebGLTexture | undefined;
5306
5626
  /** @property {WebGLTexture|undefined} - One of the two textures each light's shadow is built in
5307
5627
  * @type {WebGLTexture|undefined} */
5308
5628
  shadowTextureA: WebGLTexture | undefined;
@@ -5328,6 +5648,26 @@ declare module "littlejsengine" {
5328
5648
  shadowMapOrigin: Vector2;
5329
5649
  /** @property {number} - World size the shadow map covers, set each shadow pass */
5330
5650
  shadowMapWorldSize: number;
5651
+ /** @property {DirectionalLight|undefined} - The scene's directional light, a sun, or undefined, read only
5652
+ * @type {DirectionalLight|undefined} */
5653
+ directionalLight: DirectionalLight | undefined;
5654
+ /** @property {number} - Pixels across the square textures a directional light is built in, covering the
5655
+ * shadow map's area; larger is sharper and slower; a power of two, as shadowMapSize, so their texels line up */
5656
+ directionalTextureSize: number;
5657
+ /** @property {WebGLTexture|undefined} - The directional light as built this frame, white where it reaches,
5658
+ * over the shadow map's area, read only
5659
+ * @type {WebGLTexture|undefined} */
5660
+ directionalTexture: WebGLTexture | undefined;
5661
+ /** @type {WebGLTexture|undefined} */
5662
+ directionalTextureA: WebGLTexture | undefined;
5663
+ /** @type {WebGLTexture|undefined} */
5664
+ directionalTextureB: WebGLTexture | undefined;
5665
+ directionalTextureSizeAllocated: number;
5666
+ backgroundCasters: boolean;
5667
+ /** @type {Object<string, WebGLProgram|WebGLVertexArrayObject>} */
5668
+ directionalPrograms: {
5669
+ [x: string]: WebGLProgram | WebGLVertexArrayObject;
5670
+ };
5331
5671
  shadowMapSizeAllocated: number;
5332
5672
  shadowTextureSizeAllocated: number;
5333
5673
  /** Bring the sizes of the textures it makes down to what the device can make: shadowMapSize, shadowTextureSize
@@ -5392,6 +5732,34 @@ declare module "littlejsengine" {
5392
5732
  * called by LightSystemPlugin after the lightmap is applied */
5393
5733
  renderGlow(): void;
5394
5734
  }
5735
+ /**
5736
+ * A DirectionalLight is a sun for the 2D light system: it lights the whole scene from one direction, added into the
5737
+ * lightmap with the point lights
5738
+ * - One at a time, made after the LightSystemPlugin, lightSystem.directionalLight is the one; a debug build asserts on
5739
+ * a second while the first lives, a release build destroys the first
5740
+ * - Its castShadow lets foreground casters, objects with castShadow, throw long shadows across open space, fading out
5741
+ * by shadowLength; a light does not need lightSystem.shadows for that
5742
+ * - Objects with castBackgroundShadow, a background layer, are dark to it inside and lit at the edges that face it,
5743
+ * fading in by backgroundDepth
5744
+ * @extends EngineObject
5745
+ * @memberof LightSystem
5746
+ * @example
5747
+ * new DirectionalLight(vec2(-1, 1), hsl(.1, .3, 1)); // a warm sun up and to the left, shining down and to the right
5748
+ */
5749
+ export class DirectionalLight extends EngineObject {
5750
+ /** Create the scene's directional light
5751
+ * @param {Vector2} [sunDirection] - Toward the sun, it shines the other way, as render3D.sunDirection
5752
+ * @param {Color} [color] - Color of the light; alpha modulates intensity */
5753
+ constructor(sunDirection?: Vector2, color?: Color);
5754
+ /** @property {Vector2} - Toward the sun, it shines the other way, as render3D.sunDirection */
5755
+ sunDirection: Vector2;
5756
+ /** @property {number} - World units a long shadow reaches before it has faded out; a caster casts only from
5757
+ * inside the shadow map, shadowMapScale views across, so past (shadowMapScale - 1) / 2 of a view beyond the
5758
+ * screen it throws none in */
5759
+ shadowLength: number;
5760
+ /** @property {number} - World units the light gets into a background area from its edges facing it */
5761
+ backgroundDepth: number;
5762
+ }
5395
5763
  /**
5396
5764
  * LittleJS Audio Effects Plugin
5397
5765
  * - Web Audio effects with a wet/dry mix: filter, reverb, delay, distortion, compressor
@@ -5606,6 +5974,11 @@ declare module "littlejsengine" {
5606
5974
  * @param {number|boolean} debugMode
5607
5975
  * @memberof UISystem */
5608
5976
  export function uiSetDebug(debugMode: number | boolean): void;
5977
+ /**
5978
+ * @callback DragAndDropCallback - Callback for drag and drop events
5979
+ * @param {DragEvent} event - The drag event
5980
+ * @memberof UISystem
5981
+ */
5609
5982
  /**
5610
5983
  * UI System Global Object
5611
5984
  * @memberof UISystem
@@ -5748,24 +6121,19 @@ declare module "littlejsengine" {
5748
6121
  * @param {'left'|'center'|'right'} [align]
5749
6122
  * @param {string} [font=uiSystem.defaultFont]
5750
6123
  * @param {string} [fontStyle]
5751
- * @param {boolean} [applyMaxWidth=true]
6124
+ * @param {boolean} [applyMaxWidth]
5752
6125
  * @param {Vector2} [textShadow]
5753
6126
  * @param {Color} [shadowColor]
5754
6127
  * @param {number} [shadowBlur]
5755
6128
  * @param {Vector2} [shadowOffset] */
5756
6129
  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
- /**
5758
- * @callback DragAndDropCallback - Callback for drag and drop events
5759
- * @param {DragEvent} event - The drag event
5760
- * @memberof UISystem
5761
- */
5762
6130
  /** Setup drag and drop event handlers
5763
6131
  * Automatically prevents defaults and calls the given functions
5764
6132
  * @param {DragAndDropCallback} [onDrop] - when a file is dropped
5765
6133
  * @param {DragAndDropCallback} [onDragEnter] - when a file is dragged onto the window
5766
6134
  * @param {DragAndDropCallback} [onDragLeave] - when a file is dragged off the window
5767
6135
  * @param {DragAndDropCallback} [onDragOver] - continuously when dragging over */
5768
- setupDragAndDrop(onDrop?: (event: DragEvent) => any, onDragEnter?: (event: DragEvent) => any, onDragLeave?: (event: DragEvent) => any, onDragOver?: (event: DragEvent) => any): void;
6136
+ setupDragAndDrop(onDrop?: DragAndDropCallback, onDragEnter?: DragAndDropCallback, onDragLeave?: DragAndDropCallback, onDragOver?: DragAndDropCallback): void;
5769
6137
  /** Convert a screen space position to native UI position
5770
6138
  * @param {Vector2} pos
5771
6139
  * @return {Vector2} */
@@ -5882,6 +6250,7 @@ declare module "littlejsengine" {
5882
6250
  textLineWidth: number;
5883
6251
  /** @property {boolean} - Should this object be drawn */
5884
6252
  visible: boolean;
6253
+ uiUpdatePass: number;
5885
6254
  /** @property {Array<UIObject>} - A list of this object's children
5886
6255
  * @type {Array<UIObject>} */
5887
6256
  children: Array<UIObject>;
@@ -5951,15 +6320,20 @@ declare module "littlejsengine" {
5951
6320
  getTextPos(textSize: Vector2): Vector2;
5952
6321
  /** Called when the navigation button is pressed on this object */
5953
6322
  navigatePressed(): void;
5954
- /** @return {boolean} - Is the mouse hovering over this element */
6323
+ /** Is the mouse hovering over this element
6324
+ * @return {boolean} */
5955
6325
  isHoverObject(): boolean;
5956
- /** @return {boolean} - Is the mouse held onto this element */
6326
+ /** Is the mouse held onto this element
6327
+ * @return {boolean} */
5957
6328
  isActiveObject(): boolean;
5958
- /** @return {boolean} - Is the gamepad or keyboard navigation object */
6329
+ /** Is the gamepad or keyboard navigation object
6330
+ * @return {boolean} */
5959
6331
  isNavigationObject(): boolean;
5960
- /** @return {boolean} - Is this object in keyboard input mode */
6332
+ /** Is this object in keyboard input mode
6333
+ * @return {boolean} */
5961
6334
  isKeyInputObject(): boolean;
5962
- /** @return {boolean} - Can it be interacted with, it and every parent visible and enabled */
6335
+ /** Can it be interacted with, it and every parent visible and enabled
6336
+ * @return {boolean} */
5963
6337
  isInteractive(): boolean;
5964
6338
  /** Returns string containing info about this object for debugging
5965
6339
  * @return {string} */
@@ -6023,7 +6397,7 @@ declare module "littlejsengine" {
6023
6397
  * @param {string} [text]
6024
6398
  */
6025
6399
  constructor(pos?: Vector2, size?: Vector2, text?: string);
6026
- /** @property {number} - Max length of input (0 = no limit) */
6400
+ /** @property {number} - Max length of input in characters as a reader counts them (0 = no limit) */
6027
6401
  maxLength: number;
6028
6402
  text: string;
6029
6403
  /** Stop editing the text */
@@ -6132,9 +6506,9 @@ declare module "littlejsengine" {
6132
6506
  * @param {Vector2} pos
6133
6507
  * @param {Vector2} size
6134
6508
  * @param {string} src - Video file path or URL
6135
- * @param {boolean} [autoplay=false] - Start playing immediately?
6136
- * @param {boolean} [loop=false] - Loop the video?
6137
- * @param {number} [volume=1] - Volume percent scaled by global volume (0-1)
6509
+ * @param {boolean} [autoplay] - Start playing immediately?
6510
+ * @param {boolean} [loop] - Loop the video?
6511
+ * @param {number} [volume] - Volume percent scaled by global volume (0-1)
6138
6512
  */
6139
6513
  constructor(pos: Vector2, size: Vector2, src: string, autoplay?: boolean, loop?: boolean, volume?: number);
6140
6514
  /** @property {number} - The video volume */
@@ -6196,10 +6570,10 @@ declare module "littlejsengine" {
6196
6570
  export class UILayout extends UIObject {
6197
6571
  /** Create a UILayout container that auto-arranges children
6198
6572
  * @param {Vector2} [pos]
6199
- * @param {number} [columns=1] - Number of columns (1 = vertical list)
6200
- * @param {number} [gap=10] - Space between children
6201
- * @param {number} [padding=10] - Space between container border and children
6202
- * @param {boolean} [transparent=false] - If true, draws no background, outline, or shadow
6573
+ * @param {number} [columns] - Number of columns (1 = vertical list)
6574
+ * @param {number} [gap] - Space between children
6575
+ * @param {number} [padding] - Space between container border and children
6576
+ * @param {boolean} [transparent] - If true, draws no background, outline, or shadow
6203
6577
  */
6204
6578
  constructor(pos?: Vector2, columns?: number, gap?: number, padding?: number, transparent?: boolean);
6205
6579
  /** @property {number} - Number of columns in the layout */
@@ -6338,23 +6712,29 @@ declare module "littlejsengine" {
6338
6712
  * @param {CanvasRenderingContext2D} [context] */
6339
6713
  drawFixture(fixture: any, pos: Vector2, angle: number, color?: Color, lineColor?: Color, lineWidth?: number, useWebGL?: boolean, context?: CanvasRenderingContext2D): void;
6340
6714
  /** converts a box2d vec2 to a Vector2
6341
- * @param {Object} v */
6715
+ * @param {Object} v
6716
+ * @return {Vector2} */
6342
6717
  vec2From(v: any): Vector2;
6343
6718
  /** converts a box2d vec2 pointer to a Vector2
6344
- * @param {Object} vp */
6719
+ * @param {Object} vp
6720
+ * @return {Vector2} */
6345
6721
  vec2FromPointer(vp: any): Vector2;
6346
6722
  /** converts a Vector2 to a new box2d vec2, which stays until destroyed with box2d.instance.destroy;
6347
6723
  * the plugin itself passes Box2D reused ones, since Box2D copies every vector it is given
6348
- * @param {Vector2} v */
6724
+ * @param {Vector2} v
6725
+ * @return {Object} - A Box2D vector, its b2Vec2 */
6349
6726
  vec2dTo(v: Vector2): any;
6350
6727
  /** checks if a box2d object is null
6351
- * @param {Object} o */
6728
+ * @param {Object} o
6729
+ * @return {boolean} */
6352
6730
  isNull(o: any): boolean;
6353
6731
  /** casts a box2d object to a shape type
6354
- * @param {Object} o */
6732
+ * @param {Object} o
6733
+ * @return {Object} - The shape as its own Box2D type */
6355
6734
  castShapeObject(o: any): any;
6356
6735
  /** casts a box2d object to a joint type
6357
- * @param {Object} o */
6736
+ * @param {Object} o
6737
+ * @return {Object} - The joint as its own Box2D type */
6358
6738
  castJointObject(o: any): any;
6359
6739
  }
6360
6740
  /**
@@ -6363,6 +6743,10 @@ declare module "littlejsengine" {
6363
6743
  * - Provides interface for Box2D body and fixture functions
6364
6744
  * - Each object can have multiple fixtures and joints
6365
6745
  * - Angular values are clockwise like angle: angular velocity, torque, joint angles, limits and motor speeds
6746
+ * - Box2D moves the body, so the EngineObject physics fields do nothing on it: velocity, angleVelocity, damping,
6747
+ * angleDamping, mass, friction, restitution and gravityScale; use setLinearVelocity, setAngularVelocity,
6748
+ * setLinearDamping, setAngularDamping, setMass, the friction and restitution of its shapes and setGravityScale.
6749
+ * A debug build warns once when one of them is set
6366
6750
  * @extends EngineObject
6367
6751
  * @memberof Box2D
6368
6752
  */
@@ -6389,7 +6773,7 @@ declare module "littlejsengine" {
6389
6773
  * @type {Array<Array<Vector2>>} */
6390
6774
  edgeLoops: Array<Array<Vector2>>;
6391
6775
  edgeListFixtures: Map<any, any>;
6392
- /** Draws all this object's fixtures
6776
+ /** Draw all this object's fixtures
6393
6777
  * @param {Color} [color]
6394
6778
  * @param {Color} [lineColor]
6395
6779
  * @param {number} [lineWidth]
@@ -6415,7 +6799,8 @@ declare module "littlejsengine" {
6415
6799
  * @param {number} [density]
6416
6800
  * @param {number} [friction]
6417
6801
  * @param {number} [restitution]
6418
- * @param {boolean} [isSensor] */
6802
+ * @param {boolean} [isSensor]
6803
+ * @return {Object} - The fixture made, Box2D's own */
6419
6804
  addShape(shape: any, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
6420
6805
  /** Add a box shape to the body
6421
6806
  * @param {Vector2} [size]
@@ -6426,61 +6811,69 @@ declare module "littlejsengine" {
6426
6811
  * @param {number} [density]
6427
6812
  * @param {number} [friction]
6428
6813
  * @param {number} [restitution]
6429
- * @param {boolean} [isSensor] */
6430
- addBox(size?: Vector2, offset?: Vector2, angle?: number, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
6814
+ * @param {boolean} [isSensor]
6815
+ * @return {Object|undefined} - The fixture made, Box2D's own, undefined for a shape too small to make */
6816
+ addBox(size?: Vector2, offset?: Vector2, angle?: number, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any | undefined;
6431
6817
  /** Add a polygon shape to the body, the convex hull of its points; Box2D takes 3 to 8 points,
6432
6818
  * not all in a line, and no fixture is made from any other; points closer than .001 count as one
6433
6819
  * @param {Array<Vector2>} points
6434
6820
  * @param {number} [density]
6435
6821
  * @param {number} [friction]
6436
6822
  * @param {number} [restitution]
6437
- * @param {boolean} [isSensor] */
6438
- addPoly(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
6823
+ * @param {boolean} [isSensor]
6824
+ * @return {Object|undefined} - The fixture made, Box2D's own, undefined for a shape too small to make */
6825
+ addPoly(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any | undefined;
6439
6826
  /** Add a regular polygon shape to the body
6440
6827
  * @param {number} [diameter]
6441
6828
  * @param {number} [sides] - 3 to 8, the most Box2D polygons have
6442
6829
  * @param {number} [density]
6443
6830
  * @param {number} [friction]
6444
6831
  * @param {number} [restitution]
6445
- * @param {boolean} [isSensor] */
6446
- addRegularPoly(diameter?: number, sides?: number, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
6832
+ * @param {boolean} [isSensor]
6833
+ * @return {Object|undefined} - The fixture made, Box2D's own, undefined for a shape too small to make */
6834
+ addRegularPoly(diameter?: number, sides?: number, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any | undefined;
6447
6835
  /** Add a random polygon shape to the body
6448
6836
  * @param {number} [diameter]
6449
6837
  * @param {number} [density]
6450
6838
  * @param {number} [friction]
6451
6839
  * @param {number} [restitution]
6452
- * @param {boolean} [isSensor] */
6453
- addRandomPoly(diameter?: number, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
6840
+ * @param {boolean} [isSensor]
6841
+ * @return {Object|undefined} - The fixture made, Box2D's own, undefined for a shape too small to make */
6842
+ addRandomPoly(diameter?: number, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any | undefined;
6454
6843
  /** Add a circle shape to the body
6455
6844
  * @param {number} [diameter]
6456
6845
  * @param {Vector2} [offset]
6457
6846
  * @param {number} [density]
6458
6847
  * @param {number} [friction]
6459
6848
  * @param {number} [restitution]
6460
- * @param {boolean} [isSensor] */
6461
- addCircle(diameter?: number, offset?: Vector2, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
6849
+ * @param {boolean} [isSensor]
6850
+ * @return {Object|undefined} - The fixture made, Box2D's own, undefined for a circle too big to make */
6851
+ addCircle(diameter?: number, offset?: Vector2, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any | undefined;
6462
6852
  /** Add an edge shape to the body
6463
6853
  * @param {Vector2} point1
6464
6854
  * @param {Vector2} point2
6465
6855
  * @param {number} [density]
6466
6856
  * @param {number} [friction]
6467
6857
  * @param {number} [restitution]
6468
- * @param {boolean} [isSensor] */
6858
+ * @param {boolean} [isSensor]
6859
+ * @return {Object} - The fixture made, Box2D's own */
6469
6860
  addEdge(point1: Vector2, point2: Vector2, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
6470
6861
  /** Add an edge list to the body
6471
6862
  * @param {Array<Vector2>} points
6472
6863
  * @param {number} [density]
6473
6864
  * @param {number} [friction]
6474
6865
  * @param {number} [restitution]
6475
- * @param {boolean} [isSensor] */
6476
- addEdgeList(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any[];
6866
+ * @param {boolean} [isSensor]
6867
+ * @return {Array<Object>} - The fixtures made, Box2D's own */
6868
+ addEdgeList(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): Array<any>;
6477
6869
  /** Add an edge loop to the body, an edge loop connects the end points
6478
6870
  * @param {Array<Vector2>} points
6479
6871
  * @param {number} [density]
6480
6872
  * @param {number} [friction]
6481
6873
  * @param {number} [restitution]
6482
- * @param {boolean} [isSensor] */
6483
- addEdgeLoop(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any[];
6874
+ * @param {boolean} [isSensor]
6875
+ * @return {Array<Object>} - The fixtures made, Box2D's own */
6876
+ addEdgeLoop(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): Array<any>;
6484
6877
  /** Destroy a fixture from the body, from a contact callback once the step is done
6485
6878
  * @param {Object} fixture */
6486
6879
  destroyFixture(fixture: any): void;
@@ -6523,10 +6916,12 @@ declare module "littlejsengine" {
6523
6916
  /** Sets the angular velocity, clockwise like angle
6524
6917
  * @param {number} angularVelocity */
6525
6918
  setAngularVelocity(angularVelocity: number): void;
6526
- /** Sets the linear damping
6919
+ /** Sets the linear damping, Box2D's: a rate, 0 none and larger slows it faster, with no upper limit, where the
6920
+ * damping of an EngineObject is the fraction it keeps each frame and does nothing on a Box2dObject
6527
6921
  * @param {number} damping */
6528
6922
  setLinearDamping(damping: number): void;
6529
- /** Sets the angular damping
6923
+ /** Sets the angular damping, Box2D's: a rate, 0 none and larger slows its turning faster, with no upper limit;
6924
+ * angleDamping does nothing on a Box2dObject
6530
6925
  * @param {number} damping */
6531
6926
  setAngularDamping(damping: number): void;
6532
6927
  /** Sets the gravity scale
@@ -6796,10 +7191,10 @@ declare module "littlejsengine" {
6796
7191
  /** Get the frequency in Hertz
6797
7192
  * @return {number} */
6798
7193
  getFrequency(): number;
6799
- /** Set the damping ratio
7194
+ /** Set how much the spring is damped, 0 for none and 1 to stop it bouncing
6800
7195
  * @param {number} ratio */
6801
7196
  setDampingRatio(ratio: number): void;
6802
- /** Get the damping ratio
7197
+ /** Get how much the spring is damped, 0 for none and 1 to stop it bouncing
6803
7198
  * @return {number} */
6804
7199
  getDampingRatio(): number;
6805
7200
  }
@@ -6807,6 +7202,8 @@ declare module "littlejsengine" {
6807
7202
  * Box2D Pin Joint
6808
7203
  * - Pins two objects together at a point, where they still turn freely, like a nail through two boards
6809
7204
  * - A revolute joint at that point, so it holds exactly and its limits and motor work too
7205
+ * - new Box2dPinJoint(objectA, objectB, pos, collide): the point defaults to objectA's position, where a revolute
7206
+ * joint's anchor defaults to objectB's
6810
7207
  * @extends Box2dRevoluteJoint
6811
7208
  * @memberof Box2D
6812
7209
  */
@@ -6903,7 +7300,7 @@ declare module "littlejsengine" {
6903
7300
  /** Set the max motor torque, a magnitude
6904
7301
  * @param {number} torque */
6905
7302
  setMaxMotorTorque(torque: number): void;
6906
- /** Get the max motor torque
7303
+ /** Get the most torque the motor can apply, a magnitude
6907
7304
  * @return {number} */
6908
7305
  getMaxMotorTorque(): number;
6909
7306
  /** Get the motor torque over the last step, clockwise like angle
@@ -7003,10 +7400,10 @@ declare module "littlejsengine" {
7003
7400
  /** Enable/disable the joint motor
7004
7401
  * @param {boolean} [enable] */
7005
7402
  enableMotor(enable?: boolean): void;
7006
- /** Set the motor speed
7403
+ /** Set the speed the motor drives the bodies apart along the axis, in meters per second
7007
7404
  * @param {number} speed */
7008
7405
  setMotorSpeed(speed: number): void;
7009
- /** Get the motor speed
7406
+ /** Get the speed the motor drives the bodies apart along the axis, in meters per second
7010
7407
  * @return {number} */
7011
7408
  getMotorSpeed(): number;
7012
7409
  /** Set the maximum motor force
@@ -7067,7 +7464,7 @@ declare module "littlejsengine" {
7067
7464
  /** Set the maximum motor torque, a magnitude
7068
7465
  * @param {number} torque */
7069
7466
  setMaxMotorTorque(torque: number): void;
7070
- /** Get the max motor torque
7467
+ /** Get the most torque the wheel's motor can apply, a magnitude
7071
7468
  * @return {number} */
7072
7469
  getMaxMotorTorque(): number;
7073
7470
  /** Get the motor torque over the last step, clockwise like angle
@@ -7080,10 +7477,10 @@ declare module "littlejsengine" {
7080
7477
  /** Get the spring frequency in Hertz
7081
7478
  * @return {number} */
7082
7479
  getSpringFrequencyHz(): number;
7083
- /** Set the spring damping ratio
7480
+ /** Set how much the suspension spring is damped, 0 for none and 1 to stop it bouncing
7084
7481
  * @param {number} ratio */
7085
7482
  setSpringDampingRatio(ratio: number): void;
7086
- /** Get the spring damping ratio
7483
+ /** Get how much the suspension spring is damped, 0 for none and 1 to stop it bouncing
7087
7484
  * @return {number} */
7088
7485
  getSpringDampingRatio(): number;
7089
7486
  }
@@ -7116,18 +7513,12 @@ declare module "littlejsengine" {
7116
7513
  /** Get the frequency in Hertz
7117
7514
  * @return {number} */
7118
7515
  getFrequency(): number;
7119
- /** Set the damping ratio
7516
+ /** Set how much the weld's spring is damped, 0 for none and 1 to stop it bouncing
7120
7517
  * @param {number} ratio */
7121
7518
  setDampingRatio(ratio: number): void;
7122
- /** Get the damping ratio
7519
+ /** Get how much the weld's spring is damped, 0 for none and 1 to stop it bouncing
7123
7520
  * @return {number} */
7124
7521
  getDampingRatio(): number;
7125
- /** @deprecated since 1.20, use setDampingRatio
7126
- * @param {number} ratio */
7127
- setSpringDampingRatio(ratio: number): void;
7128
- /** @deprecated since 1.20, use getDampingRatio
7129
- * @return {number} */
7130
- getSpringDampingRatio(): number;
7131
7522
  }
7132
7523
  /**
7133
7524
  * Box2D Friction Joint
@@ -7215,10 +7606,10 @@ declare module "littlejsengine" {
7215
7606
  * @param {Box2dObject} objectA
7216
7607
  * @param {Box2dObject} objectB */
7217
7608
  constructor(objectA: Box2dObject, objectB: Box2dObject);
7218
- /** Set the target linear offset, in frame A, in meters.
7609
+ /** Set the target linear offset, in frame A, in meters
7219
7610
  * @param {Vector2} offset */
7220
7611
  setLinearOffset(offset: Vector2): void;
7221
- /** Get the target linear offset, in frame A, in meters.
7612
+ /** Get the target linear offset, in frame A, in meters
7222
7613
  * @return {Vector2} */
7223
7614
  getLinearOffset(): Vector2;
7224
7615
  /** Set the target angular offset, objectB angle minus objectA angle, clockwise like angle
@@ -7280,7 +7671,7 @@ declare module "littlejsengine" {
7280
7671
  * @param {Vector2} pos - Screen space position
7281
7672
  * @param {Vector2} size - Screen space size
7282
7673
  * @param {TileInfo} startTile - Top-left tile of the 3x3 block to sample (see drawNineSlice)
7283
- * @param {Color|number} [color=WHITE] - Color to modulate with; a number here is the borderSize of the order before 1.20, deprecated
7674
+ * @param {Color} [color=WHITE] - Color to modulate with
7284
7675
  * @param {number} [borderSize] - Rendered thickness of the border sections
7285
7676
  * @param {Color} [additiveColor] - Additive color
7286
7677
  * @param {number} [extraSpace] - Extra spacing adjustment
@@ -7288,7 +7679,7 @@ declare module "littlejsengine" {
7288
7679
  * @param {boolean} [useWebGL] - Use WebGL for rendering
7289
7680
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas context to use
7290
7681
  * @memberof DrawUtilities */
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;
7682
+ export function drawNineSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, color?: Color, borderSize?: number, additiveColor?: Color, extraSpace?: number, angle?: number, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
7292
7683
  /** Draw a scalable three-slice UI element in world space
7293
7684
  * Color and additive color apply in WebGL and Canvas2D (with canvasColorTiles)
7294
7685
  * The three-slice samples 3 consecutive tiles from the tilesheet, it does not
@@ -7316,7 +7707,7 @@ declare module "littlejsengine" {
7316
7707
  * @param {Vector2} pos - Screen space position
7317
7708
  * @param {Vector2} size - Screen space size
7318
7709
  * @param {TileInfo} startTile - First of 3 consecutive tiles: corner, side, center (see drawThreeSlice)
7319
- * @param {Color|number} [color=WHITE] - Color to modulate with; a number here is the borderSize of the order before 1.20, deprecated
7710
+ * @param {Color} [color=WHITE] - Color to modulate with
7320
7711
  * @param {number} [borderSize] - Rendered thickness of the border sections
7321
7712
  * @param {Color} [additiveColor] - Additive color
7322
7713
  * @param {number} [extraSpace] - Extra spacing adjustment
@@ -7324,7 +7715,7 @@ declare module "littlejsengine" {
7324
7715
  * @param {boolean} [useWebGL] - Use WebGL for rendering
7325
7716
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas context to use
7326
7717
  * @memberof DrawUtilities */
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;
7718
+ export function drawThreeSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, color?: Color, borderSize?: number, additiveColor?: Color, extraSpace?: number, angle?: number, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
7328
7719
  /**
7329
7720
  * A tile drawn as a box of any size, kept as a style to draw with, like a UI skin
7330
7721
  * - 9 slices is a nine-slice from the 3x3 block of tiles at tileInfo, see drawNineSlice
@@ -7421,9 +7812,9 @@ declare module "littlejsengine" {
7421
7812
  * callback receives the interpolated value (a number, or a fresh instance
7422
7813
  * for lerp-able types). Both endpoints must be the same type.
7423
7814
  * @param {function(NonNullable<T>):void} callback - Called with the interpolated value each frame
7424
- * @param {T} [start=0] - Starting value
7425
- * @param {T} [end=1] - Ending value
7426
- * @param {number} [duration=1] - Duration in seconds
7815
+ * @param {T} [start] - Starting value
7816
+ * @param {T} [end] - Ending value
7817
+ * @param {number} [duration] - Duration in seconds
7427
7818
  * @param {Object} [options]
7428
7819
  * @param {function(number):number} [options.ease] - Easing function (defaults to LINEAR)
7429
7820
  * @param {boolean} [options.useRealTime=false] - Advance even when the game is paused (matches Timer's useRealTime)
@@ -7456,15 +7847,18 @@ declare module "littlejsengine" {
7456
7847
  * the last iteration of a loop or pingPong, and again each time a restart plays through; then() sets it
7457
7848
  * @type {undefined|function():void} */
7458
7849
  onComplete: undefined | (() => void);
7459
- /** Continuation when a pass ends, set by loop() and pingPong() to start the next iteration.
7850
+ /** Continuation when a pass ends, set by loop() and pingPong() to start the next iteration
7460
7851
  * @private */
7461
7852
  private thenCallback;
7462
- /** Remaining iterations including the current run (loop/pingPong only).
7853
+ /** Remaining iterations including the current run (loop/pingPong only)
7463
7854
  * @private */
7464
7855
  private loopRemaining;
7465
- /** Whether it is in the active list, see isActive
7856
+ /** Whether it is running, see isActive
7466
7857
  * @private */
7467
7858
  private active;
7859
+ /** Whether it is in the active list, which a stopped one leaves at the next update
7860
+ * @private */
7861
+ private listed;
7468
7862
  /** The update it was started in, it first moves on the one after
7469
7863
  * @private */
7470
7864
  private activePass;
@@ -7479,9 +7873,9 @@ declare module "littlejsengine" {
7479
7873
  target: {
7480
7874
  destroyed?: boolean;
7481
7875
  } | undefined;
7482
- /** Set the easing curve and return this for chaining.
7876
+ /** Set the easing curve and return this for chaining
7483
7877
  * @param {function(number):number} easeFn
7484
- * @returns {Tween<T>} */
7878
+ * @return {Tween<T>} */
7485
7879
  setEase(easeFn: (arg0: number) => number): Tween<T>;
7486
7880
  /** Set the completion callback, `onComplete`, and return this for chaining.
7487
7881
  * It is called once the tween completes: when its pass ends, or for a
@@ -7491,7 +7885,7 @@ declare module "littlejsengine" {
7491
7885
  * - It is kept by `restart`, so a restarted tween calls it again when it completes
7492
7886
  * - `stop` and `tweenStopAll` end a tween without calling it
7493
7887
  * @param {function():void} callback
7494
- * @returns {Tween<T>} */
7888
+ * @return {Tween<T>} */
7495
7889
  then(callback: () => void): Tween<T>;
7496
7890
  /** Repeat this tween `n` total times. After each iteration finishes, the
7497
7891
  * same tween starts over, so the handle returned stays good for the whole
@@ -7502,7 +7896,7 @@ declare module "littlejsengine" {
7502
7896
  * A `then` callback, set before or after, is called when the last
7503
7897
  * iteration ends.
7504
7898
  * @param {number} [count=Infinity]
7505
- * @returns {Tween<T>} */
7899
+ * @return {Tween<T>} */
7506
7900
  loop(count?: number): Tween<T>;
7507
7901
  /** Like `loop`, but swap `start` and `end` between iterations so the value
7508
7902
  * bounces back and forth. `pingPong()` with no argument bounces forever.
@@ -7511,11 +7905,11 @@ declare module "littlejsengine" {
7511
7905
  * A `then` callback, set before or after, is called when the last
7512
7906
  * iteration ends.
7513
7907
  * @param {number} [count=Infinity]
7514
- * @returns {Tween<T>} */
7908
+ * @return {Tween<T>} */
7515
7909
  pingPong(count?: number): Tween<T>;
7516
- /** Pause this tween. While paused, tweenUpdate skips it. */
7910
+ /** Pause this tween. While paused, tweenUpdate skips it */
7517
7911
  pause(): void;
7518
- /** Resume a paused tween. */
7912
+ /** Resume a paused tween */
7519
7913
  resume(): void;
7520
7914
  /** Reset this tween to the start: life back to duration, pause cleared,
7521
7915
  * re-added to the active list if previously stopped, and the callback
@@ -7526,17 +7920,17 @@ declare module "littlejsengine" {
7526
7920
  * after restart to repeat it. The `then` callback is kept and is called
7527
7921
  * again when it completes. */
7528
7922
  restart(): void;
7529
- /** True if this tween is in the active list and not paused.
7530
- * @returns {boolean} */
7923
+ /** True if this tween is in the active list and not paused
7924
+ * @return {boolean} */
7531
7925
  isActive(): boolean;
7532
7926
  /** Get how far this tween has progressed, from 0 (just started) to 1
7533
7927
  * (completed). Clamped — overshoot past completion still reads 1.
7534
- * @returns {number} */
7928
+ * @return {number} */
7535
7929
  getPercent(): number;
7536
7930
  /** Get the current interpolated value (the value most recently passed to
7537
7931
  * the callback). Returns a number, Vector2, Vector3 or Color depending on the
7538
7932
  * tween's start/end types.
7539
- * @returns {T} */
7933
+ * @return {T} */
7540
7934
  getValue(): T;
7541
7935
  /** Compute the interpolated value at the given remaining `life`.
7542
7936
  * At life === duration the result is `start`; at life === 0 it is `end`.
@@ -7544,7 +7938,7 @@ declare module "littlejsengine" {
7544
7938
  * - A vector goes past its ends as far as the easing does, as a number does; a Color stays between them,
7545
7939
  * so its channels stay in range, and any other type goes as far as its own lerp takes it
7546
7940
  * @param {number} life
7547
- * @returns {T} */
7941
+ * @return {T} */
7548
7942
  interp(life: number): T;
7549
7943
  /** Remove this tween from the active list, ending a loop or pingPong too, without calling
7550
7944
  * the then-callback. It keeps the then-callback, so a restart calls it when it completes. */
@@ -7565,12 +7959,12 @@ declare module "littlejsengine" {
7565
7959
  * @param {string} propertyPath - Dot-separated path, e.g. `'pos.x'` or `'color'`
7566
7960
  * @param {T} start - Starting value
7567
7961
  * @param {T} end - Ending value
7568
- * @param {number} [duration=1] - Duration in seconds
7962
+ * @param {number} [duration] - Duration in seconds
7569
7963
  * @param {Object} [options] - Same options as the Tween constructor
7570
7964
  * @param {function(number):number} [options.ease] - Easing function (defaults to LINEAR)
7571
7965
  * @param {boolean} [options.useRealTime=false] - Advance even when the game is paused
7572
7966
  * @param {boolean} [options.paused=false] - Start in paused state
7573
- * @returns {Tween<T>}
7967
+ * @return {Tween<T>}
7574
7968
  * @memberof TweenSystem
7575
7969
  * @example
7576
7970
  * // Numeric: slide an object's x with an ease-out sine curve
@@ -7697,7 +8091,7 @@ declare module "littlejsengine" {
7697
8091
  * @return {function(OffscreenCanvasRenderingContext2D, Vector2): void}
7698
8092
  * @memberof Parallax */
7699
8093
  export function parallaxMountains(topColor?: Color, bottomColor?: Color, seed?: number): (arg0: OffscreenCanvasRenderingContext2D, arg1: Vector2) => void;
7700
- /** Grid pathfinder using A* with two optional smoothing passes.
8094
+ /** Grid pathfinder using A* with two optional smoothing passes
7701
8095
  * @memberof PathFinding
7702
8096
  * @example
7703
8097
  * // Tile-layer driven (most common):
@@ -7709,7 +8103,8 @@ declare module "littlejsengine" {
7709
8103
  * gridFinder.isWalkable = (x, y) => myGrid[y*50 + x] === 0;
7710
8104
  */
7711
8105
  export class PathFinder {
7712
- /** @param {TileCollisionLayer|Vector2} source - Either a TileCollisionLayer
8106
+ /** Make a path finder over a tile layer or a grid
8107
+ * @param {TileCollisionLayer|Vector2} source - Either a TileCollisionLayer
7713
8108
  * (size and walkability auto-derived) or a Vector2 grid size (user
7714
8109
  * overrides isWalkable). */
7715
8110
  constructor(source: TileCollisionLayer | Vector2);
@@ -7750,27 +8145,27 @@ declare module "littlejsengine" {
7750
8145
  * the instance or via a subclass.
7751
8146
  * @param {number} x - Tile x
7752
8147
  * @param {number} y - Tile y
7753
- * @returns {boolean} */
8148
+ * @return {boolean} */
7754
8149
  isWalkable(x: number, y: number): boolean;
7755
8150
  /** Default extra cost for stepping on a cell. Returns 0 (free) by default.
7756
8151
  * Override to add cost-weighted terrain (mud, swamp, etc).
7757
8152
  * @param {number} x - Tile x
7758
8153
  * @param {number} y - Tile y
7759
- * @returns {number} */
8154
+ * @return {number} */
7760
8155
  getCost(x: number, y: number): number;
7761
- /** Get the node at tile coords, or null if out of bounds.
8156
+ /** Get the node at tile coords, or null if out of bounds
7762
8157
  * @param {number} x
7763
8158
  * @param {number} y
7764
- * @returns {PathFinderNode|null} */
8159
+ * @return {PathFinderNode|null} */
7765
8160
  getNode(x: number, y: number): PathFinderNode | null;
7766
- /** Convert a world-space position to integer tile coords (no clamping).
8161
+ /** Convert a world-space position to integer tile coords (no clamping)
7767
8162
  * @param {Vector2} worldPos
7768
- * @returns {Vector2} */
8163
+ * @return {Vector2} */
7769
8164
  worldToTile(worldPos: Vector2): Vector2;
7770
- /** Convert integer tile coords to the world-space center of that tile.
8165
+ /** Convert integer tile coords to the world-space center of that tile
7771
8166
  * @param {number} x
7772
8167
  * @param {number} y
7773
- * @returns {Vector2} */
8168
+ * @return {Vector2} */
7774
8169
  tileToWorld(x: number, y: number): Vector2;
7775
8170
  /** Reset all nodes and re-populate walkable / cost / posWorld from the
7776
8171
  * current isWalkable / getCost overrides. Called at the start of
@@ -7781,7 +8176,7 @@ declare module "littlejsengine" {
7781
8176
  * reached; false on disconnected goal or maxLoop exhaustion, which sets searchGaveUp.
7782
8177
  * @param {PathFinderNode} startNode
7783
8178
  * @param {PathFinderNode} endNode
7784
- * @returns {boolean}
8179
+ * @return {boolean}
7785
8180
  * @private */
7786
8181
  private aStarSearch;
7787
8182
  /** Find the clear (walkable, zero-cost) node closest to the given world
@@ -7794,9 +8189,9 @@ declare module "littlejsengine" {
7794
8189
  * unchanged walkability, pass `rebuild=false` and call `buildNodeData()`
7795
8190
  * once externally to avoid redundant work.
7796
8191
  * @param {Vector2} worldPos
7797
- * @param {number} [searchRange=10] - Max box-radius in tiles
7798
- * @param {boolean} [rebuild=true] - Whether to call buildNodeData first
7799
- * @returns {PathFinderNode|null} */
8192
+ * @param {number} [searchRange] - Max box-radius in tiles
8193
+ * @param {boolean} [rebuild] - Whether to call buildNodeData first
8194
+ * @return {PathFinderNode|null} */
7800
8195
  getNearestClearNode(worldPos: Vector2, searchRange?: number, rebuild?: boolean): PathFinderNode | null;
7801
8196
  /** Smooth a node path by removing redundant turns and tightening corners
7802
8197
  * where a grid-aligned diagonal is clear. Modifies the path in place.
@@ -7831,7 +8226,7 @@ declare module "littlejsengine" {
7831
8226
  * and clear (walkable, zero-cost). Used by isLineClear's hot path.
7832
8227
  * @param {number} x
7833
8228
  * @param {number} y
7834
- * @returns {boolean}
8229
+ * @return {boolean}
7835
8230
  * @private */
7836
8231
  private isNodeClear;
7837
8232
  /** Check that the line between two tile-coord endpoints stays entirely
@@ -7843,7 +8238,7 @@ declare module "littlejsengine" {
7843
8238
  * CheckLine() in pathFinding.cpp.
7844
8239
  * @param {Vector2} startPos - Tile coords
7845
8240
  * @param {Vector2} endPos - Tile coords
7846
- * @returns {boolean}
8241
+ * @return {boolean}
7847
8242
  * @private */
7848
8243
  private isLineClear;
7849
8244
  /** Find a path from startPos to endPos in world space. Returns an array
@@ -7860,7 +8255,7 @@ declare module "littlejsengine" {
7860
8255
  * @param {Vector2} startPos - World-space start
7861
8256
  * @param {Vector2} endPos - World-space end
7862
8257
  * @param {boolean} [rebuild] - Whether to call buildNodeData first
7863
- * @returns {Vector2[]} */
8258
+ * @return {Vector2[]} */
7864
8259
  findPath(startPos: Vector2, endPos: Vector2, rebuild?: boolean): Vector2[];
7865
8260
  }
7866
8261
  /** A single grid cell tracked by the pathfinder. Allocated once per cell at
@@ -7868,7 +8263,8 @@ declare module "littlejsengine" {
7868
8263
  * findPath call.
7869
8264
  * @memberof PathFinding */
7870
8265
  export class PathFinderNode {
7871
- /** @param {number} x - Tile x
8266
+ /** Make the node of a grid cell, as PathFinder does for each
8267
+ * @param {number} x - Tile x
7872
8268
  * @param {number} y - Tile y */
7873
8269
  constructor(x: number, y: number);
7874
8270
  /** @property {Vector2} - Tile coords (integer) */
@@ -7896,9 +8292,10 @@ declare module "littlejsengine" {
7896
8292
  heapIndex: number;
7897
8293
  /** Clear what a search left on this node, keeping walkable and cost */
7898
8294
  resetSearch(): void;
7899
- /** Reset per-search state and walkability (called by buildNodeData). */
8295
+ /** Reset per-search state and walkability (called by buildNodeData) */
7900
8296
  reset(): void;
7901
- /** True if walkable and not blocked by cost. */
8297
+ /** True if walkable and not blocked by cost
8298
+ * @return {boolean} */
7902
8299
  isClear(): boolean;
7903
8300
  }
7904
8301
  /** Options for a tweak
@@ -8392,8 +8789,9 @@ declare module "littlejsengine" {
8392
8789
  * - The 3D scene draws under the 2D sprites, so HUD and text land on top
8393
8790
  * - Lighting is the sun plus ambient, with optional extra lights, fog and shadows
8394
8791
  * - Any object or draw can bring its own Shader, a mainImage snippet the lighting then applies to
8395
- * - Build shapes with buildBox, buildSphere, buildGrid and buildLathe; the other builders, terrain, particles,
8396
- * camera controls and the OBJ loader are in the Render3D Extras plugin, which goes after this one
8792
+ * - Meshes and the basic builders are in render3dMesh.js, EngineObject3D, instancing and lights in
8793
+ * render3dObject.js, both right after this one; the other builders, terrain, particles, camera controls and the
8794
+ * OBJ loader are in the Render3D Extras plugin, which goes after those
8397
8795
  * - Requires the Math3D plugin
8398
8796
  * @namespace Render3D
8399
8797
  */
@@ -8488,6 +8886,18 @@ declare module "littlejsengine" {
8488
8886
  /** @property {Mesh|undefined} - Sky dome from buildSky or setSky, drawn around the camera behind everything
8489
8887
  * @type {Mesh|undefined} */
8490
8888
  sky: Mesh | undefined;
8889
+ /** @property {CubeMap|undefined} - A cube map drawn as the sky, behind everything, in place of the sky dome;
8890
+ * an orthographic camera looks the same way through every pixel, so it sees one color of it; fog fades to
8891
+ * fogColor, not to the sky box, so with fog set fogColor to its horizon's color
8892
+ * @type {CubeMap|undefined} */
8893
+ skyBox: CubeMap | undefined;
8894
+ /** @property {CubeMap|undefined} - The world around, what reflective surfaces reflect: an object's
8895
+ * reflectivity says how much and its shininess how sharp, the same shininess that tightens its highlight:
8896
+ * 10000 a mirror, 1000 polished, 10 a wide blur; undefined reflects the sky's colors as setSky gave them; a cube map holds GPU
8897
+ * memory until its dispose(), so one made again and again, as for a sky that changes, disposes the one it
8898
+ * replaces, or a captured one is captured into again
8899
+ * @type {CubeMap|undefined} */
8900
+ environment: CubeMap | undefined;
8491
8901
  /** @property {boolean} - Draw the 3D scene on top of the 2D scene instead of under it */
8492
8902
  renderAfter2D: boolean;
8493
8903
  /** @property {boolean} - Draw see through things far to near so they blend correctly */
@@ -8548,6 +8958,19 @@ declare module "littlejsengine" {
8548
8958
  shadowShader: WebGLProgram | undefined;
8549
8959
  /** @type {WebGLVertexArrayObject|undefined} */
8550
8960
  vao: WebGLVertexArrayObject | undefined;
8961
+ /** @type {Set<CubeMap>} */
8962
+ cubeCaptures: Set<CubeMap>;
8963
+ /** @type {CubeMap|undefined} */
8964
+ capturingCube: CubeMap | undefined;
8965
+ /** @type {WebGLFramebuffer|undefined} */
8966
+ captureFramebuffer: WebGLFramebuffer | undefined;
8967
+ /** @type {WebGLRenderbuffer|undefined} */
8968
+ captureDepth: WebGLRenderbuffer | undefined;
8969
+ captureDepthSize: number;
8970
+ /** @type {WebGLProgram|undefined} */
8971
+ skyBoxProgram: WebGLProgram | undefined;
8972
+ /** @type {WebGLVertexArrayObject|undefined} */
8973
+ skyBoxVao: WebGLVertexArrayObject | undefined;
8551
8974
  /** @type {WebGLTexture|undefined} */
8552
8975
  whiteTexture: WebGLTexture | undefined;
8553
8976
  /** @type {Map<number, WebGLSampler>} */
@@ -8567,7 +8990,10 @@ declare module "littlejsengine" {
8567
8990
  cameraDepthHeight: number;
8568
8991
  depthPass: boolean;
8569
8992
  contextGeneration: number;
8570
- uniforms: Map<any, any>;
8993
+ /** @type {WeakMap<WebGLProgram, Object<string, WebGLUniformLocation|null>>} */
8994
+ uniforms: WeakMap<WebGLProgram, {
8995
+ [x: string]: WebGLUniformLocation | null;
8996
+ }>;
8571
8997
  /** @type {Object<string, Array<number>>} */
8572
8998
  uniformValues: {
8573
8999
  [x: string]: Array<number>;
@@ -8594,7 +9020,8 @@ declare module "littlejsengine" {
8594
9020
  streamCount: number;
8595
9021
  /** @type {TextureInfo|undefined} */
8596
9022
  streamTileInfo: TextureInfo | undefined;
8597
- streamState: any;
9023
+ /** @type {Object|undefined} */
9024
+ streamState: any | undefined;
8598
9025
  streamUnlit: boolean;
8599
9026
  /** @type {Mesh|undefined} */
8600
9027
  capture: Mesh | undefined;
@@ -8663,6 +9090,10 @@ declare module "littlejsengine" {
8663
9090
  /** Emissive map for the next draws, set from each object's emissiveMap
8664
9091
  * @return {TextureInfo|undefined} */
8665
9092
  get emissiveMap(): TextureInfo | undefined;
9093
+ set environmentMap(arg: CubeMap | undefined);
9094
+ /** The cube map the next draws reflect in place of render3D.environment, set from each object's environment
9095
+ * @return {CubeMap|undefined} */
9096
+ get environmentMap(): CubeMap | undefined;
8666
9097
  set emissiveMapColor(arg: Color);
8667
9098
  /** Multiplies the emissive map, set from each object's emissiveMapColor; compared by its rgb, so a Color
8668
9099
  * changed in place is seen when it is set again, and undefined is white
@@ -8805,7 +9236,8 @@ declare module "littlejsengine" {
8805
9236
  /** Draw the queued transparent draws far to near with the state each was drawn under, called automatically at the
8806
9237
  * end of the transparent stage */
8807
9238
  flushTransparentQueue(): void;
8808
- /** Draw render3D.sky around the camera, unlit, unfogged and behind everything, called automatically by the pass */
9239
+ /** Draw render3D.skyBox, or render3D.sky around the camera, unlit, unfogged and behind everything, called
9240
+ * automatically by the pass */
8809
9241
  drawSky(): void;
8810
9242
  /** Rebuild the light's view projection around the shadow center, called automatically each frame shadows are on */
8811
9243
  updateShadowMatrix(): void;
@@ -8892,6 +9324,78 @@ declare module "littlejsengine" {
8892
9324
  * @return {void} */
8893
9325
  drawSoftShadow(pos: Vector3, size?: number, floorHeight?: number | HeightMap | ((arg0: number, arg1: number) => number), color?: Color, lift?: number): void;
8894
9326
  }
9327
+ /**
9328
+ * CubeMap - Six square images all around a point, the world far away: what reflective surfaces reflect as
9329
+ * render3D.environment, and the sky as render3D.skyBox
9330
+ * - makeCubeMap paints one from a function of direction, loadCubeMap loads six images
9331
+ * - Made with no faces it is drawn from the scene: capture(pos3D) draws everything around that point into it in the
9332
+ * next frame's 3D pass, six views of the whole scene, so capture once for a still scene or now and then for one
9333
+ * that moves
9334
+ * - Its faces are in WebGL's order and lay out, +x, -x, +y, -y, +z, -z: WebGL's cube is left handed, so in this right
9335
+ * handed world a face seen from the middle is mirrored; loadCubeMap turns a sky box set's images to it
9336
+ * @memberof Render3D
9337
+ * @example
9338
+ * render3D.environment = render3D.skyBox = makeCubeMap(64, (d)=> hsl(.6, .8, .4 + d.y * .4));
9339
+ * @example
9340
+ * // a chrome ball that reflects the scene around it, captured once
9341
+ * const ball = new EngineObject3D(vec3(0, 1, 0), render3D.sphereMesh, undefined, BLACK);
9342
+ * ball.reflectivity = 1;
9343
+ * ball.shininess = 1e4;
9344
+ * render3D.environment = new CubeMap(128);
9345
+ * render3D.environment.capture(ball.pos3D);
9346
+ */
9347
+ export class CubeMap {
9348
+ /** Make a cube map from its six faces, as makeCubeMap and loadCubeMap do, or with none to capture the scene into
9349
+ * @param {number} size - Pixels a side of each face
9350
+ * @param {Array<Uint8Array|HTMLImageElement|HTMLCanvasElement|ImageBitmap|OffscreenCanvas>} [faces] - +x, -x,
9351
+ * +y, -y, +z and -z, RGBA pixels row by row or images; none for a cube map drawn by capture */
9352
+ constructor(size: number, faces?: (Uint8Array | OffscreenCanvas | ImageBitmap | HTMLCanvasElement | HTMLImageElement)[]);
9353
+ /** @property {number} - Pixels a side of each face */
9354
+ size: number;
9355
+ /** @property {Array<Uint8Array|HTMLImageElement|HTMLCanvasElement|ImageBitmap|OffscreenCanvas>|undefined} -
9356
+ * Its faces, kept to upload again after a lost context, undefined for one drawn by capture
9357
+ * @type {Array<Uint8Array|HTMLImageElement|HTMLCanvasElement|ImageBitmap|OffscreenCanvas>|undefined} */
9358
+ faces: Array<Uint8Array | HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas> | undefined;
9359
+ /** @property {Vector3|undefined} - Where it was last captured from, and is captured from again after a lost
9360
+ * context
9361
+ * @type {Vector3|undefined} */
9362
+ capturePos: Vector3 | undefined;
9363
+ /** @type {WebGLTexture|undefined} */
9364
+ glTexture: WebGLTexture | undefined;
9365
+ contextGeneration: number;
9366
+ /** Draw the scene around a point into a cube map made with no faces, in the next frame's 3D pass
9367
+ * - Every object of the layer render3D.renderAfter2D picks is drawn, with the sky and the render callbacks; the
9368
+ * camera's near and far planes, the lights and the fog are the scene's
9369
+ * - It is six more draws of the scene, so capture once for a still scene, or every few frames for a moving one
9370
+ * - A closed mesh around the point, like the ball that reflects it, is not seen from inside, so it hides nothing
9371
+ * - While it is drawn, what would reflect it reflects the sky's colors in its place
9372
+ * - It is seen from one point, so it suits what is near that point best, give each mirror its own with
9373
+ * obj.environment
9374
+ * @param {Vector3} pos3D - The point it is seen from */
9375
+ capture(pos3D: Vector3): void;
9376
+ /** Free its texture, which is made again if it is used after */
9377
+ dispose(): void;
9378
+ }
9379
+ /** Make a cube map by asking a function the color of each direction
9380
+ * - The function gets a unit Vector3 for each pixel of each face and gives a Color
9381
+ * - It runs size * size * 6 times, so a size of 64 or 128 makes one at once, larger takes a moment
9382
+ * @param {number} size - Pixels a side of each face
9383
+ * @param {function(Vector3): Color} colorOf - The color seen looking that way
9384
+ * @return {CubeMap}
9385
+ * @example
9386
+ * // a sky, blue above and pale at the horizon, with a sun
9387
+ * const sun = vec3(1, 1, -1).normalize();
9388
+ * render3D.environment = makeCubeMap(64, (d)=> hsl(.6, .7, .9 - max(d.y, 0) * .5).lerp(WHITE, max(0, d.dot(sun)) ** 64));
9389
+ * @memberof Render3D */
9390
+ export function makeCubeMap(size: number, colorOf: (arg0: Vector3) => Color): CubeMap;
9391
+ /** Load a cube map from six square images of one size
9392
+ * - The images are a sky box set as three.js's CubeTextureLoader takes them, and show the same: each face seen from
9393
+ * inside as its image is drawn
9394
+ * @param {Array<string>} sources - The images of +x, -x, +y, -y, +z and -z, as a sky box set names them right,
9395
+ * left, top, bottom, front and back
9396
+ * @return {Promise<CubeMap>}
9397
+ * @memberof Render3D */
9398
+ export function loadCubeMap(sources: Array<string>): Promise<CubeMap>;
8895
9399
  /**
8896
9400
  * Camera3D - Position, rotation and lens for the 3D view
8897
9401
  * - Looks down its -Z axis, rotation is vec3(pitch, yaw, roll)
@@ -8910,7 +9414,8 @@ declare module "littlejsengine" {
8910
9414
  far: number;
8911
9415
  /** @property {number} - Visible height in world units for an orthographic view, 0 is perspective */
8912
9416
  orthographic: number;
8913
- /** @property {boolean} - Line the 3D camera up with the 2D camera, so 3D things at z=0 sit on the 2D sprites */
9417
+ /** @property {boolean} - Line the 3D camera up with the 2D camera, so 3D things at z=0 sit on the 2D sprites;
9418
+ * it lines up with the 2D view of the main canvas, whatever canvas size a screenToRay is given */
8914
9419
  align2D: boolean;
8915
9420
  /** Returns the camera's world transform
8916
9421
  * @return {Matrix4} */
@@ -9040,6 +9545,10 @@ declare module "littlejsengine" {
9040
9545
  emissiveMap: TextureInfo | undefined;
9041
9546
  /** @property {Color} - Multiplies the emissive map, as glTF's emissiveFactor */
9042
9547
  emissiveMapColor: Color;
9548
+ /** @property {CubeMap|undefined} - What it reflects in place of render3D.environment, as a mirror captures
9549
+ * the scene from its own middle
9550
+ * @type {CubeMap|undefined} */
9551
+ environment: CubeMap | undefined;
9043
9552
  /** @property {boolean} - Collide as the sphere that fits size3D instead of as the size3D box, so it rolls
9044
9553
  * around corners */
9045
9554
  collideAsSphere3D: boolean;
@@ -9062,6 +9571,10 @@ declare module "littlejsengine" {
9062
9571
  matrixParent: EngineObject3D | undefined;
9063
9572
  matrixParentVersion: number;
9064
9573
  movePass: number;
9574
+ collideFrom: Vector3;
9575
+ collideFromPass: number;
9576
+ /** @type {EngineObject3D|undefined} */
9577
+ drawOwner: EngineObject3D | undefined;
9065
9578
  /** Called by a VoxelMap to ask whether a block stops this object, a hook to let one through or react to it
9066
9579
  * @param {number} type - The block's type, 1 to 255
9067
9580
  * @param {Vector3} cell - The block's cell in the map
@@ -9084,6 +9597,13 @@ declare module "littlejsengine" {
9084
9597
  * cheap to call
9085
9598
  * @return {Matrix4} */
9086
9599
  getMatrix(): Matrix4;
9600
+ set roughness(arg: number);
9601
+ /** How rough the surface is, 0 a mirror to 1 matte, as glTF and three.js's MeshStandardMaterial have it: another
9602
+ * way to set shininess, which is what is kept, shininess = 2 / roughness^4 - 2 and at least 1; it sets both the
9603
+ * highlight and how blurred a reflection is; read back it is the same up to about .9, above which shininess is 1
9604
+ * and it reads .9
9605
+ * @return {number} */
9606
+ get roughness(): number;
9087
9607
  /** Turn the object so its -Z axis points at a world space target, sets pitch and yaw and clears roll
9088
9608
  * @param {Vector3} target */
9089
9609
  lookAt(target: Vector3): void;
@@ -9167,6 +9687,7 @@ declare module "littlejsengine" {
9167
9687
  pointCount: number;
9168
9688
  data: ArrayBuffer;
9169
9689
  } | undefined;
9690
+ vertexDataPacked: boolean;
9170
9691
  instanceCount: number;
9171
9692
  /** @type {Float32Array|undefined} */
9172
9693
  instanceData: Float32Array | undefined;
@@ -9752,7 +10273,8 @@ declare module "littlejsengine" {
9752
10273
  chunkTransparentMeshes: Array<Mesh | undefined>;
9753
10274
  /** @type {Array<Vector3>} */
9754
10275
  chunkCenters: Array<Vector3>;
9755
- chunksChanged: Set<any>;
10276
+ /** @type {Set<number>} */
10277
+ chunksChanged: Set<number>;
9756
10278
  /** @type {Array<{faces: Array<number>, seeThrough: boolean, transparent: boolean, doubleSided: boolean}|undefined>} */
9757
10279
  blockTypes: Array<{
9758
10280
  faces: Array<number>;
@@ -9760,7 +10282,8 @@ declare module "littlejsengine" {
9760
10282
  transparent: boolean;
9761
10283
  doubleSided: boolean;
9762
10284
  } | undefined>;
9763
- tiles: Map<any, any>;
10285
+ /** @type {Map<number, Array<Vector2>>} */
10286
+ tiles: Map<number, Array<Vector2>>;
9764
10287
  /** The block type at a cell, 0 for empty or outside the map
9765
10288
  * @param {Vector3} cell
9766
10289
  * @return {number} */
@@ -9852,7 +10375,8 @@ declare module "littlejsengine" {
9852
10375
  * @ignore */
9853
10376
  levelRaycast3D(ray: Ray3D): number | undefined;
9854
10377
  /** Where a short move goes into a block, for a particle's move in one frame: the part of the move made before it,
9855
- * 0 to 1, and the normal of the face it comes in through; undefined when it hits none, or starts inside one
10378
+ * 0 to 1, and the normal of the face it comes in through; undefined when it hits none, or starts inside one; a
10379
+ * move that starts on a block's face, coming in, hits it at 0
9856
10380
  * @param {Vector3} from
9857
10381
  * @param {Vector3} to
9858
10382
  * @return {{distance: number, normal: Vector3}|undefined}
@@ -10117,7 +10641,8 @@ declare module "littlejsengine" {
10117
10641
  /** @property {boolean} - Flatten the spawn area across the way it emits, its own up: a sphere becomes a disc
10118
10642
  * and a box a flat rectangle, for rain from a sheet of sky or flames from a patch of ground */
10119
10643
  emitFlat: boolean;
10120
- /** @property {number} - How long to keep emitting, 0 is forever */
10644
+ /** @property {number} - How long to keep emitting, 0 is forever; raised while its particles are still alive,
10645
+ * it emits again for the added time */
10121
10646
  emitTime: number;
10122
10647
  /** @property {number} - Particles per second, 0 does not emit */
10123
10648
  emitRate: number;
@@ -10183,10 +10708,16 @@ declare module "littlejsengine" {
10183
10708
  * @type {Vector3|undefined} */
10184
10709
  worldPos3D: Vector3 | undefined;
10185
10710
  emitTimeBuffer: number;
10711
+ emitElapsed: number;
10712
+ /** @type {Vector3|undefined} */
10713
+ emitFrom: Vector3 | undefined;
10714
+ emitBehind: number;
10186
10715
  /** Spawn one particle now */
10187
10716
  emitParticle(): void;
10188
- particleCall(callback: any, k: any, level: any, pos: any): any;
10189
- particleCollide(k: any, x: any, y: any, z: any): boolean;
10717
+ /** @private */
10718
+ private particleCall;
10719
+ /** @private */
10720
+ private particleCollide;
10190
10721
  }
10191
10722
  /**
10192
10723
  * Trail3D - A ribbon through where the object has been, thinning and fading with age
@@ -10308,8 +10839,9 @@ declare module "littlejsengine" {
10308
10839
  /** @property {number} - Seconds the flare takes to fade out or in when the sun is hidden or shows again */
10309
10840
  fadeTime: number;
10310
10841
  /** @property {number} - How much of the sun shows, 0 hidden, off the screen or behind the camera to 1 in
10311
- * plain view, eased */
10842
+ * plain view, eased; the first update sets it at once, so a sun hidden from the start never shows */
10312
10843
  visible: number;
10844
+ visibleFound: boolean;
10313
10845
  madeKey: string;
10314
10846
  /** @type {Array<LensFlareElement>} */
10315
10847
  made: Array<LensFlareElement>;
@@ -10360,6 +10892,11 @@ declare module "littlejsengine" {
10360
10892
  * it is doubleSided
10361
10893
  * @return {boolean} */
10362
10894
  isHidden(): boolean;
10895
+ /** Ease visible toward whether the sun shows over some seconds; the first time it is found at once, from the
10896
+ * camera as it is, its matrices made, by the first update or the first draw, whichever comes first
10897
+ * @param {number} seconds
10898
+ * @ignore */
10899
+ updateVisible(seconds: number): void;
10363
10900
  }
10364
10901
  /**
10365
10902
  * Collect the EngineObject3D objects whose boxes overlap a sphere or a box, the 3D twin of engineObjectsCollect
@@ -10423,14 +10960,22 @@ declare module "littlejsengine" {
10423
10960
  * @memberof GLTF
10424
10961
  */
10425
10962
  export class GLTFModel {
10426
- /** @param {Array<GLTFPart>} parts @param {Array<GLTFAnimation>} [animations] @param {Object} [nodeTree] */
10963
+ /** Make a model from its parts, as the loader does
10964
+ * @param {Array<GLTFPart>} parts @param {Array<GLTFAnimation>} [animations] @param {Object} [nodeTree] */
10427
10965
  constructor(parts: Array<GLTFPart>, animations?: GLTFAnimation[], nodeTree?: any);
10428
10966
  /** @property {Array<GLTFPart>} - One per primitive of every node that has a mesh */
10429
10967
  parts: GLTFPart[];
10430
10968
  /** @property {Array<GLTFAnimation>} - The animations, play one through createObject's GLTFObject
10431
10969
  * @type {Array<GLTFAnimation>} */
10432
10970
  animations: Array<GLTFAnimation>;
10433
- nodeTree: any;
10971
+ /** @type {{nodes: Array<Object>, parents: Array<number|undefined>, restInverse: Array<Matrix4>,
10972
+ * restPose: Array<Matrix4|undefined>}|undefined} */
10973
+ nodeTree: {
10974
+ nodes: Array<any>;
10975
+ parents: Array<number | undefined>;
10976
+ restInverse: Array<Matrix4>;
10977
+ restPose: Array<Matrix4 | undefined>;
10978
+ } | undefined;
10434
10979
  modelMatrix: Matrix4;
10435
10980
  /** @property {Mesh} - Every part combined, each tinted with its material color; the texture is textureInfo,
10436
10981
  * and blending and unlit stay with the parts, which createObject draws */
@@ -10470,6 +11015,7 @@ declare module "littlejsengine" {
10470
11015
  * @param {number} time - Seconds into it
10471
11016
  * @return {Array<Matrix4>} */
10472
11017
  getPose(animation: GLTFAnimation, time: number): Array<Matrix4>;
11018
+ partPoses(worldOf: any): Matrix4[];
10473
11019
  /** Free the GPU buffers of every part's mesh and of the combined mesh, and the textures, for a model that is
10474
11020
  * done with, like a level's models when the next level loads
10475
11021
  * - Destroy the objects createObject made from it first; a mesh drawn again only uploads again, but a freed
@@ -10487,9 +11033,11 @@ declare module "littlejsengine" {
10487
11033
  * - Loads glTF 2.0 models: a .gltf with its .bin and images beside it, or a .glb with everything in one file
10488
11034
  * - A model comes back as parts, one Mesh per primitive of every node placed by the node tree, each with its
10489
11035
  * material's color and base color texture, plus everything combined into one Mesh
10490
- * - Geometry: positions, normals, uvs, vertex colors and indices; skins and morph targets are not read
10491
- * - Node animations play: parts that move, turn and scale, like doors, wheels and propellers, through the
10492
- * GLTFObject that createObject makes; a skinned character's walk is not read
11036
+ * - Geometry: positions, normals, uvs, vertex colors and indices, and skins, the four strongest joints of a vertex
11037
+ * of up to eight; morph targets are not read
11038
+ * - Animations play through the GLTFObject that createObject makes: parts that move, turn and scale, like doors,
11039
+ * wheels and propellers, and skinned characters, their meshes bent by their joints each frame; play takes a
11040
+ * blend time to cross-fade from one animation to the next
10493
11041
  * - Materials give a base color and texture and whether they blend; glass made with KHR_materials_transmission blends too,
10494
11042
  * and a KHR_materials_unlit material comes in emissive, its own color with no shading
10495
11043
  * - A material's normal map and emissive map load too, with its normal scale and emissive factor, read at the base
@@ -10507,6 +11055,7 @@ declare module "littlejsengine" {
10507
11055
  * const model = await loadGLTF('ship.glb'); // in an async gameInit
10508
11056
  * const ship = model.createObject(vec3(0, 1, 0)); // an object with a child per part, textures and all
10509
11057
  * ship.play('fly'); // and its animation, by name or number
11058
+ * ship.play('land', false, 1, .3); // then another, cross-faded over .3 seconds
10510
11059
  * new EngineObject3D(vec3(), model.mesh); // or the whole thing as one mesh, still
10511
11060
  */
10512
11061
  /**
@@ -10514,7 +11063,8 @@ declare module "littlejsengine" {
10514
11063
  * @memberof GLTF
10515
11064
  */
10516
11065
  export class GLTFPart {
10517
- /** @param {string} name @param {Mesh} mesh @param {Color} color @param {TextureInfo|undefined} textureInfo @param {boolean} transparent */
11066
+ /** Make a part, as the loader does for each primitive
11067
+ * @param {string} name @param {Mesh} mesh @param {Color} color @param {TextureInfo|undefined} textureInfo @param {boolean} transparent */
10518
11068
  constructor(name: string, mesh: Mesh, color: Color, textureInfo: TextureInfo | undefined, transparent: boolean);
10519
11069
  /** @property {string} - The node's name, or its mesh's */
10520
11070
  name: string;
@@ -10547,6 +11097,15 @@ declare module "littlejsengine" {
10547
11097
  emissiveMap: TextureInfo | undefined;
10548
11098
  /** @property {Color} - The emissiveFactor, which multiplies the emissive map */
10549
11099
  emissiveMapColor: Color;
11100
+ /** @property {number} - The material's roughnessFactor, 0 a mirror to 1 matte, 1 when it has none as the
11101
+ * format says; the object createObject makes takes it as its roughness, which sets its shininess */
11102
+ roughness: number;
11103
+ /** @property {GLTFSkin|undefined} - For a skinned mesh, what bends it: mesh is its resting pose, and the
11104
+ * object createObject makes bends a copy of its own to each pose
11105
+ * @type {GLTFSkin|undefined} */
11106
+ skin: GLTFSkin | undefined;
11107
+ /** @type {Array<number>|undefined} */
11108
+ vertexSource: Array<number> | undefined;
10550
11109
  }
10551
11110
  /**
10552
11111
  * GLTFObject - A model as an object with a child per part, which plays the model's animations
@@ -10577,28 +11136,65 @@ declare module "littlejsengine" {
10577
11136
  animationLoop: boolean;
10578
11137
  /** @property {boolean} - Whether it is moving through the animation now */
10579
11138
  animationPlaying: boolean;
11139
+ /** @type {{animation?: GLTFAnimation, time?: number, speed?: number, loop?: boolean, nodes?: Map<number, Object>}|undefined} */
11140
+ blendFrom: {
11141
+ animation?: GLTFAnimation;
11142
+ time?: number;
11143
+ speed?: number;
11144
+ loop?: boolean;
11145
+ nodes?: Map<number, any>;
11146
+ } | undefined;
11147
+ blendTime: number;
11148
+ blendElapsed: number;
11149
+ /** @type {Map<number, Object>|undefined} */
11150
+ poseNodes: Map<number, any> | undefined;
11151
+ poseMixed: boolean;
11152
+ /** @type {(function(number): Matrix4)|undefined} */
11153
+ poseWorldOf: ((arg0: number) => Matrix4) | undefined;
10580
11154
  /** @property {Array<EngineObject3D>} - The child that draws each of the model's parts, in the order of
10581
11155
  * model.parts, which an animation poses; one destroyed or taken off the object is left alone
10582
11156
  * @type {Array<EngineObject3D>} */
10583
11157
  parts: Array<EngineObject3D>;
10584
- /** Play an animation from its start
11158
+ /** Play an animation from its start, at once or cross-faded from the pose it is in
11159
+ * - A play with a blend of the animation already playing goes on with it, so state code may call it each
11160
+ * frame; without a blend it starts the animation again
10585
11161
  * @param {string|number|GLTFAnimation} [animation] - Its name, its number in model.animations, or itself
10586
11162
  * @param {boolean} [loop] - Start again at the end, or stop there
10587
- * @param {number} [speed] - 1 is as made, negative plays it backward from its end */
10588
- play(animation?: string | number | GLTFAnimation, loop?: boolean, speed?: number): void;
10589
- /** Stop the animation where it is, the parts hold that pose */
11163
+ * @param {number} [speed] - 1 is as made, negative plays it backward from its end
11164
+ * @param {number} [blend] - Seconds to cross-fade from the pose it is in, 0 to switch at once; the animation
11165
+ * it comes from goes on through the fade, and a fade started during another fades from the mix there */
11166
+ play(animation?: string | number | GLTFAnimation, loop?: boolean, speed?: number, blend?: number): void;
11167
+ /** Stop the animation where it is, the parts hold that pose; a cross-fade going on stops too, holding the mix */
10590
11168
  stop(): void;
10591
11169
  /** Put the parts where the animation has them at a time, playing or not
10592
11170
  * @param {number} time - Seconds into the animation */
10593
11171
  setAnimationTime(time: number): void;
11172
+ /** A node's matrix in the world as the model is posed now, by its name in the file, to hang something on a
11173
+ * joint, a sword on a hand or a hat on a head; undefined when the model has no node of that name
11174
+ * @param {string} name
11175
+ * @return {Matrix4|undefined} */
11176
+ getJointMatrix(name: string): Matrix4 | undefined;
10594
11177
  }
11178
+ /**
11179
+ * What bends a skinned part: its joints, the nodes that move it, their inverse bind matrices, and for each vertex
11180
+ * of its mesh four joints and four weights, with the place and normal each pose bends from
11181
+ * @typedef {Object} GLTFSkin
11182
+ * @property {Array<number>} joints - The joints, as node numbers
11183
+ * @property {Array<Matrix4>} inverseBind - Each joint's inverse bind matrix
11184
+ * @property {Uint16Array} vertexJoints - Four joints a vertex, as places in joints
11185
+ * @property {Float32Array} vertexWeights - Four weights a vertex, summing to 1
11186
+ * @property {Float32Array} bindPoints - Each vertex's place as stored, x y z
11187
+ * @property {Float32Array} bindNormals - Each vertex's normal as stored, x y z
11188
+ * @memberof GLTF
11189
+ */
10595
11190
  /**
10596
11191
  * GLTFAnimation - One animation of a model: keys that move, turn and scale its nodes over time
10597
11192
  * - Play it through the GLTFObject that model.createObject makes
10598
11193
  * @memberof GLTF
10599
11194
  */
10600
11195
  export class GLTFAnimation {
10601
- /** @param {string} name @param {Array<Object>} channels */
11196
+ /** Make an animation from its channels, as the loader does
11197
+ * @param {string} name @param {Array<Object>} channels */
10602
11198
  constructor(name: string, channels: Array<any>);
10603
11199
  /** @property {string} - Its name in the file, or 'animation' and its number when it has none */
10604
11200
  name: string;
@@ -10618,7 +11214,7 @@ declare module "littlejsengine" {
10618
11214
  * is fetched then
10619
11215
  * - 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
11216
  * a warning and left out
10621
- * @param {ArrayBuffer|Object|string} data - GLB bytes, or the glTF JSON as bytes, text or an object
11217
+ * @param {ArrayBuffer|ArrayBufferView|Object<string, any>|string} data - GLB bytes, or the glTF JSON as bytes, text or an object
10622
11218
  * @param {string} [baseUrl] - Where the .bin and image files are, with its trailing slash; loadGLTF passes the file's folder
10623
11219
  * @param {Map<string, Blob>} [files] - The files it refers to, by their paths, in place of fetching them
10624
11220
  * @return {Promise<GLTFModel>}
@@ -10628,7 +11224,9 @@ declare module "littlejsengine" {
10628
11224
  * const gltf = [...files.values()].find((file)=> file.name.endsWith('.gltf'));
10629
11225
  * const model = await parseGLTF(await gltf.text(), '', files);
10630
11226
  * @memberof GLTF */
10631
- export function parseGLTF(data: ArrayBuffer | any | string, baseUrl?: string, files?: Map<string, Blob>): Promise<GLTFModel>;
11227
+ export function parseGLTF(data: ArrayBuffer | ArrayBufferView | {
11228
+ [x: string]: any;
11229
+ } | string, baseUrl?: string, files?: Map<string, Blob>): Promise<GLTFModel>;
10632
11230
  /** Load a glTF or GLB model, the .bin and images of a .gltf from beside it
10633
11231
  * - A texture only OPAQUE materials use loads with its alpha set to 1, so the 3D pass cuts no holes in it
10634
11232
  * @param {string} url
@@ -10677,13 +11275,15 @@ declare module "littlejsengine" {
10677
11275
  * - Adding a name again replaces it, Box, Sphere, Cylinder and Light too
10678
11276
  * @param {string} name - The type the objects have in the level
10679
11277
  * @param {Function} make - A class made at each object's position, or a function called with it
10680
- * @param {Object} [defaults] - Properties of each one made, the level editor shows inputs for them
11278
+ * @param {Object<string, any>} [defaults] - Properties of each one made, the level editor shows inputs for them
10681
11279
  * @param {TileInfo} [tileInfo] - An icon for the level editor
10682
11280
  * @memberof Level3D
10683
11281
  * @example
10684
11282
  * level3DAddType('Crate', Crate, {health: 3});
10685
11283
  * level3DAddType('PlayerStart', (pos)=> playerStart = pos); */
10686
- export function level3DAddType(name: string, make: Function, defaults?: any, tileInfo?: TileInfo): void;
11284
+ export function level3DAddType(name: string, make: Function, defaults?: {
11285
+ [x: string]: any;
11286
+ }, tileInfo?: TileInfo): void;
10687
11287
  /** Add a type that is a mesh and nothing more, a static prop with no class to write, for a built mesh or a model
10688
11288
  * - Each object has a color and a solid property, solid collides as the box around the mesh
10689
11289
  * @param {string} name - The type the objects have in the level
@@ -10714,13 +11314,14 @@ declare module "littlejsengine" {
10714
11314
  * are added before its objects are made, one the game added itself keeps its place
10715
11315
  * - A level may set the scene too, in a scene block beside its objects: sky, three colors for straight up, the
10716
11316
  * horizon and straight down, ambient, how much of them lights the scene, .5 when not given, sunDirection and
10717
- * sunColor, fog, its start and end, fogColor, the horizon color when not given, shadows, and lensFlare, the
10718
- * sun's lens flare; what the block leaves out stays as the game set it, and a level with no block changes
10719
- * nothing
10720
- * @param {Object} level - The level, the level editor edits this same object
11317
+ * sunColor, fog, its start and end, fogColor, the horizon color when not given, shadows, lensFlare, the
11318
+ * sun's lens flare, and skyBox and environment, each six image urls as loadCubeMap takes them, which load in
11319
+ * the background and are set when they have; what the block leaves out stays as the game set it, and a level
11320
+ * with no block changes nothing
11321
+ * @param {Level3D} level - The level, the level editor edits this same object
10721
11322
  * @return {Array<any>} - What each object's type made, a function that made nothing is left out
10722
11323
  * @memberof Level3D */
10723
- export function level3DLoad(level: any): Array<any>;
11324
+ export function level3DLoad(level: Level3D): Array<any>;
10724
11325
  /** Add a prefab: a small level, its objects placed about its own origin, to place many times under one name
10725
11326
  * - It is a type from then on: a level's object of that type, the level editor's Place list and level3DSpawn make
10726
11327
  * an instance, a Prefab3D; an instance is made of the prefab as it is then, so the level editor, where a prefab
@@ -10733,13 +11334,17 @@ declare module "littlejsengine" {
10733
11334
  * by hand does
10734
11335
  * - Adding a name again replaces it
10735
11336
  * @param {string} name - The type its instances have in a level
10736
- * @param {Object} prefab - {objects, attached}
11337
+ * @param {{objects: Array<Object>, attached?: boolean}} prefab - Its objects, about its own origin, and whether
11338
+ * they are attached
10737
11339
  * @memberof Level3D
10738
11340
  * @example
10739
11341
  * level3DAddPrefab('Tower', {objects: [{type: 'Box', pos: [0, 1, 0], scale: [2, 2, 2]},
10740
11342
  * {type: 'Cylinder', pos: [0, 3, 0]}]});
10741
11343
  * level3DLoad({objects: [{type: 'Tower', pos: [5, 0, 5]}, {type: 'Tower', pos: [-5, 0, 5], rotation: [0, 45, 0]}]}); */
10742
- export function level3DAddPrefab(name: string, prefab: any): void;
11344
+ export function level3DAddPrefab(name: string, prefab: {
11345
+ objects: Array<any>;
11346
+ attached?: boolean;
11347
+ }): void;
10743
11348
  /** Load a prefab from a file the level editor saved and add it
10744
11349
  * @param {string} name - The type its instances have in a level
10745
11350
  * @param {string} url
@@ -10752,13 +11357,15 @@ declare module "littlejsengine" {
10752
11357
  * @param {Vector3} [pos3D]
10753
11358
  * @param {Vector3} [rotation3D] - In radians, as an object has it
10754
11359
  * @param {Vector3} [scale3D] - Times the scale the type makes it with
10755
- * @param {Object} [properties] - Over the type's defaults
11360
+ * @param {Object<string, any>} [properties] - Over the type's defaults
10756
11361
  * @return {any} - What the type made, a Prefab3D for a prefab, undefined when there is no such type
10757
11362
  * @memberof Level3D
10758
11363
  * @example
10759
11364
  * level3DAddPrefab('House', await fetchJSON('house.json'));
10760
11365
  * level3DSpawn('House', vec3(10, 0, 0), vec3(0, PI/2, 0)); */
10761
- export function level3DSpawn(type: string, pos3D?: Vector3, rotation3D?: Vector3, scale3D?: Vector3, properties?: any): any;
11366
+ export function level3DSpawn(type: string, pos3D?: Vector3, rotation3D?: Vector3, scale3D?: Vector3, properties?: {
11367
+ [x: string]: any;
11368
+ }): any;
10762
11369
  /**
10763
11370
  * An instance of a prefab, what a prefab's type makes: a handle with no shape of its own, and its parts, what the
10764
11371
  * prefab's objects made
@@ -10777,13 +11384,22 @@ declare module "littlejsengine" {
10777
11384
  prefabName: string;
10778
11385
  /** @property {boolean} - Are its parts its children, moving with it as one body */
10779
11386
  attached: boolean;
10780
- /** @property {Array<any>} - What the prefab's objects made, in the prefab's order */
10781
- parts: any[];
11387
+ /** @property {Array<EngineObject3D>} - What the prefab's objects made, in the prefab's order
11388
+ * @type {Array<EngineObject3D>} */
11389
+ parts: Array<EngineObject3D>;
10782
11390
  /** @property {Vector3} - From the prefab's origin to the handle, in the prefab's own space: nothing for
10783
11391
  * separate parts, and for an attached prefab the middle of the box around its parts, where its handle
10784
11392
  * is, as an object's place is the middle of its body */
10785
11393
  originOffset: Vector3;
10786
- partObjects: any[];
11394
+ /** @type {Array<{id?: number, type: string, pos?: Array<number>, rotation?: Array<number>, scale?: Array<number>|number, properties?: Object}>} */
11395
+ partObjects: Array<{
11396
+ id?: number;
11397
+ type: string;
11398
+ pos?: Array<number>;
11399
+ rotation?: Array<number>;
11400
+ scale?: Array<number> | number;
11401
+ properties?: any;
11402
+ }>;
10787
11403
  partsPlaced: string;
10788
11404
  partsMade: boolean;
10789
11405
  /** Put the instance with its prefab's origin at a place, turned and sized as the handle is: where a level's
@@ -11022,9 +11638,12 @@ declare module "littlejsengine" {
11022
11638
  * - Accepts TexturePacker json (hash and array) and Aseprite json
11023
11639
  * - Frames tagged in Aseprite or named like run_0, run_1 group into animations
11024
11640
  * @param {Object} data - Parsed atlas json data
11025
- * @return {Array<Object>} List of {name, frames} groups in atlas order
11641
+ * @return {Array<{name: string, frames: Array<Object>}>} List of {name, frames} groups in atlas order
11026
11642
  * @memberof TextureSheets */
11027
- export function parseAtlas(data: any): Array<any>;
11643
+ export function parseAtlas(data: any): {
11644
+ name: string;
11645
+ frames: Array<any>;
11646
+ }[];
11028
11647
  /** Wait for everything started by loadSprite and loadAtlas to finish packing
11029
11648
  * @return {Promise}
11030
11649
  * @example
@@ -11099,10 +11718,10 @@ declare module "littlejsengine" {
11099
11718
  }[];
11100
11719
  };
11101
11720
  /** A copy of an effect with its four colors turned around the color wheel and their saturation scaled; lightness and
11102
- * alpha stay, and grey and white have no hue to turn
11721
+ * alpha stay, and gray and white have no hue to turn
11103
11722
  * @param {Object} effect
11104
11723
  * @param {number} [hue] - How far around the wheel, 1 is all the way
11105
- * @param {number} [saturation] - Multiplies the saturation, 0 is grey, clamped to 1
11724
+ * @param {number} [saturation] - Multiplies the saturation, 0 is gray, clamped to 1
11106
11725
  * @return {Object}
11107
11726
  * @memberof ParticleEffects */
11108
11727
  export function particleEffectRecolor(effect: any, hue?: number, saturation?: number): any;
@@ -11146,7 +11765,7 @@ declare module "littlejsengine" {
11146
11765
  * @param {Object} [options] - What to change for this play, each left out when not wanted:
11147
11766
  * scale grows the whole effect, the built-ins fit a one unit object at 1;
11148
11767
  * hue turns its colors around the color wheel, 1 is all the way;
11149
- * saturation multiplies its saturation, 0 is grey;
11768
+ * saturation multiplies its saturation, 0 is gray;
11150
11769
  * angle is its direction, 0 is up, the effect's own angle when not given;
11151
11770
  * tileInfo, a TileInfo or a TextureInfo, is the game's own art to draw with in place of the effect's shape,
11152
11771
  * tinted by its colors, a whole texture drawn as one tile;
@@ -11182,8 +11801,9 @@ declare module "littlejsengine" {
11182
11801
  * @memberof ParticleEffects */
11183
11802
  export function particleEffectApply3D(emitter: ParticleEmitter3D, effect: any): void;
11184
11803
  /** An effect with a 2D emitter's settings, to save, build again, or build in 3D with particleEffect3D; its tile is
11185
- * left out, since a hand made emitter's tile is its own texture and not one an effect can name, and so is its
11186
- * scale, which an effect does not keep: pass it again with options.scale
11804
+ * left out, since a hand made emitter's tile is its own texture and not one an effect can name, and so are its
11805
+ * scale, which an effect does not keep: pass it again with options.scale, and its renderOrder, which an effect takes
11806
+ * from additive; a finished emitter's emit time is the time it emitted for
11187
11807
  * @param {ParticleEmitter} emitter
11188
11808
  * @param {string} [name]
11189
11809
  * @return {Object}
@@ -11193,7 +11813,7 @@ declare module "littlejsengine" {
11193
11813
  * @param {string} name
11194
11814
  * @param {function(Particle, number): void} update - Pushes a 2D particle, given the strength
11195
11815
  * @param {function(Particle3D, number): void} [update3D] - The same for a 3D particle, none leaves 3D alone
11196
- * @param {number} [min] - Strength range the designer offers
11816
+ * @param {number} [min] - Strength range the designer offers, and the range a strength is clamped to
11197
11817
  * @param {number} [max]
11198
11818
  * @param {number} [value] - Strength when first added
11199
11819
  * @param {string} [description]