vagran / dxf-viewer

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

Could not load ShapePath imported by node_modules textRenderer.js #77

Open MiguelG97 opened 1 year ago

MiguelG97 commented 1 year ago

Dear developer,

I'm struggling with bundling the project. I've installed the libraries and somehow the node_modules is having problems to import files form three js library. Would you mind helping me with this one, here is the repo. Literally no code, just setting up the rollup bundle:

https://github.com/MiguelG97/dxfViewer

image

All the best Miguel G

vagran commented 1 year ago

Hi, Actually I am not familiar with rollup and never tried to use it with this library. From the first look, it seems that it cannot resolve that imports without .js extensions. Probably the extensions should be added in TextRenderer.js:

import {ShapePath} from "three/src/extras/core/ShapePath.js"
import {ShapeUtils} from "three/src/extras/ShapeUtils.js"

I will fix it in the mainline, you can now fix it locally as a workaround.

MiguelG97 commented 1 year ago

Dear vagran, The issue persist somehow

image

image

By the way, does dxf-viewer provides a measurement tool? if that's not the case, would you mind pointing to me to some topics, approaches or documentation that can help me to build a measurement tool?

Best regards, Miguel G.

vagran commented 1 year ago

The fix is in master branch, not yet released in npm (there still other problems most probably will occur). You can use it directly by specifying this in your package.json:

"dxf-viewer": "github:vagran/dxf-viewer#master"

By the way, does dxf-viewer provides a measurement tool?

No, the library is just a renderer. Any tools are a subject for implementation in applications built on top of the library. For measuring distance between two points you can use some spatial 2D index for indexing all vertices received in rendering batches, then use it to lookup nearest vertex to snap to. However, currently all information about vertex semantic is lost, so it is not possible to filter out, e.g. vertices of text glyphs or tesselated arcs.

MiguelG97 commented 1 year ago

Dear @vagran I fix up the import reference issue and in addition I included the "export default" on the node_modules\loglevel\lib\loglevel.js file since rollup was asking for it: https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module

However, now I'm facing the following issue: image any ideas on how to fix it up?

here is the repo: https://github.com/MiguelG97/dxfViewer

Best regards, Miguel G

vagran commented 1 year ago

However, now I'm facing the following issue: image any ideas on how to fix it up?

Best regards, Miguel G

It is difficult to say where the problem is without any reference to the original sources. Try to build with source maps generation enabled, so it will hopefully provide reference to a place in the original sources.

MiguelG97 commented 1 year ago

Here is the link to the original repo: https://github.com/MiguelG97/dxfViewer

image

Something going on at line 30850 apparently