体量模型
<h1>体量模型</h1>
<h2>类型简要说明</h2>
<p><code>VolumeFloor</code> : 楼层类,表示轮廓线</p>
<p><code>VolumeModel</code> : 体量模型对象类</p>
<p><code>VolumeModelConfig</code> : 体量模型配置类</p>
<p><code>VolumeModelManager</code> : 体量模型管理类</p>
<h2>类型详细说明</h2>
<h2>1.楼层类 - BCore.Extension.Volume.VolumeFloor</h2>
<h3>构造</h3>
<pre><code class="language-javascript">new BCore.Extension.Volume.VolumeFloor(outline: [])</code></pre>
<h3>参数</h3>
<ul>
<li><strong>outline</strong>: <code>[[x,y],[x,y],[x,y],[x,y]]</code><br />
外轮廓线数据,例如 <code>[[0,0],[10,0],[10,10],[0,10]]</code>。</li>
</ul>
<h3>属性</h3>
<ul>
<li><strong>floorElevation</strong>: 楼层起始面高度。</li>
<li><strong>floorHeight</strong>: 楼层拉伸高度。</li>
</ul>
<hr />
<h2>2.体量模型对象类 - BCore.Extension.Volume.VolumeModel</h2>
<h3>构造</h3>
<pre><code class="language-javascript">new BCore.Extension.Volume.VolumeModel(name, volumeFloors, options)</code></pre>
<h3>参数</h3>
<ul>
<li><strong>name</strong>: <code>string</code> - 模型名称。</li>
<li><strong>volumeFloors</strong>: <code>Array</code> - 轮廓数据。</li>
<li><strong>options</strong>: <code>{}</code> - 属性配置选项。</li>
</ul>
<h3>可选参数</h3>
<pre><code class="language-json">{
&quot;position&quot;: {&quot;x&quot;: 0, &quot;y&quot;: 0, &quot;z&quot;: 0}, // 模型世界坐标
&quot;color&quot;: &quot;#BBBBBB&quot;, // 模型颜色
&quot;transparent&quot;: false, // 是否透明
&quot;opacity&quot;: 1, // 透明度
&quot;roughness&quot;: 0.5, // 粗糙度
&quot;metalness&quot;: 0,
&quot;emissive&quot;: 0x0,
&quot;enableBorder&quot;: true, // 是否显示线框
&quot;borderColor&quot;: &quot;#333333&quot;, // 线框颜色
&quot;borderTransparent&quot;: true,
&quot;borderAlphaTest&quot;: 0.1
}</code></pre>
<h3>方法</h3>
<ul>
<li><strong>getGeometryVolume()</strong>: 获得拉伸体体积 (V2.7)。</li>
<li><strong>getRectificationCoordinate(threshold, point: {x,y,z})</strong>: 获得阈值范围内的矫正坐标值 (V2.9.11)。</li>
</ul>
<hr />
<h3>示例:获得拉伸体体积</h3>
<pre><code class="language-javascript">let mVolumeModelConfig = new BCore.Extension.Volume.VolumeModelConfig(mViewer3D);
let mVolumeModelManager = new BCore.Extension.Volume.VolumeModelManager(mVolumeModelConfig);
let mVolumeFloor = new BCore.Extension.Volume.VolumeFloor([[0,0],[10,0],[10,10],[0,10]], []);
let mVolumeModel = new BCore.Extension.Volume.VolumeModel('VolumeName', [mVolumeFloor], {});
mVolumeModelManager.addVolumeModel('VolumeName', mVolumeModel);
let volume = mVolumeModel.getGeometryVolume();</code></pre>
<ul>
<li><strong>返回值</strong>:
<strong>volume</strong>: <code>number</code> - 拉伸体体积。</li>
</ul>
<hr />
<h3>示例:获得阈值范围内的矫正坐标值</h3>
<pre><code class="language-javascript">let correctedPoint = mVolumeModel.getRectificationCoordinate(2, {x: 6, y: 6, z: 10});</code></pre>
<ul>
<li><strong>返回值</strong>:
<strong>result</strong>: <code>{x:number, y:number, z:number}</code> - 矫正后坐标。</li>
</ul>
<hr />
<h2>3.体量模型配置类 - BCore.Extension.Volume.VolumeModelConfig</h2>
<h3>构造</h3>
<pre><code class="language-javascript">new BCore.Extension.Volume.VolumeModelConfig(viewer3D)</code></pre>
<h3>成员</h3>
<ul>
<li><strong>viewer3D</strong>: <code>BCore.Viewer.Viewer3D</code>。</li>
</ul>
<h3>defaultVolumeOptions 参数</h3>
<pre><code class="language-json">{
&quot;color&quot;: &quot;#BBBBBB&quot;,
&quot;transparent&quot;: false,
&quot;opacity&quot;: 1,
&quot;roughness&quot;: 0.8,
&quot;metalness&quot;: 0,
&quot;emissive&quot;: 0x0,
&quot;enableBorder&quot;: true,
&quot;borderColor&quot;: &quot;#333333&quot;,
&quot;borderTransparent&quot;: true,
&quot;borderDepthTest&quot;: true,
&quot;borderAlphaTest&quot;: 0.1
}</code></pre>
<hr />
<h2>4.体量模型管理类 - BCore.Extension.Volume.VolumeModelManager</h2>
<h3>构造</h3>
<pre><code class="language-javascript">new BCore.Extension.Volume.VolumeModelManager(VolumeModelConfig)</code></pre>
<h3>成员</h3>
<ul>
<li><code>VolumeModelConfig</code> : 体量模型配置类。</li>
</ul>
<h3>方法</h3>
<ul>
<li><code>addVolumeModel(name: string, volumeModel: VolumeModel)</code> 添加体量模型</li>
<li><code>deleteVolumeModel(name: string)</code> 移除体量模型</li>
<li><code>deleteAllVolumeModels()</code> 删除所有体量模型</li>
<li><code>addVolumeModelByFileId(fileId: string, namePrefix: string = '', nameSuffix: string = '')</code>
通过fileId加载拉伸体体量模型</li>
<li><code>ddVolumeModelByFileIds(fileId: string[], namePrefix: string = '', nameSuffix: string = '')</code>
通过fileIds加载拉伸体体量模型</li>
<li><code>deleteVolumeModelByFileId(fileId: string)</code> 通过fileId移除拉伸体体量模型</li>
<li><code>addVolumeGLTFByFileId(fileId: string, namePrefix: string = '', nameSuffix: string = '')</code>
通过fileId加载GLTF格式体量模型</li>
<li><code>addVolumeGLTFByFileIds(fileIds: string[], namePrefix: string = '', nameSuffix: string = '')</code>
通过fileIds加载GLTF格式体量模型</li>
<li><code>deleteVolumeGLTFByFileId(fileId: string)</code> 通过fileId移除GLTF格式体量模型</li>
<li><code>setVolumeColorByNames(names: Array, color: string)</code> 颜色设置</li>
<li><code>clearVolumeColorByNames(names: Array)</code> 恢复体量模型颜色</li>
<li><code>setVolumeOpacityByNames(names: Array, opacity: number)</code>透明度设置</li>
<li><code>clearVolumeOpacityByNames(names: Array)</code> 恢复体量模型透明度</li>
<li><code>setWireframeLineColorByNames(names: Array, color: string)</code> 轮廓线颜色设置</li>
<li><code>clearWireframeLineColorByNames(names: Array)</code> 恢复体量模型线框颜色</li>
<li><code>getVolumeCustomsColor()</code> 获取已经自定义颜色的体量模型</li>
<li><code>getVolumeCustomsOpacity()</code> 获取已经自定义透明度的的体量模型</li>
<li><code>getWireframeLineCustomsColor()</code> 获取已经自定义线框颜色的体量模型</li>
<li><code>getVolumeModelBoundingBoxByName(name: string)</code> 通过name返回体量模型boundingBox</li>
<li><code>getAllVolumeModelBoundingBox()</code> 返回所有体量模型boundingBox</li>
<li><code>adjustModelWorldPosition()</code> 体量模型坐标设置</li>
<li><code>adjustModelWorldRotation()</code> 体量模型角度旋转设置</li>
<li><code>adjustModelWorldMatrix()</code> 调整世界矩阵</li>
</ul>
<h3>方法示例</h3>
<h4>1.添加体量模型</h4>
<ul>
<li>
<p><strong>接口</strong>:</p>
<pre><code class="language-javascript">addVolumeModel(name: string, volumeModel: VolumeModel)</code></pre>
</li>
<li><strong>参数</strong>
<strong>name</strong> : <code>string</code> - 名称 volumeModel.name
<strong>volumeModel</strong> : <code>string</code> - 模型 VolumeModel</li>
</ul>
<h4>示例</h4>
<pre><code class="language-javascript">let mVolumeFloor = new BCore.Extension.Volume.VolumeFloor([[0,0],[10,0],[10,10],[0,10]], []);
let mVolumeModelConfig = new BCore.Extension.Volume.VolumeModelConfig(mViewer3D);
let mVolumeModelManager = new BCore.Extension.Volume.VolumeModelManager(mVolumeModelConfig);
let mVolumeModel = new BCore.Extension.Volume.VolumeModel('VolumeName', [mVolumeFloor], {});
mVolumeModelManager.addVolumeModel('VolumeName', mVolumeModel);</code></pre>
<h4>2.移除体量模型</h4>
<ul>
<li>
<p><strong>接口</strong>:</p>
<pre><code class="language-javascript">deleteVolumeModel(name: string)</code></pre>
</li>
<li><strong>参数</strong>
<strong>name</strong> : <code>string</code> - 名称 volumeModel.name</li>
</ul>
<h4>示例</h4>
<pre><code class="language-javascript">mVolumeModelManager.deleteVolumeModel('VolumeName');</code></pre>
<h4>3.自定义体量模型颜色</h4>
<ul>
<li>
<p><strong>接口</strong>:</p>
<pre><code class="language-javascript">setVolumeColorByNames(names: Array, color: string)</code></pre>
</li>
<li><strong>参数</strong>
<strong>names</strong> : <code>Array</code> - 模型名称列表
<strong>color</strong> : <code>string</code> - 将要设置的模型颜色</li>
</ul>
<h4>示例</h4>
<pre><code class="language-javascript">mVolumeModelManager.setVolumeColorByNames([&quot;VolumeName&quot;],&quot;#fff333&quot;);</code></pre>
<h4>4. 通过fileId添加体量模型</h4>
<ul>
<li><strong>接口</strong>:
<pre><code class="language-javascript">addVolumeModelByFileId(fileId: string, namePrefix: string = '', nameSuffix: string = '')
deleteVolumeModelByFileId(fileId: string)
addVolumeGLTFByFileId(fileId: string, namePrefix: string = '', nameSuffix: string = '')
deleteVolumeGLTFByFileId(fileId: string)</code></pre></li>
<li><strong>参数</strong>
<strong>fileId</strong> : <code>string</code> - rvt、ifc模型Id
<strong>namePrefix</strong> : <code>string</code> - 体量模型名称前缀
<strong>nameSuffix</strong> : <code>string</code> - 体量模型名称后缀</li>
</ul>
<h4>示例</h4>
<pre><code class="language-javascript">mViewer3D.addEventListener(BCore.Static.EventType.ModelAdded,(e)=&gt;{//楼层名称 e.floors });
let mVolumeModelConfig = new BCore.Extension.Volume.VolumeModelConfig(mViewer3D);
let mVolumeModelManager = new BCore.Extension.Volume.VolumeModelManager(mVolumeModelConfig );
mVolumeModelManager.addVolumeGLTFByFileId('MFXXXXXXXXXXXXXXX','namePrefix','nameSuffix');</code></pre>
<hr />
<p>以上是 <code>体谅模型</code>的基本介绍及示例。您可以根据需要灵活使用这些类和方法进行操作。如需进一步帮助,请联系我们~</p>