Loading 2D dwg model to threejs

floor plan.zip (610.9 KB)

I have converted a 2D DWG model to a JSON file. After that I have uploaded it in threejs editor. I am able to see some of part of model by scrolling in/out and I am unable to see the complete model. Could you please tell how do i fix this issue?

I have attached the file. Please check.

Can you please explain how this conversion was performed?

We are using https://www.prototechsolutions.com/product/json-exporter-autocad/ to convert the drawing into JSON.

I get this in the editor (after scaling down the model):


How does it supposed to look like? Can you please share a screenshot that shows the expected result?

Thank you for your response. The one in you image is correct.

But, this is how it loads for me in the ThreeJS Viewer.

1 Like

Try to decrease the scale of the top-most floor plan object. The scale of the model is huge and thus not properly renderable in the editor’s viewport.

1 Like

I have scaled the image and getting the almost correct 2D image. But there are slight mistakes, some model objects are sticking out of the image hence making it a 3D model. Could you please tell me how do I fix this? I also want to view this image as 2D image only no 3D. Could you please how do I do this? Please check the following images: -

The original Image:-

Scaled Images(with slight mistakes):-

I would report this issue to the developers of the JSON exporter. As a quick fix, you could iterate over the vertices of your model and ensure that all of them lie in a XY plane. So all vertices would have the same z-coordinate. Keep in mind that this is something you have to do in code and not with the editor.

You could render the scene with an orthographic camera into a render target which could then be used as a texture. Rendering with an orthographic camera might also solve the with the exposed objects (since no perspective is used anymore).

Thank you for your response. Is it possible to auto-scale to fit the viewport programatically?

Double-clicking on the outliner’s entry should focus the object. You can also select the floor-plan and hit f.

Could you please which file shall I edit for setting the default scale size to 0.001? Is it Command.js, Editor.js or Loader.js?

Since you are loading JSON it might make sense to adjust this code section:

result represent the loaded JSON. You can make adjustments like result.scale.multiplyScalar( 0.001 ) in the onLoad() callback (before the commands are created).

is there any api to achieve this. Means dwg to json converter

Thanks

1 Like