Always use texture buffer instead of url in case of export.
This commit is contained in:
parent
efbd5a08a2
commit
3607ab3649
@ -3,7 +3,6 @@ OV.ExportedFile = class
|
||||
constructor (name)
|
||||
{
|
||||
this.name = name;
|
||||
this.url = null;
|
||||
this.content = null;
|
||||
}
|
||||
|
||||
@ -17,16 +16,6 @@ OV.ExportedFile = class
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
GetUrl ()
|
||||
{
|
||||
return this.url;
|
||||
}
|
||||
|
||||
SetUrl (url)
|
||||
{
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
GetContent ()
|
||||
{
|
||||
return this.content;
|
||||
|
||||
@ -50,7 +50,7 @@ OV.ExporterGltf = class extends OV.ExporterBase
|
||||
let textureIndex = fileNameToIndex[fileName];
|
||||
if (textureIndex === undefined) {
|
||||
let textureFile = new OV.ExportedFile (fileName);
|
||||
textureFile.SetUrl (texture.url);
|
||||
textureFile.SetContent (texture.buffer);
|
||||
files.push (textureFile);
|
||||
|
||||
textureIndex = mainJson.textures.length;
|
||||
|
||||
@ -25,7 +25,7 @@ OV.ExporterObj = class extends OV.ExporterBase
|
||||
});
|
||||
if (fileIndex === -1) {
|
||||
let textureFile = new OV.ExportedFile (fileName);
|
||||
textureFile.SetUrl (texture.url);
|
||||
textureFile.SetContent (texture.buffer);
|
||||
files.push (textureFile);
|
||||
}
|
||||
}
|
||||
|
||||
@ -387,7 +387,7 @@ OV.Viewer = class
|
||||
this.ResizeRenderer (width, height);
|
||||
}
|
||||
this.Render ();
|
||||
let url = this.renderer.domElement.toDataURL();
|
||||
let url = this.renderer.domElement.toDataURL ();
|
||||
if (originalSize !== null) {
|
||||
this.ResizeRenderer (
|
||||
parseInt (originalSize.x, 10),
|
||||
|
||||
@ -12,15 +12,15 @@ function CreateTestModel ()
|
||||
material1.diffuseMap = new OV.TextureMap ();
|
||||
material1.diffuseMap.name = 'textures/texture1.png';
|
||||
material1.diffuseMap.url = 'texture1_url';
|
||||
material1.diffuseMap.buffer = new ArrayBuffer (4);
|
||||
material1.diffuseMap.buffer = new ArrayBuffer (1);
|
||||
material1.specularMap = new OV.TextureMap ();
|
||||
material1.specularMap.name = 'textures/texture2.png';
|
||||
material1.specularMap.url = 'texture2_url';
|
||||
material1.specularMap.buffer = new ArrayBuffer (4);
|
||||
material1.specularMap.buffer = new ArrayBuffer (2);
|
||||
material1.bumpMap = new OV.TextureMap ();
|
||||
material1.bumpMap.name = 'textures/texture3.png';
|
||||
material1.bumpMap.url = 'texture3_url';
|
||||
material1.bumpMap.buffer = new ArrayBuffer (4);
|
||||
material1.bumpMap.buffer = new ArrayBuffer (3);
|
||||
model.AddMaterial (material1);
|
||||
|
||||
let material2 = new OV.Material ();
|
||||
@ -121,18 +121,15 @@ describe ('Exporter', function () {
|
||||
|
||||
let textureFile1 = result[2];
|
||||
assert.strictEqual (textureFile1.GetName (), 'texture1.png');
|
||||
assert.strictEqual (textureFile1.GetUrl (), 'texture1_url');
|
||||
assert.strictEqual (textureFile1.GetContent (), null);
|
||||
assert.strictEqual (textureFile1.GetContent ().byteLength, 1);
|
||||
|
||||
let textureFile2 = result[3];
|
||||
assert.strictEqual (textureFile2.GetName (), 'texture2.png');
|
||||
assert.strictEqual (textureFile2.GetUrl (), 'texture2_url');
|
||||
assert.strictEqual (textureFile2.GetContent (), null);
|
||||
assert.strictEqual (textureFile2.GetContent ().byteLength, 2);
|
||||
|
||||
let textureFile3 = result[4];
|
||||
assert.strictEqual (textureFile3.GetName (), 'texture3.png');
|
||||
assert.strictEqual (textureFile3.GetUrl (), 'texture3_url');
|
||||
assert.strictEqual (textureFile3.GetContent (), null);
|
||||
assert.strictEqual (textureFile3.GetContent ().byteLength, 3);
|
||||
});
|
||||
|
||||
it ('Stl Export', function () {
|
||||
@ -305,8 +302,7 @@ describe ('Exporter', function () {
|
||||
assert.strictEqual (binFile.GetName (), 'model.bin');
|
||||
|
||||
assert.strictEqual (textureFile.GetName (), 'texture1.png');
|
||||
assert.strictEqual (textureFile.GetUrl (), 'texture1_url');
|
||||
assert.strictEqual (textureFile.GetContent (), null);
|
||||
assert.strictEqual (textureFile.GetContent ().byteLength, 1);
|
||||
|
||||
let contentBuffer = gltfFile.GetContent ();
|
||||
let importer = new OV.ImporterGltf ();
|
||||
|
||||
@ -133,11 +133,7 @@ OV.ShowExportDialog = function (model)
|
||||
fileList.empty ();
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let file = files[i];
|
||||
let url = file.GetUrl ();
|
||||
if (url === null) {
|
||||
url = OV.CreateObjectUrl (file.GetContent ());
|
||||
createdUrls.push (url);
|
||||
}
|
||||
let url = OV.CreateObjectUrl (file.GetContent ());
|
||||
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