Jump to content

[solved] PG: best way to load external script?


javalang
 Share

Recommended Posts

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);
});

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

@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 :)

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...