- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试触发 Cesium ScreenSpaceEventType LEFT_DOWN,但是当我点击一个点时,它会触发 Cesium ScreenSpaceEventType LEFT_DOWN 和 Cesium ScreenSpaceEventType LEFT_UP。我想拖分。但是现在,当我单击一个点并移动鼠标时,该点也会随鼠标一起移动。
我可以禁用点击直到满足某些条件或任何我可以改进它的方式吗请有人指导我。
代码:沙堡 click here
const viewer = new Cesium.Viewer("cesiumContainer");
var Poly_pointsCollections = [];
var scene = viewer.scene;
var Poly_coordiantesArray = [
[
72.35433701166211, 52.57522385967319, 96.18442795152974,
44.89719893727921, 72.39011732046649, 39.86453159141635,
],
[
67.29773654341213, 32.88259716109294, 69.14234015976554,
32.98282610463128, 69.19404079866142, 31.354623867578226,
66.85127436871454, 31.712787322338162,
],
];
var Poly_nameArray = "straightLine_";
// initial polygons
for (var i = 0; i < 2; i++) {
var temp=Poly_coordiantesArray[i];
for (var j = 0; j < temp.length; j = j + 2) {
draw_Zone_Corner_points(
temp[j],
temp[j + 1],
0
);
}
}
function draw_Zone_Corner_points(lon, lat, name) {
var pointGeometry = viewer.entities.add({
name: "straightLinePoint_",
description: [lon, lat],
position: Cesium.Cartesian3.fromDegrees(lon, lat),
point: {
color: Cesium.Color.SKYBLUE,
pixelSize: 10,
outlineColor: Cesium.Color.YELLOW,
outlineWidth: 3,
disableDepthTestDistance: Number.POSITIVE_INFINITY, // we can see points arounds earth
//heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
},
});
Poly_pointsCollections.push(pointGeometry);
}
var ZoneMoment = true;
// function update() {}
document
.getElementById("cesiumContainer")
.addEventListener("click", function () {
if (ZoneMoment) {
var rightEntityPicked = false;
var dragging = false;
var pickedEntity;
var mouseDroped = false;
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function (click) {
if (ZoneMoment) {
console.log("LEFT down ");
var pickedObject = scene.pick(click.position);
if (Cesium.defined(pickedObject) && pickedObject.id) {
var entityName = pickedObject.id._name;
entityName = entityName.split("_");
console.log("entityName ", entityName[0]);
if (entityName[0] === "straightLinePoint") {
rightEntityPicked = true;
}
if (rightEntityPicked) {
dragging = true;
scene.screenSpaceCameraController.enableRotate = false;
pickedEntity = pickedObject;
}
}
}
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
handler.setInputAction(function (movement) {
if (ZoneMoment && rightEntityPicked && dragging) {
var cartesian = pickedEntity.id.position.getValue(
Cesium.JulianDate.fromDate(new Date())
);
var cartographic =
scene.globe.ellipsoid.cartesianToCartographic(cartesian);
var surfaceNormal =
scene.globe.ellipsoid.geodeticSurfaceNormal(cartesian);
var planeNormal = Cesium.Cartesian3.subtract(
scene.camera.position,
cartesian,
new Cesium.Cartesian3()
);
planeNormal = Cesium.Cartesian3.normalize(
planeNormal,
planeNormal
);
var ray = viewer.scene.camera.getPickRay(movement.endPosition);
var plane = Cesium.Plane.fromPointNormal(cartesian, planeNormal);
var newCartesian = Cesium.IntersectionTests.rayPlane(ray, plane);
var newCartographic =
viewer.scene.globe.ellipsoid.cartesianToCartographic(
newCartesian
);
cartographic.longitude = newCartographic.longitude;
cartographic.latitude = newCartographic.latitude;
pickedEntity.id.position.setValue(
scene.globe.ellipsoid.cartographicToCartesian(cartographic)
);
}
if (dragging) {
mouseDroped = true;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
handler.setInputAction(function () {
if (ZoneMoment && rightEntityPicked && mouseDroped) {
console.log("Left up ");
dragging = false;
mouseDroped = false;
scene.screenSpaceCameraController.enableRotate = true;
}
}, Cesium.ScreenSpaceEventType.LEFT_UP);
}
});
最佳答案
您可以使用这段简单的代码来实现拖放操作
https://github.com/wanghongrui/cesium-entity-drag
关于javascript - Cesium ScreenSpaceEventType LEFT_DOWN 触发 LEFT_CLICK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72446477/
我使用 Cesium 的 gltf 分支,我想显示飞机的 3d 模型。为此,我创建了加载并添加到数据源的 czmlDataSource。 问题是我无法弄清楚如何计算方向四元数以使平面在给定的经纬度处平
我在我的应用程序中使用铯。我的应用程序根据收到的位置在 map 上显示广告牌。 我想知道Cesium.Viewer和Cesium.CesiumWidget之间的区别。是否可以使用Cesium Widg
我以这样的方式创建 Cesium.Primitive: _createPrimitive: function (linesNumber) { var instances = [
我已经使用带有 webpack 模板的官方 cesium 设置了一个项目,可在此处找到:https://github.com/AnalyticalGraphicsInc/cesium-webpack-
我在 Google Groups 上看到了一些示例,它们演示了如何修改信息框的 css。在此特定示例中,使用 javascript 将 css 链接附加到文档的头部: https://groups.g
我完全是 Cesium 的菜鸟,所以请原谅我的愚蠢行为。我正在尝试编写一个应用程序,将位置和方向数据流式传输到 Cesium,实时绘制它以及显示它所在位置的路径。我遇到了实体视觉卡顿的问题,这几乎可以
有没有办法获得 CesiumJS 中给定位置的地面高度?我试过scene.globe.getHeight func 但它返回未定义。 //marker is a point on map. v
我正在使用铯,并试图检测折线与地球地形相交的位置。我有一条多段线,它从空中的某个点开始,以一定的角度向地球延伸。 现在我正在使用设定的距离计算终点,所以我有一个起点和终点。我想检测这条折线首先撞击地球
我正在使用从数据库提供的位置数据来绘制实体。 我目前正在使用 viewer.entities.removeAll(); 每次从数据库中获取结果时删除所有实体。 由于实体当前是 3D 模型,因此这会导致
之前好像有人问过这个问题,但我一直找不到合适的例子。我熟悉 PHP,但不熟悉 Javascript,无法弄清楚如何流式传输 CZML。 我想在 map 上显示大约 6.500 个 Assets 。为了
我想在 cesium.js 中显示地下的多段线。但我对此一无所知。 最佳答案 貌似cesium还没有提供官方的地下功能,原因是cesium cameral can not be placed unde
我创建了缩放至特定国家/地区的按钮。然而,当我单击新加坡按钮时,它会导航到新加坡,但我看不到确切的新加坡国家。 所以我想要一个更好的图像。 下面是我的代码...
假设我在铯 map 上显示一个点:( https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=CZML%20Point.html&labe
我要从单击的点绘制一组圆形的线。我的代码工作正常,但它绘制的圆远离单击的点。有人可以帮助我找出我的错误在哪里吗? var viewer = new Cesium.Viewer('cesiumC
我想使用flyTo()并提供纬度长坐标,但保持相机与当前表面的高度/变焦/距离相同。 我尝试在调用flyTo时使用camera.position.z,但这似乎在每次调用flyTo()时都会放大得越来越
大家好,我正在尝试在我的铯地球仪上获取 WMS 图层。下面是我正在使用的代码。当我查看网络选项卡时,我确实看到请求在 200 处全部通过,并且当我使用请求上的链接时,它们确实起作用;但是,它说它们的文
我想使用 OL3-Cesium 在我的 WPF 应用程序中使用 WebBrowser 控件显示地球 View 。示例 html 文件在我的 IE 11 浏览器中运行良好,但如果我通过 WebBrows
我使用 Cesium Earth 库开发了一个应用程序。 问题是,绘制的线(实体路径)质量很差,不平滑。如何让它变得更好? viewer = new Cesium.Viewer('cesiumCo
我有多个 GeoJsonDataSource 对象,我想将它们放在 Cesium 地球仪上。问题是,如果它们重叠,我会遇到一些 z-fighting 问题,我无法调整它们的顺序。 有没有一种方法可以指
目录 前言 1、数据准备 2、效果实现 Cesium-01:Vue 中基础使用 Cesium-02:飞机模型简
我是一名优秀的程序员,十分优秀!