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
package/src/engineRelease.js
CHANGED
|
@@ -1,45 +1,79 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LittleJS - Release Mode
|
|
3
|
-
* - Replaces engineDebug.js in production builds
|
|
4
|
-
* - All debug functions are stubbed out as no-ops
|
|
5
|
-
* - Removes ASSERT and LOG calls to reduce file size
|
|
6
|
-
* - Disables debug overlay, watermark, and visualizations
|
|
7
|
-
* - Improves performance by eliminating debug overhead
|
|
8
|
-
* - Significantly reduces final bundle size
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
let debugWatermark = 0;
|
|
14
|
-
let debugKey = '';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
function
|
|
30
|
-
function
|
|
31
|
-
function
|
|
32
|
-
function
|
|
33
|
-
function
|
|
34
|
-
function
|
|
35
|
-
function
|
|
36
|
-
function
|
|
37
|
-
function
|
|
38
|
-
function
|
|
39
|
-
function
|
|
40
|
-
function
|
|
41
|
-
function
|
|
42
|
-
function
|
|
43
|
-
function
|
|
44
|
-
function
|
|
45
|
-
function
|
|
1
|
+
/**
|
|
2
|
+
* LittleJS - Release Mode
|
|
3
|
+
* - Replaces engineDebug.js in production builds
|
|
4
|
+
* - All debug functions are stubbed out as no-ops
|
|
5
|
+
* - Removes ASSERT and LOG calls to reduce file size
|
|
6
|
+
* - Disables debug overlay, watermark, and visualizations
|
|
7
|
+
* - Improves performance by eliminating debug overhead
|
|
8
|
+
* - Significantly reduces final bundle size
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
let debugWatermark = 0;
|
|
14
|
+
let debugKey = '';
|
|
15
|
+
let debugKeysAlways = false;
|
|
16
|
+
let debugTweakables = false;
|
|
17
|
+
let debugClearCount = 0;
|
|
18
|
+
const debug = 0;
|
|
19
|
+
const debugOverlay = 0;
|
|
20
|
+
const debugPhysics = 0;
|
|
21
|
+
const debugParticles = 0;
|
|
22
|
+
const debugRaycast = 0;
|
|
23
|
+
const debugGamepads = 0;
|
|
24
|
+
const debugSound = 0;
|
|
25
|
+
const debugPointSize = .5;
|
|
26
|
+
|
|
27
|
+
// debug commands are automatically removed from the final build
|
|
28
|
+
function ASSERT (){}
|
|
29
|
+
function LOG (){}
|
|
30
|
+
function debugInit (){}
|
|
31
|
+
function debugUpdate (){}
|
|
32
|
+
function debugRender (){}
|
|
33
|
+
function debugRenderPost (){}
|
|
34
|
+
function debugRect (){}
|
|
35
|
+
function debugPoly (){}
|
|
36
|
+
function debugCircle (){}
|
|
37
|
+
function debugPoint (){}
|
|
38
|
+
function debugLine (){}
|
|
39
|
+
function debugOverlap (){}
|
|
40
|
+
function debugText (){}
|
|
41
|
+
function debugClear (){}
|
|
42
|
+
function debugScreenshot (){}
|
|
43
|
+
function debugShowErrors(){}
|
|
44
|
+
function setDebugOverlay(){}
|
|
45
|
+
function debugVideoCaptureIsActive(){ return false; }
|
|
46
|
+
function debugVideoCaptureStart (){}
|
|
47
|
+
function debugVideoCaptureStop (){}
|
|
48
|
+
function debugProtectConstant(o){ return o; }
|
|
49
|
+
|
|
50
|
+
// the tweakables and the level editor are debug only
|
|
51
|
+
function tweak(){}
|
|
52
|
+
function tweakButton(){}
|
|
53
|
+
function tweakDivider(){}
|
|
54
|
+
function tweakEngineDefaults(){}
|
|
55
|
+
const levelEditor = {isOpen: false, open(){}, close(){}, onTile: undefined, onRestart: undefined, onPlayFrom: undefined,
|
|
56
|
+
paletteTiles: undefined, use3D: undefined};
|
|
57
|
+
function editorMapRestore(map){ return map; }
|
|
58
|
+
function editorMapLoaded(){}
|
|
59
|
+
function editorJSONFetched(){}
|
|
60
|
+
function editorPreRender(){}
|
|
61
|
+
function editorObjectMade(){}
|
|
62
|
+
|
|
63
|
+
// the input capture of the free camera and the 3D editor
|
|
64
|
+
function inputCaptureHides(){ return false; }
|
|
65
|
+
function inputCaptureMouse(){}
|
|
66
|
+
function inputLockExit(){}
|
|
67
|
+
|
|
68
|
+
// the 3D debug draws are debug only too
|
|
69
|
+
function debugBox3D(){}
|
|
70
|
+
function debugSphere3D(){}
|
|
71
|
+
function debugLine3D(){}
|
|
72
|
+
function debugPoint3D(){}
|
|
73
|
+
function render3DRenderDebug(){}
|
|
74
|
+
|
|
75
|
+
// the free camera and the 3D level editor are debug only
|
|
76
|
+
function editor3DCameraBegin(){}
|
|
77
|
+
function editor3DCameraEnd(){}
|
|
78
|
+
function editor3DLevelLoaded(){}
|
|
79
|
+
function editor3DObjectMade(){}
|
package/src/engineSettings.js
CHANGED
|
@@ -32,7 +32,7 @@ let cameraScale = 32;
|
|
|
32
32
|
|
|
33
33
|
/** Scale applied to engine time, can be used for slow motion or fast forward
|
|
34
34
|
* - 1 is normal speed, 2 is double speed, 0.5 is half speed
|
|
35
|
-
* - 0 freezes the
|
|
35
|
+
* - 0 freezes the game like a pause without setting the paused flag, gameUpdatePost and input still run
|
|
36
36
|
* - Should be >= 0; stacks multiplicatively with the debug +/- shortcut
|
|
37
37
|
* @type {number}
|
|
38
38
|
* @default
|
|
@@ -76,7 +76,6 @@ let canvasMinAspect = 0;
|
|
|
76
76
|
let canvasMaxAspect = 0;
|
|
77
77
|
|
|
78
78
|
/** Fixed size of the canvas in css pixels, if enabled canvas size never changes
|
|
79
|
-
* - you may also need to set mainCanvasSize if using screen space coords in startup
|
|
80
79
|
* - canvasPixelRatio still applies, it only scales the backing store
|
|
81
80
|
* @type {Vector2}
|
|
82
81
|
* @default Vector2()
|
|
@@ -92,7 +91,8 @@ let canvasPixelated = false;
|
|
|
92
91
|
|
|
93
92
|
/** Disables texture filtering for crisper pixel art
|
|
94
93
|
* - Leave true for pixel art so sprites stay sharp when scaled (uses NEAREST filtering)
|
|
95
|
-
* - Set false for smooth/high-resolution art to enable bilinear filtering and mipmaps
|
|
94
|
+
* - Set false for smooth/high-resolution art to enable bilinear filtering and mipmaps; those textures upload
|
|
95
|
+
* premultiplied, so filtering does not pull dark from see through texels into the edges
|
|
96
96
|
* @type {boolean}
|
|
97
97
|
* @default
|
|
98
98
|
* @memberof Settings */
|
|
@@ -116,13 +116,20 @@ let canvasPixelRatio = 1;
|
|
|
116
116
|
* @memberof Settings */
|
|
117
117
|
let fontDefault = 'arial';
|
|
118
118
|
|
|
119
|
-
/** Enable to show the LittleJS splash screen on startup
|
|
119
|
+
/** Enable to show the LittleJS splash screen on startup, must be set before engineInit
|
|
120
120
|
* @type {boolean}
|
|
121
121
|
* @default
|
|
122
122
|
* @memberof Settings */
|
|
123
123
|
let showSplashScreen = false;
|
|
124
124
|
|
|
125
|
-
/**
|
|
125
|
+
/** The loading screen, drawn after the splash while the images, gameInit and what they load are loading, once that
|
|
126
|
+
* takes more than half a second: a function given the part done, 0 to 1, or undefined for none, which leaves the
|
|
127
|
+
* screen blank; the default says Loading over a bar
|
|
128
|
+
* @type {LoadingScreenCallback|undefined}
|
|
129
|
+
* @memberof Settings */
|
|
130
|
+
let loadingScreen = drawLoadingScreen;
|
|
131
|
+
|
|
132
|
+
/** Disables all rendering, audio, and input for servers, must be set before engineInit
|
|
126
133
|
* @type {boolean}
|
|
127
134
|
* @default
|
|
128
135
|
* @memberof Settings */
|
|
@@ -135,6 +142,15 @@ let headlessMode = false;
|
|
|
135
142
|
* @memberof Settings */
|
|
136
143
|
let engineManualStep = false;
|
|
137
144
|
|
|
145
|
+
/** Run one update per display frame with timeDelta the time it covers, in place of fixed updates at frameRate
|
|
146
|
+
* - Per-frame values are not scaled: velocity, gravity, damping and particle speeds act once per update, so a
|
|
147
|
+
* game that turns this on scales its own movement by timeDelta
|
|
148
|
+
* - Values in seconds follow real time as they are: time, timers, particle emit rate and life, animation, Box2D
|
|
149
|
+
* @type {boolean}
|
|
150
|
+
* @default
|
|
151
|
+
* @memberof Settings */
|
|
152
|
+
let engineVariableStep = false;
|
|
153
|
+
|
|
138
154
|
///////////////////////////////////////////////////////////////////////////////
|
|
139
155
|
// WebGL settings
|
|
140
156
|
|
|
@@ -144,6 +160,17 @@ let engineManualStep = false;
|
|
|
144
160
|
* @memberof Settings */
|
|
145
161
|
let glEnable = true;
|
|
146
162
|
|
|
163
|
+
/** Draw in screen space by default: what the screenSpace parameter of the draw and debug functions defaults to, so a
|
|
164
|
+
* heads up display, or a 3D game that only draws 2D on the screen, can turn it on and leave the flag out
|
|
165
|
+
* - The engine says its own space when it draws, so objects, tile layers and particles stay in world space, but a
|
|
166
|
+
* game's own draws follow it, a render() override included: turn it on around the hud, or pass false there
|
|
167
|
+
* - Sizes and widths keep their defaults, which are world sized, so pass them in pixels
|
|
168
|
+
* - drawText has no screenSpace and stays in world space, drawTextScreen is the one for the screen
|
|
169
|
+
* @type {boolean}
|
|
170
|
+
* @default
|
|
171
|
+
* @memberof Settings */
|
|
172
|
+
let drawScreenSpace = false;
|
|
173
|
+
|
|
147
174
|
/** How many sided poly to use when drawing circles and ellipses with WebGL
|
|
148
175
|
* @type {number}
|
|
149
176
|
* @default
|
|
@@ -174,7 +201,7 @@ let tileDefaultBleed = 0;
|
|
|
174
201
|
///////////////////////////////////////////////////////////////////////////////
|
|
175
202
|
// Object settings
|
|
176
203
|
|
|
177
|
-
/** Enable physics solver for collisions between objects
|
|
204
|
+
/** Enable physics solver for collisions, between objects and with tiles
|
|
178
205
|
* @type {boolean}
|
|
179
206
|
* @default
|
|
180
207
|
* @memberof Settings */
|
|
@@ -186,13 +213,13 @@ let enablePhysicsSolver = true;
|
|
|
186
213
|
* @memberof Settings */
|
|
187
214
|
let objectDefaultMass = 1;
|
|
188
215
|
|
|
189
|
-
/**
|
|
216
|
+
/** Fraction of velocity objects keep each frame, 1 keeps all of it, 0 stops at once
|
|
190
217
|
* @type {number}
|
|
191
218
|
* @default
|
|
192
219
|
* @memberof Settings */
|
|
193
220
|
let objectDefaultDamping = 1;
|
|
194
221
|
|
|
195
|
-
/**
|
|
222
|
+
/** Fraction of angular velocity objects keep each frame, 1 keeps all of it, 0 stops at once
|
|
196
223
|
* @type {number}
|
|
197
224
|
* @default
|
|
198
225
|
* @memberof Settings */
|
|
@@ -204,19 +231,20 @@ let objectDefaultAngleDamping = 1;
|
|
|
204
231
|
* @memberof Settings */
|
|
205
232
|
let objectDefaultRestitution = 0;
|
|
206
233
|
|
|
207
|
-
/**
|
|
234
|
+
/** Fraction of sliding speed objects keep each frame on the ground, 1 is no friction, 0 stops at once
|
|
235
|
+
* - The more slippery of an object and its ground is used
|
|
208
236
|
* @type {number}
|
|
209
237
|
* @default
|
|
210
238
|
* @memberof Settings */
|
|
211
239
|
let objectDefaultFriction = .8;
|
|
212
240
|
|
|
213
|
-
/** Clamp max speed to avoid fast objects missing collisions
|
|
241
|
+
/** Clamp max speed to avoid fast objects missing collisions, in world units per frame on each axis
|
|
214
242
|
* @type {number}
|
|
215
243
|
* @default
|
|
216
244
|
* @memberof Settings */
|
|
217
245
|
let objectMaxSpeed = 1;
|
|
218
246
|
|
|
219
|
-
/** How much gravity to apply to objects, negative Y is down
|
|
247
|
+
/** How much gravity to apply to objects, negative Y is down, in world units per frame per frame
|
|
220
248
|
* @type {Vector2}
|
|
221
249
|
* @default
|
|
222
250
|
* @memberof Settings */
|
|
@@ -252,6 +280,7 @@ let gamepadDirectionEmulateStick = true;
|
|
|
252
280
|
let gamepadAxisFilterEnable = true;
|
|
253
281
|
|
|
254
282
|
/** If true the WASD keys are also routed to the direction keys (for better accessibility)
|
|
283
|
+
* - Turn it off for a game with two players on one keyboard, one on WASD and one on the arrows
|
|
255
284
|
* @type {boolean}
|
|
256
285
|
* @default
|
|
257
286
|
* @memberof Settings */
|
|
@@ -266,9 +295,10 @@ let touchInputEnable = true;
|
|
|
266
295
|
|
|
267
296
|
/** True if touch gamepad should appear on mobile devices
|
|
268
297
|
* - Supports left analog stick, 4 face buttons and start button (button 9)
|
|
269
|
-
* -
|
|
298
|
+
* - setTouchGamepadRightStick(true) for a right analog stick in place of the face buttons
|
|
270
299
|
* - Analog stick buttons 10 and 11 are also activated when virtual sticks are touched
|
|
271
300
|
* - Rendered as a full-viewport HTML/SVG overlay, so controls may sit outside the game canvas
|
|
301
|
+
* - It is gamepad 0 once touched; a real gamepad being used takes over and hides it until the screen is touched again
|
|
272
302
|
* @type {boolean}
|
|
273
303
|
* @default
|
|
274
304
|
* @memberof Settings */
|
|
@@ -425,9 +455,14 @@ function setCameraAngle(angle) { cameraAngle = angle; }
|
|
|
425
455
|
function setCameraScale(scale) { cameraScale = scale; }
|
|
426
456
|
|
|
427
457
|
/** Set scale applied to engine time
|
|
428
|
-
*
|
|
458
|
+
* - 0 freezes the game like a pause, gameUpdatePost and input still run so the game can set it back
|
|
459
|
+
* @param {number} scale - 0 or more
|
|
429
460
|
* @memberof Settings */
|
|
430
|
-
function setTimeScale(scale)
|
|
461
|
+
function setTimeScale(scale)
|
|
462
|
+
{
|
|
463
|
+
ASSERT(scale >= 0, 'time scale must be 0 or more');
|
|
464
|
+
timeScale = max(0, scale); // a negative scale would build a debt of time the game then waits out
|
|
465
|
+
}
|
|
431
466
|
|
|
432
467
|
/** Set if tiles should be colorized when using canvas2d
|
|
433
468
|
* This can be slower but results should look nearly identical to WebGL rendering
|
|
@@ -476,6 +511,7 @@ function setCanvasPixelated(pixelated)
|
|
|
476
511
|
|
|
477
512
|
/** Disables texture filtering for crisper pixel art
|
|
478
513
|
* - Leave true for pixel art; set false for smooth/high-resolution art
|
|
514
|
+
* - Set it before engineInit, a texture already loaded keeps the filtering it was made with
|
|
479
515
|
* @param {boolean} pixelated
|
|
480
516
|
* @memberof Settings */
|
|
481
517
|
function setTilesPixelated(pixelated) { tilesPixelated = pixelated; }
|
|
@@ -505,21 +541,62 @@ function getCanvasPixelRatio() { return canvasPixelRatio ?? (devicePixelRatio ||
|
|
|
505
541
|
* @memberof Settings */
|
|
506
542
|
function setFontDefault(font) { fontDefault = font; }
|
|
507
543
|
|
|
508
|
-
/** Set if the LittleJS splash screen should be shown on startup
|
|
544
|
+
/** Set if the LittleJS splash screen should be shown on startup, must be set before engineInit
|
|
509
545
|
* @param {boolean} show
|
|
510
546
|
* @memberof Settings */
|
|
511
547
|
function setShowSplashScreen(show) { showSplashScreen = show; }
|
|
512
548
|
|
|
513
|
-
/** Set
|
|
549
|
+
/** Set the loading screen, drawn after the splash while the game loads, once that takes more than half a second
|
|
550
|
+
* @param {LoadingScreenCallback} [callback] - Draws on mainContext given the part done, 0 to 1; undefined for none
|
|
551
|
+
* @memberof Settings */
|
|
552
|
+
function setLoadingScreen(callback) { loadingScreen = callback; }
|
|
553
|
+
|
|
554
|
+
/** Set to disable rendering, audio, and input for servers, must be set before engineInit
|
|
514
555
|
* @param {boolean} headless
|
|
515
556
|
* @memberof Settings */
|
|
516
557
|
function setHeadlessMode(headless) { headlessMode = headless; }
|
|
517
558
|
|
|
518
559
|
/** Set if the engine only advances when engineStep is called
|
|
519
|
-
*
|
|
560
|
+
* Set before engineInit for a test or a server; turned on in a running game it stops the loop, and turned off
|
|
561
|
+
* again it starts the loop from real time
|
|
520
562
|
* @param {boolean} [enable]
|
|
521
563
|
* @memberof Settings */
|
|
522
|
-
function setEngineManualStep(enable=true)
|
|
564
|
+
function setEngineManualStep(enable=true)
|
|
565
|
+
{
|
|
566
|
+
const resume = engineManualStep && !enable;
|
|
567
|
+
if (enable && !engineManualStep)
|
|
568
|
+
frameTimeBufferMS = -.5e3 / frameRate; // half a frame short, so each engineStep frame runs one update,
|
|
569
|
+
// not one more from time the last real frame left over
|
|
570
|
+
engineManualStep = enable;
|
|
571
|
+
if (resume && engineUpdateInternal)
|
|
572
|
+
{
|
|
573
|
+
// engineStep may have run the clock ahead of real time, start from now so that is not waited out
|
|
574
|
+
frameTimeLastMS = performance.now();
|
|
575
|
+
engineScheduleFrame();
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/** Set if the engine runs one update per display frame with timeDelta the time it covers
|
|
580
|
+
* Can be set before engineInit or while running; turned off it goes back to fixed updates at frameRate
|
|
581
|
+
* @param {boolean} [enable]
|
|
582
|
+
* @memberof Settings */
|
|
583
|
+
function setEngineVariableStep(enable=true)
|
|
584
|
+
{
|
|
585
|
+
if (engineVariableStep && !enable)
|
|
586
|
+
{
|
|
587
|
+
// fixed time goes on one fixed step after the last update, if one ran, and timeDelta is the fixed step again
|
|
588
|
+
timeFixedStart = frame ? time + 1 / frameRate : time;
|
|
589
|
+
frameFixedStart = frame;
|
|
590
|
+
timeDelta = 1 / frameRate;
|
|
591
|
+
frameTimeBufferMS = engineManualStep ? -.5e3 / frameRate : 0;
|
|
592
|
+
}
|
|
593
|
+
engineVariableStep = enable;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/** Set whether the draw and debug functions draw in screen space when a call leaves screenSpace out
|
|
597
|
+
* @param {boolean} screenSpace
|
|
598
|
+
* @memberof Settings */
|
|
599
|
+
function setDrawScreenSpace(screenSpace) { drawScreenSpace = screenSpace; }
|
|
523
600
|
|
|
524
601
|
/** Set if WebGL rendering is enabled
|
|
525
602
|
* @param {boolean} enable
|
|
@@ -556,7 +633,7 @@ function setTileDefaultPadding(padding) { tileDefaultPadding = padding; }
|
|
|
556
633
|
* @memberof Settings */
|
|
557
634
|
function setTileDefaultBleed(bleed) { tileDefaultBleed = bleed; }
|
|
558
635
|
|
|
559
|
-
/** Set if collisions between objects
|
|
636
|
+
/** Set if collisions are enabled, between objects and with tiles
|
|
560
637
|
* @param {boolean} enable
|
|
561
638
|
* @memberof Settings */
|
|
562
639
|
function setEnablePhysicsSolver(enable) { enablePhysicsSolver = enable; }
|
|
@@ -566,12 +643,12 @@ function setEnablePhysicsSolver(enable) { enablePhysicsSolver = enable; }
|
|
|
566
643
|
* @memberof Settings */
|
|
567
644
|
function setObjectDefaultMass(mass) { objectDefaultMass = mass; }
|
|
568
645
|
|
|
569
|
-
/** Set
|
|
646
|
+
/** Set the fraction of velocity objects keep each frame, 1 keeps all of it, 0 stops at once
|
|
570
647
|
* @param {number} damp
|
|
571
648
|
* @memberof Settings */
|
|
572
649
|
function setObjectDefaultDamping(damp) { objectDefaultDamping = damp; }
|
|
573
650
|
|
|
574
|
-
/** Set
|
|
651
|
+
/** Set the fraction of angular velocity objects keep each frame, 1 keeps all of it, 0 stops at once
|
|
575
652
|
* @param {number} damp
|
|
576
653
|
* @memberof Settings */
|
|
577
654
|
function setObjectDefaultAngleDamping(damp) { objectDefaultAngleDamping = damp; }
|
|
@@ -581,7 +658,7 @@ function setObjectDefaultAngleDamping(damp) { objectDefaultAngleDamping = damp;
|
|
|
581
658
|
* @memberof Settings */
|
|
582
659
|
function setObjectDefaultRestitution(restitution) { objectDefaultRestitution = restitution; }
|
|
583
660
|
|
|
584
|
-
/** Set
|
|
661
|
+
/** Set the fraction of sliding speed objects keep each frame on the ground, 1 is no friction, 0 stops at once
|
|
585
662
|
* @param {number} friction
|
|
586
663
|
* @memberof Settings */
|
|
587
664
|
function setObjectDefaultFriction(friction) { objectDefaultFriction = friction; }
|
|
@@ -596,7 +673,7 @@ function setObjectMaxSpeed(speed) { objectMaxSpeed = speed; }
|
|
|
596
673
|
* @memberof Settings */
|
|
597
674
|
function setGravity(newGravity) { gravity = newGravity.copy(); }
|
|
598
675
|
|
|
599
|
-
/** Set
|
|
676
|
+
/** Set the scale for the emit rate of particles, 0 disables particle emitters
|
|
600
677
|
* @param {number} scale
|
|
601
678
|
* @memberof Settings */
|
|
602
679
|
function setParticleEmitRateScale(scale) { particleEmitRateScale = scale; }
|
|
@@ -616,7 +693,7 @@ function setGamepadDirectionEmulateStick(enable) { gamepadDirectionEmulateStick
|
|
|
616
693
|
* @memberof Settings */
|
|
617
694
|
function setGamepadAxisFilterEnable(enable) { gamepadAxisFilterEnable = enable; }
|
|
618
695
|
|
|
619
|
-
/** Set if
|
|
696
|
+
/** Set if the WASD keys are also routed to the direction keys
|
|
620
697
|
* @param {boolean} enable
|
|
621
698
|
* @memberof Settings */
|
|
622
699
|
function setInputWASDEmulateDirection(enable) { inputWASDEmulateDirection = enable; }
|
|
@@ -694,7 +771,7 @@ function setTouchGamepadAnalog(analog) { touchGamepadAnalog = analog; }
|
|
|
694
771
|
* @memberof Settings */
|
|
695
772
|
function setTouchGamepadFloating(floating) { touchGamepadFloating = floating; }
|
|
696
773
|
|
|
697
|
-
/** Set size of virtual gamepad for touch devices in pixels
|
|
774
|
+
/** Set size of virtual gamepad for touch devices in viewport CSS pixels
|
|
698
775
|
* @param {number} size
|
|
699
776
|
* @memberof Settings */
|
|
700
777
|
function setTouchGamepadSize(size) { touchGamepadSize = size; }
|
|
@@ -719,7 +796,7 @@ function setTouchGamepadVibration(ms) { touchGamepadVibration = ms; }
|
|
|
719
796
|
* @memberof Settings */
|
|
720
797
|
function setVibrateEnable(enable) { vibrateEnable = enable; }
|
|
721
798
|
|
|
722
|
-
/** Set
|
|
799
|
+
/** Set if audio is enabled, false turns all sound off
|
|
723
800
|
* @param {boolean} enable
|
|
724
801
|
* @memberof Settings */
|
|
725
802
|
function setSoundEnable(enable) { soundEnable = enable; }
|
|
@@ -730,8 +807,7 @@ function setSoundEnable(enable) { soundEnable = enable; }
|
|
|
730
807
|
function setSoundVolume(volume)
|
|
731
808
|
{
|
|
732
809
|
soundVolume = volume;
|
|
733
|
-
|
|
734
|
-
audioMasterGain.gain.value = volume; // update gain immediately
|
|
810
|
+
audioUpdateVolume(); // update gain immediately, sound off or not
|
|
735
811
|
}
|
|
736
812
|
|
|
737
813
|
/** Set default range where sound no longer plays
|
|
@@ -757,4 +833,14 @@ function setDebugWatermark(show) { debugWatermark = show; }
|
|
|
757
833
|
/** Set key code used to toggle debug mode, Esc by default
|
|
758
834
|
* @param {string} key
|
|
759
835
|
* @memberof Debug */
|
|
760
|
-
function setDebugKey(key) { debugKey = key; }
|
|
836
|
+
function setDebugKey(key) { debugKey = key; }
|
|
837
|
+
|
|
838
|
+
/** Set if the debug keys work while the overlay is closed, the number keys and the +/- time keys
|
|
839
|
+
* @param {boolean} [enable]
|
|
840
|
+
* @memberof Debug */
|
|
841
|
+
function setDebugKeysAlways(enable=true) { debugKeysAlways = enable; }
|
|
842
|
+
|
|
843
|
+
/** Set if the tweakables panel is shown, as 9 does while the debug overlay is open
|
|
844
|
+
* @param {boolean} [show]
|
|
845
|
+
* @memberof Debug */
|
|
846
|
+
function setDebugTweakables(show=true) { debugTweakables = show; }
|