Browse Source

Adding a sandbox view to quickly test your own .babylon files

Nicolas Obré 11 years ago
parent
commit
2dd2765a93

+ 4 - 0
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJSServer/BuildOurOwnBabylonJSServer.csproj

@@ -81,6 +81,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Controllers\BabylonJSDemoController.cs" />
+    <Compile Include="Controllers\SandBoxController.cs" />
     <Compile Include="Controllers\OurDemoController.cs" />
     <Compile Include="ViewModel\OurDemoViewModel.cs" />
     <Compile Include="WebViewPageExtensions.cs" />
@@ -171,6 +172,9 @@
       <Private>True</Private>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="Views\SandBox\Index.cshtml" />
+  </ItemGroup>
   <PropertyGroup>
     <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
     <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

+ 16 - 0
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJSServer/Controllers/SandBoxController.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+
+namespace BuildOurOwnBabylonJSServer.Controllers
+{
+    public class SandBoxController : Controller
+    {
+        public ActionResult Index()
+        {
+            return View();
+        }
+    }
+}

+ 14 - 0
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJSServer/Views/SandBox/Index.cshtml

@@ -0,0 +1,14 @@
+@{
+    ViewBag.Title = "Our Own Sandbox";
+    ViewBag.BabylonJSFolder = "..\\..\\..\\";
+}
+
+<script type="text/javascript">
+    $(document).ready(function () {
+        var filesInput = new BABYLON.FilesInput(OURBABYLON.engine, OURBABYLON.currentScene, OURBABYLON.canvas, function (sceneFile, babylonScene) {
+            OURBABYLON.currentScene = babylonScene;
+            //babylonScene.activeCamera.attachControl(OURBABYLON.canvas);
+        });
+        filesInput.monitorElementForDragNDrop(OURBABYLON.canvas);
+    });
+</script>

+ 5 - 5
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJSServer/Views/Shared/_Layout.cshtml

@@ -37,6 +37,7 @@
         <div id="title">
             <h1>@ViewBag.Title</h1>
             <div id="menu">
+                <a href="@Url.Action("Index", "SandBox")">Our own sandbox</a>
             </div>
         </div>
         @if (ViewBag.DoNotUseBabylonJS == null)
@@ -54,11 +55,10 @@
                     if (req.status == 200) {
                         var json = JSON.parse(req.responseText);
                         for (var i in json.files) {
-                            if (i > 0) {
-                                var span = document.createElement("span");
-                                span.innerHTML = " | ";
-                                menu.appendChild(span);
-                            }
+                            var span = document.createElement("span");
+                            span.innerHTML = " | ";
+                            menu.appendChild(span);
+
                             var file = json.files[i];
                             var a = document.createElement("a");
                             a.setAttribute("href", file.url);