Browse Source

Custom Build refinements

- Changed if test to use getClassName() instead of instanceof
- Improved the directions of the page
- Added a output directory text field on page
Palmer-JC 8 years ago
parent
commit
07084f9f3d

+ 19 - 19
Tools/Gulp/profiling.html

@@ -3,26 +3,29 @@
     <title>Customize BJS for a specific Scene</title>
     <title>Customize BJS for a specific Scene</title>
     <meta charset="UTF-8">
     <meta charset="UTF-8">
     <script src="../../dist/preview release/babylon.js"></script>
     <script src="../../dist/preview release/babylon.js"></script>
+    <style>
+    input.path {width:600px;}
+    input.filename {width:200px;}
+    em {color:red;}
+    </style>
     
     
 </head>
 </head>
 <body onload="readConfigFile()">
 <body onload="readConfigFile()">
 Obtain a FireFox performance file by:
 Obtain a FireFox performance file by:
 <ol>
 <ol>
 	<li>Make sure scene uses Babylon MAX.</li>
 	<li>Make sure scene uses Babylon MAX.</li>
-	<li>Load the scene.</li>
-	<li>Turn on performance profiling.</li>
-	<li>Reload the scene (very important if code like sceneLoader runs on page load).</li>
+	<li>Add the temporary Javascript line <em>window.alert('Turn on Performance Recording')</em> just prior to Engine Instancing line.
+	<li>Load the scene, turn on performance profiling, &amp; click ok to the temporary alert.</li>
 	<li>Do anything that might call code in babylon.js not yet encountered.</li>
 	<li>Do anything that might call code in babylon.js not yet encountered.</li>
 	<li>Stop recording, and save the data as a file.</li>
 	<li>Stop recording, and save the data as a file.</li>
 </ol>
 </ol>
 On this page:
 On this page:
 <ol>
 <ol>
 	<li>Select File with 'Browse' button below, and pick the file saved from above.</li>
 	<li>Select File with 'Browse' button below, and pick the file saved from above.</li>
-	<li>Make any changes of name to babylon file names.</li>
-	<li>Click Generate.</li>
+	<li>Make any changes of name to babylon file names &amp; directory..</li>
+	<li>Click Generate. Tip: change Firefox Option for Downloads to <em>Always ask me where to save files</em> to avoid having to move custom config to Gulp Directory.</li>
 	<li>Copy the 'custom.cofig.json' file generated in Downloads directory to the Gulp directory.</li>
 	<li>Copy the 'custom.cofig.json' file generated in Downloads directory to the Gulp directory.</li>
-	<li>run: 'Gulp build-custom'</li>
-	<li>Copy generated scripts from dist/preview lease to where needed, and test.  Tip: test with the max version</li>
+	<li>Run: 'Gulp build-custom' then test with scene.  Tip: test with the max version generated.</li>
 	<li>If need stuff did not get recorded in performance file, then select file(s) &amp; click Generate again.</li>
 	<li>If need stuff did not get recorded in performance file, then select file(s) &amp; click Generate again.</li>
 </ol>
 </ol>
 	<form>
 	<form>
@@ -32,11 +35,12 @@ On this page:
 		
 		
 		<label>Profiling file: <input type="file" id="upload_file" name="upload" accept="text/*" multiple="" onchange="assignProfile(this.files[0])"/></label><br><br>
 		<label>Profiling file: <input type="file" id="upload_file" name="upload" accept="text/*" multiple="" onchange="assignProfile(this.files[0])"/></label><br><br>
 		
 		
-		Filename: <input type="text" id="filename" maxlength="32" value="babylon.custom.max.js">         
-		minFilename: <input type="text" id="minFilename" maxlength="32" value="babylon.custom.js"><br>         
+		Output Directory: <input class="path"     type="text" id="directory"   maxlength="256" value="C:/"> (clear for default of <em>../../dist/preview release</em>)<br>
+		Filename:         <input class="filename" type="text" id="filename"    maxlength="32"  value="babylon.custom.max.js">         
+		minFilename:      <input class="filename" type="text" id="minFilename" maxlength="32"  value="babylon.custom.js"><br>         
         Files Not In Recording: (Select those to still keep)
         Files Not In Recording: (Select those to still keep)
