Skip to content

Commit

Permalink
Add stats.js
Browse files Browse the repository at this point in the history
  • Loading branch information
cszach committed Apr 29, 2024
1 parent 30df844 commit be0647c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/cornell-box-raytraced/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Lambert,
} from '../../src/index.js';
import {quat, vec3} from 'wgpu-matrix';
import Stats from 'stats.js';

const canvas = document.querySelector('canvas');

Expand Down Expand Up @@ -84,6 +85,10 @@ renderer.init().then(() => {
lightMesh
);

const stats = new Stats();
stats.showPanel(0);
document.body.appendChild(stats.dom);

// Canvas resize
let i = 0;

Expand All @@ -106,7 +111,9 @@ renderer.init().then(() => {
resizeObserver.observe(canvas);

function frame() {
stats.begin();
renderer.render(scene, camera, i++);
stats.end();

window.requestAnimationFrame(frame);
}
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
},
"devDependencies": {
"@types/node": "20.11.5",
"@types/stats": "^0.16.30",
"@webgpu/types": "^0.1.40",
"gts": "^5.3.0",
"stats.js": "^0.17.0",
"typescript": "~5.4.3",
"vite": "^5.2.8",
"vite-raw-plugin": "^1.0.2",
Expand Down

0 comments on commit be0647c

Please sign in to comment.