Skip to content

Instantly share code, notes, and snippets.

@RobiMez
Created September 30, 2023 20:23
Show Gist options
  • Save RobiMez/4a8b1e1110f906db93d7134917095b27 to your computer and use it in GitHub Desktop.
Save RobiMez/4a8b1e1110f906db93d7134917095b27 to your computer and use it in GitHub Desktop.
Get a fps counter running with svelte and three
import { GPUStatsPanel } from 'three/addons/utils/GPUStatsPanel.js';
import Stats from 'three/addons/libs/stats.module.js';
import { useThrelte } from '@threlte/core';
const { scene, renderer } = useThrelte();
const stats = new Stats();
document.body.appendChild(stats.dom);
const gpuPanel = new GPUStatsPanel(renderer.getContext());
stats.addPanel(gpuPanel);
stats.showPanel(0);
const animate = () => {
stats.update();
requestAnimationFrame(animate);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment