模型操作
<h1>BCore.Viewer.Viewer3D</h1>
<h2>构造函数</h2>
<pre><code class="language-javascript">new BCore.Viewer.Viewer3D(config)</code></pre>
<h3>参数</h3>
<table>
<thead>
<tr>
<th>参数名</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>config</td>
<td>BCore.Viewer.Viewer3DConfig</td>
<td>三维模型视图对象的配置</td>
</tr>
</tbody>
</table>
<hr />
<h2>方法总览</h2>
<ul>
<li><code>addModel(fileId)</code> 添加模型</li>
<li><code>addModels(fileIds)</code> 添加多个模型</li>
<li><code>addSplitModel(fileId: string, splitIds: string[], isAsync = false)</code> 添加拆分模型</li>
<li><code>removeModel(fileId)</code> 移除模型</li>
<li><code>removeSplitModel(fileId)</code> 移除拆分模型</li>
<li><code>removeSplitModel(fileId, splitIds?: string[])</code> 移除拆分模型</li>
<li><code>showModel(fileId)</code> 显示指定模型</li>
<li><code>hideModel(fileId)</code> 隐藏指定模型</li>
<li><code>setShowView(fileId,viewId)</code> 设置RFA显示视图</li>
<li><code>getModelsBoundingBox()</code> 获取场景中所有模型的BoundingBox</li>
<li><code>getModelBoundingBoxByFileId(fileId)</code> 获取指定模型的BoundingBox</li>
<li><code>getModelGuids(fileId)</code> 获取指定模型的guids</li>
<li><code>setModelPosition(fileId,position)</code> 设置模型世界坐标增量</li>
<li><code>setModelRotation(fileId,rotation)</code> 设置模型自身三轴旋转增量</li>
<li><code>setBloomWireframeLine(fileId, color)</code> 设置线框发光</li>
<li><code>showModelWireframeLine(fileId)</code> 展示模型线框</li>
<li><code>hideModelWireframeLine(fileId)</code> 隐藏模型线框</li>
<li><code>openSectionByDrawing(drawingId,fileId)</code> 开启模型根据图纸裁切(可调整图纸位置剖切模型)</li>
<li><code>setObitCenter(box:THREE.BOX3)</code> 设置场景的操作中心</li>
</ul>
<h2>方法示例</h2>
<h3>1. 添加模型</h3>
<pre><code class="language-javascript">viewer3D.addModel(fileId)</code></pre>
<p><strong>简要描述:</strong> 在场景中添加模型</p>
<p><strong>参数:</strong></p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>必选</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>fileId</td>
<td>是</td>
<td>string</td>
<td>模型访问凭证,模型列表信息中获取</td>
</tr>
</tbody>
</table>
<p><strong>示例:</strong></p>
<pre><code class="language-javascript">let viewer3dConfig = new BCore.Viewer.Viewer3DConfig();
let viewer3D = new BCore.Viewer.Viewer3D(viewer3dConfig);
viewer3D.addModel(&quot;abc&quot;);</code></pre>
<hr />
<h3>2. 添加多个模型</h3>
<pre><code class="language-javascript">viewer3D.addModels(fileIds)</code></pre>
<p><strong>简要描述:</strong> 在场景中添加多个模型。</p>
<p><strong>参数:</strong></p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>必选</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>fileIds</td>
<td>是</td>
<td>Array</td>
<td>访问凭证数组,从模型列表信息中获取</td>
</tr>
</tbody>
</table>
<p><strong>示例:</strong></p>
<pre><code class="language-javascript">let viewer3dConfig = new BCore.Viewer.Viewer3DConfig();
let viewer3D = new BCore.Viewer.Viewer3D(viewer3dConfig);
viewer3D.addModels([&quot;abc&quot;, &quot;def&quot;]);</code></pre>
<hr />
<h3>3. 移除模型</h3>
<pre><code class="language-javascript">viewer3D.removeModel(fileId)</code></pre>
<p><strong>简要描述:</strong> 从场景中移除模型。</p>
<p><strong>参数:</strong></p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>必选</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>fileId</td>
<td>是</td>
<td>string</td>
<td>模型访问凭证</td>
</tr>
</tbody>
</table>
<p><strong>示例:</strong></p>
<pre><code class="language-javascript">let viewer3dConfig = new BCore.Viewer.Viewer3DConfig();
let viewer3D = new BCore.Viewer.Viewer3D(viewer3dConfig);
viewer3D.removeModel(&quot;abc&quot;);</code></pre>
<hr />
<h3>4. 显示指定模型</h3>
<pre><code class="language-javascript">viewer3D.showModel(fileId)</code></pre>
<p><strong>简要描述:</strong> 显示指定模型。</p>
<p><strong>参数:</strong></p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>必选</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>fileId</td>
<td>是</td>
<td>string</td>
<td>模型访问凭证</td>
</tr>
</tbody>
</table>
<p><strong>示例:</strong></p>
<pre><code class="language-javascript">let viewer3dConfig = new BCore.Viewer.Viewer3DConfig();
let viewer3D = new BCore.Viewer.Viewer3D(viewer3dConfig);
viewer3D.showModel(&quot;abc&quot;);</code></pre>
<hr />
<h3>5. 隐藏指定模型</h3>
<pre><code class="language-javascript">viewer3D.hideModel(fileId)</code></pre>
<p><strong>简要描述:</strong> 隐藏指定模型。</p>
<p><strong>参数:</strong></p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>必选</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>fileId</td>
<td>是</td>
<td>string</td>
<td>模型访问凭证</td>
</tr>
</tbody>
</table>
<p><strong>示例:</strong></p>
<pre><code class="language-javascript">let viewer3dConfig = new BCore.Viewer.Viewer3DConfig();
let viewer3D = new BCore.Viewer.Viewer3D(viewer3dConfig);
viewer3D.hideModel(&quot;abc&quot;);</code></pre>
<hr />
<h3>6. 获取所有模型的包围盒(BoundingBox)</h3>
<pre><code class="language-javascript">mViewer3D.getModelsBoundingBox()</code></pre>
<p><strong>简要描述:</strong> 获取所有模型的整体范围。</p>
<p><strong>示例:</strong></p>
<pre><code class="language-javascript">let boundingBox = mViewer3D.getModelsBoundingBox();</code></pre>
<hr />
<h3>7. 获取指定模型的包围盒</h3>
<pre><code class="language-javascript">mViewer3D.getModelBoundingBoxByFileId(fileId)</code></pre>
<p><strong>简要描述:</strong> 获取指定模型的包围盒。</p>
<p><strong>参数:</strong></p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>必选</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>fileId</td>
<td>是</td>
<td>string</td>
<td>模型访问凭证</td>
</tr>
</tbody>
</table>
<p><strong>示例:</strong></p>
<pre><code class="language-javascript">let boundingBox = mViewer3D.getModelBoundingBoxByFileId(fileId);</code></pre>
<hr />
<h3>8. 获取指定模型的构件 ID</h3>
<pre><code class="language-javascript">mViewer3D.getModelGuids(fileId)</code></pre>
<p><strong>简要描述:</strong> 获取已加载的指定模型的构件 ID,仅支持 IFC/RVT 模型。</p>
<p><strong>参数:</strong></p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>必选</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>fileId</td>
<td>是</td>
<td>string</td>
<td>模型访问凭证</td>
</tr>
</tbody>
</table>
<p><strong>示例:</strong></p>
<pre><code class="language-javascript">let guids = mViewer3D.getModelGuids('fileId');
// 快速选中指定的已加载模型
mViewer3D.setSelectedByGuids(guids);</code></pre>
<p><strong>返回值说明:</strong></p>
<ul>
<li>string[]:模型 guids</li>
</ul>
<hr />
<h3>9. 设置模型世界坐标增量</h3>
<pre><code class="language-javascript">viewer3D.setModelPosition(fileId, position)</code></pre>
<p><strong>简要描述:</strong> 设置模型世界坐标增量。</p>
<p><strong>参数:</strong></p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>必选</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>fileId</td>
<td>是</td>
<td>string</td>
<td>模型访问凭证</td>
</tr>
<tr>
<td>position</td>
<td>是</td>
<td>{ x: number, y: number, z: number }</td>
<td>三轴偏移量</td>
</tr>
</tbody>
</table>
<p><strong>示例:</strong></p>
<pre><code class="language-javascript">viewer3D.setModelPosition(fileId, { x: 10, y: 0, z: 0 });</code></pre>
<hr />
<h3>10. 设置模型自身三轴旋转增量</h3>
<pre><code class="language-javascript">viewer3D.setModelRotation(fileId, rotation)</code></pre>
<p><strong>简要描述:</strong> 设置模型自身三轴旋转增量。</p>
<p><strong>参数:</strong></p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>必选</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>fileId</td>
<td>是</td>
<td>string</td>
<td>模型访问凭证</td>
</tr>
<tr>
<td>rotation</td>
<td>是</td>
<td>{ x: number, y: number, z: number }</td>
<td>三轴旋转量,弧度制</td>
</tr>
</tbody>
</table>
<p><strong>示例:</strong></p>
<pre><code class="language-javascript">viewer3D.setModelRotation(fileId, { x: Math.PI, y: Math.PI / 2, z: 0 });</code></pre>
<hr />
<p>以上是关于 <code>BCore.Viewer.Viewer3D</code> 的详细使用文档,如有进一步的问题,请随时联系我们~</p>