Sfoglia il codice sorgente

Merge pull request #8138 from RaananW/createEngine

[PG] createEngine fails silently and default engine is created on error
David Catuhe 5 anni fa
parent
commit
00039f4f55
2 ha cambiato i file con 9 aggiunte e 1 eliminazioni
  1. 8 1
      Playground/js/main.js
  2. 1 0
      dist/preview release/what's new.md

+ 8 - 1
Playground/js/main.js

@@ -101,7 +101,14 @@ compileAndRun = function (parent, fpsLabel) {
 
                 parent.zipTool.ZipCode = zipVariables + defaultEngineZip + "var engine = createDefaultEngine();" + ";\r\nvar scene = new BABYLON.Scene(engine);\r\n\r\n" + code;
             } else {
-                code += "\r\n\r\nengine = " + createEngineFunction + "();";
+                code += `
+var engine;
+try {
+    engine = ${createEngineFunction}();
+} catch(e) {
+    console.log("the available createEngine function failed. Creating the default engine instead");
+    engine = createDefaultEngine();
+}`;
                 code += "\r\nif (!engine) throw 'engine should not be null.';";
 
                 if (parent.settingsPG.ScriptLanguage == "JS") {

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

@@ -140,6 +140,7 @@
 ### Playground
 
 - Added support for code templates in the playground ([sailro](http://www.github.com/sailro))
+- If createEngine fails, a default engine will be created ([#8084](https://github.com/BabylonJS/Babylon.js/issues/8084)) ([RaananW](https://github.com/RaananW))
 
 ## Bugs