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

[Examples Browser] Mini stats fix #5156

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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