diff --git a/examples/cornell-box-raytraced/index.ts b/examples/cornell-box-raytraced/index.ts index a67f897..318b2ec 100644 --- a/examples/cornell-box-raytraced/index.ts +++ b/examples/cornell-box-raytraced/index.ts @@ -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'); @@ -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; @@ -106,7 +111,9 @@ renderer.init().then(() => { resizeObserver.observe(canvas); function frame() { + stats.begin(); renderer.render(scene, camera, i++); + stats.end(); window.requestAnimationFrame(frame); } diff --git a/package-lock.json b/package-lock.json index 3ac602d..479aa77 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,8 +7,10 @@ "name": "eclipse", "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", @@ -883,6 +885,12 @@ "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", "dev": true }, + "node_modules/@types/stats": { + "version": "0.16.30", + "resolved": "https://registry.npmjs.org/@types/stats/-/stats-0.16.30.tgz", + "integrity": "sha512-ihuaNKhVjTQ8UNLJu7Kx96ywf0bSBday/K//HHvO9LKha07Ezxdm6HkazOKUIdayp0EmGEIPBQSL7eLxm8rX0w==", + "dev": true + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "5.62.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz", @@ -3354,6 +3362,12 @@ "integrity": "sha512-sh8PWc/ftMqAAdFiBu6Fy6JUOYjqDJBJvIhpfDMyHrr0Rbp5liZqd4TjtQ/RgfLjKFZb+LMx5hpml5qOWy0qvg==", "dev": true }, + "node_modules/stats.js": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/stats.js/-/stats.js-0.17.0.tgz", + "integrity": "sha512-hNKz8phvYLPEcRkeG1rsGmV5ChMjKDAWU7/OJJdDErPBNChQXxCo3WZurGpnWc6gZhAzEPFad1aVgyOANH1sMw==", + "dev": true + }, "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", diff --git a/package.json b/package.json index 54ab2d2..ed90f09 100644 --- a/package.json +++ b/package.json @@ -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",