deeptwins-engine-3d 0.1.64 → 0.1.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/{plot/utils/Algorithm.js → drawer/algorithm.js} +1 -3
- package/dist/esm/drawer/common.d.ts +61 -0
- package/dist/esm/{plot/utils/PlotCommon.js → drawer/common.js} +104 -551
- package/dist/esm/drawer/index.d.ts +11 -18
- package/dist/esm/drawer/index.js +329 -80
- package/dist/esm/{plot/utils → drawer}/plotUtil.js +1 -3
- package/dist/esm/drawer/shape/Assemble.d.ts +34 -0
- package/dist/esm/drawer/shape/Assemble.js +415 -0
- package/dist/esm/drawer/shape/AttackArrow.d.ts +32 -0
- package/dist/esm/drawer/shape/AttackArrow.js +442 -0
- package/dist/esm/drawer/shape/BaseShape.d.ts +14 -4
- package/dist/esm/drawer/shape/BaseShape.js +175 -20
- package/dist/esm/drawer/shape/Bow.d.ts +31 -0
- package/dist/esm/drawer/shape/Bow.js +375 -0
- package/dist/esm/drawer/shape/Circle.d.ts +37 -0
- package/dist/esm/drawer/shape/Circle.js +461 -0
- package/dist/esm/drawer/shape/Curve.d.ts +29 -0
- package/dist/esm/drawer/shape/Curve.js +386 -0
- package/dist/esm/drawer/shape/DragPoint.d.ts +32 -0
- package/dist/esm/drawer/shape/DragPoint.js +211 -0
- package/dist/esm/drawer/shape/Elliptic.d.ts +38 -0
- package/dist/esm/drawer/shape/Elliptic.js +491 -0
- package/dist/esm/drawer/shape/Formation.d.ts +33 -0
- package/dist/esm/drawer/shape/Formation.js +395 -0
- package/dist/esm/drawer/shape/PincerArrow.d.ts +32 -0
- package/dist/esm/drawer/shape/PincerArrow.js +445 -0
- package/dist/esm/drawer/shape/Point.d.ts +2 -31
- package/dist/esm/drawer/shape/Point.js +7 -201
- package/dist/esm/drawer/shape/Polygon.d.ts +1 -1
- package/dist/esm/drawer/shape/Polygon.js +10 -81
- package/dist/esm/drawer/shape/Polyline.d.ts +1 -1
- package/dist/esm/drawer/shape/Polyline.js +10 -81
- package/dist/esm/drawer/shape/RegularPolygon.d.ts +37 -0
- package/dist/esm/drawer/shape/RegularPolygon.js +468 -0
- package/dist/esm/drawer/shape/RightAngleArrow.d.ts +34 -0
- package/dist/esm/drawer/shape/RightAngleArrow.js +423 -0
- package/dist/esm/drawer/shape/Sector.d.ts +37 -0
- package/dist/esm/drawer/shape/Sector.js +568 -0
- package/dist/esm/drawer/shape/StraightArrow.d.ts +34 -0
- package/dist/esm/drawer/shape/StraightArrow.js +422 -0
- package/dist/esm/drawer/shape/SwallowtailArrow.d.ts +36 -0
- package/dist/esm/drawer/shape/SwallowtailArrow.js +438 -0
- package/dist/esm/drawer/types.d.ts +23 -0
- package/dist/esm/drawer/types.js +11 -0
- package/dist/esm/drawer/utils.d.ts +14 -0
- package/dist/esm/drawer/utils.js +320 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/measure/Area.d.ts +17 -17
- package/dist/esm/measure/Area.js +95 -63
- package/dist/esm/measure/BaseDraw.d.ts +9 -4
- package/dist/esm/measure/BaseDraw.js +37 -2
- package/dist/esm/measure/Distance.d.ts +9 -9
- package/dist/esm/measure/Distance.js +52 -68
- package/dist/esm/measure/index.d.ts +16 -26
- package/dist/esm/measure/index.js +72 -84
- package/dist/esm/measure/types.d.ts +94 -0
- package/dist/esm/measure/types.js +17 -0
- package/dist/esm/measure/utils.d.ts +7 -7
- package/dist/esm/measure/utils.js +43 -24
- package/dist/esm/tool/utils.js +1 -1
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +1 -1
- package/dist/esm/plot/create/CreateAssemble.d.ts +0 -2
- package/dist/esm/plot/create/CreateAssemble.js +0 -63
- package/dist/esm/plot/create/CreateAttackArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateAttackArrow.js +0 -75
- package/dist/esm/plot/create/CreateBillboard.d.ts +0 -2
- package/dist/esm/plot/create/CreateBillboard.js +0 -47
- package/dist/esm/plot/create/CreateBow.d.ts +0 -2
- package/dist/esm/plot/create/CreateBow.js +0 -63
- package/dist/esm/plot/create/CreateCircle.d.ts +0 -2
- package/dist/esm/plot/create/CreateCircle.js +0 -68
- package/dist/esm/plot/create/CreateCurve.d.ts +0 -2
- package/dist/esm/plot/create/CreateCurve.js +0 -76
- package/dist/esm/plot/create/CreateElliptic.d.ts +0 -2
- package/dist/esm/plot/create/CreateElliptic.js +0 -69
- package/dist/esm/plot/create/CreateFlag.d.ts +0 -2
- package/dist/esm/plot/create/CreateFlag.js +0 -80
- package/dist/esm/plot/create/CreateFormation.d.ts +0 -2
- package/dist/esm/plot/create/CreateFormation.js +0 -65
- package/dist/esm/plot/create/CreateFreeLine.d.ts +0 -2
- package/dist/esm/plot/create/CreateFreeLine.js +0 -69
- package/dist/esm/plot/create/CreateFreePolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreateFreePolygon.js +0 -65
- package/dist/esm/plot/create/CreateLabel.d.ts +0 -2
- package/dist/esm/plot/create/CreateLabel.js +0 -55
- package/dist/esm/plot/create/CreateLineArrow.d.ts +0 -2
- package/dist/esm/plot/create/CreateLineArrow.js +0 -79
- package/dist/esm/plot/create/CreatePincerArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreatePincerArrow.js +0 -73
- package/dist/esm/plot/create/CreatePoint.d.ts +0 -2
- package/dist/esm/plot/create/CreatePoint.js +0 -47
- package/dist/esm/plot/create/CreatePolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreatePolygon.js +0 -80
- package/dist/esm/plot/create/CreatePolyline.d.ts +0 -2
- package/dist/esm/plot/create/CreatePolyline.js +0 -70
- package/dist/esm/plot/create/CreateRectangle.d.ts +0 -2
- package/dist/esm/plot/create/CreateRectangle.js +0 -60
- package/dist/esm/plot/create/CreateRegularPolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreateRegularPolygon.js +0 -75
- package/dist/esm/plot/create/CreateRightAngleArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateRightAngleArrow.js +0 -73
- package/dist/esm/plot/create/CreateRoundRectangle.d.ts +0 -2
- package/dist/esm/plot/create/CreateRoundRectangle.js +0 -63
- package/dist/esm/plot/create/CreateSector.d.ts +0 -2
- package/dist/esm/plot/create/CreateSector.js +0 -65
- package/dist/esm/plot/create/CreateStraightArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateStraightArrow.js +0 -65
- package/dist/esm/plot/create/CreateSwallowtailArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateSwallowtailArrow.js +0 -67
- package/dist/esm/plot/create/index.d.ts +0 -25
- package/dist/esm/plot/create/index.js +0 -25
- package/dist/esm/plot/edit/EditAssemble.d.ts +0 -8
- package/dist/esm/plot/edit/EditAssemble.js +0 -120
- package/dist/esm/plot/edit/EditAttackArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditAttackArrow.js +0 -182
- package/dist/esm/plot/edit/EditBillboard.d.ts +0 -7
- package/dist/esm/plot/edit/EditBillboard.js +0 -70
- package/dist/esm/plot/edit/EditBow.d.ts +0 -8
- package/dist/esm/plot/edit/EditBow.js +0 -119
- package/dist/esm/plot/edit/EditCircle.d.ts +0 -8
- package/dist/esm/plot/edit/EditCircle.js +0 -133
- package/dist/esm/plot/edit/EditCurve.d.ts +0 -8
- package/dist/esm/plot/edit/EditCurve.js +0 -180
- package/dist/esm/plot/edit/EditElliptic.d.ts +0 -8
- package/dist/esm/plot/edit/EditElliptic.js +0 -144
- package/dist/esm/plot/edit/EditFlag.d.ts +0 -8
- package/dist/esm/plot/edit/EditFlag.js +0 -121
- package/dist/esm/plot/edit/EditFormation.d.ts +0 -8
- package/dist/esm/plot/edit/EditFormation.js +0 -120
- package/dist/esm/plot/edit/EditLabel.d.ts +0 -7
- package/dist/esm/plot/edit/EditLabel.js +0 -100
- package/dist/esm/plot/edit/EditLineArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditLineArrow.js +0 -180
- package/dist/esm/plot/edit/EditPincerArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditPincerArrow.js +0 -121
- package/dist/esm/plot/edit/EditPoint.d.ts +0 -7
- package/dist/esm/plot/edit/EditPoint.js +0 -70
- package/dist/esm/plot/edit/EditPolygon.d.ts +0 -8
- package/dist/esm/plot/edit/EditPolygon.js +0 -181
- package/dist/esm/plot/edit/EditPolyline.d.ts +0 -8
- package/dist/esm/plot/edit/EditPolyline.js +0 -179
- package/dist/esm/plot/edit/EditRectangle.d.ts +0 -8
- package/dist/esm/plot/edit/EditRectangle.js +0 -119
- package/dist/esm/plot/edit/EditRegularPolygon.d.ts +0 -8
- package/dist/esm/plot/edit/EditRegularPolygon.js +0 -170
- package/dist/esm/plot/edit/EditRightAngleArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditRightAngleArrow.js +0 -143
- package/dist/esm/plot/edit/EditRoundRectangle.d.ts +0 -8
- package/dist/esm/plot/edit/EditRoundRectangle.js +0 -119
- package/dist/esm/plot/edit/EditSector.d.ts +0 -8
- package/dist/esm/plot/edit/EditSector.js +0 -120
- package/dist/esm/plot/edit/EditStraightArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditStraightArrow.js +0 -120
- package/dist/esm/plot/edit/EditSwallowtailArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditSwallowtailArrow.js +0 -121
- package/dist/esm/plot/edit/index.d.ts +0 -23
- package/dist/esm/plot/edit/index.js +0 -23
- package/dist/esm/plot/utils/DomUtil.d.ts +0 -34
- package/dist/esm/plot/utils/DomUtil.js +0 -100
- package/dist/esm/plot/utils/PlotCommon.d.ts +0 -101
- package/dist/esm/plot/utils/ReminderTip.d.ts +0 -10
- package/dist/esm/plot/utils/ReminderTip.js +0 -67
- package/dist/esm/plot/utils/Tooltip.d.ts +0 -3
- package/dist/esm/plot/utils/Tooltip.js +0 -97
- /package/dist/esm/{plot/utils/Algorithm.d.ts → drawer/algorithm.d.ts} +0 -0
- /package/dist/esm/{plot/utils/Coordinate.d.ts → drawer/coordinate.d.ts} +0 -0
- /package/dist/esm/{plot/utils/Coordinate.js → drawer/coordinate.js} +0 -0
- /package/dist/esm/{plot/utils → drawer}/plotUtil.d.ts +0 -0
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 自由线标绘功能
|
|
3
|
-
*/
|
|
4
|
-
import * as Cesium from 'deeptwins-cesium';
|
|
5
|
-
import { getCatesian3FromPX } from "../utils/Coordinate";
|
|
6
|
-
import { newSessionid } from "../utils/PlotCommon";
|
|
7
|
-
import CreateRemindertip from "../utils/ReminderTip";
|
|
8
|
-
var CreateFreeLine = function CreateFreeLine(viewer, handler, resultList, options, callback) {
|
|
9
|
-
var id = options.id || newSessionid();
|
|
10
|
-
var color = options.color ? Cesium.Color.fromCssColorString(options.color) : Cesium.Color.BLUE.withAlpha(0.9);
|
|
11
|
-
var onground = options.onground || true;
|
|
12
|
-
if (viewer.entities.getById(id)) throw new Error('the id parameter is an unique value');
|
|
13
|
-
window.toolTip = '左键点击开始绘制';
|
|
14
|
-
var anchorpoints = [];
|
|
15
|
-
var polyline = undefined;
|
|
16
|
-
// 左键点击事件
|
|
17
|
-
handler.setInputAction(function (event) {
|
|
18
|
-
window.toolTip = '鼠标移动绘制,左键双击结束绘制';
|
|
19
|
-
var pixPos = event.position;
|
|
20
|
-
var cartesian = getCatesian3FromPX(viewer, pixPos);
|
|
21
|
-
if (!cartesian) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (anchorpoints.length == 0) {
|
|
25
|
-
anchorpoints.push(cartesian);
|
|
26
|
-
polyline = viewer.entities.add({
|
|
27
|
-
name: 'FreeLine',
|
|
28
|
-
id: id,
|
|
29
|
-
polyline: {
|
|
30
|
-
show: true,
|
|
31
|
-
positions: new Cesium.CallbackProperty(function () {
|
|
32
|
-
return anchorpoints;
|
|
33
|
-
}, false),
|
|
34
|
-
width: 15,
|
|
35
|
-
material: new Cesium.PolylineGlowMaterialProperty({
|
|
36
|
-
glowPower: 0.3,
|
|
37
|
-
color: color
|
|
38
|
-
}),
|
|
39
|
-
clampToGround: onground
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
polyline.GeoType = 'FreeLine'; //记录对象的类型,用户后续编辑等操作
|
|
43
|
-
polyline.Editable = false; //代表当前对象可编辑,false状态下不可编辑
|
|
44
|
-
}
|
|
45
|
-
anchorpoints.push(cartesian);
|
|
46
|
-
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
47
|
-
// 鼠标移动事件
|
|
48
|
-
handler.setInputAction(function (movement) {
|
|
49
|
-
//console.log('鼠标移动事件监测:------创建自由线------');
|
|
50
|
-
var endPos = movement.endPosition;
|
|
51
|
-
CreateRemindertip(window.toolTip, endPos, true);
|
|
52
|
-
if (anchorpoints.length > 1) {
|
|
53
|
-
var cartesian = getCatesian3FromPX(viewer, endPos);
|
|
54
|
-
if (!cartesian) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
anchorpoints.push(cartesian);
|
|
58
|
-
}
|
|
59
|
-
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
60
|
-
// 左键双击事件
|
|
61
|
-
handler.setInputAction(function (event) {
|
|
62
|
-
polyline.PottingPoint = anchorpoints;
|
|
63
|
-
resultList.push(polyline);
|
|
64
|
-
handler.destroy();
|
|
65
|
-
CreateRemindertip(window.toolTip, event.position, false);
|
|
66
|
-
if (callback && typeof callback == 'function') callback(polyline);
|
|
67
|
-
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
68
|
-
};
|
|
69
|
-
export default CreateFreeLine;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 自由多边形标绘功能
|
|
3
|
-
*/
|
|
4
|
-
import * as Cesium from 'deeptwins-cesium';
|
|
5
|
-
import { getCatesian3FromPX } from "../utils/Coordinate";
|
|
6
|
-
import { newSessionid } from "../utils/PlotCommon";
|
|
7
|
-
import CreateRemindertip from "../utils/ReminderTip";
|
|
8
|
-
var CreateFreePolygon = function CreateFreePolygon(viewer, handler, resultList, options, callback) {
|
|
9
|
-
var id = options.id || newSessionid();
|
|
10
|
-
var color = options.color ? Cesium.Color.fromCssColorString(options.color) : Cesium.Color.BLUE.withAlpha(0.4);
|
|
11
|
-
var onground = options.onground || true;
|
|
12
|
-
if (viewer.entities.getById(id)) throw new Error('the id parameter is an unique value');
|
|
13
|
-
window.toolTip = '左键点击开始绘制';
|
|
14
|
-
var anchorpoints = [];
|
|
15
|
-
var polygon = undefined;
|
|
16
|
-
// 左键点击事件
|
|
17
|
-
handler.setInputAction(function (event) {
|
|
18
|
-
window.toolTip = '左键双击结束绘制';
|
|
19
|
-
if (Cesium.defined(polygon)) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
var pixPos = event.position;
|
|
23
|
-
var cartesian = getCatesian3FromPX(viewer, pixPos);
|
|
24
|
-
if (anchorpoints.length == 0) {
|
|
25
|
-
anchorpoints.push(cartesian);
|
|
26
|
-
var dynamicPositions = new Cesium.CallbackProperty(function () {
|
|
27
|
-
return new Cesium.PolygonHierarchy(anchorpoints);
|
|
28
|
-
}, false);
|
|
29
|
-
polygon = viewer.entities.add({
|
|
30
|
-
name: 'FreePolygon',
|
|
31
|
-
id: id,
|
|
32
|
-
polygon: {
|
|
33
|
-
hierarchy: dynamicPositions,
|
|
34
|
-
material: color,
|
|
35
|
-
outline: true,
|
|
36
|
-
outlineColor: Cesium.Color.GREEN,
|
|
37
|
-
heightReference: onground ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
polygon.GeoType = 'FreePolygon'; //记录对象的类型,用户后续编辑等操作
|
|
41
|
-
polygon.Editable = false; //代表当前对象可编辑,false状态下不可编辑
|
|
42
|
-
}
|
|
43
|
-
anchorpoints.push(cartesian);
|
|
44
|
-
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
45
|
-
// 鼠标移动事件
|
|
46
|
-
handler.setInputAction(function (movement) {
|
|
47
|
-
//console.log('鼠标移动事件监测:------创建自由多边形------');
|
|
48
|
-
var endPos = movement.endPosition;
|
|
49
|
-
CreateRemindertip(window.toolTip, endPos, true);
|
|
50
|
-
if (Cesium.defined(polygon)) {
|
|
51
|
-
var cartesian = getCatesian3FromPX(viewer, endPos);
|
|
52
|
-
anchorpoints.push(cartesian);
|
|
53
|
-
}
|
|
54
|
-
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
55
|
-
// 左键双击事件
|
|
56
|
-
handler.setInputAction(function (event) {
|
|
57
|
-
var hierarchyPos = new Cesium.PolygonHierarchy(anchorpoints);
|
|
58
|
-
polygon.PottingPoint = Cesium.clone(hierarchyPos, true); //记录对象的节点数据,用户后续编辑等操作
|
|
59
|
-
resultList.push(polygon);
|
|
60
|
-
handler.destroy();
|
|
61
|
-
CreateRemindertip(window.toolTip, event.position, false);
|
|
62
|
-
if (typeof callback == 'function') callback(polygon);
|
|
63
|
-
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
64
|
-
};
|
|
65
|
-
export default CreateFreePolygon;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 文本标注功能
|
|
3
|
-
*/
|
|
4
|
-
import * as Cesium from 'deeptwins-cesium';
|
|
5
|
-
import { getCatesian3FromPX } from "../utils/Coordinate";
|
|
6
|
-
import { getLabelText, newSessionid } from "../utils/PlotCommon";
|
|
7
|
-
import CreateRemindertip from "../utils/ReminderTip";
|
|
8
|
-
var CreateLabel = function CreateLabel(viewer, handler, resultList, options, callback) {
|
|
9
|
-
var id = options.id || newSessionid();
|
|
10
|
-
var onground = options.onground || true;
|
|
11
|
-
var color = options.color ? Cesium.Color.fromCssColorString(options.color) : Cesium.Color.WHITE;
|
|
12
|
-
var text = getLabelText(options.text || 'undefined', 0);
|
|
13
|
-
var size = options.size || '32';
|
|
14
|
-
if (viewer.entities.getById(id)) throw new Error('the id parameter is an unique value');
|
|
15
|
-
window.toolTip = '左键点击选择点位';
|
|
16
|
-
handler.setInputAction(function (event) {
|
|
17
|
-
var pixPos = event.position;
|
|
18
|
-
var cartesian = getCatesian3FromPX(viewer, pixPos);
|
|
19
|
-
var point = viewer.entities.add({
|
|
20
|
-
id: id,
|
|
21
|
-
name: 'Label',
|
|
22
|
-
position: cartesian,
|
|
23
|
-
label: {
|
|
24
|
-
text: text,
|
|
25
|
-
font: size + 'px Helvetica',
|
|
26
|
-
fillColor: color,
|
|
27
|
-
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
28
|
-
heightReference: onground ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE,
|
|
29
|
-
disableDepthTestDistance: 100000 //解决遮挡显示一半的问题
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
point.GeoType = 'Label'; //记录对象的类型,用户后续编辑等操作
|
|
33
|
-
point.PottingPoint = {
|
|
34
|
-
position: cartesian,
|
|
35
|
-
text: text,
|
|
36
|
-
size: size
|
|
37
|
-
}; //记录对象的节点数据,用户后续编辑等操作
|
|
38
|
-
point.EditingPoint = {
|
|
39
|
-
position: cartesian,
|
|
40
|
-
text: text,
|
|
41
|
-
size: size
|
|
42
|
-
}; //记录对象的节点数据,用户后续编辑等操作
|
|
43
|
-
point.Editable = true; //代表当前对象可编辑,false状态下不可编辑
|
|
44
|
-
resultList.push(point);
|
|
45
|
-
handler.destroy();
|
|
46
|
-
CreateRemindertip(window.toolTip, event.position, false);
|
|
47
|
-
if (callback && typeof callback == 'function') callback(point);
|
|
48
|
-
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
49
|
-
handler.setInputAction(function (movement) {
|
|
50
|
-
//console.log('鼠标移动事件监测:------创建文本------');
|
|
51
|
-
var endPos = movement.endPosition;
|
|
52
|
-
CreateRemindertip(window.toolTip, endPos, true);
|
|
53
|
-
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
54
|
-
};
|
|
55
|
-
export default CreateLabel;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 简单箭头标绘功能-包括直线和曲线
|
|
3
|
-
*/
|
|
4
|
-
import * as Cesium from 'deeptwins-cesium';
|
|
5
|
-
import { getCatesian3FromPX } from "../utils/Coordinate";
|
|
6
|
-
import { createBezierPoints, newSessionid } from "../utils/PlotCommon";
|
|
7
|
-
import CreateRemindertip from "../utils/ReminderTip";
|
|
8
|
-
var CreateLineArrow = function CreateLineArrow(viewer, handler, resultList, options, callback) {
|
|
9
|
-
var id = options.id || newSessionid();
|
|
10
|
-
var color = options.color ? Cesium.Color.fromCssColorString(options.color) : Cesium.Color.ORANGE.withAlpha(0.9);
|
|
11
|
-
var onground = options.onground || true;
|
|
12
|
-
if (viewer.entities.getById(id)) throw new Error('the id parameter is an unique value');
|
|
13
|
-
window.toolTip = '左键点击开始绘制';
|
|
14
|
-
var anchorpoints = [];
|
|
15
|
-
var polyline = undefined;
|
|
16
|
-
var linePoints;
|
|
17
|
-
// 左键点击事件
|
|
18
|
-
handler.setInputAction(function (event) {
|
|
19
|
-
window.toolTip = '左键添加点,右键撤销,左键双击结束绘制';
|
|
20
|
-
var pixPos = event.position;
|
|
21
|
-
var cartesian = getCatesian3FromPX(viewer, pixPos);
|
|
22
|
-
if (!cartesian) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (anchorpoints.length == 0) {
|
|
26
|
-
anchorpoints.push(cartesian);
|
|
27
|
-
}
|
|
28
|
-
anchorpoints.push(cartesian);
|
|
29
|
-
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
30
|
-
// 鼠标移动事件
|
|
31
|
-
handler.setInputAction(function (movement) {
|
|
32
|
-
//console.log('鼠标移动事件监测:------创建简单箭头------');
|
|
33
|
-
var endPos = movement.endPosition;
|
|
34
|
-
CreateRemindertip(window.toolTip, endPos, true);
|
|
35
|
-
if (anchorpoints.length > 0) {
|
|
36
|
-
if (!Cesium.defined(polyline)) {
|
|
37
|
-
linePoints = createBezierPoints(anchorpoints);
|
|
38
|
-
polyline = viewer.entities.add({
|
|
39
|
-
name: 'LineArrow',
|
|
40
|
-
id: id,
|
|
41
|
-
polyline: {
|
|
42
|
-
positions: new Cesium.CallbackProperty(function () {
|
|
43
|
-
return linePoints;
|
|
44
|
-
}, false),
|
|
45
|
-
width: 15,
|
|
46
|
-
material: new Cesium.PolylineArrowMaterialProperty(color),
|
|
47
|
-
clampToGround: onground
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
polyline.GeoType = 'LineArrow'; //记录对象的类型,用户后续编辑等操作
|
|
51
|
-
polyline.Editable = true; //代表当前对象可编辑,false状态下不可编辑
|
|
52
|
-
} else {
|
|
53
|
-
anchorpoints.pop();
|
|
54
|
-
var cartesian = getCatesian3FromPX(viewer, endPos);
|
|
55
|
-
if (!cartesian) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
anchorpoints.push(cartesian);
|
|
59
|
-
linePoints = createBezierPoints(anchorpoints);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
63
|
-
// 左键双击事件
|
|
64
|
-
handler.setInputAction(function (event) {
|
|
65
|
-
anchorpoints.pop();
|
|
66
|
-
anchorpoints.pop(); //因为是双击结束,所以要pop两次,一次是move的结果,一次是单击结果
|
|
67
|
-
polyline.PottingPoint = Cesium.clone(anchorpoints, true); //记录对象的节点数据,用户后续编辑等操作
|
|
68
|
-
polyline.EditingPoint = Cesium.clone(anchorpoints, true); //记录复杂对象的编辑的节点数据,用户后续编辑等操作
|
|
69
|
-
resultList.push(polyline);
|
|
70
|
-
handler.destroy();
|
|
71
|
-
CreateRemindertip(window.toolTip, event.position, false);
|
|
72
|
-
if (typeof callback == 'function') callback(polyline);
|
|
73
|
-
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
74
|
-
// 右键摁下事件
|
|
75
|
-
handler.setInputAction(function () {
|
|
76
|
-
anchorpoints.pop();
|
|
77
|
-
}, Cesium.ScreenSpaceEventType.RIGHT_DOWN);
|
|
78
|
-
};
|
|
79
|
-
export default CreateLineArrow;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 创建钳击箭头
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as Cesium from 'deeptwins-cesium';
|
|
6
|
-
import { getCatesian3FromPX } from "../utils/Coordinate";
|
|
7
|
-
import { calculatePincerArrowPoint, newSessionid } from "../utils/PlotCommon";
|
|
8
|
-
import CreateRemindertip from "../utils/ReminderTip";
|
|
9
|
-
var CreatePincerArrow = function CreatePincerArrow(viewer, handler, resultList, options, callback) {
|
|
10
|
-
var id = options.id || newSessionid();
|
|
11
|
-
if (viewer.entities.getById(id)) throw new Error('the id parameter is an unique value');
|
|
12
|
-
var color = options.color ? Cesium.Color.fromCssColorString(options.color) : Cesium.Color.RED;
|
|
13
|
-
var onground = options.onground || true;
|
|
14
|
-
var anchorpoints = [];
|
|
15
|
-
var pincerArrow = undefined;
|
|
16
|
-
window.toolTip = '左键点击开始绘制';
|
|
17
|
-
//左键点击事件
|
|
18
|
-
handler.setInputAction(function (event) {
|
|
19
|
-
var cartesian = getCatesian3FromPX(viewer, event.position);
|
|
20
|
-
if (!cartesian || anchorpoints.length > 4) return;
|
|
21
|
-
anchorpoints.push(cartesian);
|
|
22
|
-
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
23
|
-
//鼠标移动事件
|
|
24
|
-
handler.setInputAction(function (move) {
|
|
25
|
-
//console.log('鼠标移动事件监测:------创建钳击箭头------');
|
|
26
|
-
var endPos = move.endPosition;
|
|
27
|
-
CreateRemindertip(window.toolTip, endPos, true);
|
|
28
|
-
var cartesian = getCatesian3FromPX(viewer, endPos);
|
|
29
|
-
if (!cartesian || anchorpoints.length === 0) return;
|
|
30
|
-
window.toolTip = anchorpoints.length === 5 ? '右键撤销,左键双击结束绘制' : '左键添加点,右键撤销';
|
|
31
|
-
if (anchorpoints.length >= 2) {
|
|
32
|
-
if (!Cesium.defined(pincerArrow)) {
|
|
33
|
-
anchorpoints.push(cartesian);
|
|
34
|
-
var dynamicPositions = new Cesium.CallbackProperty(function () {
|
|
35
|
-
var points = calculatePincerArrowPoint(anchorpoints);
|
|
36
|
-
return new Cesium.PolygonHierarchy(points);
|
|
37
|
-
}, false);
|
|
38
|
-
pincerArrow = viewer.entities.add({
|
|
39
|
-
id: id,
|
|
40
|
-
name: 'PincerArrow',
|
|
41
|
-
polygon: new Cesium.PolygonGraphics({
|
|
42
|
-
hierarchy: dynamicPositions,
|
|
43
|
-
show: true,
|
|
44
|
-
fill: true,
|
|
45
|
-
material: color,
|
|
46
|
-
heightReference: onground ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE
|
|
47
|
-
})
|
|
48
|
-
});
|
|
49
|
-
pincerArrow.GeoType = 'PincerArrow'; //记录对象的类型,用户后续编辑等操作
|
|
50
|
-
pincerArrow.Editable = true; //代表当前对象可编辑,false状态下不可编辑
|
|
51
|
-
} else {
|
|
52
|
-
anchorpoints.pop();
|
|
53
|
-
anchorpoints.push(cartesian);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
57
|
-
//左键双击事件
|
|
58
|
-
handler.setInputAction(function (event) {
|
|
59
|
-
pincerArrow.PottingPoint = Cesium.clone(anchorpoints, true); //记录对象的节点数据,用户后续编辑等操作
|
|
60
|
-
pincerArrow.EditingPoint = Cesium.clone(anchorpoints, true); //记录复杂对象的编辑的节点数据,用户后续编辑等操作
|
|
61
|
-
var points = calculatePincerArrowPoint(anchorpoints);
|
|
62
|
-
pincerArrow.polygon.hierarchy = new Cesium.PolygonHierarchy(points);
|
|
63
|
-
resultList.push(pincerArrow);
|
|
64
|
-
handler.destroy();
|
|
65
|
-
CreateRemindertip(window.toolTip, event.position, false);
|
|
66
|
-
if (typeof callback == 'function') callback(pincerArrow);
|
|
67
|
-
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
68
|
-
// 右键摁下事件
|
|
69
|
-
handler.setInputAction(function () {
|
|
70
|
-
anchorpoints.pop();
|
|
71
|
-
}, Cesium.ScreenSpaceEventType.RIGHT_DOWN);
|
|
72
|
-
};
|
|
73
|
-
export default CreatePincerArrow;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 点标绘功能
|
|
3
|
-
*/
|
|
4
|
-
import * as Cesium from 'deeptwins-cesium';
|
|
5
|
-
import { getCatesian3FromPX } from "../utils/Coordinate";
|
|
6
|
-
import { newSessionid } from "../utils/PlotCommon";
|
|
7
|
-
import CreateRemindertip from "../utils/ReminderTip";
|
|
8
|
-
var CreatePoint = function CreatePoint(viewer, handler, resultList, options, callback) {
|
|
9
|
-
var id = options.id || newSessionid();
|
|
10
|
-
var onground = options.onground || true;
|
|
11
|
-
var color = options.color ? Cesium.Color.fromCssColorString(options.color) : Cesium.Color.GREEN;
|
|
12
|
-
if (viewer.entities.getById(id)) throw new Error('the id parameter is an unique value');
|
|
13
|
-
window.toolTip = '左键点击选择点位';
|
|
14
|
-
handler.setInputAction(function (event) {
|
|
15
|
-
var pixPos = event.position;
|
|
16
|
-
var cartesian = getCatesian3FromPX(viewer, pixPos);
|
|
17
|
-
if (!cartesian) return;
|
|
18
|
-
var point = viewer.entities.add({
|
|
19
|
-
id: id,
|
|
20
|
-
name: 'Point',
|
|
21
|
-
position: cartesian,
|
|
22
|
-
point: {
|
|
23
|
-
show: true,
|
|
24
|
-
color: color,
|
|
25
|
-
pixelSize: 20,
|
|
26
|
-
outlineColor: Cesium.Color.YELLOW,
|
|
27
|
-
outlineWidth: 3,
|
|
28
|
-
heightReference: onground ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE,
|
|
29
|
-
disableDepthTestDistance: 1500 //解决遮挡显示一半的问题
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
point.GeoType = 'Point'; //记录对象的类型,用户后续编辑等操作
|
|
33
|
-
point.PottingPoint = cartesian; //记录对象的节点数据,用户后续编辑等操作
|
|
34
|
-
point.EditingPoint = cartesian; //记录对象的节点数据,用户后续编辑等操作
|
|
35
|
-
point.Editable = true; //代表当前对象可编辑,false状态下不可编辑
|
|
36
|
-
resultList.push(point);
|
|
37
|
-
handler.destroy();
|
|
38
|
-
CreateRemindertip(window.toolTip, event.position, false);
|
|
39
|
-
if (callback && typeof callback == 'function') callback(point);
|
|
40
|
-
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
41
|
-
handler.setInputAction(function (movement) {
|
|
42
|
-
//console.log('鼠标移动事件监测:------创建点------');
|
|
43
|
-
var endPos = movement.endPosition;
|
|
44
|
-
CreateRemindertip(window.toolTip, endPos, true);
|
|
45
|
-
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
46
|
-
};
|
|
47
|
-
export default CreatePoint;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 多边形标绘功能
|
|
3
|
-
*/
|
|
4
|
-
import * as Cesium from 'deeptwins-cesium';
|
|
5
|
-
import { getCatesian3FromPX } from "../utils/Coordinate";
|
|
6
|
-
import { newSessionid } from "../utils/PlotCommon";
|
|
7
|
-
import CreateRemindertip from "../utils/ReminderTip";
|
|
8
|
-
var CreatePolygon = function CreatePolygon(viewer, handler, resultList, options, callback) {
|
|
9
|
-
var id = options.id || newSessionid();
|
|
10
|
-
var color = options.color ? Cesium.Color.fromCssColorString(options.color) : Cesium.Color.BLUE.withAlpha(0.4);
|
|
11
|
-
var onground = options.onground || true;
|
|
12
|
-
if (viewer.entities.getById(id)) throw new Error('the id parameter is an unique value');
|
|
13
|
-
window.toolTip = '左键点击开始绘制';
|
|
14
|
-
var anchorpoints = [];
|
|
15
|
-
var polygon = undefined;
|
|
16
|
-
// 左键点击事件
|
|
17
|
-
handler.setInputAction(function (event) {
|
|
18
|
-
var pixPos = event.position;
|
|
19
|
-
var cartesian = getCatesian3FromPX(viewer, pixPos);
|
|
20
|
-
if (anchorpoints.length == 0) {
|
|
21
|
-
window.toolTip = '左键添加第二个顶点';
|
|
22
|
-
anchorpoints.push(cartesian);
|
|
23
|
-
var dynamicPositions = new Cesium.CallbackProperty(function () {
|
|
24
|
-
return new Cesium.PolygonHierarchy(anchorpoints);
|
|
25
|
-
}, false);
|
|
26
|
-
polygon = viewer.entities.add({
|
|
27
|
-
name: 'Polygon',
|
|
28
|
-
id: id,
|
|
29
|
-
polygon: {
|
|
30
|
-
hierarchy: dynamicPositions,
|
|
31
|
-
material: color,
|
|
32
|
-
heightReference: onground ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE
|
|
33
|
-
},
|
|
34
|
-
polyline: {
|
|
35
|
-
positions: new Cesium.CallbackProperty(function () {
|
|
36
|
-
var linePos = anchorpoints.concat(anchorpoints[0]);
|
|
37
|
-
return linePos;
|
|
38
|
-
}, false),
|
|
39
|
-
width: 5,
|
|
40
|
-
material: Cesium.Color.GREEN,
|
|
41
|
-
clampToGround: onground
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
polygon.GeoType = 'Polygon'; //记录对象的类型,用户后续编辑等操作
|
|
45
|
-
polygon.Editable = true; //代表当前对象可编辑,false状态下不可编辑
|
|
46
|
-
} else {
|
|
47
|
-
window.toolTip = '左键添加点,右键撤销,左键双击完成绘制';
|
|
48
|
-
}
|
|
49
|
-
anchorpoints.push(cartesian);
|
|
50
|
-
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
51
|
-
// 鼠标移动事件
|
|
52
|
-
handler.setInputAction(function (movement) {
|
|
53
|
-
//console.log('鼠标移动事件监测:------创建多边形------');
|
|
54
|
-
var endPos = movement.endPosition;
|
|
55
|
-
CreateRemindertip(window.toolTip, endPos, true);
|
|
56
|
-
if (Cesium.defined(polygon)) {
|
|
57
|
-
anchorpoints.pop();
|
|
58
|
-
var cartesian = getCatesian3FromPX(viewer, endPos);
|
|
59
|
-
if (!cartesian) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
anchorpoints.push(cartesian);
|
|
63
|
-
}
|
|
64
|
-
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
65
|
-
// 左键双击事件
|
|
66
|
-
handler.setInputAction(function (event) {
|
|
67
|
-
anchorpoints.pop();
|
|
68
|
-
anchorpoints.pop(); //因为是双击结束,所以要pop两次,一次是move的结果,一次是单击结果
|
|
69
|
-
polygon.PottingPoint = Cesium.clone(anchorpoints, true); //记录对象的节点数据,用户后续编辑等操作
|
|
70
|
-
resultList.push(polygon);
|
|
71
|
-
handler.destroy();
|
|
72
|
-
CreateRemindertip(window.toolTip, event.position, false);
|
|
73
|
-
if (typeof callback == 'function') callback(polygon);
|
|
74
|
-
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
75
|
-
// 右键摁下事件
|
|
76
|
-
handler.setInputAction(function () {
|
|
77
|
-
anchorpoints.pop();
|
|
78
|
-
}, Cesium.ScreenSpaceEventType.RIGHT_DOWN);
|
|
79
|
-
};
|
|
80
|
-
export default CreatePolygon;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 折线标绘功能
|
|
3
|
-
*/
|
|
4
|
-
import * as Cesium from 'deeptwins-cesium';
|
|
5
|
-
import { getCatesian3FromPX } from "../utils/Coordinate";
|
|
6
|
-
import { newSessionid } from "../utils/PlotCommon";
|
|
7
|
-
import CreateRemindertip from "../utils/ReminderTip";
|
|
8
|
-
var CreatePolyline = function CreatePolyline(viewer, handler, resultList, options, callback) {
|
|
9
|
-
var id = options.id || newSessionid();
|
|
10
|
-
var color = options.color ? Cesium.Color.fromCssColorString(options.color) : Cesium.Color.BLUE.withAlpha(0.9);
|
|
11
|
-
var onground = options.onground || true;
|
|
12
|
-
if (viewer.entities.getById(id)) throw new Error('the id parameter is an unique value');
|
|
13
|
-
window.toolTip = '左键点击开始绘制';
|
|
14
|
-
var anchorpoints = [];
|
|
15
|
-
var polyline = undefined;
|
|
16
|
-
// 左键点击事件
|
|
17
|
-
handler.setInputAction(function (event) {
|
|
18
|
-
window.toolTip = '左键添加点,右键撤销,左键双击结束绘制';
|
|
19
|
-
var pixPos = event.position;
|
|
20
|
-
var cartesian = getCatesian3FromPX(viewer, pixPos);
|
|
21
|
-
if (anchorpoints.length == 0) {
|
|
22
|
-
anchorpoints.push(cartesian);
|
|
23
|
-
polyline = viewer.entities.add({
|
|
24
|
-
name: 'Polyline',
|
|
25
|
-
id: id,
|
|
26
|
-
polyline: {
|
|
27
|
-
show: true,
|
|
28
|
-
positions: new Cesium.CallbackProperty(function () {
|
|
29
|
-
return anchorpoints;
|
|
30
|
-
}, false),
|
|
31
|
-
width: 25,
|
|
32
|
-
material: new Cesium.PolylineGlowMaterialProperty({
|
|
33
|
-
glowPower: 0.1,
|
|
34
|
-
color: color
|
|
35
|
-
}),
|
|
36
|
-
clampToGround: onground
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
polyline.GeoType = 'Polyline'; //记录对象的类型,用户后续编辑等操作
|
|
40
|
-
polyline.Editable = true; //代表当前对象可编辑,false状态下不可编辑
|
|
41
|
-
}
|
|
42
|
-
anchorpoints.push(cartesian);
|
|
43
|
-
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
44
|
-
// 鼠标移动事件
|
|
45
|
-
handler.setInputAction(function (movement) {
|
|
46
|
-
//console.log('鼠标移动事件监测:------创建折线------');
|
|
47
|
-
var endPos = movement.endPosition;
|
|
48
|
-
CreateRemindertip(window.toolTip, endPos, true);
|
|
49
|
-
if (Cesium.defined(polyline)) {
|
|
50
|
-
anchorpoints.pop();
|
|
51
|
-
var cartesian = getCatesian3FromPX(viewer, endPos);
|
|
52
|
-
anchorpoints.push(cartesian);
|
|
53
|
-
}
|
|
54
|
-
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
55
|
-
// 左键双击事件
|
|
56
|
-
handler.setInputAction(function (event) {
|
|
57
|
-
anchorpoints.pop();
|
|
58
|
-
anchorpoints.pop(); //因为是双击结束,所以要pop两次,一次是move的结果,一次是单击结果
|
|
59
|
-
polyline.PottingPoint = Cesium.clone(polyline.polyline.positions.getValue(), true); //记录对象的节点数据,用户后续编辑等操作
|
|
60
|
-
resultList.push(polyline);
|
|
61
|
-
handler.destroy();
|
|
62
|
-
CreateRemindertip(window.toolTip, event.position, false);
|
|
63
|
-
if (callback && typeof callback == 'function') callback(polyline);
|
|
64
|
-
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
65
|
-
// 右键摁下事件
|
|
66
|
-
handler.setInputAction(function () {
|
|
67
|
-
anchorpoints.pop();
|
|
68
|
-
}, Cesium.ScreenSpaceEventType.RIGHT_DOWN);
|
|
69
|
-
};
|
|
70
|
-
export default CreatePolyline;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 矩形标绘功能
|
|
3
|
-
*/
|
|
4
|
-
import * as Cesium from 'deeptwins-cesium';
|
|
5
|
-
import { getCatesian3FromPX } from "../utils/Coordinate";
|
|
6
|
-
import { calculateRectanglePoints, newSessionid } from "../utils/PlotCommon";
|
|
7
|
-
import CreateRemindertip from "../utils/ReminderTip";
|
|
8
|
-
var CreateRectangle = function CreateRectangle(viewer, handler, resultList, options, callback) {
|
|
9
|
-
var id = options.id || newSessionid();
|
|
10
|
-
var color = options.color ? Cesium.Color.fromCssColorString(options.color) : Cesium.Color.BLUE.withAlpha(0.4);
|
|
11
|
-
var onground = options.onground || true;
|
|
12
|
-
if (viewer.entities.getById(id)) throw new Error('the id parameter is an unique value');
|
|
13
|
-
window.toolTip = '左键点击开始绘制';
|
|
14
|
-
var anchorpoints = []; //记录矩形的左上和右下两个点
|
|
15
|
-
var rectangle = undefined;
|
|
16
|
-
// 左键点击事件
|
|
17
|
-
handler.setInputAction(function (event) {
|
|
18
|
-
window.toolTip = '左键双击键结束绘制';
|
|
19
|
-
var pos = getCatesian3FromPX(viewer, event.position);
|
|
20
|
-
if (!pos || Cesium.defined(rectangle)) return;
|
|
21
|
-
anchorpoints.push(pos);
|
|
22
|
-
var dynamicRectangle = new Cesium.CallbackProperty(function () {
|
|
23
|
-
return Cesium.Rectangle.fromCartesianArray(calculateRectanglePoints(anchorpoints));
|
|
24
|
-
}, false);
|
|
25
|
-
rectangle = viewer.entities.add({
|
|
26
|
-
name: 'Rectangle',
|
|
27
|
-
id: id,
|
|
28
|
-
rectangle: {
|
|
29
|
-
coordinates: dynamicRectangle,
|
|
30
|
-
material: color,
|
|
31
|
-
heightReference: onground ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
rectangle.GeoType = 'Rectangle'; //记录对象的类型,用户后续编辑等操作
|
|
35
|
-
rectangle.Editable = true; //代表当前对象可编辑,false状态下不可编辑
|
|
36
|
-
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
37
|
-
// 鼠标移动事件
|
|
38
|
-
handler.setInputAction(function (movement) {
|
|
39
|
-
//console.log('鼠标移动事件监测:------创建矩形------');
|
|
40
|
-
var endPos = movement.endPosition;
|
|
41
|
-
CreateRemindertip(window.toolTip, endPos, true);
|
|
42
|
-
if (!Cesium.defined(rectangle)) return;
|
|
43
|
-
var endCartesian = getCatesian3FromPX(viewer, endPos);
|
|
44
|
-
if (!endCartesian) return;
|
|
45
|
-
if (anchorpoints.length > 1) {
|
|
46
|
-
anchorpoints.pop();
|
|
47
|
-
}
|
|
48
|
-
anchorpoints.push(endCartesian);
|
|
49
|
-
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
50
|
-
// 左键双击事件
|
|
51
|
-
handler.setInputAction(function () {
|
|
52
|
-
rectangle.PottingPoint = Cesium.clone(anchorpoints, true);
|
|
53
|
-
rectangle.EditingPoint = Cesium.clone(anchorpoints, true);
|
|
54
|
-
resultList.push(rectangle);
|
|
55
|
-
handler.destroy();
|
|
56
|
-
CreateRemindertip(window.toolTip, null, false);
|
|
57
|
-
if (typeof callback == 'function') callback(rectangle);
|
|
58
|
-
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
59
|
-
};
|
|
60
|
-
export default CreateRectangle;
|