搞了许久,也没实现使用GroundPolylinePrimitive
创建贴地线动态改变其线宽,已改为使用viewer.entities.add
方式加载Entity
类型的polyline
。
你是看到了有断开的部分,其实你应该发现上面几个圆柱已经重合了。
拿第一段来说:
entities.add({
position : Cesium.Cartesian3.fromDegrees(116.472305, 35.416434, -965),
cylinder : {
length: 200,
topRadius: 10,
bottomRadius: 10,
material : Cesium.Color.fromRandom({alpha : 1.0})
}
});
高程为 -965,高度为 200,那么这段圆柱的最低点高程为 -965-200/2 = -1065;最高点高程为 -965+200/2 = -865;也就是说它是以 -965 为中心向两头延伸。
因此该这么计算
https://sogrey.top/Cesium-start-Example/examples/other/cylinders.html
这个viewer.entities
应该不能满足,可以使用scene.primitives
。只要给位置矩阵设置旋转就行。
示例地址(需要npm run build
编译源码后可见):
http://localhost:8080/Apps/Sandcastle/index.html?src=development/Cylinder.html&label=Development
我简单修改了官方源码,只加了一行代码:
//在 41 行后加上
Cesium.Matrix4.multiplyByMatrix3(modelMatrix,
Cesium.Matrix3.fromRotationY(Math.PI/4),//绕Y轴旋转 π/4
modelMatrix);
https://sogrey.top/Cesium-start-Example/examples/model/development_Cylinder.html
官方api有提供Cesium.MapboxImageryProvider
,不妨试下。
MapboxImageryProvider
https://blog.csdn.net/A873054267/article/details/86479829
该博主的github来了 Cesium学习系列汇总 |Cesium学习笔记汇总_cumtzheNo1_新浪博客| Cesium学习笔记汇总_cumtzheNo1_源码 @YanzheZhang
示例中人家是封装的,渐变色有一个状态位控制
Cesium.ExpandByMars.styleBM = !0
cesium 中可查阅 Cesium3DTileStyle
https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/Styling
从楼主提供的代码看,是想模拟鼠标点击画布中心点来拾取模型,如果中心点处确实有模型应该能拾取到,亲测过:
但如果中心点没有模型,那就拾取不到。
欢迎入群 QQ群: 807482793
群文件里有 激光点云las处理工具
cesium的las、点云之前涉及很少,不过在GitHub发现个工具开源库:https://github.com/mattshax/cesium_pnt_generator
看看对你有没有帮助。
目前思路:
//得到射线
var ray = new Cesium.Ray(origin, direction);
//发射线与场景中碰撞得到第一个碰撞结果,
//碰撞到场景中3D瓦片模型,返回碰撞结果,包括碰撞到的模型及位置
//未检测到碰撞返回undefined,
//碰撞地形返回object是undefined,但position有值
var result = scene.pickFromRay(ray /*,[],0.1*/ );