码迷,mamicode.com
首页 > 其他好文 > 详细

Cesium的model初识

时间:2019-11-03 12:50:16      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:active   anti   cloc   tno   DPoS   nes   坐标系   parameter   osi   

学习Cesium的model的基础知识。

#primitve方式加载模型

// Cesium.Transforms.eastNorthUpToFixedFrame去创建了一个以经纬度为原点的enu(east-north-up )局部坐标系。 
var
modelmatrix=Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(118,31,1000)); var model = viewer.scene.primitives.add( Cesium.Model.fromGltf({ url:"../data/models/CesiumAir/Cesium_Air.glTF", modelMatrix:modelmatrix,
    //模型大小系数 scale:
100,
    //裁剪面 clippingPlanes: clippingplans }));

#模型运动显示

//设置开始时间
var
startTime = new Cesium.JulianDate.now();
//加载后activeAnimations.addAll({}) Cesium.when(model.readyPromise).then(
function(model){ model.activeAnimations.addAll({
//the style of thr model movement,thiS MIRRORED_REPEAT style means "moving clockwise and then moving anti-clockwise" loop:Cesium.ModelAnimationLoop.MIRRORED_REPEAT, startTime:startTime,
    //stopTime: startTime,stoptime(seconds),create new time (new Cesium.JulianDate())     stopTime:Cesium.JulianDate.addSeconds(startTime,
10,new Cesium.JulianDate()) }) });

#clippingPlane

the core  :ax+by+cz=d; a,b,c,d is four parameters

try to understand this by mathmatics

var clippingPlane= new Cesium.ClippingPlane(new Cesium.Cartesian3(0,1,0),0);//(a,b,c),d
var clippingplans = new Cesium.ClippingPlaneCollection({
    planes:[clippingPlane]
    });

 

#pick the model

var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function(movement){
    var pick = scene.pick(movement.endPosition);
    if (Cesium.defined(pick) && Cesium.defined(pick.node) ) {
        console.log(‘node: ‘ + pick.node.name + ‘. mesh: ‘ + pick.mesh.name);
    }
},Cesium.ScreenSpaceEventType.MOUSE_MOVE)

 

Cesium的model初识

标签:active   anti   cloc   tno   DPoS   nes   坐标系   parameter   osi   

原文地址:https://www.cnblogs.com/xiaoguniang0204/p/11785592.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!