<!DOCTYPE html> <html lang="en"> <head> <!-- Use correct character set. --> <meta charset="utf-8"> <!-- Tell IE to use the latest, best version. --> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <!-- Make the app on mobile take up the full browser screen and disable user scaling. --> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> <title>Polyline Volume</title> <!-- The Cesium library. --> <script src="../ThirdParty/Cesium/Cesium.js"></script> <!-- Style our app. --> <style> @import url(../ThirdParty/Cesium/Widgets/widgets.css); html, body, #cesiumContainer { width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; } </style> </head> <body> <div id="cesiumContainer"></div> <script> Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzNDhhYmQxOC1mYzMwLTRhYmEtOTI5Ny1iNGExNTQ3ZTZhODkiLCJpZCI6NTQ1NCwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU0MzM3Mzc0NH0.RU6ynAZcwQvdfygt_N_j2rb2lpsuyyROzdaLQg0emAg'; let viewer = new Cesium.Viewer('cesiumContainer'); function computeCircle(radius) { /*此函数用于,给定半径,计算出该圆的特征点的坐标放在数组positions, * 并返回该数组。*/ let positions = []; for (let i = 0; i < 360; i++) { let radians = Cesium.Math.toRadians(i); positions.push(new Cesium.Cartesian2(radius * Math.cos(radians), radius * Math.sin(radians))); } return positions; } function computeStar(arms, rOuter, rInner) { /*此函数用于,给定星星的胳膊数,大圆半径,小圆半径,计算出星星的特征点位置, * 放在数组positions,并返回该数组。*/ let angle = Math.PI / arms; let length = 2 * arms; let positions = new Array(length); for (let i = 0; i < length; i++) { let r = (i % 2) === 0 ? rOuter : rInner; positions[i] = new Cesium.Cartesian2(Math.cos(i * angle) * r, Math.sin(i * angle) * r); } return positions; } let redTube = viewer.entities.add({ name : 'Red tube with rounded corners', polylineVolume : { positions : Cesium.Cartesian3.fromDegreesArray([-85.0, 32.0, -85.0, 36.0, -89.0, 36.0]), // polylineVolume 中心线(我猜)。 shape : computeCircle(60000.0), // 用于指定要挤压的形状的cartesian 2位置数组 material : Cesium.Color.RED } }); let greenBox = viewer.entities.add({ name : 'Green box with beveled corners and outline', polylineVolume : { positions : Cesium.Cartesian3.fromDegreesArrayHeights([-90.0, 32.0, 0.0, -90.0, 36.0, 100000.0, -94.0, 36.0, 0.0]), shape :[new Cesium.Cartesian2(-50000, -50000), new Cesium.Cartesian2(50000, -50000), new Cesium.Cartesian2(50000, 50000), new Cesium.Cartesian2(-50000, 50000)], cornerType : Cesium.CornerType.BEVELED, material : Cesium.Color.GREEN.withAlpha(0.5), outline : true, outlineColor : Cesium.Color.BLACK } }); let blueStar = viewer.entities.add({ name : 'Blue star with mitered corners and outline', polylineVolume : { positions : Cesium.Cartesian3.fromDegreesArrayHeights([-95.0, 32.0, 0.0, -95.0, 36.0, 100000.0, -99.0, 36.0, 200000.0]), shape : computeStar(7, 70000, 50000), // 7角星,大圆半径,小圆半径。 cornerType : Cesium.CornerType.MITERED, material : Cesium.Color.BLUE } }); viewer.zoomTo(viewer.entities); </script> </body> </html>
cesium 1.52 demo - Polyline Volume.html
猜你喜欢
转载自blog.csdn.net/weixin_42193179/article/details/85615983
今日推荐
周排行