g05_gltf_rotate.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
  6. <meta name="author" content="火星科技 http://mars3d.cn " />
  7. <meta name="apple-touch-fullscreen" content="yes" />
  8. <meta name="apple-mobile-web-app-capable" content="yes" />
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  10. <meta name="format-detection" content="telephone=no" />
  11. <meta name="x5-fullscreen" content="true" />
  12. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
  13. <!-- 标题及搜索关键字 -->
  14. <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
  15. <meta
  16. name="description"
  17. content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型 gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包 地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
  18. />
  19. <link rel="shortcut icon" type="image/x-icon" href="" />
  20. <title>模型自旋转 </title>
  21. <!--第三方lib-->
  22. <script
  23. type="text/javascript"
  24. src="../lib/include-lib.js"
  25. libpath="../lib/"
  26. include="jquery,font-awesome,bootstrap,layer,haoutil,turf,mars3d"
  27. ></script>
  28. <link href="css/style.css" rel="stylesheet" />
  29. </head>
  30. <body class="dark">
  31. <!--加载前进行操作提示,优化用户体验-->
  32. <div id="mask" class="signmask" onclick="removeMask()"></div>
  33. <div id="mars3dContainer" class="mars3d-container"></div>
  34. <script src="./js/common.js"></script>
  35. <script type="text/javascript">
  36. "use script"; //开发环境建议开启严格模式
  37. var map;
  38. function initMap(options) {
  39. //合并属性参数,可覆盖config.json中的对应配置
  40. var mapOptions = mars3d.Util.merge(options, {
  41. scene: {
  42. center: { lat: 30.820398, lng: 116.218603, alt: 6483, heading: 22, pitch: -40 },
  43. },
  44. });
  45. //创建三维地球场景
  46. map = new mars3d.Map("mars3dContainer", mapOptions);
  47. //固定光照,避免gltf模型随时间存在亮度不一致。
  48. map.fixedLight = true;
  49. //创建矢量数据图层
  50. var graphicLayer = new mars3d.layer.GraphicLayer();
  51. map.addLayer(graphicLayer);
  52. addGraphic_a1(graphicLayer);
  53. addGraphic_a2(graphicLayer);
  54. addGraphic_a3(graphicLayer);
  55. }
  56. function addGraphic_a1(graphicLayer) {
  57. var graphic = new mars3d.graphic.ModelEntity({
  58. name: "飞机",
  59. position: [116.239918, 30.879709, 1208],
  60. style: {
  61. url: "//data.mars3d.cn/gltf/mars/feiji.glb",
  62. scale: 2,
  63. },
  64. });
  65. graphicLayer.addGraphic(graphic);
  66. //开始 自旋转效果
  67. graphic.rotateStart({
  68. direction: false, //控制方向, true逆时针,false顺时针
  69. time: 30, //time:给定飞行一周所需时间(单位 秒),控制速度
  70. });
  71. }
  72. function addGraphic_a2(graphicLayer) {
  73. var graphic = new mars3d.graphic.ModelEntity({
  74. name: "四凌锥体",
  75. position: [116.257665, 30.869372, 1500],
  76. style: {
  77. url: "//data.mars3d.cn/gltf/mars/zhui.glb",
  78. scale: 200,
  79. },
  80. });
  81. graphicLayer.addGraphic(graphic);
  82. //开始 自旋转效果
  83. graphic.rotateStart({
  84. direction: true, //控制方向, true逆时针,false顺时针
  85. time: 6, //time:给定飞行一周所需时间(单位 秒),控制速度
  86. });
  87. }
  88. function addGraphic_a3(graphicLayer) {
  89. var graphicCar = new mars3d.graphic.ModelEntity({
  90. name: "汽车",
  91. position: [116.210938, 30.87518, 613.1],
  92. style: {
  93. url: "//data.mars3d.cn/gltf/mars/qiche.gltf",
  94. scale: 0.5,
  95. heading: 30,
  96. minimumPixelSize: 100,
  97. },
  98. });
  99. graphicLayer.addGraphic(graphicCar);
  100. //移动模型
  101. graphicCar.moveTo({
  102. position: [116.259138, 30.855247, 562],
  103. time: 8, //移动的时长(单位 秒)
  104. });
  105. }
  106. </script>
  107. </body>
  108. </html>