Merge branch 'dev' into dark_mode
This commit is contained in:
commit
bc54053d31
@ -93,7 +93,7 @@ OV.Exporter3dm = class extends OV.ExporterBase
|
||||
writeOptions.version = 6;
|
||||
let rhinoDocBuffer = rhinoDoc.toByteArray (writeOptions);
|
||||
|
||||
rhinoFile.SetContent (rhinoDocBuffer);
|
||||
rhinoFile.SetBufferContent (rhinoDocBuffer);
|
||||
onFinish ();
|
||||
}
|
||||
};
|
||||
|
||||
@ -16,12 +16,24 @@ OV.ExportedFile = class
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
GetContent ()
|
||||
GetTextContent ()
|
||||
{
|
||||
let text = OV.ArrayBufferToUtf8String (this.content);
|
||||
return text;
|
||||
}
|
||||
|
||||
GetBufferContent ()
|
||||
{
|
||||
return this.content;
|
||||
}
|
||||
|
||||
SetContent (content)
|
||||
SetTextContent (content)
|
||||
{
|
||||
let buffer = OV.Utf8StringToArrayBuffer (content);
|
||||
this.content = buffer;
|
||||
}
|
||||
|
||||
SetBufferContent (content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ OV.ExporterGltf = class extends OV.ExporterBase
|
||||
let textureIndex = fileNameToIndex[fileName];
|
||||
if (textureIndex === undefined) {
|
||||
let textureFile = new OV.ExportedFile (fileName);
|
||||
textureFile.SetContent (texture.buffer);
|
||||
textureFile.SetBufferContent (texture.buffer);
|
||||
files.push (textureFile);
|
||||
|
||||
textureIndex = mainJson.textures.length;
|
||||
@ -67,8 +67,8 @@ OV.ExporterGltf = class extends OV.ExporterBase
|
||||
return textureIndex;
|
||||
});
|
||||
|
||||
gltfFile.SetContent (JSON.stringify (mainJson, null, 4));
|
||||
binFile.SetContent (mainBuffer);
|
||||
gltfFile.SetTextContent (JSON.stringify (mainJson, null, 4));
|
||||
binFile.SetBufferContent (mainBuffer);
|
||||
}
|
||||
|
||||
ExportBinaryContent (model, files)
|
||||
@ -164,7 +164,7 @@ OV.ExporterGltf = class extends OV.ExporterBase
|
||||
}
|
||||
WriteCharacters (glbWriter, 0, mainBinaryBufferAlignedLength - mainBinaryBufferLength);
|
||||
|
||||
glbFile.SetContent (glbWriter.GetBuffer ());
|
||||
glbFile.SetBufferContent (glbWriter.GetBuffer ());
|
||||
}
|
||||
|
||||
GetMeshData (model)
|
||||
|
||||
@ -25,7 +25,7 @@ OV.ExporterObj = class extends OV.ExporterBase
|
||||
});
|
||||
if (fileIndex === -1) {
|
||||
let textureFile = new OV.ExportedFile (fileName);
|
||||
textureFile.SetContent (texture.buffer);
|
||||
textureFile.SetBufferContent (texture.buffer);
|
||||
files.push (textureFile);
|
||||
}
|
||||
}
|
||||
@ -50,7 +50,7 @@ OV.ExporterObj = class extends OV.ExporterBase
|
||||
WriteTexture (mtlWriter, 'map_Ks', material.specularMap, files);
|
||||
WriteTexture (mtlWriter, 'bump', material.bumpMap, files);
|
||||
}
|
||||
mtlFile.SetContent (mtlWriter.GetText ());
|
||||
mtlFile.SetTextContent (mtlWriter.GetText ());
|
||||
|
||||
let objWriter = new OV.TextWriter ();
|
||||
objWriter.WriteLine (this.GetHeaderText ());
|
||||
@ -105,7 +105,7 @@ OV.ExporterObj = class extends OV.ExporterBase
|
||||
uvOffset += mesh.TextureUVCount ();
|
||||
}
|
||||
|
||||
objFile.SetContent (objWriter.GetText ());
|
||||
objFile.SetTextContent (objWriter.GetText ());
|
||||
onFinish ();
|
||||
}
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ OV.ExporterOff = class extends OV.ExporterBase
|
||||
}
|
||||
});
|
||||
|
||||
offFile.SetContent (offWriter.GetText ());
|
||||
offFile.SetTextContent (offWriter.GetText ());
|
||||
onFinish ();
|
||||
}
|
||||
};
|
||||
|
||||
@ -41,7 +41,7 @@ OV.ExporterPly = class extends OV.ExporterBase
|
||||
}
|
||||
});
|
||||
|
||||
plyFile.SetContent (plyWriter.GetText ());
|
||||
plyFile.SetTextContent (plyWriter.GetText ());
|
||||
}
|
||||
|
||||
ExportBinary (model, files)
|
||||
@ -75,7 +75,7 @@ OV.ExporterPly = class extends OV.ExporterBase
|
||||
}
|
||||
});
|
||||
|
||||
plyFile.SetContent (plyWriter.GetBuffer ());
|
||||
plyFile.SetBufferContent (plyWriter.GetBuffer ());
|
||||
}
|
||||
|
||||
GetHeaderText (format, vertexCount, triangleCount)
|
||||
|
||||
@ -42,7 +42,7 @@ OV.ExporterStl = class extends OV.ExporterBase
|
||||
});
|
||||
stlWriter.WriteLine ('endsolid Model');
|
||||
|
||||
stlFile.SetContent (stlWriter.GetText ());
|
||||
stlFile.SetTextContent (stlWriter.GetText ());
|
||||
}
|
||||
|
||||
ExportBinary (model, files)
|
||||
@ -80,6 +80,6 @@ OV.ExporterStl = class extends OV.ExporterBase
|
||||
stlWriter.WriteUnsignedInteger16 (0);
|
||||
});
|
||||
|
||||
stlFile.SetContent (stlWriter.GetBuffer ());
|
||||
stlFile.SetBufferContent (stlWriter.GetBuffer ());
|
||||
}
|
||||
};
|
||||
|
||||
@ -14,13 +14,11 @@ OV.File = class
|
||||
this.name = OV.GetFileName (file.name);
|
||||
this.extension = OV.GetFileExtension (file.name);
|
||||
}
|
||||
this.format = null;
|
||||
this.content = null;
|
||||
}
|
||||
|
||||
SetContent (format, content)
|
||||
SetContent (content)
|
||||
{
|
||||
this.format = format;
|
||||
this.content = content;
|
||||
}
|
||||
};
|
||||
@ -141,36 +139,22 @@ OV.FileList = class
|
||||
complete ();
|
||||
return;
|
||||
}
|
||||
let format = this.GetFileFormat (file);
|
||||
let loaderPromise = null;
|
||||
if (file.source === OV.FileSource.Url) {
|
||||
loaderPromise = OV.RequestUrl (file.fileUrl, format);
|
||||
loaderPromise = OV.RequestUrl (file.fileUrl, OV.FileFormat.Binary);
|
||||
} else if (file.source === OV.FileSource.File) {
|
||||
loaderPromise = OV.ReadFile (file.fileObject, format);
|
||||
loaderPromise = OV.ReadFile (file.fileObject, OV.FileFormat.Binary);
|
||||
} else {
|
||||
complete ();
|
||||
return;
|
||||
}
|
||||
loaderPromise.then ((content) => {
|
||||
file.SetContent (format, content);
|
||||
file.SetContent (content);
|
||||
}).catch (() => {
|
||||
}).finally (() => {
|
||||
complete ();
|
||||
});
|
||||
}
|
||||
|
||||
GetFileFormat (file)
|
||||
{
|
||||
for (let importerIndex = 0; importerIndex < this.importers.length; importerIndex++) {
|
||||
let importer = this.importers[importerIndex];
|
||||
let extension = file.extension;
|
||||
let knownFormats = importer.GetKnownFileFormats ();
|
||||
if (knownFormats[extension] !== undefined) {
|
||||
return knownFormats[extension];
|
||||
}
|
||||
}
|
||||
return OV.FileFormat.Binary;
|
||||
}
|
||||
|
||||
FindImporter (file)
|
||||
{
|
||||
|
||||
@ -10,14 +10,7 @@ OV.Importer3dm = class extends OV.ImporterBase
|
||||
{
|
||||
return extension === '3dm';
|
||||
}
|
||||
|
||||
GetKnownFileFormats ()
|
||||
{
|
||||
return {
|
||||
'3dm' : OV.FileFormat.Binary
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
GetUpDirection ()
|
||||
{
|
||||
return OV.Direction.Z;
|
||||
|
||||
@ -56,13 +56,6 @@ OV.Importer3ds = class extends OV.ImporterBase
|
||||
return extension === '3ds';
|
||||
}
|
||||
|
||||
GetKnownFileFormats ()
|
||||
{
|
||||
return {
|
||||
'3ds' : OV.FileFormat.Binary
|
||||
};
|
||||
}
|
||||
|
||||
GetUpDirection ()
|
||||
{
|
||||
return OV.Direction.Z;
|
||||
|
||||
@ -55,11 +55,6 @@ OV.ImporterBase = class
|
||||
return false;
|
||||
}
|
||||
|
||||
GetKnownFileFormats ()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
GetUpDirection ()
|
||||
{
|
||||
return OV.Direction.Z;
|
||||
|
||||
@ -483,15 +483,6 @@ OV.ImporterGltf = class extends OV.ImporterBase
|
||||
return extension === 'gltf' || extension === 'glb';
|
||||
}
|
||||
|
||||
GetKnownFileFormats ()
|
||||
{
|
||||
return {
|
||||
'gltf' : OV.FileFormat.Text,
|
||||
'glb' : OV.FileFormat.Binary,
|
||||
'bin' : OV.FileFormat.Binary
|
||||
};
|
||||
}
|
||||
|
||||
GetUpDirection ()
|
||||
{
|
||||
return OV.Direction.Y;
|
||||
@ -520,7 +511,8 @@ OV.ImporterGltf = class extends OV.ImporterBase
|
||||
|
||||
ProcessGltf (fileContent, onFinish)
|
||||
{
|
||||
let gltf = JSON.parse (fileContent);
|
||||
let textContent = OV.ArrayBufferToUtf8String (fileContent);
|
||||
let gltf = JSON.parse (textContent);
|
||||
if (gltf.asset.version !== '2.0') {
|
||||
this.SetError ('Invalid glTF version.');
|
||||
onFinish ();
|
||||
|
||||
@ -11,13 +11,6 @@ OV.ImporterIfc = class extends OV.ImporterBase
|
||||
return extension === 'ifc';
|
||||
}
|
||||
|
||||
GetKnownFileFormats ()
|
||||
{
|
||||
return {
|
||||
'ifc' : OV.FileFormat.Binary
|
||||
};
|
||||
}
|
||||
|
||||
GetUpDirection ()
|
||||
{
|
||||
return OV.Direction.Y;
|
||||
|
||||
@ -9,14 +9,7 @@ OV.ImporterO3dv = class extends OV.ImporterBase
|
||||
{
|
||||
return extension === 'o3dv';
|
||||
}
|
||||
|
||||
GetKnownFileFormats ()
|
||||
{
|
||||
return {
|
||||
'o3dv' : OV.FileFormat.Text
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
GetUpDirection ()
|
||||
{
|
||||
return OV.Direction.Z;
|
||||
@ -34,7 +27,8 @@ OV.ImporterO3dv = class extends OV.ImporterBase
|
||||
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
let content = JSON.parse (fileContent);
|
||||
let textContent = OV.ArrayBufferToUtf8String (fileContent);
|
||||
let content = JSON.parse (textContent);
|
||||
if (content.materials !== undefined) {
|
||||
for (let i = 0; i < content.materials.length; i++) {
|
||||
const materialContent = content.materials[i];
|
||||
|
||||
@ -9,14 +9,6 @@ OV.ImporterObj = class extends OV.ImporterBase
|
||||
{
|
||||
return extension === 'obj';
|
||||
}
|
||||
|
||||
GetKnownFileFormats ()
|
||||
{
|
||||
return {
|
||||
'obj' : OV.FileFormat.Text,
|
||||
'mtl' : OV.FileFormat.Text
|
||||
};
|
||||
}
|
||||
|
||||
GetUpDirection ()
|
||||
{
|
||||
@ -55,7 +47,8 @@ OV.ImporterObj = class extends OV.ImporterBase
|
||||
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
OV.ReadLines (fileContent, (line) => {
|
||||
let textContent = OV.ArrayBufferToUtf8String (fileContent);
|
||||
OV.ReadLines (textContent, (line) => {
|
||||
if (!this.WasError ()) {
|
||||
this.ProcessLine (line);
|
||||
}
|
||||
@ -212,7 +205,8 @@ OV.ImporterObj = class extends OV.ImporterBase
|
||||
let fileName = OV.NameFromLine (line, keyword.length, '#');
|
||||
let fileBuffer = this.callbacks.getFileBuffer (fileName);
|
||||
if (fileBuffer !== null) {
|
||||
OV.ReadLines (fileBuffer, (line) => {
|
||||
let textContent = OV.ArrayBufferToUtf8String (fileBuffer);
|
||||
OV.ReadLines (textContent, (line) => {
|
||||
if (!this.WasError ()) {
|
||||
this.ProcessLine (line);
|
||||
}
|
||||
|
||||
@ -9,14 +9,7 @@ OV.ImporterOff = class extends OV.ImporterBase
|
||||
{
|
||||
return extension === 'off';
|
||||
}
|
||||
|
||||
GetKnownFileFormats ()
|
||||
{
|
||||
return {
|
||||
'off' : OV.FileFormat.Text
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
GetUpDirection ()
|
||||
{
|
||||
return OV.Direction.Y;
|
||||
@ -42,7 +35,8 @@ OV.ImporterOff = class extends OV.ImporterBase
|
||||
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
OV.ReadLines (fileContent, (line) => {
|
||||
let textContent = OV.ArrayBufferToUtf8String (fileContent);
|
||||
OV.ReadLines (textContent, (line) => {
|
||||
if (!this.WasError ()) {
|
||||
this.ProcessLine (line);
|
||||
}
|
||||
|
||||
@ -164,13 +164,6 @@ OV.ImporterPly = class extends OV.ImporterBase
|
||||
return extension === 'ply';
|
||||
}
|
||||
|
||||
GetKnownFileFormats ()
|
||||
{
|
||||
return {
|
||||
'ply' : OV.FileFormat.Binary
|
||||
};
|
||||
}
|
||||
|
||||
GetUpDirection ()
|
||||
{
|
||||
return OV.Direction.Y;
|
||||
|
||||
@ -10,13 +10,6 @@ OV.ImporterStl = class extends OV.ImporterBase
|
||||
return extension === 'stl';
|
||||
}
|
||||
|
||||
GetKnownFileFormats ()
|
||||
{
|
||||
return {
|
||||
'stl' : OV.FileFormat.Binary
|
||||
};
|
||||
}
|
||||
|
||||
GetUpDirection ()
|
||||
{
|
||||
return OV.Direction.Z;
|
||||
|
||||
@ -231,16 +231,6 @@ OV.ThreeImporter = class extends OV.ImporterBase
|
||||
return false;
|
||||
}
|
||||
|
||||
GetKnownFileFormats ()
|
||||
{
|
||||
let result = {};
|
||||
for (let i = 0; i < this.loaders.length; i++) {
|
||||
let loader = this.loaders[i];
|
||||
result[loader.GetExtension ()] = OV.FileFormat.Binary;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
GetUpDirection ()
|
||||
{
|
||||
return this.loader.GetUpDirection ();
|
||||
|
||||
@ -90,7 +90,7 @@ describe ('Exporter', function () {
|
||||
|
||||
let mtlFile = result[0];
|
||||
assert.strictEqual (mtlFile.GetName (), 'model.mtl');
|
||||
assert.strictEqual (mtlFile.GetContent (),
|
||||
assert.strictEqual (mtlFile.GetTextContent (),
|
||||
[
|
||||
'# exported by https://3dviewer.net',
|
||||
'newmtl TestMaterial1',
|
||||
@ -112,7 +112,7 @@ describe ('Exporter', function () {
|
||||
].join ('\n'));
|
||||
let objFile = result[1];
|
||||
assert.strictEqual (objFile.GetName (), 'model.obj');
|
||||
assert.strictEqual (objFile.GetContent (),
|
||||
assert.strictEqual (objFile.GetTextContent (),
|
||||
[
|
||||
'# exported by https://3dviewer.net',
|
||||
'mtllib model.mtl',
|
||||
@ -141,15 +141,15 @@ describe ('Exporter', function () {
|
||||
|
||||
let textureFile1 = result[2];
|
||||
assert.strictEqual (textureFile1.GetName (), 'texture1.png');
|
||||
assert.strictEqual (textureFile1.GetContent ().byteLength, 1);
|
||||
assert.strictEqual (textureFile1.GetBufferContent ().byteLength, 1);
|
||||
|
||||
let textureFile2 = result[3];
|
||||
assert.strictEqual (textureFile2.GetName (), 'texture2.png');
|
||||
assert.strictEqual (textureFile2.GetContent ().byteLength, 2);
|
||||
assert.strictEqual (textureFile2.GetBufferContent ().byteLength, 2);
|
||||
|
||||
let textureFile3 = result[4];
|
||||
assert.strictEqual (textureFile3.GetName (), 'texture3.png');
|
||||
assert.strictEqual (textureFile3.GetContent ().byteLength, 3);
|
||||
assert.strictEqual (textureFile3.GetBufferContent ().byteLength, 3);
|
||||
|
||||
done ();
|
||||
});
|
||||
@ -162,7 +162,7 @@ describe ('Exporter', function () {
|
||||
|
||||
let stlFile = result[0];
|
||||
assert.strictEqual (stlFile.GetName (), 'model.stl');
|
||||
assert.strictEqual (stlFile.GetContent (),
|
||||
assert.strictEqual (stlFile.GetTextContent (),
|
||||
[
|
||||
'solid Model',
|
||||
'facet normal 0 0 1',
|
||||
@ -208,9 +208,9 @@ describe ('Exporter', function () {
|
||||
|
||||
let stlFile = result[0];
|
||||
assert.strictEqual (stlFile.GetName (), 'model.stl');
|
||||
assert.strictEqual (stlFile.GetContent ().byteLength, 284);
|
||||
assert.strictEqual (stlFile.GetBufferContent ().byteLength, 284);
|
||||
|
||||
let contentBuffer = stlFile.GetContent ();
|
||||
let contentBuffer = stlFile.GetBufferContent ();
|
||||
let importer = new OV.ImporterStl ();
|
||||
importer.Import (contentBuffer, 'stl', {
|
||||
getDefaultMaterial () {
|
||||
@ -235,7 +235,7 @@ describe ('Exporter', function () {
|
||||
|
||||
let offFile = result[0];
|
||||
assert.strictEqual (offFile.GetName (), 'model.off');
|
||||
assert.strictEqual (offFile.GetContent (),
|
||||
assert.strictEqual (offFile.GetTextContent (),
|
||||
[
|
||||
'OFF',
|
||||
'8 4 0',
|
||||
@ -265,7 +265,7 @@ describe ('Exporter', function () {
|
||||
|
||||
let plyFile = result[0];
|
||||
assert.strictEqual (plyFile.GetName (), 'model.ply');
|
||||
assert.strictEqual (plyFile.GetContent (),
|
||||
assert.strictEqual (plyFile.GetTextContent (),
|
||||
[
|
||||
'ply',
|
||||
'format ascii 1.0',
|
||||
@ -302,9 +302,9 @@ describe ('Exporter', function () {
|
||||
|
||||
let plyFile = result[0];
|
||||
assert.strictEqual (plyFile.GetName (), 'model.ply');
|
||||
assert.strictEqual (plyFile.GetContent ().byteLength, 315);
|
||||
assert.strictEqual (plyFile.GetBufferContent ().byteLength, 315);
|
||||
|
||||
let contentBuffer = plyFile.GetContent ();
|
||||
let contentBuffer = plyFile.GetBufferContent ();
|
||||
let importer = new OV.ImporterPly ();
|
||||
importer.Import (contentBuffer, 'ply', {
|
||||
getDefaultMaterial () {
|
||||
@ -332,9 +332,9 @@ describe ('Exporter', function () {
|
||||
assert.strictEqual (binFile.GetName (), 'model.bin');
|
||||
|
||||
assert.strictEqual (textureFile.GetName (), 'texture1.png');
|
||||
assert.strictEqual (textureFile.GetContent ().byteLength, 1);
|
||||
assert.strictEqual (textureFile.GetBufferContent ().byteLength, 1);
|
||||
|
||||
let contentBuffer = gltfFile.GetContent ();
|
||||
let contentBuffer = gltfFile.GetBufferContent ();
|
||||
let importer = new OV.ImporterGltf ();
|
||||
importer.Import (contentBuffer, 'gltf', {
|
||||
getDefaultMaterial () {
|
||||
@ -342,7 +342,7 @@ describe ('Exporter', function () {
|
||||
},
|
||||
getFileBuffer (filePath) {
|
||||
if (filePath == 'model.bin') {
|
||||
return binFile.GetContent ();
|
||||
return binFile.GetBufferContent ();
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@ -372,7 +372,7 @@ describe ('Exporter', function () {
|
||||
let glbFile = result[0];
|
||||
assert.strictEqual (glbFile.GetName (), 'model.glb');
|
||||
|
||||
let contentBuffer = glbFile.GetContent ();
|
||||
let contentBuffer = glbFile.GetBufferContent ();
|
||||
let importer = new OV.ImporterGltf ();
|
||||
importer.Import (contentBuffer, 'glb', {
|
||||
getDefaultMaterial () {
|
||||
|
||||
@ -5,72 +5,51 @@ module.exports =
|
||||
ImportObjFile : function (fileName, onReady)
|
||||
{
|
||||
var importer = new OV.ImporterObj ();
|
||||
this.ImportFile (importer, OV.FileFormat.Text, 'obj', fileName, onReady);
|
||||
this.ImportFile (importer, 'obj', fileName, onReady);
|
||||
},
|
||||
|
||||
ImportStlFile : function (fileName, onReady)
|
||||
{
|
||||
var importer = new OV.ImporterStl ();
|
||||
this.ImportFile (importer, OV.FileFormat.Binary, 'stl', fileName, onReady);
|
||||
this.ImportFile (importer, 'stl', fileName, onReady);
|
||||
},
|
||||
|
||||
ImportOffFile : function (fileName, onReady)
|
||||
{
|
||||
var importer = new OV.ImporterOff ();
|
||||
this.ImportFile (importer, OV.FileFormat.Text, 'off', fileName, onReady);
|
||||
this.ImportFile (importer, 'off', fileName, onReady);
|
||||
},
|
||||
|
||||
ImportPlyFile : function (fileName, onReady)
|
||||
{
|
||||
var importer = new OV.ImporterPly ();
|
||||
this.ImportFile (importer, OV.FileFormat.Binary, 'ply', fileName, onReady);
|
||||
this.ImportFile (importer, 'ply', fileName, onReady);
|
||||
},
|
||||
|
||||
Import3dsFile : function (fileName, onReady)
|
||||
{
|
||||
var importer = new OV.Importer3ds ();
|
||||
this.ImportFile (importer, OV.FileFormat.Binary, '3ds', fileName, onReady);
|
||||
this.ImportFile (importer, '3ds', fileName, onReady);
|
||||
},
|
||||
|
||||
ImportGltfFile : function (folderName, fileName, onReady)
|
||||
{
|
||||
let extension = OV.GetFileExtension (fileName);
|
||||
let format = OV.FileFormat.Text;
|
||||
if (extension == 'glb') {
|
||||
format = OV.FileFormat.Binary;
|
||||
}
|
||||
var importer = new OV.ImporterGltf ();
|
||||
this.ImportFile (importer, format, 'gltf/' + folderName, fileName, onReady);
|
||||
this.ImportFile (importer, 'gltf/' + folderName, fileName, onReady);
|
||||
},
|
||||
|
||||
ImportO3dvFile : function (fileName, onReady)
|
||||
{
|
||||
var importer = new OV.ImporterO3dv ();
|
||||
this.ImportFile (importer, OV.FileFormat.Text, 'o3dv', fileName, onReady);
|
||||
this.ImportFile (importer, 'o3dv', fileName, onReady);
|
||||
},
|
||||
|
||||
ImportFile : function (importer, format, folder, fileName, onReady)
|
||||
ImportFile : function (importer, folder, fileName, onReady)
|
||||
{
|
||||
var content = null;
|
||||
if (format == OV.FileFormat.Text) {
|
||||
content = testUtils.GetTextFileContent (folder, fileName);
|
||||
} else if (format == OV.FileFormat.Binary) {
|
||||
content = testUtils.GetArrayBufferFileContent (folder, fileName);
|
||||
}
|
||||
let content = testUtils.GetArrayBufferFileContent (folder, fileName);
|
||||
var extension = OV.GetFileExtension (fileName);
|
||||
let buffers = new OV.ImportBuffers (function (filePath) {
|
||||
let extension = OV.GetFileExtension (filePath);
|
||||
let knownFormats = importer.GetKnownFileFormats ();
|
||||
let format = OV.FileFormat.Binary;
|
||||
if (knownFormats[extension] !== undefined) {
|
||||
format = knownFormats[extension];
|
||||
}
|
||||
let fileContent = null;
|
||||
if (format == OV.FileFormat.Text) {
|
||||
fileContent = testUtils.GetTextFileContent (folder, filePath);
|
||||
} else if (format == OV.FileFormat.Binary) {
|
||||
fileContent = testUtils.GetArrayBufferFileContent (folder, filePath);
|
||||
}
|
||||
let fileContent = testUtils.GetArrayBufferFileContent (folder, filePath);
|
||||
return fileContent;
|
||||
});
|
||||
importer.Import (content, extension, {
|
||||
|
||||
@ -171,7 +171,7 @@ OV.ExportDialog = class
|
||||
} else if (files.length === 1) {
|
||||
progressDialog.Hide ();
|
||||
let file = files[0];
|
||||
OV.DownloadArrayBufferAsFile (file.GetContent (), file.GetName ());
|
||||
OV.DownloadArrayBufferAsFile (file.GetBufferContent (), file.GetName ());
|
||||
} else if (files.length > 1) {
|
||||
progressDialog.Hide ();
|
||||
this.ShowExportedFiles (files);
|
||||
@ -211,7 +211,7 @@ OV.ExportDialog = class
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let file = files[i];
|
||||
let url = OV.CreateObjectUrl (file.GetContent ());
|
||||
let url = OV.CreateObjectUrl (file.GetBufferContent ());
|
||||
let fileLink = $('<a>').addClass ('ov_dialog_file_link').appendTo (fileList);
|
||||
fileLink.attr ('href', url);
|
||||
fileLink.attr ('download', file.GetName ());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user