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
1
npm install cannon-es-debugger
2
# yarn add cannon-es-debugger
3
# pnpm add cannon-es-debugger

Import NgtcDebug from angular-three-cannon/debug

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

Attach [debug] to the ngtc-physics component

1
@Component({
2
standalone: true,
3
imports: [NgtcDebug, NgtcPhysics],
4
template: `
5
<ngtc-physics debug>
6
<!-- objects that are subject to physics -->
7
</ngtc-physics>
8
`
9
})
10
export class SceneGraph {}

Passing options to NgtcDebug

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

1
@Component({
2
standalone: true,
3
imports: [NgtcDebug, NgtcPhysics],
4
template: `
5
<ngtc-physics
6
[debug]="{ enabled: true, color: 'red', scale: 1.1 }"
7
>
8
<!-- objects that are subject to physics -->
9
</ngtc-physics>
10
`
11
})
12
export class SceneGraph {}

Example