Load occt-import-js from cdn.
This commit is contained in:
parent
722e8db2e9
commit
0dd11501aa
8
libs/loaders/occt-import-js-worker-cdn.js
Normal file
8
libs/loaders/occt-import-js-worker-cdn.js
Normal file
@ -0,0 +1,8 @@
|
||||
importScripts ('https://cdn.jsdelivr.net/npm/occt-import-js@0.0.4/dist/occt-import-js.js');
|
||||
|
||||
onmessage = async function (ev)
|
||||
{
|
||||
let occt = await occtimportjs ();
|
||||
let result = occt.ReadStepFile (ev.data);
|
||||
postMessage (result);
|
||||
};
|
||||
@ -34,7 +34,7 @@ export class ImporterStp extends ImporterBase
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
if (this.worker === null) {
|
||||
let workerPath = GetExternalLibPath ('loaders/occt-import-js-worker.js');
|
||||
let workerPath = GetExternalLibPath ('loaders/occt-import-js-worker-cdn.js');
|
||||
this.worker = new Worker (workerPath);
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import json
|
||||
|
||||
from lib import tools_lib as Tools
|
||||
|
||||
pickrFileMap = [
|
||||
[os.path.join ('@simonwep', 'pickr', 'LICENSE'), os.path.join ('pickr.license.md')],
|
||||
@ -67,13 +70,27 @@ def Main (argv):
|
||||
nodeModulesDir = os.path.join (rootDir, 'node_modules')
|
||||
libsDir = os.path.join (rootDir, 'libs')
|
||||
|
||||
package = None
|
||||
with open (os.path.join (rootDir, 'package.json')) as packageJson:
|
||||
package = json.load (packageJson)
|
||||
|
||||
UpdateModule (pickrFileMap, nodeModulesDir, libsDir)
|
||||
UpdateModule (threeJsFileMap, nodeModulesDir, libsDir)
|
||||
UpdateModule (dracoFileMap, nodeModulesDir, libsDir)
|
||||
UpdateModule (rhino3dmFileMap, nodeModulesDir, libsDir)
|
||||
UpdateModule (fflateFileMap, nodeModulesDir, libsDir)
|
||||
UpdateModule (webIfcFileMap, nodeModulesDir, libsDir)
|
||||
|
||||
UpdateModule (occtImportJsFileMap, nodeModulesDir, libsDir)
|
||||
occtImportJsVersion = package['dependencies']['occt-import-js']
|
||||
occtWorkerFile = os.path.join (libsDir, 'loaders', 'occt-import-js-worker.js')
|
||||
occtWorkerCdnFile = os.path.join (libsDir, 'loaders', 'occt-import-js-worker-cdn.js')
|
||||
shutil.copy (occtWorkerFile, occtWorkerCdnFile)
|
||||
Tools.ReplaceStringInFile (
|
||||
occtWorkerCdnFile,
|
||||
'occt-import-js.js',
|
||||
'https://cdn.jsdelivr.net/npm/occt-import-js@' + occtImportJsVersion + '/dist/occt-import-js.js'
|
||||
)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user