vagran / dxf-viewer

DXF 2D viewer written in JavaScript
Mozilla Public License 2.0
290 stars 86 forks source link

How to compute scale? The dxf is vector illustration, how to compute scale in dxf-viewer ? #94

Open thinkyoyo opened 7 months ago

thinkyoyo commented 7 months ago

The dxf is vector illustration, how to compute scale in dxf-viewer when we change the viewer size?

vagran commented 7 months ago

This is defined by three.js OrthographicCamera which can be obtained by viewer.GetCamera(). Three.js world space is DXF model space with some offset applied, scale is not changed, so you can use something like (camera.right - camera.left) / canvasWidth to get model units per pixel.

thinkyoyo commented 7 months ago

This is defined by three.js OrthographicCamera which can be obtained by viewer.GetCamera(). Three.js world space is DXF model space with some offset applied, scale is not changed, so you can use something like (camera.right - camera.left) / canvasWidth to get model units per pixel.

Please accept my best thanks. I will try use viewer.GetCamera() in my project. It would be great to provide this method by dxf-viewer. Thanks again for your reply