blob: ed4d557d02fdbb1d19a93eecec49d285e71366e8 (
plain)
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
|
import DXFParser from 'dxf-parser';
import DXF from './dxf';
export default class DXFRenderer {
constructor(container) {
this.el = container;
this.endpoint = this.el.dataset.endpoint;
this.loadFile();
}
loadFile() {
const xhr = new XMLHttpRequest();
xhr.open('GET', this.endpoint, true);
xhr.responseType = 'string';
xhr.onload = this.parseDxf.bind(this);
// xhr.onerror = DXFParser.onError;
xhr.send();
}
parseDxf(e) {
var parser = new DXFParser();
try {
var dxf = parser.parseSync(e.target.response);
console.log(dxf)
}catch(err) {
return console.error(err.stack);
}
}
}
|