Debug

LittleJS Debug System

  • Press Esc to show debug overlay with mouse pick
  • Number keys toggle debug functions
  • +/- apply time scale
  • Debug primitive rendering
  • Save a 2d canvas as a png image

Members

(static, constant) debug :Boolean

True if debug is enabled

Type:
  • Boolean
Default Value
  • true

(static) debugKey :String

Key code used to toggle debug mode, Esc by default

Type:
  • String
Default Value
  • Escape

(static) debugOverlay :Boolean

True if the debug overlay is active, always false in release builds

Type:
  • Boolean

(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
  • true

(static) showWatermark :Boolean

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

Type:
  • Boolean
Default Value
  • true

Methods

(static) ASSERT(assert, output)

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

Parameters:
NameTypeDescription
assertBoolean
outputObject

(static) debugAABB(pA, sA, pB, sB, coloropt)

Draw a debug axis aligned bounding box in world space

Parameters:
NameTypeAttributesDescription
pAVector2

position A

sAVector2

size A

pBVector2

position B

sBVector2

size B

colorString<optional>

(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>
thicknessNumber<optional>
0.1
timeNumber<optional>

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

Draw a debug point in world space

Parameters:
NameTypeAttributesDescription
posVector2
colorString<optional>
timeNumber<optional>
angleNumber<optional>

(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, typeopt)

Save a canvas to disk

Parameters:
NameTypeAttributesDefaultDescription
canvasHTMLCanvasElement
filenameString<optional>
typeString<optional>
image/png

(static) debugSaveDataURL(dataURL, filename)

Save a data url to disk

Parameters:
NameTypeDescription
dataURLString
filenameString

(static) debugSaveText(text, filenameopt, typeopt)

Save a text file to disk

Parameters:
NameTypeAttributesDefaultDescription
textString
filenameString<optional>
typeString<optional>
text/plain

(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
keyString

(static) setShowWatermark(show)

Set if watermark with FPS should be shown

Parameters:
NameTypeDescription
showBoolean