更新了版本
This commit is contained in:
89
docs/ENGINNE_3D/jumpToCamera-使用指南.md
Normal file
89
docs/ENGINNE_3D/jumpToCamera-使用指南.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# jumpToCamera 方法使用指南
|
||||
|
||||
## 概述
|
||||
|
||||
`jumpToCamera` 是 BIM 引擎提供的一个视角跳转方法,允许开发者通过传入相机配置 JSON 数据,将 3D 视图快速定位到指定构件或特定视角。
|
||||
|
||||
## 方法签名
|
||||
|
||||
```javascript
|
||||
engine.engine.jumpToCamera(cameraData)
|
||||
```
|
||||
|
||||
### 参数
|
||||
|
||||
- `cameraData` - 相机配置 JSON 对象
|
||||
|
||||
### 返回值
|
||||
|
||||
- `true` - 跳转成功
|
||||
- `false` - 跳转失败
|
||||
|
||||
## 基本使用
|
||||
|
||||
```javascript
|
||||
// 跳转到指定视角
|
||||
engine.engine.jumpToCamera({
|
||||
type: "orthographic",
|
||||
position: { x: 229.68, y: 247.98, z: 233.79 },
|
||||
target: { x: -4.58, y: 13.72, z: -0.47 },
|
||||
orthographicHeight: 140.56
|
||||
});
|
||||
```
|
||||
|
||||
## 配合 getModelPosition 使用
|
||||
|
||||
```javascript
|
||||
// 1. 获取构件位置数据(返回的 modelJson 中包含 cameraRestorePose)
|
||||
const data = engine.engine.getModelPosition({
|
||||
url: "模型URL",
|
||||
ids: [465979]
|
||||
});
|
||||
|
||||
// 2. 使用返回的 cameraRestorePose 跳转视角
|
||||
if (data?.modelJson?.cameraRestorePose) {
|
||||
engine.engine.jumpToCamera(data.modelJson.cameraRestorePose);
|
||||
}
|
||||
```
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. 调用前确保引擎已初始化
|
||||
2. 参数为 JSON 对象格式
|
||||
3. 数据可通过 `getModelPosition` 方法获取
|
||||
|
||||
## 完整示例
|
||||
|
||||
```javascript
|
||||
const engine = new BimEngine(container, { theme: 'dark' });
|
||||
|
||||
// 初始化引擎
|
||||
engine.engine.initialize({
|
||||
version: 'v2',
|
||||
showStats: false,
|
||||
showViewCube: true
|
||||
});
|
||||
|
||||
// 加载模型
|
||||
engine.engine.loadModel(['模型URL'], {
|
||||
position: [0, 0, 0],
|
||||
rotation: [0, 0, 0],
|
||||
scale: [1, 1, 1]
|
||||
});
|
||||
|
||||
// 获取构件位置并跳转
|
||||
const componentData = engine.engine.getModelPosition({
|
||||
url: "模型URL",
|
||||
ids: [465979]
|
||||
});
|
||||
|
||||
if (componentData?.modelJson?.cameraRestorePose) {
|
||||
const success = engine.engine.jumpToCamera(
|
||||
componentData.modelJson.cameraRestorePose
|
||||
);
|
||||
|
||||
if (success) {
|
||||
console.log('跳转成功');
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user