Load external libraries only once.
This commit is contained in:
parent
094189ce4f
commit
dde3e08687
13
source/external/externallibs.js
vendored
13
source/external/externallibs.js
vendored
@ -1,15 +1,26 @@
|
||||
OV.ExternalLibLocation = null;
|
||||
|
||||
OV.LoadedExternalLibs = {};
|
||||
|
||||
OV.LoadExternalLibrary = function (libName, callbacks)
|
||||
{
|
||||
if (OV.ExternalLibLocation === null) {
|
||||
callbacks.error ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (OV.LoadedExternalLibs[libName] !== undefined) {
|
||||
callbacks.success ();
|
||||
return;
|
||||
}
|
||||
|
||||
let scriptElement = document.createElement ('script');
|
||||
scriptElement.type = 'text/javascript';
|
||||
scriptElement.src = OV.ExternalLibLocation + '/' + libName;
|
||||
scriptElement.onload = callbacks.success;
|
||||
scriptElement.onload = function () {
|
||||
callbacks.success ();
|
||||
OV.LoadedExternalLibs[libName] = true;
|
||||
};
|
||||
scriptElement.onerror = callbacks.error;
|
||||
document.head.appendChild (scriptElement);
|
||||
};
|
||||
|
||||
15
source/external/rhinoexporter.js
vendored
15
source/external/rhinoexporter.js
vendored
@ -15,10 +15,17 @@ OV.Exporter3dm = class extends OV.ExporterBase
|
||||
{
|
||||
if (this.rhino === null) {
|
||||
let obj = this;
|
||||
rhino3dm ().then (function (rhino) {
|
||||
obj.rhino = rhino;
|
||||
obj.ExportRhinoContent (model, files, onFinish);
|
||||
});
|
||||
OV.LoadExternalLibrary ('rhino3dm.min.js', {
|
||||
success : function () {
|
||||
rhino3dm ().then (function (rhino) {
|
||||
obj.rhino = rhino;
|
||||
obj.ExportRhinoContent (model, files, onFinish);
|
||||
});
|
||||
},
|
||||
error : function () {
|
||||
onFinish ();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.ExportRhinoContent (model, files, onFinish);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user