Delay load rhino3dm so it will be loaded only if it's needed.
This commit is contained in:
parent
cca1b44096
commit
094189ce4f
@ -53,6 +53,7 @@
|
||||
<script type="text/javascript" src="../source/export/exporteroff.js"></script>
|
||||
<script type="text/javascript" src="../source/export/exportergltf.js"></script>
|
||||
<script type="text/javascript" src="../source/export/exporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/externallibs.js"></script>
|
||||
<script type="text/javascript" src="../source/external/rhinoimporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/rhinoexporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/threeutils.js"></script>
|
||||
|
||||
@ -54,6 +54,7 @@
|
||||
<script type="text/javascript" src="../source/export/exporteroff.js"></script>
|
||||
<script type="text/javascript" src="../source/export/exportergltf.js"></script>
|
||||
<script type="text/javascript" src="../source/export/exporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/externallibs.js"></script>
|
||||
<script type="text/javascript" src="../source/external/rhinoimporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/rhinoexporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/threeutils.js"></script>
|
||||
|
||||
@ -53,6 +53,7 @@
|
||||
<script type="text/javascript" src="../source/export/exporteroff.js"></script>
|
||||
<script type="text/javascript" src="../source/export/exportergltf.js"></script>
|
||||
<script type="text/javascript" src="../source/export/exporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/externallibs.js"></script>
|
||||
<script type="text/javascript" src="../source/external/rhinoimporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/rhinoexporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/threeutils.js"></script>
|
||||
|
||||
@ -53,6 +53,7 @@
|
||||
<script type="text/javascript" src="../source/export/exporteroff.js"></script>
|
||||
<script type="text/javascript" src="../source/export/exportergltf.js"></script>
|
||||
<script type="text/javascript" src="../source/export/exporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/externallibs.js"></script>
|
||||
<script type="text/javascript" src="../source/external/rhinoimporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/rhinoexporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/threeutils.js"></script>
|
||||
|
||||
15
source/external/externallibs.js
vendored
Normal file
15
source/external/externallibs.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
OV.ExternalLibLocation = null;
|
||||
|
||||
OV.LoadExternalLibrary = function (libName, callbacks)
|
||||
{
|
||||
if (OV.ExternalLibLocation === null) {
|
||||
callbacks.error ();
|
||||
return;
|
||||
}
|
||||
let scriptElement = document.createElement ('script');
|
||||
scriptElement.type = 'text/javascript';
|
||||
scriptElement.src = OV.ExternalLibLocation + '/' + libName;
|
||||
scriptElement.onload = callbacks.success;
|
||||
scriptElement.onerror = callbacks.error;
|
||||
document.head.appendChild (scriptElement);
|
||||
};
|
||||
15
source/external/rhinoimporter.js
vendored
15
source/external/rhinoimporter.js
vendored
@ -39,10 +39,17 @@ OV.Importer3dm = class extends OV.ImporterBase
|
||||
{
|
||||
if (this.rhino === null) {
|
||||
let obj = this;
|
||||
rhino3dm ().then (function (rhino) {
|
||||
obj.rhino = rhino;
|
||||
obj.ImportRhinoContent (fileContent);
|
||||
onFinish ();
|
||||
OV.LoadExternalLibrary ('rhino3dm.min.js', {
|
||||
success : function () {
|
||||
rhino3dm ().then (function (rhino) {
|
||||
obj.rhino = rhino;
|
||||
obj.ImportRhinoContent (fileContent);
|
||||
onFinish ();
|
||||
});
|
||||
},
|
||||
error : function () {
|
||||
onFinish ();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.ImportRhinoContent (fileContent);
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
{
|
||||
"lib_files" : [
|
||||
"libs/jquery-3.5.1.min.js",
|
||||
"libs/three.min-129.js",
|
||||
"libs/rhino3dm.min.js"
|
||||
"libs/three.min-129.js"
|
||||
],
|
||||
"importer_files" : [
|
||||
"source/core/core.js",
|
||||
@ -49,6 +48,7 @@
|
||||
"source/export/exporteroff.js",
|
||||
"source/export/exportergltf.js",
|
||||
"source/export/exporter.js",
|
||||
"source/external/externallibs.js",
|
||||
"source/external/rhinoimporter.js",
|
||||
"source/external/rhinoexporter.js",
|
||||
"source/external/threeutils.js",
|
||||
|
||||
@ -71,6 +71,11 @@ def CreateDestinationDir (config, rootDir, websiteDir, version, testBuild):
|
||||
replacer.ReplaceTokenFileLinks ('<!-- libs start -->', '<!-- libs end -->', libFiles, None)
|
||||
replacer.ReplaceTokenFileLinks ('<!-- importer start -->', '<!-- importer end -->', importerFiles, version)
|
||||
replacer.ReplaceTokenFileLinks ('<!-- website start -->', '<!-- website end -->', websiteFiles, version)
|
||||
externalScriptContent = ''
|
||||
externalScriptContent += '<script type="text/javascript">' + replacer.eolChar
|
||||
externalScriptContent += ' OV.ExternalLibLocation = \'libs\';' + replacer.eolChar
|
||||
externalScriptContent += '</script>'
|
||||
replacer.ReplaceTokenContent ('<!-- externals start -->', '<!-- externals end -->', externalScriptContent)
|
||||
metaFile = os.path.join (rootDir, 'tools', 'website_meta_data.txt')
|
||||
if os.path.exists (metaFile):
|
||||
metaContent = Tools.GetFileContent (metaFile)
|
||||
|
||||
@ -57,7 +57,10 @@ class TokenReplacer:
|
||||
def ReplaceContent (self, begToken, endToken, begPosition, endPosition, linePrefix, newContent):
|
||||
if self.keepToken:
|
||||
newContent = linePrefix + begToken + self.eolChar + newContent + self.eolChar + linePrefix + endToken
|
||||
self.fileContent = self.fileContent.replace (self.fileContent[begPosition : endPosition], newContent)
|
||||
self.ReplaceString (self.fileContent[begPosition : endPosition], newContent)
|
||||
|
||||
def ReplaceString (self, oldString, newString):
|
||||
self.fileContent = self.fileContent.replace (oldString, newString)
|
||||
|
||||
def GetTokenBegPosition (self, begToken):
|
||||
begPosition = self.fileContent.find (begToken)
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
<!-- libs start -->
|
||||
<script type="text/javascript" src="../libs/jquery-3.5.1.min.js"></script>
|
||||
<script type="text/javascript" src="../libs/three.min-129.js"></script>
|
||||
<script type="text/javascript" src="../libs/rhino3dm.min.js"></script>
|
||||
<!-- libs end -->
|
||||
|
||||
<!-- importer start -->
|
||||
@ -62,6 +61,7 @@
|
||||
<script type="text/javascript" src="../source/export/exporteroff.js"></script>
|
||||
<script type="text/javascript" src="../source/export/exportergltf.js"></script>
|
||||
<script type="text/javascript" src="../source/export/exporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/externallibs.js"></script>
|
||||
<script type="text/javascript" src="../source/external/rhinoimporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/rhinoexporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/threeutils.js"></script>
|
||||
@ -99,7 +99,13 @@
|
||||
<!-- analytics start -->
|
||||
<!-- analytics end -->
|
||||
|
||||
<script type='text/javascript'>
|
||||
<!-- externals start -->
|
||||
<script type="text/javascript">
|
||||
OV.ExternalLibLocation = '../libs';
|
||||
</script>
|
||||
<!-- externals end -->
|
||||
|
||||
<script type="text/javascript">
|
||||
$(window).on ('load', function () {
|
||||
let embed = new OV.Embed ({
|
||||
viewerDiv : $('#embed_viewer'),
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
<!-- libs start -->
|
||||
<script type="text/javascript" src="../libs/jquery-3.5.1.min.js"></script>
|
||||
<script type="text/javascript" src="../libs/three.min-129.js"></script>
|
||||
<script type="text/javascript" src="../libs/rhino3dm.min.js"></script>
|
||||
<!-- libs end -->
|
||||
|
||||
<!-- meta start -->
|
||||
@ -62,6 +61,7 @@
|
||||
<script type="text/javascript" src="../source/export/exporteroff.js"></script>
|
||||
<script type="text/javascript" src="../source/export/exportergltf.js"></script>
|
||||
<script type="text/javascript" src="../source/export/exporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/externallibs.js"></script>
|
||||
<script type="text/javascript" src="../source/external/rhinoimporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/rhinoexporter.js"></script>
|
||||
<script type="text/javascript" src="../source/external/threeutils.js"></script>
|
||||
@ -96,7 +96,13 @@
|
||||
<script type="text/javascript" src="o3dv/embed.js"></script>
|
||||
<!-- website end -->
|
||||
|
||||
<script type='text/javascript'>
|
||||
<!-- externals start -->
|
||||
<script type="text/javascript">
|
||||
OV.ExternalLibLocation = '../libs';
|
||||
</script>
|
||||
<!-- externals end -->
|
||||
|
||||
<script type="text/javascript">
|
||||
$(window).on ('load', function () {
|
||||
let website = new OV.Website ({
|
||||
headerDiv : $('#header'),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user