littlejsengine 1.19.3 → 1.21.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/FAQ.md +841 -820
- package/README.md +29 -25
- package/dist/littlejs.d.ts +2857 -955
- package/dist/littlejs.esm.js +33428 -20995
- package/dist/littlejs.esm.min.js +4 -3
- package/dist/littlejs.js +33386 -20996
- package/dist/littlejs.min.js +2 -2
- package/dist/littlejs.release.js +27841 -20422
- package/package.json +10 -5
- package/plugins/audioEffects.js +28 -24
- package/plugins/box2d.js +2516 -2073
- package/plugins/drawUtilities.js +206 -31
- package/plugins/gltf.js +786 -0
- package/plugins/jsconfig.json +19 -0
- package/plugins/lightSystem.js +719 -332
- package/plugins/math3d.js +148 -27
- package/plugins/medalSystem.js +326 -280
- package/plugins/newgrounds.js +400 -199
- package/plugins/pathFinder.js +208 -175
- package/plugins/pluginExport.js +25 -0
- package/plugins/postProcess.js +96 -24
- package/plugins/render3d.js +2067 -1632
- package/plugins/render3dDebug.js +110 -0
- package/plugins/render3dEditor.js +1812 -0
- package/plugins/render3dExtras.js +1948 -0
- package/plugins/render3dLevel.js +189 -0
- package/plugins/render3dVoxels.js +514 -0
- package/plugins/sceneSystem.js +58 -0
- package/plugins/textureSheet.js +496 -458
- package/plugins/threejs.js +183 -163
- package/plugins/tweakables.js +411 -0
- package/plugins/tweenSystem.js +265 -145
- package/plugins/uiSystem.js +2024 -1687
- package/plugins/zzfxm.js +159 -159
- package/src/engine.js +378 -97
- package/src/engineAudio.js +231 -127
- package/src/engineBuild.mjs +292 -256
- package/src/engineDebug.js +967 -743
- package/src/engineDraw.js +391 -198
- package/src/engineEditor.js +2452 -0
- package/src/engineExport.js +18 -0
- package/src/engineInput.js +1466 -1293
- package/src/engineLogo.js +19 -0
- package/src/engineMath.js +1274 -1252
- package/src/engineObject.js +197 -82
- package/src/engineParticles.js +583 -532
- package/src/engineRelease.js +79 -45
- package/src/engineSettings.js +115 -29
- package/src/engineTileLayer.js +995 -741
- package/src/engineUtilities.js +19 -13
- package/src/engineWebGL.js +239 -82
- package/src/jsconfig.json +17 -13
- package/plugins/box2d.wasm.js +0 -630
- package/plugins/box2d.wasm.wasm +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* LittleJS 3D Debug Plugin
|
|
3
|
+
* - debugBox3D, debugSphere3D, debugLine3D and debugPoint3D, drawn on top of the 3D scene like the 2D debug functions
|
|
4
|
+
* - Debug builds only, like the 2D ones: engineRelease.js has empty stubs for these, so release builds carry none of it
|
|
5
|
+
* - Goes after the Render3D plugin, part of its Render3D namespace
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
11
|
+
|
|
12
|
+
const RENDER3D_DEBUG_WIDTH = .05; // line width of the debug primitives
|
|
13
|
+
|
|
14
|
+
let render3DDebugPrimitives = []; // each keeps the debugClear count it was made under, a debugClear since drops it
|
|
15
|
+
|
|
16
|
+
// draw the live debug primitives with depth test off so they show through walls, drop the expired ones
|
|
17
|
+
function render3DRenderDebug()
|
|
18
|
+
{
|
|
19
|
+
if (!render3DDebugPrimitives.length) return;
|
|
20
|
+
render3DDebugPrimitives = render3DDebugPrimitives.filter(p=> p.clearCount === debugClearCount);
|
|
21
|
+
if (!debugVideoCaptureIsActive()) // hidden from a video capture like the 2D ones, but they still expire
|
|
22
|
+
{
|
|
23
|
+
render3DWithState({lighting: false, depthTest: false, receiveShadow: false, additive: false, shader: undefined,
|
|
24
|
+
emissiveMap: undefined}, ()=>
|
|
25
|
+
{
|
|
26
|
+
for (const p of render3DDebugPrimitives)
|
|
27
|
+
p.draw();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
render3DDebugPrimitives = render3DDebugPrimitives.filter(p=> p.timer < 0); // a Timer compares as negative until it elapses
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// record a debug draw for a time
|
|
34
|
+
function render3DDebugPush(duration, draw)
|
|
35
|
+
{
|
|
36
|
+
ASSERT(isNumber(duration), 'duration must be a number');
|
|
37
|
+
debug && glEnable && render3D?.program &&
|
|
38
|
+
render3DDebugPrimitives.push({timer: new Timer(duration, true), draw, clearCount: debugClearCount}); // real time, like 2D
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Draw a debug wireframe box
|
|
42
|
+
* @param {Vector3} pos - Center
|
|
43
|
+
* @param {Vector3|number} [size] - Full size, a number for a cube
|
|
44
|
+
* @param {Color} [color]
|
|
45
|
+
* @param {number} [time] - How long to show it, 0 is one frame
|
|
46
|
+
* @param {Vector3} [rotation] - vec3(pitch, yaw, roll)
|
|
47
|
+
* @memberof Render3D */
|
|
48
|
+
function debugBox3D(pos, size=1, color=WHITE, time=0, rotation)
|
|
49
|
+
{
|
|
50
|
+
const matrix = buildMatrix(pos, rotation, render3DSize3(size));
|
|
51
|
+
const corner = (i)=> matrix.transformPoint(vec3(i & 1 ? .5 : -.5, i & 2 ? .5 : -.5, i & 4 ? .5 : -.5));
|
|
52
|
+
render3DDebugPush(time, ()=>
|
|
53
|
+
{
|
|
54
|
+
for (let i = 0; i < 8; ++i)
|
|
55
|
+
for (const bit of [1, 2, 4])
|
|
56
|
+
if (!(i & bit))
|
|
57
|
+
render3D.drawLine(corner(i), corner(i | bit), RENDER3D_DEBUG_WIDTH, color);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Draw a debug wireframe sphere as three rings
|
|
62
|
+
* @param {Vector3} pos - Center
|
|
63
|
+
* @param {number} [size] - Diameter
|
|
64
|
+
* @param {Color} [color]
|
|
65
|
+
* @param {number} [time] - How long to show it, 0 is one frame
|
|
66
|
+
* @memberof Render3D */
|
|
67
|
+
function debugSphere3D(pos, size=1, color=WHITE, time=0)
|
|
68
|
+
{
|
|
69
|
+
pos = pos.copy(); // where it is now, a timed one stays put when the object moves
|
|
70
|
+
const circle = render3DCircle(24), r = size / 2;
|
|
71
|
+
render3DDebugPush(time, ()=>
|
|
72
|
+
{
|
|
73
|
+
for (const ring of [(c, s)=> vec3(c, s, 0), (c, s)=> vec3(c, 0, s), (c, s)=> vec3(0, c, s)])
|
|
74
|
+
{
|
|
75
|
+
const points = [];
|
|
76
|
+
for (let i = 0; i <= 24; ++i)
|
|
77
|
+
points.push(pos.add(ring(circle[i*2], circle[i*2 + 1]).scale(r)));
|
|
78
|
+
render3D.drawRibbon(points, RENDER3D_DEBUG_WIDTH, undefined, color);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Draw a debug line
|
|
84
|
+
* @param {Vector3} posA
|
|
85
|
+
* @param {Vector3} posB
|
|
86
|
+
* @param {Color} [color]
|
|
87
|
+
* @param {number} [width]
|
|
88
|
+
* @param {number} [time] - How long to show it, 0 is one frame
|
|
89
|
+
* @memberof Render3D */
|
|
90
|
+
function debugLine3D(posA, posB, color=WHITE, width=RENDER3D_DEBUG_WIDTH, time=0)
|
|
91
|
+
{
|
|
92
|
+
posA = posA.copy(), posB = posB.copy(); // where they are now, a timed one stays put when the ends move
|
|
93
|
+
render3DDebugPush(time, ()=> render3D.drawLine(posA, posB, width, color));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Draw a debug point as a small cross of three lines
|
|
97
|
+
* @param {Vector3} pos
|
|
98
|
+
* @param {Color} [color]
|
|
99
|
+
* @param {number} [time] - How long to show it, 0 is one frame
|
|
100
|
+
* @param {number} [size] - Length of the cross
|
|
101
|
+
* @memberof Render3D */
|
|
102
|
+
function debugPoint3D(pos, color=WHITE, time=0, size=.2)
|
|
103
|
+
{
|
|
104
|
+
pos = pos.copy(); // where it is now, a timed one stays put when the object moves
|
|
105
|
+
render3DDebugPush(time, ()=>
|
|
106
|
+
{
|
|
107
|
+
for (const axis of [vec3(size / 2, 0, 0), vec3(0, size / 2, 0), vec3(0, 0, size / 2)])
|
|
108
|
+
render3D.drawLine(pos.subtract(axis), pos.add(axis), RENDER3D_DEBUG_WIDTH, color);
|
|
109
|
+
});
|
|
110
|
+
}
|