_Layout.cshtml 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. @using BuildOurOwnBabylonJSServer.Extensions;
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8" />
  6. <title>@ViewBag.Title</title>
  7. <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
  8. <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
  9. <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
  10. @if (ViewBag.DoNotUseBabylonJS == null)
  11. {
  12. @Html.Raw(this.BabylonJSStyle(@"Tools\BuildOurOwnBabylonJS\BuildOurOwnBabylonJSShared\Style\Loading.css"))
  13. @Html.Raw(this.BabylonJSScript("cannon.js"))
  14. @Html.Raw(this.BabylonJSScript(@"Tools\BuildOurOwnBabylonJS\BuildOurOwnBabylonJS\ourOwnBabylon.js"))
  15. @Html.Raw(this.BabylonJSScript(@"Tools\BuildOurOwnBabylonJS\BuildOurOwnBabylonJSShared\Scripts\Loading.js"))
  16. <script type="text/javascript">
  17. var OURBABYLON = OURBABYLON || {};
  18. $(document).ready(function(){
  19. if (!BABYLON.Engine.isSupported()) {
  20. alert("Your browser does not support WebGL so you can't use BabylonJS on it");
  21. return;
  22. }
  23. OURBABYLON.canvas = document.getElementById("ourOwnBabylonJSCanvas");
  24. OURBABYLON.engine = new BABYLON.Engine(OURBABYLON.canvas, true);
  25. OURBABYLON.sceneInitialization = function (scene, attachControlToCamera) {
  26. OURBABYLON.currentScene = scene;
  27. if (!OURBABYLON.currentScene.activeCamera) {
  28. OURBABYLON.currentScene.activeCamera = new BABYLON.ArcRotateCamera("DefaultCamera", Math.PI / 2, 0, 10, new BABYLON.Vector3.Zero(), OURBABYLON.currentScene);
  29. OURBABYLON.currentScene.activeCamera.zoomOn();
  30. if (attachControlToCamera) {
  31. OURBABYLON.currentScene.activeCamera.attachControl(OURBABYLON.canvas);
  32. }
  33. }
  34. if (OURBABYLON.currentScene.lights.length == 0) {
  35. var light = new BABYLON.HemisphericLight("Default light", new BABYLON.Vector3(0, 1, 0), OURBABYLON.currentScene);
  36. }
  37. };
  38. window.addEventListener("resize", function () {
  39. OURBABYLON.engine.resize();
  40. });
  41. window.OURBABYLON = OURBABYLON;
  42. });
  43. </script>
  44. }
  45. </head>
  46. <body>
  47. <div id="main">
  48. <div id="title">
  49. <h1>@ViewBag.Title</h1>
  50. <div id="menu">
  51. <a href="@Url.Action("Index", "SandBox")">Sandbox</a>
  52. </div>
  53. </div>
  54. @if (ViewBag.DoNotUseBabylonJS == null)
  55. {
  56. <canvas id="ourOwnBabylonJSCanvas"></canvas>
  57. }
  58. @RenderBody()
  59. <script type="text/javascript">
  60. var menu = document.getElementById("menu");
  61. var req = new XMLHttpRequest();
  62. req.open('GET', "@Html.Raw(this.BabylonJSSamplesFolder())");
  63. req.onreadystatechange = function (evt) {
  64. if (req.readyState == 4) {
  65. if (req.status == 200) {
  66. var json = JSON.parse(req.responseText);
  67. for (var i in json.files) {
  68. var span = document.createElement("span");
  69. span.innerHTML = " | ";
  70. menu.appendChild(span);
  71. var file = json.files[i];
  72. var a = document.createElement("a");
  73. a.setAttribute("href", file.url);
  74. a.textContent = file.linkName.charAt(0).toUpperCase() + file.linkName.slice(1);
  75. menu.appendChild(a);
  76. }
  77. }
  78. }
  79. };
  80. req.send(null);
  81. </script>
  82. </div>
  83. </body>
  84. </html>