littlejsengine 1.16.1 → 1.17.1
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/dist/littlejs.d.ts +287 -240
- package/dist/littlejs.esm.js +1419 -1259
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +1076 -910
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +977 -815
- package/examples/box2d/gameObjects.js +6 -6
- package/examples/breakout/game.js +5 -6
- package/examples/electron/index.html +2 -2
- package/examples/electron/tiles.png +0 -0
- package/examples/htmlMenu/tiles.png +0 -0
- package/examples/index.html +1 -1
- package/examples/logo.png +0 -0
- package/examples/logo2.png +0 -0
- package/examples/module/tiles.png +0 -0
- package/examples/platformer/gameEffects.js +24 -23
- package/examples/platformer/gameLevel.js +24 -25
- package/examples/shorts/base.html +2 -1
- package/examples/shorts/clock.js +3 -3
- package/examples/shorts/fontImage.js +4 -3
- package/examples/shorts/parallax.js +1 -1
- package/examples/shorts/sequencer.js +1 -1
- package/examples/shorts/shapes.js +1 -1
- package/examples/shorts/texture.js +10 -6
- package/examples/shorts/tiles.png +0 -0
- package/examples/shorts/tiltedView.js +2 -0
- package/examples/starter/index.html +3 -2
- package/examples/starter/tiles.png +0 -0
- package/examples/typescript/tiles.png +0 -0
- package/examples/uiSystem/game.js +1 -1
- package/examples/uiSystem/tiles.png +0 -0
- package/package.json +1 -1
- package/plugins/postProcess.js +47 -28
- package/plugins/uiSystem.js +16 -16
- package/reference.md +6 -6
- package/src/engine.js +186 -198
- package/src/engineAudio.js +6 -10
- package/src/engineBuild.js +1 -0
- package/src/engineDebug.js +100 -98
- package/src/engineDraw.js +185 -148
- package/src/engineExport.js +327 -333
- package/src/engineFont.png +0 -0
- package/src/engineInput.js +17 -26
- package/src/engineMath.js +1112 -0
- package/src/engineMedals.js +4 -4
- package/src/engineObject.js +27 -27
- package/src/engineParticles.js +2 -2
- package/src/engineRelease.js +1 -3
- package/src/engineSettings.js +2 -2
- package/src/engineTileLayer.js +200 -176
- package/src/engineUtilities.js +48 -1097
- package/src/engineWebGL.js +127 -79
package/dist/littlejs.d.ts
CHANGED
|
@@ -212,7 +212,7 @@ declare module "littlejsengine" {
|
|
|
212
212
|
export function LOG(...output?: any[]): void;
|
|
213
213
|
/** Draw a debug rectangle in world space
|
|
214
214
|
* @param {Vector2} pos
|
|
215
|
-
* @param {Vector2} [size=
|
|
215
|
+
* @param {Vector2} [size=vec2(0)]
|
|
216
216
|
* @param {Color|string} [color]
|
|
217
217
|
* @param {number} [time]
|
|
218
218
|
* @param {number} [angle]
|
|
@@ -283,37 +283,20 @@ declare module "littlejsengine" {
|
|
|
283
283
|
/** Trigger debug system to take a screenshot
|
|
284
284
|
* @memberof Debug */
|
|
285
285
|
export function debugScreenshot(): void;
|
|
286
|
-
/** Save a canvas to disk
|
|
287
|
-
* @param {HTMLCanvasElement|OffscreenCanvas} canvas
|
|
288
|
-
* @param {string} [filename]
|
|
289
|
-
* @param {string} [type]
|
|
290
|
-
* @memberof Debug */
|
|
291
|
-
export function debugSaveCanvas(canvas: HTMLCanvasElement | OffscreenCanvas, filename?: string, type?: string): void;
|
|
292
|
-
/** Save a text file to disk
|
|
293
|
-
* @param {string} text
|
|
294
|
-
* @param {string} [filename]
|
|
295
|
-
* @param {string} [type]
|
|
296
|
-
* @memberof Debug */
|
|
297
|
-
export function debugSaveText(text: string, filename?: string, type?: string): void;
|
|
298
|
-
/** Save a data url to disk
|
|
299
|
-
* @param {string} dataURL
|
|
300
|
-
* @param {string} filename
|
|
301
|
-
* @memberof Debug */
|
|
302
|
-
export function debugSaveDataURL(dataURL: string, filename: string): void;
|
|
303
286
|
/** Breaks on all asserts/errors, hides the canvas, and shows message in plain text
|
|
304
287
|
* This is a good function to call at the start of your game to catch all errors
|
|
305
288
|
* In release builds this function has no effect
|
|
306
289
|
* @memberof Debug */
|
|
307
290
|
export function debugShowErrors(): void;
|
|
308
|
-
/** Check if video capture is active
|
|
309
|
-
* @memberof Debug */
|
|
310
|
-
export function debugVideoCaptureIsActive(): boolean;
|
|
311
291
|
/** Start capturing video
|
|
312
292
|
* @memberof Debug */
|
|
313
293
|
export function debugVideoCaptureStart(): void;
|
|
314
294
|
/** Stop capturing video and save to disk
|
|
315
295
|
* @memberof Debug */
|
|
316
296
|
export function debugVideoCaptureStop(): void;
|
|
297
|
+
/** Check if video capture is active
|
|
298
|
+
* @memberof Debug */
|
|
299
|
+
export function debugVideoCaptureIsActive(): boolean;
|
|
317
300
|
/**
|
|
318
301
|
* LittleJS Engine Settings
|
|
319
302
|
* - All settings for the engine are here
|
|
@@ -340,7 +323,7 @@ declare module "littlejsengine" {
|
|
|
340
323
|
* @default
|
|
341
324
|
* @memberof Settings */
|
|
342
325
|
export let canvasColorTiles: boolean;
|
|
343
|
-
/** Color to clear the canvas to before render
|
|
326
|
+
/** Color to clear the canvas to before render, does not clear if alpha is 0
|
|
344
327
|
* @type {Color}
|
|
345
328
|
* @memberof Draw */
|
|
346
329
|
export let canvasClearColor: Color;
|
|
@@ -560,7 +543,7 @@ declare module "littlejsengine" {
|
|
|
560
543
|
* @param {boolean} colorTiles
|
|
561
544
|
* @memberof Settings */
|
|
562
545
|
export function setCanvasColorTiles(colorTiles: boolean): void;
|
|
563
|
-
/** Set color to clear the canvas to before render
|
|
546
|
+
/** Set color to clear the canvas to before render, does not clear if alpha is 0
|
|
564
547
|
* @param {Color} color
|
|
565
548
|
* @memberof Settings */
|
|
566
549
|
export function setCanvasClearColor(color: Color): void;
|
|
@@ -738,111 +721,110 @@ declare module "littlejsengine" {
|
|
|
738
721
|
* @memberof Debug */
|
|
739
722
|
export function setDebugKey(key: string): void;
|
|
740
723
|
/**
|
|
741
|
-
* LittleJS
|
|
724
|
+
* LittleJS Math Classes and Functions
|
|
742
725
|
* - General purpose math library
|
|
743
|
-
* - Vector2 - fast, simple, easy 2D vector class
|
|
744
|
-
* - Color - holds a rgba color with some math functions
|
|
745
|
-
* - Timer - tracks time automatically
|
|
746
726
|
* - RandomGenerator - seeded random number generator
|
|
747
|
-
*
|
|
727
|
+
* - Vector2 - fast, simple, easy 2D vector class
|
|
728
|
+
* - Color - holds a rgba color with math functions
|
|
729
|
+
* @namespace Math
|
|
748
730
|
*/
|
|
749
731
|
/** The value of PI
|
|
750
732
|
* @type {number}
|
|
751
733
|
* @default Math.PI
|
|
752
|
-
* @memberof
|
|
734
|
+
* @memberof Math */
|
|
753
735
|
export const PI: number;
|
|
754
736
|
/** Returns absolute value of value passed in
|
|
755
737
|
* @param {number} value
|
|
756
738
|
* @return {number}
|
|
757
|
-
* @memberof
|
|
739
|
+
* @memberof Math */
|
|
758
740
|
export const abs: (x: number) => number;
|
|
759
741
|
/** Returns floored value of value passed in
|
|
760
742
|
* @param {number} value
|
|
761
743
|
* @return {number}
|
|
762
|
-
* @memberof
|
|
744
|
+
* @memberof Math */
|
|
763
745
|
export const floor: (x: number) => number;
|
|
764
746
|
/** Returns ceiled value of value passed in
|
|
765
747
|
* @param {number} value
|
|
766
748
|
* @return {number}
|
|
767
|
-
* @memberof
|
|
749
|
+
* @memberof Math */
|
|
768
750
|
export const ceil: (x: number) => number;
|
|
769
751
|
/** Returns rounded value passed in
|
|
770
752
|
* @param {number} value
|
|
771
753
|
* @return {number}
|
|
772
|
-
* @memberof
|
|
754
|
+
* @memberof Math */
|
|
773
755
|
export const round: (x: number) => number;
|
|
774
756
|
/** Returns lowest value passed in
|
|
775
757
|
* @param {...number} values
|
|
776
758
|
* @return {number}
|
|
777
|
-
* @memberof
|
|
759
|
+
* @memberof Math */
|
|
778
760
|
export const min: (...values: number[]) => number;
|
|
779
761
|
/** Returns highest value passed in
|
|
780
762
|
* @param {...number} values
|
|
781
763
|
* @return {number}
|
|
782
|
-
* @memberof
|
|
764
|
+
* @memberof Math */
|
|
783
765
|
export const max: (...values: number[]) => number;
|
|
784
766
|
/** Returns the sign of value passed in
|
|
785
767
|
* @param {number} value
|
|
786
768
|
* @return {number}
|
|
787
|
-
* @memberof
|
|
769
|
+
* @memberof Math */
|
|
788
770
|
export const sign: (x: number) => number;
|
|
789
771
|
/** Returns hypotenuse of values passed in
|
|
790
772
|
* @param {...number} values
|
|
791
773
|
* @return {number}
|
|
792
|
-
* @memberof
|
|
774
|
+
* @memberof Math */
|
|
793
775
|
export const hypot: (...values: number[]) => number;
|
|
794
776
|
/** Returns log2 of value passed in
|
|
795
777
|
* @param {number} value
|
|
796
778
|
* @return {number}
|
|
797
|
-
* @memberof
|
|
779
|
+
* @memberof Math */
|
|
798
780
|
export const log2: (x: number) => number;
|
|
799
781
|
/** Returns sin of value passed in
|
|
800
782
|
* @param {number} value
|
|
801
783
|
* @return {number}
|
|
802
|
-
* @memberof
|
|
784
|
+
* @memberof Math */
|
|
803
785
|
export const sin: (x: number) => number;
|
|
804
786
|
/** Returns cos of value passed in
|
|
805
787
|
* @param {number} value
|
|
806
788
|
* @return {number}
|
|
807
|
-
* @memberof
|
|
789
|
+
* @memberof Math */
|
|
808
790
|
export const cos: (x: number) => number;
|
|
809
791
|
/** Returns tan of value passed in
|
|
810
792
|
* @param {number} value
|
|
811
793
|
* @return {number}
|
|
812
|
-
* @memberof
|
|
794
|
+
* @memberof Math */
|
|
813
795
|
export const tan: (x: number) => number;
|
|
814
796
|
/** Returns atan2 of values passed in
|
|
815
797
|
* @param {number} y
|
|
816
798
|
* @param {number} x
|
|
817
799
|
* @return {number}
|
|
818
|
-
* @memberof
|
|
800
|
+
* @memberof Math */
|
|
819
801
|
export const atan2: (y: number, x: number) => number;
|
|
820
802
|
/** Returns first parm modulo the second param, but adjusted so negative numbers work as expected
|
|
821
803
|
* @param {number} dividend
|
|
822
804
|
* @param {number} [divisor]
|
|
823
805
|
* @return {number}
|
|
824
|
-
* @memberof
|
|
806
|
+
* @memberof Math */
|
|
825
807
|
export function mod(dividend: number, divisor?: number): number;
|
|
826
808
|
/** Clamps the value between max and min
|
|
827
809
|
* @param {number} value
|
|
828
810
|
* @param {number} [min]
|
|
829
811
|
* @param {number} [max]
|
|
830
812
|
* @return {number}
|
|
831
|
-
* @memberof
|
|
813
|
+
* @memberof Math */
|
|
832
814
|
export function clamp(value: number, min?: number, max?: number): number;
|
|
833
815
|
/** Returns what percentage the value is between valueA and valueB
|
|
834
816
|
* @param {number} value
|
|
835
817
|
* @param {number} valueA
|
|
836
818
|
* @param {number} valueB
|
|
837
819
|
* @return {number}
|
|
838
|
-
* @memberof
|
|
820
|
+
* @memberof Math */
|
|
839
821
|
export function percent(value: number, valueA: number, valueB: number): number;
|
|
840
822
|
/** Returns signed wrapped distance between the two values passed in
|
|
841
823
|
* @param {number} valueA
|
|
842
824
|
* @param {number} valueB
|
|
843
825
|
* @param {number} [wrapSize]
|
|
844
826
|
* @return {number}
|
|
845
|
-
* @memberof
|
|
827
|
+
* @memberof Math */
|
|
846
828
|
export function distanceWrap(valueA: number, valueB: number, wrapSize?: number): number;
|
|
847
829
|
/** Linearly interpolates between values passed in with wrapping
|
|
848
830
|
* @param {number} valueA
|
|
@@ -850,46 +832,46 @@ declare module "littlejsengine" {
|
|
|
850
832
|
* @param {number} percent
|
|
851
833
|
* @param {number} [wrapSize]
|
|
852
834
|
* @return {number}
|
|
853
|
-
* @memberof
|
|
835
|
+
* @memberof Math */
|
|
854
836
|
export function lerpWrap(valueA: number, valueB: number, percent: number, wrapSize?: number): number;
|
|
855
837
|
/** Returns signed wrapped distance between the two angles passed in
|
|
856
838
|
* @param {number} angleA
|
|
857
839
|
* @param {number} angleB
|
|
858
840
|
* @return {number}
|
|
859
|
-
* @memberof
|
|
841
|
+
* @memberof Math */
|
|
860
842
|
export function distanceAngle(angleA: number, angleB: number): number;
|
|
861
843
|
/** Linearly interpolates between the angles passed in with wrapping
|
|
862
844
|
* @param {number} angleA
|
|
863
845
|
* @param {number} angleB
|
|
864
846
|
* @param {number} percent
|
|
865
847
|
* @return {number}
|
|
866
|
-
* @memberof
|
|
848
|
+
* @memberof Math */
|
|
867
849
|
export function lerpAngle(angleA: number, angleB: number, percent: number): number;
|
|
868
850
|
/** Linearly interpolates between values passed in using percent
|
|
869
851
|
* @param {number} valueA
|
|
870
852
|
* @param {number} valueB
|
|
871
853
|
* @param {number} percent
|
|
872
854
|
* @return {number}
|
|
873
|
-
* @memberof
|
|
855
|
+
* @memberof Math */
|
|
874
856
|
export function lerp(valueA: number, valueB: number, percent: number): number;
|
|
875
857
|
/** Applies smoothstep function to the percentage value
|
|
876
858
|
* @param {number} percent
|
|
877
859
|
* @return {number}
|
|
878
|
-
* @memberof
|
|
860
|
+
* @memberof Math */
|
|
879
861
|
export function smoothStep(percent: number): number;
|
|
880
862
|
/** Returns the nearest power of two not less than the value
|
|
881
863
|
* @param {number} value
|
|
882
864
|
* @return {number}
|
|
883
|
-
* @memberof
|
|
865
|
+
* @memberof Math */
|
|
884
866
|
export function nearestPowerOfTwo(value: number): number;
|
|
885
867
|
/** Returns true if two axis aligned bounding boxes are overlapping
|
|
886
868
|
* this can be used for simple collision detection between objects
|
|
887
|
-
* @param {Vector2} posA
|
|
888
|
-
* @param {Vector2} sizeA
|
|
889
|
-
* @param {Vector2} posB
|
|
890
|
-
* @param {Vector2} [sizeB=(
|
|
891
|
-
* @return {boolean}
|
|
892
|
-
* @memberof
|
|
869
|
+
* @param {Vector2} posA - Center of box A
|
|
870
|
+
* @param {Vector2} sizeA - Size of box A
|
|
871
|
+
* @param {Vector2} posB - Center of box B
|
|
872
|
+
* @param {Vector2} [sizeB=vec2()] - Size of box B, uses a point if undefined
|
|
873
|
+
* @return {boolean} - True if overlapping
|
|
874
|
+
* @memberof Math */
|
|
893
875
|
export function isOverlapping(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB?: Vector2): boolean;
|
|
894
876
|
/** Returns true if a line segment is intersecting an axis aligned box
|
|
895
877
|
* @param {Vector2} start - Start of raycast
|
|
@@ -897,7 +879,7 @@ declare module "littlejsengine" {
|
|
|
897
879
|
* @param {Vector2} pos - Center of box
|
|
898
880
|
* @param {Vector2} size - Size of box
|
|
899
881
|
* @return {boolean} - True if intersecting
|
|
900
|
-
* @memberof
|
|
882
|
+
* @memberof Math */
|
|
901
883
|
export function isIntersecting(start: Vector2, end: Vector2, pos: Vector2, size: Vector2): boolean;
|
|
902
884
|
/** Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default
|
|
903
885
|
* @param {number} [frequency] - Frequency of the wave in Hz
|
|
@@ -905,8 +887,14 @@ declare module "littlejsengine" {
|
|
|
905
887
|
* @param {number} [t=time] - Value to use for time of the wave
|
|
906
888
|
* @param {number} [offset] - Value to use for time offset of the wave
|
|
907
889
|
* @return {number} - Value waving between 0 and amplitude
|
|
908
|
-
* @memberof
|
|
890
|
+
* @memberof Math */
|
|
909
891
|
export function wave(frequency?: number, amplitude?: number, t?: number, offset?: number): number;
|
|
892
|
+
/**
|
|
893
|
+
* LittleJS Utility Classes and Functions
|
|
894
|
+
* - General purpose utilities
|
|
895
|
+
* - Timer - tracks time automatically
|
|
896
|
+
* @namespace Utilities
|
|
897
|
+
*/
|
|
910
898
|
/** Formats seconds to mm:ss style for display purposes
|
|
911
899
|
* @param {number} t - time in seconds
|
|
912
900
|
* @return {string}
|
|
@@ -917,6 +905,30 @@ declare module "littlejsengine" {
|
|
|
917
905
|
* @return {Promise<object>}
|
|
918
906
|
* @memberof Utilities */
|
|
919
907
|
export function fetchJSON(url: string): Promise<object>;
|
|
908
|
+
/** Save a text file to disk
|
|
909
|
+
* @param {string} text
|
|
910
|
+
* @param {string} [filename]
|
|
911
|
+
* @param {string} [type]
|
|
912
|
+
* @memberof Utilities */
|
|
913
|
+
export function saveText(text: string, filename?: string, type?: string): void;
|
|
914
|
+
/** Save a canvas to disk
|
|
915
|
+
* @param {HTMLCanvasElement|OffscreenCanvas} canvas
|
|
916
|
+
* @param {string} [filename]
|
|
917
|
+
* @param {string} [type]
|
|
918
|
+
* @memberof Utilities */
|
|
919
|
+
export function saveCanvas(canvas: HTMLCanvasElement | OffscreenCanvas, filename?: string, type?: string): void;
|
|
920
|
+
/** Save a data url to disk
|
|
921
|
+
* @param {string} url
|
|
922
|
+
* @param {string} [filename]
|
|
923
|
+
* @param {number} [revokeTime] - how long before revoking the url
|
|
924
|
+
* @memberof Utilities */
|
|
925
|
+
export function saveDataURL(url: string, filename?: string, revokeTime?: number): void;
|
|
926
|
+
/** Share content using the native share dialog if available
|
|
927
|
+
* @param {string} title - title of the share
|
|
928
|
+
* @param {string} url - url to share
|
|
929
|
+
* @param {Function} [callback] - Called when share is complete
|
|
930
|
+
* @memberof Utilities */
|
|
931
|
+
export function shareURL(title: string, url: string, callback?: Function): void;
|
|
920
932
|
/** Random global functions
|
|
921
933
|
* @namespace Random */
|
|
922
934
|
/** Returns a random value between the two values passed in
|
|
@@ -953,8 +965,8 @@ declare module "littlejsengine" {
|
|
|
953
965
|
* @memberof Random */
|
|
954
966
|
export function randVec2(length?: number): Vector2;
|
|
955
967
|
/** Returns a random color between the two passed in colors, combine components if linear
|
|
956
|
-
* @param {Color} [colorA=
|
|
957
|
-
* @param {Color} [colorB=
|
|
968
|
+
* @param {Color} [colorA=WHITE]
|
|
969
|
+
* @param {Color} [colorB=BLACK]
|
|
958
970
|
* @param {boolean} [linear]
|
|
959
971
|
* @return {Color}
|
|
960
972
|
* @memberof Random */
|
|
@@ -1007,8 +1019,8 @@ declare module "littlejsengine" {
|
|
|
1007
1019
|
* @return {Vector2} */
|
|
1008
1020
|
vec2(valueA?: number, valueB?: number): Vector2;
|
|
1009
1021
|
/** Returns a random color between the two passed in colors, combine components if linear
|
|
1010
|
-
* @param {Color} [colorA=
|
|
1011
|
-
* @param {Color} [colorB=
|
|
1022
|
+
* @param {Color} [colorA=WHITE]
|
|
1023
|
+
* @param {Color} [colorB=BLACK]
|
|
1012
1024
|
* @param {boolean} [linear]
|
|
1013
1025
|
* @return {Color} */
|
|
1014
1026
|
randColor(colorA?: Color, colorB?: Color, linear?: boolean): Color;
|
|
@@ -1138,9 +1150,6 @@ declare module "littlejsengine" {
|
|
|
1138
1150
|
/** Returns the area this vector covers as a rectangle
|
|
1139
1151
|
* @return {number} */
|
|
1140
1152
|
area(): number;
|
|
1141
|
-
/** Returns true if this vector is (0,0)
|
|
1142
|
-
* @return {boolean} */
|
|
1143
|
-
isZero(): boolean;
|
|
1144
1153
|
/** Returns a new vector that is p percent between this and the vector passed in
|
|
1145
1154
|
* @param {Vector2} v - other vector
|
|
1146
1155
|
* @param {number} percent
|
|
@@ -1319,7 +1328,7 @@ declare module "littlejsengine" {
|
|
|
1319
1328
|
* let a = vec2(0, 1); // vector with coordinates (0, 1)
|
|
1320
1329
|
* a = vec2(5); // set a to (5, 5)
|
|
1321
1330
|
* b = vec2(); // set b to (0, 0)
|
|
1322
|
-
* @memberof
|
|
1331
|
+
* @memberof Math */
|
|
1323
1332
|
export function vec2(x?: number, y?: number): Vector2;
|
|
1324
1333
|
/**
|
|
1325
1334
|
* Create a color object with RGBA values, white by default
|
|
@@ -1328,7 +1337,7 @@ declare module "littlejsengine" {
|
|
|
1328
1337
|
* @param {number} [b=1] - blue
|
|
1329
1338
|
* @param {number} [a=1] - alpha
|
|
1330
1339
|
* @return {Color}
|
|
1331
|
-
* @memberof
|
|
1340
|
+
* @memberof Math
|
|
1332
1341
|
*/
|
|
1333
1342
|
export function rgb(r?: number, g?: number, b?: number, a?: number): Color;
|
|
1334
1343
|
/**
|
|
@@ -1338,98 +1347,99 @@ declare module "littlejsengine" {
|
|
|
1338
1347
|
* @param {number} [l=1] - lightness
|
|
1339
1348
|
* @param {number} [a=1] - alpha
|
|
1340
1349
|
* @return {Color}
|
|
1341
|
-
* @memberof
|
|
1350
|
+
* @memberof Math */
|
|
1342
1351
|
export function hsl(h?: number, s?: number, l?: number, a?: number): Color;
|
|
1343
1352
|
/**
|
|
1344
1353
|
* Check if object is a valid Color
|
|
1345
1354
|
* @param {any} c
|
|
1346
1355
|
* @return {boolean}
|
|
1347
|
-
* @memberof
|
|
1356
|
+
* @memberof Math */
|
|
1348
1357
|
export function isColor(c: any): boolean;
|
|
1349
1358
|
/**
|
|
1350
1359
|
* Check if object is a valid Vector2
|
|
1351
1360
|
* @param {any} v
|
|
1352
1361
|
* @return {boolean}
|
|
1353
|
-
* @memberof
|
|
1362
|
+
* @memberof Math */
|
|
1354
1363
|
export function isVector2(v: any): boolean;
|
|
1355
1364
|
/**
|
|
1356
1365
|
* Check if object is a valid number, not NaN or undefined, but it may be infinite
|
|
1357
1366
|
* @param {any} n
|
|
1358
1367
|
* @return {boolean}
|
|
1359
|
-
* @memberof
|
|
1368
|
+
* @memberof Math */
|
|
1360
1369
|
export function isNumber(n: any): boolean;
|
|
1361
1370
|
/**
|
|
1362
1371
|
* Check if object is a valid string or can be converted to one
|
|
1363
1372
|
* @param {any} s
|
|
1364
1373
|
* @return {boolean}
|
|
1365
|
-
* @memberof
|
|
1374
|
+
* @memberof Math */
|
|
1366
1375
|
export function isString(s: any): boolean;
|
|
1367
1376
|
/**
|
|
1368
1377
|
* Check if object is an array
|
|
1369
1378
|
* @param {any} a
|
|
1370
1379
|
* @return {boolean}
|
|
1371
|
-
* @memberof
|
|
1380
|
+
* @memberof Math */
|
|
1372
1381
|
export function isArray(a: any): boolean;
|
|
1373
1382
|
/** Color - White #ffffff
|
|
1374
1383
|
* @type {Color}
|
|
1375
|
-
* @memberof
|
|
1384
|
+
* @memberof Math */
|
|
1376
1385
|
export const WHITE: Color;
|
|
1377
1386
|
/** Color - Clear White #757474ff with 0 alpha
|
|
1378
1387
|
* @type {Color}
|
|
1379
|
-
* @memberof
|
|
1388
|
+
* @memberof Math */
|
|
1380
1389
|
export const CLEAR_WHITE: Color;
|
|
1381
1390
|
/** Color - Black #000000
|
|
1382
1391
|
* @type {Color}
|
|
1383
|
-
* @memberof
|
|
1392
|
+
* @memberof Math */
|
|
1384
1393
|
export const BLACK: Color;
|
|
1385
1394
|
/** Color - Clear Black #000000 with 0 alpha
|
|
1386
1395
|
* @type {Color}
|
|
1387
|
-
* @memberof
|
|
1396
|
+
* @memberof Math */
|
|
1388
1397
|
export const CLEAR_BLACK: Color;
|
|
1389
1398
|
/** Color - Gray #808080
|
|
1390
1399
|
* @type {Color}
|
|
1391
|
-
* @memberof
|
|
1400
|
+
* @memberof Math */
|
|
1392
1401
|
export const GRAY: Color;
|
|
1393
1402
|
/** Color - Red #ff0000
|
|
1394
1403
|
* @type {Color}
|
|
1395
|
-
* @memberof
|
|
1404
|
+
* @memberof Math */
|
|
1396
1405
|
export const RED: Color;
|
|
1397
1406
|
/** Color - Orange #ff8000
|
|
1398
1407
|
* @type {Color}
|
|
1399
|
-
* @memberof
|
|
1408
|
+
* @memberof Math */
|
|
1400
1409
|
export const ORANGE: Color;
|
|
1401
1410
|
/** Color - Yellow #ffff00
|
|
1402
1411
|
* @type {Color}
|
|
1403
|
-
* @memberof
|
|
1412
|
+
* @memberof Math */
|
|
1404
1413
|
export const YELLOW: Color;
|
|
1405
1414
|
/** Color - Green #00ff00
|
|
1406
1415
|
* @type {Color}
|
|
1407
|
-
* @memberof
|
|
1416
|
+
* @memberof Math */
|
|
1408
1417
|
export const GREEN: Color;
|
|
1409
1418
|
/** Color - Cyan #00ffff
|
|
1410
1419
|
* @type {Color}
|
|
1411
|
-
* @memberof
|
|
1420
|
+
* @memberof Math */
|
|
1412
1421
|
export const CYAN: Color;
|
|
1413
1422
|
/** Color - Blue #0000ff
|
|
1414
1423
|
* @type {Color}
|
|
1415
|
-
* @memberof
|
|
1424
|
+
* @memberof Math */
|
|
1416
1425
|
export const BLUE: Color;
|
|
1417
1426
|
/** Color - Purple #8000ff
|
|
1418
1427
|
* @type {Color}
|
|
1419
|
-
* @memberof
|
|
1428
|
+
* @memberof Math */
|
|
1420
1429
|
export const PURPLE: Color;
|
|
1421
1430
|
/** Color - Magenta #ff00ff
|
|
1422
1431
|
* @type {Color}
|
|
1423
|
-
* @memberof
|
|
1432
|
+
* @memberof Math */
|
|
1424
1433
|
export const MAGENTA: Color;
|
|
1425
1434
|
/**
|
|
1426
1435
|
* Create a tile info object using a grid based system
|
|
1427
1436
|
* - This can take vecs or floats for easier use and conversion
|
|
1428
1437
|
* - If an index is passed in, the tile size and index will determine the position
|
|
1429
|
-
* @param {Vector2|number} [
|
|
1438
|
+
* @param {Vector2|number} [index=0] - Index of the tile in 1d or 2d form
|
|
1430
1439
|
* @param {Vector2|number} [size] - Size of tile in pixels
|
|
1431
|
-
* @param {number} [
|
|
1440
|
+
* @param {TextureInfo|number} [texture] - Texture index or info to use
|
|
1432
1441
|
* @param {number} [padding] - How many pixels padding around tiles
|
|
1442
|
+
* @param {number} [bleed] - How many pixels smaller to draw tiles
|
|
1433
1443
|
* @return {TileInfo}
|
|
1434
1444
|
* @example
|
|
1435
1445
|
* tile(2) // a tile at index 2 using the default tile size of 16
|
|
@@ -1437,26 +1447,24 @@ declare module "littlejsengine" {
|
|
|
1437
1447
|
* tile(1, 16, 3) // a tile at index 1 of size 16 on texture 3
|
|
1438
1448
|
* tile(vec2(4,8), vec2(30,10)) // a tile at index (4,8) with a size of (30,10)
|
|
1439
1449
|
* @memberof Draw */
|
|
1440
|
-
export function tile(
|
|
1450
|
+
export function tile(index?: Vector2 | number, size?: Vector2 | number, texture?: TextureInfo | number, padding?: number, bleed?: number): TileInfo;
|
|
1441
1451
|
/**
|
|
1442
1452
|
* Tile Info - Stores info about how to draw a tile
|
|
1443
1453
|
* @memberof Draw
|
|
1444
1454
|
*/
|
|
1445
1455
|
export class TileInfo {
|
|
1446
1456
|
/** Create a tile info object
|
|
1447
|
-
* @param {Vector2} [pos=(
|
|
1457
|
+
* @param {Vector2} [pos=vec2()] - Top left corner of tile in pixels
|
|
1448
1458
|
* @param {Vector2} [size] - Size of tile in pixels
|
|
1449
|
-
* @param {
|
|
1450
|
-
* @param {number}
|
|
1451
|
-
* @param {number}
|
|
1459
|
+
* @param {TextureInfo} [textureInfo] - Texture info to use
|
|
1460
|
+
* @param {number} [padding] - How many pixels padding around tiles
|
|
1461
|
+
* @param {number} [bleed] - How many pixels smaller to draw tiles
|
|
1452
1462
|
*/
|
|
1453
|
-
constructor(pos?: Vector2, size?: Vector2,
|
|
1463
|
+
constructor(pos?: Vector2, size?: Vector2, textureInfo?: TextureInfo, padding?: number, bleed?: number);
|
|
1454
1464
|
/** @property {Vector2} - Top left corner of tile in pixels */
|
|
1455
1465
|
pos: Vector2;
|
|
1456
1466
|
/** @property {Vector2} - Size of tile in pixels */
|
|
1457
1467
|
size: Vector2;
|
|
1458
|
-
/** @property {number} - Texture index to use */
|
|
1459
|
-
textureIndex: number;
|
|
1460
1468
|
/** @property {number} - How many pixels padding around tiles */
|
|
1461
1469
|
padding: number;
|
|
1462
1470
|
/** @property {TextureInfo} - The texture info for this tile */
|
|
@@ -1475,10 +1483,16 @@ declare module "littlejsengine" {
|
|
|
1475
1483
|
frame(frame: number): TileInfo;
|
|
1476
1484
|
/**
|
|
1477
1485
|
* Set this tile to use a full image in a texture info
|
|
1478
|
-
* @param {TextureInfo} textureInfo
|
|
1486
|
+
* @param {TextureInfo} [textureInfo]
|
|
1487
|
+
* @return {TileInfo}
|
|
1488
|
+
*/
|
|
1489
|
+
setFullImage(textureInfo?: TextureInfo): TileInfo;
|
|
1490
|
+
/**
|
|
1491
|
+
* Returns a tile info for an index using this tile as refrence
|
|
1492
|
+
* @param {Vector2|number} [index=0]
|
|
1479
1493
|
* @return {TileInfo}
|
|
1480
1494
|
*/
|
|
1481
|
-
|
|
1495
|
+
tile(index?: Vector2 | number): TileInfo;
|
|
1482
1496
|
}
|
|
1483
1497
|
/**
|
|
1484
1498
|
* Tile Info - Stores info about each texture
|
|
@@ -1535,10 +1549,6 @@ declare module "littlejsengine" {
|
|
|
1535
1549
|
* @type {CanvasRenderingContext2D}
|
|
1536
1550
|
* @memberof Draw */
|
|
1537
1551
|
export let mainContext: CanvasRenderingContext2D;
|
|
1538
|
-
/** The default canvas to use for drawing, usually mainCanvas
|
|
1539
|
-
* @type {HTMLCanvasElement|OffscreenCanvas}
|
|
1540
|
-
* @memberof Draw */
|
|
1541
|
-
export let drawCanvas: HTMLCanvasElement | OffscreenCanvas;
|
|
1542
1552
|
/** The default 2d context to use for drawing, usually mainContext
|
|
1543
1553
|
* @type {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D}
|
|
1544
1554
|
* @memberof Draw */
|
|
@@ -1591,14 +1601,21 @@ declare module "littlejsengine" {
|
|
|
1591
1601
|
* @return {Vector2}
|
|
1592
1602
|
* @memberof Draw */
|
|
1593
1603
|
export function worldToScreenDelta(worldDelta: Vector2): Vector2;
|
|
1594
|
-
/**
|
|
1595
|
-
* @param {Vector2}
|
|
1596
|
-
* @param {Vector2}
|
|
1597
|
-
* @param {
|
|
1598
|
-
* @
|
|
1599
|
-
* @
|
|
1600
|
-
|
|
1601
|
-
|
|
1604
|
+
/** Convert screen space transform to world space
|
|
1605
|
+
* @param {Vector2} screenPos
|
|
1606
|
+
* @param {Vector2} screenSize
|
|
1607
|
+
* @param {number} [screenAngle]
|
|
1608
|
+
* @return {[Vector2, Vector2, number]} - [pos, size, angle]
|
|
1609
|
+
* @memberof Draw */
|
|
1610
|
+
export function screenToWorldTransform(screenPos: Vector2, screenSize: Vector2, screenAngle?: number): [Vector2, Vector2, number];
|
|
1611
|
+
/** Draw textured tile centered in world space
|
|
1612
|
+
* @param {Vector2} pos - Center of the tile in world space
|
|
1613
|
+
* @param {Vector2} [size=vec2(1)] - Size of the tile in world space
|
|
1614
|
+
* @param {TileInfo} [tileInfo] - Tile info to use, untextured if undefined
|
|
1615
|
+
* @param {Color} [color=WHITE] - Color to modulate with
|
|
1616
|
+
* @param {number} [angle] - Angle to rotate by
|
|
1617
|
+
* @param {boolean} [mirror] - Is image flipped along the Y axis?
|
|
1618
|
+
* @param {Color} [additiveColor] - Additive color to be applied if any
|
|
1602
1619
|
* @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering?
|
|
1603
1620
|
* @param {boolean} [screenSpace=false] - Are the pos and size are in screen space?
|
|
1604
1621
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
@@ -1606,8 +1623,8 @@ declare module "littlejsengine" {
|
|
|
1606
1623
|
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;
|
|
1607
1624
|
/** Draw colored rect centered on pos
|
|
1608
1625
|
* @param {Vector2} pos
|
|
1609
|
-
* @param {Vector2} [size=(1
|
|
1610
|
-
* @param {Color} [color=
|
|
1626
|
+
* @param {Vector2} [size=vec2(1)]
|
|
1627
|
+
* @param {Color} [color=WHITE]
|
|
1611
1628
|
* @param {number} [angle]
|
|
1612
1629
|
* @param {boolean} [useWebGL=glEnable]
|
|
1613
1630
|
* @param {boolean} [screenSpace]
|
|
@@ -1616,9 +1633,9 @@ declare module "littlejsengine" {
|
|
|
1616
1633
|
export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1617
1634
|
/** Draw a rect centered on pos with a gradient from top to bottom
|
|
1618
1635
|
* @param {Vector2} pos
|
|
1619
|
-
* @param {Vector2} [size=(1
|
|
1620
|
-
* @param {Color} [colorTop=
|
|
1621
|
-
* @param {Color} [colorBottom=
|
|
1636
|
+
* @param {Vector2} [size=vec2(1)]
|
|
1637
|
+
* @param {Color} [colorTop=WHITE]
|
|
1638
|
+
* @param {Color} [colorBottom=BLACK]
|
|
1622
1639
|
* @param {number} [angle]
|
|
1623
1640
|
* @param {boolean} [useWebGL=glEnable]
|
|
1624
1641
|
* @param {boolean} [screenSpace]
|
|
@@ -1628,9 +1645,9 @@ declare module "littlejsengine" {
|
|
|
1628
1645
|
/** Draw connected lines between a series of points
|
|
1629
1646
|
* @param {Array<Vector2>} points
|
|
1630
1647
|
* @param {number} [width]
|
|
1631
|
-
* @param {Color} [color=
|
|
1648
|
+
* @param {Color} [color=WHITE]
|
|
1632
1649
|
* @param {boolean} [wrap] - Should the last point connect to the first?
|
|
1633
|
-
* @param {Vector2} [pos=(
|
|
1650
|
+
* @param {Vector2} [pos=vec2()] - Offset to apply
|
|
1634
1651
|
* @param {number} [angle] - Angle to rotate by
|
|
1635
1652
|
* @param {boolean} [useWebGL=glEnable]
|
|
1636
1653
|
* @param {boolean} [screenSpace]
|
|
@@ -1641,8 +1658,8 @@ declare module "littlejsengine" {
|
|
|
1641
1658
|
* @param {Vector2} posA
|
|
1642
1659
|
* @param {Vector2} posB
|
|
1643
1660
|
* @param {number} [width]
|
|
1644
|
-
* @param {Color} [color=
|
|
1645
|
-
* @param {Vector2} [pos=(
|
|
1661
|
+
* @param {Color} [color=WHITE]
|
|
1662
|
+
* @param {Vector2} [pos=vec2()] - Offset to apply
|
|
1646
1663
|
* @param {number} [angle] - Angle to rotate by
|
|
1647
1664
|
* @param {boolean} [useWebGL=glEnable]
|
|
1648
1665
|
* @param {boolean} [screenSpace]
|
|
@@ -1651,10 +1668,10 @@ declare module "littlejsengine" {
|
|
|
1651
1668
|
export function drawLine(posA: Vector2, posB: Vector2, width?: number, color?: Color, pos?: Vector2, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1652
1669
|
/** Draw colored polygon using passed in points
|
|
1653
1670
|
* @param {Array<Vector2>} points - Array of Vector2 points
|
|
1654
|
-
* @param {Color} [color=
|
|
1671
|
+
* @param {Color} [color=WHITE]
|
|
1655
1672
|
* @param {number} [lineWidth]
|
|
1656
|
-
* @param {Color} [lineColor=
|
|
1657
|
-
* @param {Vector2} [pos=(
|
|
1673
|
+
* @param {Color} [lineColor=BLACK]
|
|
1674
|
+
* @param {Vector2} [pos=vec2()] - Offset to apply
|
|
1658
1675
|
* @param {number} [angle] - Angle to rotate by
|
|
1659
1676
|
* @param {boolean} [useWebGL=glEnable]
|
|
1660
1677
|
* @param {boolean} [screenSpace]
|
|
@@ -1663,11 +1680,11 @@ declare module "littlejsengine" {
|
|
|
1663
1680
|
export function drawPoly(points: Array<Vector2>, color?: Color, lineWidth?: number, lineColor?: Color, pos?: Vector2, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1664
1681
|
/** Draw colored ellipse using passed in point
|
|
1665
1682
|
* @param {Vector2} pos
|
|
1666
|
-
* @param {Vector2} [size=(1
|
|
1667
|
-
* @param {Color} [color=
|
|
1683
|
+
* @param {Vector2} [size=vec2(1)] - Width and height diameter
|
|
1684
|
+
* @param {Color} [color=WHITE]
|
|
1668
1685
|
* @param {number} [angle]
|
|
1669
1686
|
* @param {number} [lineWidth]
|
|
1670
|
-
* @param {Color} [lineColor=
|
|
1687
|
+
* @param {Color} [lineColor=BLACK]
|
|
1671
1688
|
* @param {boolean} [useWebGL=glEnable]
|
|
1672
1689
|
* @param {boolean} [screenSpace]
|
|
1673
1690
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
@@ -1676,9 +1693,9 @@ declare module "littlejsengine" {
|
|
|
1676
1693
|
/** Draw colored circle using passed in point
|
|
1677
1694
|
* @param {Vector2} pos
|
|
1678
1695
|
* @param {number} [size=1] - Diameter
|
|
1679
|
-
* @param {Color} [color=
|
|
1696
|
+
* @param {Color} [color=WHITE]
|
|
1680
1697
|
* @param {number} [lineWidth=0]
|
|
1681
|
-
* @param {Color} [lineColor=
|
|
1698
|
+
* @param {Color} [lineColor=BLACK]
|
|
1682
1699
|
* @param {boolean} [useWebGL=glEnable]
|
|
1683
1700
|
* @param {boolean} [screenSpace]
|
|
1684
1701
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
@@ -1704,9 +1721,9 @@ declare module "littlejsengine" {
|
|
|
1704
1721
|
* @param {string|number} text
|
|
1705
1722
|
* @param {Vector2} pos
|
|
1706
1723
|
* @param {number} [size]
|
|
1707
|
-
* @param {Color} [color=
|
|
1724
|
+
* @param {Color} [color=WHITE]
|
|
1708
1725
|
* @param {number} [lineWidth]
|
|
1709
|
-
* @param {Color} [lineColor=
|
|
1726
|
+
* @param {Color} [lineColor=BLACK]
|
|
1710
1727
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1711
1728
|
* @param {string} [font=fontDefault]
|
|
1712
1729
|
* @param {string} [fontStyle]
|
|
@@ -1719,18 +1736,18 @@ declare module "littlejsengine" {
|
|
|
1719
1736
|
* Automatically splits new lines into rows
|
|
1720
1737
|
* @param {string|number} text
|
|
1721
1738
|
* @param {Vector2} pos
|
|
1722
|
-
* @param {number}
|
|
1723
|
-
* @param {Color} [color=
|
|
1739
|
+
* @param {number} size
|
|
1740
|
+
* @param {Color} [color=WHITE]
|
|
1724
1741
|
* @param {number} [lineWidth]
|
|
1725
|
-
* @param {Color} [lineColor=
|
|
1742
|
+
* @param {Color} [lineColor=BLACK]
|
|
1726
1743
|
* @param {CanvasTextAlign} [textAlign]
|
|
1727
1744
|
* @param {string} [font=fontDefault]
|
|
1728
1745
|
* @param {string} [fontStyle]
|
|
1729
1746
|
* @param {number} [maxWidth]
|
|
1730
1747
|
* @param {number} [angle]
|
|
1731
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=
|
|
1748
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1732
1749
|
* @memberof Draw */
|
|
1733
|
-
export function drawTextScreen(text: string | number, pos: Vector2, size
|
|
1750
|
+
export function drawTextScreen(text: string | number, pos: Vector2, size: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1734
1751
|
/** Enable normal or additive blend mode
|
|
1735
1752
|
* @param {boolean} [additive]
|
|
1736
1753
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
@@ -1740,46 +1757,52 @@ declare module "littlejsengine" {
|
|
|
1740
1757
|
* This is necessary for things like screenshots and video
|
|
1741
1758
|
* @memberof Draw */
|
|
1742
1759
|
export function combineCanvases(): void;
|
|
1743
|
-
|
|
1760
|
+
/** Engine font image, 8x8 font provided by the engine
|
|
1761
|
+
* @type {FontImage}
|
|
1762
|
+
* @memberof Draw */
|
|
1763
|
+
export let engineFontImage: FontImage;
|
|
1744
1764
|
/**
|
|
1745
|
-
* Font Image Object - Draw text
|
|
1765
|
+
* Font Image Object - Draw text by using tiles in an image
|
|
1746
1766
|
* - 96 characters (from space to tilde) are stored in an image
|
|
1747
|
-
* -
|
|
1748
|
-
* -
|
|
1767
|
+
* - A 8x8 default engine font is supplied for general use
|
|
1768
|
+
* - This system is WebGL enabled for fast text rendering
|
|
1769
|
+
* - Fonts can also be colored and scaled along each axis
|
|
1770
|
+
*
|
|
1749
1771
|
* @memberof Draw
|
|
1750
1772
|
* @example
|
|
1751
1773
|
* // use built in font
|
|
1752
|
-
* const font =
|
|
1774
|
+
* const font = engineFontImage;
|
|
1753
1775
|
*
|
|
1754
1776
|
* // draw text
|
|
1755
1777
|
* font.drawTextScreen('LittleJS\nHello World!', vec2(200, 50));
|
|
1756
1778
|
*/
|
|
1757
1779
|
export class FontImage {
|
|
1758
1780
|
/** Create an image font
|
|
1759
|
-
* @param {
|
|
1760
|
-
* @param {Vector2} [tileSize=(8,8)] - Size of the font source tiles
|
|
1761
|
-
* @param {Vector2} [paddingSize=(0,1)] - How much space between characters
|
|
1781
|
+
* @param {TileInfo} tileInfo - Tile info of first characeter in font
|
|
1762
1782
|
*/
|
|
1763
|
-
constructor(
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
paddingSize: Vector2;
|
|
1783
|
+
constructor(tileInfo: TileInfo);
|
|
1784
|
+
/** @property {TileInfo} - Tile info for the font */
|
|
1785
|
+
tileInfo: TileInfo;
|
|
1767
1786
|
/** Draw text in world space using the image font
|
|
1768
|
-
* @param {string|number}
|
|
1787
|
+
* @param {string|number} text
|
|
1769
1788
|
* @param {Vector2} pos
|
|
1770
|
-
* @param {number}
|
|
1771
|
-
* @param {boolean} [center]
|
|
1772
|
-
* @param {
|
|
1789
|
+
* @param {Vector2|number} [size]
|
|
1790
|
+
* @param {boolean} [center=true]
|
|
1791
|
+
* @param {Color} [color=WHITE]
|
|
1792
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1793
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1773
1794
|
*/
|
|
1774
|
-
drawText(text: string | number, pos: Vector2,
|
|
1795
|
+
drawText(text: string | number, pos: Vector2, size?: Vector2 | number, center?: boolean, color?: Color, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1775
1796
|
/** Draw text in screen space using the image font
|
|
1776
|
-
* @param {string|number}
|
|
1797
|
+
* @param {string|number} text
|
|
1777
1798
|
* @param {Vector2} pos
|
|
1778
|
-
* @param {number}
|
|
1799
|
+
* @param {Vector2|number} size
|
|
1779
1800
|
* @param {boolean} [center]
|
|
1780
|
-
* @param {
|
|
1801
|
+
* @param {Color} [color=WHITE]
|
|
1802
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1803
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1781
1804
|
*/
|
|
1782
|
-
drawTextScreen(text: string | number, pos: Vector2,
|
|
1805
|
+
drawTextScreen(text: string | number, pos: Vector2, size: Vector2 | number, center?: boolean, color?: Color, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1783
1806
|
}
|
|
1784
1807
|
/** Returns true if fullscreen mode is active
|
|
1785
1808
|
* @return {boolean}
|
|
@@ -1816,6 +1839,10 @@ declare module "littlejsengine" {
|
|
|
1816
1839
|
* @type {WebGL2RenderingContext}
|
|
1817
1840
|
* @memberof WebGL */
|
|
1818
1841
|
export let glContext: WebGL2RenderingContext;
|
|
1842
|
+
/** Should WebGL be setup with anti-aliasing? must be set before calling engineInit
|
|
1843
|
+
* @type {boolean}
|
|
1844
|
+
* @memberof WebGL */
|
|
1845
|
+
export let glAntialias: boolean;
|
|
1819
1846
|
/** Clear the canvas and setup the viewport
|
|
1820
1847
|
* @memberof WebGL */
|
|
1821
1848
|
export function glClearCanvas(): void;
|
|
@@ -1911,21 +1938,18 @@ declare module "littlejsengine" {
|
|
|
1911
1938
|
* @param {Array<number>} pointColors - Array of 32-bit integer colors
|
|
1912
1939
|
* @memberof WebGL */
|
|
1913
1940
|
export function glDrawColoredPoints(points: Array<Vector2>, pointColors: Array<number>): void;
|
|
1914
|
-
/**
|
|
1915
|
-
* @
|
|
1941
|
+
/** Set the WebGL render target to the given texture or back to the canvas
|
|
1942
|
+
* @param {WebGLTexture} [texture] - a texture or undefined to use normal glCanvas
|
|
1943
|
+
* @param {boolean} [clear] - should the render target be cleared
|
|
1916
1944
|
* @memberof WebGL */
|
|
1917
|
-
export
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
export
|
|
1925
|
-
export let glGeometryBuffer: any;
|
|
1926
|
-
export let glPositionData: any;
|
|
1927
|
-
export let glColorData: any;
|
|
1928
|
-
export let glBatchCount: any;
|
|
1945
|
+
export function glSetRenderTarget(texture?: WebGLTexture, clear?: boolean): void;
|
|
1946
|
+
/** Clear out a rectangle area of the WebGL canvas or render target
|
|
1947
|
+
* @param {number} x
|
|
1948
|
+
* @param {number} y
|
|
1949
|
+
* @param {number} width
|
|
1950
|
+
* @param {number} height
|
|
1951
|
+
* @memberof WebGL */
|
|
1952
|
+
export function glClearRect(x: number, y: number, width: number, height: number): void;
|
|
1929
1953
|
/** Returns true if device key is down
|
|
1930
1954
|
* @param {string|number} key
|
|
1931
1955
|
* @param {number} [device]
|
|
@@ -2026,6 +2050,9 @@ declare module "littlejsengine" {
|
|
|
2026
2050
|
* @type {number}
|
|
2027
2051
|
* @memberof Input */
|
|
2028
2052
|
export let gamepadPrimary: number;
|
|
2053
|
+
/** True if a touch device has been detected
|
|
2054
|
+
* @memberof Input */
|
|
2055
|
+
export const isTouchDevice: boolean;
|
|
2029
2056
|
/** Prevents input continuing to the default browser handling
|
|
2030
2057
|
* This is useful to disable for html menus so the browser can handle input normally
|
|
2031
2058
|
* @param {boolean} preventDefault
|
|
@@ -2072,9 +2099,6 @@ declare module "littlejsengine" {
|
|
|
2072
2099
|
/** Cancel any ongoing vibration
|
|
2073
2100
|
* @memberof Input */
|
|
2074
2101
|
export function vibrateStop(): void;
|
|
2075
|
-
/** True if a touch device has been detected
|
|
2076
|
-
* @memberof Input */
|
|
2077
|
-
export const isTouchDevice: boolean;
|
|
2078
2102
|
/** Request to lock the pointer, does not work on touch devices
|
|
2079
2103
|
* @memberof Input */
|
|
2080
2104
|
export function pointerLockRequest(): void;
|
|
@@ -2381,10 +2405,10 @@ declare module "littlejsengine" {
|
|
|
2381
2405
|
*/
|
|
2382
2406
|
export class EngineObject {
|
|
2383
2407
|
/** Create an engine object and adds it to the list of objects
|
|
2384
|
-
* @param {Vector2} [pos=(
|
|
2385
|
-
* @param {Vector2} [size=(1
|
|
2386
|
-
* @param {TileInfo} [tileInfo]
|
|
2387
|
-
* @param {number} [angle]
|
|
2408
|
+
* @param {Vector2} [pos=vec2()] - World space position of the object
|
|
2409
|
+
* @param {Vector2} [size=vec2(1)] - World space size of the object
|
|
2410
|
+
* @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
|
|
2411
|
+
* @param {number} [angle] - Angle the object is rotated by
|
|
2388
2412
|
* @param {Color} [color=WHITE] - Color to apply to tile when rendered
|
|
2389
2413
|
* @param {number} [renderOrder] - Objects sorted by renderOrder before being rendered
|
|
2390
2414
|
*/
|
|
@@ -2468,14 +2492,14 @@ declare module "littlejsengine" {
|
|
|
2468
2492
|
/** Convert from world space to local space for a vector (rotation only)
|
|
2469
2493
|
* @param {Vector2} vec - world space vector */
|
|
2470
2494
|
worldToLocalVector(vec: Vector2): Vector2;
|
|
2471
|
-
/** Called to check if a tile collision should be resolved
|
|
2495
|
+
/** 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.
|
|
2472
2496
|
* @param {number} tileData - the value of the tile at the position
|
|
2473
|
-
* @param {Vector2} pos
|
|
2474
|
-
* @return {boolean}
|
|
2497
|
+
* @param {Vector2} pos - tile where the collision occurred
|
|
2498
|
+
* @return {boolean} - true if the collision should be resolved by modifying it's position and velocity */
|
|
2475
2499
|
collideWithTile(tileData: number, pos: Vector2): boolean;
|
|
2476
|
-
/** Called to check if
|
|
2500
|
+
/** Called by the engine to check if an object collision should be resolved. Return true for physics to resolve the collision or false to ignore and resolve it manually.
|
|
2477
2501
|
* @param {EngineObject} object - the object to test against
|
|
2478
|
-
* @return {boolean}
|
|
2502
|
+
* @return {boolean} - true if the collision should be resolved by modifying it's position and velocity
|
|
2479
2503
|
*/
|
|
2480
2504
|
collideWithObject(object: EngineObject): boolean;
|
|
2481
2505
|
/** Get this object's up vector
|
|
@@ -2506,7 +2530,7 @@ declare module "littlejsengine" {
|
|
|
2506
2530
|
getMirrorSign(): number;
|
|
2507
2531
|
/** Attaches a child to this with a local transform, returns child for chaining
|
|
2508
2532
|
* @param {EngineObject} child
|
|
2509
|
-
* @param {Vector2} [localPos=(
|
|
2533
|
+
* @param {Vector2} [localPos=vec2()]
|
|
2510
2534
|
* @param {number} [localAngle]
|
|
2511
2535
|
* @return {EngineObject} The child object added */
|
|
2512
2536
|
addChild(child: EngineObject, localPos?: Vector2, localAngle?: number): EngineObject;
|
|
@@ -2520,7 +2544,7 @@ declare module "littlejsengine" {
|
|
|
2520
2544
|
isOverlappingObject(object: EngineObject): boolean;
|
|
2521
2545
|
/** Check if overlapping a point or aligned bounding box
|
|
2522
2546
|
* @param {Vector2} pos - Center of box
|
|
2523
|
-
* @param {Vector2} [size=(
|
|
2547
|
+
* @param {Vector2} [size=vec2()] - Size of box, uses a point if undefined
|
|
2524
2548
|
* @return {boolean} */
|
|
2525
2549
|
isOverlapping(pos: Vector2, size?: Vector2): boolean;
|
|
2526
2550
|
/** Set how this object collides
|
|
@@ -2554,7 +2578,7 @@ declare module "littlejsengine" {
|
|
|
2554
2578
|
export function tileCollisionGetData(pos: Vector2): number;
|
|
2555
2579
|
/** Check if a tile layer collides with another object
|
|
2556
2580
|
* @param {Vector2} pos
|
|
2557
|
-
* @param {Vector2} [size=(
|
|
2581
|
+
* @param {Vector2} [size=vec2()]
|
|
2558
2582
|
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
2559
2583
|
* @param {boolean} [solidOnly] - Only check solid layers if true
|
|
2560
2584
|
* @return {TileCollisionLayer}
|
|
@@ -2593,18 +2617,18 @@ declare module "littlejsengine" {
|
|
|
2593
2617
|
*/
|
|
2594
2618
|
export class TileLayerData {
|
|
2595
2619
|
/** Create a tile layer data object, one for each tile in a TileLayer
|
|
2596
|
-
* @param {number} [tile]
|
|
2620
|
+
* @param {number} [tile] - The tile to use, untextured if undefined
|
|
2597
2621
|
* @param {number} [direction] - Integer direction of tile, in 90 degree increments
|
|
2598
|
-
* @param {boolean} [mirror]
|
|
2599
|
-
* @param {Color} [color]
|
|
2622
|
+
* @param {boolean} [mirror] - If the tile should be mirrored along the x axis
|
|
2623
|
+
* @param {Color} [color] - Color of the tile */
|
|
2600
2624
|
constructor(tile?: number, direction?: number, mirror?: boolean, color?: Color);
|
|
2601
|
-
/** @property {number}
|
|
2625
|
+
/** @property {number} - The tile to use, untextured if undefined */
|
|
2602
2626
|
tile: number;
|
|
2603
|
-
/** @property {number}
|
|
2627
|
+
/** @property {number} - Integer direction of tile, in 90 degree increments */
|
|
2604
2628
|
direction: number;
|
|
2605
2629
|
/** @property {boolean} - If the tile should be mirrored along the x axis */
|
|
2606
2630
|
mirror: boolean;
|
|
2607
|
-
/** @property {Color}
|
|
2631
|
+
/** @property {Color} - Color of the tile */
|
|
2608
2632
|
color: Color;
|
|
2609
2633
|
/** Set this tile to clear, it will not be rendered */
|
|
2610
2634
|
clear(): void;
|
|
@@ -2612,7 +2636,7 @@ declare module "littlejsengine" {
|
|
|
2612
2636
|
/**
|
|
2613
2637
|
* Canvas Layer - cached off screen rendering system
|
|
2614
2638
|
* - Contains an offscreen canvas that can be rendered to
|
|
2615
|
-
* - WebGL rendering is optional, call
|
|
2639
|
+
* - WebGL rendering is optional, call updateWebGL to enable/update
|
|
2616
2640
|
* @extends EngineObject
|
|
2617
2641
|
* @memberof TileLayers
|
|
2618
2642
|
* @example
|
|
@@ -2625,15 +2649,15 @@ declare module "littlejsengine" {
|
|
|
2625
2649
|
* @param {number} [angle] - Angle the layer is rotated by
|
|
2626
2650
|
* @param {number} [renderOrder] - Objects sorted by renderOrder
|
|
2627
2651
|
* @param {Vector2} [canvasSize] - Default size of canvas, can be changed later
|
|
2652
|
+
* @param {boolean} [useWebGL] - Should this layer use WebGL for rendering
|
|
2628
2653
|
*/
|
|
2629
|
-
constructor(position?: Vector2, size?: Vector2, angle?: number, renderOrder?: number, canvasSize?: Vector2);
|
|
2654
|
+
constructor(position?: Vector2, size?: Vector2, angle?: number, renderOrder?: number, canvasSize?: Vector2, useWebGL?: boolean);
|
|
2630
2655
|
/** @property {HTMLCanvasElement} - The canvas used by this layer */
|
|
2631
2656
|
canvas: OffscreenCanvas;
|
|
2632
2657
|
/** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
|
|
2633
2658
|
context: OffscreenCanvasRenderingContext2D;
|
|
2659
|
+
/** @property {TextureInfo} - Texture info to use for this object rendering */
|
|
2634
2660
|
textureInfo: TextureInfo;
|
|
2635
|
-
/** @property {boolean} - True if WebGL texture needs to be refreshed */
|
|
2636
|
-
refreshWebGL: boolean;
|
|
2637
2661
|
/** Draw this canvas layer centered in world space, with color applied if using WebGL
|
|
2638
2662
|
* @param {Vector2} pos - Center in world space
|
|
2639
2663
|
* @param {Vector2} [size] - Size in world space
|
|
@@ -2644,38 +2668,26 @@ declare module "littlejsengine" {
|
|
|
2644
2668
|
* @param {boolean} [screenSpace] - If true the pos and size are in screen space
|
|
2645
2669
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
2646
2670
|
* @memberof Draw */
|
|
2647
|
-
draw(pos: Vector2, size?: Vector2,
|
|
2648
|
-
/**
|
|
2649
|
-
* @callback Canvas2DDrawCallback - Function that draws to a canvas 2D context
|
|
2650
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
|
|
2651
|
-
* @memberof TileLayers
|
|
2652
|
-
*/
|
|
2653
|
-
/** Draw onto the layer canvas in world space (bypass WebGL)
|
|
2654
|
-
* @param {Vector2} pos
|
|
2655
|
-
* @param {Vector2} size
|
|
2656
|
-
* @param {number} angle
|
|
2657
|
-
* @param {boolean} mirror
|
|
2658
|
-
* @param {Canvas2DDrawCallback} drawFunction */
|
|
2659
|
-
drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: (context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D) => any): void;
|
|
2671
|
+
draw(pos: Vector2, size?: Vector2, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
2660
2672
|
/** Draw a tile onto the layer canvas in world space
|
|
2661
2673
|
* @param {Vector2} pos
|
|
2662
|
-
* @param {Vector2} [size=(1
|
|
2674
|
+
* @param {Vector2} [size=vec2(1)]
|
|
2663
2675
|
* @param {TileInfo} [tileInfo]
|
|
2664
|
-
* @param {Color} [color=
|
|
2665
|
-
* @param {number} [angle
|
|
2666
|
-
* @param {boolean} [mirror
|
|
2676
|
+
* @param {Color} [color=WHITE]
|
|
2677
|
+
* @param {number} [angle]
|
|
2678
|
+
* @param {boolean} [mirror] */
|
|
2667
2679
|
drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
2668
2680
|
/** Draw a rectangle onto the layer canvas in world space
|
|
2669
2681
|
* @param {Vector2} pos
|
|
2670
|
-
* @param {Vector2} [size=(1
|
|
2671
|
-
* @param {Color} [color=
|
|
2672
|
-
* @param {number} [angle
|
|
2682
|
+
* @param {Vector2} [size=vec2(1)]
|
|
2683
|
+
* @param {Color} [color=WHITE]
|
|
2684
|
+
* @param {number} [angle] */
|
|
2673
2685
|
drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
|
|
2674
|
-
/** Create
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
*/
|
|
2678
|
-
|
|
2686
|
+
/** Create WebGL texture if necessary and copy layer canvas to it */
|
|
2687
|
+
updateWebGL(): void;
|
|
2688
|
+
/** Check if this layer is using WebGL
|
|
2689
|
+
* @return {boolean} */
|
|
2690
|
+
hasWebGL(): boolean;
|
|
2679
2691
|
}
|
|
2680
2692
|
/**
|
|
2681
2693
|
* Tile Layer - cached rendering system for tile layers
|
|
@@ -2691,18 +2703,21 @@ declare module "littlejsengine" {
|
|
|
2691
2703
|
*/
|
|
2692
2704
|
export class TileLayer extends CanvasLayer {
|
|
2693
2705
|
/** Create a tile layer object
|
|
2694
|
-
* @param {Vector2} position
|
|
2695
|
-
* @param {Vector2} size
|
|
2696
|
-
* @param {TileInfo} [tileInfo]
|
|
2706
|
+
* @param {Vector2} position - World space position
|
|
2707
|
+
* @param {Vector2} size - World space size
|
|
2708
|
+
* @param {TileInfo} [tileInfo] - Default tile info for layer (used for size and texture)
|
|
2697
2709
|
* @param {number} [renderOrder] - Objects are sorted by renderOrder
|
|
2698
2710
|
*/
|
|
2699
2711
|
constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo, renderOrder?: number);
|
|
2712
|
+
/** @property {Array<TileLayerData>} - Default tile info for layer */
|
|
2700
2713
|
data: TileLayerData[];
|
|
2714
|
+
/** @property {boolean} - Is this layer using a webgl texture? */
|
|
2715
|
+
isUsingWebGL: boolean;
|
|
2701
2716
|
/** Draw all the tile data to an offscreen canvas
|
|
2702
|
-
* - This may be slow
|
|
2717
|
+
* - This may be slow if not using webgl but only needs to be done once */
|
|
2703
2718
|
redraw(): void;
|
|
2704
2719
|
/** Call to start the redraw process
|
|
2705
|
-
* - This can be used to manually update
|
|
2720
|
+
* - This can be used to manually update parts of the level
|
|
2706
2721
|
* @param {boolean} [clear] - Should it clear the canvas before drawing */
|
|
2707
2722
|
redrawStart(clear?: boolean): void;
|
|
2708
2723
|
/** Call to end the redraw process */
|
|
@@ -2714,23 +2729,52 @@ declare module "littlejsengine" {
|
|
|
2714
2729
|
* @param {boolean} [clear] - should the old tile be cleared out
|
|
2715
2730
|
*/
|
|
2716
2731
|
drawTileData(layerPos: Vector2, clear?: boolean): void;
|
|
2732
|
+
/** Draw the tile at a given position in the tile grid
|
|
2733
|
+
* This can be used to clear tiles when they are destroyed
|
|
2734
|
+
* For better performance use drawTileData inside a redrawStart/End block
|
|
2735
|
+
* @param {Vector2} layerPos
|
|
2736
|
+
* @param {boolean} [clear] - should the old tile be cleared
|
|
2737
|
+
*/
|
|
2738
|
+
redrawTileData(layerPos: Vector2, clear?: boolean): void;
|
|
2739
|
+
/** Draw textured tile in layer space
|
|
2740
|
+
* @param {Vector2} pos - Position in pixel coordinates
|
|
2741
|
+
* @param {Vector2} [size=vec2(1)] - Size of the tile
|
|
2742
|
+
* @param {TileInfo} [tileInfo] - Tile info to use, untextured if undefined
|
|
2743
|
+
* @param {Color} [color=WHITE] - Color to modulate with
|
|
2744
|
+
* @param {number} [angle] - Angle to rotate by
|
|
2745
|
+
* @param {boolean} [mirror] - Is image flipped along the Y axis?
|
|
2746
|
+
* @param {Color} [additiveColor] - Additive color to be applied if any */
|
|
2747
|
+
drawLayerTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color): void;
|
|
2748
|
+
/** Clear a rectangle in layer space
|
|
2749
|
+
* @param {Vector2} pos
|
|
2750
|
+
* @param {Vector2} size
|
|
2751
|
+
* @param {Color} [color=WHITE] - Color to modulate with
|
|
2752
|
+
* @param {number} [angle] - Angle to rotate by
|
|
2753
|
+
*/
|
|
2754
|
+
drawLayerRect(pos: Vector2, size: Vector2, color?: Color, angle?: number): void;
|
|
2755
|
+
/** Clear a rectangle in layer space
|
|
2756
|
+
* @param {Vector2} pos - position in pixel coordinates
|
|
2757
|
+
* @param {Vector2} size
|
|
2758
|
+
*/
|
|
2759
|
+
clearLayerRect(pos: Vector2, size: Vector2): void;
|
|
2717
2760
|
/** Set data at a given position in the array
|
|
2718
2761
|
* @param {Vector2} layerPos - Local position in array
|
|
2719
|
-
* @param {TileLayerData} data
|
|
2762
|
+
* @param {TileLayerData} data - Data to set
|
|
2720
2763
|
* @param {boolean} [redraw] - Force the tile to redraw if true */
|
|
2721
2764
|
setData(layerPos: Vector2, data: TileLayerData, redraw?: boolean): void;
|
|
2722
2765
|
/** Get data at a given position in the array
|
|
2723
2766
|
* @param {Vector2} layerPos - Local position in array
|
|
2724
2767
|
* @return {TileLayerData} */
|
|
2725
2768
|
getData(layerPos: Vector2): TileLayerData;
|
|
2726
|
-
/**
|
|
2727
|
-
|
|
2769
|
+
/** Called after this layer is redrawn, does nothing by default */
|
|
2770
|
+
onRedraw(): void;
|
|
2771
|
+
/** @type {[CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, Color]} */
|
|
2772
|
+
savedRenderSettings: [CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, Color];
|
|
2728
2773
|
}
|
|
2729
2774
|
/**
|
|
2730
2775
|
* Tile Collision Layer - a tile layer with collision
|
|
2731
2776
|
* - adds collision data and functions to TileLayer
|
|
2732
2777
|
* - there can be multiple tile collision layers
|
|
2733
|
-
* - tile collision layers should not overlap each other
|
|
2734
2778
|
* @extends TileLayer
|
|
2735
2779
|
* @memberof TileLayers
|
|
2736
2780
|
*/
|
|
@@ -2750,7 +2794,7 @@ declare module "littlejsengine" {
|
|
|
2750
2794
|
getCollisionData(gridPos: Vector2): number;
|
|
2751
2795
|
/** Check if collision with another object should occur
|
|
2752
2796
|
* @param {Vector2} pos
|
|
2753
|
-
* @param {Vector2} [size=(
|
|
2797
|
+
* @param {Vector2} [size=vec2()]
|
|
2754
2798
|
* @param {EngineObject} [object]
|
|
2755
2799
|
* @return {boolean} */
|
|
2756
2800
|
collisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
|
|
@@ -3073,16 +3117,19 @@ declare module "littlejsengine" {
|
|
|
3073
3117
|
export class PostProcessPlugin {
|
|
3074
3118
|
/** Create global post processing shader
|
|
3075
3119
|
* @param {string} shaderCode
|
|
3076
|
-
* @param {boolean} [includeMainCanvas]
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3120
|
+
* @param {boolean} [includeMainCanvas] - combine mainCanvs onto glCanvas
|
|
3121
|
+
* @param {boolean} [feedbackTexture] - use glCanvas from previous frame as the texture
|
|
3122
|
+
* @example
|
|
3123
|
+
* // create the post process plugin object
|
|
3124
|
+
* new PostProcessPlugin(shaderCode);
|
|
3125
|
+
*/
|
|
3126
|
+
constructor(shaderCode: string, includeMainCanvas?: boolean, feedbackTexture?: boolean);
|
|
3082
3127
|
/** @property {WebGLProgram} - Shader for post processing */
|
|
3083
3128
|
shader: any;
|
|
3084
3129
|
/** @property {WebGLTexture} - Texture for post processing */
|
|
3085
3130
|
texture: any;
|
|
3131
|
+
/** @property {WebGLVertexArrayObject} - Vertex array object */
|
|
3132
|
+
vao: any;
|
|
3086
3133
|
}
|
|
3087
3134
|
/**
|
|
3088
3135
|
* LittleJS ZzFXM Plugin
|
|
@@ -3325,8 +3372,8 @@ declare module "littlejsengine" {
|
|
|
3325
3372
|
* @memberof UISystem */
|
|
3326
3373
|
export class UIObject {
|
|
3327
3374
|
/** Create a UIObject
|
|
3328
|
-
* @param {Vector2} [pos=(
|
|
3329
|
-
* @param {Vector2} [size=(1
|
|
3375
|
+
* @param {Vector2} [pos=vec2()]
|
|
3376
|
+
* @param {Vector2} [size=vec2(1)]
|
|
3330
3377
|
*/
|
|
3331
3378
|
constructor(pos?: Vector2, size?: Vector2);
|
|
3332
3379
|
/** @property {Vector2} - Local position of the object */
|
|
@@ -3337,7 +3384,7 @@ declare module "littlejsengine" {
|
|
|
3337
3384
|
size: Vector2;
|
|
3338
3385
|
/** @property {Color} - Color of the object */
|
|
3339
3386
|
color: Color;
|
|
3340
|
-
/** @property {Color} - Color of the object when active, uses
|
|
3387
|
+
/** @property {Color} - Color of the object when active, uses hoverColor if undefined */
|
|
3341
3388
|
activeColor: any;
|
|
3342
3389
|
/** @property {string} - Text for this ui object */
|
|
3343
3390
|
text: any;
|