A helper class to debug draw Ammo physics world state in PlayCanvas.
Live Demo: https://playcanv.as/p/OEVC2poo/
Project: https://playcanvas.com/project/744419/overview/ammo-debug-draw
Create new renderer and enabling it:
const renderer = new AmmoDebugDrawer();
renderer.enable();
Change drawing mode:
// Following modes supported:
// 0: hide
// 1: wireframe mode
// 2: bounding boxes
// 3: wireframe + AABB
// 8: contact points
const mode = 2;
renderer.setMode(mode);
Update the drawer state (should be in your update
method to run every frame):
renderer.update();
Optionally, you can target specific layer for drawing. Internally defaults to layer Debug Draw
and falls back to UI
, if not found.
const layer = app.scene.layers.getLayerByName('My Layer');
const renderer = new AmmoDebugDrawer(layer);
Disable drawer:
renderer.disable();