Volumetrics-io / mrjs

An extensible WebComponents library for the Spatial Web
https://mrjs.io
MIT License
160 stars 9 forks source link

Can't toggle debug on `mr-app` dynamically #310

Open lobau opened 8 months ago

lobau commented 8 months ago

While making demos, I thought it would be really nice to be able to toggle the debug parameters dynamically instead of having to edit the code (especially while presenting the demo)

So I wrote a bit of code to toggle the parameter dynamically, but it's not working

https://codepen.io/lobau/pen/BabmBRx

var debugToggle = false;

const toggleDebug = () => {
    if (debugToggle) {
        document.querySelector("mr-app").removeAttribute("debug");
        debugToggle = false;
    } else {
        document.querySelector("mr-app").setAttribute("debug", true);
        debugToggle = true;
    }
    console.log(document.querySelector("mr-app"));
    console.log(debugToggle);
};

The console output is correct:

> <mr-app>
false

> <mr-app debug="true">
true

but the mr-app doesn't show / hide the debug elements

michaelthatsit commented 8 months ago

This would also boil down to a per-entity debug experience, adding the debug attribute to an element rather than at the app level, rather than rendering the whole physics scene.

michaelthatsit commented 8 months ago

we need a more advanced system for sure. I'll dig into dynamic toggling between now and then.