Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created May 14, 2023 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/3b49f29524ad2ecf2e43f1247df35ddb to your computer and use it in GitHub Desktop.
Save flushpot1125/3b49f29524ad2ecf2e43f1247df35ddb to your computer and use it in GitHub Desktop.
//See the link "https://github.com/BabylonJS/Website/tree/master/build/Demos/WebGPU" in detail.
(async function() {
if (!navigator.gpu) {
alert("Web GPU is not supported on your platform so far.");
return;
}
const canvas = document.getElementById("renderCanvas");
const divFps = document.getElementById("fps");
const engine = new BABYLON.WebGPUEngine(canvas);
await engine.initAsync();
const scene = new BABYLON.Scene(engine);
scene.environmentTexture = new BABYLON.CubeTexture("https://assets.babylonjs.com/environments/environmentSpecular.env", scene);
await BABYLON.SceneLoader.ImportMeshAsync("", "https://www.babylonjs.com/Assets/DamagedHelmet/glTF/", "damagedhelmet.gltf", scene);
scene.createDefaultCamera(true, true, true);
scene.createDefaultSkybox(scene.environmentTexture, true, undefined, 0.3);
engine.runRenderLoop(() => {
scene.render();
divFps.innerHTML = engine.getFps().toFixed() + " fps";
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment