Pass original file name and extension to importers.
This commit is contained in:
parent
5bd71dd50c
commit
fb3cdbe83c
@ -139,7 +139,7 @@ OV.Importer = class
|
||||
return fileBuffer;
|
||||
});
|
||||
|
||||
importer.Import (mainFile.file.content, mainFile.file.extension, {
|
||||
importer.Import (mainFile.file.name, mainFile.file.extension, mainFile.file.content, {
|
||||
getDefaultMaterial : () => {
|
||||
let material = new OV.Material (OV.MaterialType.Phong);
|
||||
material.color = settings.defaultColor;
|
||||
@ -152,12 +152,9 @@ OV.Importer = class
|
||||
return buffers.GetTextureBuffer (filePath);
|
||||
},
|
||||
onSuccess : () => {
|
||||
this.model = importer.GetModel ();
|
||||
this.model.SetName (mainFile.file.name);
|
||||
|
||||
let result = new OV.ImportResult ();
|
||||
result.mainFile = mainFile.file.name;
|
||||
result.model = this.model;
|
||||
result.model = importer.GetModel ();
|
||||
result.usedFiles = this.usedFiles;
|
||||
result.missingFiles = this.missingFiles;
|
||||
result.upVector = importer.GetUpDirection ();
|
||||
|
||||
@ -5,10 +5,11 @@ OV.ImporterBase = class
|
||||
|
||||
}
|
||||
|
||||
Import (content, extension, callbacks)
|
||||
Import (name, extension, content, callbacks)
|
||||
{
|
||||
this.Clear ();
|
||||
|
||||
this.name = name;
|
||||
this.extension = extension;
|
||||
this.callbacks = callbacks;
|
||||
this.model = new OV.Model ();
|
||||
@ -22,6 +23,7 @@ OV.ImporterBase = class
|
||||
|
||||
Clear ()
|
||||
{
|
||||
this.name = null;
|
||||
this.extension = null;
|
||||
this.callbacks = null;
|
||||
this.model = null;
|
||||
@ -46,6 +48,7 @@ OV.ImporterBase = class
|
||||
}
|
||||
|
||||
OV.FinalizeModel (this.model, this.callbacks.getDefaultMaterial);
|
||||
|
||||
callbacks.onSuccess ();
|
||||
callbacks.onComplete ();
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ describe ('Exporter', function () {
|
||||
|
||||
let contentBuffer = stlFile.GetBufferContent ();
|
||||
let importer = new OV.ImporterStl ();
|
||||
importer.Import (contentBuffer, 'stl', {
|
||||
importer.Import (stlFile.GetName (), 'stl', contentBuffer, {
|
||||
getDefaultMaterial () {
|
||||
return new OV.Material (OV.MaterialType.Phong);
|
||||
},
|
||||
@ -306,7 +306,7 @@ describe ('Exporter', function () {
|
||||
|
||||
let contentBuffer = plyFile.GetBufferContent ();
|
||||
let importer = new OV.ImporterPly ();
|
||||
importer.Import (contentBuffer, 'ply', {
|
||||
importer.Import (plyFile.GetName (), 'ply', contentBuffer, {
|
||||
getDefaultMaterial () {
|
||||
return new OV.Material (OV.MaterialType.Phong);
|
||||
},
|
||||
@ -336,7 +336,7 @@ describe ('Exporter', function () {
|
||||
|
||||
let contentBuffer = gltfFile.GetBufferContent ();
|
||||
let importer = new OV.ImporterGltf ();
|
||||
importer.Import (contentBuffer, 'gltf', {
|
||||
importer.Import (gltfFile.GetName (), 'gltf', contentBuffer, {
|
||||
getDefaultMaterial () {
|
||||
return new OV.Material (OV.MaterialType.Phong);
|
||||
},
|
||||
@ -374,7 +374,7 @@ describe ('Exporter', function () {
|
||||
|
||||
let contentBuffer = glbFile.GetBufferContent ();
|
||||
let importer = new OV.ImporterGltf ();
|
||||
importer.Import (contentBuffer, 'glb', {
|
||||
importer.Import (glbFile.GetName (), 'glb', contentBuffer, {
|
||||
getDefaultMaterial () {
|
||||
return new OV.Material (OV.MaterialType.Phong);
|
||||
},
|
||||
|
||||
@ -312,7 +312,6 @@ describe ('Importer Test', function () {
|
||||
ImportFiles (files, {
|
||||
success : function (importer, importResult) {
|
||||
assert (!OV.IsModelEmpty (importResult.model));
|
||||
console.log (importResult.usedFiles);
|
||||
assert.deepStrictEqual (importResult.usedFiles, ['cube_with_materials.obj', 'cube_with_materials.mtl', 'cube_texture.png']);
|
||||
assert.deepStrictEqual (importResult.missingFiles, []);
|
||||
done ();
|
||||
|
||||
@ -52,7 +52,7 @@ module.exports =
|
||||
let fileContent = testUtils.GetArrayBufferFileContent (folder, filePath);
|
||||
return fileContent;
|
||||
});
|
||||
importer.Import (content, extension, {
|
||||
importer.Import (fileName, extension, content, {
|
||||
getDefaultMaterial : function () {
|
||||
var material = new OV.Material (OV.MaterialType.Phong);
|
||||
return material;
|
||||
|
||||
@ -141,11 +141,12 @@ OV.Navigator = class
|
||||
|
||||
FillTree (importResult)
|
||||
{
|
||||
this.titleDiv.html (importResult.mainFile).attr ('title', importResult.mainFile);
|
||||
const model = importResult.model;
|
||||
const mainFile = importResult.mainFile;
|
||||
const usedFiles = importResult.usedFiles;
|
||||
const missingFiles = importResult.missingFiles;
|
||||
|
||||
let model = importResult.model;
|
||||
let usedFiles = importResult.usedFiles;
|
||||
let missingFiles = importResult.missingFiles;
|
||||
this.titleDiv.html (mainFile).attr ('title', mainFile);
|
||||
|
||||
let filesItem = new OV.TreeViewGroupItem ('Files', 'files');
|
||||
this.treeView.AddItem (filesItem);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user