Cesium测量优化1
简介:优化绘制点、线,面鼠标位置获取精度。支持3dties,gltf model,以及box等Geometry Entity上的位置拾取。
测试代码
<template> <div class="dog"> <div id="cesiumContainer" style="width: 100%; height: 100%"></div> <MeasureAnalysis ref="analysis_measure"></MeasureAnalysis> <div id="toolTip"></div> </div> </template> <script> import MeasureAnalysis from "./components/measureAnalysis"; export default { data() { return {}; }, components: { MeasureAnalysis, }, computed: {}, created() {}, mounted() { TS.ready(() => { Cesium.Camera.DEFAULT_VIEW_RECTANGLE = Cesium.Rectangle.fromDegrees( 92.0, 25.0, 119.0, 33.0 ); window.viewer = new Cesium.Viewer("cesiumContainer", { // terrainProvider : Cesium.createWorldTerrain() }); this.$refs.analysis_measure.init(); // 添加三维模型到球儿上 const tileset = viewer.scene.primitives.add( new Cesium.Cesium3DTileset({ url: "http://localhost:8080/tileset.json", }) ); viewer.flyTo(tileset); // 添加box const blueBox = viewer.entities.add({ name: "Blue box", position: Cesium.Cartesian3.fromDegrees(115.99992822, 39.00004025, 2.5), box: { dimensions: new Cesium.Cartesian3(5.0, 5.0, 5.0), material: Cesium.Color.BLUE, }, }); // viewer.flyTo(blueBox); // 添加model glb function createModel(url, height) { //viewer.entities.removeAll(); const position = Cesium.Cartesian3.fromDegrees( 116.00005686, 39.00001029, height ); const heading = Cesium.Math.toRadians(0); const pitch = 0; const roll = 0; const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll); const orientation = Cesium.Transforms.headingPitchRollQuaternion( position, hpr ); const entity = viewer.entities.add({ name: 'glb', position: position, orientation: orientation, model: { uri: url, minimumPixelSize: 128, maximumScale: 20000, }, }); //viewer.trackedEntity = entity; } // createModel("./assets/CesiumMilkTruck/CesiumMilkTruck.glb", 0); createModel('http://localhost:8081/CesiumMilkTruck/CesiumMilkTruck.glb',0);
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)