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 extract mesh geometry from polylines? #46

Open
Ni55aN opened this issue Apr 18, 2019 · 12 comments
Open

How to extract mesh geometry from polylines? #46

Ni55aN opened this issue Apr 18, 2019 · 12 comments

Comments

@Ni55aN
Copy link

Ni55aN commented Apr 18, 2019

How should I create faces and vertices from 3D points list? (dxf.entities -> type = 'POLYLINE')

I have tried this:

function addTriangle(g, p, i1, i2, i3) {
    if(Math.max(i1, i2, i3) > p.length - 1) return; 
    let p1 = p[i1];
    let p2 = p[i2];
    let p3 = p[i3];
    g.vertices.push(new THREE.Vector3( p1.x, p1.y, p1.z ))
    g.vertices.push(new THREE.Vector3( p2.x, p2.y, p2.z ))
    g.vertices.push(new THREE.Vector3( p3.x, p3.y, p3.z ))
    g.faces.push(new THREE.Face3(g.vertices.length - 3, g.vertices.length - 2, g.vertices.length - 1))
}

    var g = new THREE.Geometry();


    polylines.map(p => {
        for(let i=0;i<p.length;i+=6) {
            addTriangle(g, p, i, i+1, i+2)
            addTriangle(g, p, i+3, i+1, i)
        }
    })

But several polygons are missed. Moreover, I see a few points with a zero coordinates
Kazam_screenshot_00003

@Serthys
Copy link
Contributor

Serthys commented Apr 18, 2019

I don't think there's enough information to help here, can you provide a stackblitz with a basic sample of the problem?
Here's a simple template, you should add your dxf file and log the things that give you problems.

@Ni55aN
Copy link
Author

Ni55aN commented Apr 18, 2019

@Serthys https://stackblitz.com/edit/js-csuc78?file=index.js
You can open downloaded scene.json in the three.js editor

@Serthys
Copy link
Contributor

Serthys commented Apr 18, 2019

You can open downloaded scene.json in the three.js editor

The scene data on that editor is stored on your browser, I can't see it.
Try creating a scene.json file on the stackblitz project and paste the contents you can download there.

@Ni55aN
Copy link
Author

Ni55aN commented Apr 18, 2019

You can load any dxf file

@Ni55aN
Copy link
Author

Ni55aN commented Apr 18, 2019

I have added scene.json to project

@Serthys
Copy link
Contributor

Serthys commented Apr 18, 2019

Ok, I didn't understand you before. I thought you were trying to load the scene file.
The file I need to test what's wrong is the dxf you are parsing, not the result.

@Ni55aN
Copy link
Author

Ni55aN commented Apr 18, 2019

roof.dxf being imported in Blender (using the addon DXF import) correctly

I just uploaded the scene.json to project successfully https://stackblitz.com/edit/js-csuc78?file=scene.json

@Ni55aN
Copy link
Author

Ni55aN commented Apr 18, 2019

DXF file cannot be uploaded due to 413 Request Entity Too Large

@Serthys
Copy link
Contributor

Serthys commented Apr 18, 2019

Upload it on other place like pastebin for example.

@Ni55aN
Copy link
Author

Ni55aN commented Apr 18, 2019

DXF is too large (about 3MB)

@Ni55aN
Copy link
Author

Ni55aN commented Apr 18, 2019

@Serthys
Copy link
Contributor

Serthys commented Apr 18, 2019

I've checked the dxf source and the zeros are already there, it doesn't look like an error from the parsing.

About how to extract the data and display it in threejs, I've never used the 3D features of dxf some I'm kinda lost there. If you manage to do it feel free to submit a pull request on /gdsestimating/three-dxf.

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