/**
* 模型水平方向旋转——主要用于大包翻转台
* 例子正值、负值代表正反方向旋转
* modelRotate(entity,270,10);modelRotate(entity,-90,5);
* @param model 模型
* @param angle 旋转角度
* @param seconds 多少秒旋转结束
*/
function modelHeadingRotate(model,angle,seconds) {
let state = false;
if(angle>0){
state = true;
}
let modelHPR = Cesium.Transforms.fixedFrameToHeadingPitchRoll(computeModelMatrix(model,Cesium.JulianDate.now()));
let angle_ = Cesium.Math.toRadians(angle);
let starthpr={heading:modelHPR.heading},endhpr={heading:modelHPR.heading+angle_};
let center = model.position._value;
let heading_ = Math.abs((endhpr.heading-starthpr.heading)/(seconds*20));
let index = 0;
let interval = setInterval(function(){
let nowhpr = Cesium.Transforms.fixedFrameToHeadingPitchRoll(computeModelMatrix(model,Cesium.JulianDate.now()));
if(state){
if(index>angle_){
clearInterval(interval);
}else{
index+=heading_;
model.orientation=Cesium.Transforms.headingPitchRollQuaternion(center, new Cesium.HeadingPitchRoll(nowhpr.heading+=heading_,0,0));
}
}else{
if(index>angle_){
index-=heading_;
model.orientation=Cesium.Transforms.headingPitchRollQuaternion(center, new Cesium.HeadingPitchRoll(nowhpr.heading-=heading_,0,0));
}else{
clearInterval(interval);
}
}
},50);
}
/**
* 模型水平方向旋转——主要用于大包翻转台
* 例子正值、负值代表正反方向旋转
* modelRotate(entity,270,10);modelRotate(entity,-90,5);
* @param model 模型
* @param angle 旋转角度
* @param seconds 多少秒旋转结束
*/
function modelRollRotate(model,angle,seconds) {
let state = false;
if(angle>0){
state = true;
}
let modelHPR = Cesium.Transforms.fixedFrameToHeadingPitchRoll(computeModelMatrix(model,Cesium.JulianDate.now()));
let angle_ = Cesium.Math.toRadians(angle);
let starthpr={roll:modelHPR.roll},endhpr={roll:modelHPR.roll+angle_};
let center = model.position._value;
let roll_ = Math.abs((endhpr.roll-starthpr.roll)/(seconds*20));
let index = 0;
let interval = setInterval(function(){
let nowhpr = Cesium.Transforms.fixedFrameToHeadingPitchRoll(computeModelMatrix(model,Cesium.JulianDate.now()));
if(state){
if(index>angle_){
clearInterval(interval);
}else{
index+=roll_;
model.orientation=Cesium.Transforms.headingPitchRollQuaternion(center, new Cesium.HeadingPitchRoll(0,0,nowhpr.roll+=roll_));
}
}else{
if(index>angle_){
index-=roll_;
model.orientation=Cesium.Transforms.headingPitchRollQuaternion(center, new Cesium.HeadingPitchRoll(0,0,nowhpr.roll-=roll_));
}else{
clearInterval(interval);
}
}
},50);
}
Cesium控制模型旋转2019-11-15
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- cesium编程入门(七)3D Tiles,模型旋转 上一节介绍了3D Tiles模型的位置移动,和贴地的操作,这...
- 咨询的商业模式,就是帮助客户从目前状态达到理想状态,其中有三种情况: 1.客户本身没有能力实现; 2.客户有能力实...