dxf-viewer
dxf-viewer copied to clipboard
AxesHelper not shown
Hi vagran, This project is great, I read the code and it was well organised. I came with a question, in fact this is not a issues. Here is the question: ` // DxfViewer.js constructor() { ... this.canvas.addEventListener("pointerdown", this._OnPointerEvent.bind(this)) this.canvas.addEventListener("pointerup", this._OnPointerEvent.bind(this))
/**
* AxesHelper
*/
const axesHelper = new three.AxesHelper(1000);
this.scene.add(axesHelper);
this.Render()
} ` I add an axesHelper to the scene, but when I load the dxf file, the axesHelper is not shown, I tried some work around and I still do not know why. Could you give me some advice? Thank you, I really appreciate it.
You do not see it, probably because the scene is cleared on each model loading here: https://github.com/vagran/dxf-viewer/blob/2256f3437271d1584ee27f8d059120350ea29766/src/DxfViewer.js#L239 Called here: https://github.com/vagran/dxf-viewer/blob/2256f3437271d1584ee27f8d059120350ea29766/src/DxfViewer.js#L151
However, such simple approach will anyway not give expected result because Three.js world coordinates do not correspond to DXF model space coordinates, there is an origin
property in DXF scene which moves the scene origin so that all rendered features are near GL coordinates origin. This is required to preserve coordinates data, which otherwise may be lost when converting from double float representation to single float used in HW. Typical construction site DXF is defined in some geographic projection far away from origin with features size very small comparing with distance to the origin so it definitely loses significant bits during such conversion.
In your case you can add two lines to the Three.js scene after DXF loaded to dxf scene (-scene.origin.x, -scene.origin.y) coordinates which correspond to DXF model space origin.
We can keep this issue open as a remainder to add origin mark feature.
I see, thanks vagran, I will try it.