cesium 模型设置中心点
时间: 2023-08-01 17:10:19 浏览: 356
在Cesium中,可以使用`Entity`对象来表示3D模型并设置其位置、方向和缩放。要设置模型的中心点,可以使用`position`属性指定模型的位置,然后使用`modelMatrix`属性来进一步调整模型的方向和缩放。
例如,以下代码将把一个3D模型放置在地球表面上,并将其中心点设置为模型底部的中心:
```javascript
var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(position);
var model = viewer.entities.add({
name: 'My Model',
position: position,
orientation: orientation,
model: {
uri: 'path/to/model.gltf',
scale: 1.0,
minimumPixelSize: 128,
maximumScale: 20000,
runAnimations: true,
clampAnimations: true
},
modelMatrix: Cesium.Matrix4.multiply(modelMatrix, Cesium.Transforms.headingPitchRollToFixedFrame(new Cesium.HeadingPitchRoll(0, 0, 0))),
});
```
在这里,`position`是模型的位置,可以是`Cartesian3`对象或`Cartographic`对象。`modelMatrix`使用`eastNorthUpToFixedFrame`函数将模型从地球表面的位置转换为固定坐标系中的位置。然后,`modelMatrix`与`headingPitchRollToFixedFrame`函数一起使用,可以更进一步地调整模型的方向和缩放。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)