index.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Using babylon.js - How to load a scene</title>
  5. <script src="babylon.js"></script>
  6. <style>
  7. html, body {
  8. width: 100%;
  9. height: 100%;
  10. padding: 0;
  11. margin: 0;
  12. overflow: hidden;
  13. }
  14. #renderCanvas {
  15. width: 100%;
  16. height: 100%;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <canvas id="renderCanvas"></canvas>
  22. <script>
  23. if (BABYLON.Engine.isSupported()) {
  24. var canvas = document.getElementById("renderCanvas");
  25. var engine = new BABYLON.Engine(canvas, true);
  26. BABYLON.SceneLoader.Load("data/", "sundew_engine.babylon", engine, function (newScene) {
  27. // Wait for textures and shaders to be ready
  28. newScene.executeWhenReady(function () {
  29. // Attach camera to canvas inputs
  30. newScene.activeCamera.attachControl(canvas);
  31. // Once the scene is loaded, just register a render loop to render it
  32. engine.runRenderLoop(function() {
  33. newScene.render();
  34. });
  35. });
  36. }, function (progress) {
  37. // To do: give progress feedback to user
  38. });
  39. }
  40. </script>
  41. </body>
  42. </html>