littlejsengine 1.24.3 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/EDITOR.md +2 -2
- package/FAQ.md +6 -0
- package/REFERENCE.md +84 -40
- package/dist/littlejs.d.ts +474 -219
- package/dist/littlejs.esm.js +2318 -1743
- package/dist/littlejs.esm.min.js +38 -24
- package/dist/littlejs.js +2316 -1743
- package/dist/littlejs.min.js +37 -23
- package/dist/littlejs.release.js +2313 -1786
- package/package.json +1 -1
- package/plugins/box2d.js +32 -23
- package/plugins/drawUtilities.js +374 -380
- package/plugins/gltf.js +325 -54
- package/plugins/lightSystem.js +2 -2
- package/plugins/math3d.js +1013 -1014
- package/plugins/newgrounds.js +1 -4
- package/plugins/particleEffects.js +3 -4
- package/plugins/pathFinder.js +52 -28
- package/plugins/pluginExport.js +2 -0
- package/plugins/postProcess.js +196 -65
- package/plugins/render3d.js +8 -6
- package/plugins/render3dEditor.js +3 -3
- package/plugins/render3dExtras.js +19 -2
- package/plugins/render3dLevel.js +15 -4
- package/plugins/tweenSystem.js +43 -38
- package/plugins/uiSystem.js +25 -20
- package/src/engine.js +9 -5
- package/src/engineAudio.js +10 -6
- package/src/engineDebug.js +3 -2
- package/src/engineDraw.js +9 -9
- package/src/engineEditor.js +75 -23
- package/src/engineInput.js +4 -7
- package/src/engineMath.js +3 -6
- package/src/engineObject.js +8 -9
- package/src/engineParticles.js +8 -7
- package/src/engineRelease.js +17 -10
- package/src/engineTileLayer.js +33 -14
- package/src/engineUtilities.js +15 -2
- package/src/engineWebGL.js +31 -9
package/package.json
CHANGED
package/plugins/box2d.js
CHANGED
|
@@ -303,7 +303,8 @@ class Box2dObject extends EngineObject
|
|
|
303
303
|
* @param {number} [density]
|
|
304
304
|
* @param {number} [friction]
|
|
305
305
|
* @param {number} [restitution]
|
|
306
|
-
* @param {boolean} [isSensor]
|
|
306
|
+
* @param {boolean} [isSensor]
|
|
307
|
+
* @return {Object} - The fixture made, Box2D's own */
|
|
307
308
|
addShape(shape, density=1, friction=.2, restitution=0, isSensor=false)
|
|
308
309
|
{
|
|
309
310
|
ASSERT(isNumber(density), 'density must be a number');
|
|
@@ -332,7 +333,8 @@ class Box2dObject extends EngineObject
|
|
|
332
333
|
* @param {number} [density]
|
|
333
334
|
* @param {number} [friction]
|
|
334
335
|
* @param {number} [restitution]
|
|
335
|
-
* @param {boolean} [isSensor]
|
|
336
|
+
* @param {boolean} [isSensor]
|
|
337
|
+
* @return {Object|undefined} - The fixture made, Box2D's own, undefined for a shape too small to make */
|
|
336
338
|
addBox(size=vec2(1), offset=vec2(), angle=0, density, friction, restitution, isSensor)
|
|
337
339
|
{
|
|
338
340
|
ASSERT(isVector2(size), 'size must be a Vector2');
|
|
@@ -357,7 +359,8 @@ class Box2dObject extends EngineObject
|
|
|
357
359
|
* @param {number} [density]
|
|
358
360
|
* @param {number} [friction]
|
|
359
361
|
* @param {number} [restitution]
|
|
360
|
-
* @param {boolean} [isSensor]
|
|
362
|
+
* @param {boolean} [isSensor]
|
|
363
|
+
* @return {Object|undefined} - The fixture made, Box2D's own, undefined for a shape too small to make */
|
|
361
364
|
addPoly(points, density, friction, restitution, isSensor)
|
|
362
365
|
{
|
|
363
366
|
ASSERT(isArray(points), 'points must be an array');
|
|
@@ -404,7 +407,8 @@ class Box2dObject extends EngineObject
|
|
|
404
407
|
* @param {number} [density]
|
|
405
408
|
* @param {number} [friction]
|
|
406
409
|
* @param {number} [restitution]
|
|
407
|
-
* @param {boolean} [isSensor]
|
|
410
|
+
* @param {boolean} [isSensor]
|
|
411
|
+
* @return {Object|undefined} - The fixture made, Box2D's own, undefined for a shape too small to make */
|
|
408
412
|
addRegularPoly(diameter=1, sides=8, density, friction, restitution, isSensor)
|
|
409
413
|
{
|
|
410
414
|
ASSERT(isNumber(diameter) && diameter>0, 'diameter must be a positive number');
|
|
@@ -424,7 +428,8 @@ class Box2dObject extends EngineObject
|
|
|
424
428
|
* @param {number} [density]
|
|
425
429
|
* @param {number} [friction]
|
|
426
430
|
* @param {number} [restitution]
|
|
427
|
-
* @param {boolean} [isSensor]
|
|
431
|
+
* @param {boolean} [isSensor]
|
|
432
|
+
* @return {Object|undefined} - The fixture made, Box2D's own, undefined for a shape too small to make */
|
|
428
433
|
addRandomPoly(diameter=1, density, friction, restitution, isSensor)
|
|
429
434
|
{
|
|
430
435
|
ASSERT(isNumber(diameter) && diameter>0, 'diameter must be a positive number');
|
|
@@ -443,7 +448,8 @@ class Box2dObject extends EngineObject
|
|
|
443
448
|
* @param {number} [density]
|
|
444
449
|
* @param {number} [friction]
|
|
445
450
|
* @param {number} [restitution]
|
|
446
|
-
* @param {boolean} [isSensor]
|
|
451
|
+
* @param {boolean} [isSensor]
|
|
452
|
+
* @return {Object} - The fixture made, Box2D's own */
|
|
447
453
|
addCircle(diameter=1, offset=vec2(), density, friction, restitution, isSensor)
|
|
448
454
|
{
|
|
449
455
|
ASSERT(isNumber(diameter) && diameter>0, 'diameter must be a positive number');
|
|
@@ -463,7 +469,8 @@ class Box2dObject extends EngineObject
|
|
|
463
469
|
* @param {number} [density]
|
|
464
470
|
* @param {number} [friction]
|
|
465
471
|
* @param {number} [restitution]
|
|
466
|
-
* @param {boolean} [isSensor]
|
|
472
|
+
* @param {boolean} [isSensor]
|
|
473
|
+
* @return {Object} - The fixture made, Box2D's own */
|
|
467
474
|
addEdge(point1, point2, density, friction, restitution, isSensor)
|
|
468
475
|
{
|
|
469
476
|
ASSERT(isVector2(point1), 'point1 must be a Vector2');
|
|
@@ -481,7 +488,8 @@ class Box2dObject extends EngineObject
|
|
|
481
488
|
* @param {number} [density]
|
|
482
489
|
* @param {number} [friction]
|
|
483
490
|
* @param {number} [restitution]
|
|
484
|
-
* @param {boolean} [isSensor]
|
|
491
|
+
* @param {boolean} [isSensor]
|
|
492
|
+
* @return {Array<Object>} - The fixtures made, Box2D's own */
|
|
485
493
|
addEdgeList(points, density, friction, restitution, isSensor)
|
|
486
494
|
{
|
|
487
495
|
ASSERT(isArray(points), 'points must be an array');
|
|
@@ -514,7 +522,8 @@ class Box2dObject extends EngineObject
|
|
|
514
522
|
* @param {number} [density]
|
|
515
523
|
* @param {number} [friction]
|
|
516
524
|
* @param {number} [restitution]
|
|
517
|
-
* @param {boolean} [isSensor]
|
|
525
|
+
* @param {boolean} [isSensor]
|
|
526
|
+
* @return {Array<Object>} - The fixtures made, Box2D's own */
|
|
518
527
|
addEdgeLoop(points, density, friction, restitution, isSensor)
|
|
519
528
|
{
|
|
520
529
|
ASSERT(isArray(points), 'points must be an array');
|
|
@@ -1432,6 +1441,8 @@ class Box2dRevoluteJoint extends Box2dJoint
|
|
|
1432
1441
|
* Box2D Pin Joint
|
|
1433
1442
|
* - Pins two objects together at a point, where they still turn freely, like a nail through two boards
|
|
1434
1443
|
* - A revolute joint at that point, so it holds exactly and its limits and motor work too
|
|
1444
|
+
* - new Box2dPinJoint(objectA, objectB, pos, collide): the point defaults to objectA's position, where a revolute
|
|
1445
|
+
* joint's anchor defaults to objectB's
|
|
1435
1446
|
* @extends Box2dRevoluteJoint
|
|
1436
1447
|
* @memberof Box2D
|
|
1437
1448
|
*/
|
|
@@ -1787,14 +1798,6 @@ class Box2dWeldJoint extends Box2dJoint
|
|
|
1787
1798
|
/** Get the damping ratio
|
|
1788
1799
|
* @return {number} */
|
|
1789
1800
|
getDampingRatio() { return this.box2dJoint.GetDampingRatio(); }
|
|
1790
|
-
|
|
1791
|
-
/** @deprecated since 1.20, use setDampingRatio
|
|
1792
|
-
* @param {number} ratio */
|
|
1793
|
-
setSpringDampingRatio(ratio) { this.setDampingRatio(ratio); }
|
|
1794
|
-
|
|
1795
|
-
/** @deprecated since 1.20, use getDampingRatio
|
|
1796
|
-
* @return {number} */
|
|
1797
|
-
getSpringDampingRatio() { return this.getDampingRatio(); }
|
|
1798
1801
|
}
|
|
1799
1802
|
|
|
1800
1803
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -2322,7 +2325,8 @@ class Box2dPlugin
|
|
|
2322
2325
|
// helper functions
|
|
2323
2326
|
|
|
2324
2327
|
/** converts a box2d vec2 to a Vector2
|
|
2325
|
-
* @param {Object} v
|
|
2328
|
+
* @param {Object} v
|
|
2329
|
+
* @return {Vector2} */
|
|
2326
2330
|
vec2From(v)
|
|
2327
2331
|
{
|
|
2328
2332
|
ASSERT(v instanceof box2d.instance.b2Vec2);
|
|
@@ -2330,7 +2334,8 @@ class Box2dPlugin
|
|
|
2330
2334
|
}
|
|
2331
2335
|
|
|
2332
2336
|
/** converts a box2d vec2 pointer to a Vector2
|
|
2333
|
-
* @param {Object} vp
|
|
2337
|
+
* @param {Object} vp
|
|
2338
|
+
* @return {Vector2} */
|
|
2334
2339
|
vec2FromPointer(vp)
|
|
2335
2340
|
{
|
|
2336
2341
|
const v = box2d.instance.wrapPointer(vp, box2d.instance.b2Vec2);
|
|
@@ -2339,7 +2344,8 @@ class Box2dPlugin
|
|
|
2339
2344
|
|
|
2340
2345
|
/** converts a Vector2 to a new box2d vec2, which stays until destroyed with box2d.instance.destroy;
|
|
2341
2346
|
* the plugin itself passes Box2D reused ones, since Box2D copies every vector it is given
|
|
2342
|
-
* @param {Vector2} v
|
|
2347
|
+
* @param {Vector2} v
|
|
2348
|
+
* @return {Object} - A Box2D vector, its b2Vec2 */
|
|
2343
2349
|
vec2dTo(v)
|
|
2344
2350
|
{
|
|
2345
2351
|
ASSERT(isVector2(v));
|
|
@@ -2347,11 +2353,13 @@ class Box2dPlugin
|
|
|
2347
2353
|
}
|
|
2348
2354
|
|
|
2349
2355
|
/** checks if a box2d object is null
|
|
2350
|
-
* @param {Object} o
|
|
2356
|
+
* @param {Object} o
|
|
2357
|
+
* @return {boolean} */
|
|
2351
2358
|
isNull(o) { return !box2d.instance.getPointer(o); }
|
|
2352
2359
|
|
|
2353
2360
|
/** casts a box2d object to a shape type
|
|
2354
|
-
* @param {Object} o
|
|
2361
|
+
* @param {Object} o
|
|
2362
|
+
* @return {Object} - The shape as its own Box2D type */
|
|
2355
2363
|
castShapeObject(o)
|
|
2356
2364
|
{
|
|
2357
2365
|
switch (o.GetType())
|
|
@@ -2370,7 +2378,8 @@ class Box2dPlugin
|
|
|
2370
2378
|
}
|
|
2371
2379
|
|
|
2372
2380
|
/** casts a box2d object to a joint type
|
|
2373
|
-
* @param {Object} o
|
|
2381
|
+
* @param {Object} o
|
|
2382
|
+
* @return {Object} - The joint as its own Box2D type */
|
|
2374
2383
|
castJointObject(o)
|
|
2375
2384
|
{
|
|
2376
2385
|
switch (o.GetType())
|