CAD图纸
<h1>CAD图纸</h1>
<h2>一、BCore.Extension.CAD.CadConfig</h2>
<p><strong>构造:</strong> </p>
<pre><code class="language-javascript">new BCore.Extension.CAD.CadConfig(viewer)</code></pre>
<p><strong>成员:</strong></p>
<table>
<thead>
<tr>
<th>成员变量</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>viewer</td>
<td>BCore.Viewer.Viewer3D</td>
<td>视图对象</td>
</tr>
</tbody>
</table>
<hr />
<h2>二、 BCore.Extension.CAD.Cad</h2>
<p><strong>构造:</strong> </p>
<pre><code class="language-javascript">new BCore.Extension.CAD.Cad(config)</code></pre>
<p><strong>参数:</strong></p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>必选</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>config</td>
<td>是</td>
<td>BCore.Extension.CAD.CadConfig</td>
<td>CAD图纸模型配置参数对象</td>
</tr>
</tbody>
</table>
<p><strong>方法总览:</strong></p>
<ul>
<li>
<p><strong>addCadData(fileId)</strong><br />
加载CAD图纸模型(仅支持加载图形引擎极速解析的图纸)。</p>
</li>
<li>
<p><strong>deleteCadData(fileId)</strong><br />
删除CAD图纸模型。</p>
</li>
<li>
<p><strong>adjustCadWorldPosition(fileId, position)</strong><br />
调整CAD图纸模型位置。</p>
</li>
<li>
<p><strong>adjustDrawingTransform(fileId, position, angle, scale)</strong><br />
调整CAD图纸模型位置、旋转、缩放。</p>
</li>
<li>
<p><strong>hideCadDataByLayerNames(layerNames: Array)</strong><br />
通过图纸图层名隐藏CAD。</p>
</li>
<li>
<p><strong>showCadDataByLayerNames(layerNames: Array)</strong><br />
通过图纸图层名显示CAD。</p>
</li>
<li>
<p><strong>showAllCadData()</strong>
显示所有CAD数据。</p>
</li>
<li>
<p><strong>getHiddenObjectsLayerNames()</strong><br />
返回已隐藏的图层名。</p>
</li>
<li>
<p><strong>setDrawingdepthTest(fileId, type: boolean)</strong><br />
是否设置图纸深度检测(图纸是否被遮)。</p>
</li>
<li>
<p><strong>setSectionBox(fileId, box: THREE.B3)</strong><br />
根据box范围裁切图纸(前后左右四面)。</p>
</li>
<li>
<p><strong>resetSectionBox(fileId)</strong><br />
关闭根据box范围裁切图纸。</p>
</li>
<li><strong>rotateDrawing(fileId, radius: number)</strong><br />
旋转图纸(绕z轴)。</li>
</ul>
<hr />
<h3>示例</h3>
<h4>1. 加载CAD图纸模型</h4>
<pre><code class="language-javascript">let mCadConfig = new BCore.Extension.CAD.CadConfig(mViewer3D);
let mCad = new BCore.Extension.CAD.Cad(mCadConfig);
mCad.addCadData(fileId);</code></pre>
<h4>2. 删除CAD图纸模型</h4>
<pre><code class="language-javascript">let mCadConfig = new BCore.Extension.CAD.CadConfig(mViewer3D);
let mCad = new BCore.Extension.CAD.Cad(mCadConfig);
mCad.deleteCadData(fileId);</code></pre>
<h4>3. 调整CAD图纸模型位置</h4>
<pre><code class="language-javascript">let mCadConfig = new BCore.Extension.CAD.CadConfig(mViewer3D);
let mCad = new BCore.Extension.CAD.Cad(mCadConfig);
mCad.addCadData(fileId);
mCad.adjustCadWorldPosition(fileId, {x: 0, y: 0, z: 10});</code></pre>
<h4>4. 调整CAD图纸模型位置、旋转、缩放</h4>
<pre><code class="language-javascript">let mCadConfig = new BCore.Extension.CAD.CadConfig(mViewer3D);
let mCad = new BCore.Extension.CAD.Cad(mCadConfig);
mCad.addCadData(fileId);
mCad.adjustDrawingTransform(fileId, {x: 0, y: 0, z: 10}, Math.PI / 2, 0.5);</code></pre>
<h4>5. 通过图纸图层名隐藏CAD</h4>
<pre><code class="language-javascript">let mCadConfig = new BCore.Extension.CAD.CadConfig(m3D);
let mCad = new BCore.Extension.CAD.Cad(mCadConfig);
mCad.addCadData(fileId);
mCad.hideCadDataByLayerNames([&#039;&#039;]);</code></pre>
<h4>6. 通过图纸图层名显示CAD</h4>
<pre><code class="language-javascript">let mCadConfig = new BCore.Extension.CAD.CadConfig(mViewer3D);
let mCad = new BCore.Extension.CAD.Cad(mCadConfig);
mCad.addCadData(fileId);
mCad.showCadDataByLayerNames([&#039;0&#039;]);</code></pre>
<h4>7. 显示所有</h4>
<pre><code class="language-javascript">let mCadConfig = new BCore.Extension.CAD.CadConfig(mViewer3D);
let mCad = new BCore.Extension.CAD.Cad(mCadConfig);
mCad.addCadData(fileId);
mCad.hideCadDataByLayerNames([&#039;0&#039;]);
mCad.showAllCadData();</code></pre>
<h4>8. 返回已隐藏的图层名</h4>
<pre><code class="language-javascript">let mCadConfig = new BCore.Extension.CAD.CadConfig(mViewer3D);
let mCad = new BCore.Extension.CAD.Cad(mCadConfig);
mCad.addCadData(fileId);
mCad.hideCadDataByLayerNames([&#039;0&#039;]);
let result = mCad.getHiddenObjectsLayerNames();
console.log(result); // 输出已隐藏图层名数组</code></pre>
<hr />
<p>以上是CAD图纸相关的API文档和使用示例~</p>