javalang Posted April 4, 2017 Share Posted April 4, 2017 Hi all, what is the best way to load an external script in playground? I have a playground and every time I start the browser an error message is displayed "Compilation error Line 7:15 - BABYLONX is not defined". If I press then the run button, everything works fine. I tried to move the document.appendChild() outside the createScene() function but no change. Maybe there is a better aproach? here is the playground: http://www.babylonjs-playground.com/#1MYQ3T#2 Thanks PS: I've tried following, but also without success: $.holdReady(true); $.getScript("https://rawgit.com/androdlang/Extensions/master/ClonerSystem/src/babylonx.cloner.js", function() { $.holdReady(false); }); Quote Link to comment Share on other sites More sharing options...
javalang Posted April 4, 2017 Author Share Posted April 4, 2017 I've found a workaround but it's really a hack var createScene = function () { var url = "https://rawgit.com/androdlang/Extensions/master/ClonerSystem/src/babylonx.cloner.js"; var s = document.createElement("script"); s.src = url;document.head.appendChild(s); var run=document.getElementById("runButton"); if (typeof BABYLONX === 'undefined') { // variable is undefined setTimeout(function(){run.click();},500) } http://www.babylonjs-playground.com/#1MYQ3T#10 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 4, 2017 Share Posted April 4, 2017 Hi guys! How about one more version? http://www.babylonjs-playground.com/#1MYQ3T#14 Might work, might not. I sound 'sure' of myself, eh? heh. I avoided demo.scene. I guess it wasn't needed. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 4, 2017 Share Posted April 4, 2017 If you want I can add the Cloner System by default on the PG Quote Link to comment Share on other sites More sharing options...
javalang Posted April 4, 2017 Author Share Posted April 4, 2017 @Wingnut Unfortunately there is a default constructor which detects empty arguments and instanciates an engine and a scene in parallel. So each time you reload, the whole scene is getting slower and slower. My idea was to absolutly minimize the overhead code for the demo. @Deltakosh Yes that would be fine, but on the other hand I will you not overload with pull requests (there will be a lot of activities next time) . If you could include my repro (https://rawgit.com/androdlang/Extensions/master/ClonerSystem/src/babylonx.cloner.js) that would be fine Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 4, 2017 Share Posted April 4, 2017 I prefer referencing the main repo Can you update these files? https://github.com/BabylonJS/Babylon.js/blob/master/Playground/index.html https://github.com/BabylonJS/Babylon.js/blob/master/Playground/frame.html https://github.com/BabylonJS/Babylon.js/blob/master/Playground/debug.html No worry for PR I'm a github addict Quote Link to comment Share on other sites More sharing options...
javalang Posted April 4, 2017 Author Share Posted April 4, 2017 @Deltakosh PERFECT!!! Thank you PG is working now as expected: http://www.babylonjs-playground.com/#1MYQ3T#16 Quote Link to comment Share on other sites More sharing options...
Temechon Posted April 4, 2017 Share Posted April 4, 2017 And to answer the question, for futur forum users : https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.tools.ts#L460 javalang 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.