Loading Errors
Opened this issue · 5 comments
lucas-vitrus commented
I got these errors repetitively when using with r3f, while loading the sample .dxf file on this repo:
![image](https://private-user-images.githubusercontent.com/133435610/300240124-ef29364a-37aa-48a1-bb31-d0de2c6171a1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk4MTU1MjIsIm5iZiI6MTcxOTgxNTIyMiwicGF0aCI6Ii8xMzM0MzU2MTAvMzAwMjQwMTI0LWVmMjkzNjRhLTM3YWEtNDhhMS1iYjMxLWQwZGUyYzYxNzFhMS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcwMVQwNjI3MDJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mNmU5YTkwNDM1NDk0MzczMmQ3NTE2NjI5ZThjZjRkYTU4YmU5OWJiMDNlZDg3Y2NiOTkxODc2YmJmOGE0OWQwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.lYMbmB6uNaZyILPNvHmSyUet_VRjMXVy-kYepybcy7s)
three-dxf-loader.js?v=c58e8641:4786 Text is not supported without a Three.js font loaded with THREE.FontLoader! Load a font of your choice and pass this into the constructor. See the sample for this repository or Three.js examples at http://threejs.org/examples/?q=text#webgl_geometry_text for more details.
Unsupported Entity Type: ATTDEF
lucas-vitrus commented
Font problem solved (based on documentation)
import { FontLoader } from "three/examples/jsm/loaders/FontLoader";
//@ts-ignore
import { DXFLoader } from "three-dxf-loader";
interface DFXObjectProps {
url: string;
}
const fontLoader = new FontLoader();
const DFXObject = (props: DFXObjectProps) => {
const group = new THREE.Group();
fontLoader.load("/fonts/helvetiker_regular.typeface.json", (font) => {
const loader = new DXFLoader();
loader.setFont(font); //<< Solved one of the issues related to Text
const onLoad = (data: any) => {
if (data && data.entities) {
data.entities.forEach((ent: any) => group.add(ent));
}
};
const onError = (error: any) => {
console.error(error);
};
const onProgress = (xhr: any) => {
console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
};
loader.load(props.url, onLoad, onProgress, onError);
});
return <primitive object={group} />;
};
lucas-vitrus commented
vasco3 commented
I'm getting this error
⚠ ../../node_modules/.pnpm/three-dxf-loader@5.0.0_three@0.163.0/node_modules/three-dxf-loader/dist/three-dxf-loader.js
Attempted import error: 'TextGeometry' is not exported from 'three' (imported as 'e').
Import trace for requested module:
../../node_modules/.pnpm/three-dxf-loader@5.0.0_three@0.163.0/node_modules/three-dxf-loader/dist/three-dxf-loader.js
using
- pnpm 8.15.7
- "three-dxf-loader": "^5.0.0",
- "three-stdlib": "^2.29.6",
- "three": "^0.163.0",
- "react": "18.2.0",
- "next": "14.2.1", // seems like it started happening in this next.js version
Hastu004 commented
vasco3 commented
it is breaking my next.js build when i upgrade this lib from v5 to v5.1
The error is about not finding the import font-loader.
I think it is because now the FontLoader is in another path within threejs
https://threejs.org/docs/index.html?q=fontlo#examples/en/loaders/FontLoader
import { FontLoader } from 'three/addons/loaders/FontLoader.js';