-			<input type="button" value="Generate" onclick="generate()"><br>
-        <select id="discards" multiple size="30">
+			<input type="button" value="Generate Custom Config" onclick="generate()"><br>
+        <select id="discards" multiple size="50">
         </select>
         </select>
 
 
 	</form>
 	</form>
@@ -80,17 +84,10 @@ On this page:
 						// force stuff to always be added
 						// force stuff to always be added
 						appendSecondarySearches("decorators.js", "engine"); //needed for Serialize
 						appendSecondarySearches("decorators.js", "engine"); //needed for Serialize
 						appendSecondarySearches("stringDictionary.js", "engine"); //needed in Engine Constructor
 						appendSecondarySearches("stringDictionary.js", "engine"); //needed in Engine Constructor
-						appendSecondarySearches("loadingScreen.js", "engine"); //needed in Engine Constructor		
 						appendSecondarySearches("postProcessRenderPipelineManager.js", "scene"); //needed in Scene Constructor		
 						appendSecondarySearches("postProcessRenderPipelineManager.js", "scene"); //needed in Scene Constructor		
 						appendSecondarySearches("boundingBoxRenderer.js", "scene"); //needed in Scene Constructor		
 						appendSecondarySearches("boundingBoxRenderer.js", "scene"); //needed in Scene Constructor		
 						appendSecondarySearches("collisionCoordinator.js", "scene"); //needed in Scene Constructor, from a called set of this.workerCollisions = false;
 						appendSecondarySearches("collisionCoordinator.js", "scene"); //needed in Scene Constructor, from a called set of this.workerCollisions = false;
 						appendSecondarySearches("collider.js", "abstractMesh"); // needed in abstractMesh constructor
 						appendSecondarySearches("collider.js", "abstractMesh"); // needed in abstractMesh constructor
-						appendSecondarySearches("linesMesh.js", "geometry"); // needed in geometry constructor
-						appendSecondarySearches("multiMaterial.js", "subMesh"); // needed in subMesh.getMaterial()
-						appendSecondarySearches("pointLight.js", "subMesh"); // needed in MaterialHelper.PrepareDefinesForLights
-						appendSecondarySearches("spotLight.js", "subMesh"); // needed in MaterialHelper.PrepareDefinesForLights
-						appendSecondarySearches("hemisphericLight.js", "subMesh"); // needed in MaterialHelper.PrepareDefinesForLights
-						appendSecondarySearches("directionalLight.js", "subMesh"); // needed in MaterialHelper.PrepareDefinesForLights
 						appendSecondarySearches("videoTexture.js", "engine"); //needed in Engine._setTexture()	
 						appendSecondarySearches("videoTexture.js", "engine"); //needed in Engine._setTexture()	
 						
 						
 						// there should always some detection of FreeCamera or ArcRotateCamera, but maybe not all inputs got recorded
 						// there should always some detection of FreeCamera or ArcRotateCamera, but maybe not all inputs got recorded
@@ -191,14 +188,17 @@ On this page:
                 }
                 }
 			}
 			}
 
 
+			var directory   = document.getElementById("directory"  ).value;
 			var filename    = document.getElementById("filename"   ).value;
 			var filename    = document.getElementById("filename"   ).value;
 			var minFilename = document.getElementById("minFilename").value;
 			var minFilename = document.getElementById("minFilename").value;
+			
+			if (directory.length === 0) directory = "../../dist/preview release";
 	    	var out = '';
 	    	var out = '';
 	    	out += '{\n';
 	    	out += '{\n';
 	    	out += '  "build": {\n';
 	    	out += '  "build": {\n';
 	    	out += '	    "filename": "' + filename + '",\n';
 	    	out += '	    "filename": "' + filename + '",\n';
 	    	out += '	    "minFilename": "' + minFilename + '",\n';
 	    	out += '	    "minFilename": "' + minFilename + '",\n';
-	    	out += '	    "outputDirectory": "../../dist/preview release",\n';
+	    	out += '	    "outputDirectory":  "' + directory + '",\n';
 	    	out += '	    "srcOutputDirectory": "../../src/"\n';
 	    	out += '	    "srcOutputDirectory": "../../src/"\n';
 	    	out += '	  },\n';
 	    	out += '	  },\n';
 	    	out += '	  "core": {\n';
 	    	out += '	  "core": {\n';

