-
Notifications
You must be signed in to change notification settings - Fork 172
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
Unable to load ThreeDxf from the window object in React #63
Comments
Sorry, I'm not familiar enough with react to have an immediate answer. I've been meaning to try to create a react sample so I can learn and have it available for people. If anyone wants to make a PR with a simple react sample, I'd happily merge it in. |
Hmm.... /node_modules/three-dxf/src/index.js + import { TextGeometry } from 'three/examples/jsm/geometries/TextGeometry'
// line: 570
- geometry = new THREE.TextGeometry(entity.text, { font: font, height: 0, size: entity.textHeight || 12 });
+ geometry = new TextGeometry(entity.text, { font: font, height: 0, size: entity.textHeight || 12 }); And... import { FontLoader } from 'three/examples/jsm/loaders/FontLoader'
//@ts-ignore
import DxfParser from 'dxf-parser'
//@ts-ignore
- import { Viewer } from 'three-dxf'
+ import { Viewer } from 'three-dxf/src/index' Demo:
Please Note:In the above example code, I use vite + react + typescript. I tried to use 'create-react-app', but I encountered this error:
We know that the create-react-app uses weback4. I think weback4 does not support it, but I haven't found a solution. Therefore, there are only two solutions: use |
I've the same problem ,I hope the author could solve it. |
I am trying to load the three-dxf script into my React app using below.
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 undefinedAny idea why the window object does not contain ThreeDxf?
The text was updated successfully, but these errors were encountered: