Repository navigation
Add minimum viable debug mode - #856
Conversation
| detail: { | ||
| renderer, | ||
| THREE: { | ||
| ShaderMaterial, |
There was a problem hiding this comment.
We should probably include Scene here, I think. Any others, @elalish ? My hope is to limit it to things that we already import for rendering, and are necessary to do essential debug rendering outside of the element.
There was a problem hiding this comment.
Agreed on Scene. Renderer already includes TextureUtils, so that's good. We might want to reevaluate what is private, for instance TextureUtils has a private member PMREMGenerator that it might be nice to access. Likewise perhaps with Renderer's private member arRenderer.
There was a problem hiding this comment.
I added Scene, and I added a read-only accessor for the PMREMGenerator in TextureUtils. Let's add arRenderer later if and when we need it.
There was a problem hiding this comment.
When you said Scene, I was actually thinking [$scene], since that owns things like the model and the shadow. The renderer has the set of all scenes, but it might be hard to tell which one relates to this element.
There was a problem hiding this comment.
Yah, currently there is no offered mechanism to distinguish the scenes. Originally, I added a special event to advertise each scene as it is registered with the Renderer, but I don't have a use case for it yet so I took it out.
I'm happy to add it back in if you think we should land it now.
There was a problem hiding this comment.
I don't have a strong opinion, but I like the idea of being able to access all of the textures. Many of those are in the Model's materials and the shadow lives in the ModelScene, so having hooks to that seems important.
There was a problem hiding this comment.
Added advertisement of scenes as they are registered/unregistered. Details in the PR description.
| this.renderer.setPixelRatio(resolveDpr()); | ||
|
|
||
| if (options == null || options.debug === false) { | ||
| this.debugger = new Debugger(this); |
There was a problem hiding this comment.
Is this condition backwards? Seems like you make a debugger if debug is false.
There was a problem hiding this comment.
Ah, yes, good catch. Thanks!
| Mesh, | ||
| PlaneBufferGeometry, | ||
| OrthographicCamera, | ||
| WebGLRenderTarget |
There was a problem hiding this comment.
What's the rationale behind these particular things to include?
There was a problem hiding this comment.
These are intended to be the minimum viable set of things needed to do debug rendering outside of the element. The actual set we should use may be different, have any suggestions?
There was a problem hiding this comment.
So basically what's needed to display a texture? Yeah that sounds good. I'm not sure what other kinds of debugging we'd do here.
There was a problem hiding this comment.
We can add more as we need it
| detail: { | ||
| renderer, | ||
| THREE: { | ||
| ShaderMaterial, |
There was a problem hiding this comment.
When you said Scene, I was actually thinking [$scene], since that owns things like the model and the shadow. The renderer has the set of all scenes, but it might be hard to tell which one relates to this element.
| if (options != null && options.debug) { | ||
| this.debugger = new Debugger(this); | ||
| } else { | ||
| this.renderer.debug = {checkShaderErrors: false}; |
There was a problem hiding this comment.
if this condition is going to live here, maybe turning it on should live here too instead of buried in the Debugger.ts?
There was a problem hiding this comment.
Yeah, it's funky because it's technically on by default, I just wanted the Debugger to assert that it be on when it is used.
There was a problem hiding this comment.
I changed the logic here to make it more explicit. LMKWYT.
Add minimum viable debug mode (google#856) * Add minimum viable debug mode * Make debugger protected * Fix debug logic, expose more things * Announce adding/removing scenes
This change introduces a very light "debug" mode to
<model-viewer>. Debug mode can be activated in two ways:http://example.com/foo.html?model-viewer-debug-modeActivating debug mode currently does two things:
model-viewer-renderer-debugeventAn example of using this event looks like:
The
Debuggerwill also advertise scenes as they are registered and unregistered. You can listen for globalmodel-viewer-scene-added-debugandmodel-viewer-scene-removed-debugevents, which contain a reference to the related scene asevent.detail.scene. The scenes in this case will be instances ofModelScene.If you wanted to turn on debugging for most tests, you could manually run them with a URL like:
http://localhost:8000/test/?model-viewer-debug-mode.Note that this will currently only enable debug mode for tests that create a
RendererviaModelViewerElementBase. Tests that instantiate aRendererdirectly would need to pass a debug flag e.g.,new Renderer({ debug: true });.