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