3.5 KiB
3.5 KiB
| outline | ||
|---|---|---|
|
ParametricBox
- 源文件:
packages/sdk/src/parametric/ParametricBox.ts - 文档位置:
packages/docs/api/parametric/ParametricBox.md
类:ParametricBox
- 作用:高精度参数化长方体 支持完全自定义的长方体生成,包括宽度、高度、深度、分段数等参数
- 继承/实现:
extends Mesh<BufferGeometry, Material>;implements IParametricGeometry
构造函数
new ParametricBox(options: IBoxOptions = {})
-
作用:创建参数化长方体
-
入参:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
options |
IBoxOptions |
否 | - 长方体配置选项 |
- 出参:
ParametricBox - 返回说明:返回当前类实例。
属性
| 属性名 | 可见性 | 类型 | 作用 |
|---|---|---|---|
options |
public |
Required<IBoxOptions> |
用于保存 options 对应的数据。 |
clippingPlanes |
public |
Plane[] |
用于保存 clippingPlanes 的集合数据。 |
bvhHelper |
public |
BVHHelper | null |
用于保存 bvhHelper 对应的数据。 |
方法
createGeometry(): BoxGeometry
-
作用:创建长方体几何体
-
入参:无
-
出参:
BoxGeometry -
返回说明:返回
BoxGeometry。
updateParameters(options: Partial<IBoxOptions>): void
-
作用:更新长方体参数
-
入参:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
options |
Partial<IBoxOptions> |
是 | - 新的长方体配置选项 |
- 出参:
void - 返回说明:无返回值。
updateGeometry(): void
-
作用:更新几何体
-
入参:无
-
出参:
void -
返回说明:无返回值。
getBVHBoundingBox(): Box3 | undefined
-
作用:获取 BVH 包围盒
-
入参:无
-
出参:
Box3 \| undefined -
返回说明:返回
Box3 | undefined。
createClippingPlanes(): Plane[]
-
作用:创建对应长方体 6 个面的裁剪平面
-
入参:无
-
出参:
Plane[] -
返回说明:包含 6 个 THREE.Plane 的数组 [右, 左, 上, 下, 前, 后]
updateClippingPlanes(): void
-
作用:更新裁剪平面
-
入参:无
-
出参:
void -
返回说明:无返回值。
dispose(): void
-
作用:销毁资源
-
入参:无
-
出参:
void -
返回说明:无返回值。
createDebugPanel(viewer: Viewer): void
-
作用:创建调试面板
-
入参:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
viewer |
Viewer |
是 | 关联的 Viewer 实例。 |
- 出参:
void - 返回说明:无返回值。
构造示例
- 来源:
packages/demo/src/hooks/useRockSample.ts
const boxMaterial = createRock6Material({
opacity: 0.6,
// depthWrite:false
});
const box = new ParametricBox({
width: 5,
height: 5,
depth: 5,
material: boxMaterial
});
- 来源:
packages/demo/src/hooks/useSection.ts
const viewer = bus.getViewer();
const section = new ParametricBox({
width: 0.1,
height: 4.8,
depth: 4.7,
material: createRock2Material({}, false)
});
section.name = "断面";
函数示例
- 当前 Demo 中没有直接展示
ParametricBox的公开方法调用。
Demo 参考
ParametricBox
以下示例文件中可以看到该 API 的实际调用方式:
packages/demo/src/hooks/Bus.tspackages/demo/src/hooks/useRockSample.tspackages/demo/src/hooks/useSection.tspackages/demo/src/panels/TunnelScene/DisturbanceLoadingPanel.vue