littlejsengine 1.24.3 → 1.25.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.
- package/CHANGELOG.md +36 -0
- package/EDITOR.md +2 -2
- package/FAQ.md +6 -0
- package/REFERENCE.md +84 -40
- package/dist/littlejs.d.ts +474 -219
- package/dist/littlejs.esm.js +2318 -1743
- package/dist/littlejs.esm.min.js +38 -24
- package/dist/littlejs.js +2316 -1743
- package/dist/littlejs.min.js +37 -23
- package/dist/littlejs.release.js +2313 -1786
- package/package.json +1 -1
- package/plugins/box2d.js +32 -23
- package/plugins/drawUtilities.js +374 -380
- package/plugins/gltf.js +325 -54
- package/plugins/lightSystem.js +2 -2
- package/plugins/math3d.js +1013 -1014
- package/plugins/newgrounds.js +1 -4
- package/plugins/particleEffects.js +3 -4
- package/plugins/pathFinder.js +52 -28
- package/plugins/pluginExport.js +2 -0
- package/plugins/postProcess.js +196 -65
- package/plugins/render3d.js +8 -6
- package/plugins/render3dEditor.js +3 -3
- package/plugins/render3dExtras.js +19 -2
- package/plugins/render3dLevel.js +15 -4
- package/plugins/tweenSystem.js +43 -38
- package/plugins/uiSystem.js +25 -20
- package/src/engine.js +9 -5
- package/src/engineAudio.js +10 -6
- package/src/engineDebug.js +3 -2
- package/src/engineDraw.js +9 -9
- package/src/engineEditor.js +75 -23
- package/src/engineInput.js +4 -7
- package/src/engineMath.js +3 -6
- package/src/engineObject.js +8 -9
- package/src/engineParticles.js +8 -7
- package/src/engineRelease.js +17 -10
- package/src/engineTileLayer.js +33 -14
- package/src/engineUtilities.js +15 -2
- package/src/engineWebGL.js +31 -9
package/dist/littlejs.d.ts
CHANGED
|
@@ -88,6 +88,50 @@ declare module "littlejsengine" {
|
|
|
88
88
|
* - Function called when sound is loaded
|
|
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
|
*/
|
|
@@ -234,10 +282,69 @@ declare module "littlejsengine" {
|
|
|
234
282
|
normal: Vector3;
|
|
235
283
|
type: number;
|
|
236
284
|
};
|
|
285
|
+
/**
|
|
286
|
+
* A 3D level as it is saved, what level3DLoad takes and the 3D level editor edits
|
|
287
|
+
*/
|
|
288
|
+
export type Level3D = {
|
|
289
|
+
/**
|
|
290
|
+
* - The format's version, 1
|
|
291
|
+
*/
|
|
292
|
+
littlejs3D?: number;
|
|
293
|
+
/**
|
|
294
|
+
* - Each {id, type, pos, rotation, scale, properties}, all but type optional
|
|
295
|
+
*/
|
|
296
|
+
objects: Array<any>;
|
|
297
|
+
/**
|
|
298
|
+
* - The scene block: sky, ambient, sunDirection, sunColor, fog, fogColor, shadows, lensFlare
|
|
299
|
+
*/
|
|
300
|
+
scene?: any;
|
|
301
|
+
/**
|
|
302
|
+
* - A block map: {pos, size, blocks}
|
|
303
|
+
*/
|
|
304
|
+
voxels?: any;
|
|
305
|
+
/**
|
|
306
|
+
* - A height map: {pos, size, height, color, heights, paint}
|
|
307
|
+
*/
|
|
308
|
+
terrain?: any;
|
|
309
|
+
/**
|
|
310
|
+
* - The level's own prefabs by name, each {objects, attached}
|
|
311
|
+
*/
|
|
312
|
+
prefabs?: any;
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* What bends a skinned part: its joints, the nodes that move it, their inverse bind matrices, and for each vertex
|
|
316
|
+
* of its mesh four joints and four weights, with the place and normal each pose bends from
|
|
317
|
+
*/
|
|
318
|
+
export type GLTFSkin = {
|
|
319
|
+
/**
|
|
320
|
+
* - The joints, as node numbers
|
|
321
|
+
*/
|
|
322
|
+
joints: Array<number>;
|
|
323
|
+
/**
|
|
324
|
+
* - Each joint's inverse bind matrix
|
|
325
|
+
*/
|
|
326
|
+
inverseBind: Array<Matrix4>;
|
|
327
|
+
/**
|
|
328
|
+
* - Four joints a vertex, as places in joints
|
|
329
|
+
*/
|
|
330
|
+
vertexJoints: Uint16Array;
|
|
331
|
+
/**
|
|
332
|
+
* - Four weights a vertex, summing to 1
|
|
333
|
+
*/
|
|
334
|
+
vertexWeights: Float32Array;
|
|
335
|
+
/**
|
|
336
|
+
* - Each vertex's place as stored, x y z
|
|
337
|
+
*/
|
|
338
|
+
bindPoints: Float32Array;
|
|
339
|
+
/**
|
|
340
|
+
* - Each vertex's normal as stored, x y z
|
|
341
|
+
*/
|
|
342
|
+
bindNormals: Float32Array;
|
|
343
|
+
};
|
|
237
344
|
/**
|
|
238
345
|
* - Puts the player at a world position, for the level editor's Play from mouse
|
|
239
346
|
*/
|
|
240
|
-
export type EditorPlayFromCallback = (pos:
|
|
347
|
+
export type EditorPlayFromCallback = (pos: any) => any;
|
|
241
348
|
/**
|
|
242
349
|
* - Rebuilds the level from the map the level editor changed
|
|
243
350
|
*/
|
|
@@ -247,14 +354,15 @@ declare module "littlejsengine" {
|
|
|
247
354
|
*/
|
|
248
355
|
export type EditorTileCallback = (layer: TileLayer, pos: Vector2, tile: number | undefined) => any;
|
|
249
356
|
/**
|
|
250
|
-
* - What the level editor gives the callbacks of a tool of the game's own
|
|
357
|
+
* - What the level editor gives the callbacks of a tool of the game's own; P is
|
|
358
|
+
* the type of pos, a Vector2 for a 2D tool, the default, and Vector3|undefined for a 3D one
|
|
251
359
|
*/
|
|
252
|
-
export type EditorToolAt = {
|
|
360
|
+
export type EditorToolAt<P = Vector2> = {
|
|
253
361
|
/**
|
|
254
362
|
* - Where the mouse is in the level: a Vector2 in the 2D editor; in the 3D one a Vector3 on
|
|
255
363
|
* the level or the ground, undefined when the mouse is over the panel
|
|
256
364
|
*/
|
|
257
|
-
pos:
|
|
365
|
+
pos: P;
|
|
258
366
|
/**
|
|
259
367
|
* - 2D: the tile cell under the mouse on the selected tile layer
|
|
260
368
|
*/
|
|
@@ -262,7 +370,7 @@ declare module "littlejsengine" {
|
|
|
262
370
|
/**
|
|
263
371
|
* - 3D: the mouse's Ray3D
|
|
264
372
|
*/
|
|
265
|
-
ray:
|
|
373
|
+
ray: Ray3D | undefined;
|
|
266
374
|
/**
|
|
267
375
|
* - Is Shift held
|
|
268
376
|
*/
|
|
@@ -273,9 +381,10 @@ declare module "littlejsengine" {
|
|
|
273
381
|
ctrl: boolean;
|
|
274
382
|
};
|
|
275
383
|
/**
|
|
276
|
-
* - A tool of the game's own for the level editor, see LevelEditor.addTool
|
|
384
|
+
* - A tool of the game's own for the level editor, see LevelEditor.addTool; P is the
|
|
385
|
+
* type of its pos, as EditorToolAt has it
|
|
277
386
|
*/
|
|
278
|
-
export type EditorTool = {
|
|
387
|
+
export type EditorTool<P = Vector2> = {
|
|
279
388
|
/**
|
|
280
389
|
* - The key that picks it, as addKey spells one
|
|
281
390
|
*/
|
|
@@ -288,19 +397,19 @@ declare module "littlejsengine" {
|
|
|
288
397
|
* - The left button went down in the level; returning false
|
|
289
398
|
* says the press was not the tool's
|
|
290
399
|
*/
|
|
291
|
-
onPress?: (arg0: EditorToolAt) => any;
|
|
400
|
+
onPress?: (arg0: EditorToolAt<P>) => any;
|
|
292
401
|
/**
|
|
293
402
|
* - Each frame it is held
|
|
294
403
|
*/
|
|
295
|
-
onDrag?: (arg0: EditorToolAt) => any;
|
|
404
|
+
onDrag?: (arg0: EditorToolAt<P>) => any;
|
|
296
405
|
/**
|
|
297
406
|
* - It was let go
|
|
298
407
|
*/
|
|
299
|
-
onRelease?: (arg0: EditorToolAt) => any;
|
|
408
|
+
onRelease?: (arg0: EditorToolAt<P>) => any;
|
|
300
409
|
/**
|
|
301
410
|
* - Each frame the tool is on, to draw its cursor or preview
|
|
302
411
|
*/
|
|
303
|
-
onDraw?: (arg0: EditorToolAt) => any;
|
|
412
|
+
onDraw?: (arg0: EditorToolAt<P>) => any;
|
|
304
413
|
};
|
|
305
414
|
/**
|
|
306
415
|
* - The 2D level editor's edit functions, levelEditor.edit2D
|
|
@@ -549,7 +658,8 @@ declare module "littlejsengine" {
|
|
|
549
658
|
* ()=> { drawHUD(); }, // gameRenderPost
|
|
550
659
|
* ['tiles.png', 'tilesLevel.png'] // images to load
|
|
551
660
|
* );
|
|
552
|
-
* @memberof Engine
|
|
661
|
+
* @memberof Engine
|
|
662
|
+
* @return {Promise<void>} - Done when the images have loaded and gameInit has run */
|
|
553
663
|
export function engineInit(gameInit?: GameInitCallback, gameUpdate?: GameCallback, gameUpdatePost?: GameCallback, gameRender?: GameCallback, gameRenderPost?: GameCallback, imageSources?: string[], rootElement?: HTMLElement): Promise<void>;
|
|
554
664
|
/** Advance the engine by a number of frames
|
|
555
665
|
* Requires setEngineManualStep(true), before engineInit or while running; it stops early if an update turns it off
|
|
@@ -688,7 +798,7 @@ declare module "littlejsengine" {
|
|
|
688
798
|
*/
|
|
689
799
|
/**
|
|
690
800
|
* @callback EditorPlayFromCallback - Puts the player at a world position, for the level editor's Play from mouse
|
|
691
|
-
* @param {
|
|
801
|
+
* @param {any} pos - Where to start playing, a Vector2 from the 2D editor and a Vector3 from the 3D one
|
|
692
802
|
* @memberof Editor
|
|
693
803
|
*/
|
|
694
804
|
/**
|
|
@@ -703,24 +813,28 @@ declare module "littlejsengine" {
|
|
|
703
813
|
* @memberof Editor
|
|
704
814
|
*/
|
|
705
815
|
/**
|
|
706
|
-
* @
|
|
707
|
-
* @
|
|
816
|
+
* @template [P=Vector2]
|
|
817
|
+
* @typedef {Object} EditorToolAt - What the level editor gives the callbacks of a tool of the game's own; P is
|
|
818
|
+
* the type of pos, a Vector2 for a 2D tool, the default, and Vector3|undefined for a 3D one
|
|
819
|
+
* @property {P} pos - Where the mouse is in the level: a Vector2 in the 2D editor; in the 3D one a Vector3 on
|
|
708
820
|
* the level or the ground, undefined when the mouse is over the panel
|
|
709
821
|
* @property {Vector2|undefined} cell - 2D: the tile cell under the mouse on the selected tile layer
|
|
710
|
-
* @property {
|
|
822
|
+
* @property {Ray3D|undefined} ray - 3D: the mouse's Ray3D
|
|
711
823
|
* @property {boolean} shift - Is Shift held
|
|
712
824
|
* @property {boolean} ctrl - Is Ctrl held
|
|
713
825
|
* @memberof Editor
|
|
714
826
|
*/
|
|
715
827
|
/**
|
|
716
|
-
* @
|
|
828
|
+
* @template [P=Vector2]
|
|
829
|
+
* @typedef {Object} EditorTool - A tool of the game's own for the level editor, see LevelEditor.addTool; P is the
|
|
830
|
+
* type of its pos, as EditorToolAt has it
|
|
717
831
|
* @property {string} [key] - The key that picks it, as addKey spells one
|
|
718
832
|
* @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
|
|
833
|
+
* @property {function(EditorToolAt<P>): any} [onPress] - The left button went down in the level; returning false
|
|
720
834
|
* 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
|
|
835
|
+
* @property {function(EditorToolAt<P>): any} [onDrag] - Each frame it is held
|
|
836
|
+
* @property {function(EditorToolAt<P>): any} [onRelease] - It was let go
|
|
837
|
+
* @property {function(EditorToolAt<P>): any} [onDraw] - Each frame the tool is on, to draw its cursor or preview
|
|
724
838
|
* @memberof Editor
|
|
725
839
|
*/
|
|
726
840
|
/**
|
|
@@ -816,9 +930,9 @@ declare module "littlejsengine" {
|
|
|
816
930
|
onClick: Function;
|
|
817
931
|
title: string;
|
|
818
932
|
}>;
|
|
819
|
-
/** @type {Object<string, EditorTool
|
|
933
|
+
/** @type {Object<string, EditorTool<any>>} */
|
|
820
934
|
tools: {
|
|
821
|
-
[x: string]: EditorTool
|
|
935
|
+
[x: string]: EditorTool<any>;
|
|
822
936
|
};
|
|
823
937
|
/** What the game does when the 2D editor paints a tile, like setting its collision or its look the way the
|
|
824
938
|
* game does when it loads the level; set it or override it, without one the collision layer gets collision 1
|
|
@@ -832,7 +946,7 @@ declare module "littlejsengine" {
|
|
|
832
946
|
onRestart(): void;
|
|
833
947
|
/** 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
948
|
* and the editor has Play from mouse, which starts play there
|
|
835
|
-
* @param {any} pos */
|
|
949
|
+
* @param {any} pos - A Vector2 from the 2D editor, a Vector3 from the 3D one */
|
|
836
950
|
onPlayFrom(pos: any): void;
|
|
837
951
|
/** Called when the editor opens, to set or override */
|
|
838
952
|
onOpen(): void;
|
|
@@ -890,15 +1004,16 @@ declare module "littlejsengine" {
|
|
|
890
1004
|
* in 3D
|
|
891
1005
|
* - What the callbacks change through edit2D or edit3D is one undo: the editor ends the stroke at the release,
|
|
892
1006
|
* and takes it back when the right button or Escape ends the press
|
|
1007
|
+
* @template [P=Vector2]
|
|
893
1008
|
* @param {string} name
|
|
894
|
-
* @param {EditorTool} tool - {key, hint, onPress, onDrag, onRelease, onDraw}, each optional; onPress returning
|
|
1009
|
+
* @param {EditorTool<P>} tool - {key, hint, onPress, onDrag, onRelease, onDraw}, each optional; onPress returning
|
|
895
1010
|
* false says the press was not the tool's */
|
|
896
|
-
addTool(name: string, tool: EditorTool): void;
|
|
1011
|
+
addTool<P = Vector2>(name: string, tool: EditorTool<P>): void;
|
|
897
1012
|
/** Open the editor, pausing the game; until close(), Escape (the debug key) switches between playing and editing */
|
|
898
|
-
open():
|
|
1013
|
+
open(): void;
|
|
899
1014
|
/** Close the editor and end its session, the game carries on with the changes and Escape opens the debug
|
|
900
1015
|
* overlay again */
|
|
901
|
-
close():
|
|
1016
|
+
close(): void;
|
|
902
1017
|
}
|
|
903
1018
|
/** Make a level editor of the game's own the one in use: an instance of a class that extends LevelEditor, with
|
|
904
1019
|
* the game's hooks as its methods; set it before the editor opens
|
|
@@ -922,7 +1037,7 @@ declare module "littlejsengine" {
|
|
|
922
1037
|
export const debugPointSize: number;
|
|
923
1038
|
/** Draw a debug rectangle in world space, or on the screen with screenSpace
|
|
924
1039
|
* @param {Vector2} pos
|
|
925
|
-
* @param {Vector2} [size=vec2(
|
|
1040
|
+
* @param {Vector2} [size=vec2()]
|
|
926
1041
|
* @param {Color|string} [color]
|
|
927
1042
|
* @param {number} [time]
|
|
928
1043
|
* @param {number} [angle]
|
|
@@ -1005,7 +1120,8 @@ declare module "littlejsengine" {
|
|
|
1005
1120
|
* @memberof Debug */
|
|
1006
1121
|
export function debugVideoCaptureStop(): void;
|
|
1007
1122
|
/** Check if video capture is active
|
|
1008
|
-
* @memberof Debug
|
|
1123
|
+
* @memberof Debug
|
|
1124
|
+
* @return {boolean} */
|
|
1009
1125
|
export function debugVideoCaptureIsActive(): boolean;
|
|
1010
1126
|
/**
|
|
1011
1127
|
* LittleJS Engine Settings
|
|
@@ -1898,9 +2014,9 @@ declare module "littlejsengine" {
|
|
|
1898
2014
|
export function formatTime(t: number): string;
|
|
1899
2015
|
/** Fetches a JSON file from a URL and returns the parsed JSON object. Must be used with await!
|
|
1900
2016
|
* @param {string} url - URL of JSON file
|
|
1901
|
-
* @return {Promise<
|
|
2017
|
+
* @return {Promise<any>} - The parsed JSON, any shape, as response.json() gives it
|
|
1902
2018
|
* @memberof Utilities */
|
|
1903
|
-
export function fetchJSON(url: string): Promise<
|
|
2019
|
+
export function fetchJSON(url: string): Promise<any>;
|
|
1904
2020
|
/** Save a text file to disk
|
|
1905
2021
|
* @param {string} text
|
|
1906
2022
|
* @param {string} [filename]
|
|
@@ -2512,7 +2628,7 @@ declare module "littlejsengine" {
|
|
|
2512
2628
|
* Create a tile info object using a grid based system
|
|
2513
2629
|
* - This can take vecs or floats for easier use and conversion
|
|
2514
2630
|
* - If an index is passed in, the tile size and index will determine the position
|
|
2515
|
-
* @param {Vector2|number} [index
|
|
2631
|
+
* @param {Vector2|number} [index] - Index of the tile in 1d or 2d form
|
|
2516
2632
|
* @param {Vector2|number} [size] - Size of tile in pixels
|
|
2517
2633
|
* @param {TextureInfo|number} [texture] - Texture index or info to use
|
|
2518
2634
|
* @param {number} [padding] - How many pixels padding around tiles
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
3142
|
+
* @param {number} [size] - Diameter
|
|
3027
3143
|
* @param {Color} [color=WHITE]
|
|
3028
|
-
* @param {number} [lineWidth
|
|
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
|
|
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
|
|
3204
|
+
* @param {'left'|'center'|'right'} [textAlign]
|
|
3089
3205
|
* @param {string} [font=fontDefault]
|
|
3090
3206
|
* @param {string} [fontStyle]
|
|
3091
3207
|
* @param {number} [maxWidth]
|
|
@@ -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
|
|
3334
|
-
* @param {number} [rgbaAdditive
|
|
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 */
|
|
@@ -3686,13 +3799,13 @@ declare module "littlejsengine" {
|
|
|
3686
3799
|
*/
|
|
3687
3800
|
export class Sound {
|
|
3688
3801
|
/** 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
|
|
3802
|
+
* @param {string|URL|Array<number|undefined>} [asset] - Filename or URL of an audio file, or a zzfx array
|
|
3690
3803
|
* @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
3804
|
* @param {number} [range=soundDefaultRange] - World space max range of sound
|
|
3692
3805
|
* @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
|
|
3693
3806
|
* @param {SoundLoadCallback} [onloadCallback] - callback function to call when sound is loaded
|
|
3694
3807
|
*/
|
|
3695
|
-
constructor(asset?: string |
|
|
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
|
|
@@ -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=
|
|
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=
|
|
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;
|
|
@@ -4137,16 +4250,20 @@ declare module "littlejsengine" {
|
|
|
4137
4250
|
* @param {boolean} [immediate] - true removes attached effects like particle emitters at once, false lets them finish first */
|
|
4138
4251
|
destroy(immediate?: boolean): void;
|
|
4139
4252
|
/** Convert from local space to world space
|
|
4140
|
-
* @param {Vector2} pos - local space point
|
|
4253
|
+
* @param {Vector2} pos - local space point
|
|
4254
|
+
* @return {Vector2} */
|
|
4141
4255
|
localToWorld(pos: Vector2): Vector2;
|
|
4142
4256
|
/** Convert from world space to local space
|
|
4143
|
-
* @param {Vector2} pos - world space point
|
|
4257
|
+
* @param {Vector2} pos - world space point
|
|
4258
|
+
* @return {Vector2} */
|
|
4144
4259
|
worldToLocal(pos: Vector2): Vector2;
|
|
4145
4260
|
/** Convert from local space to world space for a vector (rotation only)
|
|
4146
|
-
* @param {Vector2} vec - local space vector
|
|
4261
|
+
* @param {Vector2} vec - local space vector
|
|
4262
|
+
* @return {Vector2} */
|
|
4147
4263
|
localToWorldVector(vec: Vector2): Vector2;
|
|
4148
4264
|
/** Convert from world space to local space for a vector (rotation only)
|
|
4149
|
-
* @param {Vector2} vec - world space vector
|
|
4265
|
+
* @param {Vector2} vec - world space vector
|
|
4266
|
+
* @return {Vector2} */
|
|
4150
4267
|
worldToLocalVector(vec: Vector2): Vector2;
|
|
4151
4268
|
/** 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
4269
|
* - Called for each solid tile the physics tests, which can be several times a frame for the same tile, and for
|
|
@@ -4224,10 +4341,6 @@ declare module "littlejsengine" {
|
|
|
4224
4341
|
* @param {boolean} [collideLevel] - Does it collide with the level, its tile collision layers?
|
|
4225
4342
|
* @param {boolean} [collideRaycast] - Does it collide with raycasts? */
|
|
4226
4343
|
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
4344
|
/** Returns string containing info about this object for debugging
|
|
4232
4345
|
* @return {string} */
|
|
4233
4346
|
toString(): string;
|
|
@@ -4243,9 +4356,30 @@ declare module "littlejsengine" {
|
|
|
4243
4356
|
* - TileLayer for rendering, TileCollisionLayer for physics
|
|
4244
4357
|
* - Collision callbacks for tile interactions with objects
|
|
4245
4358
|
* - Optimized raycast support for tile-based physics
|
|
4246
|
-
* - Integration with Box2D physics via
|
|
4359
|
+
* - Integration with Box2D physics via the Box2dTileLayer plugin
|
|
4247
4360
|
* @namespace TileLayers
|
|
4248
4361
|
*/
|
|
4362
|
+
/** A Tiled map as Tiled saves it as JSON, what tileLayersLoad and objectLayersLoad take and tileLayersFromLDtk
|
|
4363
|
+
* makes; the fields read are listed, and the rest of the file is kept as it is
|
|
4364
|
+
* @typedef {Object} TiledMap
|
|
4365
|
+
* @property {number} width - Cells across
|
|
4366
|
+
* @property {number} height - Cells up
|
|
4367
|
+
* @property {number} [tilewidth] - A tile's width in pixels
|
|
4368
|
+
* @property {number} [tileheight] - A tile's height in pixels
|
|
4369
|
+
* @property {Array<Object>} layers - Tile layers, object layers and groups of them, bottom first
|
|
4370
|
+
* @property {Array<Object>} [tilesets] - The first one's margin, spacing and columns are read
|
|
4371
|
+
* @property {number} [nextlayerid]
|
|
4372
|
+
* @property {number} [nextobjectid]
|
|
4373
|
+
* @property {string} [orientation]
|
|
4374
|
+
* @property {string} [renderorder]
|
|
4375
|
+
* @property {boolean} [infinite]
|
|
4376
|
+
* @property {string} [type]
|
|
4377
|
+
* @property {string|number} [version] - A number in files from Tiled before 1.6
|
|
4378
|
+
* @property {string} [tiledversion]
|
|
4379
|
+
* @property {number} [compressionlevel]
|
|
4380
|
+
* @property {string} [backgroundcolor]
|
|
4381
|
+
* @property {Array<Object>} [properties]
|
|
4382
|
+
* @memberof TileLayers */
|
|
4249
4383
|
/** Keep track of all tile layers with collision
|
|
4250
4384
|
* @type {Array<TileCollisionLayer>}
|
|
4251
4385
|
* @memberof TileLayers */
|
|
@@ -4277,7 +4411,7 @@ declare module "littlejsengine" {
|
|
|
4277
4411
|
* @param {Vector2} posEnd
|
|
4278
4412
|
* @param {EngineObject|TileCollisionCallback} [callbackObject] - Callback, engine object, or undefined
|
|
4279
4413
|
* @param {Vector2} [normal] - Optional normal of the surface hit
|
|
4280
|
-
* @param {boolean} [solidOnly
|
|
4414
|
+
* @param {boolean} [solidOnly] - Only check solid layers?
|
|
4281
4415
|
* @return {Vector2|undefined} - where the ray meets the first tile hit, nudged just inside it, or undefined if no hit
|
|
4282
4416
|
* @memberof TileLayers */
|
|
4283
4417
|
export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, callbackObject?: EngineObject | TileCollisionCallback, normal?: Vector2, solidOnly?: boolean): Vector2 | undefined;
|
|
@@ -4295,7 +4429,7 @@ declare module "littlejsengine" {
|
|
|
4295
4429
|
* - An object or image layer keeps its index, with its slot in the returned array left empty
|
|
4296
4430
|
* - A hidden layer (visible false) is loaded, its collision included, but not drawn; its render
|
|
4297
4431
|
* is a no-op, delete that and call redraw() to show it
|
|
4298
|
-
* @param {
|
|
4432
|
+
* @param {TiledMap} [tileMapData] - Level data from exported data, a 50 by 50 empty level when left out
|
|
4299
4433
|
* @param {TileInfo} [tileInfo] - Default tile info (used for size and texture), tile() by default, none when no image is loaded
|
|
4300
4434
|
* @param {number} [renderOrder] - Render order of the top layer
|
|
4301
4435
|
* @param {number|string} [collisionLayer] - Layer to use for collision if any, by its index or its name
|
|
@@ -4303,7 +4437,7 @@ declare module "littlejsengine" {
|
|
|
4303
4437
|
* @return {Array<TileCollisionLayer>} - It throws for a map that is not whole cells, or a layer whose tiles do not
|
|
4304
4438
|
* fill it, before it makes any layer
|
|
4305
4439
|
* @memberof TileLayers */
|
|
4306
|
-
export function tileLayersLoad(tileMapData
|
|
4440
|
+
export function tileLayersLoad(tileMapData?: TiledMap, tileInfo?: TileInfo, renderOrder?: number, collisionLayer?: string | number, draw?: boolean): Array<TileCollisionLayer>;
|
|
4307
4441
|
/**
|
|
4308
4442
|
* Make a Tiled map of a level of an LDtk project, to load with tileLayersLoad and objectLayersLoad
|
|
4309
4443
|
* - Each Tiles, AutoLayer and IntGrid layer is a tile layer, the bottom one first as in Tiled; where LDtk stacks
|
|
@@ -4324,13 +4458,13 @@ declare module "littlejsengine" {
|
|
|
4324
4458
|
* - The level editor edits the map this returns, and saves it as a Tiled map
|
|
4325
4459
|
* @param {Object} ldtk - The LDtk project, its JSON
|
|
4326
4460
|
* @param {number|string} [level] - Which level, by its index or its identifier
|
|
4327
|
-
* @return {
|
|
4461
|
+
* @return {TiledMap} - A Tiled map: width, height, tilewidth, tileheight, tilesets and layers
|
|
4328
4462
|
* @example
|
|
4329
4463
|
* const map = tileLayersFromLDtk(await fetchJSON('world.ldtk'), 'Level_0');
|
|
4330
4464
|
* const layers = tileLayersLoad(map, tile(0, 16), 0, 'Collisions'); // its IntGrid layer is solid
|
|
4331
4465
|
* objectLayersLoad(map);
|
|
4332
4466
|
* @memberof TileLayers */
|
|
4333
|
-
export function tileLayersFromLDtk(ldtk: any, level?: string | number):
|
|
4467
|
+
export function tileLayersFromLDtk(ldtk: any, level?: string | number): TiledMap;
|
|
4334
4468
|
/** Add a type of object, so objectLayersLoad makes one wherever a map's object layer has an object of that type
|
|
4335
4469
|
* - The name is the object's type in Tiled (its class in Tiled 1.9); it is a string because minified builds
|
|
4336
4470
|
* rename classes
|
|
@@ -4340,13 +4474,15 @@ declare module "littlejsengine" {
|
|
|
4340
4474
|
* - Adding a name again replaces it
|
|
4341
4475
|
* @param {string} name - The type the objects have in Tiled
|
|
4342
4476
|
* @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
|
|
4477
|
+
* @param {Object<string, any>} [defaults] - Properties set on each one made, the level editor shows inputs for them
|
|
4344
4478
|
* @param {TileInfo} [tileInfo] - An icon for the level editor
|
|
4345
4479
|
* @memberof TileLayers
|
|
4346
4480
|
* @example
|
|
4347
4481
|
* objectLayersAddType('Coin', Coin, {value: 1}, tile(5, 16));
|
|
4348
4482
|
* objectLayersAddType('PlayerStart', (pos)=> playerStartPos = pos); */
|
|
4349
|
-
export function objectLayersAddType(name: string, make: Function, defaults?:
|
|
4483
|
+
export function objectLayersAddType(name: string, make: Function, defaults?: {
|
|
4484
|
+
[x: string]: any;
|
|
4485
|
+
}, tileInfo?: TileInfo): void;
|
|
4350
4486
|
/** Make the objects in a map's object layers, each from the type added for its name with objectLayersAddType
|
|
4351
4487
|
* - An object is made at its position, the world y up as tileLayersLoad places the layers; layer offsets are
|
|
4352
4488
|
* not read, and a shape or tile object is made at its position too
|
|
@@ -4354,10 +4490,10 @@ declare module "littlejsengine" {
|
|
|
4354
4490
|
* - The object's properties in Tiled are set over the type's defaults: numbers, booleans, strings, and colors,
|
|
4355
4491
|
* and for a Vector2 default the string x,y
|
|
4356
4492
|
* - An object whose type was not added is skipped, with a warning in debug builds
|
|
4357
|
-
* @param {
|
|
4493
|
+
* @param {TiledMap} tileMapData - The same Tiled map given to tileLayersLoad
|
|
4358
4494
|
* @return {Array<any>} - What each object's type made, a function that made nothing is left out
|
|
4359
4495
|
* @memberof TileLayers */
|
|
4360
|
-
export function objectLayersLoad(tileMapData:
|
|
4496
|
+
export function objectLayersLoad(tileMapData: TiledMap): Array<any>;
|
|
4361
4497
|
/**
|
|
4362
4498
|
* Tile layer data object stores info about how to draw a tile
|
|
4363
4499
|
* @memberof TileLayers
|
|
@@ -4373,7 +4509,7 @@ declare module "littlejsengine" {
|
|
|
4373
4509
|
/** Create a tile layer data object, one for each tile in a TileLayer
|
|
4374
4510
|
* @param {number} [tile] - The tile to use, from 0 like tile(); undefined is an empty cell that draws nothing
|
|
4375
4511
|
* @param {number} [direction] - Integer direction of tile, in 90 degree increments
|
|
4376
|
-
* @param {boolean} [mirror] - If the tile
|
|
4512
|
+
* @param {boolean} [mirror] - If the tile is flipped left to right
|
|
4377
4513
|
* @param {Color} [color] - Color of the tile */
|
|
4378
4514
|
constructor(tile?: number, direction?: number, mirror?: boolean, color?: Color);
|
|
4379
4515
|
/** @property {number|undefined} - The tile to use, from 0 like tile(); undefined is an empty cell that draws nothing
|
|
@@ -4381,7 +4517,7 @@ declare module "littlejsengine" {
|
|
|
4381
4517
|
tile: number | undefined;
|
|
4382
4518
|
/** @property {number} - Integer direction of tile, in 90 degree increments */
|
|
4383
4519
|
direction: number;
|
|
4384
|
-
/** @property {boolean} - If the tile
|
|
4520
|
+
/** @property {boolean} - If the tile is flipped left to right */
|
|
4385
4521
|
mirror: boolean;
|
|
4386
4522
|
/** @property {Color} - Color of the tile */
|
|
4387
4523
|
color: Color;
|
|
@@ -4421,7 +4557,7 @@ declare module "littlejsengine" {
|
|
|
4421
4557
|
* @param {Vector2} [size] - Size in world space
|
|
4422
4558
|
* @param {Color} [color] - Color to modulate with
|
|
4423
4559
|
* @param {number} [angle] - Angle to rotate by
|
|
4424
|
-
* @param {boolean} [mirror] - If true image is flipped
|
|
4560
|
+
* @param {boolean} [mirror] - If true the image is flipped left to right
|
|
4425
4561
|
* @param {Color} [additiveColor] - Additive color to be applied if any
|
|
4426
4562
|
* @param {boolean} [screenSpace=drawScreenSpace] - If true the pos and size are in screen space
|
|
4427
4563
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to */
|
|
@@ -4489,7 +4625,7 @@ declare module "littlejsengine" {
|
|
|
4489
4625
|
* @param {TileInfo} [tileInfo] - Tile info to use, untextured if undefined
|
|
4490
4626
|
* @param {Color} [color=WHITE] - Color to modulate with
|
|
4491
4627
|
* @param {number} [angle] - Angle to rotate by
|
|
4492
|
-
* @param {boolean} [mirror] - Is image flipped
|
|
4628
|
+
* @param {boolean} [mirror] - Is the image flipped left to right?
|
|
4493
4629
|
* @param {Color} [additiveColor] - Additive color to be applied if any */
|
|
4494
4630
|
drawLayerTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color): void;
|
|
4495
4631
|
/** Draw a rectangle in layer space
|
|
@@ -4616,13 +4752,13 @@ declare module "littlejsengine" {
|
|
|
4616
4752
|
* let pos = vec2(2,3);
|
|
4617
4753
|
* let particleEmitter = new ParticleEmitter
|
|
4618
4754
|
* (
|
|
4619
|
-
* pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate,
|
|
4755
|
+
* pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emitConeAngle
|
|
4620
4756
|
* tile(0, 16), // tileInfo
|
|
4621
4757
|
* rgb(1,1,1,1), rgb(0,0,0,1), // colorStartA, colorStartB
|
|
4622
4758
|
* rgb(1,1,1,0), rgb(0,0,0,0), // colorEndA, colorEndB
|
|
4623
|
-
* 1, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd,
|
|
4624
|
-
* .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale,
|
|
4625
|
-
* .5, true // randomness,
|
|
4759
|
+
* 1, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, speed, angleSpeed
|
|
4760
|
+
* .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleConeAngle, fadeRate
|
|
4761
|
+
* .5, true // randomness, collideLevel
|
|
4626
4762
|
* );
|
|
4627
4763
|
*/
|
|
4628
4764
|
export class ParticleEmitter extends EngineObject {
|
|
@@ -4730,7 +4866,8 @@ declare module "littlejsengine" {
|
|
|
4730
4866
|
/** Spawn one particle
|
|
4731
4867
|
* @return {Particle} */
|
|
4732
4868
|
emitParticle(): Particle;
|
|
4733
|
-
/** is emitter actively spawning
|
|
4869
|
+
/** is emitter actively spawning
|
|
4870
|
+
* @return {boolean} */
|
|
4734
4871
|
isActive(): boolean;
|
|
4735
4872
|
}
|
|
4736
4873
|
/**
|
|
@@ -4980,8 +5117,6 @@ declare module "littlejsengine" {
|
|
|
4980
5117
|
session_id: string | null;
|
|
4981
5118
|
/** @property {Promise<NewgroundsPlugin>} - Resolves once the session is checked and the lists are in, empty if the server could not be reached */
|
|
4982
5119
|
ready: Promise<this>;
|
|
4983
|
-
/** @deprecated since 1.20, the view is logged when the plugin starts, so this does nothing */
|
|
4984
|
-
logView(): void;
|
|
4985
5120
|
/** Log the view, check the session, fetch the medals and scoreboards, then keep the session alive; the constructor runs it once
|
|
4986
5121
|
* @private */
|
|
4987
5122
|
private init;
|
|
@@ -5077,6 +5212,18 @@ declare module "littlejsengine" {
|
|
|
5077
5212
|
constructor(shaderCode?: string, includeMainCanvas?: boolean, feedbackTexture?: boolean);
|
|
5078
5213
|
/** @property {string} - The shadertoy style mainImage code it shades with, see setShaderCode */
|
|
5079
5214
|
shaderCode: string;
|
|
5215
|
+
/** @property {Object<string, number|Array<number>>} - The game's own values for the shader, a uniform each
|
|
5216
|
+
* by its name, a number a float and a list of 2 to 4 numbers a vector, set every frame as they are; an
|
|
5217
|
+
* effect setting can be one of these names, so it changes every frame without making the shader again, all
|
|
5218
|
+
* but glow's size, which sets how many samples it takes; adding or removing a name makes the shader again,
|
|
5219
|
+
* and the shader is first made at the first render, so values set right after the plugin are in it; a name
|
|
5220
|
+
* is a GLSL name not starting with an underscore, which the effects keep for their own, nor i and a capital
|
|
5221
|
+
* or gl_, and not c, uv or p, the names mainImage works on
|
|
5222
|
+
* @type {Object<string, number|Array<number>>} */
|
|
5223
|
+
values: {
|
|
5224
|
+
[x: string]: number | Array<number>;
|
|
5225
|
+
};
|
|
5226
|
+
valueNames: string;
|
|
5080
5227
|
/** @property {WebGLProgram|undefined} - Shader for post processing
|
|
5081
5228
|
* @type {WebGLProgram|undefined} */
|
|
5082
5229
|
shader: WebGLProgram | undefined;
|
|
@@ -5096,8 +5243,8 @@ declare module "littlejsengine" {
|
|
|
5096
5243
|
}
|
|
5097
5244
|
/**
|
|
5098
5245
|
* 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
|
|
5246
|
+
* @param {number|string} [threshold] - Brightness where the glow starts, 0 is everything and 1 is only pure white
|
|
5247
|
+
* @param {number|string} [strength] - How much glow to add
|
|
5101
5248
|
* @param {number} [size] - How far the glow spreads in pixels
|
|
5102
5249
|
* @param {boolean} [includeMainCanvas] - Glow the 2D canvas too, off by default so HUD text stays crisp
|
|
5103
5250
|
* (a HUD drawn with WebGL in gameRenderPost glows either way, draw it with useWebGL=false)
|
|
@@ -5106,17 +5253,18 @@ declare module "littlejsengine" {
|
|
|
5106
5253
|
* @example
|
|
5107
5254
|
* postProcessBloom(); // in gameInit, after any Render3DPlugin
|
|
5108
5255
|
*/
|
|
5109
|
-
export function postProcessBloom(threshold?: number, strength?: number, size?: number, includeMainCanvas?: boolean): PostProcessPlugin;
|
|
5256
|
+
export function postProcessBloom(threshold?: string | number, strength?: string | number, size?: number, includeMainCanvas?: boolean): PostProcessPlugin;
|
|
5110
5257
|
/**
|
|
5111
5258
|
* Shader code for a bloom effect, the bright parts of the image blurred back over it
|
|
5112
5259
|
* - 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
|
|
5260
|
+
* @param {number|string} [threshold] - Brightness where the glow starts, 0 is everything and 1 is only pure white
|
|
5261
|
+
* @param {number|string} [strength] - How much glow to add
|
|
5262
|
+
* @param {number} [size] - How far the glow spreads in pixels, which also sets how many samples it takes, so a
|
|
5263
|
+
* number and not a value's name
|
|
5116
5264
|
* @return {string}
|
|
5117
5265
|
* @memberof PostProcess
|
|
5118
5266
|
*/
|
|
5119
|
-
export function postProcessBloomShader(threshold?: number, strength?: number, size?: number): string;
|
|
5267
|
+
export function postProcessBloomShader(threshold?: string | number, strength?: string | number, size?: number): string;
|
|
5120
5268
|
/**
|
|
5121
5269
|
* Join effects into one post process shader, in the order given, for PostProcessPlugin or setShaderCode
|
|
5122
5270
|
* - 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 +5280,109 @@ declare module "littlejsengine" {
|
|
|
5132
5280
|
export function postProcessEffects(...effects: string[]): string;
|
|
5133
5281
|
/**
|
|
5134
5282
|
* 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
|
|
5283
|
+
* @param {number|string} [threshold] - Brightness where the glow starts, 0 is everything and 1 is only pure white
|
|
5284
|
+
* @param {number|string} [strength] - How much glow to add
|
|
5285
|
+
* @param {number} [size] - How far the glow spreads in pixels, which also sets how many samples it takes, so a
|
|
5286
|
+
* number and not a value's name
|
|
5138
5287
|
* @return {string}
|
|
5139
5288
|
* @memberof PostProcess
|
|
5140
5289
|
*/
|
|
5141
|
-
export function postProcessGlow(threshold?: number, strength?: number, size?: number): string;
|
|
5290
|
+
export function postProcessGlow(threshold?: string | number, strength?: string | number, size?: number): string;
|
|
5142
5291
|
/**
|
|
5143
5292
|
* 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
|
|
5293
|
+
* @param {number|string} [strength] - How dark the lines are, and how bright between them
|
|
5294
|
+
* @param {number|string} [spacing] - Pixels from one line to the next
|
|
5146
5295
|
* @return {string}
|
|
5147
5296
|
* @memberof PostProcess
|
|
5148
5297
|
*/
|
|
5149
|
-
export function postProcessScanlines(strength?: number, spacing?: number): string;
|
|
5298
|
+
export function postProcessScanlines(strength?: string | number, spacing?: string | number): string;
|
|
5150
5299
|
/**
|
|
5151
5300
|
* 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
|
|
5301
|
+
* @param {number|string} [strength] - How bright the static is
|
|
5302
|
+
* @param {number|string} [size] - Size of a speck in pixels
|
|
5154
5303
|
* @return {string}
|
|
5155
5304
|
* @memberof PostProcess
|
|
5156
5305
|
*/
|
|
5157
|
-
export function postProcessNoise(strength?: number, size?: number): string;
|
|
5306
|
+
export function postProcessNoise(strength?: string | number, size?: string | number): string;
|
|
5158
5307
|
/**
|
|
5159
5308
|
* 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
|
|
5309
|
+
* @param {number|string} [strength] - How dark the corners get, 1 is black
|
|
5310
|
+
* @param {number|string} [falloff] - How far in it reaches, low darkens most of the screen, high only the corners
|
|
5162
5311
|
* @return {string}
|
|
5163
5312
|
* @memberof PostProcess
|
|
5164
5313
|
*/
|
|
5165
|
-
export function postProcessVignette(strength?: number, falloff?: number): string;
|
|
5314
|
+
export function postProcessVignette(strength?: string | number, falloff?: string | number): string;
|
|
5166
5315
|
/**
|
|
5167
5316
|
* 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
|
|
5317
|
+
* @param {number|string} [strength] - How much it bends
|
|
5169
5318
|
* @return {string}
|
|
5170
5319
|
* @memberof PostProcess
|
|
5171
5320
|
*/
|
|
5172
|
-
export function postProcessCurve(strength?: number): string;
|
|
5321
|
+
export function postProcessCurve(strength?: string | number): string;
|
|
5173
5322
|
/**
|
|
5174
5323
|
* 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
|
|
5324
|
+
* @param {number|string} [strength] - How far apart at the edge, as a part of the screen
|
|
5176
5325
|
* @return {string}
|
|
5177
5326
|
* @memberof PostProcess
|
|
5178
5327
|
*/
|
|
5179
|
-
export function postProcessChromatic(strength?: number): string;
|
|
5328
|
+
export function postProcessChromatic(strength?: string | number): string;
|
|
5180
5329
|
/**
|
|
5181
5330
|
* Draw lines where the 3D depth jumps, around objects and along their creases; needs render3D.depthTexture on
|
|
5182
5331
|
* @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
|
|
5332
|
+
* @param {number|string} [thickness] - How wide the lines are in pixels
|
|
5333
|
+
* @param {number|string} [threshold] - How big a jump makes a line, as a part of the distance, lower draws more
|
|
5334
|
+
* @return {string}
|
|
5335
|
+
* @memberof PostProcess
|
|
5336
|
+
*/
|
|
5337
|
+
export function postProcessOutline(color?: Color, thickness?: string | number, threshold?: string | number): string;
|
|
5338
|
+
/**
|
|
5339
|
+
* Keep a band across the screen sharp and blur the picture above and below it, as a tilt shift lens does, which
|
|
5340
|
+
* makes a scene look like a small model; it reads only the screen, so it works in 2D and 3D; put it first
|
|
5341
|
+
* @param {number|string} [focus] - Height of the middle of the sharp band, 0 the bottom of the screen and 1 the top
|
|
5342
|
+
* @param {number|string} [size] - Height of the sharp band, as a part of the screen
|
|
5343
|
+
* @param {number|string} [blur] - Widest blur in pixels, reached half the screen past the band, at most 32
|
|
5344
|
+
* @return {string}
|
|
5345
|
+
* @memberof PostProcess
|
|
5346
|
+
* @example
|
|
5347
|
+
* new PostProcessPlugin(postProcessEffects(postProcessTiltShift(.4, .2, 10), postProcessVignette(.5)));
|
|
5348
|
+
*/
|
|
5349
|
+
export function postProcessTiltShift(focus?: string | number, size?: string | number, blur?: string | number): string;
|
|
5350
|
+
/**
|
|
5351
|
+
* Keep what is a distance from the camera sharp and blur what is nearer or farther, as a camera lens does; needs
|
|
5352
|
+
* render3D.depthTexture on, and blurs 3D only, 2D draws having no depth; put it first
|
|
5353
|
+
* - What is in focus stays sharp at its edges: a blur in front of or behind it leaves out what is in focus
|
|
5354
|
+
* @param {number|string} [focus] - Distance from the camera, along its view, that is sharpest, in world units
|
|
5355
|
+
* @param {number|string} [range] - How deep the sharp part is; the blur grows over as far again past it
|
|
5356
|
+
* @param {number|string} [blur] - Widest blur in pixels, at most 32
|
|
5185
5357
|
* @return {string}
|
|
5186
5358
|
* @memberof PostProcess
|
|
5359
|
+
* @example
|
|
5360
|
+
* render3D.depthTexture = true;
|
|
5361
|
+
* new PostProcessPlugin(postProcessEffects(postProcessDepthOfField(10, 4, 8)));
|
|
5187
5362
|
*/
|
|
5188
|
-
export function
|
|
5363
|
+
export function postProcessDepthOfField(focus?: string | number, range?: string | number, blur?: string | number): string;
|
|
5189
5364
|
/**
|
|
5190
5365
|
* 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
5366
|
* a vignette, and a bulged screen when curve is set; any setting at 0 leaves that part out
|
|
5192
5367
|
* @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
|
|
5368
|
+
* @param {number|string} [settings.noise] - Static noise strength
|
|
5369
|
+
* @param {number|string} [settings.scanlines] - Scan line strength
|
|
5370
|
+
* @param {number|string} [settings.scanlineSpacing] - Pixels from one scan line to the next
|
|
5371
|
+
* @param {number|string} [settings.glow] - Soft glow strength
|
|
5372
|
+
* @param {number|string} [settings.vignette] - Vignette strength
|
|
5373
|
+
* @param {number|string} [settings.curve] - How much the screen bulges, 0 by default for flat
|
|
5199
5374
|
* @return {string}
|
|
5200
5375
|
* @example
|
|
5201
5376
|
* new PostProcessPlugin(postProcessEffects(postProcessTV({scanlines: .4, curve: .1})));
|
|
5202
5377
|
* @memberof PostProcess
|
|
5203
5378
|
*/
|
|
5204
5379
|
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;
|
|
5380
|
+
noise?: string | number;
|
|
5381
|
+
scanlines?: string | number;
|
|
5382
|
+
scanlineSpacing?: string | number;
|
|
5383
|
+
glow?: string | number;
|
|
5384
|
+
vignette?: string | number;
|
|
5385
|
+
curve?: string | number;
|
|
5211
5386
|
}): string;
|
|
5212
5387
|
/**
|
|
5213
5388
|
* LittleJS Light System Plugin
|
|
@@ -5606,6 +5781,11 @@ declare module "littlejsengine" {
|
|
|
5606
5781
|
* @param {number|boolean} debugMode
|
|
5607
5782
|
* @memberof UISystem */
|
|
5608
5783
|
export function uiSetDebug(debugMode: number | boolean): void;
|
|
5784
|
+
/**
|
|
5785
|
+
* @callback DragAndDropCallback - Callback for drag and drop events
|
|
5786
|
+
* @param {DragEvent} event - The drag event
|
|
5787
|
+
* @memberof UISystem
|
|
5788
|
+
*/
|
|
5609
5789
|
/**
|
|
5610
5790
|
* UI System Global Object
|
|
5611
5791
|
* @memberof UISystem
|
|
@@ -5748,24 +5928,19 @@ declare module "littlejsengine" {
|
|
|
5748
5928
|
* @param {'left'|'center'|'right'} [align]
|
|
5749
5929
|
* @param {string} [font=uiSystem.defaultFont]
|
|
5750
5930
|
* @param {string} [fontStyle]
|
|
5751
|
-
* @param {boolean} [applyMaxWidth
|
|
5931
|
+
* @param {boolean} [applyMaxWidth]
|
|
5752
5932
|
* @param {Vector2} [textShadow]
|
|
5753
5933
|
* @param {Color} [shadowColor]
|
|
5754
5934
|
* @param {number} [shadowBlur]
|
|
5755
5935
|
* @param {Vector2} [shadowOffset] */
|
|
5756
5936
|
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
5937
|
/** Setup drag and drop event handlers
|
|
5763
5938
|
* Automatically prevents defaults and calls the given functions
|
|
5764
5939
|
* @param {DragAndDropCallback} [onDrop] - when a file is dropped
|
|
5765
5940
|
* @param {DragAndDropCallback} [onDragEnter] - when a file is dragged onto the window
|
|
5766
5941
|
* @param {DragAndDropCallback} [onDragLeave] - when a file is dragged off the window
|
|
5767
5942
|
* @param {DragAndDropCallback} [onDragOver] - continuously when dragging over */
|
|
5768
|
-
setupDragAndDrop(onDrop?:
|
|
5943
|
+
setupDragAndDrop(onDrop?: DragAndDropCallback, onDragEnter?: DragAndDropCallback, onDragLeave?: DragAndDropCallback, onDragOver?: DragAndDropCallback): void;
|
|
5769
5944
|
/** Convert a screen space position to native UI position
|
|
5770
5945
|
* @param {Vector2} pos
|
|
5771
5946
|
* @return {Vector2} */
|
|
@@ -5951,15 +6126,20 @@ declare module "littlejsengine" {
|
|
|
5951
6126
|
getTextPos(textSize: Vector2): Vector2;
|
|
5952
6127
|
/** Called when the navigation button is pressed on this object */
|
|
5953
6128
|
navigatePressed(): void;
|
|
5954
|
-
/**
|
|
6129
|
+
/** Is the mouse hovering over this element
|
|
6130
|
+
* @return {boolean} */
|
|
5955
6131
|
isHoverObject(): boolean;
|
|
5956
|
-
/**
|
|
6132
|
+
/** Is the mouse held onto this element
|
|
6133
|
+
* @return {boolean} */
|
|
5957
6134
|
isActiveObject(): boolean;
|
|
5958
|
-
/**
|
|
6135
|
+
/** Is the gamepad or keyboard navigation object
|
|
6136
|
+
* @return {boolean} */
|
|
5959
6137
|
isNavigationObject(): boolean;
|
|
5960
|
-
/**
|
|
6138
|
+
/** Is this object in keyboard input mode
|
|
6139
|
+
* @return {boolean} */
|
|
5961
6140
|
isKeyInputObject(): boolean;
|
|
5962
|
-
/**
|
|
6141
|
+
/** Can it be interacted with, it and every parent visible and enabled
|
|
6142
|
+
* @return {boolean} */
|
|
5963
6143
|
isInteractive(): boolean;
|
|
5964
6144
|
/** Returns string containing info about this object for debugging
|
|
5965
6145
|
* @return {string} */
|
|
@@ -6132,9 +6312,9 @@ declare module "littlejsengine" {
|
|
|
6132
6312
|
* @param {Vector2} pos
|
|
6133
6313
|
* @param {Vector2} size
|
|
6134
6314
|
* @param {string} src - Video file path or URL
|
|
6135
|
-
* @param {boolean} [autoplay
|
|
6136
|
-
* @param {boolean} [loop
|
|
6137
|
-
* @param {number} [volume
|
|
6315
|
+
* @param {boolean} [autoplay] - Start playing immediately?
|
|
6316
|
+
* @param {boolean} [loop] - Loop the video?
|
|
6317
|
+
* @param {number} [volume] - Volume percent scaled by global volume (0-1)
|
|
6138
6318
|
*/
|
|
6139
6319
|
constructor(pos: Vector2, size: Vector2, src: string, autoplay?: boolean, loop?: boolean, volume?: number);
|
|
6140
6320
|
/** @property {number} - The video volume */
|
|
@@ -6196,10 +6376,10 @@ declare module "littlejsengine" {
|
|
|
6196
6376
|
export class UILayout extends UIObject {
|
|
6197
6377
|
/** Create a UILayout container that auto-arranges children
|
|
6198
6378
|
* @param {Vector2} [pos]
|
|
6199
|
-
* @param {number} [columns
|
|
6200
|
-
* @param {number} [gap
|
|
6201
|
-
* @param {number} [padding
|
|
6202
|
-
* @param {boolean} [transparent
|
|
6379
|
+
* @param {number} [columns] - Number of columns (1 = vertical list)
|
|
6380
|
+
* @param {number} [gap] - Space between children
|
|
6381
|
+
* @param {number} [padding] - Space between container border and children
|
|
6382
|
+
* @param {boolean} [transparent] - If true, draws no background, outline, or shadow
|
|
6203
6383
|
*/
|
|
6204
6384
|
constructor(pos?: Vector2, columns?: number, gap?: number, padding?: number, transparent?: boolean);
|
|
6205
6385
|
/** @property {number} - Number of columns in the layout */
|
|
@@ -6338,23 +6518,29 @@ declare module "littlejsengine" {
|
|
|
6338
6518
|
* @param {CanvasRenderingContext2D} [context] */
|
|
6339
6519
|
drawFixture(fixture: any, pos: Vector2, angle: number, color?: Color, lineColor?: Color, lineWidth?: number, useWebGL?: boolean, context?: CanvasRenderingContext2D): void;
|
|
6340
6520
|
/** converts a box2d vec2 to a Vector2
|
|
6341
|
-
* @param {Object} v
|
|
6521
|
+
* @param {Object} v
|
|
6522
|
+
* @return {Vector2} */
|
|
6342
6523
|
vec2From(v: any): Vector2;
|
|
6343
6524
|
/** converts a box2d vec2 pointer to a Vector2
|
|
6344
|
-
* @param {Object} vp
|
|
6525
|
+
* @param {Object} vp
|
|
6526
|
+
* @return {Vector2} */
|
|
6345
6527
|
vec2FromPointer(vp: any): Vector2;
|
|
6346
6528
|
/** converts a Vector2 to a new box2d vec2, which stays until destroyed with box2d.instance.destroy;
|
|
6347
6529
|
* the plugin itself passes Box2D reused ones, since Box2D copies every vector it is given
|
|
6348
|
-
* @param {Vector2} v
|
|
6530
|
+
* @param {Vector2} v
|
|
6531
|
+
* @return {Object} - A Box2D vector, its b2Vec2 */
|
|
6349
6532
|
vec2dTo(v: Vector2): any;
|
|
6350
6533
|
/** checks if a box2d object is null
|
|
6351
|
-
* @param {Object} o
|
|
6534
|
+
* @param {Object} o
|
|
6535
|
+
* @return {boolean} */
|
|
6352
6536
|
isNull(o: any): boolean;
|
|
6353
6537
|
/** casts a box2d object to a shape type
|
|
6354
|
-
* @param {Object} o
|
|
6538
|
+
* @param {Object} o
|
|
6539
|
+
* @return {Object} - The shape as its own Box2D type */
|
|
6355
6540
|
castShapeObject(o: any): any;
|
|
6356
6541
|
/** casts a box2d object to a joint type
|
|
6357
|
-
* @param {Object} o
|
|
6542
|
+
* @param {Object} o
|
|
6543
|
+
* @return {Object} - The joint as its own Box2D type */
|
|
6358
6544
|
castJointObject(o: any): any;
|
|
6359
6545
|
}
|
|
6360
6546
|
/**
|
|
@@ -6415,7 +6601,8 @@ declare module "littlejsengine" {
|
|
|
6415
6601
|
* @param {number} [density]
|
|
6416
6602
|
* @param {number} [friction]
|
|
6417
6603
|
* @param {number} [restitution]
|
|
6418
|
-
* @param {boolean} [isSensor]
|
|
6604
|
+
* @param {boolean} [isSensor]
|
|
6605
|
+
* @return {Object} - The fixture made, Box2D's own */
|
|
6419
6606
|
addShape(shape: any, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
6420
6607
|
/** Add a box shape to the body
|
|
6421
6608
|
* @param {Vector2} [size]
|
|
@@ -6426,38 +6613,43 @@ declare module "littlejsengine" {
|
|
|
6426
6613
|
* @param {number} [density]
|
|
6427
6614
|
* @param {number} [friction]
|
|
6428
6615
|
* @param {number} [restitution]
|
|
6429
|
-
* @param {boolean} [isSensor]
|
|
6430
|
-
|
|
6616
|
+
* @param {boolean} [isSensor]
|
|
6617
|
+
* @return {Object|undefined} - The fixture made, Box2D's own, undefined for a shape too small to make */
|
|
6618
|
+
addBox(size?: Vector2, offset?: Vector2, angle?: number, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any | undefined;
|
|
6431
6619
|
/** Add a polygon shape to the body, the convex hull of its points; Box2D takes 3 to 8 points,
|
|
6432
6620
|
* not all in a line, and no fixture is made from any other; points closer than .001 count as one
|
|
6433
6621
|
* @param {Array<Vector2>} points
|
|
6434
6622
|
* @param {number} [density]
|
|
6435
6623
|
* @param {number} [friction]
|
|
6436
6624
|
* @param {number} [restitution]
|
|
6437
|
-
* @param {boolean} [isSensor]
|
|
6438
|
-
|
|
6625
|
+
* @param {boolean} [isSensor]
|
|
6626
|
+
* @return {Object|undefined} - The fixture made, Box2D's own, undefined for a shape too small to make */
|
|
6627
|
+
addPoly(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any | undefined;
|
|
6439
6628
|
/** Add a regular polygon shape to the body
|
|
6440
6629
|
* @param {number} [diameter]
|
|
6441
6630
|
* @param {number} [sides] - 3 to 8, the most Box2D polygons have
|
|
6442
6631
|
* @param {number} [density]
|
|
6443
6632
|
* @param {number} [friction]
|
|
6444
6633
|
* @param {number} [restitution]
|
|
6445
|
-
* @param {boolean} [isSensor]
|
|
6446
|
-
|
|
6634
|
+
* @param {boolean} [isSensor]
|
|
6635
|
+
* @return {Object|undefined} - The fixture made, Box2D's own, undefined for a shape too small to make */
|
|
6636
|
+
addRegularPoly(diameter?: number, sides?: number, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any | undefined;
|
|
6447
6637
|
/** Add a random polygon shape to the body
|
|
6448
6638
|
* @param {number} [diameter]
|
|
6449
6639
|
* @param {number} [density]
|
|
6450
6640
|
* @param {number} [friction]
|
|
6451
6641
|
* @param {number} [restitution]
|
|
6452
|
-
* @param {boolean} [isSensor]
|
|
6453
|
-
|
|
6642
|
+
* @param {boolean} [isSensor]
|
|
6643
|
+
* @return {Object|undefined} - The fixture made, Box2D's own, undefined for a shape too small to make */
|
|
6644
|
+
addRandomPoly(diameter?: number, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any | undefined;
|
|
6454
6645
|
/** Add a circle shape to the body
|
|
6455
6646
|
* @param {number} [diameter]
|
|
6456
6647
|
* @param {Vector2} [offset]
|
|
6457
6648
|
* @param {number} [density]
|
|
6458
6649
|
* @param {number} [friction]
|
|
6459
6650
|
* @param {number} [restitution]
|
|
6460
|
-
* @param {boolean} [isSensor]
|
|
6651
|
+
* @param {boolean} [isSensor]
|
|
6652
|
+
* @return {Object} - The fixture made, Box2D's own */
|
|
6461
6653
|
addCircle(diameter?: number, offset?: Vector2, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
6462
6654
|
/** Add an edge shape to the body
|
|
6463
6655
|
* @param {Vector2} point1
|
|
@@ -6465,22 +6657,25 @@ declare module "littlejsengine" {
|
|
|
6465
6657
|
* @param {number} [density]
|
|
6466
6658
|
* @param {number} [friction]
|
|
6467
6659
|
* @param {number} [restitution]
|
|
6468
|
-
* @param {boolean} [isSensor]
|
|
6660
|
+
* @param {boolean} [isSensor]
|
|
6661
|
+
* @return {Object} - The fixture made, Box2D's own */
|
|
6469
6662
|
addEdge(point1: Vector2, point2: Vector2, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
6470
6663
|
/** Add an edge list to the body
|
|
6471
6664
|
* @param {Array<Vector2>} points
|
|
6472
6665
|
* @param {number} [density]
|
|
6473
6666
|
* @param {number} [friction]
|
|
6474
6667
|
* @param {number} [restitution]
|
|
6475
|
-
* @param {boolean} [isSensor]
|
|
6476
|
-
|
|
6668
|
+
* @param {boolean} [isSensor]
|
|
6669
|
+
* @return {Array<Object>} - The fixtures made, Box2D's own */
|
|
6670
|
+
addEdgeList(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): Array<any>;
|
|
6477
6671
|
/** Add an edge loop to the body, an edge loop connects the end points
|
|
6478
6672
|
* @param {Array<Vector2>} points
|
|
6479
6673
|
* @param {number} [density]
|
|
6480
6674
|
* @param {number} [friction]
|
|
6481
6675
|
* @param {number} [restitution]
|
|
6482
|
-
* @param {boolean} [isSensor]
|
|
6483
|
-
|
|
6676
|
+
* @param {boolean} [isSensor]
|
|
6677
|
+
* @return {Array<Object>} - The fixtures made, Box2D's own */
|
|
6678
|
+
addEdgeLoop(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): Array<any>;
|
|
6484
6679
|
/** Destroy a fixture from the body, from a contact callback once the step is done
|
|
6485
6680
|
* @param {Object} fixture */
|
|
6486
6681
|
destroyFixture(fixture: any): void;
|
|
@@ -6807,6 +7002,8 @@ declare module "littlejsengine" {
|
|
|
6807
7002
|
* Box2D Pin Joint
|
|
6808
7003
|
* - Pins two objects together at a point, where they still turn freely, like a nail through two boards
|
|
6809
7004
|
* - A revolute joint at that point, so it holds exactly and its limits and motor work too
|
|
7005
|
+
* - new Box2dPinJoint(objectA, objectB, pos, collide): the point defaults to objectA's position, where a revolute
|
|
7006
|
+
* joint's anchor defaults to objectB's
|
|
6810
7007
|
* @extends Box2dRevoluteJoint
|
|
6811
7008
|
* @memberof Box2D
|
|
6812
7009
|
*/
|
|
@@ -7122,12 +7319,6 @@ declare module "littlejsengine" {
|
|
|
7122
7319
|
/** Get the damping ratio
|
|
7123
7320
|
* @return {number} */
|
|
7124
7321
|
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
7322
|
}
|
|
7132
7323
|
/**
|
|
7133
7324
|
* Box2D Friction Joint
|
|
@@ -7280,7 +7471,7 @@ declare module "littlejsengine" {
|
|
|
7280
7471
|
* @param {Vector2} pos - Screen space position
|
|
7281
7472
|
* @param {Vector2} size - Screen space size
|
|
7282
7473
|
* @param {TileInfo} startTile - Top-left tile of the 3x3 block to sample (see drawNineSlice)
|
|
7283
|
-
* @param {Color
|
|
7474
|
+
* @param {Color} [color=WHITE] - Color to modulate with
|
|
7284
7475
|
* @param {number} [borderSize] - Rendered thickness of the border sections
|
|
7285
7476
|
* @param {Color} [additiveColor] - Additive color
|
|
7286
7477
|
* @param {number} [extraSpace] - Extra spacing adjustment
|
|
@@ -7288,7 +7479,7 @@ declare module "littlejsengine" {
|
|
|
7288
7479
|
* @param {boolean} [useWebGL] - Use WebGL for rendering
|
|
7289
7480
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas context to use
|
|
7290
7481
|
* @memberof DrawUtilities */
|
|
7291
|
-
export function drawNineSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, color?:
|
|
7482
|
+
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
7483
|
/** Draw a scalable three-slice UI element in world space
|
|
7293
7484
|
* Color and additive color apply in WebGL and Canvas2D (with canvasColorTiles)
|
|
7294
7485
|
* The three-slice samples 3 consecutive tiles from the tilesheet, it does not
|
|
@@ -7316,7 +7507,7 @@ declare module "littlejsengine" {
|
|
|
7316
7507
|
* @param {Vector2} pos - Screen space position
|
|
7317
7508
|
* @param {Vector2} size - Screen space size
|
|
7318
7509
|
* @param {TileInfo} startTile - First of 3 consecutive tiles: corner, side, center (see drawThreeSlice)
|
|
7319
|
-
* @param {Color
|
|
7510
|
+
* @param {Color} [color=WHITE] - Color to modulate with
|
|
7320
7511
|
* @param {number} [borderSize] - Rendered thickness of the border sections
|
|
7321
7512
|
* @param {Color} [additiveColor] - Additive color
|
|
7322
7513
|
* @param {number} [extraSpace] - Extra spacing adjustment
|
|
@@ -7324,7 +7515,7 @@ declare module "littlejsengine" {
|
|
|
7324
7515
|
* @param {boolean} [useWebGL] - Use WebGL for rendering
|
|
7325
7516
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas context to use
|
|
7326
7517
|
* @memberof DrawUtilities */
|
|
7327
|
-
export function drawThreeSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, color?:
|
|
7518
|
+
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
7519
|
/**
|
|
7329
7520
|
* A tile drawn as a box of any size, kept as a style to draw with, like a UI skin
|
|
7330
7521
|
* - 9 slices is a nine-slice from the 3x3 block of tiles at tileInfo, see drawNineSlice
|
|
@@ -7421,9 +7612,9 @@ declare module "littlejsengine" {
|
|
|
7421
7612
|
* callback receives the interpolated value (a number, or a fresh instance
|
|
7422
7613
|
* for lerp-able types). Both endpoints must be the same type.
|
|
7423
7614
|
* @param {function(NonNullable<T>):void} callback - Called with the interpolated value each frame
|
|
7424
|
-
* @param {T} [start
|
|
7425
|
-
* @param {T} [end
|
|
7426
|
-
* @param {number} [duration
|
|
7615
|
+
* @param {T} [start] - Starting value
|
|
7616
|
+
* @param {T} [end] - Ending value
|
|
7617
|
+
* @param {number} [duration] - Duration in seconds
|
|
7427
7618
|
* @param {Object} [options]
|
|
7428
7619
|
* @param {function(number):number} [options.ease] - Easing function (defaults to LINEAR)
|
|
7429
7620
|
* @param {boolean} [options.useRealTime=false] - Advance even when the game is paused (matches Timer's useRealTime)
|
|
@@ -7462,9 +7653,12 @@ declare module "littlejsengine" {
|
|
|
7462
7653
|
/** Remaining iterations including the current run (loop/pingPong only).
|
|
7463
7654
|
* @private */
|
|
7464
7655
|
private loopRemaining;
|
|
7465
|
-
/** Whether it is
|
|
7656
|
+
/** Whether it is running, see isActive
|
|
7466
7657
|
* @private */
|
|
7467
7658
|
private active;
|
|
7659
|
+
/** Whether it is in the active list, which a stopped one leaves at the next update
|
|
7660
|
+
* @private */
|
|
7661
|
+
private listed;
|
|
7468
7662
|
/** The update it was started in, it first moves on the one after
|
|
7469
7663
|
* @private */
|
|
7470
7664
|
private activePass;
|
|
@@ -7481,7 +7675,7 @@ declare module "littlejsengine" {
|
|
|
7481
7675
|
} | undefined;
|
|
7482
7676
|
/** Set the easing curve and return this for chaining.
|
|
7483
7677
|
* @param {function(number):number} easeFn
|
|
7484
|
-
* @
|
|
7678
|
+
* @return {Tween<T>} */
|
|
7485
7679
|
setEase(easeFn: (arg0: number) => number): Tween<T>;
|
|
7486
7680
|
/** Set the completion callback, `onComplete`, and return this for chaining.
|
|
7487
7681
|
* It is called once the tween completes: when its pass ends, or for a
|
|
@@ -7491,7 +7685,7 @@ declare module "littlejsengine" {
|
|
|
7491
7685
|
* - It is kept by `restart`, so a restarted tween calls it again when it completes
|
|
7492
7686
|
* - `stop` and `tweenStopAll` end a tween without calling it
|
|
7493
7687
|
* @param {function():void} callback
|
|
7494
|
-
* @
|
|
7688
|
+
* @return {Tween<T>} */
|
|
7495
7689
|
then(callback: () => void): Tween<T>;
|
|
7496
7690
|
/** Repeat this tween `n` total times. After each iteration finishes, the
|
|
7497
7691
|
* same tween starts over, so the handle returned stays good for the whole
|
|
@@ -7502,7 +7696,7 @@ declare module "littlejsengine" {
|
|
|
7502
7696
|
* A `then` callback, set before or after, is called when the last
|
|
7503
7697
|
* iteration ends.
|
|
7504
7698
|
* @param {number} [count=Infinity]
|
|
7505
|
-
* @
|
|
7699
|
+
* @return {Tween<T>} */
|
|
7506
7700
|
loop(count?: number): Tween<T>;
|
|
7507
7701
|
/** Like `loop`, but swap `start` and `end` between iterations so the value
|
|
7508
7702
|
* bounces back and forth. `pingPong()` with no argument bounces forever.
|
|
@@ -7511,7 +7705,7 @@ declare module "littlejsengine" {
|
|
|
7511
7705
|
* A `then` callback, set before or after, is called when the last
|
|
7512
7706
|
* iteration ends.
|
|
7513
7707
|
* @param {number} [count=Infinity]
|
|
7514
|
-
* @
|
|
7708
|
+
* @return {Tween<T>} */
|
|
7515
7709
|
pingPong(count?: number): Tween<T>;
|
|
7516
7710
|
/** Pause this tween. While paused, tweenUpdate skips it. */
|
|
7517
7711
|
pause(): void;
|
|
@@ -7527,16 +7721,16 @@ declare module "littlejsengine" {
|
|
|
7527
7721
|
* again when it completes. */
|
|
7528
7722
|
restart(): void;
|
|
7529
7723
|
/** True if this tween is in the active list and not paused.
|
|
7530
|
-
* @
|
|
7724
|
+
* @return {boolean} */
|
|
7531
7725
|
isActive(): boolean;
|
|
7532
7726
|
/** Get how far this tween has progressed, from 0 (just started) to 1
|
|
7533
7727
|
* (completed). Clamped — overshoot past completion still reads 1.
|
|
7534
|
-
* @
|
|
7728
|
+
* @return {number} */
|
|
7535
7729
|
getPercent(): number;
|
|
7536
7730
|
/** Get the current interpolated value (the value most recently passed to
|
|
7537
7731
|
* the callback). Returns a number, Vector2, Vector3 or Color depending on the
|
|
7538
7732
|
* tween's start/end types.
|
|
7539
|
-
* @
|
|
7733
|
+
* @return {T} */
|
|
7540
7734
|
getValue(): T;
|
|
7541
7735
|
/** Compute the interpolated value at the given remaining `life`.
|
|
7542
7736
|
* At life === duration the result is `start`; at life === 0 it is `end`.
|
|
@@ -7544,7 +7738,7 @@ declare module "littlejsengine" {
|
|
|
7544
7738
|
* - A vector goes past its ends as far as the easing does, as a number does; a Color stays between them,
|
|
7545
7739
|
* so its channels stay in range, and any other type goes as far as its own lerp takes it
|
|
7546
7740
|
* @param {number} life
|
|
7547
|
-
* @
|
|
7741
|
+
* @return {T} */
|
|
7548
7742
|
interp(life: number): T;
|
|
7549
7743
|
/** Remove this tween from the active list, ending a loop or pingPong too, without calling
|
|
7550
7744
|
* the then-callback. It keeps the then-callback, so a restart calls it when it completes. */
|
|
@@ -7565,12 +7759,12 @@ declare module "littlejsengine" {
|
|
|
7565
7759
|
* @param {string} propertyPath - Dot-separated path, e.g. `'pos.x'` or `'color'`
|
|
7566
7760
|
* @param {T} start - Starting value
|
|
7567
7761
|
* @param {T} end - Ending value
|
|
7568
|
-
* @param {number} [duration
|
|
7762
|
+
* @param {number} [duration] - Duration in seconds
|
|
7569
7763
|
* @param {Object} [options] - Same options as the Tween constructor
|
|
7570
7764
|
* @param {function(number):number} [options.ease] - Easing function (defaults to LINEAR)
|
|
7571
7765
|
* @param {boolean} [options.useRealTime=false] - Advance even when the game is paused
|
|
7572
7766
|
* @param {boolean} [options.paused=false] - Start in paused state
|
|
7573
|
-
* @
|
|
7767
|
+
* @return {Tween<T>}
|
|
7574
7768
|
* @memberof TweenSystem
|
|
7575
7769
|
* @example
|
|
7576
7770
|
* // Numeric: slide an object's x with an ease-out sine curve
|
|
@@ -7709,7 +7903,8 @@ declare module "littlejsengine" {
|
|
|
7709
7903
|
* gridFinder.isWalkable = (x, y) => myGrid[y*50 + x] === 0;
|
|
7710
7904
|
*/
|
|
7711
7905
|
export class PathFinder {
|
|
7712
|
-
/**
|
|
7906
|
+
/** Make a path finder over a tile layer or a grid
|
|
7907
|
+
* @param {TileCollisionLayer|Vector2} source - Either a TileCollisionLayer
|
|
7713
7908
|
* (size and walkability auto-derived) or a Vector2 grid size (user
|
|
7714
7909
|
* overrides isWalkable). */
|
|
7715
7910
|
constructor(source: TileCollisionLayer | Vector2);
|
|
@@ -7750,27 +7945,27 @@ declare module "littlejsengine" {
|
|
|
7750
7945
|
* the instance or via a subclass.
|
|
7751
7946
|
* @param {number} x - Tile x
|
|
7752
7947
|
* @param {number} y - Tile y
|
|
7753
|
-
* @
|
|
7948
|
+
* @return {boolean} */
|
|
7754
7949
|
isWalkable(x: number, y: number): boolean;
|
|
7755
7950
|
/** Default extra cost for stepping on a cell. Returns 0 (free) by default.
|
|
7756
7951
|
* Override to add cost-weighted terrain (mud, swamp, etc).
|
|
7757
7952
|
* @param {number} x - Tile x
|
|
7758
7953
|
* @param {number} y - Tile y
|
|
7759
|
-
* @
|
|
7954
|
+
* @return {number} */
|
|
7760
7955
|
getCost(x: number, y: number): number;
|
|
7761
7956
|
/** Get the node at tile coords, or null if out of bounds.
|
|
7762
7957
|
* @param {number} x
|
|
7763
7958
|
* @param {number} y
|
|
7764
|
-
* @
|
|
7959
|
+
* @return {PathFinderNode|null} */
|
|
7765
7960
|
getNode(x: number, y: number): PathFinderNode | null;
|
|
7766
7961
|
/** Convert a world-space position to integer tile coords (no clamping).
|
|
7767
7962
|
* @param {Vector2} worldPos
|
|
7768
|
-
* @
|
|
7963
|
+
* @return {Vector2} */
|
|
7769
7964
|
worldToTile(worldPos: Vector2): Vector2;
|
|
7770
7965
|
/** Convert integer tile coords to the world-space center of that tile.
|
|
7771
7966
|
* @param {number} x
|
|
7772
7967
|
* @param {number} y
|
|
7773
|
-
* @
|
|
7968
|
+
* @return {Vector2} */
|
|
7774
7969
|
tileToWorld(x: number, y: number): Vector2;
|
|
7775
7970
|
/** Reset all nodes and re-populate walkable / cost / posWorld from the
|
|
7776
7971
|
* current isWalkable / getCost overrides. Called at the start of
|
|
@@ -7781,7 +7976,7 @@ declare module "littlejsengine" {
|
|
|
7781
7976
|
* reached; false on disconnected goal or maxLoop exhaustion, which sets searchGaveUp.
|
|
7782
7977
|
* @param {PathFinderNode} startNode
|
|
7783
7978
|
* @param {PathFinderNode} endNode
|
|
7784
|
-
* @
|
|
7979
|
+
* @return {boolean}
|
|
7785
7980
|
* @private */
|
|
7786
7981
|
private aStarSearch;
|
|
7787
7982
|
/** Find the clear (walkable, zero-cost) node closest to the given world
|
|
@@ -7794,9 +7989,9 @@ declare module "littlejsengine" {
|
|
|
7794
7989
|
* unchanged walkability, pass `rebuild=false` and call `buildNodeData()`
|
|
7795
7990
|
* once externally to avoid redundant work.
|
|
7796
7991
|
* @param {Vector2} worldPos
|
|
7797
|
-
* @param {number} [searchRange
|
|
7798
|
-
* @param {boolean} [rebuild
|
|
7799
|
-
* @
|
|
7992
|
+
* @param {number} [searchRange] - Max box-radius in tiles
|
|
7993
|
+
* @param {boolean} [rebuild] - Whether to call buildNodeData first
|
|
7994
|
+
* @return {PathFinderNode|null} */
|
|
7800
7995
|
getNearestClearNode(worldPos: Vector2, searchRange?: number, rebuild?: boolean): PathFinderNode | null;
|
|
7801
7996
|
/** Smooth a node path by removing redundant turns and tightening corners
|
|
7802
7997
|
* where a grid-aligned diagonal is clear. Modifies the path in place.
|
|
@@ -7831,7 +8026,7 @@ declare module "littlejsengine" {
|
|
|
7831
8026
|
* and clear (walkable, zero-cost). Used by isLineClear's hot path.
|
|
7832
8027
|
* @param {number} x
|
|
7833
8028
|
* @param {number} y
|
|
7834
|
-
* @
|
|
8029
|
+
* @return {boolean}
|
|
7835
8030
|
* @private */
|
|
7836
8031
|
private isNodeClear;
|
|
7837
8032
|
/** Check that the line between two tile-coord endpoints stays entirely
|
|
@@ -7843,7 +8038,7 @@ declare module "littlejsengine" {
|
|
|
7843
8038
|
* CheckLine() in pathFinding.cpp.
|
|
7844
8039
|
* @param {Vector2} startPos - Tile coords
|
|
7845
8040
|
* @param {Vector2} endPos - Tile coords
|
|
7846
|
-
* @
|
|
8041
|
+
* @return {boolean}
|
|
7847
8042
|
* @private */
|
|
7848
8043
|
private isLineClear;
|
|
7849
8044
|
/** Find a path from startPos to endPos in world space. Returns an array
|
|
@@ -7860,7 +8055,7 @@ declare module "littlejsengine" {
|
|
|
7860
8055
|
* @param {Vector2} startPos - World-space start
|
|
7861
8056
|
* @param {Vector2} endPos - World-space end
|
|
7862
8057
|
* @param {boolean} [rebuild] - Whether to call buildNodeData first
|
|
7863
|
-
* @
|
|
8058
|
+
* @return {Vector2[]} */
|
|
7864
8059
|
findPath(startPos: Vector2, endPos: Vector2, rebuild?: boolean): Vector2[];
|
|
7865
8060
|
}
|
|
7866
8061
|
/** A single grid cell tracked by the pathfinder. Allocated once per cell at
|
|
@@ -7868,7 +8063,8 @@ declare module "littlejsengine" {
|
|
|
7868
8063
|
* findPath call.
|
|
7869
8064
|
* @memberof PathFinding */
|
|
7870
8065
|
export class PathFinderNode {
|
|
7871
|
-
/**
|
|
8066
|
+
/** Make the node of a grid cell, as PathFinder does for each
|
|
8067
|
+
* @param {number} x - Tile x
|
|
7872
8068
|
* @param {number} y - Tile y */
|
|
7873
8069
|
constructor(x: number, y: number);
|
|
7874
8070
|
/** @property {Vector2} - Tile coords (integer) */
|
|
@@ -7898,7 +8094,8 @@ declare module "littlejsengine" {
|
|
|
7898
8094
|
resetSearch(): void;
|
|
7899
8095
|
/** Reset per-search state and walkability (called by buildNodeData). */
|
|
7900
8096
|
reset(): void;
|
|
7901
|
-
/** True if walkable and not blocked by cost.
|
|
8097
|
+
/** True if walkable and not blocked by cost.
|
|
8098
|
+
* @return {boolean} */
|
|
7902
8099
|
isClear(): boolean;
|
|
7903
8100
|
}
|
|
7904
8101
|
/** Options for a tweak
|
|
@@ -8594,7 +8791,8 @@ declare module "littlejsengine" {
|
|
|
8594
8791
|
streamCount: number;
|
|
8595
8792
|
/** @type {TextureInfo|undefined} */
|
|
8596
8793
|
streamTileInfo: TextureInfo | undefined;
|
|
8597
|
-
|
|
8794
|
+
/** @type {Object|undefined} */
|
|
8795
|
+
streamState: any | undefined;
|
|
8598
8796
|
streamUnlit: boolean;
|
|
8599
8797
|
/** @type {Mesh|undefined} */
|
|
8600
8798
|
capture: Mesh | undefined;
|
|
@@ -10423,7 +10621,8 @@ declare module "littlejsengine" {
|
|
|
10423
10621
|
* @memberof GLTF
|
|
10424
10622
|
*/
|
|
10425
10623
|
export class GLTFModel {
|
|
10426
|
-
/**
|
|
10624
|
+
/** Make a model from its parts, as the loader does
|
|
10625
|
+
* @param {Array<GLTFPart>} parts @param {Array<GLTFAnimation>} [animations] @param {Object} [nodeTree] */
|
|
10427
10626
|
constructor(parts: Array<GLTFPart>, animations?: GLTFAnimation[], nodeTree?: any);
|
|
10428
10627
|
/** @property {Array<GLTFPart>} - One per primitive of every node that has a mesh */
|
|
10429
10628
|
parts: GLTFPart[];
|
|
@@ -10470,6 +10669,7 @@ declare module "littlejsengine" {
|
|
|
10470
10669
|
* @param {number} time - Seconds into it
|
|
10471
10670
|
* @return {Array<Matrix4>} */
|
|
10472
10671
|
getPose(animation: GLTFAnimation, time: number): Array<Matrix4>;
|
|
10672
|
+
partPoses(worldOf: any): Matrix4[];
|
|
10473
10673
|
/** Free the GPU buffers of every part's mesh and of the combined mesh, and the textures, for a model that is
|
|
10474
10674
|
* done with, like a level's models when the next level loads
|
|
10475
10675
|
* - Destroy the objects createObject made from it first; a mesh drawn again only uploads again, but a freed
|
|
@@ -10487,9 +10687,11 @@ declare module "littlejsengine" {
|
|
|
10487
10687
|
* - Loads glTF 2.0 models: a .gltf with its .bin and images beside it, or a .glb with everything in one file
|
|
10488
10688
|
* - A model comes back as parts, one Mesh per primitive of every node placed by the node tree, each with its
|
|
10489
10689
|
* material's color and base color texture, plus everything combined into one Mesh
|
|
10490
|
-
* - Geometry: positions, normals, uvs, vertex colors and indices
|
|
10491
|
-
*
|
|
10492
|
-
*
|
|
10690
|
+
* - Geometry: positions, normals, uvs, vertex colors and indices, and skins, the four strongest joints of a vertex
|
|
10691
|
+
* of up to eight; morph targets are not read
|
|
10692
|
+
* - Animations play through the GLTFObject that createObject makes: parts that move, turn and scale, like doors,
|
|
10693
|
+
* wheels and propellers, and skinned characters, their meshes bent by their joints each frame; play takes a
|
|
10694
|
+
* blend time to cross-fade from one animation to the next
|
|
10493
10695
|
* - Materials give a base color and texture and whether they blend; glass made with KHR_materials_transmission blends too,
|
|
10494
10696
|
* and a KHR_materials_unlit material comes in emissive, its own color with no shading
|
|
10495
10697
|
* - A material's normal map and emissive map load too, with its normal scale and emissive factor, read at the base
|
|
@@ -10507,6 +10709,7 @@ declare module "littlejsengine" {
|
|
|
10507
10709
|
* const model = await loadGLTF('ship.glb'); // in an async gameInit
|
|
10508
10710
|
* const ship = model.createObject(vec3(0, 1, 0)); // an object with a child per part, textures and all
|
|
10509
10711
|
* ship.play('fly'); // and its animation, by name or number
|
|
10712
|
+
* ship.play('land', false, 1, .3); // then another, cross-faded over .3 seconds
|
|
10510
10713
|
* new EngineObject3D(vec3(), model.mesh); // or the whole thing as one mesh, still
|
|
10511
10714
|
*/
|
|
10512
10715
|
/**
|
|
@@ -10514,7 +10717,8 @@ declare module "littlejsengine" {
|
|
|
10514
10717
|
* @memberof GLTF
|
|
10515
10718
|
*/
|
|
10516
10719
|
export class GLTFPart {
|
|
10517
|
-
/**
|
|
10720
|
+
/** Make a part, as the loader does for each primitive
|
|
10721
|
+
* @param {string} name @param {Mesh} mesh @param {Color} color @param {TextureInfo|undefined} textureInfo @param {boolean} transparent */
|
|
10518
10722
|
constructor(name: string, mesh: Mesh, color: Color, textureInfo: TextureInfo | undefined, transparent: boolean);
|
|
10519
10723
|
/** @property {string} - The node's name, or its mesh's */
|
|
10520
10724
|
name: string;
|
|
@@ -10547,6 +10751,12 @@ declare module "littlejsengine" {
|
|
|
10547
10751
|
emissiveMap: TextureInfo | undefined;
|
|
10548
10752
|
/** @property {Color} - The emissiveFactor, which multiplies the emissive map */
|
|
10549
10753
|
emissiveMapColor: Color;
|
|
10754
|
+
/** @property {GLTFSkin|undefined} - For a skinned mesh, what bends it: mesh is its resting pose, and the
|
|
10755
|
+
* object createObject makes bends a copy of its own to each pose
|
|
10756
|
+
* @type {GLTFSkin|undefined} */
|
|
10757
|
+
skin: GLTFSkin | undefined;
|
|
10758
|
+
/** @type {Array<number>|undefined} */
|
|
10759
|
+
vertexSource: Array<number> | undefined;
|
|
10550
10760
|
}
|
|
10551
10761
|
/**
|
|
10552
10762
|
* GLTFObject - A model as an object with a child per part, which plays the model's animations
|
|
@@ -10577,28 +10787,65 @@ declare module "littlejsengine" {
|
|
|
10577
10787
|
animationLoop: boolean;
|
|
10578
10788
|
/** @property {boolean} - Whether it is moving through the animation now */
|
|
10579
10789
|
animationPlaying: boolean;
|
|
10790
|
+
/** @type {{animation?: GLTFAnimation, time?: number, speed?: number, loop?: boolean, nodes?: Map<number, Object>}|undefined} */
|
|
10791
|
+
blendFrom: {
|
|
10792
|
+
animation?: GLTFAnimation;
|
|
10793
|
+
time?: number;
|
|
10794
|
+
speed?: number;
|
|
10795
|
+
loop?: boolean;
|
|
10796
|
+
nodes?: Map<number, any>;
|
|
10797
|
+
} | undefined;
|
|
10798
|
+
blendTime: number;
|
|
10799
|
+
blendElapsed: number;
|
|
10800
|
+
/** @type {Map<number, Object>|undefined} */
|
|
10801
|
+
poseNodes: Map<number, any> | undefined;
|
|
10802
|
+
poseMixed: boolean;
|
|
10803
|
+
/** @type {(function(number): Matrix4)|undefined} */
|
|
10804
|
+
poseWorldOf: ((arg0: number) => Matrix4) | undefined;
|
|
10580
10805
|
/** @property {Array<EngineObject3D>} - The child that draws each of the model's parts, in the order of
|
|
10581
10806
|
* model.parts, which an animation poses; one destroyed or taken off the object is left alone
|
|
10582
10807
|
* @type {Array<EngineObject3D>} */
|
|
10583
10808
|
parts: Array<EngineObject3D>;
|
|
10584
|
-
/** Play an animation from its start
|
|
10809
|
+
/** Play an animation from its start, at once or cross-faded from the pose it is in
|
|
10810
|
+
* - A play with a blend of the animation already playing goes on with it, so state code may call it each
|
|
10811
|
+
* frame; without a blend it starts the animation again
|
|
10585
10812
|
* @param {string|number|GLTFAnimation} [animation] - Its name, its number in model.animations, or itself
|
|
10586
10813
|
* @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
|
-
|
|
10589
|
-
|
|
10814
|
+
* @param {number} [speed] - 1 is as made, negative plays it backward from its end
|
|
10815
|
+
* @param {number} [blend] - Seconds to cross-fade from the pose it is in, 0 to switch at once; the animation
|
|
10816
|
+
* it comes from goes on through the fade, and a fade started during another fades from the mix there */
|
|
10817
|
+
play(animation?: string | number | GLTFAnimation, loop?: boolean, speed?: number, blend?: number): void;
|
|
10818
|
+
/** Stop the animation where it is, the parts hold that pose; a cross-fade going on stops too, holding the mix */
|
|
10590
10819
|
stop(): void;
|
|
10591
10820
|
/** Put the parts where the animation has them at a time, playing or not
|
|
10592
10821
|
* @param {number} time - Seconds into the animation */
|
|
10593
10822
|
setAnimationTime(time: number): void;
|
|
10823
|
+
/** A node's matrix in the world as the model is posed now, by its name in the file, to hang something on a
|
|
10824
|
+
* joint, a sword on a hand or a hat on a head; undefined when the model has no node of that name
|
|
10825
|
+
* @param {string} name
|
|
10826
|
+
* @return {Matrix4|undefined} */
|
|
10827
|
+
getJointMatrix(name: string): Matrix4 | undefined;
|
|
10594
10828
|
}
|
|
10829
|
+
/**
|
|
10830
|
+
* What bends a skinned part: its joints, the nodes that move it, their inverse bind matrices, and for each vertex
|
|
10831
|
+
* of its mesh four joints and four weights, with the place and normal each pose bends from
|
|
10832
|
+
* @typedef {Object} GLTFSkin
|
|
10833
|
+
* @property {Array<number>} joints - The joints, as node numbers
|
|
10834
|
+
* @property {Array<Matrix4>} inverseBind - Each joint's inverse bind matrix
|
|
10835
|
+
* @property {Uint16Array} vertexJoints - Four joints a vertex, as places in joints
|
|
10836
|
+
* @property {Float32Array} vertexWeights - Four weights a vertex, summing to 1
|
|
10837
|
+
* @property {Float32Array} bindPoints - Each vertex's place as stored, x y z
|
|
10838
|
+
* @property {Float32Array} bindNormals - Each vertex's normal as stored, x y z
|
|
10839
|
+
* @memberof GLTF
|
|
10840
|
+
*/
|
|
10595
10841
|
/**
|
|
10596
10842
|
* GLTFAnimation - One animation of a model: keys that move, turn and scale its nodes over time
|
|
10597
10843
|
* - Play it through the GLTFObject that model.createObject makes
|
|
10598
10844
|
* @memberof GLTF
|
|
10599
10845
|
*/
|
|
10600
10846
|
export class GLTFAnimation {
|
|
10601
|
-
/**
|
|
10847
|
+
/** Make an animation from its channels, as the loader does
|
|
10848
|
+
* @param {string} name @param {Array<Object>} channels */
|
|
10602
10849
|
constructor(name: string, channels: Array<any>);
|
|
10603
10850
|
/** @property {string} - Its name in the file, or 'animation' and its number when it has none */
|
|
10604
10851
|
name: string;
|
|
@@ -10677,13 +10924,15 @@ declare module "littlejsengine" {
|
|
|
10677
10924
|
* - Adding a name again replaces it, Box, Sphere, Cylinder and Light too
|
|
10678
10925
|
* @param {string} name - The type the objects have in the level
|
|
10679
10926
|
* @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
|
|
10927
|
+
* @param {Object<string, any>} [defaults] - Properties of each one made, the level editor shows inputs for them
|
|
10681
10928
|
* @param {TileInfo} [tileInfo] - An icon for the level editor
|
|
10682
10929
|
* @memberof Level3D
|
|
10683
10930
|
* @example
|
|
10684
10931
|
* level3DAddType('Crate', Crate, {health: 3});
|
|
10685
10932
|
* level3DAddType('PlayerStart', (pos)=> playerStart = pos); */
|
|
10686
|
-
export function level3DAddType(name: string, make: Function, defaults?:
|
|
10933
|
+
export function level3DAddType(name: string, make: Function, defaults?: {
|
|
10934
|
+
[x: string]: any;
|
|
10935
|
+
}, tileInfo?: TileInfo): void;
|
|
10687
10936
|
/** 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
10937
|
* - Each object has a color and a solid property, solid collides as the box around the mesh
|
|
10689
10938
|
* @param {string} name - The type the objects have in the level
|
|
@@ -10717,10 +10966,10 @@ declare module "littlejsengine" {
|
|
|
10717
10966
|
* sunColor, fog, its start and end, fogColor, the horizon color when not given, shadows, and lensFlare, the
|
|
10718
10967
|
* sun's lens flare; what the block leaves out stays as the game set it, and a level with no block changes
|
|
10719
10968
|
* nothing
|
|
10720
|
-
* @param {
|
|
10969
|
+
* @param {Level3D} level - The level, the level editor edits this same object
|
|
10721
10970
|
* @return {Array<any>} - What each object's type made, a function that made nothing is left out
|
|
10722
10971
|
* @memberof Level3D */
|
|
10723
|
-
export function level3DLoad(level:
|
|
10972
|
+
export function level3DLoad(level: Level3D): Array<any>;
|
|
10724
10973
|
/** Add a prefab: a small level, its objects placed about its own origin, to place many times under one name
|
|
10725
10974
|
* - It is a type from then on: a level's object of that type, the level editor's Place list and level3DSpawn make
|
|
10726
10975
|
* an instance, a Prefab3D; an instance is made of the prefab as it is then, so the level editor, where a prefab
|
|
@@ -10733,13 +10982,17 @@ declare module "littlejsengine" {
|
|
|
10733
10982
|
* by hand does
|
|
10734
10983
|
* - Adding a name again replaces it
|
|
10735
10984
|
* @param {string} name - The type its instances have in a level
|
|
10736
|
-
* @param {Object} prefab -
|
|
10985
|
+
* @param {{objects: Array<Object>, attached?: boolean}} prefab - Its objects, about its own origin, and whether
|
|
10986
|
+
* they are attached
|
|
10737
10987
|
* @memberof Level3D
|
|
10738
10988
|
* @example
|
|
10739
10989
|
* level3DAddPrefab('Tower', {objects: [{type: 'Box', pos: [0, 1, 0], scale: [2, 2, 2]},
|
|
10740
10990
|
* {type: 'Cylinder', pos: [0, 3, 0]}]});
|
|
10741
10991
|
* 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:
|
|
10992
|
+
export function level3DAddPrefab(name: string, prefab: {
|
|
10993
|
+
objects: Array<any>;
|
|
10994
|
+
attached?: boolean;
|
|
10995
|
+
}): void;
|
|
10743
10996
|
/** Load a prefab from a file the level editor saved and add it
|
|
10744
10997
|
* @param {string} name - The type its instances have in a level
|
|
10745
10998
|
* @param {string} url
|
|
@@ -10752,13 +11005,15 @@ declare module "littlejsengine" {
|
|
|
10752
11005
|
* @param {Vector3} [pos3D]
|
|
10753
11006
|
* @param {Vector3} [rotation3D] - In radians, as an object has it
|
|
10754
11007
|
* @param {Vector3} [scale3D] - Times the scale the type makes it with
|
|
10755
|
-
* @param {Object} [properties] - Over the type's defaults
|
|
11008
|
+
* @param {Object<string, any>} [properties] - Over the type's defaults
|
|
10756
11009
|
* @return {any} - What the type made, a Prefab3D for a prefab, undefined when there is no such type
|
|
10757
11010
|
* @memberof Level3D
|
|
10758
11011
|
* @example
|
|
10759
11012
|
* level3DAddPrefab('House', await fetchJSON('house.json'));
|
|
10760
11013
|
* level3DSpawn('House', vec3(10, 0, 0), vec3(0, PI/2, 0)); */
|
|
10761
|
-
export function level3DSpawn(type: string, pos3D?: Vector3, rotation3D?: Vector3, scale3D?: Vector3, properties?:
|
|
11014
|
+
export function level3DSpawn(type: string, pos3D?: Vector3, rotation3D?: Vector3, scale3D?: Vector3, properties?: {
|
|
11015
|
+
[x: string]: any;
|
|
11016
|
+
}): any;
|
|
10762
11017
|
/**
|
|
10763
11018
|
* 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
11019
|
* prefab's objects made
|
|
@@ -11099,10 +11354,10 @@ declare module "littlejsengine" {
|
|
|
11099
11354
|
}[];
|
|
11100
11355
|
};
|
|
11101
11356
|
/** A copy of an effect with its four colors turned around the color wheel and their saturation scaled; lightness and
|
|
11102
|
-
* alpha stay, and
|
|
11357
|
+
* alpha stay, and gray and white have no hue to turn
|
|
11103
11358
|
* @param {Object} effect
|
|
11104
11359
|
* @param {number} [hue] - How far around the wheel, 1 is all the way
|
|
11105
|
-
* @param {number} [saturation] - Multiplies the saturation, 0 is
|
|
11360
|
+
* @param {number} [saturation] - Multiplies the saturation, 0 is gray, clamped to 1
|
|
11106
11361
|
* @return {Object}
|
|
11107
11362
|
* @memberof ParticleEffects */
|
|
11108
11363
|
export function particleEffectRecolor(effect: any, hue?: number, saturation?: number): any;
|
|
@@ -11146,7 +11401,7 @@ declare module "littlejsengine" {
|
|
|
11146
11401
|
* @param {Object} [options] - What to change for this play, each left out when not wanted:
|
|
11147
11402
|
* scale grows the whole effect, the built-ins fit a one unit object at 1;
|
|
11148
11403
|
* hue turns its colors around the color wheel, 1 is all the way;
|
|
11149
|
-
* saturation multiplies its saturation, 0 is
|
|
11404
|
+
* saturation multiplies its saturation, 0 is gray;
|
|
11150
11405
|
* angle is its direction, 0 is up, the effect's own angle when not given;
|
|
11151
11406
|
* tileInfo, a TileInfo or a TextureInfo, is the game's own art to draw with in place of the effect's shape,
|
|
11152
11407
|
* tinted by its colors, a whole texture drawn as one tile;
|