diff --git a/source/external/externallibs.js b/source/external/externallibs.js index 174f34c..c2a3344 100644 --- a/source/external/externallibs.js +++ b/source/external/externallibs.js @@ -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); }; diff --git a/source/external/rhinoexporter.js b/source/external/rhinoexporter.js index 9bf8f17..376de9f 100644 --- a/source/external/rhinoexporter.js +++ b/source/external/rhinoexporter.js @@ -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); }