-
-
Notifications
You must be signed in to change notification settings - Fork 575
/
Copy pathexporteroff.js
38 lines (32 loc) · 958 Bytes
/
exporteroff.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { FileFormat } from '../io/fileutils.js';
import { TextWriter } from '../io/textwriter.js';
import { ExportedFile, ExporterBase } from './exporterbase.js';
export class ExporterOff extends ExporterBase
{
constructor ()
{
super ();
}
CanExport (format, extension)
{
return format === FileFormat.Text && extension === 'off';
}
ExportContent (exporterModel, format, files, onFinish)
{
let offFile = new ExportedFile ('model.off');
files.push (offFile);
let offWriter = new TextWriter ();
offWriter.WriteLine ('OFF');
offWriter.WriteArrayLine ([exporterModel.VertexCount (), exporterModel.TriangleCount (), 0]);
exporterModel.EnumerateVerticesAndTriangles ({
onVertex : function (x, y, z) {
offWriter.WriteArrayLine ([x, y, z]);
},
onTriangle : function (v0, v1, v2) {
offWriter.WriteArrayLine ([3, v0, v1, v2]);
}
});
offFile.SetTextContent (offWriter.GetText ());
onFinish ();
}
}