I only need the three.js library if users choose a certain option. It is loaded like this. (and called like this "var motion = bd.code.tcCrowdSim.wglRndr(a,b)". Is it possible to unload after use? tia
Ext.define('bd.code.tcCrowdSim', {
statics: {
wglRndr: function (caller, data) {
this.preLoader(caller, data);
},
preLoader: function(caller, data) {
Ext.Loader.loadScript({
url: 'js/Three.js',
scope: this,
onLoad: function() {
Ext.Loader.loadScript({
url: 'js/ShaderExtrasCrowd.js',
scope: this,
onLoad: function() {
Ext.Loader.loadScript({
url: 'js/PostProcessingCrowd.js',
scope: this,
onLoad: function() {
this.crowd2(caller, data);
}
})
}
})
}
})
},
crowd2: function(caller,data) { .....
.... not sure whether editing original or adding comment to specific answer is best way of communication?
init : function(){
var len = $('script[src*="js/Three2.js"]').length;
if (len === 0) {
console.log('SCRIPNOTLOADED');
this.preLoader(this.caller, this.data); // preLoader.onLoad calls doScene
}
else{
this.doScene(this.caller, this.data);
}
},
code detects whether js loaded, and adding
preLoader: function(caller, data) {
Ext.Loader.setConfig({
preserveScripts: false
})
Ext.Loader.loadScript({ .....
forces a load every time suggesting that the scripts are being flushed? Since it is kicked off with
this.motion = bd.code.tcCrowdSim.wglRndr(a,b)
from a Deft ViewController, wondering when "False to remove and optionally garbage-collect asynchronously loaded scripts" is applied? Overhead-wise the canvas object holding all the webGL/Threejs stuff is created on an extjs popup window that is modal, so user closes window to continue. At this point is it true to say that there is no associated html/dom footprint?. Maybe this is more significant than having two versions of ThreeJS loaded?