Git Product home page Git Product logo

three-dxf's People

Contributors

bzuillsmith avatar duncanthrax avatar gouldingken avatar serthys avatar tat757 avatar vinzentvega avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

three-dxf's Issues

No compatibility with latest versions of Three

"ERROR in ./node_modules/three-dxf/src/index.js 472:36-47
"export 'Face3' (imported as 'THREE') was not found in 'three'"

during build time

Three.js version : 0.128.0
Three-dxf version : 1.0.1

ERR_TOO_MANY_REDIRECTS

Trying to run the sample I get a redirection error:

Hit CTRL-C to stop the server
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample//" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample///" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample/////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample//////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample///////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample////////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample/////////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample//////////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68

Unable to load ThreeDxf from the window object in React

I am trying to load the three-dxf script into my React app using below.

useEffect(() => {
    const script = document.createElement("script");
    script.type = 'text/javascript';
    script.src = '/dist/three-dxf.js';
    script.async = true;
    script.onload = () => scriptLoaded();

    document.getElementsByTagName('head')[0].appendChild(script);
  });

The above does not give any error, however, inside the scriptLoaded function, when I try to load the ThreeDxf object from the window object, it gives undefined, i.e.

window.ThreeDxf.Viewer(...) gives an error TypeError: Cannot read property 'Viewer' of undefined

Any idea why the window object does not contain ThreeDxf?

Some of drawings seems different from AutoCAD

Thank you for this great project. It can open big dxf files faster than AutoCAD :) I have a project that it seems different in three-dxf in comparison with AutoCAD like this:
DXF file on three-dxf sample viewer:
dxf_treejs
DXF file on AutoCAD:
autocad

Object type of lines are "Block Referance". and some of lines are polylines. Is it because the object type is Block reference?

Displaying in Scene via three.js

Sample showing a parsed result in canvas, How to show it in three.js scene.
Is it possible to show file results in 3D or 2D scenes.

Support block inserts

Dxf-parser nearly supports this, so we should work on blocks in three-dxf in tandem.

Error in text location

normal:
image
error:
image
some text error and i can't fix it.
can you help me fix it or give me some advice. when you are free. thanks!

Needs to figure viewport correctly

Last I remember, the viewport assumes it should be pointed at 0,0,0. This is a reasonable guess, but not always the case. I think we can parse viewport information and start there, or the dxf header may have some reasonable info for where we should point and what the extents of the cad drawing are.

Performance drop on large Geometry

When adding a dxf with 10.000 entities, there is a huge performance drop.
Every Entity produce a draw call on scene.add(obj).
Is it possible to merge the whole Geometry without loosing the single entity color?

Refactoring to typescript. (Pull request)

Hi, I refactored three-dxf with typescript in my fork, can I open a pull request?
After the refactoring I also made some code bug fixes and optimizations:

  • Improved the way the three.js render function is called.
  • Added raycaster to detect mouse and 3d object interaction.
  • Comment out functions that are not applicable.
  • Enhanced visibility of point painting.
  • Fix the bug of AABB calculation.

We can discuss further if needed, thanks!

Stange circles in dxf line work

hi,
Unfortunately i cannot share the file but we have some linework showing strange circles instead of buldges (left: ours, right three-dxf)
image
and qgis for comparison
image

Cannot open property "Viewer" of undefined or null. (Internet Explorer)

cadCanvas = new window.ThreeDxf.Viewer(dxf, document.getElementById('cad-view'), 400, 400, font);

causes an error in the console when I try to open a file. It cannot open property "Viewer" of undefined or null.

