Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Be able to toggle debug mode on or off #27

Open
jacknkandy opened this issue Feb 11, 2022 · 2 comments
Open

Feature request: Be able to toggle debug mode on or off #27

jacknkandy opened this issue Feb 11, 2022 · 2 comments

Comments

@jacknkandy
Copy link

Hey thanks for this library, its awesome and makes it easy to visualize the collision bodies. I was trying to enable a way to for this mode to be turned on and off but noticed that I would have to find the objects in the scene and manually remove them. When you stop calling update() the objects remain in their old position.

I whipped something up will submit a PR if you are willing to consider it. Cheers.

@marcofugaro
Copy link
Member

You can already do this with:

const cannonDebugger = new CannonDebugger(scene, world, {
  onInit(body, mesh) {
    gui.onChange((value) => {
      if (value) {
        mesh.visible = true
      } else {
        mesh.visible = false
      }
    })
  }
})

But maybe it would be easier to do it like this?

const cannonDebugger = new CannonDebugger(scene, world)

gui.onChange((value) => {
  if (value) {
    cannonDebugger.enable()
  } else {
    cannonDebugger.disable()
  }
})

@jacknkandy
Copy link
Author

Hi @marcofugaro thanks for your reply. I didn't realize the onInit function fired for each individual mesh. But I went ahead and created a PR #28 with this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants