Restructure libs.

This commit is contained in:
kovacsv 2021-08-10 19:24:59 +02:00
parent 294ae6a975
commit 1e6e6b65af
15 changed files with 1415 additions and 27 deletions

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@ OV.Importer3dm = class extends OV.ImporterBase
ImportContent (fileContent, onFinish)
{
if (this.rhino === null) {
OV.LoadExternalLibrary ('rhino3dm.min.js').then (() => {
OV.LoadExternalLibrary ('loaders/rhino3dm.min.js').then (() => {
rhino3dm ().then ((rhino) => {
this.rhino = rhino;
this.ImportRhinoContent (fileContent);

View File

@ -271,7 +271,7 @@ OV.GltfExtensions = class
return;
}
if (this.draco === null && extensionsRequired.indexOf ('KHR_draco_mesh_compression') !== -1) {
OV.LoadExternalLibrary ('draco_decoder.js').then (() => {
OV.LoadExternalLibrary ('loaders/draco_decoder.js').then (() => {
DracoDecoderModule ().then ((draco) => {
this.draco = draco;
callbacks.onSuccess ();

View File

@ -38,7 +38,7 @@ OV.ImporterIfc = class extends OV.ImporterBase
ImportContent (fileContent, onFinish)
{
if (this.ifc === null) {
OV.LoadExternalLibrary ('web-ifc-api.js').then (() => {
OV.LoadExternalLibrary ('loaders/web-ifc-api.js').then (() => {
this.ifc = new IfcAPI ();
this.ifc.Init ().then (() => {
this.ImportIfcContent (fileContent);

View File

@ -24,6 +24,11 @@ OV.ThreeLoader = class
{
}
GetUpDirection ()
{
return null;
}
};
OV.ThreeLoaderFbx = class extends OV.ThreeLoader
@ -61,6 +66,11 @@ OV.ThreeLoaderFbx = class extends OV.ThreeLoader
}
});
}
GetUpDirection ()
{
return OV.Direction.Y;
}
};
OV.ThreeLoaderDae = class extends OV.ThreeLoader
@ -97,6 +107,11 @@ OV.ThreeLoaderDae = class extends OV.ThreeLoader
}
});
}
GetUpDirection ()
{
return OV.Direction.Y;
}
};
OV.ThreeLoaderVrml = class extends OV.ThreeLoader
@ -145,6 +160,51 @@ OV.ThreeLoaderVrml = class extends OV.ThreeLoader
}
});
}
GetUpDirection ()
{
return OV.Direction.Y;
}
};
OV.ThreeLoader3mf = class extends OV.ThreeLoader
{
constructor ()
{
super ();
}
GetExtension ()
{
return '3mf';
}
GetExternalLibraries ()
{
return [
'three_loaders/fflate.min.js',
'three_loaders/3MFLoader.js'
];
}
CreateLoader (manager)
{
return new THREE.ThreeMFLoader (manager);
}
EnumerateMeshes (loadedObject, processor)
{
loadedObject.traverse ((child) => {
if (child.isMesh) {
processor (child);
}
});
}
GetUpDirection ()
{
return OV.Direction.Z;
}
};
OV.ThreeImporter = class extends OV.ImporterBase
@ -155,7 +215,8 @@ OV.ThreeImporter = class extends OV.ImporterBase
this.loaders = [
new OV.ThreeLoaderFbx (),
new OV.ThreeLoaderDae (),
new OV.ThreeLoaderVrml ()
new OV.ThreeLoaderVrml (),
new OV.ThreeLoader3mf ()
];
}
@ -182,17 +243,17 @@ OV.ThreeImporter = class extends OV.ImporterBase
GetUpDirection ()
{
return OV.Direction.Y;
return this.loader.GetUpDirection ();
}
ClearContent ()
{
this.loader = null;
}
ResetContent ()
{
this.loader = null;
}
ImportContent (fileContent, onFinish)
@ -209,20 +270,20 @@ OV.ThreeImporter = class extends OV.ImporterBase
onFinish ();
}
const loader = this.FindLoader ();
if (loader === null) {
this.loader = this.FindLoader ();
if (this.loader === null) {
onFinish ();
return;
}
const libraries = loader.GetExternalLibraries ();
const libraries = this.loader.GetExternalLibraries ();
if (libraries === null) {
onFinish ();
return;
}
LoadLibraries (libraries, () => {
this.LoadModel (loader, fileContent, onFinish);
this.LoadModel (fileContent, onFinish);
}, () => {
onFinish ();
});
@ -239,13 +300,13 @@ OV.ThreeImporter = class extends OV.ImporterBase
return null;
}
LoadModel (loader, fileContent, onFinish)
LoadModel (fileContent, onFinish)
{
let loadedObject = null;
let externalFileNames = {};
let loadingManager = new THREE.LoadingManager (() => {
if (loadedObject !== null) {
this.OnThreeObjectsLoaded (loader, loadedObject, externalFileNames, onFinish);
this.OnThreeObjectsLoaded (loadedObject, externalFileNames, onFinish);
}
});
@ -269,8 +330,7 @@ OV.ThreeImporter = class extends OV.ImporterBase
return url;
});
const threeLoader = loader.CreateLoader (loadingManager);
const threeLoader = this.loader.CreateLoader (loadingManager);
if (threeLoader === null) {
onFinish ();
return;
@ -290,7 +350,7 @@ OV.ThreeImporter = class extends OV.ImporterBase
);
}
OnThreeObjectsLoaded (loader, loadedObject, externalFileNames, onFinish)
OnThreeObjectsLoaded (loadedObject, externalFileNames, onFinish)
{
function ConvertThreeMaterialToMaterial (threeMaterial, externalFileNames)
{
@ -378,7 +438,7 @@ OV.ThreeImporter = class extends OV.ImporterBase
}
let materialIdToIndex = {};
loader.EnumerateMeshes (loadedObject, (child) => {
this.loader.EnumerateMeshes (loadedObject, (child) => {
let materialIndex = null;
let mesh = null;
if (Array.isArray (child.material)) {

View File

@ -109,20 +109,12 @@ def CreatePackage (rootDir, websiteDir, packageDir, version):
'three.min-129.js',
'three.license.md'
]
externalLibs = [
'draco_decoder.js',
'draco_decoder.wasm',
'draco.license.md',
'rhino3dm.min.js',
'rhino3dm.wasm',
'rhino3dm.license.md'
]
zipPath = os.path.join (packageDir, 'o3dv_' + version + '.zip')
zip = zipfile.ZipFile (zipPath, mode = 'w', compression = zipfile.ZIP_DEFLATED)
for lib in libs:
zip.write (os.path.join (websiteDir, 'libs', lib), lib)
for lib in externalLibs:
zip.write (os.path.join (websiteDir, 'libs', lib), 'libs/' + lib)
for lib in os.listdir (os.path.join (websiteDir, 'libs', 'loaders')):
zip.write (os.path.join (websiteDir, 'libs', 'loaders', lib), 'libs/loaders/' + lib)
for lib in os.listdir (os.path.join (websiteDir, 'libs', 'three_loaders')):
zip.write (os.path.join (websiteDir, 'libs', 'three_loaders', lib), 'libs/three_loaders/' + lib)
zip.write (os.path.join (websiteDir, 'o3dv', 'o3dv.min.js'), 'o3dv.min-' + version + '.js')