(When I load the site there is another error about an expected semicolon in three-dxf.js between "use-strict"; and eval(.)

Does anyone know why this happens and how I can fix it? It only happens on Internet Explorer 11. With Chrome and Edge everything works.

Edit:

I think I've fixed the Viewer undefined error by copying everything in the same file and <script> but it still doesn't work. Maybe the Error with the semicolon is the reason. Any help appreciated.

Support Polylines

I believe there is only support for LWPolylines, so we need regular Polylines as well. Dxf-parser's latest version should support them already so it's just a matter of displaying them.

Can't run Three-DXF

Getting this error trying to run this in Angular, tried installing types but like other posts had no success.

 You may need an appropriate loader to handle this file type.
| 
| 		this.texture = source.texture.clone();
| 		this.texture.image = { ...this.texture.image }; // See #20328.
| 
| 		this.depthBuffer = source.depthBuffer;
 @ ./~/three-dxf-loader/dist/three-dxf-loader.js 16:82-98
 @ ./src/app/dxf-viewer/dxf-viewer.component.ts
 @ ./src/app/app.module.ts
 @ ./src/main.ts

Here's the TS file I'm calling it in:

import { Component, OnInit } from '@angular/core';
// import * as THREE from 'three'
import { ThreeDxf } from 'three-dxf-loader'
import DxfParser from 'dxf-parser'

@Component({
  selector: 'app-dxf-viewer',
  templateUrl: './dxf-viewer.component.html',
  styleUrls: ['./dxf-viewer.component.css']
})
export class DxfViewerComponent implements OnInit {
  private file: Blob;
  public dxf;
  public cadCanvas;
  constructor() { }

  ngOnInit() {
  }

  public handleFileInput(fileInput) {
    this.file = fileInput.item(0) as Blob;
    console.log(this.file instanceof Blob);
    let fileReader = new FileReader();
    fileReader.onload = function(e) {
      const parser = new DxfParser();
      try {
        let dxf = parser.parseSync(e.target.result);
        return dxf
      } catch (err) {
        return console.error(err.stack);
      }
    }
    this.dxf = fileReader.readAsText(this.file);
  }

  public renderDxf() {
    // var font;
    // var loader = new THREE.FontLoader();
    // loader.load( 'fonts/helvetiker_regular.typeface.json', function ( response ) {
    //     font = response;
    // this.cadCanvas = new ThreeDxf.Viewer(this.dxf, document.getElementById('cad-view'), 1000, 800);
    // });
  this.cadCanvas = new ThreeDxf.Viewer(this.dxf, document.getElementById('cad-view'), 400, 400);

  }



}

Any tips on what I should do? Thanks!

Uncaught TypeError: (intermediate value).setFromPoints is not a function

I am trying to get three-dxf to work on my liferay tomcat server. I believe I have dxf-parser.js fully working and I have r79 of three.min.js loaded.

When trying to display a dxf with the line
cadCanvas = new window.ThreeDxf.Viewer(dxf,document.getElementById('mainwrap'),400,400,font);

I get the error

Uncaught TypeError: (intermediate value).setFromPoints is not a function
    at drawArc (index.js?b635:445)
    at drawEntity (index.js?b635:212)
    at new Viewer (index.js?b635:112)
    at three.min.js:387
    at XMLHttpRequest.<anonymous> (three.min.js:385)

I was able to get the sample working with the http-server, so I'm not sure why it doesn't work on this server. Is this an issue with the version of three.min.js that I'm using?

Select layers

Hy,
it's possible select layers (example dropdown list) and color single layer?

Cannot see anything in Viewer

I tried to run sample file and uploaded dxf file(api-cw750-details.dxf), but I could not see anything in the viewer as below image. Does anyone know why?
image

Sample code fails to render image of DXF files?

I have just checke out the repository and following the run sample instructions.

On loading a DXF file the page displays the JSON loaded structure but fails to render the DXF objects.

Console shows the following:
three-dxf.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'prototype') at three-dxf.js:1 (anonymous) @ three-dxf.js:1 index.js:59 progress index.js:60 100 index.js:92 Uncaught TypeError: Cannot read properties of undefined (reading 'Viewer') at index.js:92 at Object.onLoad (three.min.js:6) at XMLHttpRequest.<anonymous> (three.min.js:6)

Integrate Three-dxf with a php application to view all the dxf files from a directory

Hi,

I have installed the component and it is great!
Now I would like to view all the dxf files from a directory.
I have these lines in php :

$directory = '\\\\pc0234\docs\data\01';
foreach(scandir($directory) as $file) 
{

<div id="cad-view" name="<?php  echo $directory . $file; ?>"> 
		<?php  echo $directory . $file; ?>
</div>

} 

What do I have to change in the index.js?
Do you have any sample about this?

Thanks, best regards

Can't import

Sorry, beginner in Angular here. I got dxf-parser to install types by running npm install dxf-parser-typings. But three-dxf shows this error after installing it:
Could not find a declaration file for module 'three-dxf'. .../ClientApp/node_modules/three-dxf/dist/three-dxf.js' implicitly has an 'any' type.
Try npm i --save-dev @types/three-dxf if it exists or add a new declaration (.d.ts) file containing declare module 'three-dxf';ts(7016)

I have tried running npm i --save-dev @types/three-dxf, npm install @types/three-dxf, and npm install three-dxf-typings and it shows this error in the console:
npm ERR! code E404
npm ERR! 404 Not Found - GET http://registry.npmjs.org/three-dxf-typings - Not found
npm ERR! 404
npm ERR! 404 'three-dxf-typings@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

Please help :(

Z-index issue

When creating dxf file we can use "mirror" command. It does not change the shape of entity, but change z-extrusion direction, which is not taken to the account in your library when image is drawn.
In my work I make center of ellipce to be the [0,0], then command "curve" look like this:
var curve = new THREE.EllipseCurve( 0, 0, xrad, yrad, alpha, beta, false, rotation );
The trick is to use:
ctx.scale(1, Math.sign(z_extrussion));
while generating image for user, where z_extrussion is our 230 line value.
All we have to do in the end is to move canvas zero position back to it's prewious position.
Thank you for reading :-)

i can't run

i add all dependencies manually but i can't run it. I tried 10 times. Can someone please send me a full local version of this? Thank you so much. I'm a beginner sorry
image

the toShapes doesn't work in three.js

Hello bzuillsmith, I download your project, test it. And I find some questions.The function of toShapes doesn't work, all the word doesn't show in canvas. And do you know how to show the solid graphics in cavans? I find it doesn't show either. I'm looking forward for your reply.Thanks.

Support React

Please, add support to React. If I install the dxf-parse, three and three-dxf, when I import all the modules in my React application:

import DxfParser from 'dxf-parser';

import * as THREE from 'three';

import * as ThreeDxf from 'three-dxf';

I receive an error, THREE is not defined. This error happens because the module three-dxf expect the THREE on global scope:

<script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/101/three.js'></script>

To solve this issue I had import the Dxf Parse and Three Dxf on my React component and the Three in the index.html file. It could be cool to support React by default.

Disposing WebGL objects

If I use this three-dxf user in angular SPA and have several calls to "new ThreeDxf.Viewer" I get an warning "Too many active WebGL contexts. Oldest context will be lost."
What is the best approach to clean up those webgl objects? should I somehow call dispose() on all three.js objects?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.