Browse Source

Export to Zip from Playground is not equivalent.
1. EngineOptions are missing.
2. custom createEngine() function, if defined, is not called.

original report: http://www.html5gamedevs.com/topic/39000-autoclear-and%C2%A0autocleardepthandstencil-problem/

Brian Zinn 7 năm trước cách đây
mục cha
commit
9e9a864859

+ 12 - 4
Playground/js/index.js

@@ -558,7 +558,8 @@ function showError(errorMessage, errorEvent) {
                     }
                     }
     
     
                     var scene;
                     var scene;
-    
+                    var defaultEngineZip = "new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true })";
+
                     if (code.indexOf("createEngine") !== -1) {
                     if (code.indexOf("createEngine") !== -1) {
                         createEngineFunction = "createEngine";
                         createEngineFunction = "createEngine";
                     }
                     }
@@ -581,7 +582,7 @@ function showError(errorMessage, errorEvent) {
                         eval("runScript = function(scene, canvas) {" + code + "}");
                         eval("runScript = function(scene, canvas) {" + code + "}");
                         runScript(scene, canvas);
                         runScript(scene, canvas);
     
     
-                        zipCode = "var scene = new BABYLON.Scene(engine);\r\n\r\n" + code;
+                        zipCode = "var engine = " + defaultEngineZip + ";\r\nvar scene = new BABYLON.Scene(engine);\r\n\r\n" + code;
                     } else {
                     } else {
                         //execute the code
                         //execute the code
                         eval(code);
                         eval(code);
@@ -600,8 +601,15 @@ function showError(errorMessage, errorEvent) {
                             return;
                             return;
                         }
                         }
     
     
-                        // update the scene code for the zip file
-                        zipCode = code + "\r\n\r\nvar scene = " + createSceneFunction + "()";
+                        var createEngineZip = (createEngineFunction === "createEngine")
+                            ? "createEngine()"
+                            : defaultEngineZip
+
+                        zipCode = 
+                            code + "\r\n\r\n" +
+                            "var engine = " + createEngineZip + ";\r\n" +
+                            "var scene = " + createSceneFunction + "();"
+
                     }
                     }
     
     
                     engine.runRenderLoop(function () {
                     engine.runRenderLoop(function () {

+ 0 - 1
Playground/zipContent/index.html

@@ -40,7 +40,6 @@
     <canvas id="renderCanvas"></canvas>
     <canvas id="renderCanvas"></canvas>
     <script>
     <script>
         var canvas = document.getElementById("renderCanvas");
         var canvas = document.getElementById("renderCanvas");
-        var engine = new BABYLON.Engine(canvas, true);
 
 
 ####INJECT####
 ####INJECT####