Skip to content

Commit

Permalink
mini stats fix (#5156)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellthompson committed Mar 16, 2023
1 parent 08982b3 commit dbc28c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
16 changes: 11 additions & 5 deletions examples/scripts/iframe/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
}).observe(canvasContainerElement);
}
if ({{miniStats}}) {
if ({{miniStats}} && app.graphicsDevice.deviceType !== 'webgpu') {
// set up miniStats
var miniStats = new pcx.MiniStats(app);
if (urlParams.get('miniStats') === 'false') {
Expand Down Expand Up @@ -191,12 +191,18 @@
}
}
});
window.exampleFunction.apply(this, args);
if (pc.app && pc.app.graphicsDevice.canvas) {
setupApplication(pc.app);
const pollHandler = setInterval(appCreationPoll, 50);
function appCreationPoll() {
if (pc.app && pc.app.graphicsDevice.canvas) {
clearInterval(pollHandler);
setupApplication(pc.app);
var event = new CustomEvent("exampleLoad");
window.top.dispatchEvent(event);
}
}
var event = new CustomEvent("exampleLoad");
window.top.dispatchEvent(event);
}
</script>
<script>
Expand Down
14 changes: 4 additions & 10 deletions examples/src/app/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,9 @@ class ControlLoader extends Component <ControlLoaderProps, ControlLoaderState> {
exampleLoaded: true
});


const pollHandler = setInterval(appCreationPoll, 50);
function appCreationPoll() {
if ((window as any).pc.app) {
clearInterval(pollHandler);
const app: { graphicsDevice: { deviceType: string } } = (window as any).pc.app;
const activeDevice = app.graphicsDevice.deviceType;
controlsObserver.emit('updateActiveDevice', activeDevice);
}
}
const app: { graphicsDevice: { deviceType: string } } = (window as any).pc.app;
const activeDevice = app.graphicsDevice.deviceType;
controlsObserver.emit('updateActiveDevice', activeDevice);
});
}

Expand Down Expand Up @@ -152,6 +145,7 @@ class Example extends Component <ExampleProps, ExampleState> {
this.deviceTypeSelectInput.value = value;
}
this.setDisabledOptions(this.preferredGraphicsDevice, value);
document.getElementById('showMiniStatsButton').ui.enabled = value !== DEVICETYPE_WEBGPU;
};

onSetPreferredGraphicsDevice = (value: string) => {
Expand Down

0 comments on commit dbc28c7

Please sign in to comment.