LittleJS Debug System
- Press ~ to show debug overlay with mouse pick
- Number keys toggle debug functions
- +/- apply time scale
- Debug primitive rendering
- Save a 2d canvas as an image
- Source
Members
(static, constant) ASSERT
Asserts if the experssion is false, does not do anything in release builds
- Source
(static, constant) debug :Boolean
True if debug is enabled
- Boolean
- Default Value
- 1
- Source
(static) debugKey :Boolean
Key code used to toggle debug mode, Esc by default
- Boolean
- Default Value
- 27
- Source
(static, constant) debugPointSize :Number
Size to render debug points by default
- Number
- Default Value
- 0.5
- Source
(static, constant) enableAsserts :Boolean
True if asserts are enaled
- Boolean
- Default Value
- 1
- Source
(static) godMode :Boolean
True if god mode is enabled, handle this however you want
- Boolean
- Source
(static) showWatermark :Boolean
True if watermark with FPS should be shown, false in release builds
- Boolean
- Default Value
- 1
- Source
Methods
(static) debugAABB(posA, sizeA, posB, sizeB, coloropt)
Draw a debug axis aligned bounding box in world space
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
posA | Vector2 | |||
sizeA | Vector2 | |||
posB | Vector2 | |||
sizeB | Vector2 | |||
color | String | <optional> | '#fff' |
- Source
(static) debugCircle(pos, radiusopt, coloropt, timeopt, fillopt)
Draw a debug circle in world space
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos | Vector2 | |||
radius | Number | <optional> | 0 | |
color | String | <optional> | '#fff' | |
time | Number | <optional> | 0 | |
fill | Boolean | <optional> | false |
- Source
(static) debugClear()
Clear all debug primitives in the list
- Source
(static) debugLine(posA, posB, coloropt, thicknessopt, timeopt)
Draw a debug line in world space
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
posA | Vector2 | |||
posB | Vector2 | |||
color | String | <optional> | '#fff' | |
thickness | Number | <optional> | .1 | |
time | Number | <optional> | 0 |
- Source
(static) debugPoint(pos, coloropt, timeopt, angleopt)
Draw a debug point in world space
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos | Vector2 | |||
color | String | <optional> | '#fff' | |
time | Number | <optional> | 0 | |
angle | Number | <optional> | 0 |
- Source
(static) debugRect(pos, sizeopt, coloropt, timeopt, angleopt, fillopt)
Draw a debug rectangle in world space
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos | Vector2 | |||
size | Vector2 | <optional> | Vector2() | |
color | String | <optional> | '#fff' | |
time | Number | <optional> | 0 | |
angle | Number | <optional> | 0 | |
fill | Boolean | <optional> | false |
- Source
(static) debugSaveCanvas(canvas, filenameopt)
Save a canvas to disk
Name | Type | Attributes | Description |
---|---|---|---|
canvas | HTMLCanvasElement | ||
filename | String | <optional> |
- Source
(static) debugText(text, pos, sizeopt, coloropt, timeopt, angleopt, fontopt)
Draw a debug axis aligned bounding box in world space
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
text | String | |||
pos | Vector2 | |||
size | Number | <optional> | 1 | |
color | String | <optional> | '#fff' | |
time | Number | <optional> | 0 | |
angle | Number | <optional> | 0 | |
font | String | <optional> | 'monospace' |
- Source
(static) setDebugKey(key)
Set key code used to toggle debug mode, Esc by default
Name | Type | Description |
---|---|---|
key | Number |
- Source
(static) setGodMode(enable)
Set if god mode is enabled
Name | Type | Description |
---|---|---|
enable | Boolean |
- Source
(static) setShowWatermark(show)
Set if watermark with FPS should be shown
Name | Type | Description |
---|---|---|
show | Boolean |
- Source