Display debug geometry in the editor

Hey guys,
We’ve rolled our own system for entity picking (basically like this - https://playcanvas.com/project/436809/overview/entity-picking-without-physics) to avoid including ammo. However, we’d like to still be able to see the extents of the bounding box (we’re just using cubes at the moment) in the editor like you can on the collision component.

Is there any way to do this?

Hi @Tchom,

Sadly no there isn’t any automatic way of doing that in the engine. The editor uses a custom system of its own.

You can build it relatively easily yourself, a class that acts on a list of entities:

  • Finds the combined bounding box
  • Creates a box model and scales it to fit that bounding box.
1 Like

I thought that might be the case. Would your suggestion actually work in the editor? Or would that only happen at runtime?

It will work on runtime only for the moment.

There is some work done, from what I know, to expose editor scripting in Playcanvas at some point. For now you will have to inject your code using a browser extension or the console, take a look at this post:

Thanks mate! That thread is an interesting read!

1 Like

Do you know which hook is used to select entity instances?

The following will get you a list of the selected items in the hierarchy:

// Playcanvas editor code
const items = editor.call("selector:items");

And the following will update the selection:

// Playcanvas editor code
editor.call("selector:set", "entity", [entityToSelect]);

Just keep in mind that an editor item is not the same as a pc.Entity, it’s an editor observer that wraps a pc.Entity to provide the environment for editing it.

1 Like

Amazing, thank you!

1 Like