-
-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use hosted version of occt-import-js.
- Loading branch information
Showing
12 changed files
with
121 additions
and
625 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { LoadRhinoLibrary } from '../import/importerutils.js'; | ||
import { LoadExternalLibraryFromUrl } from '../io/externallibs.js'; | ||
import { FileFormat } from '../io/fileutils.js'; | ||
import { MaterialType } from '../model/material.js'; | ||
|
@@ -20,7 +21,7 @@ export class Exporter3dm extends ExporterBase | |
ExportContent (exporterModel, format, files, onFinish) | ||
{ | ||
if (this.rhino === null) { | ||
LoadExternalLibraryFromUrl ('https://cdn.jsdelivr.net/npm/[email protected]/rhino3dm.min.js').then (() => { | ||
LoadRhinoLibrary ().then (() => { | ||
rhino3dm ().then ((rhino) => { | ||
this.rhino = rhino; | ||
this.ExportRhinoContent (exporterModel, files, onFinish); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import { IsModelEmpty } from '../model/modelutils.js'; | |
import { Property, PropertyGroup, PropertyType } from '../model/property.js'; | ||
import { ConvertThreeGeometryToMesh } from '../threejs/threeutils.js'; | ||
import { ImporterBase } from './importerbase.js'; | ||
import { UpdateMaterialTransparency } from './importerutils.js'; | ||
import { LoadRhinoLibrary, UpdateMaterialTransparency } from './importerutils.js'; | ||
import { TextureMap } from '../model/material.js'; | ||
import { Mesh } from '../model/mesh.js'; | ||
import { Line } from '../model/line.js'; | ||
|
@@ -49,7 +49,7 @@ export class Importer3dm extends ImporterBase | |
ImportContent (fileContent, onFinish) | ||
{ | ||
if (this.rhino === null) { | ||
LoadExternalLibraryFromUrl ('https://cdn.jsdelivr.net/npm/[email protected]/rhino3dm.min.js').then (() => { | ||
LoadRhinoLibrary ().then (() => { | ||
rhino3dm ().then ((rhino) => { | ||
this.rhino = rhino; | ||
this.ImportRhinoContent (fileContent); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { IsLower } from '../geometry/geometry.js'; | ||
import { PhongMaterial } from '../model/material.js'; | ||
import { RGBColor, IntegerToHexString } from '../model/color.js'; | ||
import { LoadExternalLibraryFromUrl } from '../io/externallibs.js'; | ||
|
||
export function NameFromLine (line, startIndex, commentChar) | ||
{ | ||
|
@@ -100,3 +101,37 @@ export class ColorToMaterialConverter | |
} | ||
} | ||
} | ||
|
||
let occtWorkerUrl = null; | ||
|
||
export function CreateOcctWorker (worker) | ||
{ | ||
return new Promise ((resolve, reject) => { | ||
if (occtWorkerUrl !== null) { | ||
resolve (new Worker (occtWorkerUrl)); | ||
return; | ||
} | ||
|
||
let baseUrl = 'https://cdn.jsdelivr.net/npm/[email protected]/dist/'; | ||
fetch (baseUrl + 'occt-import-js-worker.js') | ||
.then ((response) => { | ||
if (!response.ok) { | ||
return reject (); | ||
} | ||
return response.text (); | ||
}) | ||
.then ((workerScript) => { | ||
workerScript = workerScript.replace ('occt-import-js.js', baseUrl + 'occt-import-js.js'); | ||
workerScript = workerScript.replace ('return path', 'return \'' + baseUrl + 'occt-import-js.wasm\''); | ||
let blob = new Blob ([workerScript], { type : 'text/javascript' }); | ||
occtWorkerUrl = URL.createObjectURL (blob); | ||
return resolve (new Worker (occtWorkerUrl)); | ||
}) | ||
.catch (reject); | ||
}); | ||
} | ||
|
||
export function LoadRhinoLibrary () | ||
{ | ||
return LoadExternalLibraryFromUrl ('https://cdn.jsdelivr.net/npm/[email protected]/rhino3dm.min.js'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters