Open kamildul opened 1 year ago
Hi! You can use DxfViewer.GetScene()
method to obtain three.js
scene object which can be used to add any additional objects to render. To match model space coordinates you should subtract scene origin from your objects coordinates. The origin can be obtained by DxfViewer.GetOrigin()
method.
Hi Vagran,
thanks for your response, where is tutorial for instalation without node, i want install only javascript+html version.
When i install via node cmd with command : npm install dxf-viewer I get the result:
I dont see example version in HTML + Javascript :-(
There is currently no any bundle build. You can find usage example in typical full-featured web application here.
Will this compilation be available?
Currently it is not planned for this version. Bundle building is planned for next major release which will be rewritten in TypeScript.
I understand, can you help me run your solution from the simplest version without node to open a dxf file? Only html and js?
I doubt I can help there, since I am not really familiar with modern web application build toolchain, so I also need to spend some time for some research. You may invest your time in learning some of web building tools (like rollup, webpack, esbuild etc.) and producing a bundle. Then check the code in the example mentioned above to get basic understanding how the library is used.
Ok, where i find documentation?
The library API is documented by JsDoc comments in the source code.
Thanks, but still i dont know how i can run this library, i need simple example only index.html where i add patch to the dxf file, and finally in browser index.html show dxf file...
@vagran Hello, I also need to add some text or image markers in the model, but I haven't implemented them according to the code below. Is there a problem with my coordinate settings
let scene = this.dxfViewer.GetScene()
let origin = new THREE.Vector2
origin = this.dxfViewer.GetOrigin()
const loader = new FontLoader()
loader.load('./static/ThreeFont/Alibaba PuHuiTi_Regular.json', (font) => {
const textGeometry = new TextGeometry('测试', {
font: font,
size: size,
height: 1000,
curveSegments: 1,
bevelEnabled: false,
bevelThickness: 0.1,
bevelSize: 0.1,
bevelSegments: 3
})
const textMaterial = new THREE.MeshBasicMaterial({color: color})
const textMesh = new THREE.Mesh(textGeometry, textMaterial)
textMesh.position.set(0-origin.x,0-origin.y,0)
scene.add(textMesh)
})
@vagran Hello, I also need to add some text or image markers in the model, but I haven't implemented them according to the code below. Is there a problem with my coordinate settings
let scene = this.dxfViewer.GetScene() let origin = new THREE.Vector2 origin = this.dxfViewer.GetOrigin() const loader = new FontLoader() loader.load('./static/ThreeFont/Alibaba PuHuiTi_Regular.json', (font) => { const textGeometry = new TextGeometry('测试', { font: font, size: size, height: 1000, curveSegments: 1, bevelEnabled: false, bevelThickness: 0.1, bevelSize: 0.1, bevelSegments: 3 }) const textMaterial = new THREE.MeshBasicMaterial({color: color}) const textMesh = new THREE.Mesh(textGeometry, textMaterial) textMesh.position.set(0-origin.x,0-origin.y,0) scene.add(textMesh) })
Hello, your code looks good at first glance. Coordinates 0-origin.x,0-origin.y,0
assume that you are adding text to the 0;0
coordinates of the model space. Are you sure your model is defined near the model space origin? In some cases (e.g. georeferenced models) it might be far from origin. Also check that size and color is visible. Also you might want to check it on some very simple synthetic DXF (e.g. with single line near origin) before trying on real one.
Hi everyone! i have a question: It is possible add function for drawing line, polyline or other elements? Thanks!