littlejsengine 1.24.2 → 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 +55 -0
- package/EDITOR.md +2 -2
- package/FAQ.md +6 -0
- package/REFERENCE.md +86 -41
- package/dist/littlejs.d.ts +600 -323
- package/dist/littlejs.esm.js +2412 -1797
- package/dist/littlejs.esm.min.js +38 -24
- package/dist/littlejs.js +2410 -1797
- package/dist/littlejs.min.js +37 -23
- package/dist/littlejs.release.js +2393 -1826
- package/package.json +1 -1
- package/plugins/box2d.js +41 -28
- package/plugins/drawUtilities.js +374 -380
- package/plugins/gltf.js +331 -55
- 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 +31 -10
- package/plugins/render3dLevel.js +15 -4
- package/plugins/textureSheet.js +15 -7
- package/plugins/tweenSystem.js +43 -38
- package/plugins/uiSystem.js +25 -20
- package/src/engine.js +39 -21
- package/src/engineAudio.js +13 -9
- package/src/engineBuild.mjs +49 -2
- package/src/engineDebug.js +3 -2
- package/src/engineDraw.js +20 -18
- package/src/engineEditor.js +75 -23
- package/src/engineInput.js +10 -10
- 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 +34 -12
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,8 +658,9 @@ declare module "littlejsengine" {
|
|
|
549
658
|
* ()=> { drawHUD(); }, // gameRenderPost
|
|
550
659
|
* ['tiles.png', 'tilesLevel.png'] // images to load
|
|
551
660
|
* );
|
|
552
|
-
* @memberof Engine
|
|
553
|
-
|
|
661
|
+
* @memberof Engine
|
|
662
|
+
* @return {Promise<void>} - Done when the images have loaded and gameInit has run */
|
|
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
|
|
556
666
|
* Respects paused exactly as the normal update loop does
|
|
@@ -584,7 +694,7 @@ declare module "littlejsengine" {
|
|
|
584
694
|
* @param {boolean} [testCenters] - Test only each object's center, a little faster, and ignores object sizes
|
|
585
695
|
* @return {Array<EngineObject>} - List of collected objects
|
|
586
696
|
* @memberof Engine */
|
|
587
|
-
export function engineObjectsCollect(pos?: Vector2, size?:
|
|
697
|
+
export function engineObjectsCollect(pos?: Vector2, size?: number | Vector2, objects?: EngineObject[], testCenters?: boolean): Array<EngineObject>;
|
|
588
698
|
/**
|
|
589
699
|
* @callback ObjectCallbackFunction - Function that processes an object
|
|
590
700
|
* @param {EngineObject} object
|
|
@@ -598,7 +708,7 @@ declare module "littlejsengine" {
|
|
|
598
708
|
* @param {Array<EngineObject>} [objects=engineObjects] - List of objects to check
|
|
599
709
|
* @param {boolean} [testCenters] - Test only each object's center, see engineObjectsCollect
|
|
600
710
|
* @memberof Engine */
|
|
601
|
-
export function engineObjectsCallback(pos?: Vector2, size?:
|
|
711
|
+
export function engineObjectsCallback(pos?: Vector2, size?: number | Vector2, callbackFunction?: ObjectCallbackFunction, objects?: EngineObject[], testCenters?: boolean): void;
|
|
602
712
|
/** Return a list of objects intersecting a ray, objects destroyed this frame left out
|
|
603
713
|
* - Only objects with collideRaycast set are hit, which setCollision turns on
|
|
604
714
|
* @param {Vector2} start
|
|
@@ -606,7 +716,7 @@ declare module "littlejsengine" {
|
|
|
606
716
|
* @param {Array<EngineObject>} [objects=engineObjects] - List of objects to check
|
|
607
717
|
* @return {Array<EngineObject>} - List of objects hit
|
|
608
718
|
* @memberof Engine */
|
|
609
|
-
export function engineObjectsRaycast(start: Vector2, end: Vector2, objects?:
|
|
719
|
+
export function engineObjectsRaycast(start: Vector2, end: Vector2, objects?: EngineObject[]): Array<EngineObject>;
|
|
610
720
|
/**
|
|
611
721
|
* @callback PluginCallback - Update or render function for a plugin
|
|
612
722
|
* @memberof Engine
|
|
@@ -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;
|
|
@@ -868,7 +982,7 @@ declare module "littlejsengine" {
|
|
|
868
982
|
* place(type, pos3D); setTransform(object, pos3D, rotationDegrees, scale3D); setProperty(object, name, value);
|
|
869
983
|
* pos(object), rotation(object) and scale(object); mousePoint(); undo(redo); toJSON()
|
|
870
984
|
* @return {EditorEdit3D|undefined} */
|
|
871
|
-
get edit3D(): EditorEdit3D;
|
|
985
|
+
get edit3D(): EditorEdit3D | undefined;
|
|
872
986
|
/** Add a key of the game's own to the editor, the 2D and the 3D one
|
|
873
987
|
* - Escape and 0 are the editor's own, to play and to exit, and Ctrl is the one modifier: Shift is given to
|
|
874
988
|
* the action
|
|
@@ -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,14 +1037,14 @@ 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]
|
|
929
1044
|
* @param {boolean} [fill]
|
|
930
1045
|
* @param {boolean} [screenSpace=drawScreenSpace]
|
|
931
1046
|
* @memberof Debug */
|
|
932
|
-
export function debugRect(pos: Vector2, size?: Vector2, color?:
|
|
1047
|
+
export function debugRect(pos: Vector2, size?: Vector2, color?: string | Color, time?: number, angle?: number, fill?: boolean, screenSpace?: boolean): void;
|
|
933
1048
|
/** Draw a debug poly in world space, or on the screen with screenSpace
|
|
934
1049
|
* @param {Vector2} pos
|
|
935
1050
|
* @param {Array<Vector2>} points
|
|
@@ -939,7 +1054,7 @@ declare module "littlejsengine" {
|
|
|
939
1054
|
* @param {boolean} [fill]
|
|
940
1055
|
* @param {boolean} [screenSpace=drawScreenSpace]
|
|
941
1056
|
* @memberof Debug */
|
|
942
|
-
export function debugPoly(pos: Vector2, points: Array<Vector2>, color?:
|
|
1057
|
+
export function debugPoly(pos: Vector2, points: Array<Vector2>, color?: string | Color, time?: number, angle?: number, fill?: boolean, screenSpace?: boolean): void;
|
|
943
1058
|
/** Draw a debug circle in world space, or on the screen with screenSpace
|
|
944
1059
|
* @param {Vector2} pos
|
|
945
1060
|
* @param {number} [size] - diameter
|
|
@@ -948,7 +1063,7 @@ declare module "littlejsengine" {
|
|
|
948
1063
|
* @param {boolean} [fill]
|
|
949
1064
|
* @param {boolean} [screenSpace=drawScreenSpace]
|
|
950
1065
|
* @memberof Debug */
|
|
951
|
-
export function debugCircle(pos: Vector2, size?: number, color?:
|
|
1066
|
+
export function debugCircle(pos: Vector2, size?: number, color?: string | Color, time?: number, fill?: boolean, screenSpace?: boolean): void;
|
|
952
1067
|
/** Draw a debug point in world space, or on the screen with screenSpace
|
|
953
1068
|
* @param {Vector2} pos
|
|
954
1069
|
* @param {Color|string} [color]
|
|
@@ -956,7 +1071,7 @@ declare module "littlejsengine" {
|
|
|
956
1071
|
* @param {number} [angle]
|
|
957
1072
|
* @param {boolean} [screenSpace=drawScreenSpace]
|
|
958
1073
|
* @memberof Debug */
|
|
959
|
-
export function debugPoint(pos: Vector2, color?:
|
|
1074
|
+
export function debugPoint(pos: Vector2, color?: string | Color, time?: number, angle?: number, screenSpace?: boolean): void;
|
|
960
1075
|
/** Draw a debug line in world space, or on the screen with screenSpace
|
|
961
1076
|
* @param {Vector2} posA
|
|
962
1077
|
* @param {Vector2} posB
|
|
@@ -965,7 +1080,7 @@ declare module "littlejsengine" {
|
|
|
965
1080
|
* @param {number} [time]
|
|
966
1081
|
* @param {boolean} [screenSpace=drawScreenSpace]
|
|
967
1082
|
* @memberof Debug */
|
|
968
|
-
export function debugLine(posA: Vector2, posB: Vector2, color?:
|
|
1083
|
+
export function debugLine(posA: Vector2, posB: Vector2, color?: string | Color, width?: number, time?: number, screenSpace?: boolean): void;
|
|
969
1084
|
/** Draw a debug combined axis aligned bounding box in world space, or on the screen with screenSpace
|
|
970
1085
|
* @param {Vector2} posA
|
|
971
1086
|
* @param {Vector2} sizeA
|
|
@@ -975,7 +1090,7 @@ declare module "littlejsengine" {
|
|
|
975
1090
|
* @param {number} [time]
|
|
976
1091
|
* @param {boolean} [screenSpace=drawScreenSpace]
|
|
977
1092
|
* @memberof Debug */
|
|
978
|
-
export function debugOverlap(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB: Vector2, color?:
|
|
1093
|
+
export function debugOverlap(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB: Vector2, color?: string | Color, time?: number, screenSpace?: boolean): void;
|
|
979
1094
|
/** Draw debug text in world space, or on the screen with screenSpace
|
|
980
1095
|
* @param {string|number} text
|
|
981
1096
|
* @param {Vector2} pos
|
|
@@ -986,7 +1101,7 @@ declare module "littlejsengine" {
|
|
|
986
1101
|
* @param {string} [font]
|
|
987
1102
|
* @param {boolean} [screenSpace=drawScreenSpace]
|
|
988
1103
|
* @memberof Debug */
|
|
989
|
-
export function debugText(text: string | number, pos: Vector2, size?: number, color?:
|
|
1104
|
+
export function debugText(text: string | number, pos: Vector2, size?: number, color?: string | Color, time?: number, angle?: number, font?: string, screenSpace?: boolean): void;
|
|
990
1105
|
/** Clear all debug primitives in the list
|
|
991
1106
|
* @memberof Debug */
|
|
992
1107
|
export function debugClear(): void;
|
|
@@ -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
|
|
@@ -2524,7 +2640,7 @@ declare module "littlejsengine" {
|
|
|
2524
2640
|
* tile(1, 16, 3) // a tile at index 1 of size 16 on texture 3
|
|
2525
2641
|
* tile(vec2(4,8), vec2(30,10)) // a tile at index (4,8) with a size of (30,10)
|
|
2526
2642
|
* @memberof Draw */
|
|
2527
|
-
export function tile(index?:
|
|
2643
|
+
export function tile(index?: number | Vector2, size?: number | Vector2, texture?: number | TextureInfo, padding?: number, bleed?: number): TileInfo;
|
|
2528
2644
|
/**
|
|
2529
2645
|
* Tile Info - Stores info about how to draw a tile
|
|
2530
2646
|
* @memberof Draw
|
|
@@ -2577,7 +2693,7 @@ declare module "littlejsengine" {
|
|
|
2577
2693
|
* @param {Vector2|number} [index=0]
|
|
2578
2694
|
* @return {TileInfo}
|
|
2579
2695
|
*/
|
|
2580
|
-
index(index?:
|
|
2696
|
+
index(index?: number | Vector2): TileInfo;
|
|
2581
2697
|
/**
|
|
2582
2698
|
* Set this tile to use a full image in a texture info
|
|
2583
2699
|
* @param {TextureInfo} [textureInfo]
|
|
@@ -2598,7 +2714,7 @@ declare module "littlejsengine" {
|
|
|
2598
2714
|
* modes across and down, like [gl.CLAMP_TO_EDGE, gl.MIRRORED_REPEAT], as a glTF sampler gives them
|
|
2599
2715
|
* @param {boolean} [pixelated] - Hard edged or smooth for this texture alone, undefined follows tilesPixelated
|
|
2600
2716
|
*/
|
|
2601
|
-
constructor(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, useWebGL?: boolean, wrap?: boolean |
|
|
2717
|
+
constructor(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, useWebGL?: boolean, wrap?: boolean | number[], pixelated?: boolean);
|
|
2602
2718
|
/** @property {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} - image source */
|
|
2603
2719
|
image: OffscreenCanvas | ImageBitmap | HTMLCanvasElement | HTMLImageElement;
|
|
2604
2720
|
/** @property {Vector2} - size of the image */
|
|
@@ -2626,7 +2742,7 @@ declare module "littlejsengine" {
|
|
|
2626
2742
|
/** Set the wrap mode for this texture
|
|
2627
2743
|
* @param {boolean|Array<number>} [wrap] - true for REPEAT, false for CLAMP_TO_EDGE, or the WebGL modes across
|
|
2628
2744
|
* and down */
|
|
2629
|
-
setWrap(wrap?: boolean |
|
|
2745
|
+
setWrap(wrap?: boolean | number[]): void;
|
|
2630
2746
|
/** Make this texture hard edged or smooth on its own, whatever tilesPixelated says for the rest; it is made again
|
|
2631
2747
|
* with the new filtering
|
|
2632
2748
|
* @param {boolean} [pixelated] - undefined follows tilesPixelated again */
|
|
@@ -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,15 +3065,15 @@ 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?
|
|
2958
3074
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
2959
3075
|
* @memberof Draw */
|
|
2960
|
-
export function drawTextureWrapped(pos: Vector2, size: Vector2, wrapCount: Vector2, texture?:
|
|
3076
|
+
export function drawTextureWrapped(pos: Vector2, size: Vector2, wrapCount: Vector2, texture?: number | TextureInfo, color?: Color, angle?: number, additiveColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
2961
3077
|
/** Draw connected lines between a series of points
|
|
2962
3078
|
* @param {Array<Vector2>} points
|
|
2963
3079
|
* @param {number} [width]
|
|
@@ -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,14 +3201,14 @@ 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]
|
|
3092
3208
|
* @param {number} [angle]
|
|
3093
3209
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
3094
3210
|
* @memberof Draw */
|
|
3095
|
-
export function drawText(text: string | number, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?:
|
|
3211
|
+
export function drawText(text: string | number, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: "center" | "left" | "right", font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
3096
3212
|
/** Draw text in screen space
|
|
3097
3213
|
* Automatically splits new lines into rows
|
|
3098
3214
|
* @param {string|number} text
|
|
@@ -3108,7 +3224,7 @@ declare module "littlejsengine" {
|
|
|
3108
3224
|
* @param {number} [angle] - Clockwise, like the other screen space draws
|
|
3109
3225
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
3110
3226
|
* @memberof Draw */
|
|
3111
|
-
export function drawTextScreen(text: string | number, pos: Vector2, size: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?:
|
|
3227
|
+
export function drawTextScreen(text: string | number, pos: Vector2, size: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: "center" | "left" | "right", font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
3112
3228
|
/** Enable additive blending
|
|
3113
3229
|
* @param {boolean} [additive]
|
|
3114
3230
|
* @memberof Draw */
|
|
@@ -3164,7 +3280,7 @@ declare module "littlejsengine" {
|
|
|
3164
3280
|
* @param {boolean} [useWebGL=glEnable]
|
|
3165
3281
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
3166
3282
|
*/
|
|
3167
|
-
drawText(text: string | number, pos: Vector2, size?:
|
|
3283
|
+
drawText(text: string | number, pos: Vector2, size?: number | Vector2, center?: boolean, color?: Color, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
3168
3284
|
/** Draw text in screen space using the image font
|
|
3169
3285
|
* @param {string|number} text
|
|
3170
3286
|
* @param {Vector2} pos
|
|
@@ -3224,7 +3340,7 @@ declare module "littlejsengine" {
|
|
|
3224
3340
|
* @param {Vector2|number} [size] - world space size or diameter
|
|
3225
3341
|
* @return {boolean}
|
|
3226
3342
|
* @memberof Draw */
|
|
3227
|
-
export function isOnScreen(pos: Vector2, size?:
|
|
3343
|
+
export function isOnScreen(pos: Vector2, size?: number | Vector2): boolean;
|
|
3228
3344
|
/**
|
|
3229
3345
|
* LittleJS WebGL Interface
|
|
3230
3346
|
* - WebGL2 rendering engine for high-performance graphics
|
|
@@ -3266,27 +3382,27 @@ declare module "littlejsengine" {
|
|
|
3266
3382
|
* @param {boolean|Array<number>} [wrap] - true for REPEAT, false for CLAMP_TO_EDGE, or the WebGL modes across and
|
|
3267
3383
|
* down, like [gl.CLAMP_TO_EDGE, gl.MIRRORED_REPEAT]
|
|
3268
3384
|
* @memberof WebGL */
|
|
3269
|
-
export function glSetTextureWrap(texture: WebGLTexture, wrap?: boolean |
|
|
3385
|
+
export function glSetTextureWrap(texture: WebGLTexture, wrap?: boolean | number[]): void;
|
|
3270
3386
|
/** Compile WebGL shader of the given type, will throw errors if in debug mode
|
|
3271
3387
|
* @param {string} source
|
|
3272
3388
|
* @param {number} type
|
|
3273
|
-
* @return {WebGLShader}
|
|
3389
|
+
* @return {WebGLShader|undefined} - undefined with no WebGL
|
|
3274
3390
|
* @memberof WebGL */
|
|
3275
|
-
export function glCompileShader(source: string, type: number): WebGLShader;
|
|
3391
|
+
export function glCompileShader(source: string, type: number): WebGLShader | undefined;
|
|
3276
3392
|
/** Create WebGL program with given shaders
|
|
3277
3393
|
* @param {string} vsSource
|
|
3278
3394
|
* @param {string} fsSource
|
|
3279
|
-
* @return {WebGLProgram}
|
|
3395
|
+
* @return {WebGLProgram|undefined} - undefined with no WebGL
|
|
3280
3396
|
* @memberof WebGL */
|
|
3281
|
-
export function glCreateProgram(vsSource: string, fsSource: string): WebGLProgram;
|
|
3397
|
+
export function glCreateProgram(vsSource: string, fsSource: string): WebGLProgram | undefined;
|
|
3282
3398
|
/** Create WebGL texture from an image and init the texture settings
|
|
3283
3399
|
* Restores the active texture when done
|
|
3284
3400
|
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} [image]
|
|
3285
3401
|
* @param {boolean|Array<number>} [wrap] - true for REPEAT, false for CLAMP_TO_EDGE, or the WebGL modes across and down
|
|
3286
3402
|
* @param {boolean} [pixelated] - Hard edged or smooth, undefined follows tilesPixelated
|
|
3287
|
-
* @return {WebGLTexture}
|
|
3403
|
+
* @return {WebGLTexture|undefined} - undefined with no WebGL
|
|
3288
3404
|
* @memberof WebGL */
|
|
3289
|
-
export function glCreateTexture(image?:
|
|
3405
|
+
export function glCreateTexture(image?: OffscreenCanvas | ImageBitmap | HTMLCanvasElement | HTMLImageElement, wrap?: boolean | number[], pixelated?: boolean): WebGLTexture | undefined;
|
|
3290
3406
|
/** Deletes a WebGL texture
|
|
3291
3407
|
* @param {WebGLTexture} [texture]
|
|
3292
3408
|
* @memberof WebGL */
|
|
@@ -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 | URL |
|
|
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
|
|
@@ -3700,16 +3813,16 @@ declare module "littlejsengine" {
|
|
|
3700
3813
|
get range(): number;
|
|
3701
3814
|
/** @property {boolean} - No range was given, so it got soundDefaultRange; played in 3D such a sound is heard
|
|
3702
3815
|
* to render3D.soundDefaultRange instead, which is further; setting range makes it false */
|
|
3703
|
-
rangeIsDefault: boolean;
|
|
3816
|
+
rangeIsDefault: boolean | undefined;
|
|
3704
3817
|
/** @property {number} - At what percentage of range should it start tapering */
|
|
3705
|
-
taper: number;
|
|
3818
|
+
taper: number | undefined;
|
|
3706
3819
|
/** @property {number} - How much to randomize frequency each time sound plays
|
|
3707
3820
|
* @type {number} */
|
|
3708
3821
|
randomness: number;
|
|
3709
3822
|
/** @property {number} - Sample rate for this sound */
|
|
3710
|
-
sampleRate: number;
|
|
3823
|
+
sampleRate: number | undefined;
|
|
3711
3824
|
/** @property {number} - How many samples per channel this sound has */
|
|
3712
|
-
sampleLength: number;
|
|
3825
|
+
sampleLength: number | undefined;
|
|
3713
3826
|
/** @property {AudioBuffer|undefined} - Decoded audio shared by every play of this sound
|
|
3714
3827
|
* @type {AudioBuffer|undefined} */
|
|
3715
3828
|
sampleBuffer: AudioBuffer | undefined;
|
|
@@ -3724,14 +3837,14 @@ declare module "littlejsengine" {
|
|
|
3724
3837
|
* @type {AudioNode|AudioEffectNodes|undefined} */
|
|
3725
3838
|
output: AudioNode | AudioEffectNodes | undefined;
|
|
3726
3839
|
/** @param {Array<Array<number>|Float32Array>} sampleChannels */
|
|
3727
|
-
set sampleChannels(arg: (number[] | Float32Array)[]);
|
|
3840
|
+
set sampleChannels(arg: (number[] | Float32Array)[] | undefined);
|
|
3728
3841
|
/** Sample data for each channel
|
|
3729
3842
|
* Sounds keep their samples in an audio buffer, so reading this rebuilds
|
|
3730
3843
|
* the arrays from it and caches them. The copies are safe to hold onto,
|
|
3731
3844
|
* playing a sound detaches the buffer's own channel arrays.
|
|
3732
3845
|
* @return {Array<Array<number>|Float32Array>|undefined} */
|
|
3733
|
-
get sampleChannels(): (number[] | Float32Array)[];
|
|
3734
|
-
rangeValue: number;
|
|
3846
|
+
get sampleChannels(): (number[] | Float32Array)[] | undefined;
|
|
3847
|
+
rangeValue: number | undefined;
|
|
3735
3848
|
/** Move this sound's samples into an audio buffer that every play can share
|
|
3736
3849
|
* Does nothing if there is already a buffer or no samples to build one from */
|
|
3737
3850
|
buildSampleBuffer(): void;
|
|
@@ -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?:
|
|
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;
|
|
@@ -4411,9 +4547,9 @@ declare module "littlejsengine" {
|
|
|
4411
4547
|
*/
|
|
4412
4548
|
constructor(pos?: Vector2, size?: Vector2, angle?: number, renderOrder?: number, canvasSize?: Vector2, useWebGL?: boolean);
|
|
4413
4549
|
/** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
|
|
4414
|
-
context: OffscreenCanvasRenderingContext2D;
|
|
4550
|
+
context: OffscreenCanvasRenderingContext2D | undefined;
|
|
4415
4551
|
/** @property {OffscreenCanvas} - The canvas used by this layer */
|
|
4416
|
-
canvas: OffscreenCanvas;
|
|
4552
|
+
canvas: OffscreenCanvas | undefined;
|
|
4417
4553
|
/** @property {TextureInfo} - Texture info to use for this object rendering */
|
|
4418
4554
|
textureInfo: TextureInfo;
|
|
4419
4555
|
/** Draw this canvas layer centered in world space
|
|
@@ -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 */
|
|
@@ -4456,7 +4592,7 @@ declare module "littlejsengine" {
|
|
|
4456
4592
|
data: TileLayerData[];
|
|
4457
4593
|
/** @property {boolean} - Is this layer using a webgl texture? */
|
|
4458
4594
|
isUsingWebGL: boolean;
|
|
4459
|
-
tilesInWebGL: boolean;
|
|
4595
|
+
tilesInWebGL: boolean | undefined;
|
|
4460
4596
|
/** @property {boolean} - Show this layer's bounds and values when the debug overlay's Debug Tiles is on,
|
|
4461
4597
|
* turn it off for layers that only add noise */
|
|
4462
4598
|
debugShow: boolean;
|
|
@@ -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
|
|
@@ -4535,8 +4671,8 @@ declare module "littlejsengine" {
|
|
|
4535
4671
|
onRedraw(): void;
|
|
4536
4672
|
redrawIfSwitched(): void;
|
|
4537
4673
|
/** @type {[CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, number, Color, Shader|undefined]} */
|
|
4538
|
-
savedRenderSettings: [CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, number, Color, Shader | undefined];
|
|
4539
|
-
savedRenderTarget: any[];
|
|
4674
|
+
savedRenderSettings: [CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, number, Color, Shader | undefined] | undefined;
|
|
4675
|
+
savedRenderTarget: any[] | undefined;
|
|
4540
4676
|
}
|
|
4541
4677
|
/**
|
|
4542
4678
|
* Tile Collision Layer - a tile layer with collision
|
|
@@ -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
|
|
@@ -5263,7 +5438,7 @@ declare module "littlejsengine" {
|
|
|
5263
5438
|
/** @property {Color} - Baseline color applied to unlit areas of the scene. Defaults to BLACK (pitch dark). Set to a small RGB for a faint ambient. The lightmap is cleared to this color each frame, then lights add on top, then the result multiplies the scene. */
|
|
5264
5439
|
ambientColor: Color;
|
|
5265
5440
|
/** @property {Vector2} - Size of the lightmap texture, follows mainCanvasSize (css pixels, so it is not scaled by canvasPixelRatio) unless a size was passed */
|
|
5266
|
-
textureSize: Vector2;
|
|
5441
|
+
textureSize: Vector2 | undefined;
|
|
5267
5442
|
/** @property {boolean} - True when no size was passed, so the lightmap follows mainCanvasSize */
|
|
5268
5443
|
textureSizeAuto: boolean;
|
|
5269
5444
|
/** @property {WebGLTexture|undefined} - The lightmap texture
|
|
@@ -5416,14 +5591,14 @@ declare module "littlejsengine" {
|
|
|
5416
5591
|
/** @property {number} - Wet/dry balance, 0 is fully dry and 1 is fully wet */
|
|
5417
5592
|
mix: number;
|
|
5418
5593
|
/** @property {GainNode} - Connect sounds to this node */
|
|
5419
|
-
input: GainNode;
|
|
5594
|
+
input: GainNode | undefined;
|
|
5420
5595
|
/** @property {GainNode} - This node carries the mixed result, send it somewhere with connect(), never by assigning here
|
|
5421
5596
|
* - Unlike sound.output, which is where a sound's audio goes and can be set to an effect */
|
|
5422
|
-
output: GainNode;
|
|
5597
|
+
output: GainNode | undefined;
|
|
5423
5598
|
/** @property {GainNode} - Level of the unprocessed signal */
|
|
5424
|
-
dryGain: GainNode;
|
|
5599
|
+
dryGain: GainNode | undefined;
|
|
5425
5600
|
/** @property {GainNode} - Level of the processed signal */
|
|
5426
|
-
wetGain: GainNode;
|
|
5601
|
+
wetGain: GainNode | undefined;
|
|
5427
5602
|
/** Set the wet/dry balance
|
|
5428
5603
|
* @param {number} mix - 0 is fully dry and 1 is fully wet
|
|
5429
5604
|
* @param {number} [fadeTime] - Seconds to ramp over so the change doesn't click */
|
|
@@ -5466,7 +5641,7 @@ declare module "littlejsengine" {
|
|
|
5466
5641
|
* @param {number} [mix] - Wet/dry balance, 0 is fully dry and 1 is fully wet */
|
|
5467
5642
|
constructor(type?: BiquadFilterType, frequency?: number, q?: number, mix?: number);
|
|
5468
5643
|
/** @property {BiquadFilterNode} - The filter node */
|
|
5469
|
-
node: BiquadFilterNode;
|
|
5644
|
+
node: BiquadFilterNode | undefined;
|
|
5470
5645
|
/** Set the cutoff or center frequency
|
|
5471
5646
|
* @param {number} frequency - Frequency in Hz
|
|
5472
5647
|
* @param {number} [fadeTime] - Seconds to sweep over */
|
|
@@ -5492,7 +5667,7 @@ declare module "littlejsengine" {
|
|
|
5492
5667
|
* @param {number} [mix] - Wet/dry balance, 0 is fully dry and 1 is fully wet */
|
|
5493
5668
|
constructor(duration?: number, decay?: number, mix?: number);
|
|
5494
5669
|
/** @property {ConvolverNode} - The convolver node */
|
|
5495
|
-
node: ConvolverNode;
|
|
5670
|
+
node: ConvolverNode | undefined;
|
|
5496
5671
|
/** Change the room by rebuilding the impulse response
|
|
5497
5672
|
* @param {number} duration - Seconds until the reverb tail is silent
|
|
5498
5673
|
* @param {number} [decay] - How quickly the tail fades, higher is faster */
|
|
@@ -5518,9 +5693,9 @@ declare module "littlejsengine" {
|
|
|
5518
5693
|
* @param {number} [mix] - Wet/dry balance, 0 is fully dry and 1 is fully wet */
|
|
5519
5694
|
constructor(time?: number, feedback?: number, mix?: number);
|
|
5520
5695
|
/** @property {DelayNode} - The delay node */
|
|
5521
|
-
node: DelayNode;
|
|
5696
|
+
node: DelayNode | undefined;
|
|
5522
5697
|
/** @property {GainNode} - How much of the delayed signal feeds back in */
|
|
5523
|
-
feedbackGain: GainNode;
|
|
5698
|
+
feedbackGain: GainNode | undefined;
|
|
5524
5699
|
/** Set the time between echoes
|
|
5525
5700
|
* - Browsers hold a delay in a feedback loop to at least one render quantum, so 0 is not a bypass
|
|
5526
5701
|
* @param {number} time - Seconds, up to 5
|
|
@@ -5547,7 +5722,7 @@ declare module "littlejsengine" {
|
|
|
5547
5722
|
/** @property {number} - How hard the signal is driven, 0 is clean and 1 is crushed */
|
|
5548
5723
|
amount: number;
|
|
5549
5724
|
/** @property {WaveShaperNode} - The wave shaper node */
|
|
5550
|
-
node: WaveShaperNode;
|
|
5725
|
+
node: WaveShaperNode | undefined;
|
|
5551
5726
|
/** Set how hard to drive the signal, rebuilds the shaping curve
|
|
5552
5727
|
* @param {number} amount - 0 is clean and 1 is crushed */
|
|
5553
5728
|
setAmount(amount: number): void;
|
|
@@ -5568,7 +5743,7 @@ declare module "littlejsengine" {
|
|
|
5568
5743
|
* @param {number} [mix] - Wet/dry balance, 0 is fully dry and 1 is fully wet */
|
|
5569
5744
|
constructor(threshold?: number, ratio?: number, mix?: number);
|
|
5570
5745
|
/** @property {DynamicsCompressorNode} - The compressor node */
|
|
5571
|
-
node: DynamicsCompressorNode;
|
|
5746
|
+
node: DynamicsCompressorNode | undefined;
|
|
5572
5747
|
/** Set the level above which the signal is reduced
|
|
5573
5748
|
* @param {number} threshold - Level in dB
|
|
5574
5749
|
* @param {number} [fadeTime] - Seconds to ramp over */
|
|
@@ -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,35 +5928,30 @@ 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
|
-
drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?:
|
|
5757
|
-
/**
|
|
5758
|
-
* @callback DragAndDropCallback - Callback for drag and drop events
|
|
5759
|
-
* @param {DragEvent} event - The drag event
|
|
5760
|
-
* @memberof UISystem
|
|
5761
|
-
*/
|
|
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;
|
|
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} */
|
|
5772
5947
|
screenToNative(pos: Vector2): Vector2;
|
|
5773
|
-
set keyInputObject(arg: UIObject);
|
|
5948
|
+
set keyInputObject(arg: UIObject | undefined);
|
|
5774
5949
|
/** Object to send keyboard input to (typically a UITextInput), which keeps the keys from the game while set.
|
|
5775
5950
|
* The keyboard listeners are only attached while this is set,
|
|
5776
5951
|
* so games that never use text input pay no event-handling cost.
|
|
5777
5952
|
* To end typing in a field, call its stopEditing(), which also fires its onChange and release sound
|
|
5778
5953
|
* @type {UIObject|undefined} */
|
|
5779
|
-
get keyInputObject(): UIObject;
|
|
5954
|
+
get keyInputObject(): UIObject | undefined;
|
|
5780
5955
|
/** Destroy and remove all objects */
|
|
5781
5956
|
destroyObjects(): void;
|
|
5782
5957
|
/** Get all navigable UI objects sorted by navigationIndex
|
|
@@ -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} */
|
|
@@ -6004,7 +6184,8 @@ declare module "littlejsengine" {
|
|
|
6004
6184
|
* @param {'left'|'center'|'right'} [align]
|
|
6005
6185
|
* @param {string} [font=uiSystem.defaultFont]
|
|
6006
6186
|
*/
|
|
6007
|
-
constructor(pos?: Vector2, size?: Vector2, text?: string, align?:
|
|
6187
|
+
constructor(pos?: Vector2, size?: Vector2, text?: string, align?: "center" | "left" | "right", font?: string);
|
|
6188
|
+
text: string;
|
|
6008
6189
|
}
|
|
6009
6190
|
/**
|
|
6010
6191
|
* UITextInput - An editable text input field
|
|
@@ -6024,6 +6205,7 @@ declare module "littlejsengine" {
|
|
|
6024
6205
|
constructor(pos?: Vector2, size?: Vector2, text?: string);
|
|
6025
6206
|
/** @property {number} - Max length of input (0 = no limit) */
|
|
6026
6207
|
maxLength: number;
|
|
6208
|
+
text: string;
|
|
6027
6209
|
/** Stop editing the text */
|
|
6028
6210
|
stopEditing(): void;
|
|
6029
6211
|
}
|
|
@@ -6064,6 +6246,7 @@ declare module "littlejsengine" {
|
|
|
6064
6246
|
constructor(pos?: Vector2, size?: Vector2, text?: string, color?: Color);
|
|
6065
6247
|
/** @property {Vector2} - Text offset for the button */
|
|
6066
6248
|
textOffset: Vector2;
|
|
6249
|
+
text: string;
|
|
6067
6250
|
}
|
|
6068
6251
|
/**
|
|
6069
6252
|
* UICheckbox - A UI object that acts as a checkbox
|
|
@@ -6081,6 +6264,7 @@ declare module "littlejsengine" {
|
|
|
6081
6264
|
constructor(pos?: Vector2, size?: Vector2, checked?: boolean, text?: string, color?: Color);
|
|
6082
6265
|
/** @property {boolean} - Is the checkbox currently checked? */
|
|
6083
6266
|
checked: boolean;
|
|
6267
|
+
text: string;
|
|
6084
6268
|
}
|
|
6085
6269
|
/**
|
|
6086
6270
|
* UISlider - A UI object that acts as a slider or scrollbar
|
|
@@ -6107,6 +6291,7 @@ declare module "littlejsengine" {
|
|
|
6107
6291
|
handleSlice: TileSlice | undefined;
|
|
6108
6292
|
/** @property {boolean} - Should it fill up like a progress bar? */
|
|
6109
6293
|
fillMode: boolean;
|
|
6294
|
+
text: string;
|
|
6110
6295
|
/** Draw the handle, or the fill of a fill mode slider, with the handle slice, the slider's own, or a rectangle
|
|
6111
6296
|
* @param {Vector2} pos
|
|
6112
6297
|
* @param {Vector2} size
|
|
@@ -6127,9 +6312,9 @@ declare module "littlejsengine" {
|
|
|
6127
6312
|
* @param {Vector2} pos
|
|
6128
6313
|
* @param {Vector2} size
|
|
6129
6314
|
* @param {string} src - Video file path or URL
|
|
6130
|
-
* @param {boolean} [autoplay
|
|
6131
|
-
* @param {boolean} [loop
|
|
6132
|
-
* @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)
|
|
6133
6318
|
*/
|
|
6134
6319
|
constructor(pos: Vector2, size: Vector2, src: string, autoplay?: boolean, loop?: boolean, volume?: number);
|
|
6135
6320
|
/** @property {number} - The video volume */
|
|
@@ -6191,10 +6376,10 @@ declare module "littlejsengine" {
|
|
|
6191
6376
|
export class UILayout extends UIObject {
|
|
6192
6377
|
/** Create a UILayout container that auto-arranges children
|
|
6193
6378
|
* @param {Vector2} [pos]
|
|
6194
|
-
* @param {number} [columns
|
|
6195
|
-
* @param {number} [gap
|
|
6196
|
-
* @param {number} [padding
|
|
6197
|
-
* @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
|
|
6198
6383
|
*/
|
|
6199
6384
|
constructor(pos?: Vector2, columns?: number, gap?: number, padding?: number, transparent?: boolean);
|
|
6200
6385
|
/** @property {number} - Number of columns in the layout */
|
|
@@ -6290,13 +6475,15 @@ declare module "littlejsengine" {
|
|
|
6290
6475
|
* @param {boolean} [includeSensors] - Also hit sensors, trigger zones are passed through by default
|
|
6291
6476
|
* @return {Box2dRaycastResult|undefined} */
|
|
6292
6477
|
raycast(start: Vector2, end: Vector2, includeSensors?: boolean): Box2dRaycastResult | undefined;
|
|
6293
|
-
/** box
|
|
6478
|
+
/** Every object whose shapes' bounding boxes overlap a box, not the shapes themselves, so near the corner of a
|
|
6479
|
+
* turned box or a circle it finds one the box does not touch; use pointCast or a raycast for exact
|
|
6294
6480
|
* @param {Vector2} pos
|
|
6295
6481
|
* @param {Vector2} size
|
|
6296
6482
|
* @param {boolean} [includeSensors] - Also find sensors, trigger zones are passed through by default
|
|
6297
6483
|
* @return {Array<Box2dObject>} */
|
|
6298
6484
|
boxCastAll(pos: Vector2, size: Vector2, includeSensors?: boolean): Array<Box2dObject>;
|
|
6299
|
-
/** box
|
|
6485
|
+
/** The first object whose shapes' bounding boxes overlap a box, not the shapes themselves, so near the corner of
|
|
6486
|
+
* a turned box or a circle it finds one the box does not touch; use pointCast or a raycast for exact
|
|
6300
6487
|
* @param {Vector2} pos
|
|
6301
6488
|
* @param {Vector2} size
|
|
6302
6489
|
* @param {boolean} [includeSensors] - Also find sensors, trigger zones are passed through by default
|
|
@@ -6331,23 +6518,29 @@ declare module "littlejsengine" {
|
|
|
6331
6518
|
* @param {CanvasRenderingContext2D} [context] */
|
|
6332
6519
|
drawFixture(fixture: any, pos: Vector2, angle: number, color?: Color, lineColor?: Color, lineWidth?: number, useWebGL?: boolean, context?: CanvasRenderingContext2D): void;
|
|
6333
6520
|
/** converts a box2d vec2 to a Vector2
|
|
6334
|
-
* @param {Object} v
|
|
6521
|
+
* @param {Object} v
|
|
6522
|
+
* @return {Vector2} */
|
|
6335
6523
|
vec2From(v: any): Vector2;
|
|
6336
6524
|
/** converts a box2d vec2 pointer to a Vector2
|
|
6337
|
-
* @param {Object} vp
|
|
6525
|
+
* @param {Object} vp
|
|
6526
|
+
* @return {Vector2} */
|
|
6338
6527
|
vec2FromPointer(vp: any): Vector2;
|
|
6339
6528
|
/** converts a Vector2 to a new box2d vec2, which stays until destroyed with box2d.instance.destroy;
|
|
6340
6529
|
* the plugin itself passes Box2D reused ones, since Box2D copies every vector it is given
|
|
6341
|
-
* @param {Vector2} v
|
|
6530
|
+
* @param {Vector2} v
|
|
6531
|
+
* @return {Object} - A Box2D vector, its b2Vec2 */
|
|
6342
6532
|
vec2dTo(v: Vector2): any;
|
|
6343
6533
|
/** checks if a box2d object is null
|
|
6344
|
-
* @param {Object} o
|
|
6534
|
+
* @param {Object} o
|
|
6535
|
+
* @return {boolean} */
|
|
6345
6536
|
isNull(o: any): boolean;
|
|
6346
6537
|
/** casts a box2d object to a shape type
|
|
6347
|
-
* @param {Object} o
|
|
6538
|
+
* @param {Object} o
|
|
6539
|
+
* @return {Object} - The shape as its own Box2D type */
|
|
6348
6540
|
castShapeObject(o: any): any;
|
|
6349
6541
|
/** casts a box2d object to a joint type
|
|
6350
|
-
* @param {Object} o
|
|
6542
|
+
* @param {Object} o
|
|
6543
|
+
* @return {Object} - The joint as its own Box2D type */
|
|
6351
6544
|
castJointObject(o: any): any;
|
|
6352
6545
|
}
|
|
6353
6546
|
/**
|
|
@@ -6408,7 +6601,8 @@ declare module "littlejsengine" {
|
|
|
6408
6601
|
* @param {number} [density]
|
|
6409
6602
|
* @param {number} [friction]
|
|
6410
6603
|
* @param {number} [restitution]
|
|
6411
|
-
* @param {boolean} [isSensor]
|
|
6604
|
+
* @param {boolean} [isSensor]
|
|
6605
|
+
* @return {Object} - The fixture made, Box2D's own */
|
|
6412
6606
|
addShape(shape: any, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
6413
6607
|
/** Add a box shape to the body
|
|
6414
6608
|
* @param {Vector2} [size]
|
|
@@ -6419,38 +6613,43 @@ declare module "littlejsengine" {
|
|
|
6419
6613
|
* @param {number} [density]
|
|
6420
6614
|
* @param {number} [friction]
|
|
6421
6615
|
* @param {number} [restitution]
|
|
6422
|
-
* @param {boolean} [isSensor]
|
|
6423
|
-
|
|
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;
|
|
6424
6619
|
/** Add a polygon shape to the body, the convex hull of its points; Box2D takes 3 to 8 points,
|
|
6425
6620
|
* not all in a line, and no fixture is made from any other; points closer than .001 count as one
|
|
6426
6621
|
* @param {Array<Vector2>} points
|
|
6427
6622
|
* @param {number} [density]
|
|
6428
6623
|
* @param {number} [friction]
|
|
6429
6624
|
* @param {number} [restitution]
|
|
6430
|
-
* @param {boolean} [isSensor]
|
|
6431
|
-
|
|
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;
|
|
6432
6628
|
/** Add a regular polygon shape to the body
|
|
6433
6629
|
* @param {number} [diameter]
|
|
6434
6630
|
* @param {number} [sides] - 3 to 8, the most Box2D polygons have
|
|
6435
6631
|
* @param {number} [density]
|
|
6436
6632
|
* @param {number} [friction]
|
|
6437
6633
|
* @param {number} [restitution]
|
|
6438
|
-
* @param {boolean} [isSensor]
|
|
6439
|
-
|
|
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;
|
|
6440
6637
|
/** Add a random polygon shape to the body
|
|
6441
6638
|
* @param {number} [diameter]
|
|
6442
6639
|
* @param {number} [density]
|
|
6443
6640
|
* @param {number} [friction]
|
|
6444
6641
|
* @param {number} [restitution]
|
|
6445
|
-
* @param {boolean} [isSensor]
|
|
6446
|
-
|
|
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;
|
|
6447
6645
|
/** Add a circle shape to the body
|
|
6448
6646
|
* @param {number} [diameter]
|
|
6449
6647
|
* @param {Vector2} [offset]
|
|
6450
6648
|
* @param {number} [density]
|
|
6451
6649
|
* @param {number} [friction]
|
|
6452
6650
|
* @param {number} [restitution]
|
|
6453
|
-
* @param {boolean} [isSensor]
|
|
6651
|
+
* @param {boolean} [isSensor]
|
|
6652
|
+
* @return {Object} - The fixture made, Box2D's own */
|
|
6454
6653
|
addCircle(diameter?: number, offset?: Vector2, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
6455
6654
|
/** Add an edge shape to the body
|
|
6456
6655
|
* @param {Vector2} point1
|
|
@@ -6458,22 +6657,25 @@ declare module "littlejsengine" {
|
|
|
6458
6657
|
* @param {number} [density]
|
|
6459
6658
|
* @param {number} [friction]
|
|
6460
6659
|
* @param {number} [restitution]
|
|
6461
|
-
* @param {boolean} [isSensor]
|
|
6660
|
+
* @param {boolean} [isSensor]
|
|
6661
|
+
* @return {Object} - The fixture made, Box2D's own */
|
|
6462
6662
|
addEdge(point1: Vector2, point2: Vector2, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
6463
6663
|
/** Add an edge list to the body
|
|
6464
6664
|
* @param {Array<Vector2>} points
|
|
6465
6665
|
* @param {number} [density]
|
|
6466
6666
|
* @param {number} [friction]
|
|
6467
6667
|
* @param {number} [restitution]
|
|
6468
|
-
* @param {boolean} [isSensor]
|
|
6469
|
-
|
|
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>;
|
|
6470
6671
|
/** Add an edge loop to the body, an edge loop connects the end points
|
|
6471
6672
|
* @param {Array<Vector2>} points
|
|
6472
6673
|
* @param {number} [density]
|
|
6473
6674
|
* @param {number} [friction]
|
|
6474
6675
|
* @param {number} [restitution]
|
|
6475
|
-
* @param {boolean} [isSensor]
|
|
6476
|
-
|
|
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>;
|
|
6477
6679
|
/** Destroy a fixture from the body, from a contact callback once the step is done
|
|
6478
6680
|
* @param {Object} fixture */
|
|
6479
6681
|
destroyFixture(fixture: any): void;
|
|
@@ -6800,6 +7002,8 @@ declare module "littlejsengine" {
|
|
|
6800
7002
|
* Box2D Pin Joint
|
|
6801
7003
|
* - Pins two objects together at a point, where they still turn freely, like a nail through two boards
|
|
6802
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
|
|
6803
7007
|
* @extends Box2dRevoluteJoint
|
|
6804
7008
|
* @memberof Box2D
|
|
6805
7009
|
*/
|
|
@@ -7115,12 +7319,6 @@ declare module "littlejsengine" {
|
|
|
7115
7319
|
/** Get the damping ratio
|
|
7116
7320
|
* @return {number} */
|
|
7117
7321
|
getDampingRatio(): number;
|
|
7118
|
-
/** @deprecated since 1.20, use setDampingRatio
|
|
7119
|
-
* @param {number} ratio */
|
|
7120
|
-
setSpringDampingRatio(ratio: number): void;
|
|
7121
|
-
/** @deprecated since 1.20, use getDampingRatio
|
|
7122
|
-
* @return {number} */
|
|
7123
|
-
getSpringDampingRatio(): number;
|
|
7124
7322
|
}
|
|
7125
7323
|
/**
|
|
7126
7324
|
* Box2D Friction Joint
|
|
@@ -7273,7 +7471,7 @@ declare module "littlejsengine" {
|
|
|
7273
7471
|
* @param {Vector2} pos - Screen space position
|
|
7274
7472
|
* @param {Vector2} size - Screen space size
|
|
7275
7473
|
* @param {TileInfo} startTile - Top-left tile of the 3x3 block to sample (see drawNineSlice)
|
|
7276
|
-
* @param {Color
|
|
7474
|
+
* @param {Color} [color=WHITE] - Color to modulate with
|
|
7277
7475
|
* @param {number} [borderSize] - Rendered thickness of the border sections
|
|
7278
7476
|
* @param {Color} [additiveColor] - Additive color
|
|
7279
7477
|
* @param {number} [extraSpace] - Extra spacing adjustment
|
|
@@ -7281,7 +7479,7 @@ declare module "littlejsengine" {
|
|
|
7281
7479
|
* @param {boolean} [useWebGL] - Use WebGL for rendering
|
|
7282
7480
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas context to use
|
|
7283
7481
|
* @memberof DrawUtilities */
|
|
7284
|
-
export function drawNineSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, color?: 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;
|
|
7285
7483
|
/** Draw a scalable three-slice UI element in world space
|
|
7286
7484
|
* Color and additive color apply in WebGL and Canvas2D (with canvasColorTiles)
|
|
7287
7485
|
* The three-slice samples 3 consecutive tiles from the tilesheet, it does not
|
|
@@ -7309,7 +7507,7 @@ declare module "littlejsengine" {
|
|
|
7309
7507
|
* @param {Vector2} pos - Screen space position
|
|
7310
7508
|
* @param {Vector2} size - Screen space size
|
|
7311
7509
|
* @param {TileInfo} startTile - First of 3 consecutive tiles: corner, side, center (see drawThreeSlice)
|
|
7312
|
-
* @param {Color
|
|
7510
|
+
* @param {Color} [color=WHITE] - Color to modulate with
|
|
7313
7511
|
* @param {number} [borderSize] - Rendered thickness of the border sections
|
|
7314
7512
|
* @param {Color} [additiveColor] - Additive color
|
|
7315
7513
|
* @param {number} [extraSpace] - Extra spacing adjustment
|
|
@@ -7317,7 +7515,7 @@ declare module "littlejsengine" {
|
|
|
7317
7515
|
* @param {boolean} [useWebGL] - Use WebGL for rendering
|
|
7318
7516
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas context to use
|
|
7319
7517
|
* @memberof DrawUtilities */
|
|
7320
|
-
export function drawThreeSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, color?: 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;
|
|
7321
7519
|
/**
|
|
7322
7520
|
* A tile drawn as a box of any size, kept as a style to draw with, like a UI skin
|
|
7323
7521
|
* - 9 slices is a nine-slice from the 3x3 block of tiles at tileInfo, see drawNineSlice
|
|
@@ -7414,9 +7612,9 @@ declare module "littlejsengine" {
|
|
|
7414
7612
|
* callback receives the interpolated value (a number, or a fresh instance
|
|
7415
7613
|
* for lerp-able types). Both endpoints must be the same type.
|
|
7416
7614
|
* @param {function(NonNullable<T>):void} callback - Called with the interpolated value each frame
|
|
7417
|
-
* @param {T} [start
|
|
7418
|
-
* @param {T} [end
|
|
7419
|
-
* @param {number} [duration
|
|
7615
|
+
* @param {T} [start] - Starting value
|
|
7616
|
+
* @param {T} [end] - Ending value
|
|
7617
|
+
* @param {number} [duration] - Duration in seconds
|
|
7420
7618
|
* @param {Object} [options]
|
|
7421
7619
|
* @param {function(number):number} [options.ease] - Easing function (defaults to LINEAR)
|
|
7422
7620
|
* @param {boolean} [options.useRealTime=false] - Advance even when the game is paused (matches Timer's useRealTime)
|
|
@@ -7455,9 +7653,12 @@ declare module "littlejsengine" {
|
|
|
7455
7653
|
/** Remaining iterations including the current run (loop/pingPong only).
|
|
7456
7654
|
* @private */
|
|
7457
7655
|
private loopRemaining;
|
|
7458
|
-
/** Whether it is
|
|
7656
|
+
/** Whether it is running, see isActive
|
|
7459
7657
|
* @private */
|
|
7460
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;
|
|
7461
7662
|
/** The update it was started in, it first moves on the one after
|
|
7462
7663
|
* @private */
|
|
7463
7664
|
private activePass;
|
|
@@ -7474,7 +7675,7 @@ declare module "littlejsengine" {
|
|
|
7474
7675
|
} | undefined;
|
|
7475
7676
|
/** Set the easing curve and return this for chaining.
|
|
7476
7677
|
* @param {function(number):number} easeFn
|
|
7477
|
-
* @
|
|
7678
|
+
* @return {Tween<T>} */
|
|
7478
7679
|
setEase(easeFn: (arg0: number) => number): Tween<T>;
|
|
7479
7680
|
/** Set the completion callback, `onComplete`, and return this for chaining.
|
|
7480
7681
|
* It is called once the tween completes: when its pass ends, or for a
|
|
@@ -7484,7 +7685,7 @@ declare module "littlejsengine" {
|
|
|
7484
7685
|
* - It is kept by `restart`, so a restarted tween calls it again when it completes
|
|
7485
7686
|
* - `stop` and `tweenStopAll` end a tween without calling it
|
|
7486
7687
|
* @param {function():void} callback
|
|
7487
|
-
* @
|
|
7688
|
+
* @return {Tween<T>} */
|
|
7488
7689
|
then(callback: () => void): Tween<T>;
|
|
7489
7690
|
/** Repeat this tween `n` total times. After each iteration finishes, the
|
|
7490
7691
|
* same tween starts over, so the handle returned stays good for the whole
|
|
@@ -7495,7 +7696,7 @@ declare module "littlejsengine" {
|
|
|
7495
7696
|
* A `then` callback, set before or after, is called when the last
|
|
7496
7697
|
* iteration ends.
|
|
7497
7698
|
* @param {number} [count=Infinity]
|
|
7498
|
-
* @
|
|
7699
|
+
* @return {Tween<T>} */
|
|
7499
7700
|
loop(count?: number): Tween<T>;
|
|
7500
7701
|
/** Like `loop`, but swap `start` and `end` between iterations so the value
|
|
7501
7702
|
* bounces back and forth. `pingPong()` with no argument bounces forever.
|
|
@@ -7504,7 +7705,7 @@ declare module "littlejsengine" {
|
|
|
7504
7705
|
* A `then` callback, set before or after, is called when the last
|
|
7505
7706
|
* iteration ends.
|
|
7506
7707
|
* @param {number} [count=Infinity]
|
|
7507
|
-
* @
|
|
7708
|
+
* @return {Tween<T>} */
|
|
7508
7709
|
pingPong(count?: number): Tween<T>;
|
|
7509
7710
|
/** Pause this tween. While paused, tweenUpdate skips it. */
|
|
7510
7711
|
pause(): void;
|
|
@@ -7520,16 +7721,16 @@ declare module "littlejsengine" {
|
|
|
7520
7721
|
* again when it completes. */
|
|
7521
7722
|
restart(): void;
|
|
7522
7723
|
/** True if this tween is in the active list and not paused.
|
|
7523
|
-
* @
|
|
7724
|
+
* @return {boolean} */
|
|
7524
7725
|
isActive(): boolean;
|
|
7525
7726
|
/** Get how far this tween has progressed, from 0 (just started) to 1
|
|
7526
7727
|
* (completed). Clamped — overshoot past completion still reads 1.
|
|
7527
|
-
* @
|
|
7728
|
+
* @return {number} */
|
|
7528
7729
|
getPercent(): number;
|
|
7529
7730
|
/** Get the current interpolated value (the value most recently passed to
|
|
7530
7731
|
* the callback). Returns a number, Vector2, Vector3 or Color depending on the
|
|
7531
7732
|
* tween's start/end types.
|
|
7532
|
-
* @
|
|
7733
|
+
* @return {T} */
|
|
7533
7734
|
getValue(): T;
|
|
7534
7735
|
/** Compute the interpolated value at the given remaining `life`.
|
|
7535
7736
|
* At life === duration the result is `start`; at life === 0 it is `end`.
|
|
@@ -7537,7 +7738,7 @@ declare module "littlejsengine" {
|
|
|
7537
7738
|
* - A vector goes past its ends as far as the easing does, as a number does; a Color stays between them,
|
|
7538
7739
|
* so its channels stay in range, and any other type goes as far as its own lerp takes it
|
|
7539
7740
|
* @param {number} life
|
|
7540
|
-
* @
|
|
7741
|
+
* @return {T} */
|
|
7541
7742
|
interp(life: number): T;
|
|
7542
7743
|
/** Remove this tween from the active list, ending a loop or pingPong too, without calling
|
|
7543
7744
|
* the then-callback. It keeps the then-callback, so a restart calls it when it completes. */
|
|
@@ -7558,12 +7759,12 @@ declare module "littlejsengine" {
|
|
|
7558
7759
|
* @param {string} propertyPath - Dot-separated path, e.g. `'pos.x'` or `'color'`
|
|
7559
7760
|
* @param {T} start - Starting value
|
|
7560
7761
|
* @param {T} end - Ending value
|
|
7561
|
-
* @param {number} [duration
|
|
7762
|
+
* @param {number} [duration] - Duration in seconds
|
|
7562
7763
|
* @param {Object} [options] - Same options as the Tween constructor
|
|
7563
7764
|
* @param {function(number):number} [options.ease] - Easing function (defaults to LINEAR)
|
|
7564
7765
|
* @param {boolean} [options.useRealTime=false] - Advance even when the game is paused
|
|
7565
7766
|
* @param {boolean} [options.paused=false] - Start in paused state
|
|
7566
|
-
* @
|
|
7767
|
+
* @return {Tween<T>}
|
|
7567
7768
|
* @memberof TweenSystem
|
|
7568
7769
|
* @example
|
|
7569
7770
|
* // Numeric: slide an object's x with an ease-out sine curve
|
|
@@ -7702,7 +7903,8 @@ declare module "littlejsengine" {
|
|
|
7702
7903
|
* gridFinder.isWalkable = (x, y) => myGrid[y*50 + x] === 0;
|
|
7703
7904
|
*/
|
|
7704
7905
|
export class PathFinder {
|
|
7705
|
-
/**
|
|
7906
|
+
/** Make a path finder over a tile layer or a grid
|
|
7907
|
+
* @param {TileCollisionLayer|Vector2} source - Either a TileCollisionLayer
|
|
7706
7908
|
* (size and walkability auto-derived) or a Vector2 grid size (user
|
|
7707
7909
|
* overrides isWalkable). */
|
|
7708
7910
|
constructor(source: TileCollisionLayer | Vector2);
|
|
@@ -7743,27 +7945,27 @@ declare module "littlejsengine" {
|
|
|
7743
7945
|
* the instance or via a subclass.
|
|
7744
7946
|
* @param {number} x - Tile x
|
|
7745
7947
|
* @param {number} y - Tile y
|
|
7746
|
-
* @
|
|
7948
|
+
* @return {boolean} */
|
|
7747
7949
|
isWalkable(x: number, y: number): boolean;
|
|
7748
7950
|
/** Default extra cost for stepping on a cell. Returns 0 (free) by default.
|
|
7749
7951
|
* Override to add cost-weighted terrain (mud, swamp, etc).
|
|
7750
7952
|
* @param {number} x - Tile x
|
|
7751
7953
|
* @param {number} y - Tile y
|
|
7752
|
-
* @
|
|
7954
|
+
* @return {number} */
|
|
7753
7955
|
getCost(x: number, y: number): number;
|
|
7754
7956
|
/** Get the node at tile coords, or null if out of bounds.
|
|
7755
7957
|
* @param {number} x
|
|
7756
7958
|
* @param {number} y
|
|
7757
|
-
* @
|
|
7959
|
+
* @return {PathFinderNode|null} */
|
|
7758
7960
|
getNode(x: number, y: number): PathFinderNode | null;
|
|
7759
7961
|
/** Convert a world-space position to integer tile coords (no clamping).
|
|
7760
7962
|
* @param {Vector2} worldPos
|
|
7761
|
-
* @
|
|
7963
|
+
* @return {Vector2} */
|
|
7762
7964
|
worldToTile(worldPos: Vector2): Vector2;
|
|
7763
7965
|
/** Convert integer tile coords to the world-space center of that tile.
|
|
7764
7966
|
* @param {number} x
|
|
7765
7967
|
* @param {number} y
|
|
7766
|
-
* @
|
|
7968
|
+
* @return {Vector2} */
|
|
7767
7969
|
tileToWorld(x: number, y: number): Vector2;
|
|
7768
7970
|
/** Reset all nodes and re-populate walkable / cost / posWorld from the
|
|
7769
7971
|
* current isWalkable / getCost overrides. Called at the start of
|
|
@@ -7774,7 +7976,7 @@ declare module "littlejsengine" {
|
|
|
7774
7976
|
* reached; false on disconnected goal or maxLoop exhaustion, which sets searchGaveUp.
|
|
7775
7977
|
* @param {PathFinderNode} startNode
|
|
7776
7978
|
* @param {PathFinderNode} endNode
|
|
7777
|
-
* @
|
|
7979
|
+
* @return {boolean}
|
|
7778
7980
|
* @private */
|
|
7779
7981
|
private aStarSearch;
|
|
7780
7982
|
/** Find the clear (walkable, zero-cost) node closest to the given world
|
|
@@ -7787,9 +7989,9 @@ declare module "littlejsengine" {
|
|
|
7787
7989
|
* unchanged walkability, pass `rebuild=false` and call `buildNodeData()`
|
|
7788
7990
|
* once externally to avoid redundant work.
|
|
7789
7991
|
* @param {Vector2} worldPos
|
|
7790
|
-
* @param {number} [searchRange
|
|
7791
|
-
* @param {boolean} [rebuild
|
|
7792
|
-
* @
|
|
7992
|
+
* @param {number} [searchRange] - Max box-radius in tiles
|
|
7993
|
+
* @param {boolean} [rebuild] - Whether to call buildNodeData first
|
|
7994
|
+
* @return {PathFinderNode|null} */
|
|
7793
7995
|
getNearestClearNode(worldPos: Vector2, searchRange?: number, rebuild?: boolean): PathFinderNode | null;
|
|
7794
7996
|
/** Smooth a node path by removing redundant turns and tightening corners
|
|
7795
7997
|
* where a grid-aligned diagonal is clear. Modifies the path in place.
|
|
@@ -7824,7 +8026,7 @@ declare module "littlejsengine" {
|
|
|
7824
8026
|
* and clear (walkable, zero-cost). Used by isLineClear's hot path.
|
|
7825
8027
|
* @param {number} x
|
|
7826
8028
|
* @param {number} y
|
|
7827
|
-
* @
|
|
8029
|
+
* @return {boolean}
|
|
7828
8030
|
* @private */
|
|
7829
8031
|
private isNodeClear;
|
|
7830
8032
|
/** Check that the line between two tile-coord endpoints stays entirely
|
|
@@ -7836,7 +8038,7 @@ declare module "littlejsengine" {
|
|
|
7836
8038
|
* CheckLine() in pathFinding.cpp.
|
|
7837
8039
|
* @param {Vector2} startPos - Tile coords
|
|
7838
8040
|
* @param {Vector2} endPos - Tile coords
|
|
7839
|
-
* @
|
|
8041
|
+
* @return {boolean}
|
|
7840
8042
|
* @private */
|
|
7841
8043
|
private isLineClear;
|
|
7842
8044
|
/** Find a path from startPos to endPos in world space. Returns an array
|
|
@@ -7853,7 +8055,7 @@ declare module "littlejsengine" {
|
|
|
7853
8055
|
* @param {Vector2} startPos - World-space start
|
|
7854
8056
|
* @param {Vector2} endPos - World-space end
|
|
7855
8057
|
* @param {boolean} [rebuild] - Whether to call buildNodeData first
|
|
7856
|
-
* @
|
|
8058
|
+
* @return {Vector2[]} */
|
|
7857
8059
|
findPath(startPos: Vector2, endPos: Vector2, rebuild?: boolean): Vector2[];
|
|
7858
8060
|
}
|
|
7859
8061
|
/** A single grid cell tracked by the pathfinder. Allocated once per cell at
|
|
@@ -7861,7 +8063,8 @@ declare module "littlejsengine" {
|
|
|
7861
8063
|
* findPath call.
|
|
7862
8064
|
* @memberof PathFinding */
|
|
7863
8065
|
export class PathFinderNode {
|
|
7864
|
-
/**
|
|
8066
|
+
/** Make the node of a grid cell, as PathFinder does for each
|
|
8067
|
+
* @param {number} x - Tile x
|
|
7865
8068
|
* @param {number} y - Tile y */
|
|
7866
8069
|
constructor(x: number, y: number);
|
|
7867
8070
|
/** @property {Vector2} - Tile coords (integer) */
|
|
@@ -7891,7 +8094,8 @@ declare module "littlejsengine" {
|
|
|
7891
8094
|
resetSearch(): void;
|
|
7892
8095
|
/** Reset per-search state and walkability (called by buildNodeData). */
|
|
7893
8096
|
reset(): void;
|
|
7894
|
-
/** True if walkable and not blocked by cost.
|
|
8097
|
+
/** True if walkable and not blocked by cost.
|
|
8098
|
+
* @return {boolean} */
|
|
7895
8099
|
isClear(): boolean;
|
|
7896
8100
|
}
|
|
7897
8101
|
/** Options for a tweak
|
|
@@ -8171,7 +8375,7 @@ declare module "littlejsengine" {
|
|
|
8171
8375
|
static lookAt(eye: Vector3, target: Vector3, up?: Vector3): Matrix4;
|
|
8172
8376
|
/** Create a matrix, identity by default
|
|
8173
8377
|
* @param {Float32Array|Array<number>} [m] - 16 column major values */
|
|
8174
|
-
constructor(m?:
|
|
8378
|
+
constructor(m?: number[] | Float32Array);
|
|
8175
8379
|
/** @property {Float32Array} - The 16 column major values */
|
|
8176
8380
|
m: Float32Array;
|
|
8177
8381
|
/** Returns a new matrix that is a copy of this
|
|
@@ -8587,7 +8791,8 @@ declare module "littlejsengine" {
|
|
|
8587
8791
|
streamCount: number;
|
|
8588
8792
|
/** @type {TextureInfo|undefined} */
|
|
8589
8793
|
streamTileInfo: TextureInfo | undefined;
|
|
8590
|
-
|
|
8794
|
+
/** @type {Object|undefined} */
|
|
8795
|
+
streamState: any | undefined;
|
|
8591
8796
|
streamUnlit: boolean;
|
|
8592
8797
|
/** @type {Mesh|undefined} */
|
|
8593
8798
|
capture: Mesh | undefined;
|
|
@@ -8640,10 +8845,10 @@ declare module "littlejsengine" {
|
|
|
8640
8845
|
* like polished metal; set from each object's shininess
|
|
8641
8846
|
* @return {number} */
|
|
8642
8847
|
get shininess(): number;
|
|
8643
|
-
set normalMap(arg: TextureInfo);
|
|
8848
|
+
set normalMap(arg: TextureInfo | undefined);
|
|
8644
8849
|
/** Normal map for the next draws, set from each object's normalMap
|
|
8645
8850
|
* @return {TextureInfo|undefined} */
|
|
8646
|
-
get normalMap(): TextureInfo;
|
|
8851
|
+
get normalMap(): TextureInfo | undefined;
|
|
8647
8852
|
set normalScale(arg: number);
|
|
8648
8853
|
/** How strongly the normal map bends the surface, set from each object's normalScale
|
|
8649
8854
|
* @return {number} */
|
|
@@ -8652,20 +8857,20 @@ declare module "littlejsengine" {
|
|
|
8652
8857
|
/** How much the surface reflects the sky, 0 to 1, set from each object's reflectivity
|
|
8653
8858
|
* @return {number} */
|
|
8654
8859
|
get reflectivity(): number;
|
|
8655
|
-
set emissiveMap(arg: TextureInfo);
|
|
8860
|
+
set emissiveMap(arg: TextureInfo | undefined);
|
|
8656
8861
|
/** Emissive map for the next draws, set from each object's emissiveMap
|
|
8657
8862
|
* @return {TextureInfo|undefined} */
|
|
8658
|
-
get emissiveMap(): TextureInfo;
|
|
8863
|
+
get emissiveMap(): TextureInfo | undefined;
|
|
8659
8864
|
set emissiveMapColor(arg: Color);
|
|
8660
8865
|
/** Multiplies the emissive map, set from each object's emissiveMapColor; compared by its rgb, so a Color
|
|
8661
8866
|
* changed in place is seen when it is set again, and undefined is white
|
|
8662
8867
|
* @return {Color} */
|
|
8663
8868
|
get emissiveMapColor(): Color;
|
|
8664
|
-
set shader(arg: Shader);
|
|
8869
|
+
set shader(arg: Shader | undefined);
|
|
8665
8870
|
/** Custom Shader for the next draws, set from each object's shader; undefined draws
|
|
8666
8871
|
* with the plugin's own
|
|
8667
8872
|
* @return {Shader|undefined} */
|
|
8668
|
-
get shader(): Shader;
|
|
8873
|
+
get shader(): Shader | undefined;
|
|
8669
8874
|
set receiveShadow(arg: boolean);
|
|
8670
8875
|
/** Darken by the shadow map when shadows are on, turn it off for things that should
|
|
8671
8876
|
* stay lit inside a shadow
|
|
@@ -8715,7 +8920,7 @@ declare module "littlejsengine" {
|
|
|
8715
8920
|
* @param {Vector2|Ray3D} from - A screen position like mousePosScreen, or a ray to look along
|
|
8716
8921
|
* @param {Array<EngineObject>} [objects] - Defaults to every object; only those with a mesh or a sprite count
|
|
8717
8922
|
* @return {{object: EngineObject3D, distance: number}|undefined} */
|
|
8718
|
-
pick(from: Vector2 | Ray3D, objects?:
|
|
8923
|
+
pick(from: Vector2 | Ray3D, objects?: EngineObject[]): {
|
|
8719
8924
|
object: EngineObject3D;
|
|
8720
8925
|
distance: number;
|
|
8721
8926
|
} | undefined;
|
|
@@ -8752,7 +8957,7 @@ declare module "littlejsengine" {
|
|
|
8752
8957
|
* @param {TileInfo|TextureInfo} [tileInfo] - Texture, mesh uvs map across the tile or the whole texture
|
|
8753
8958
|
* @param {Color} [color] - Tint
|
|
8754
8959
|
* @return {void} */
|
|
8755
|
-
drawMesh(mesh: Mesh, matrix?:
|
|
8960
|
+
drawMesh(mesh: Mesh, matrix?: Vector3 | Matrix4, tileInfo?: TileInfo | TextureInfo, color?: Color): void;
|
|
8756
8961
|
/** Draw a triangle strip, batched into the stream with the current draw state
|
|
8757
8962
|
* - Strip order: the first three points make a triangle, then each point makes another with the two before it
|
|
8758
8963
|
* - List the first three points counter clockwise as seen from the front, or the face points away
|
|
@@ -8765,14 +8970,14 @@ declare module "littlejsengine" {
|
|
|
8765
8970
|
* @param {Color|Array<Color>} [colors] - One for all or one per point, vertex colors come before the texture
|
|
8766
8971
|
* @param {TileInfo|TextureInfo} [tileInfo] - Texture for this strip
|
|
8767
8972
|
* @return {void} */
|
|
8768
|
-
drawStrip(points: Array<Vector3>, normals?: Vector3 |
|
|
8973
|
+
drawStrip(points: Array<Vector3>, normals?: Vector3 | Vector3[], uvs?: Vector2 | Vector2[], colors?: Color | Color[], tileInfo?: TileInfo | TextureInfo): void;
|
|
8769
8974
|
/** Draw a strip with lighting off, for camera facing shapes where the light direction means nothing
|
|
8770
8975
|
* @param {Array<Vector3>} points - Strip order
|
|
8771
8976
|
* @param {Vector3|Array<Vector3>} [normals]
|
|
8772
8977
|
* @param {Vector2|Array<Vector2>} [uvs]
|
|
8773
8978
|
* @param {Color|Array<Color>} [colors]
|
|
8774
8979
|
* @param {TileInfo|TextureInfo} [tileInfo] */
|
|
8775
|
-
drawStripUnlit(points: Array<Vector3>, normals?: Vector3 |
|
|
8980
|
+
drawStripUnlit(points: Array<Vector3>, normals?: Vector3 | Vector3[], uvs?: Vector2 | Vector2[], colors?: Color | Color[], tileInfo?: TileInfo | TextureInfo): void;
|
|
8776
8981
|
/** Draw the pending stream vertices as one strip with the state they were drawn under, called automatically when needed */
|
|
8777
8982
|
flush(): void;
|
|
8778
8983
|
/** Build a mesh once out of draw calls, instead of redrawing the shapes every frame
|
|
@@ -8820,7 +9025,7 @@ declare module "littlejsengine" {
|
|
|
8820
9025
|
* @param {Vector3|number} [size] - Full size, a number for a cube
|
|
8821
9026
|
* @param {Color} [color]
|
|
8822
9027
|
* @param {Vector3} [rotation] - vec3(pitch, yaw, roll) */
|
|
8823
|
-
drawBox(pos: Vector3, size?:
|
|
9028
|
+
drawBox(pos: Vector3, size?: number | Vector3, color?: Color, rotation?: Vector3): void;
|
|
8824
9029
|
/** Draw a sphere, untextured and smooth shaded
|
|
8825
9030
|
* @param {Vector3} pos - Center
|
|
8826
9031
|
* @param {number} [size] - Diameter
|
|
@@ -8843,7 +9048,7 @@ declare module "littlejsengine" {
|
|
|
8843
9048
|
* @param {Vector3} d
|
|
8844
9049
|
* @param {TileInfo|TextureInfo} [tileInfo]
|
|
8845
9050
|
* @param {Color|Array<Color>} [color] - One for all or one per corner */
|
|
8846
|
-
drawQuad(a: Vector3, b: Vector3, c: Vector3, d: Vector3, tileInfo?: TileInfo | TextureInfo, color?: Color |
|
|
9051
|
+
drawQuad(a: Vector3, b: Vector3, c: Vector3, d: Vector3, tileInfo?: TileInfo | TextureInfo, color?: Color | Color[]): void;
|
|
8847
9052
|
/** Draw a triangle, counter clockwise from outside is the front
|
|
8848
9053
|
* @param {Vector3} a
|
|
8849
9054
|
* @param {Vector3} b
|
|
@@ -8865,7 +9070,7 @@ declare module "littlejsengine" {
|
|
|
8865
9070
|
* @param {Color|Array<Color>} [color] - One for all or one per point
|
|
8866
9071
|
* @param {Vector3|Array<Vector3>} [side] - Direction across the ribbon, one for all or one per point, default
|
|
8867
9072
|
* faces the camera */
|
|
8868
|
-
drawRibbon(points: Array<Vector3>, width?: number |
|
|
9073
|
+
drawRibbon(points: Array<Vector3>, width?: number | number[], tileInfo?: TileInfo | TextureInfo, color?: Color | Color[], side?: Vector3 | Vector3[]): void;
|
|
8869
9074
|
/** Draw a disc that fades to transparent at the rim, unlit, for glows, puffs and sky dots
|
|
8870
9075
|
* @param {Vector3} pos - Center
|
|
8871
9076
|
* @param {number} [size] - Diameter
|
|
@@ -9184,7 +9389,7 @@ declare module "littlejsengine" {
|
|
|
9184
9389
|
* @param {Vector2|Array<Vector2>} [uvs] - One for all or one per point, default zero
|
|
9185
9390
|
* @param {Color|Array<Color>} [colors] - One for all or one per point, default white
|
|
9186
9391
|
* @return {Mesh} */
|
|
9187
|
-
addStrip(points: Array<Vector3>, normals?: Vector3 |
|
|
9392
|
+
addStrip(points: Array<Vector3>, normals?: Vector3 | Vector3[], uvs?: Vector2 | Vector2[], colors?: Color | Color[]): Mesh;
|
|
9188
9393
|
/** Add triangles over their own vertices, the indexed form a model file comes in
|
|
9189
9394
|
* - The mesh becomes indexed: a strip mesh is turned into triangles first, and strips added later join as triangles
|
|
9190
9395
|
* - List each triangle counter clockwise as seen from the front, like a strip's first triangle
|
|
@@ -9194,7 +9399,7 @@ declare module "littlejsengine" {
|
|
|
9194
9399
|
* @param {Vector2|Array<Vector2>} [uvs] - One for all or one per point, default zero
|
|
9195
9400
|
* @param {Color|Array<Color>} [colors] - One for all or one per point, default white
|
|
9196
9401
|
* @return {Mesh} */
|
|
9197
|
-
addTriangles(points: Array<Vector3>, indices: Array<number>, normals?: Vector3 |
|
|
9402
|
+
addTriangles(points: Array<Vector3>, indices: Array<number>, normals?: Vector3 | Vector3[], uvs?: Vector2 | Vector2[], colors?: Color | Color[]): Mesh;
|
|
9198
9403
|
/** Turn a strip mesh into the indexed form, each distinct vertex once and the real triangles over them, in place
|
|
9199
9404
|
* - An indexed mesh is left as it is; the builders make strips and a loader makes this, and either draws the same
|
|
9200
9405
|
* @return {Mesh} */
|
|
@@ -9207,13 +9412,13 @@ declare module "littlejsengine" {
|
|
|
9207
9412
|
* @param {Color|Array<Color>} [color] - One for all or one per corner
|
|
9208
9413
|
* @param {Array<Vector2>} [uvs] - One per corner, default across the tile
|
|
9209
9414
|
* @return {Mesh} */
|
|
9210
|
-
addQuad(a: Vector3, b: Vector3, c: Vector3, d: Vector3, color?: Color |
|
|
9415
|
+
addQuad(a: Vector3, b: Vector3, c: Vector3, d: Vector3, color?: Color | Color[], uvs?: Vector2[]): Mesh;
|
|
9211
9416
|
/** Append another mesh transformed by a matrix, for building one shape out of several
|
|
9212
9417
|
* @param {Mesh} mesh
|
|
9213
9418
|
* @param {Matrix4|Vector3} [matrix] - Transform, or just a position to move it to
|
|
9214
9419
|
* @param {Color} [color] - Multiplies the appended vertex colors
|
|
9215
9420
|
* @return {Mesh} */
|
|
9216
|
-
combine(mesh: Mesh, matrix?:
|
|
9421
|
+
combine(mesh: Mesh, matrix?: Vector3 | Matrix4, color?: Color): Mesh;
|
|
9217
9422
|
/** Returns a new mesh: this one and its mirror image across the plane through the origin facing axis
|
|
9218
9423
|
* - For modeling half a shape against that plane, a part that crosses it overlaps its image
|
|
9219
9424
|
* @param {Vector3} [axis] - Faces the mirror plane, vec3(1,0,0) mirrors across x
|
|
@@ -9228,7 +9433,7 @@ declare module "littlejsengine" {
|
|
|
9228
9433
|
* @param {Mesh} mesh - Closed, as the builders make them apart from the open ones like buildGrid
|
|
9229
9434
|
* @param {Matrix4|Vector3} [matrix] - Places the other mesh, or just a position to move it to
|
|
9230
9435
|
* @return {Mesh} */
|
|
9231
|
-
union(mesh: Mesh, matrix?:
|
|
9436
|
+
union(mesh: Mesh, matrix?: Vector3 | Matrix4): Mesh;
|
|
9232
9437
|
/** Returns a new mesh of this one with the other cut out of it, CSG with BSP trees
|
|
9233
9438
|
* - Both must be closed, every edge shared by two triangles, as the builders make them apart from the open
|
|
9234
9439
|
* ones like buildGrid and buildRibbon; the result is closed and indexed, and neither mesh changes
|
|
@@ -9245,12 +9450,12 @@ declare module "littlejsengine" {
|
|
|
9245
9450
|
* @return {Mesh}
|
|
9246
9451
|
* @example
|
|
9247
9452
|
* const wall = buildBox(vec3(4, 3, .5)).subtract(buildBox(vec3(1, 2, 1)), vec3(0, -.5, 0)); // a doorway */
|
|
9248
|
-
subtract(mesh: Mesh, matrix?:
|
|
9453
|
+
subtract(mesh: Mesh, matrix?: Vector3 | Matrix4): Mesh;
|
|
9249
9454
|
/** Returns a new mesh of only what is in both this mesh and the other, see subtract
|
|
9250
9455
|
* @param {Mesh} mesh - Closed, as the builders make them apart from the open ones like buildGrid
|
|
9251
9456
|
* @param {Matrix4|Vector3} [matrix] - Places the other mesh, or just a position to move it to
|
|
9252
9457
|
* @return {Mesh} */
|
|
9253
|
-
intersect(mesh: Mesh, matrix?:
|
|
9458
|
+
intersect(mesh: Mesh, matrix?: Vector3 | Matrix4): Mesh;
|
|
9254
9459
|
/** Scale every uv, so a whole texture repeats across the mesh when its TextureInfo wraps
|
|
9255
9460
|
* @param {Vector2|number} scale - Repeats across and up, a number for both
|
|
9256
9461
|
* @return {Mesh} */
|
|
@@ -9303,7 +9508,7 @@ declare module "littlejsengine" {
|
|
|
9303
9508
|
* @param {Matrix4|Vector3} [matrix] - Object transform, or just a position to draw it at
|
|
9304
9509
|
* @param {TileInfo|TextureInfo} [tileInfo] - Texture, mesh uvs map across the tile or the whole texture
|
|
9305
9510
|
* @param {Color} [color] - Tint */
|
|
9306
|
-
render(matrix?:
|
|
9511
|
+
render(matrix?: Vector3 | Matrix4, tileInfo?: TileInfo | TextureInfo, color?: Color): void;
|
|
9307
9512
|
/** Delete the GPU buffer now, the CPU arrays stay so the mesh can be rendered again
|
|
9308
9513
|
* - Optional, the buffer is freed anyway once the mesh is garbage collected, this frees it right away */
|
|
9309
9514
|
dispose(): void;
|
|
@@ -9362,11 +9567,11 @@ declare module "littlejsengine" {
|
|
|
9362
9567
|
boundsEnd: number;
|
|
9363
9568
|
/** @type {number|undefined} */
|
|
9364
9569
|
fixedRadius: number | undefined;
|
|
9365
|
-
buffer: WebGLBuffer;
|
|
9570
|
+
buffer: WebGLBuffer | null | undefined;
|
|
9366
9571
|
/** @type {WebGLBuffer|undefined} */
|
|
9367
9572
|
colorBuffer: WebGLBuffer | undefined;
|
|
9368
9573
|
bufferGeneration: number;
|
|
9369
|
-
uvTileInfo: TileInfo | TextureInfo;
|
|
9574
|
+
uvTileInfo: TileInfo | TextureInfo | undefined;
|
|
9370
9575
|
/** Place an instance by its position, rotation and scale, what buildMatrix takes, written straight in with no
|
|
9371
9576
|
* matrix made; in world space
|
|
9372
9577
|
* @param {number} i
|
|
@@ -9507,7 +9712,7 @@ declare module "littlejsengine" {
|
|
|
9507
9712
|
* @return {Mesh}
|
|
9508
9713
|
* @memberof Render3D
|
|
9509
9714
|
*/
|
|
9510
|
-
export function buildBox(size?:
|
|
9715
|
+
export function buildBox(size?: number | Vector3, bevel?: number, bevelSegments?: number): Mesh;
|
|
9511
9716
|
/**
|
|
9512
9717
|
* Build a heightfield grid in the XZ plane centered on the origin
|
|
9513
9718
|
* - smooth rounds the lighting across cells and colors each corner
|
|
@@ -9525,7 +9730,7 @@ declare module "littlejsengine" {
|
|
|
9525
9730
|
* @example
|
|
9526
9731
|
* const ground = buildGrid(vec2(20), 10, (x, z)=> (floor(x / 2) + floor(z / 2)) & 1 ? GRAY : WHITE); // 2 unit checks
|
|
9527
9732
|
*/
|
|
9528
|
-
export function buildGrid(size?:
|
|
9733
|
+
export function buildGrid(size?: number | Vector2, segments?: number | Vector2, color?: Color | ((arg0: number, arg1: number) => Color), heightFunction?: (arg0: number, arg1: number) => number, smooth?: boolean): Mesh;
|
|
9529
9734
|
/**
|
|
9530
9735
|
* Build a lit ribbon along a path, for roads, tracks and walls
|
|
9531
9736
|
* - Each segment is a flat quad, the sides are across the path in the plane of the up vector
|
|
@@ -9540,7 +9745,7 @@ declare module "littlejsengine" {
|
|
|
9540
9745
|
* @example
|
|
9541
9746
|
* const road = buildRibbon(trackPoints, 8, GRAY, true); // a loop of road
|
|
9542
9747
|
*/
|
|
9543
|
-
export function buildRibbon(points: Array<Vector3>, width?: number |
|
|
9748
|
+
export function buildRibbon(points: Array<Vector3>, width?: number | number[], color?: Color | Color[], closed?: boolean, up?: Vector3): Mesh;
|
|
9544
9749
|
/**
|
|
9545
9750
|
* Build a hull from a row of diamond shaped slices along Z, for ships, planes and cars
|
|
9546
9751
|
* - Each slice is [z, width, top, bottom, sideHeight]
|
|
@@ -9632,7 +9837,7 @@ declare module "littlejsengine" {
|
|
|
9632
9837
|
* @param {Array<Array<Color>>|HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|TextureInfo} [colors]
|
|
9633
9838
|
* @param {Vector3} [pos3D] - Center of the map
|
|
9634
9839
|
* @param {boolean} [smooth] - Defaults to render3D.smoothShading */
|
|
9635
|
-
constructor(heights: Array<Array<number>> | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | TextureInfo, mapSize?: Vector2, height?: number, colors?:
|
|
9840
|
+
constructor(heights: Array<Array<number>> | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | TextureInfo, mapSize?: Vector2, height?: number, colors?: OffscreenCanvas | HTMLCanvasElement | HTMLImageElement | TextureInfo | Color[][], pos3D?: Vector3, smooth?: boolean);
|
|
9636
9841
|
/** @property {Array<Array<number>>} - Heights 0-1 as [row][column], rows along Z, rebuild() after changing them */
|
|
9637
9842
|
heights: number[][];
|
|
9638
9843
|
/** @property {Array<Array<Color>>|undefined} - Vertex colors as [row][column], undefined for white
|
|
@@ -9692,7 +9897,7 @@ declare module "littlejsengine" {
|
|
|
9692
9897
|
levelSegment3D(from: Vector3, to: Vector3): {
|
|
9693
9898
|
distance: number;
|
|
9694
9899
|
normal: Vector3;
|
|
9695
|
-
};
|
|
9900
|
+
} | undefined;
|
|
9696
9901
|
/** Keep an object above the ground, called by the engine for each object with collideLevel
|
|
9697
9902
|
* @param {EngineObject3D} o
|
|
9698
9903
|
* @param {Vector3} oldPos - Where it was before it moved
|
|
@@ -9731,6 +9936,8 @@ declare module "littlejsengine" {
|
|
|
9731
9936
|
constructor(pos3D?: Vector3, mapSize?: Vector3, tileInfo?: TileInfo);
|
|
9732
9937
|
/** @property {Vector3} - Cells along X, Y and Z */
|
|
9733
9938
|
mapSize: Vector3;
|
|
9939
|
+
/** @property {TileInfo} - The sheet's first tile, rebuild() after changing it or resizing its texture */
|
|
9940
|
+
tileInfo: TileInfo;
|
|
9734
9941
|
/** @property {Uint8Array} - The block type of each cell, x + mapSize.x * (y + mapSize.y * z), 0 empty; call
|
|
9735
9942
|
* rebuild() after changing it directly */
|
|
9736
9943
|
data: Uint8Array;
|
|
@@ -9920,13 +10127,13 @@ declare module "littlejsengine" {
|
|
|
9920
10127
|
* @param {Color} [color] - Tints the flare, with the light's own color
|
|
9921
10128
|
* @return {LensFlare3D} - The flare, to change: light.addFlare().shapes = ['hex'] */
|
|
9922
10129
|
addFlare(size?: number, count?: number, intensity?: number, saturation?: number, color?: Color): LensFlare3D;
|
|
9923
|
-
set flare(arg: LensFlare3D);
|
|
10130
|
+
set flare(arg: LensFlare3D | undefined);
|
|
9924
10131
|
/** The light's lens flare, undefined for none: addFlare makes it, or set a LensFlare3D of your own, and
|
|
9925
10132
|
* destroying the flare takes it away
|
|
9926
10133
|
* - The flare is the light's: it is attached to the light as its child, so it stays through a scene change
|
|
9927
10134
|
* when the light does, and is destroyed with the light or when another takes its place
|
|
9928
10135
|
* @type {LensFlare3D|undefined} */
|
|
9929
|
-
get flare(): LensFlare3D;
|
|
10136
|
+
get flare(): LensFlare3D | undefined;
|
|
9930
10137
|
}
|
|
9931
10138
|
/**
|
|
9932
10139
|
* DirectionalLight3D - A Light3D that shines from far away with no falloff, like sunlight
|
|
@@ -10220,7 +10427,7 @@ declare module "littlejsengine" {
|
|
|
10220
10427
|
}>;
|
|
10221
10428
|
/** Forget the trail so far, for when the object teleports */
|
|
10222
10429
|
clear(): void;
|
|
10223
|
-
worldPos3D: Vector3;
|
|
10430
|
+
worldPos3D: Vector3 | undefined;
|
|
10224
10431
|
}
|
|
10225
10432
|
/**
|
|
10226
10433
|
* A part of a lens flare
|
|
@@ -10308,18 +10515,28 @@ declare module "littlejsengine" {
|
|
|
10308
10515
|
* glowSize and ghostSize, a glow and a core at the sun and the ghosts, made again when one of those changes
|
|
10309
10516
|
* @return {Array<LensFlareElement>} */
|
|
10310
10517
|
getElements(): Array<LensFlareElement>;
|
|
10518
|
+
/** What the flare is of, seen from the camera: the way to it, how far it is, Infinity for the sun and for a
|
|
10519
|
+
* directional light, which shines from its place toward the origin, and a point to find it on the screen by;
|
|
10520
|
+
* undefined with no direction, or a light that is gone or at the camera
|
|
10521
|
+
* @return {{direction: Vector3, distance: number, pos: Vector3}|undefined}
|
|
10522
|
+
* @ignore */
|
|
10311
10523
|
flareSource(): {
|
|
10312
10524
|
direction: Vector3;
|
|
10313
10525
|
distance: number;
|
|
10314
10526
|
pos: Vector3;
|
|
10315
|
-
};
|
|
10527
|
+
} | undefined;
|
|
10528
|
+
/** How the flare would show with nothing in the way: where its source is on the screen, how strong it is there,
|
|
10529
|
+
* fading as it leaves the screen, its tint and the height its sizes are parts of; undefined when it would not
|
|
10530
|
+
* show at all, behind the camera, off the screen, or of a light that is off or seen from outside its cone
|
|
10531
|
+
* @return {{sun: Vector2, center: Vector2, strength: number, tint: Color, height: number}|undefined}
|
|
10532
|
+
* @ignore */
|
|
10316
10533
|
flareLook(): {
|
|
10317
10534
|
sun: Vector2;
|
|
10318
10535
|
center: Vector2;
|
|
10319
10536
|
strength: number;
|
|
10320
10537
|
tint: Color;
|
|
10321
10538
|
height: number;
|
|
10322
|
-
};
|
|
10539
|
+
} | undefined;
|
|
10323
10540
|
/** Where the sun, or the flare's light, is on the screen, in pixels like mousePosScreen, undefined when it is
|
|
10324
10541
|
* behind the camera
|
|
10325
10542
|
* @return {Vector2|undefined} */
|
|
@@ -10353,7 +10570,7 @@ declare module "littlejsengine" {
|
|
|
10353
10570
|
* @return {Array<EngineObject3D>}
|
|
10354
10571
|
* @memberof Render3D
|
|
10355
10572
|
*/
|
|
10356
|
-
export function engineObjectsCollect3D(pos: Vector3, size: Vector3 | number, objects?:
|
|
10573
|
+
export function engineObjectsCollect3D(pos: Vector3, size: Vector3 | number, objects?: EngineObject[], testCenters?: boolean): Array<EngineObject3D>;
|
|
10357
10574
|
/**
|
|
10358
10575
|
* Call a function for each EngineObject3D whose box overlaps a sphere or a box
|
|
10359
10576
|
* - An object destroyed by an earlier callback is skipped
|
|
@@ -10364,7 +10581,7 @@ declare module "littlejsengine" {
|
|
|
10364
10581
|
* @param {boolean} [testCenters] - Test only each object's center, see engineObjectsCollect3D
|
|
10365
10582
|
* @memberof Render3D
|
|
10366
10583
|
*/
|
|
10367
|
-
export function engineObjectsCallback3D(pos: Vector3, size: Vector3 | number, callback: (arg0: EngineObject3D) => void, objects?:
|
|
10584
|
+
export function engineObjectsCallback3D(pos: Vector3, size: Vector3 | number, callback: (arg0: EngineObject3D) => void, objects?: EngineObject[], testCenters?: boolean): void;
|
|
10368
10585
|
/**
|
|
10369
10586
|
* Collect every EngineObject3D a ray passes through, nearest first, the 3D twin of engineObjectsRaycast
|
|
10370
10587
|
* - The ray has no end, so everything along it counts however far away it is
|
|
@@ -10374,7 +10591,7 @@ declare module "littlejsengine" {
|
|
|
10374
10591
|
* @return {Array<EngineObject3D>}
|
|
10375
10592
|
* @memberof Render3D
|
|
10376
10593
|
*/
|
|
10377
|
-
export function engineObjectsRaycast3D(ray: Ray3D, objects?:
|
|
10594
|
+
export function engineObjectsRaycast3D(ray: Ray3D, objects?: EngineObject[]): Array<EngineObject3D>;
|
|
10378
10595
|
/**
|
|
10379
10596
|
* Parse Wavefront OBJ text into a Mesh
|
|
10380
10597
|
* - Reads v, vt, vn and f lines with convex polygons of any size, materials and groups are ignored
|
|
@@ -10404,8 +10621,9 @@ declare module "littlejsengine" {
|
|
|
10404
10621
|
* @memberof GLTF
|
|
10405
10622
|
*/
|
|
10406
10623
|
export class GLTFModel {
|
|
10407
|
-
/**
|
|
10408
|
-
|
|
10624
|
+
/** Make a model from its parts, as the loader does
|
|
10625
|
+
* @param {Array<GLTFPart>} parts @param {Array<GLTFAnimation>} [animations] @param {Object} [nodeTree] */
|
|
10626
|
+
constructor(parts: Array<GLTFPart>, animations?: GLTFAnimation[], nodeTree?: any);
|
|
10409
10627
|
/** @property {Array<GLTFPart>} - One per primitive of every node that has a mesh */
|
|
10410
10628
|
parts: GLTFPart[];
|
|
10411
10629
|
/** @property {Array<GLTFAnimation>} - The animations, play one through createObject's GLTFObject
|
|
@@ -10451,6 +10669,7 @@ declare module "littlejsengine" {
|
|
|
10451
10669
|
* @param {number} time - Seconds into it
|
|
10452
10670
|
* @return {Array<Matrix4>} */
|
|
10453
10671
|
getPose(animation: GLTFAnimation, time: number): Array<Matrix4>;
|
|
10672
|
+
partPoses(worldOf: any): Matrix4[];
|
|
10454
10673
|
/** Free the GPU buffers of every part's mesh and of the combined mesh, and the textures, for a model that is
|
|
10455
10674
|
* done with, like a level's models when the next level loads
|
|
10456
10675
|
* - Destroy the objects createObject made from it first; a mesh drawn again only uploads again, but a freed
|
|
@@ -10468,9 +10687,11 @@ declare module "littlejsengine" {
|
|
|
10468
10687
|
* - Loads glTF 2.0 models: a .gltf with its .bin and images beside it, or a .glb with everything in one file
|
|
10469
10688
|
* - A model comes back as parts, one Mesh per primitive of every node placed by the node tree, each with its
|
|
10470
10689
|
* material's color and base color texture, plus everything combined into one Mesh
|
|
10471
|
-
* - Geometry: positions, normals, uvs, vertex colors and indices
|
|
10472
|
-
*
|
|
10473
|
-
*
|
|
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
|
|
10474
10695
|
* - Materials give a base color and texture and whether they blend; glass made with KHR_materials_transmission blends too,
|
|
10475
10696
|
* and a KHR_materials_unlit material comes in emissive, its own color with no shading
|
|
10476
10697
|
* - A material's normal map and emissive map load too, with its normal scale and emissive factor, read at the base
|
|
@@ -10488,6 +10709,7 @@ declare module "littlejsengine" {
|
|
|
10488
10709
|
* const model = await loadGLTF('ship.glb'); // in an async gameInit
|
|
10489
10710
|
* const ship = model.createObject(vec3(0, 1, 0)); // an object with a child per part, textures and all
|
|
10490
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
|
|
10491
10713
|
* new EngineObject3D(vec3(), model.mesh); // or the whole thing as one mesh, still
|
|
10492
10714
|
*/
|
|
10493
10715
|
/**
|
|
@@ -10495,7 +10717,8 @@ declare module "littlejsengine" {
|
|
|
10495
10717
|
* @memberof GLTF
|
|
10496
10718
|
*/
|
|
10497
10719
|
export class GLTFPart {
|
|
10498
|
-
/**
|
|
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 */
|
|
10499
10722
|
constructor(name: string, mesh: Mesh, color: Color, textureInfo: TextureInfo | undefined, transparent: boolean);
|
|
10500
10723
|
/** @property {string} - The node's name, or its mesh's */
|
|
10501
10724
|
name: string;
|
|
@@ -10528,6 +10751,12 @@ declare module "littlejsengine" {
|
|
|
10528
10751
|
emissiveMap: TextureInfo | undefined;
|
|
10529
10752
|
/** @property {Color} - The emissiveFactor, which multiplies the emissive map */
|
|
10530
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;
|
|
10531
10760
|
}
|
|
10532
10761
|
/**
|
|
10533
10762
|
* GLTFObject - A model as an object with a child per part, which plays the model's animations
|
|
@@ -10558,28 +10787,65 @@ declare module "littlejsengine" {
|
|
|
10558
10787
|
animationLoop: boolean;
|
|
10559
10788
|
/** @property {boolean} - Whether it is moving through the animation now */
|
|
10560
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;
|
|
10561
10805
|
/** @property {Array<EngineObject3D>} - The child that draws each of the model's parts, in the order of
|
|
10562
10806
|
* model.parts, which an animation poses; one destroyed or taken off the object is left alone
|
|
10563
10807
|
* @type {Array<EngineObject3D>} */
|
|
10564
10808
|
parts: Array<EngineObject3D>;
|
|
10565
|
-
/** 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
|
|
10566
10812
|
* @param {string|number|GLTFAnimation} [animation] - Its name, its number in model.animations, or itself
|
|
10567
10813
|
* @param {boolean} [loop] - Start again at the end, or stop there
|
|
10568
|
-
* @param {number} [speed] - 1 is as made, negative plays it backward from its end
|
|
10569
|
-
|
|
10570
|
-
|
|
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 */
|
|
10571
10819
|
stop(): void;
|
|
10572
10820
|
/** Put the parts where the animation has them at a time, playing or not
|
|
10573
10821
|
* @param {number} time - Seconds into the animation */
|
|
10574
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;
|
|
10575
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
|
+
*/
|
|
10576
10841
|
/**
|
|
10577
10842
|
* GLTFAnimation - One animation of a model: keys that move, turn and scale its nodes over time
|
|
10578
10843
|
* - Play it through the GLTFObject that model.createObject makes
|
|
10579
10844
|
* @memberof GLTF
|
|
10580
10845
|
*/
|
|
10581
10846
|
export class GLTFAnimation {
|
|
10582
|
-
/**
|
|
10847
|
+
/** Make an animation from its channels, as the loader does
|
|
10848
|
+
* @param {string} name @param {Array<Object>} channels */
|
|
10583
10849
|
constructor(name: string, channels: Array<any>);
|
|
10584
10850
|
/** @property {string} - Its name in the file, or 'animation' and its number when it has none */
|
|
10585
10851
|
name: string;
|
|
@@ -10623,7 +10889,7 @@ declare module "littlejsengine" {
|
|
|
10623
10889
|
* @param {number} [time] - How long to show it, 0 is one frame
|
|
10624
10890
|
* @param {Vector3} [rotation] - vec3(pitch, yaw, roll)
|
|
10625
10891
|
* @memberof Render3D */
|
|
10626
|
-
export function debugBox3D(pos: Vector3, size?:
|
|
10892
|
+
export function debugBox3D(pos: Vector3, size?: number | Vector3, color?: Color, time?: number, rotation?: Vector3): void;
|
|
10627
10893
|
/** Draw a debug wireframe sphere as three rings
|
|
10628
10894
|
* @param {Vector3} pos - Center
|
|
10629
10895
|
* @param {number} [size] - Diameter
|
|
@@ -10658,13 +10924,15 @@ declare module "littlejsengine" {
|
|
|
10658
10924
|
* - Adding a name again replaces it, Box, Sphere, Cylinder and Light too
|
|
10659
10925
|
* @param {string} name - The type the objects have in the level
|
|
10660
10926
|
* @param {Function} make - A class made at each object's position, or a function called with it
|
|
10661
|
-
* @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
|
|
10662
10928
|
* @param {TileInfo} [tileInfo] - An icon for the level editor
|
|
10663
10929
|
* @memberof Level3D
|
|
10664
10930
|
* @example
|
|
10665
10931
|
* level3DAddType('Crate', Crate, {health: 3});
|
|
10666
10932
|
* level3DAddType('PlayerStart', (pos)=> playerStart = pos); */
|
|
10667
|
-
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;
|
|
10668
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
|
|
10669
10937
|
* - Each object has a color and a solid property, solid collides as the box around the mesh
|
|
10670
10938
|
* @param {string} name - The type the objects have in the level
|
|
@@ -10698,10 +10966,10 @@ declare module "littlejsengine" {
|
|
|
10698
10966
|
* sunColor, fog, its start and end, fogColor, the horizon color when not given, shadows, and lensFlare, the
|
|
10699
10967
|
* sun's lens flare; what the block leaves out stays as the game set it, and a level with no block changes
|
|
10700
10968
|
* nothing
|
|
10701
|
-
* @param {
|
|
10969
|
+
* @param {Level3D} level - The level, the level editor edits this same object
|
|
10702
10970
|
* @return {Array<any>} - What each object's type made, a function that made nothing is left out
|
|
10703
10971
|
* @memberof Level3D */
|
|
10704
|
-
export function level3DLoad(level:
|
|
10972
|
+
export function level3DLoad(level: Level3D): Array<any>;
|
|
10705
10973
|
/** Add a prefab: a small level, its objects placed about its own origin, to place many times under one name
|
|
10706
10974
|
* - It is a type from then on: a level's object of that type, the level editor's Place list and level3DSpawn make
|
|
10707
10975
|
* an instance, a Prefab3D; an instance is made of the prefab as it is then, so the level editor, where a prefab
|
|
@@ -10714,13 +10982,17 @@ declare module "littlejsengine" {
|
|
|
10714
10982
|
* by hand does
|
|
10715
10983
|
* - Adding a name again replaces it
|
|
10716
10984
|
* @param {string} name - The type its instances have in a level
|
|
10717
|
-
* @param {Object} prefab -
|
|
10985
|
+
* @param {{objects: Array<Object>, attached?: boolean}} prefab - Its objects, about its own origin, and whether
|
|
10986
|
+
* they are attached
|
|
10718
10987
|
* @memberof Level3D
|
|
10719
10988
|
* @example
|
|
10720
10989
|
* level3DAddPrefab('Tower', {objects: [{type: 'Box', pos: [0, 1, 0], scale: [2, 2, 2]},
|
|
10721
10990
|
* {type: 'Cylinder', pos: [0, 3, 0]}]});
|
|
10722
10991
|
* level3DLoad({objects: [{type: 'Tower', pos: [5, 0, 5]}, {type: 'Tower', pos: [-5, 0, 5], rotation: [0, 45, 0]}]}); */
|
|
10723
|
-
export function level3DAddPrefab(name: string, prefab:
|
|
10992
|
+
export function level3DAddPrefab(name: string, prefab: {
|
|
10993
|
+
objects: Array<any>;
|
|
10994
|
+
attached?: boolean;
|
|
10995
|
+
}): void;
|
|
10724
10996
|
/** Load a prefab from a file the level editor saved and add it
|
|
10725
10997
|
* @param {string} name - The type its instances have in a level
|
|
10726
10998
|
* @param {string} url
|
|
@@ -10733,13 +11005,15 @@ declare module "littlejsengine" {
|
|
|
10733
11005
|
* @param {Vector3} [pos3D]
|
|
10734
11006
|
* @param {Vector3} [rotation3D] - In radians, as an object has it
|
|
10735
11007
|
* @param {Vector3} [scale3D] - Times the scale the type makes it with
|
|
10736
|
-
* @param {Object} [properties] - Over the type's defaults
|
|
11008
|
+
* @param {Object<string, any>} [properties] - Over the type's defaults
|
|
10737
11009
|
* @return {any} - What the type made, a Prefab3D for a prefab, undefined when there is no such type
|
|
10738
11010
|
* @memberof Level3D
|
|
10739
11011
|
* @example
|
|
10740
11012
|
* level3DAddPrefab('House', await fetchJSON('house.json'));
|
|
10741
11013
|
* level3DSpawn('House', vec3(10, 0, 0), vec3(0, PI/2, 0)); */
|
|
10742
|
-
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;
|
|
10743
11017
|
/**
|
|
10744
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
|
|
10745
11019
|
* prefab's objects made
|
|
@@ -10825,7 +11099,7 @@ declare module "littlejsengine" {
|
|
|
10825
11099
|
/** @property {Object} - The three.js perspective camera */
|
|
10826
11100
|
camera: any;
|
|
10827
11101
|
/** @property {boolean} - Lock the camera to the LittleJS 2D camera so the z=0 plane matches world space */
|
|
10828
|
-
cameraAlign2D: boolean;
|
|
11102
|
+
cameraAlign2D: boolean | undefined;
|
|
10829
11103
|
/** @property {number|undefined} - Near plane of the aligned camera before any zoom out, from camera.near on the
|
|
10830
11104
|
* first aligned frame; while aligned, change this rather than camera.near
|
|
10831
11105
|
* @type {number|undefined} */
|
|
@@ -10907,9 +11181,9 @@ declare module "littlejsengine" {
|
|
|
10907
11181
|
/** @property {number} - Width and height of the sheet in pixels */
|
|
10908
11182
|
size: number;
|
|
10909
11183
|
/** @property {OffscreenCanvasRenderingContext2D} - 2d context for the canvas */
|
|
10910
|
-
context: OffscreenCanvasRenderingContext2D;
|
|
11184
|
+
context: OffscreenCanvasRenderingContext2D | undefined;
|
|
10911
11185
|
/** @property {OffscreenCanvas} - Canvas holding the packed images */
|
|
10912
|
-
canvas: OffscreenCanvas;
|
|
11186
|
+
canvas: OffscreenCanvas | undefined;
|
|
10913
11187
|
/** @property {TextureInfo} - The texture info for this sheet */
|
|
10914
11188
|
textureInfo: TextureInfo;
|
|
10915
11189
|
/** @property {Vector2} - Where the next image will be packed */
|
|
@@ -10941,7 +11215,8 @@ declare module "littlejsengine" {
|
|
|
10941
11215
|
* - Pass frameSize for animations, then step through them with TileInfo.frame
|
|
10942
11216
|
* - Grid images keep their layout and frames wrap down to the next row
|
|
10943
11217
|
* - Pass sourcePadding if the source image has padding baked in around frames
|
|
10944
|
-
* - The same image loaded again with the same settings gives back what the first load did, packed once
|
|
11218
|
+
* - The same image loaded again with the same settings gives back what the first load did, packed once, unless
|
|
11219
|
+
* that load failed
|
|
10945
11220
|
* @param {string} src - Image source path
|
|
10946
11221
|
* @param {Vector2|number} [frameSize] - Size of each animation frame in pixels, or the whole image less its
|
|
10947
11222
|
* source padding if not passed
|
|
@@ -10952,7 +11227,7 @@ declare module "littlejsengine" {
|
|
|
10952
11227
|
* const playerTile = loadSprite('player.png'); // a single sprite
|
|
10953
11228
|
* const runTile = loadSprite('run.png', vec2(16)); // a 16x16 frame animation
|
|
10954
11229
|
* @memberof TextureSheets */
|
|
10955
|
-
export function loadSprite(src: string, frameSize?:
|
|
11230
|
+
export function loadSprite(src: string, frameSize?: number | Vector2, padding?: number, sourcePadding?: number | Vector2): TileInfo;
|
|
10956
11231
|
/** Load tile images and pack them into texture sheets as one tile set, for tile layers and maps
|
|
10957
11232
|
* - Each image is cut into tiles of tileSize, left to right then down, so an image of one tile is one tile and a
|
|
10958
11233
|
* sheet is all of its tiles; the tiles are numbered from 0 in the order the images are given
|
|
@@ -10964,7 +11239,8 @@ declare module "littlejsengine" {
|
|
|
10964
11239
|
* is not read, cut it into its tiles first
|
|
10965
11240
|
* - An image that fails to load, or that no sheet can hold, adds no tiles and says so in the console, so the tiles
|
|
10966
11241
|
* of the images after it move up
|
|
10967
|
-
* - The same images loaded again with the same settings give back what the first load did, packed once
|
|
11242
|
+
* - The same images loaded again with the same settings give back what the first load did, packed once, unless
|
|
11243
|
+
* an image of it failed
|
|
10968
11244
|
* @param {Array<string>} sources - Image source paths
|
|
10969
11245
|
* @param {Vector2|number} [tileSize] - Size of a tile in pixels
|
|
10970
11246
|
* @param {number} [padding] - How many pixels padding around each tile on the sheet
|
|
@@ -10974,7 +11250,7 @@ declare module "littlejsengine" {
|
|
|
10974
11250
|
* await spritesReady();
|
|
10975
11251
|
* tileLayersLoad(map, tiles); // tile 0 is grass, 1 dirt, 2 water, then the tiles of props.png
|
|
10976
11252
|
* @memberof TextureSheets */
|
|
10977
|
-
export function loadTiles(sources: Array<string>, tileSize?:
|
|
11253
|
+
export function loadTiles(sources: Array<string>, tileSize?: number | Vector2, padding?: number): TileInfo;
|
|
10978
11254
|
/** Load a pre-packed texture atlas and repack it onto texture sheets
|
|
10979
11255
|
* - Supports TexturePacker json (hash and array) and Aseprite json
|
|
10980
11256
|
* - Returns an empty object which is filled with TileInfos when loaded
|
|
@@ -10982,7 +11258,8 @@ declare module "littlejsengine" {
|
|
|
10982
11258
|
* - Aseprite frame tags become animations, so do names like run_0, run_1
|
|
10983
11259
|
* - Trimmed frames are restored to their full source size when packed
|
|
10984
11260
|
* - Rotated frames are rotated back upright when packed
|
|
10985
|
-
* - The same atlas loaded again by its paths, with the same padding, gives back what the first load did, packed
|
|
11261
|
+
* - The same atlas loaded again by its paths, with the same padding, gives back what the first load did, packed
|
|
11262
|
+
* once, unless that load failed
|
|
10986
11263
|
* @param {string} imageSrc - Atlas image path
|
|
10987
11264
|
* @param {string|Object} jsonSrc - Atlas json path, or already parsed json data
|
|
10988
11265
|
* @param {number} [padding] - How many pixels padding around each frame
|
|
@@ -11077,10 +11354,10 @@ declare module "littlejsengine" {
|
|
|
11077
11354
|
}[];
|
|
11078
11355
|
};
|
|
11079
11356
|
/** A copy of an effect with its four colors turned around the color wheel and their saturation scaled; lightness and
|
|
11080
|
-
* alpha stay, and
|
|
11357
|
+
* alpha stay, and gray and white have no hue to turn
|
|
11081
11358
|
* @param {Object} effect
|
|
11082
11359
|
* @param {number} [hue] - How far around the wheel, 1 is all the way
|
|
11083
|
-
* @param {number} [saturation] - Multiplies the saturation, 0 is
|
|
11360
|
+
* @param {number} [saturation] - Multiplies the saturation, 0 is gray, clamped to 1
|
|
11084
11361
|
* @return {Object}
|
|
11085
11362
|
* @memberof ParticleEffects */
|
|
11086
11363
|
export function particleEffectRecolor(effect: any, hue?: number, saturation?: number): any;
|
|
@@ -11124,7 +11401,7 @@ declare module "littlejsengine" {
|
|
|
11124
11401
|
* @param {Object} [options] - What to change for this play, each left out when not wanted:
|
|
11125
11402
|
* scale grows the whole effect, the built-ins fit a one unit object at 1;
|
|
11126
11403
|
* hue turns its colors around the color wheel, 1 is all the way;
|
|
11127
|
-
* saturation multiplies its saturation, 0 is
|
|
11404
|
+
* saturation multiplies its saturation, 0 is gray;
|
|
11128
11405
|
* angle is its direction, 0 is up, the effect's own angle when not given;
|
|
11129
11406
|
* tileInfo, a TileInfo or a TextureInfo, is the game's own art to draw with in place of the effect's shape,
|
|
11130
11407
|
* tinted by its colors, a whole texture drawn as one tile;
|