Created
May 14, 2023 06:28
-
-
Save flushpot1125/3b49f29524ad2ecf2e43f1247df35ddb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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