index.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Local Development</title>
  5. <script src="https://babylonjs.azurewebsites.net/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. var canvas = document.getElementById("renderCanvas");
  24. var engine = new BABYLON.Engine(canvas, true, { stencil: false, audioEngine: false });
  25. engine.preventCacheWipeBetweenFrames = true;
  26. BABYLON.PerfCounter.Enabled = false;
  27. BABYLON.SceneLoader.ShowLoadingScreen = false;
  28. BABYLON.SceneLoader.Load("./", "cortana.babylon", engine, function(scene) {
  29. // Replace camera by a arcRotate to be able to rotate around Cortana
  30. var newCamera = new BABYLON.ArcRotateCamera("camera1", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
  31. // newCamera.attachControl(canvas, false); // Attach mouse control to be able to move around
  32. newCamera.setPosition(new BABYLON.Vector3(0, 2, -4));
  33. scene.activeCamera = newCamera;
  34. // Update materials (they are pretty good actually only alpha is missing)
  35. for (var index = 0; index < scene.materials.length; index++) {
  36. scene.materials[index].diffuseTexture.hasAlpha = true;
  37. scene.materials[index].useAlphaFromDiffuseTexture = true;
  38. scene.materials[index].alpha = 0.5;
  39. // Freezing materials
  40. scene.materials[index].freeze();
  41. }
  42. var mesh = scene.getMeshByName("Inner1");
  43. mesh.scaling = new BABYLON.Vector3(0.6, 0.6, 0.6);
  44. mesh = scene.getMeshByName("Inner2");
  45. mesh.scaling = new BABYLON.Vector3(0.6, 0.6, 0.6);
  46. mesh = scene.getMeshByName("Inner3");
  47. mesh.scaling = new BABYLON.Vector3(0.6, 0.6, 0.6);
  48. for (var index = 0; index < scene.meshes.length; index++) {
  49. // Avoid frustum clipping. No needed here as objects are always visible
  50. scene.meshes[index].alwaysSelectAsActiveMesh = true;
  51. }
  52. // Find root object
  53. var innerSphere = scene.getMeshByName("InnerSphereHolder");
  54. var outerSphere = scene.getMeshByName("OuterSphereHolder");
  55. // Set clear color to black (it is white by default)
  56. scene.clearColor = BABYLON.Color3.Black();
  57. // Register a render loop to repeatedly render the scene
  58. engine.runRenderLoop(function () {
  59. scene.render();
  60. // Do a bit of self-rotation
  61. innerSphere.rotation.y += 0.01;
  62. outerSphere.rotation.y -= 0.01;
  63. });
  64. });
  65. // Resize
  66. window.addEventListener("resize", function () {
  67. engine.resize();
  68. });
  69. </script>
  70. </body>
  71. </html>