Cesium基础知识-创建模型,动画
作者:互联网
- viewer = new Cesium.Viewer('cesiumContainer'
- /*
- ,{
- shouldAnimate : true
- }*/
- );
- //创建3d模型
- function Create3DModel() {
- //var viewer = new Cesium.Viewer('cesiumContainer');
- var entity = viewer.entities.add({
- position: Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706),
- model: {
- //uri : '../Apps/SampleData/models/GroundVehicle/GroundVehicle.glb'
- uri: '../Apps/SampleData/models/CesiumAir/Cesium_Air.glb'
- //uri : '../Apps/SampleData/models/CesiumMan/Cesium_Man.glb',
- }
- });
- viewer.trackedEntity = entity;
- }
- //Create3DModel();
- //创建3d模型设置位置
- function Create3DModel2() {
- var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706);
- var heading = Cesium.Math.toRadians(45.0);
- var pitch = Cesium.Math.toRadians(0);
- var roll = Cesium.Math.toRadians(0);
- var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, new Cesium.HeadingPitchRoll(heading, pitch, roll));
- var entity = viewer.entities.add({
- position: position,
- orientation: orientation,
- model: {
- uri: '../Apps/SampleData/models/GroundVehicle/GroundVehicle.glb'
- }
- });
- viewer.trackedEntity = entity;
- }
- //Create3DModel2();
- //创建模型gltf格式,可视化坐标
- function CreateModel() {
- var scene = viewer.scene;
- var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
- Cesium.Cartesian3.fromDegrees(-75.62898254394531, 40.02804946899414, 0.0));
- var model = scene.primitives.add(Cesium.Model.fromGltf({
- //url : '../Apps/SampleData/models/GroundVehicle/GroundVehicle.glb',
- url: '../Apps/SampleData/models/CesiumMan/Cesium_Man.glb',
- //url : '../Apps/SampleData/models/CesiumAir/Cesium_Air.glb',
- modelMatrix: modelMatrix,
- scale: 20000.0
- }));
- viewer.extend(Cesium.viewerCesiumInspectorMixin);
- }
- //CreateModel();
- //创建模型gltf格式,动画
- function CreateModelAni() {
- var scene = viewer.scene;
- var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
- Cesium.Cartesian3.fromDegrees(-75.62898254394531, 40.02804946899414, 0.0));
- var model = scene.primitives.add(Cesium.Model.fromGltf({
- //url : '../Apps/SampleData/models/GroundVehicle/GroundVehicle.glb',
- url: '../Apps/SampleData/models/CesiumMan/Cesium_Man.glb',
- //url : '../Apps/SampleData/models/CesiumAir/Cesium_Air.glb',
- modelMatrix: modelMatrix,
- scale: 200000.0
- }));
- Cesium.when(model.readyPromise).then(function (model) {
- model.activeAnimations.addAll({
- loop: Cesium.ModelAnimationLoop.REPEAT,
- speedup: 0.5,
- reverse: false,
- });
- });
- viewer.extend(Cesium.viewerCesiumInspectorMixin);
- //事件,鼠标点击模型,在控制台输出信息
- var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
- handler.setInputAction(
- function (movement) {
- var pick = scene.pick(movement.endPosition);
- if (Cesium.defined(pick) && Cesium.defined(pick.node) && Cesium.defined(pick.mesh)) {
- console.log('node: ' + pick.node.name + '. mesh: ' + pick.mesh.name);
- }
- },
- Cesium.ScreenSpaceEventType.MOUSE_MOVE
- );
- }
- CreateModelAni();
标签:动画,..,SampleData,glb,Apps,基础知识,var,Cesium 来源: https://blog.csdn.net/QQhelphelp/article/details/122580815