+ 1 - 0
dist/preview release/what's new.md

@@ -47,6 +47,7 @@
 - New material: `ShadowOnlyMaterial` to display shadows on transparent surfaces ([deltakosh](https://github.com/deltakosh)) 
 - New material: `ShadowOnlyMaterial` to display shadows on transparent surfaces ([deltakosh](https://github.com/deltakosh)) 
 - Added `VertexBuffer.TangentKind` to specify tangents in place of shader-calculated tangents ([dewadswo](https://github.com/dewadswo), [bghgary](https://github.com/bghgary))
 - Added `VertexBuffer.TangentKind` to specify tangents in place of shader-calculated tangents ([dewadswo](https://github.com/dewadswo), [bghgary](https://github.com/bghgary))
 - Added `material.twoSidedLighting` to PBRMaterial and StandardMaterial to enable flipping normals when backfaceCulling is false ([BeardedGnome](https://github.com/BeardedGnome), [bghgary](https://github.com/bghgary))
 - Added `material.twoSidedLighting` to PBRMaterial and StandardMaterial to enable flipping normals when backfaceCulling is false ([BeardedGnome](https://github.com/BeardedGnome), [bghgary](https://github.com/bghgary))
+- Added a [HTML page](https://github.com/BabylonJS/Babylon.js/blob/master/Tools/Gulp/profiling.html) with embedded directions to improve the custom build process. ([jcpalmer](https://github.com/Palmer-JC))
  
  
 ### Bug fixes
 ### Bug fixes
 - Fixed a bug with spotlight direction ([deltakosh](https://github.com/deltakosh)) 
 - Fixed a bug with spotlight direction ([deltakosh](https://github.com/deltakosh)) 

+ 7 - 7
src/Materials/babylon.materialHelper.ts

@@ -111,11 +111,11 @@
                     defines["DIRLIGHT" + lightIndex] = false;
                     defines["DIRLIGHT" + lightIndex] = false;
 
 
                     var type;
                     var type;
-                    if (light instanceof SpotLight) {
+                    if (light.getClassName() === "SpotLight") {
                         type = "SPOTLIGHT" + lightIndex;
                         type = "SPOTLIGHT" + lightIndex;
-                    } else if (light instanceof HemisphericLight) {
+                    } else if (light.getClassName() === "HemisphericLight") {
                         type = "HEMILIGHT" + lightIndex;
                         type = "HEMILIGHT" + lightIndex;
-                    } else if (light instanceof PointLight) {
+                    } else if (light.getClassName() === "PointLight") {
                         type = "POINTLIGHT" + lightIndex;
                         type = "POINTLIGHT" + lightIndex;
                     } else {
                     } else {
                         type = "DIRLIGHT" + lightIndex;
                         type = "DIRLIGHT" + lightIndex;
@@ -305,16 +305,16 @@
         }
         }
 
 
         public static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void {
         public static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void {
-            if (light instanceof PointLight) {
+            if (light.getClassName() === "PointLight") {
                 // Point Light
                 // Point Light
                 light.transferToEffect(effect, "vLightData" + lightIndex);
                 light.transferToEffect(effect, "vLightData" + lightIndex);
-            } else if (light instanceof DirectionalLight) {
+            } else if (light.getClassName() === "DirectionalLight") {
                 // Directional Light
                 // Directional Light
                 light.transferToEffect(effect, "vLightData" + lightIndex);
                 light.transferToEffect(effect, "vLightData" + lightIndex);
-            } else if (light instanceof SpotLight) {
+            } else if (light.getClassName() === "SpotLight") {
                 // Spot Light
                 // Spot Light
                 light.transferToEffect(effect, "vLightData" + lightIndex, "vLightDirection" + lightIndex);
                 light.transferToEffect(effect, "vLightData" + lightIndex, "vLightDirection" + lightIndex);
-            } else if (light instanceof HemisphericLight) {
+            } else if (light.getClassName() === "HemisphericLight") {
                 // Hemispheric Light
                 // Hemispheric Light
                 light.transferToEffect(effect, "vLightData" + lightIndex, "vLightGround" + lightIndex);
                 light.transferToEffect(effect, "vLightData" + lightIndex, "vLightGround" + lightIndex);
             }
             }

+ 2 - 2
src/Mesh/babylon.geometry.ts

@@ -65,8 +65,8 @@
 
 
             // applyToMesh
             // applyToMesh
             if (mesh) {
             if (mesh) {
-                if (mesh instanceof LinesMesh) {
-                    this.boundingBias = new Vector2(0, mesh.intersectionThreshold);
+                if (mesh.getClassName() === "LinesMesh") {
+                    this.boundingBias = new Vector2(0, (<LinesMesh> mesh).intersectionThreshold);
                     this.updateExtend();
                     this.updateExtend();
                 }
                 }
 
 

+ 1 - 1
src/Mesh/babylon.subMesh.ts

@@ -89,7 +89,7 @@
         public getMaterial(): Material {
         public getMaterial(): Material {
             var rootMaterial = this._renderingMesh.material;
             var rootMaterial = this._renderingMesh.material;
 
 
-            if (rootMaterial && rootMaterial instanceof MultiMaterial) {
+            if (rootMaterial && rootMaterial.getClassName() === "MultiMaterial") {
                 var multiMaterial = <MultiMaterial>rootMaterial;
                 var multiMaterial = <MultiMaterial>rootMaterial;
                 return multiMaterial.getSubMaterial(this.materialIndex);
                 return multiMaterial.getSubMaterial(this.materialIndex);
             }
             }

+ 6 - 3
src/babylon.engine.ts

@@ -779,9 +779,6 @@
                 Engine.audioEngine = new AudioEngine();
                 Engine.audioEngine = new AudioEngine();
             }
             }
 
 
-            //default loading screen
-            this._loadingScreen = new DefaultLoadingScreen(this._renderingCanvas);
-
             //Load WebVR Devices
             //Load WebVR Devices
             if (options.autoEnableWebVR) {
             if (options.autoEnableWebVR) {
                 this.initWebVR();
                 this.initWebVR();
@@ -3362,26 +3359,32 @@
 
 
         // Loading screen
         // Loading screen
         public displayLoadingUI(): void {
         public displayLoadingUI(): void {
+            if (!this._loadingScreen) this._loadingScreen = new DefaultLoadingScreen(this._renderingCanvas)
             this._loadingScreen.displayLoadingUI();
             this._loadingScreen.displayLoadingUI();
         }
         }
 
 
         public hideLoadingUI(): void {
         public hideLoadingUI(): void {
+            if (!this._loadingScreen) this._loadingScreen = new DefaultLoadingScreen(this._renderingCanvas)
             this._loadingScreen.hideLoadingUI();
             this._loadingScreen.hideLoadingUI();
         }
         }
 
 
         public get loadingScreen(): ILoadingScreen {
         public get loadingScreen(): ILoadingScreen {
+            if (!this._loadingScreen) this._loadingScreen = new DefaultLoadingScreen(this._renderingCanvas)
             return this._loadingScreen;
             return this._loadingScreen;
         }
         }
 
 
         public set loadingScreen(loadingScreen: ILoadingScreen) {
         public set loadingScreen(loadingScreen: ILoadingScreen) {
+            if (!this._loadingScreen) this._loadingScreen = new DefaultLoadingScreen(this._renderingCanvas)
             this._loadingScreen = loadingScreen;
             this._loadingScreen = loadingScreen;
         }
         }
 
 
         public set loadingUIText(text: string) {
         public set loadingUIText(text: string) {
+            if (!this._loadingScreen) this._loadingScreen = new DefaultLoadingScreen(this._renderingCanvas)
             this._loadingScreen.loadingUIText = text;
             this._loadingScreen.loadingUIText = text;
         }
         }
 
 
         public set loadingUIBackgroundColor(color: string) {
         public set loadingUIBackgroundColor(color: string) {
+            if (!this._loadingScreen) this._loadingScreen = new DefaultLoadingScreen(this._renderingCanvas)
             this._loadingScreen.loadingUIBackgroundColor = color;
             this._loadingScreen.loadingUIBackgroundColor = color;
         }
         }