cesium primitive立方体沿着y轴旋转 90 度代码
时间: 2023-04-03 11:01:13 浏览: 260
以下是 C 知道的回答:
可以使用以下代码将 Cesium primitive 立方体沿着 y 轴旋转 90 度:
```javascript
var entity = viewer.entities.add({
name: 'Rotating box',
position: Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
box: {
dimensions: new Cesium.Cartesian3(400000., 300000., 500000.),
material: Cesium.Color.RED
}
});
var initialOrientation = Cesium.Transforms.headingPitchRollQuaternion(
entity.position.getValue(viewer.clock.currentTime),
new Cesium.HeadingPitchRoll(., ., .)
);
var rotatingOrientation = Cesium.Quaternion.multiply(
Cesium.Quaternion.fromAxisAngle(Cesium.Cartesian3.UNIT_Y, Cesium.Math.toRadians(90)),
initialOrientation,
new Cesium.Quaternion()
);
viewer.clock.onTick.addEventListener(function(clock) {
var angle = Cesium.Math.TWO_PI * (clock.currentTime.secondsOfDay / 240.);
var axis = new Cesium.Cartesian3(Math.cos(angle), Math.sin(angle), Math.sin(angle));
entity.orientation = Cesium.Quaternion.multiply(
Cesium.Quaternion.fromAxisAngle(axis, angle),
rotatingOrientation,
new Cesium.Quaternion()
);
});
```
希望能对您有所帮助。
阅读全文