Parcourir la source

Loading babylon demos scenes links dynamically instead of hard coding links.

Nicolas Obré il y a 11 ans
Parent
commit
06a13fec62

+ 11 - 0
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJS.sln

@@ -27,36 +27,47 @@ Global
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Debug|Any CPU.ActiveCfg = Debug|x86
 		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Debug|Any CPU.Build.0 = Debug|x86
+		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Debug|ARM.ActiveCfg = Debug|x86
 		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
 		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Debug|Mixed Platforms.Build.0 = Debug|x86
+		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Debug|x64.ActiveCfg = Debug|x86
 		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Debug|x86.ActiveCfg = Debug|x86
 		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Debug|x86.Build.0 = Debug|x86
 		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Release|Any CPU.ActiveCfg = Release|x86
 		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Release|Any CPU.Build.0 = Release|x86
+		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Release|ARM.ActiveCfg = Release|x86
 		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Release|Mixed Platforms.ActiveCfg = Release|x86
 		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Release|Mixed Platforms.Build.0 = Release|x86
+		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Release|x64.ActiveCfg = Release|x86
 		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Release|x86.ActiveCfg = Release|x86
 		{0263AD0D-56E6-4439-BC05-6EC957200F52}.Release|x86.Build.0 = Release|x86
 		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Debug|Any CPU.ActiveCfg = Debug|x86
 		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Debug|Any CPU.Build.0 = Debug|x86
+		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Debug|ARM.ActiveCfg = Debug|x86
 		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
 		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Debug|Mixed Platforms.Build.0 = Debug|x86
+		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Debug|x64.ActiveCfg = Debug|x86
 		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Debug|x86.ActiveCfg = Debug|x86
 		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Debug|x86.Build.0 = Debug|x86
 		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Release|Any CPU.ActiveCfg = Release|x86
 		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Release|Any CPU.Build.0 = Release|x86
+		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Release|ARM.ActiveCfg = Release|x86
 		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Release|Mixed Platforms.ActiveCfg = Release|x86
 		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Release|Mixed Platforms.Build.0 = Release|x86
+		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Release|x64.ActiveCfg = Release|x86
 		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Release|x86.ActiveCfg = Release|x86
 		{93EF5B02-72EB-4B55-831E-E5051269EDA6}.Release|x86.Build.0 = Release|x86
 		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Debug|Any CPU.ActiveCfg = Debug|x86
 		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Debug|Any CPU.Build.0 = Debug|x86
+		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Debug|ARM.ActiveCfg = Debug|x86
 		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
 		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Debug|Mixed Platforms.Build.0 = Debug|x86
+		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Debug|x64.ActiveCfg = Debug|x86
 		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Debug|x86.ActiveCfg = Debug|x86
 		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Debug|x86.Build.0 = Debug|x86
 		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Release|Any CPU.ActiveCfg = Release|x86
 		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Release|Any CPU.Build.0 = Release|x86
+		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Release|ARM.ActiveCfg = Release|x86
 		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Release|Mixed Platforms.ActiveCfg = Release|x86
 		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Release|Mixed Platforms.Build.0 = Release|x86
 		{CFBE5149-1605-4824-8BD2-55C9B3C1DA60}.Release|x64.ActiveCfg = Release|x86

Fichier diff supprimé car celui-ci est trop grand
+ 2 - 2
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJS/ourOwnBabylon.js


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

@@ -54,6 +54,9 @@
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="Microsoft.CSharp" />
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\packages\Newtonsoft.Json.6.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="System.Data.Entity" />
     <Reference Include="System" />

+ 29 - 0
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJSServer/Controllers/BuildOurOwnBabylonJSController.cs

@@ -2,12 +2,15 @@
 using System.IO;
 using System.Text;
 using System;
+using Newtonsoft.Json.Linq;
+using System.Collections.Generic;
 
 namespace BuildOurOwnBabylonJSServer.Controllers
 {
     public class BuildOurOwnBabylonJSController : Controller
     {
         public const string GetFileContentActionName = "GetFileContent";
+        public const string GetBabylonScenesActionName = "GetBabylonScenes";
         
         [ActionName(BuildOurOwnBabylonJSController.GetFileContentActionName)]
         public ActionResult GetFileContent(string rootPath, string relPath)
@@ -57,5 +60,31 @@ namespace BuildOurOwnBabylonJSServer.Controllers
                 return new HttpNotFoundResult();
             }
         }
+
+        [ActionName(BuildOurOwnBabylonJSController.GetBabylonScenesActionName)]
+        public string GetBabylonScenes(string rootPath)
+        {
+            var dir = new DirectoryInfo(rootPath);
+            var subDirs = dir.GetDirectories();
+            var files = new List<JObject>();
+
+            foreach (var directory in subDirs) {
+                var babylonFiles = directory.GetFiles("*.babylon");
+                if (babylonFiles.Length == 0) {
+                    continue;
+                }
+
+                foreach (var file in babylonFiles) {
+                    var linkName = directory.Name + (file.Name.Contains(".incremental.babylon") ? " - Incremental" : "");
+                    files.Add(new JObject(
+                        new JProperty("url", Url.Action("Index", "BabylonJSDemo", new { demoFolderName = directory.Name, demoFile = file.Name })),
+                        new JProperty("linkName", linkName)
+                    ));
+                }
+            }
+
+            var json = new JObject(new JProperty("files", files));
+            return json.ToString(Newtonsoft.Json.Formatting.None);
+        }
     }
 }

