_Layout.cshtml 3.7 KB

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