Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle large points #77

Open
yashj119 opened this issue Sep 30, 2021 · 1 comment
Open

How to handle large points #77

yashj119 opened this issue Sep 30, 2021 · 1 comment

Comments

@yashj119
Copy link

Hello,

I have a dxf file and i am using your parser to read it and getting huge points like this

vertices: Array(5)
new THREE.Vector3(11480992.59240649,3454785.183761712,0)
new THREE.Vector3(11481107.78168301,3454732.692403951,0)
new THREE.Vector3(11481100.31350271,3454716.314788647,0)
new THREE.Vector3(11480985.23491298,3454768.755673313,0)
new THREE.Vector3(11480992.59240649,3454785.183761712,0)

Now in three js the scene you know is really small and i want to make this polylines visible, so how i can scale or transform them, whats your unit system here in the conversion if the file unit is feet or meter

@bzuillsmith
Copy link
Member

I'm not sure. I have not figured out how to handle such large numbers yet. My understanding is that javascript can handle them because it uses 64-bit numbers, but webgl is using 32-bit floating point numbers in some of it's process and this causes a loss of precision. See the SO answer here.

So my understanding is that you need to shift your coordinates closer to 0. You might do this by taking every coordinate and and translating them toward 0 before adding them to the scene: position.x = position.x - 11481000 and position.y = position.y - 3454700. DxfParser does not yet have a built-in way to do this.

I don't know at what stage three.js/WebGL loses precision, but there is a small chance you could add a translate to your whole scene that moves it closer to 0; however, my guess is this won't work because the precision is lost before it can be translated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants