Debug

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

Members

(static, constant) ASSERT

Asserts if the experssion is false, does not do anything in release builds

(static, constant) debug :Boolean

True if debug is enabled

Type:
  • Boolean
Default Value
  • 1

(static) debugKey :Boolean

Key code used to toggle debug mode, Esc by default

Type:
  • Boolean
Default Value
  • 27

(static, constant) debugPointSize :Number

Size to render debug points by default

Type:
  • Number
Default Value
  • 0.5

(static, constant) enableAsserts :Boolean

True if asserts are enaled

Type:
  • Boolean
Default Value
  • 1

(static) godMode :Boolean

True if god mode is enabled, handle this however you want

Type:
  • Boolean

(static) showWatermark :Boolean

True if watermark with FPS should be shown, false in release builds

Type:
  • Boolean
Default Value
  • 1

Methods

(static) debugAABB(posA, sizeA, posB, sizeB, coloropt)

Draw a debug axis aligned bounding box in world space

Parameters:
NameTypeAttributesDefaultDescription
posAVector2
sizeAVector2
posBVector2
sizeBVector2
colorString<optional>
'#fff'

(static) debugCircle(pos, radiusopt, coloropt, timeopt, fillopt)

Draw a debug circle in world space

Parameters:
NameTypeAttributesDefaultDescription
posVector2
radiusNumber<optional>
0
colorString<optional>
'#fff'
timeNumber<optional>
0
fillBoolean<optional>
false

(static) debugClear()

Clear all debug primitives in the list

(static) debugLine(posA, posB, coloropt, thicknessopt, timeopt)

Draw a debug line in world space

Parameters:
NameTypeAttributesDefaultDescription
posAVector2
posBVector2
colorString<optional>
'#fff'
thicknessNumber<optional>
.1
timeNumber<optional>
0

(static) debugPoint(pos, coloropt, timeopt, angleopt)

Draw a debug point in world space

Parameters:
NameTypeAttributesDefaultDescription
posVector2
colorString<optional>
'#fff'
timeNumber<optional>
0
angleNumber<optional>
0

(static) debugRect(pos, sizeopt, coloropt, timeopt, angleopt, fillopt)

Draw a debug rectangle in world space

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2<optional>
Vector2()
colorString<optional>
'#fff'
timeNumber<optional>
0
angleNumber<optional>
0
fillBoolean<optional>
false

(static) debugSaveCanvas(canvas, filenameopt)

Save a canvas to disk

Parameters:
NameTypeAttributesDescription
canvasHTMLCanvasElement
filenameString<optional>

(static) debugText(text, pos, sizeopt, coloropt, timeopt, angleopt, fontopt)

Draw a debug axis aligned bounding box in world space

Parameters:
NameTypeAttributesDefaultDescription
textString
posVector2
sizeNumber<optional>
1
colorString<optional>
'#fff'
timeNumber<optional>
0
angleNumber<optional>
0
fontString<optional>
'monospace'

(static) setDebugKey(key)

Set key code used to toggle debug mode, Esc by default

Parameters:
NameTypeDescription
keyNumber

(static) setGodMode(enable)

Set if god mode is enabled

Parameters:
NameTypeDescription
enableBoolean

(static) setShowWatermark(show)

Set if watermark with FPS should be shown

Parameters:
NameTypeDescription
showBoolean