Move CDN handling to a common place.
This commit is contained in:
parent
0c4df9f4fe
commit
6311e69163
@ -1,4 +1,4 @@
|
|||||||
import { LoadRhinoLibrary } from '../import/importerutils.js';
|
import { LoadExternalLibrary } from '../import/importerutils.js';
|
||||||
import { FileFormat } from '../io/fileutils.js';
|
import { FileFormat } from '../io/fileutils.js';
|
||||||
import { MaterialType } from '../model/material.js';
|
import { MaterialType } from '../model/material.js';
|
||||||
import { ConvertMeshToMeshBuffer } from '../model/meshbuffer.js';
|
import { ConvertMeshToMeshBuffer } from '../model/meshbuffer.js';
|
||||||
@ -20,7 +20,7 @@ export class Exporter3dm extends ExporterBase
|
|||||||
ExportContent (exporterModel, format, files, onFinish)
|
ExportContent (exporterModel, format, files, onFinish)
|
||||||
{
|
{
|
||||||
if (this.rhino === null) {
|
if (this.rhino === null) {
|
||||||
LoadRhinoLibrary ().then (() => {
|
LoadExternalLibrary ('rhino3dm').then (() => {
|
||||||
rhino3dm ().then ((rhino) => {
|
rhino3dm ().then ((rhino) => {
|
||||||
this.rhino = rhino;
|
this.rhino = rhino;
|
||||||
this.ExportRhinoContent (exporterModel, files, onFinish);
|
this.ExportRhinoContent (exporterModel, files, onFinish);
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { IsModelEmpty } from '../model/modelutils.js';
|
|||||||
import { Property, PropertyGroup, PropertyType } from '../model/property.js';
|
import { Property, PropertyGroup, PropertyType } from '../model/property.js';
|
||||||
import { ConvertThreeGeometryToMesh } from '../threejs/threeutils.js';
|
import { ConvertThreeGeometryToMesh } from '../threejs/threeutils.js';
|
||||||
import { ImporterBase } from './importerbase.js';
|
import { ImporterBase } from './importerbase.js';
|
||||||
import { LoadRhinoLibrary, UpdateMaterialTransparency } from './importerutils.js';
|
import { LoadExternalLibrary, UpdateMaterialTransparency } from './importerutils.js';
|
||||||
import { TextureMap } from '../model/material.js';
|
import { TextureMap } from '../model/material.js';
|
||||||
import { Mesh } from '../model/mesh.js';
|
import { Mesh } from '../model/mesh.js';
|
||||||
import { Line } from '../model/line.js';
|
import { Line } from '../model/line.js';
|
||||||
@ -48,7 +48,7 @@ export class Importer3dm extends ImporterBase
|
|||||||
ImportContent (fileContent, onFinish)
|
ImportContent (fileContent, onFinish)
|
||||||
{
|
{
|
||||||
if (this.rhino === null) {
|
if (this.rhino === null) {
|
||||||
LoadRhinoLibrary ().then (() => {
|
LoadExternalLibrary ('rhino3dm').then (() => {
|
||||||
rhino3dm ().then ((rhino) => {
|
rhino3dm ().then ((rhino) => {
|
||||||
this.rhino = rhino;
|
this.rhino = rhino;
|
||||||
this.ImportRhinoContent (fileContent);
|
this.ImportRhinoContent (fileContent);
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import { ArrayToQuaternion } from '../geometry/quaternion.js';
|
|||||||
import { Transformation } from '../geometry/transformation.js';
|
import { Transformation } from '../geometry/transformation.js';
|
||||||
import { BinaryReader } from '../io/binaryreader.js';
|
import { BinaryReader } from '../io/binaryreader.js';
|
||||||
import { ArrayBufferToUtf8String, Base64DataURIToArrayBuffer, GetFileExtensionFromMimeType } from '../io/bufferutils.js';
|
import { ArrayBufferToUtf8String, Base64DataURIToArrayBuffer, GetFileExtensionFromMimeType } from '../io/bufferutils.js';
|
||||||
import { LoadExternalLibraryFromUrl } from '../io/externallibs.js';
|
|
||||||
import { RGBColor, ColorComponentFromFloat, RGBColorFromFloatComponents, LinearToSRGB } from '../model/color.js';
|
import { RGBColor, ColorComponentFromFloat, RGBColorFromFloatComponents, LinearToSRGB } from '../model/color.js';
|
||||||
import { PhongMaterial, PhysicalMaterial, TextureMap } from '../model/material.js';
|
import { PhongMaterial, PhysicalMaterial, TextureMap } from '../model/material.js';
|
||||||
import { Mesh } from '../model/mesh.js';
|
import { Mesh } from '../model/mesh.js';
|
||||||
@ -16,6 +15,7 @@ import { Property, PropertyGroup, PropertyType } from '../model/property.js';
|
|||||||
import { Triangle } from '../model/triangle.js';
|
import { Triangle } from '../model/triangle.js';
|
||||||
import { ImporterBase } from './importerbase.js';
|
import { ImporterBase } from './importerbase.js';
|
||||||
import { Loc, FLoc } from '../core/localization.js';
|
import { Loc, FLoc } from '../core/localization.js';
|
||||||
|
import { LoadExternalLibrary } from './importerutils.js';
|
||||||
|
|
||||||
const GltfComponentType =
|
const GltfComponentType =
|
||||||
{
|
{
|
||||||
@ -282,7 +282,7 @@ class GltfExtensions
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.draco === null && extensionsRequired.indexOf ('KHR_draco_mesh_compression') !== -1) {
|
if (this.draco === null && extensionsRequired.indexOf ('KHR_draco_mesh_compression') !== -1) {
|
||||||
LoadExternalLibraryFromUrl ('https://cdn.jsdelivr.net/npm/draco3d@1.5.7/draco_decoder_nodejs.min.js').then (() => {
|
LoadExternalLibrary ('draco3d').then (() => {
|
||||||
DracoDecoderModule ().then ((draco) => {
|
DracoDecoderModule ().then ((draco) => {
|
||||||
this.draco = draco;
|
this.draco = draco;
|
||||||
callbacks.onSuccess ();
|
callbacks.onSuccess ();
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Coord3D } from '../geometry/coord3d.js';
|
|||||||
import { Direction } from '../geometry/geometry.js';
|
import { Direction } from '../geometry/geometry.js';
|
||||||
import { Matrix } from '../geometry/matrix.js';
|
import { Matrix } from '../geometry/matrix.js';
|
||||||
import { Transformation } from '../geometry/transformation.js';
|
import { Transformation } from '../geometry/transformation.js';
|
||||||
import { LoadExternalLibrary } from '../io/externallibs.js';
|
import { LoadExternalLibraryFromLibs } from '../io/externallibs.js';
|
||||||
import { RGBColorFromFloatComponents } from '../model/color.js';
|
import { RGBColorFromFloatComponents } from '../model/color.js';
|
||||||
import { Mesh } from '../model/mesh.js';
|
import { Mesh } from '../model/mesh.js';
|
||||||
import { Property, PropertyGroup, PropertyType } from '../model/property.js';
|
import { Property, PropertyGroup, PropertyType } from '../model/property.js';
|
||||||
@ -44,7 +44,7 @@ export class ImporterIfc extends ImporterBase
|
|||||||
ImportContent (fileContent, onFinish)
|
ImportContent (fileContent, onFinish)
|
||||||
{
|
{
|
||||||
if (this.ifc === null) {
|
if (this.ifc === null) {
|
||||||
LoadExternalLibrary ('web-ifc-api-browser.js').then (() => {
|
LoadExternalLibraryFromLibs ('web-ifc-api-browser.js').then (() => {
|
||||||
this.ifc = new WebIFC.IfcAPI ();
|
this.ifc = new WebIFC.IfcAPI ();
|
||||||
this.ifc.Init ().then (() => {
|
this.ifc.Init ().then (() => {
|
||||||
this.ImportIfcContent (fileContent);
|
this.ImportIfcContent (fileContent);
|
||||||
|
|||||||
@ -131,7 +131,13 @@ export function CreateOcctWorker (worker)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LoadRhinoLibrary ()
|
export function LoadExternalLibrary (libraryName)
|
||||||
{
|
{
|
||||||
|
if (libraryName === 'rhino3dm') {
|
||||||
return LoadExternalLibraryFromUrl ('https://cdn.jsdelivr.net/npm/rhino3dm@8.4.0/rhino3dm.min.js');
|
return LoadExternalLibraryFromUrl ('https://cdn.jsdelivr.net/npm/rhino3dm@8.4.0/rhino3dm.min.js');
|
||||||
|
} else if (libraryName === 'draco3d') {
|
||||||
|
return LoadExternalLibraryFromUrl ('https://cdn.jsdelivr.net/npm/draco3d@1.5.7/draco_decoder_nodejs.min.js');
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export function GetExternalLibPath (libName)
|
|||||||
return externalLibLocation + '/' + libName;
|
return externalLibLocation + '/' + libName;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LoadExternalLibrary (libName)
|
export function LoadExternalLibraryFromLibs (libName)
|
||||||
{
|
{
|
||||||
return new Promise ((resolve, reject) => {
|
return new Promise ((resolve, reject) => {
|
||||||
if (externalLibLocation === null) {
|
if (externalLibLocation === null) {
|
||||||
|
|||||||
@ -39,11 +39,11 @@ import { ImporterPly } from './import/importerply.js';
|
|||||||
import { ImporterStl } from './import/importerstl.js';
|
import { ImporterStl } from './import/importerstl.js';
|
||||||
import { ImporterThreeSvg } from './import/importersvg.js';
|
import { ImporterThreeSvg } from './import/importersvg.js';
|
||||||
import { ImporterThreeBase, ImporterThreeFbx, ImporterThreeDae, ImporterThreeWrl, ImporterThree3mf, ImporterThreeAmf } from './import/importerthree.js';
|
import { ImporterThreeBase, ImporterThreeFbx, ImporterThreeDae, ImporterThreeWrl, ImporterThree3mf, ImporterThreeAmf } from './import/importerthree.js';
|
||||||
import { ColorToMaterialConverter, NameFromLine, ParametersFromLine, ReadLines, IsPowerOfTwo, NextPowerOfTwo, UpdateMaterialTransparency, CreateOcctWorker } from './import/importerutils.js';
|
import { ColorToMaterialConverter, NameFromLine, ParametersFromLine, ReadLines, IsPowerOfTwo, NextPowerOfTwo, UpdateMaterialTransparency, CreateOcctWorker, LoadExternalLibrary } from './import/importerutils.js';
|
||||||
import { BinaryReader } from './io/binaryreader.js';
|
import { BinaryReader } from './io/binaryreader.js';
|
||||||
import { BinaryWriter } from './io/binarywriter.js';
|
import { BinaryWriter } from './io/binarywriter.js';
|
||||||
import { ArrayBufferToUtf8String, ArrayBufferToAsciiString, AsciiStringToArrayBuffer, Utf8StringToArrayBuffer, Base64DataURIToArrayBuffer, GetFileExtensionFromMimeType, CreateObjectUrl, CreateObjectUrlWithMimeType, RevokeObjectUrl } from './io/bufferutils.js';
|
import { ArrayBufferToUtf8String, ArrayBufferToAsciiString, AsciiStringToArrayBuffer, Utf8StringToArrayBuffer, Base64DataURIToArrayBuffer, GetFileExtensionFromMimeType, CreateObjectUrl, CreateObjectUrlWithMimeType, RevokeObjectUrl } from './io/bufferutils.js';
|
||||||
import { SetExternalLibLocation, GetExternalLibPath, LoadExternalLibrary, LoadExternalLibraryFromUrl } from './io/externallibs.js';
|
import { SetExternalLibLocation, GetExternalLibPath, LoadExternalLibraryFromLibs, LoadExternalLibraryFromUrl } from './io/externallibs.js';
|
||||||
import { GetFileName, GetFileExtension, RequestUrl, ReadFile, TransformFileHostUrls, IsUrl, FileSource, FileFormat } from './io/fileutils.js';
|
import { GetFileName, GetFileExtension, RequestUrl, ReadFile, TransformFileHostUrls, IsUrl, FileSource, FileFormat } from './io/fileutils.js';
|
||||||
import { TextWriter } from './io/textwriter.js';
|
import { TextWriter } from './io/textwriter.js';
|
||||||
import { RGBColor, RGBAColor, ColorComponentFromFloat, ColorComponentToFloat, RGBColorFromFloatComponents, SRGBToLinear, LinearToSRGB, IntegerToHexString, RGBColorToHexString, RGBAColorToHexString, HexStringToRGBColor, HexStringToRGBAColor, ArrayToRGBColor, RGBColorIsEqual } from './model/color.js';
|
import { RGBColor, RGBAColor, ColorComponentFromFloat, ColorComponentToFloat, RGBColorFromFloatComponents, SRGBToLinear, LinearToSRGB, IntegerToHexString, RGBColorToHexString, RGBAColorToHexString, HexStringToRGBColor, HexStringToRGBAColor, ArrayToRGBColor, RGBColorIsEqual } from './model/color.js';
|
||||||
@ -194,6 +194,7 @@ export {
|
|||||||
NextPowerOfTwo,
|
NextPowerOfTwo,
|
||||||
UpdateMaterialTransparency,
|
UpdateMaterialTransparency,
|
||||||
CreateOcctWorker,
|
CreateOcctWorker,
|
||||||
|
LoadExternalLibrary,
|
||||||
BinaryReader,
|
BinaryReader,
|
||||||
BinaryWriter,
|
BinaryWriter,
|
||||||
ArrayBufferToUtf8String,
|
ArrayBufferToUtf8String,
|
||||||
@ -207,7 +208,7 @@ export {
|
|||||||
RevokeObjectUrl,
|
RevokeObjectUrl,
|
||||||
SetExternalLibLocation,
|
SetExternalLibLocation,
|
||||||
GetExternalLibPath,
|
GetExternalLibPath,
|
||||||
LoadExternalLibrary,
|
LoadExternalLibraryFromLibs,
|
||||||
LoadExternalLibraryFromUrl,
|
LoadExternalLibraryFromUrl,
|
||||||
GetFileName,
|
GetFileName,
|
||||||
GetFileExtension,
|
GetFileExtension,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user