littlejsengine 1.18.15 â 1.18.17
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/README.md +4 -4
- package/dist/littlejs.d.ts +198 -17
- package/dist/littlejs.esm.js +1180 -257
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +1160 -257
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +1134 -241
- package/package.json +1 -1
- package/plugins/box2d.js +9 -13
- package/plugins/drawUtilities.js +63 -0
- package/plugins/lightSystem.js +330 -0
- package/plugins/medalSystem.js +36 -5
- package/plugins/pluginExport.js +8 -0
- package/src/engine.js +1 -1
- package/src/engineAudio.js +21 -3
- package/src/engineBuild.mjs +1 -0
- package/src/engineDebug.js +27 -16
- package/src/engineDraw.js +9 -6
- package/src/engineExport.js +12 -0
- package/src/engineInput.js +528 -189
- package/src/engineObject.js +5 -2
- package/src/engineParticles.js +19 -15
- package/src/engineRelease.js +1 -0
- package/src/engineSettings.js +111 -10
- package/src/engineTileLayer.js +5 -0
package/README.md
CHANGED
|
@@ -19,13 +19,13 @@ LittleJS is a fast, lightweight, and fully open source HTML5 game engine designe
|
|
|
19
19
|
Its small footprint is packed with a comprehensive feature set including rendering, physics, particles, sound, and input handling.
|
|
20
20
|
The code is very clean and well documented with many examples to get you started quickly.
|
|
21
21
|
|
|
22
|
-
### đ Join the LittleJS Game Jam
|
|
22
|
+
### đ [Join the LittleJS Game Jam](https://itch.io/jam/littlejs-jam)
|
|
23
23
|
|
|
24
|
-
*The Third Annual LittleJS Game Jam will take place From Oct 2 to Nov 2! Unleash your creativity and develop amazing games using the LittleJS game engine
|
|
24
|
+
*The Third Annual LittleJS Game Jam will take place From Oct 2 to Nov 2! Unleash your creativity and develop amazing games using the LittleJS game engine.*
|
|
25
25
|
|
|
26
26
|
<div align='center' markdown='1'>
|
|
27
27
|
|
|
28
|
-
## [Demos](https://killedbyapixel.github.io/LittleJS/examples) | [
|
|
28
|
+
## [Demos](https://killedbyapixel.github.io/LittleJS/examples) | [Arcade](https://killedbyapixel.github.io/LittleJSArcade) | [Docs](https://killedbyapixel.github.io/LittleJS/docs) | [FAQ](https://github.com/KilledByAPixel/LittleJS/blob/main/FAQ.md) | [Trailer](https://youtu.be/chuBzGjv7Ms) | [Discord](https://discord.gg/zb7hcGkyZe)
|
|
29
29
|
|
|
30
30
|
</div>
|
|
31
31
|
|
|
@@ -120,6 +120,7 @@ engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost);
|
|
|
120
120
|
LittleJS comes with several demos both for learning and using as starter projects to create new games.
|
|
121
121
|
|
|
122
122
|
- [Example Browser](https://killedbyapixel.github.io/LittleJS/examples/) - Live example browser with all examples and editable source
|
|
123
|
+
- [LittleJS Arcade](https://killedbyapixel.github.io/LittleJSArcade/) - Over 50 example games you can use as starter projects
|
|
123
124
|
- [Short Examples](https://github.com/KilledByAPixel/LittleJS/tree/main/examples/shorts) - 60+ single-file demos showing off individual engine features
|
|
124
125
|
- [Breakout](https://killedbyapixel.github.io/LittleJS/examples/breakout/) - Block breaking game with post-processing effects
|
|
125
126
|
- [Puzzle Game](https://killedbyapixel.github.io/LittleJS/examples/puzzle/) - Match 3 puzzle game with HD rendering and high score tracking
|
|
@@ -157,7 +158,6 @@ Here are a few of the many amazing games created with LittleJS...
|
|
|
157
158
|
- [Tetrimals](https://nixn.itch.io/tetrimals) - A puzzle game mixing Tetris with animals. by [nixn](https://nixn.itch.io/)
|
|
158
159
|
- [Bug&Bee](https://itch.io/jam/littlejs-game-jam-2025/results) - Low fi shoot em up with co-op gameplay. LittleJS Jam 1st place! by [eoinmcg](https://eoinmcg.itch.io/)
|
|
159
160
|
- [Little Platformer](https://psemo.itch.io/little-platformer) - Platformer with many mechanics. LittleJS Jam 2st place! by [PSEMO](https://psemo.itch.io/), [Solita666](https://itch.io/profile/solita666), [GabrielRG](https://gabrielrg.itch.io/), [Nate](https://natesassoon.itch.io/)
|
|
160
|
-
- [Rogue Pong](https://itch.io/jam/littlejs-game-jam-2025/rate/4004165) - Roguelike crossed with classic pong gameplay. LittleJS Jam 3rd place! by [webdevbrian](https://webdevbrian.itch.io/)
|
|
161
161
|
- [Alien Escape Pinball](https://focaccai.itch.io/alien-pinball) - Pinball game with physics and aliens. by [Focaccai](https://www.focaccai.com/)
|
|
162
162
|
- [LittleJS Jam 2024 Results](https://itch.io/jam/littlejs-jam-2024/results) - All the games from the first LittleJS Game Jam.
|
|
163
163
|
- [LittleJS Jam 2025 Results](https://itch.io/jam/littlejs-game-jam-2025/results) - All the games from the second LittleJS Game Jam.
|
package/dist/littlejs.d.ts
CHANGED
|
@@ -510,31 +510,69 @@ declare module "littlejsengine" {
|
|
|
510
510
|
* - Supports left analog stick, 4 face buttons and start button (button 9)
|
|
511
511
|
* - setTouchGamepadButtonCount(1) to use face buttons as right analog stick
|
|
512
512
|
* - Analog stick buttons 10 and 11 are also activated when virtual sticks are touched
|
|
513
|
-
|
|
513
|
+
* - Rendered as a full-viewport HTML/SVG overlay, so controls may sit outside the game canvas
|
|
514
514
|
* @type {boolean}
|
|
515
515
|
* @default
|
|
516
516
|
* @memberof Settings */
|
|
517
517
|
export let touchGamepadEnable: boolean;
|
|
518
|
-
/** True if
|
|
519
|
-
* -
|
|
520
|
-
*
|
|
518
|
+
/** True if touches outside the gamepad controls should still drive mouse/touch input
|
|
519
|
+
* - When false (the default), enabling the touch gamepad suppresses touch-to-mouse input entirely
|
|
520
|
+
* - Set true to also pass touches outside the controls through to the game as mouse/touch input
|
|
521
|
+
* - Touches on the gamepad controls never drive the mouse regardless of this setting
|
|
522
|
+
* @type {boolean}
|
|
523
|
+
* @default
|
|
524
|
+
* @memberof Settings */
|
|
525
|
+
export let touchGamepadPassthrough: boolean;
|
|
526
|
+
/** Size of center button if touch gamepad should have start button in the center
|
|
527
|
+
* - Prevents activating when pressed near virtual stick or face buttons
|
|
521
528
|
* - When the game is paused, any touch will press the button
|
|
522
|
-
* -
|
|
529
|
+
* - Measured in viewport CSS pixels
|
|
523
530
|
* @type {number}
|
|
524
531
|
* @default
|
|
525
532
|
* @memberof Settings */
|
|
526
533
|
export let touchGamepadCenterButtonSize: number;
|
|
527
|
-
/** Number of buttons on touch gamepad (0-4),
|
|
534
|
+
/** Number of buttons on the right side of the touch gamepad (0-4), using gamepad buttons 0-3
|
|
535
|
+
* - A count of 1 is a single large button (the size of a stick)
|
|
536
|
+
* - Ignored when touchGamepadRightStick is set (the right side is a stick instead)
|
|
528
537
|
* @type {number}
|
|
529
538
|
* @default
|
|
530
539
|
* @memberof Settings */
|
|
531
540
|
export let touchGamepadButtonCount: number;
|
|
541
|
+
/** True if the touch gamepad should have a left analog stick (or dpad)
|
|
542
|
+
* - When false, the left side is face buttons (touchGamepadLeftButtonCount) or nothing
|
|
543
|
+
* @type {boolean}
|
|
544
|
+
* @default
|
|
545
|
+
* @memberof Settings */
|
|
546
|
+
export let touchGamepadLeftStick: boolean;
|
|
547
|
+
/** Number of buttons on the left side of the touch gamepad (0-4), using gamepad buttons 4-7
|
|
548
|
+
* - Only used when touchGamepadLeftStick is false (otherwise the left side is a stick)
|
|
549
|
+
* - A count of 1 is a single large button (the size of a stick)
|
|
550
|
+
* @type {number}
|
|
551
|
+
* @default
|
|
552
|
+
* @memberof Settings */
|
|
553
|
+
export let touchGamepadLeftButtonCount: number;
|
|
554
|
+
/** True if the touch gamepad right side should be an analog stick (or dpad) instead of face buttons
|
|
555
|
+
* - When set, touchGamepadButtonCount is ignored and the right side is a stick
|
|
556
|
+
* - Uses an analog stick when touchGamepadAnalog is true, otherwise an 8 way dpad
|
|
557
|
+
* @type {boolean}
|
|
558
|
+
* @default
|
|
559
|
+
* @memberof Settings */
|
|
560
|
+
export let touchGamepadRightStick: boolean;
|
|
532
561
|
/** True if touch gamepad should be analog stick or false to use if 8 way dpad
|
|
533
562
|
* @type {boolean}
|
|
534
563
|
* @default
|
|
535
564
|
* @memberof Settings */
|
|
536
565
|
export let touchGamepadAnalog: boolean;
|
|
537
|
-
/**
|
|
566
|
+
/** True if touch gamepad directional controls should float to where you press
|
|
567
|
+
* - Only affects analog sticks and dpads, not face buttons
|
|
568
|
+
* - Directional controls re-anchor to where you press within the bottom ~60% of their screen half; the top ~40% passes through to the game
|
|
569
|
+
* - The right side floats only when it acts as the right analog stick (touchGamepadRightStick is set)
|
|
570
|
+
* - A center button (touchGamepadCenterButtonSize) still works since it ignores touches near the sticks
|
|
571
|
+
* @type {boolean}
|
|
572
|
+
* @default
|
|
573
|
+
* @memberof Settings */
|
|
574
|
+
export let touchGamepadFloating: boolean;
|
|
575
|
+
/** Size of virtual gamepad for touch devices in viewport CSS pixels
|
|
538
576
|
* @type {number}
|
|
539
577
|
* @default
|
|
540
578
|
* @memberof Settings */
|
|
@@ -549,6 +587,12 @@ declare module "littlejsengine" {
|
|
|
549
587
|
* @default
|
|
550
588
|
* @memberof Settings */
|
|
551
589
|
export let touchGamepadDisplayTime: number;
|
|
590
|
+
/** Duration in ms to vibrate when a touch gamepad face button or start button is pressed
|
|
591
|
+
* - Set to 0 to disable, also requires vibrateEnable and hardware support (ignored on iOS)
|
|
592
|
+
* @type {number}
|
|
593
|
+
* @default
|
|
594
|
+
* @memberof Settings */
|
|
595
|
+
export let touchGamepadVibration: number;
|
|
552
596
|
/** Allow vibration hardware if it exists
|
|
553
597
|
* @type {boolean}
|
|
554
598
|
* @default
|
|
@@ -718,20 +762,41 @@ declare module "littlejsengine" {
|
|
|
718
762
|
* @param {boolean} enable
|
|
719
763
|
* @memberof Settings */
|
|
720
764
|
export function setTouchGamepadEnable(enable: boolean): void;
|
|
765
|
+
/** Set if touches outside the gamepad controls should still drive mouse/touch input
|
|
766
|
+
* @param {boolean} passthrough
|
|
767
|
+
* @memberof Settings */
|
|
768
|
+
export function setTouchGamepadPassthrough(passthrough: boolean): void;
|
|
721
769
|
/** Set if touch gamepad should have start button in the center
|
|
722
770
|
* - Set size to enable the center button
|
|
723
771
|
* - When the game is paused, any touch will press the button
|
|
724
772
|
* @param {number} size
|
|
725
773
|
* @memberof Settings */
|
|
726
774
|
export function setTouchGamepadCenterButtonSize(size: number): void;
|
|
727
|
-
/** Set number of buttons on touch gamepad (0-4
|
|
775
|
+
/** Set number of buttons on the right side of the touch gamepad (0-4, gamepad buttons 0-3)
|
|
728
776
|
* @param {number} count
|
|
729
777
|
* @memberof Settings */
|
|
730
778
|
export function setTouchGamepadButtonCount(count: number): void;
|
|
779
|
+
/** Set if the touch gamepad should have a left analog stick (or dpad)
|
|
780
|
+
* @param {boolean} enable
|
|
781
|
+
* @memberof Settings */
|
|
782
|
+
export function setTouchGamepadLeftStick(enable: boolean): void;
|
|
783
|
+
/** Set number of buttons on the left side of the touch gamepad (0-4, gamepad buttons 4-7)
|
|
784
|
+
* - Only used when touchGamepadLeftStick is false
|
|
785
|
+
* @param {number} count
|
|
786
|
+
* @memberof Settings */
|
|
787
|
+
export function setTouchGamepadLeftButtonCount(count: number): void;
|
|
788
|
+
/** Set if the touch gamepad right side is an analog stick (or dpad) instead of face buttons
|
|
789
|
+
* @param {boolean} rightStick
|
|
790
|
+
* @memberof Settings */
|
|
791
|
+
export function setTouchGamepadRightStick(rightStick: boolean): void;
|
|
731
792
|
/** Set if touch gamepad should be analog stick or 8 way dpad
|
|
732
793
|
* @param {boolean} analog
|
|
733
794
|
* @memberof Settings */
|
|
734
795
|
export function setTouchGamepadAnalog(analog: boolean): void;
|
|
796
|
+
/** Set if touch gamepad directional controls should float to where you press
|
|
797
|
+
* @param {boolean} floating
|
|
798
|
+
* @memberof Settings */
|
|
799
|
+
export function setTouchGamepadFloating(floating: boolean): void;
|
|
735
800
|
/** Set size of virtual gamepad for touch devices in pixels
|
|
736
801
|
* @param {number} size
|
|
737
802
|
* @memberof Settings */
|
|
@@ -744,6 +809,10 @@ declare module "littlejsengine" {
|
|
|
744
809
|
* @param {number} time
|
|
745
810
|
* @memberof Settings */
|
|
746
811
|
export function setTouchGamepadDisplayTime(time: number): void;
|
|
812
|
+
/** Set duration in ms to vibrate when a touch gamepad face or start button is pressed (0 disables)
|
|
813
|
+
* @param {number} ms
|
|
814
|
+
* @memberof Settings */
|
|
815
|
+
export function setTouchGamepadVibration(ms: number): void;
|
|
747
816
|
/** Set to allow vibration hardware if it exists
|
|
748
817
|
* @param {boolean} enable
|
|
749
818
|
* @memberof Settings */
|
|
@@ -1889,7 +1958,10 @@ declare module "littlejsengine" {
|
|
|
1889
1958
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
|
|
1890
1959
|
* @memberof Draw
|
|
1891
1960
|
*/
|
|
1892
|
-
/** Draw directly to a 2d canvas context in world space
|
|
1961
|
+
/** Draw directly to a 2d canvas context in world space.
|
|
1962
|
+
* The Y axis is flipped so world-Y-up coordinates render right-side up
|
|
1963
|
+
* (matches the WebGL path). Callers whose drawing depends on Y direction
|
|
1964
|
+
* (e.g. linear gradients) should flip their own Y endpoints accordingly.
|
|
1893
1965
|
* @param {Vector2} pos
|
|
1894
1966
|
* @param {Vector2} size
|
|
1895
1967
|
* @param {number} angle
|
|
@@ -2424,7 +2496,7 @@ declare module "littlejsengine" {
|
|
|
2424
2496
|
* @param {number} [randomnessScale] - How much to scale pitch randomness
|
|
2425
2497
|
* @param {boolean} [loop] - Should the sound loop?
|
|
2426
2498
|
* @param {boolean} [paused] - Should the sound start paused
|
|
2427
|
-
* @return {SoundInstance} - The
|
|
2499
|
+
* @return {SoundInstance} - The sound instance, or undefined if sound is disabled, not loaded, or running in headless mode
|
|
2428
2500
|
*/
|
|
2429
2501
|
play(pos?: Vector2, volume?: number, pitch?: number, randomnessScale?: number, loop?: boolean, paused?: boolean): SoundInstance;
|
|
2430
2502
|
/** Play a music track that loops by default
|
|
@@ -2712,6 +2784,8 @@ declare module "littlejsengine" {
|
|
|
2712
2784
|
update(): void;
|
|
2713
2785
|
/** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
|
|
2714
2786
|
render(): void;
|
|
2787
|
+
/** Optional hook called during the light system plugin's lightmap pass to draw this object's lightmap contribution. Does nothing by default. */
|
|
2788
|
+
renderLight(): void;
|
|
2715
2789
|
/** Destroy this object, destroy its children, detach its parent, and mark it for removal
|
|
2716
2790
|
* @param {boolean} [immediate] - should attached effects be allowed to die off? */
|
|
2717
2791
|
destroy(immediate?: boolean): void;
|
|
@@ -3121,10 +3195,10 @@ declare module "littlejsengine" {
|
|
|
3121
3195
|
* @param {number} [particleTime] - How long particles live
|
|
3122
3196
|
* @param {number} [sizeStart] - How big are particles at start
|
|
3123
3197
|
* @param {number} [sizeEnd] - How big are particles at end
|
|
3124
|
-
* @param {number} [speed] - How fast are particles when spawned
|
|
3125
|
-
* @param {number} [angleSpeed] - How fast are particles rotating
|
|
3126
|
-
* @param {number} [damping] - How much to dampen particle speed
|
|
3127
|
-
* @param {number} [angleDamping] - How much to dampen particle angular speed
|
|
3198
|
+
* @param {number} [speed] - How fast are particles when spawned, in world units per frame (at 60fps, so multiply units/sec by 1/60)
|
|
3199
|
+
* @param {number} [angleSpeed] - How fast are particles rotating, in radians per frame (at 60fps)
|
|
3200
|
+
* @param {number} [damping] - How much to dampen particle speed, per-frame velocity multiplier (1 = no damping, .9 = lose 10% speed each frame)
|
|
3201
|
+
* @param {number} [angleDamping] - How much to dampen particle angular speed, per-frame multiplier (1 = no damping)
|
|
3128
3202
|
* @param {number} [gravityScale] - How much gravity effect particles
|
|
3129
3203
|
* @param {number} [particleConeAngle] - Cone for start particle angle
|
|
3130
3204
|
* @param {number} [fadeRate] - Fraction of life spent fading: half at fade-in (start), half at fade-out (end). e.g. .2 = 10% fade-in, 80% full opacity, 10% fade-out
|
|
@@ -3162,9 +3236,9 @@ declare module "littlejsengine" {
|
|
|
3162
3236
|
sizeStart: number;
|
|
3163
3237
|
/** @property {number} - How big are particles at end */
|
|
3164
3238
|
sizeEnd: number;
|
|
3165
|
-
/** @property {number} -
|
|
3239
|
+
/** @property {number} - Particle speed when spawned, in world units per frame (at 60fps) */
|
|
3166
3240
|
speed: number;
|
|
3167
|
-
/** @property {number} -
|
|
3241
|
+
/** @property {number} - Particle angular speed when spawned, in radians per frame (at 60fps) */
|
|
3168
3242
|
angleSpeed: number;
|
|
3169
3243
|
/** @property {number} - Cone for start particle angle */
|
|
3170
3244
|
particleConeAngle: number;
|
|
@@ -3298,6 +3372,9 @@ declare module "littlejsengine" {
|
|
|
3298
3372
|
* @param {MedalCallbackFunction} callback
|
|
3299
3373
|
* @memberof Medals */
|
|
3300
3374
|
export function medalsForEach(callback: MedalCallbackFunction): void;
|
|
3375
|
+
/** Reset all medals to locked and persist the cleared catalog
|
|
3376
|
+
* @memberof Medals */
|
|
3377
|
+
export function medalsReset(): void;
|
|
3301
3378
|
/** Set how long to show medals for in seconds
|
|
3302
3379
|
* @param {number} time
|
|
3303
3380
|
* @memberof Settings */
|
|
@@ -3359,7 +3436,6 @@ declare module "littlejsengine" {
|
|
|
3359
3436
|
* @param {number} size - Screen space size
|
|
3360
3437
|
*/
|
|
3361
3438
|
renderIcon(pos: Vector2, size: number): void;
|
|
3362
|
-
storageKey(): string;
|
|
3363
3439
|
}
|
|
3364
3440
|
/**
|
|
3365
3441
|
* LittleJS Newgrounds Plugin
|
|
@@ -3466,6 +3542,85 @@ declare module "littlejsengine" {
|
|
|
3466
3542
|
/** @property {WebGLVertexArrayObject} - Vertex array object */
|
|
3467
3543
|
vao: any;
|
|
3468
3544
|
}
|
|
3545
|
+
/**
|
|
3546
|
+
* LittleJS Light System Plugin
|
|
3547
|
+
* - Adds 2D dynamic lighting to the scene
|
|
3548
|
+
* - Lights are first-class EngineObjects (the Light class)
|
|
3549
|
+
* - Each Light draws a soft falloff blob of its color into a shared lightmap
|
|
3550
|
+
* - Lights accumulate ADDITIVELY in the lightmap (red + blue = magenta)
|
|
3551
|
+
* - The lightmap is then MULTIPLIED with the scene during composite, so unlit
|
|
3552
|
+
* areas go to the ambient color and lit areas show the scene tinted by the
|
|
3553
|
+
* accumulated light color
|
|
3554
|
+
* - Draw the world at full brightness â the lightmap does the darkening
|
|
3555
|
+
* - Any EngineObject may override renderLight() to additively contribute to the
|
|
3556
|
+
* lightmap (e.g. emissive lava tiles, weapon flashes, glowing crystals)
|
|
3557
|
+
* - Must be constructed BEFORE PostProcessPlugin so post-process sees lit pixels
|
|
3558
|
+
* @namespace LightSystem
|
|
3559
|
+
*/
|
|
3560
|
+
/** Global Light System plugin object
|
|
3561
|
+
* @type {LightSystemPlugin}
|
|
3562
|
+
* @memberof LightSystem */
|
|
3563
|
+
export let lightSystem: LightSystemPlugin;
|
|
3564
|
+
/**
|
|
3565
|
+
* LightSystemPlugin
|
|
3566
|
+
* - Owns the offscreen lightmap texture, falloff/composite shaders, and the
|
|
3567
|
+
* per-frame render pass that multiplies the lightmap onto the WebGL scene
|
|
3568
|
+
* - The composite is MULTIPLICATIVE: unlit areas get the ambient color, lit
|
|
3569
|
+
* areas show the scene tinted by the accumulated light color. So you should
|
|
3570
|
+
* draw your world at full brightness â the lightmap handles the darkening.
|
|
3571
|
+
* @memberof LightSystem
|
|
3572
|
+
*/
|
|
3573
|
+
export class LightSystemPlugin {
|
|
3574
|
+
/** Create the global light system plugin.
|
|
3575
|
+
* @param {Vector2} [textureSize] - Size of the lightmap texture (defaults to mainCanvasSize)
|
|
3576
|
+
* @param {Color} [ambientColor] - Color applied to unlit areas of the scene (defaults to BLACK = pitch dark). Set a small RGB like rgb(0.1,0.1,0.15) for a faint "moonlight" baseline so unlit areas aren't fully black.
|
|
3577
|
+
* @example
|
|
3578
|
+
* // simplest usage
|
|
3579
|
+
* new LightSystemPlugin();
|
|
3580
|
+
*/
|
|
3581
|
+
constructor(textureSize?: Vector2, ambientColor?: Color);
|
|
3582
|
+
/** @property {boolean} - When false, the render pass is skipped entirely */
|
|
3583
|
+
enabled: boolean;
|
|
3584
|
+
/** @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. */
|
|
3585
|
+
ambientColor: Color;
|
|
3586
|
+
/** @property {Vector2} - Size of the lightmap texture (set at construction; falls back to mainCanvasSize at init time) */
|
|
3587
|
+
textureSize: Vector2;
|
|
3588
|
+
/** @property {WebGLTexture} - The lightmap texture */
|
|
3589
|
+
texture: any;
|
|
3590
|
+
/** @property {WebGLProgram} - Shader for drawing per-Light falloff blobs into the lightmap */
|
|
3591
|
+
lightShader: any;
|
|
3592
|
+
/** @property {WebGLProgram} - Shader for compositing the lightmap over the main scene */
|
|
3593
|
+
compositeShader: any;
|
|
3594
|
+
/** @property {WebGLVertexArrayObject} - Vertex array object for the light shader */
|
|
3595
|
+
lightVAO: any;
|
|
3596
|
+
/** @property {WebGLVertexArrayObject} - Vertex array object for the composite shader */
|
|
3597
|
+
compositeVAO: any;
|
|
3598
|
+
/** Draw a single Light's falloff blob into the currently bound lightmap.
|
|
3599
|
+
* Called by Light.renderLight() during the plugin's render pass.
|
|
3600
|
+
* @param {Light} light */
|
|
3601
|
+
drawLight(light: Light): void;
|
|
3602
|
+
}
|
|
3603
|
+
/**
|
|
3604
|
+
* A Light is an EngineObject that contributes a soft additive blob of color
|
|
3605
|
+
* to the LightSystem plugin's lightmap.
|
|
3606
|
+
* @extends EngineObject
|
|
3607
|
+
* @memberof LightSystem
|
|
3608
|
+
* @example
|
|
3609
|
+
* new Light(vec2(5, 5), 4, rgb(1, 0.5, 0)); // orange light, full soft blob
|
|
3610
|
+
* new Light(vec2(0, 0), 8, rgb(1, 1, 1), 2); // white core with 2-unit soft halo
|
|
3611
|
+
*/
|
|
3612
|
+
export class Light extends EngineObject {
|
|
3613
|
+
/** Create a light object and add it to the engine object list
|
|
3614
|
+
* @param {Vector2} pos - World space position
|
|
3615
|
+
* @param {number} radius - Total extent of the light in world units
|
|
3616
|
+
* @param {Color} [color] - Color of the light; alpha modulates intensity
|
|
3617
|
+
* @param {number} [fadeRange] - Width of the soft edge in world units (defaults to radius) */
|
|
3618
|
+
constructor(pos: Vector2, radius: number, color?: Color, fadeRange?: number);
|
|
3619
|
+
/** @property {number} - Total extent of the light in world units */
|
|
3620
|
+
radius: number;
|
|
3621
|
+
/** @property {number} - Width of the soft edge in world units */
|
|
3622
|
+
fadeRange: number;
|
|
3623
|
+
}
|
|
3469
3624
|
/**
|
|
3470
3625
|
* LittleJS ZzFXM Plugin
|
|
3471
3626
|
* @namespace ZzFXM
|
|
@@ -5114,6 +5269,32 @@ declare module "littlejsengine" {
|
|
|
5114
5269
|
* @param {number} [angle] - Angle to rotate by
|
|
5115
5270
|
* @memberof DrawUtilities */
|
|
5116
5271
|
export function drawThreeSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, borderSize?: number, extraSpace?: number, angle?: number): void;
|
|
5272
|
+
/** Draw a crescent / moon-phase shape built from a polygon
|
|
5273
|
+
* Routes through drawPoly, so it supports WebGL, screen space, color, and outlines
|
|
5274
|
+
* @param {Vector2} pos - Center position
|
|
5275
|
+
* @param {number} [size] - Diameter
|
|
5276
|
+
* @param {number} [percent] - Moon phase over a full cycle (0=new, .25=first quarter, .5=full, .75=last quarter), wraps
|
|
5277
|
+
* @param {Color} [color] - Fill color
|
|
5278
|
+
* @param {number} [angle] - Angle to rotate by
|
|
5279
|
+
* @param {boolean} [invert] - Flip which side is illuminated
|
|
5280
|
+
* @param {number} [lineWidth] - Outline width, 0 for no outline
|
|
5281
|
+
* @param {Color} [lineColor] - Outline color
|
|
5282
|
+
* @param {boolean} [useWebGL=glEnable] - Use WebGL for rendering
|
|
5283
|
+
* @param {boolean} [screenSpace] - Use screen space coordinates
|
|
5284
|
+
* @param {CanvasRenderingContext2D} [context] - Canvas context to use
|
|
5285
|
+
* @memberof DrawUtilities */
|
|
5286
|
+
export function drawCrescent(pos: Vector2, size?: number, percent?: number, color?: Color, angle?: number, invert?: boolean, lineWidth?: number, lineColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
5287
|
+
/** Get the list of points that make up a crescent / moon-phase shape
|
|
5288
|
+
* Returns world-space points with pos and angle baked in, ready for drawPoly or other use
|
|
5289
|
+
* @param {Vector2} pos - Center position
|
|
5290
|
+
* @param {number} [size] - Diameter
|
|
5291
|
+
* @param {number} [percent] - Moon phase over a full cycle (0=new, .25=first quarter, .5=full, .75=last quarter), wraps
|
|
5292
|
+
* @param {number} [angle] - Angle to rotate by
|
|
5293
|
+
* @param {boolean} [invert] - Flip which side is illuminated
|
|
5294
|
+
* @param {number} [sides=glCircleSides] - Number of sides for a full circle (halved per arc)
|
|
5295
|
+
* @return {Array<Vector2>} - List of points making up the crescent
|
|
5296
|
+
* @memberof DrawUtilities */
|
|
5297
|
+
export function getCrescentPoints(pos: Vector2, size?: number, percent?: number, angle?: number, invert?: boolean, sides?: number): Array<Vector2>;
|
|
5117
5298
|
/** A numeric tween: drives a callback with a value interpolated between
|
|
5118
5299
|
* `start` and `end` over `duration` seconds. Pauses with the game by default.
|
|
5119
5300
|
* @memberof TweenSystem
|