+ 26 - 13
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJSServer/Views/Shared/_Layout.cshtml

@@ -37,19 +37,6 @@
         <div id="title">
             <h1>@ViewBag.Title</h1>
             <div id="menu">
-                <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "Blender", demoFile = "blender.babylon" })">Blender</a>
-                | <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "Dude", demoFile = "Dude.babylon" })">Dude</a>
-                | <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "Espilit", demoFile = "Espilit.incremental.babylon" })">Espilit</a>
-                | <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "Flat2009", demoFile = "Flat2009.babylon" })">Flat2009</a>
-                | <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "Heart", demoFile = "Heart.babylon" })">Heart</a>
-                | <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "Rabbit", demoFile = "Rabbit.babylon" })">Rabbit</a>
-                | <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "Robot", demoFile = "Robot.babylon" })">Robot</a>
-                | <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "SpaceDek", demoFile = "SpaceDek.babylon" })">SpaceDek</a>
-                | <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "Spaceship", demoFile = "Spaceship.babylon" })">Spaceship</a>
-                | <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "TheCar", demoFile = "TheCar.incremental.babylon" })">TheCar</a>
-                | <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "Train", demoFile = "Train.babylon" })">Train</a>
-                | <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "Viper", demoFile = "Viper.babylon" })">Viper</a>
-                | <a href="@Url.Action("Index", "BabylonJSDemo", new { demoFolderName = "WCafe", demoFile = "WCafe.babylon" })">WCafe</a>
             </div>
         </div>
         @if (ViewBag.DoNotUseBabylonJS == null)
@@ -57,6 +44,32 @@
         <canvas id="ourOwnBabylonJSCanvas"></canvas>
         }
         @RenderBody()
+        <script type="text/javascript">
+            var menu = document.getElementById("menu");
+
+            var req = new XMLHttpRequest();
+            req.open('GET', "@Html.Raw(this.BabylonJSSamplesFolder())");
+            req.onreadystatechange = function (evt) {
+                if (req.readyState == 4) {
+                    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 file = json.files[i];
+                            var a = document.createElement("a");
+                            a.setAttribute("href", file.url);
+                            a.textContent = file.linkName.charAt(0).toUpperCase() + file.linkName.slice(1);
+                            menu.appendChild(a);
+                        }
+                    }
+                }
+            };
+            req.send(null);
+        </script>
     </div>
 </body>
 </html>

+ 15 - 0
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJSServer/WebViewPageExtensions.cs

@@ -57,5 +57,20 @@ namespace BuildOurOwnBabylonJSServer.Extensions
 
             return url;
         }
+
+
+        public static string BabylonJSSamplesFolder(this WebViewPage page)
+        {
+            if (page == null)
+                return null;
+
+            var babylonJSSamplesDirFullPath = Environment.GetEnvironmentVariable("BabylonJSSamplesDirFullPath") + "\\Scenes";
+
+            var url = page.Url.Action(BuildOurOwnBabylonJSController.GetBabylonScenesActionName,
+                                      "BuildOurOwnBabylonJS",
+                                      new { rootPath = babylonJSSamplesDirFullPath },
+                                      page.Request.Url.Scheme);
+            return url;
+        }
     }
 }

+ 1 - 0
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJSServer/packages.config

@@ -6,4 +6,5 @@
   <package id="jQuery.Validation" version="1.8.0" />
   <package id="jQuery.vsdoc" version="1.5.1" />
   <package id="Modernizr" version="1.7" />
+  <package id="Newtonsoft.Json" version="6.0.2" targetFramework="net45" />
 </packages>

+ 4 - 3
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJSWinJSApp/BuildOurOwnBabylonJSWinJSApp.jsproj

@@ -55,9 +55,6 @@
     <AppxManifest Include="package.appxmanifest">
       <SubType>Designer</SubType>
     </AppxManifest>
-    <Content Include="..\..\..\Samples\Scenes\**\*.*">
-      <Link>BabylonJS-Demos\%(RecursiveDir)%(Filename)%(Extension)</Link>
-    </Content>
     <Content Include="css\default.css" />
     <Content Include="images\logo.scale-100.png" />
     <Content Include="images\smalllogo.scale-100.png" />
@@ -76,6 +73,10 @@
     <Content Include="..\BuildOurOwnBabylonJS\ourOwnBabylon.js">
       <Link>js\ourOwnBabylon.js</Link>
     </Content>
+    <Content Include="$(BabylonJSSamplesDirFullPath)Scenes\**\*.*">
+      <Link>BabylonJS-Demos\%(RecursiveDir)%(Filename)%(Extension)</Link>
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
     <None Include="BuildOurOwnBabylonJSWinJSApp_TemporaryKey.pfx" />
   </ItemGroup>
   <ItemGroup>