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 { MaterialType } from '../model/material.js';
|
||||
import { ConvertMeshToMeshBuffer } from '../model/meshbuffer.js';
|
||||
@ -20,7 +20,7 @@ export class Exporter3dm extends ExporterBase
|
||||
ExportContent (exporterModel, format, files, onFinish)
|
||||
{
|
||||
if (this.rhino === null) {
|
||||
LoadRhinoLibrary ().then (() => {
|
||||
LoadExternalLibrary ('rhino3dm').then (() => {
|
||||
rhino3dm ().then ((rhino) => {
|
||||
this.rhino = rhino;
|
||||
this.ExportRhinoContent (exporterModel, files, onFinish);
|
||||
|
||||
@ -8,7 +8,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 { LoadRhinoLibrary, UpdateMaterialTransparency } from './importerutils.js';
|
||||
import { LoadExternalLibrary, UpdateMaterialTransparency } from './importerutils.js';
|
||||
import { TextureMap } from '../model/material.js';
|
||||
import { Mesh } from '../model/mesh.js';
|
||||
import { Line } from '../model/line.js';
|
||||
@ -48,7 +48,7 @@ export class Importer3dm extends ImporterBase
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
if (this.rhino === null) {
|
||||
LoadRhinoLibrary ().then (() => {
|
||||
LoadExternalLibrary ('rhino3dm').then (() => {
|
||||
rhino3dm ().then ((rhino) => {
|
||||
this.rhino = rhino;
|
||||
this.ImportRhinoContent (fileContent);
|
||||
|
||||
@ -7,7 +7,6 @@ import { ArrayToQuaternion } from '../geometry/quaternion.js';
|
||||
import { Transformation } from '../geometry/transformation.js';
|
||||
import { BinaryReader } from '../io/binaryreader.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 { PhongMaterial, PhysicalMaterial, TextureMap } from '../model/material.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 { ImporterBase } from './importerbase.js';
|
||||
import { Loc, FLoc } from '../core/localization.js';
|
||||
import { LoadExternalLibrary } from './importerutils.js';
|
||||
|
||||
const GltfComponentType =
|
||||
{
|
||||
@ -282,7 +282,7 @@ class GltfExtensions
|
||||
return;
|
||||
}
|
||||
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) => {
|
||||
this.draco = draco;
|
||||
callbacks.onSuccess ();
|
||||
|
||||
@ -2,7 +2,7 @@ import { Coord3D } from '../geometry/coord3d.js';
|
||||
import { Direction } from '../geometry/geometry.js';
|
||||
import { Matrix } from '../geometry/matrix.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 { Mesh } from '../model/mesh.js';
|
||||
import { Property, PropertyGroup, PropertyType } from '../model/property.js';
|
||||
@ -44,7 +44,7 @@ export class ImporterIfc extends ImporterBase
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
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.Init ().then (() => {
|
||||
this.ImportIfcContent (fileContent);
|
||||
|
||||
@ -131,7 +131,13 @@ export function CreateOcctWorker (worker)
|
||||
});
|
||||
}
|
||||
|
||||
export function LoadRhinoLibrary ()
|
||||
export function LoadExternalLibrary (libraryName)
|
||||
{
|
||||
return LoadExternalLibraryFromUrl ('https://cdn.jsdelivr.net/npm/rhino3dm@8.4.0/rhino3dm.min.js');
|
||||
if (libraryName === 'rhino3dm') {
|
||||
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;
|
||||
}
|
||||
|
||||
export function LoadExternalLibrary (libName)
|
||||
export function LoadExternalLibraryFromLibs (libName)
|
||||
{
|
||||
return new Promise ((resolve, reject) => {
|
||||
if (externalLibLocation === null) {
|
||||
|
||||
@ -39,11 +39,11 @@ import { ImporterPly } from './import/importerply.js';
|
||||
import { ImporterStl } from './import/importerstl.js';
|
||||
import { ImporterThreeSvg } from './import/importersvg.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 { BinaryWriter } from './io/binarywriter.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 { TextWriter } from './io/textwriter.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,
|
||||
UpdateMaterialTransparency,
|
||||
CreateOcctWorker,
|
||||
LoadExternalLibrary,
|
||||
BinaryReader,
|
||||
BinaryWriter,
|
||||
ArrayBufferToUtf8String,
|
||||
@ -207,7 +208,7 @@ export {
|
||||
RevokeObjectUrl,
|
||||
SetExternalLibLocation,
|
||||
GetExternalLibPath,
|
||||
LoadExternalLibrary,
|
||||
LoadExternalLibraryFromLibs,
|
||||
LoadExternalLibraryFromUrl,
|
||||
GetFileName,
|
||||
GetFileExtension,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user