MRzh@yx12138
2020-09-16 14:17在Cesium.js中围绕顶点旋转锥体
参考资料得知可以设置偏移量, 有没有办法计算任何滚动值的正确偏移量?
我还想在旋转锥体时延长锥体的长度,这样当它旋转30度时,锥体的底部仍然会在那个方向上到达地面,而顶点仍然保持在原来的位置,我不知道这有多可行。
var viewer = new Cesium.Viewer('cesiumContainer');
var position = Cesium.Cartesian3.fromDegrees(-75, 40, 90);
//Original, non-rotated cone for comparison.
viewer.entities.add(new Cesium.Entity({
position: position,
point: {
color: Cesium.Color.YELLOW,
show: true,
pixelSize: 20
},
cylinder: {
topRadius: 0,
bottomRadius: 45,
length: 180,
material: Cesium.Color.YELLOW.withAlpha(0.5)
}
}));
var heading = Cesium.Math.toRadians(0.0);
var pitch = Cesium.Math.toRadians(0.0);
var roll = Cesium.Math.toRadians(90.0);
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
//Create a rotation
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);
// offset the rotation so it's rotating from the apex of the cone, instead of the centre
var offset = new Cesium.Cartesian3(0, 90, 90);
//Create a transform for the offset.
var enuTransform = Cesium.Transforms.eastNorthUpToFixedFrame(position);
//Transform the offset
Cesium.Matrix4.multiplyByPointAsVector(enuTransform, offset, offset);
//Add the offset to the original position to get the final value.
Cesium.Cartesian3.add(position, offset, position);
viewer.entities.add(new Cesium.Entity({
position: position,
orientation: orientation,
point: {
color: Cesium.Color.YELLOW,
show: true,
pixelSize: 20
},
cylinder: {
topRadius: 0,
bottomRadius: 45,
length: 180,
material: Cesium.Color.YELLOW.withAlpha(0.5)
}
}));
viewer.zoomTo(viewer.entities);
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- 将切片调整为新顺序
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 1个回答
- Dojo-UI框架浏览器兼容问题
- dojo
- javascript
- 0个回答
- 多个事件触发相同的函数
- javascript
- events
- jquery
- 0个回答
- js不是不需要编译吗,Cesium修改源码后为何还要编译,编译这个过程作了什么?
- javascript
- cesium
- 2个回答
- 任意多边形拆分长多个三角形
- 算法
- 多边形拆分
- 4个回答
换一换