mesh_parent_JSON.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <html>
  2. <head>
  3. <meta charset="UTF-8">
  4. <title>mesh_parent</title>
  5. <!-- edit path - name of babylon library as required -->
  6. <script src="./lib/babylon.js"></script>
  7. <style>
  8. html, body { width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; }
  9. #renderCanvas{ width: 100%; height: 100%; }
  10. </style>
  11. </head>
  12. <body>
  13. <canvas id="renderCanvas"></canvas>
  14. <script>
  15. if (BABYLON.Engine.isSupported()) {
  16. var canvas = document.getElementById("renderCanvas");
  17. var engine = new BABYLON.Engine(canvas, true);
  18. console.log("Babylon version: " + BABYLON.Engine.Version);
  19. var url = "./TOB-out/"; // edit when .babylon / texture files in a different dir than html
  20. BABYLON.SceneLoader.Load(url, "mesh_parent.babylon", engine,
  21. function (newScene) {
  22. newScene.executeWhenReady(function () {
  23. // Attach camera to canvas inputs
  24. newScene.activeCamera.attachControl(canvas);
  25. // Once the scene is loaded, register a render loop
  26. engine.runRenderLoop(function() {
  27. newScene.render();
  28. });
  29. });
  30. },
  31. function (progress) {
  32. // To do: give progress feedback to user
  33. }
  34. );
  35. }else{
  36. alert("WebGL not supported in this browser.\n\n" +
  37. "If in Safari browser, check 'Show Develop menu in menu bar' on the Advanced tab of Preferences. " +
  38. "On the 'Develop' menu, check the 'Enable WebGL' menu item.");
  39. }
  40. //Resize
  41. window.addEventListener("resize", function () {
  42. engine.resize();
  43. });
  44. </script>
  45. </body>
  46. </html>