Skip to content

Debug

angular-three-cannon/debug provides a debug experience for Cannon.js physics engine using cannon-es-debugger. This allows us to visualize how Cannon sees the 3D scene graph.

Installation

Terminal window
npm install cannon-es-debugger
# yarn add cannon-es-debugger
# pnpm add cannon-es-debugger

Import NgtcDebug from angular-three-cannon/debug

import { NgtcDebug } from 'angular-three-cannon/debug';

Attach [debug] to the ngtc-physics component

@Component({
standalone: true,
imports: [NgtcDebug, NgtcPhysics],
template: `
<ngtc-physics debug>
<!-- objects that are subject to physics -->
</ngtc-physics>
`
})
export class SceneGraph {}

Passing options to NgtcDebug

We can pass options to NgtcDebug by passing in an object to the debug input

@Component({
standalone: true,
imports: [NgtcDebug, NgtcPhysics],
template: `
<ngtc-physics
[debug]="{ enabled: true, color: 'red', scale: 1.1 }"
>
<!-- objects that are subject to physics -->
</ngtc-physics>
`
})
export class SceneGraph {}

Example