Write header in obj and mtl files.
This commit is contained in:
parent
31b4935ac1
commit
89aaca6081
@ -37,6 +37,7 @@ OV.ExporterObj = class extends OV.ExporterBase
|
||||
files.push (objFile);
|
||||
|
||||
let mtlWriter = new OV.TextWriter ();
|
||||
mtlWriter.WriteLine (this.GetExportedByText ());
|
||||
for (let materialIndex = 0; materialIndex < model.MaterialCount (); materialIndex++) {
|
||||
let material = model.GetMaterial (materialIndex);
|
||||
mtlWriter.WriteArrayLine (['newmtl', this.GetExportedMaterialName (material.name)]);
|
||||
@ -52,6 +53,7 @@ OV.ExporterObj = class extends OV.ExporterBase
|
||||
mtlFile.SetContent (mtlWriter.GetText ());
|
||||
|
||||
let objWriter = new OV.TextWriter ();
|
||||
objWriter.WriteLine (this.GetExportedByText ());
|
||||
objWriter.WriteArrayLine (['mtllib', mtlFile.GetName ()]);
|
||||
let vertexOffset = 0;
|
||||
let normalOffset = 0;
|
||||
@ -105,4 +107,9 @@ OV.ExporterObj = class extends OV.ExporterBase
|
||||
|
||||
objFile.SetContent (objWriter.GetText ());
|
||||
}
|
||||
|
||||
GetExportedByText ()
|
||||
{
|
||||
return '# exported by https://3dviewer.net';
|
||||
}
|
||||
};
|
||||
|
||||
@ -74,6 +74,7 @@ describe ('Exporter', function () {
|
||||
assert.strictEqual (mtlFile.GetName (), 'model.mtl');
|
||||
assert.strictEqual (mtlFile.GetContent (),
|
||||
[
|
||||
'# exported by https://3dviewer.net',
|
||||
'newmtl TestMaterial1',
|
||||
'Ka 0 0 0',
|
||||
'Kd 1 0 0',
|
||||
@ -95,6 +96,7 @@ describe ('Exporter', function () {
|
||||
assert.strictEqual (objFile.GetName (), 'model.obj');
|
||||
assert.strictEqual (objFile.GetContent (),
|
||||
[
|
||||
'# exported by https://3dviewer.net',
|
||||
'mtllib model.mtl',
|
||||
'g TestMesh1',
|
||||
'v 0 0 1',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user