pattern-x / gemini-viewer-examples

Examples and demos for gemini-viewer sdk, which is a WebGL based BIM model viewer, built on three.js. It is used to view dwg/dxf, gltf, obj, ifc models, etc.
169 stars 40 forks source link

自适应 #128

Open Super-Xiao opened 3 months ago

Super-Xiao commented 3 months ago

老哥 怎么默认加载dxf自适应宽高呢

yanzexuan1 commented 3 months ago

I don't quite understand your question. After a dxf is loaded, it automatically zoom to the "home" view, which is defined in the dxf itself.

Do you want it to zoom to graphic extent rather than the original "home" view? To do so, you can firstly get the graphic extent, then zoom to it:

const extent = viewer.getActiveLayoutInfo().extent;
viewer.zoomToBBox(extent);
Super-Xiao commented 3 months ago

image 目前我加载完成dxf是这样的 被放大了很多。

yanzexuan1 commented 3 months ago

Oh, please try this:

const bbox = viewer.getBBox();
viewer.zoomToBBox(bbox);
Super-Xiao commented 3 months ago

使用这段代码后 image

yanzexuan1 commented 3 months ago

Can you check carefully, if there is any small entity somewhere in the corner? That often happen. Or, you can create a new dxf, draw some entities and test again.