@openglobus/og 0.16.3 → 0.17.1
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/README.md +1 -1
- package/css/og.css +24 -2
- package/dist/@openglobus/og.css +1 -1
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/og/Clock.js +1 -5
- package/src/og/Events.js +2 -6
- package/src/og/Extent.js +5 -9
- package/src/og/Globe.js +93 -56
- package/src/og/ImageCanvas.js +13 -6
- package/src/og/Lock.js +44 -48
- package/src/og/LonLat.js +1 -5
- package/src/og/Object3d.js +2 -2
- package/src/og/QueueArray.js +1 -1
- package/src/og/Stack.js +49 -53
- package/src/og/astro/earth.js +112 -116
- package/src/og/astro/jd.js +514 -518
- package/src/og/astro/orbit.js +119 -123
- package/src/og/astro/rotation.js +36 -40
- package/src/og/bv/Box.js +77 -81
- package/src/og/bv/Sphere.js +57 -61
- package/src/og/camera/Camera.js +20 -7
- package/src/og/camera/Frustum.js +4 -4
- package/src/og/camera/PlanetCamera.js +15 -22
- package/src/og/cons.js +1 -1
- package/src/og/control/Atmosphere.js +0 -4
- package/src/og/control/Control.js +9 -8
- package/src/og/control/DebugInfo.js +3 -7
- package/src/og/control/DrawingSwitcher.js +117 -0
- package/src/og/control/EarthCoordinates.js +214 -214
- package/src/og/control/EarthNavigation.js +6 -13
- package/src/og/control/GeoImageDragControl.js +0 -4
- package/src/og/control/KeyboardNavigation.js +0 -4
- package/src/og/control/LayerAnimation.js +0 -4
- package/src/og/control/LayerSwitcher.js +2 -4
- package/src/og/control/Lighting.js +12 -16
- package/src/og/control/MouseNavigation.js +1 -5
- package/src/og/control/MouseWheelZoomControl.js +0 -4
- package/src/og/control/RulerSwitcher.js +0 -4
- package/src/og/control/ScaleControl.js +2 -6
- package/src/og/control/ShowFps.js +40 -44
- package/src/og/control/SimpleNavigation.js +10 -10
- package/src/og/control/SimpleSkyBackground.js +0 -4
- package/src/og/control/Sun.js +0 -4
- package/src/og/control/ToggleWireframe.js +35 -39
- package/src/og/control/ZoomControl.js +0 -4
- package/src/og/control/drawing/DrawingControl.js +51 -0
- package/src/og/control/drawing/LineStringDrawingScene.js +203 -0
- package/src/og/control/drawing/PolygonDrawingScene.js +785 -0
- package/src/og/control/elevationProfile/ElevationProfile.js +275 -0
- package/src/og/control/index.js +5 -1
- package/src/og/control/ruler/Ruler.js +0 -4
- package/src/og/control/ruler/RulerScene.js +3 -2
- package/src/og/control/selection/Selection.js +0 -4
- package/src/og/control/selection/SelectionScene.js +2 -4
- package/src/og/control/timeline/TimelineControl.js +4 -4
- package/src/og/control/timeline/TimelineModel.js +2 -2
- package/src/og/control/timeline/TimelineView.js +1 -0
- package/src/og/control/visibleExtent/Segment.js +7 -7
- package/src/og/control/visibleExtent/drawnode.js +0 -4
- package/src/og/ellipsoid/Ellipsoid.js +236 -325
- package/src/og/ellipsoid/wgs84.js +0 -4
- package/src/og/entity/BaseBillboard.js +375 -379
- package/src/og/entity/Billboard.js +0 -4
- package/src/og/entity/BillboardHandler.js +3 -7
- package/src/og/entity/Entity.js +22 -22
- package/src/og/entity/EntityCollection.js +14 -18
- package/src/og/entity/GeoObject.js +6 -8
- package/src/og/entity/GeoObjectHandler.js +30 -24
- package/src/og/entity/Geometry.js +5 -4
- package/src/og/entity/GeometryHandler.js +18 -19
- package/src/og/entity/Label.js +0 -4
- package/src/og/entity/LabelHandler.js +10 -14
- package/src/og/entity/LabelWorker.js +1 -1
- package/src/og/entity/PointCloud.js +2 -6
- package/src/og/entity/PointCloudHandler.js +122 -126
- package/src/og/entity/Polyline.js +15 -17
- package/src/og/entity/PolylineHandler.js +104 -108
- package/src/og/entity/Ray.js +29 -29
- package/src/og/entity/RayHandler.js +2 -2
- package/src/og/entity/Strip.js +1 -1
- package/src/og/entity/StripHandler.js +2 -2
- package/src/og/index.js +3 -1
- package/src/og/input/KeyboardHandler.js +128 -132
- package/src/og/input/MouseHandler.js +94 -98
- package/src/og/input/TouchHandler.js +59 -63
- package/src/og/input/input.js +44 -48
- package/src/og/layer/BaseGeoImage.js +6 -9
- package/src/og/layer/CanvasTiles.js +1 -5
- package/src/og/layer/GeoImage.js +0 -4
- package/src/og/layer/GeoTexture2d.js +0 -4
- package/src/og/layer/GeoVideo.js +0 -4
- package/src/og/layer/KML.js +1 -0
- package/src/og/layer/Layer.js +22 -26
- package/src/og/layer/Material.js +0 -4
- package/src/og/layer/Vector.js +25 -22
- package/src/og/layer/WMS.js +182 -186
- package/src/og/layer/XYZ.js +0 -4
- package/src/og/light/LightSource.js +0 -4
- package/src/og/math/Line2.js +28 -32
- package/src/og/math/Mat3.js +152 -156
- package/src/og/math/Ray.js +0 -4
- package/src/og/math/Vec2.js +0 -4
- package/src/og/math/Vec3.js +5 -4
- package/src/og/math/Vec4.js +0 -4
- package/src/og/math/coder.js +104 -104
- package/src/og/math.js +42 -10
- package/src/og/mercator.js +1 -1
- package/src/og/proj/EPSG3857.js +13 -13
- package/src/og/proj/Proj.js +59 -63
- package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +1 -0
- package/src/og/quadTree/EarthQuadTreeStrategy.js +1 -0
- package/src/og/quadTree/EntityCollectionNode.js +12 -16
- package/src/og/quadTree/MarsQuadTreeStrategy.js +1 -0
- package/src/og/quadTree/Node.js +15 -14
- package/src/og/quadTree/QuadTreeStrategy.js +1 -0
- package/src/og/quadTree/Wgs84QuadTreeStrategy.js +1 -0
- package/src/og/renderer/Renderer.js +114 -27
- package/src/og/renderer/RendererEvents.js +0 -4
- package/src/og/scene/Axes.js +74 -78
- package/src/og/scene/BaseNode.js +1 -5
- package/src/og/scene/Planet.js +127 -130
- package/src/og/scene/RenderNode.js +20 -12
- package/src/og/scene/SkyBox.js +104 -108
- package/src/og/segment/Segment.js +10 -6
- package/src/og/segment/SegmentLonLat.js +3 -7
- package/src/og/segment/segmentHelper.js +229 -225
- package/src/og/shaders/atmos.js +1 -1
- package/src/og/shaders/billboard.js +0 -4
- package/src/og/shaders/drawnode.js +5 -9
- package/src/og/shaders/geoObject.js +0 -4
- package/src/og/shaders/label.js +0 -4
- package/src/og/shaders/pickingMask.js +0 -4
- package/src/og/shaders/pointCloud.js +0 -4
- package/src/og/shaders/polyline.js +0 -4
- package/src/og/shaders/ray.js +0 -4
- package/src/og/shaders/skybox.js +0 -4
- package/src/og/terrain/EmptyTerrain.js +0 -4
- package/src/og/utils/FontAtlas.js +0 -4
- package/src/og/utils/GeoImageCreator.js +2 -3
- package/src/og/utils/NormalMapCreator.js +11 -12
- package/src/og/utils/PlainSegmentWorker.js +9 -9
- package/src/og/utils/TerrainWorker.js +2 -2
- package/src/og/utils/TextureAtlas.js +1 -1
- package/src/og/utils/VectorTileCreator.js +3 -9
- package/src/og/utils/earcut.js +8 -8
- package/src/og/utils/shared.js +30 -11
- package/src/og/webgl/Framebuffer.js +2 -6
- package/src/og/webgl/Handler.js +46 -20
- package/src/og/webgl/Multisample.js +2 -6
- package/src/og/webgl/Program.js +4 -8
- package/src/og/webgl/ProgramController.js +2 -2
- package/types/Clock.d.ts +1 -1
- package/types/Extent.d.ts +5 -5
- package/types/Globe.d.ts +15 -1
- package/types/ImageCanvas.d.ts +5 -0
- package/types/bv/Box.d.ts +1 -1
- package/types/bv/Sphere.d.ts +3 -3
- package/types/camera/Camera.d.ts +3 -2
- package/types/camera/PlanetCamera.d.ts +4 -4
- package/types/control/DrawingSwitcher.d.ts +13 -0
- package/types/control/EarthCoordinates.d.ts +1 -1
- package/types/control/Lighting.d.ts +8 -8
- package/types/control/drawing/DrawingControl.d.ts +14 -0
- package/types/control/drawing/LineStringDrawingScene.d.ts +5 -0
- package/types/control/drawing/PolygonDrawingScene.d.ts +99 -0
- package/types/control/index.d.ts +3 -1
- package/types/control/ruler/RulerScene.d.ts +0 -1
- package/types/control/selection/SelectionScene.d.ts +0 -1
- package/types/ellipsoid/Ellipsoid.d.ts +53 -64
- package/types/entity/Entity.d.ts +3 -2
- package/types/entity/GeoObject.d.ts +1 -2
- package/types/entity/Geometry.d.ts +5 -0
- package/types/entity/Polyline.d.ts +1 -1
- package/types/entity/Ray.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/layer/BaseGeoImage.d.ts +1 -1
- package/types/layer/CanvasTiles.d.ts +1 -1
- package/types/layer/Layer.d.ts +1 -1
- package/types/layer/Vector.d.ts +1 -0
- package/types/math/Vec3.d.ts +2 -0
- package/types/math.d.ts +7 -0
- package/types/renderer/Renderer.d.ts +7 -1
- package/types/scene/Axes.d.ts +0 -1
- package/types/scene/Planet.d.ts +27 -26
- package/types/scene/RenderNode.d.ts +2 -0
- package/types/scene/SkyBox.d.ts +0 -1
- package/types/segment/Segment.d.ts +3 -2
- package/types/segment/SegmentLonLat.d.ts +0 -1
- package/types/utils/GeoImageCreator.d.ts +1 -1
- package/types/utils/NormalMapCreator.d.ts +1 -1
- package/types/utils/VectorTileCreator.d.ts +2 -2
- package/types/utils/shared.d.ts +2 -0
- package/types/webgl/Handler.d.ts +6 -4
|
@@ -1,44 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { ShowFps };
|
|
44
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { print2d } from "../utils/shared.js";
|
|
4
|
+
import { Control } from "./Control.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Frame per second(FPS) display control.
|
|
8
|
+
* @class
|
|
9
|
+
* @extends {Control}
|
|
10
|
+
* @param {Object} [options] - Control options.
|
|
11
|
+
*/
|
|
12
|
+
class ShowFps extends Control {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
super(options);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
oninit() {
|
|
18
|
+
var d = document.createElement("div");
|
|
19
|
+
d.className = "defaultText ";
|
|
20
|
+
d.id = "ogShowFpsControl";
|
|
21
|
+
document.body.appendChild(d);
|
|
22
|
+
this.renderer.events.on("draw", this._draw, this);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
_draw() {
|
|
26
|
+
print2d(
|
|
27
|
+
"ogShowFpsControl",
|
|
28
|
+
(1000.0 / this.renderer.handler.deltaTime).toFixed(1),
|
|
29
|
+
this.renderer.handler.canvas.clientWidth - 60,
|
|
30
|
+
0
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function showFps(options) {
|
|
36
|
+
return new ShowFps(options);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { ShowFps };
|
|
40
|
+
|
|
@@ -35,7 +35,7 @@ class SimpleNavigation extends Control {
|
|
|
35
35
|
if (this._active) {
|
|
36
36
|
var camera = this.camera;
|
|
37
37
|
camera.slide(0, 0, -this.speed);
|
|
38
|
-
|
|
38
|
+
camera.update();
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -43,7 +43,7 @@ class SimpleNavigation extends Control {
|
|
|
43
43
|
if (this._active) {
|
|
44
44
|
var camera = this.camera;
|
|
45
45
|
camera.slide(0, 0, this.speed);
|
|
46
|
-
|
|
46
|
+
camera.update();
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -51,7 +51,7 @@ class SimpleNavigation extends Control {
|
|
|
51
51
|
if (this._active) {
|
|
52
52
|
var camera = this.camera;
|
|
53
53
|
camera.slide(-this.speed, 0, 0);
|
|
54
|
-
|
|
54
|
+
camera.update();
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -59,7 +59,7 @@ class SimpleNavigation extends Control {
|
|
|
59
59
|
if (this._active) {
|
|
60
60
|
var camera = this.camera;
|
|
61
61
|
camera.slide(this.speed, 0, 0);
|
|
62
|
-
|
|
62
|
+
camera.update();
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -67,7 +67,7 @@ class SimpleNavigation extends Control {
|
|
|
67
67
|
if (this._active) {
|
|
68
68
|
var cam = this.camera;
|
|
69
69
|
cam.pitch(0.5);
|
|
70
|
-
|
|
70
|
+
cam.update();
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -75,7 +75,7 @@ class SimpleNavigation extends Control {
|
|
|
75
75
|
if (this._active) {
|
|
76
76
|
var cam = this.camera;
|
|
77
77
|
cam.pitch(-0.5);
|
|
78
|
-
|
|
78
|
+
cam.update();
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -83,7 +83,7 @@ class SimpleNavigation extends Control {
|
|
|
83
83
|
if (this._active) {
|
|
84
84
|
var cam = this.camera;
|
|
85
85
|
cam.yaw(0.5);
|
|
86
|
-
|
|
86
|
+
cam.update();
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -91,7 +91,7 @@ class SimpleNavigation extends Control {
|
|
|
91
91
|
if (this._active) {
|
|
92
92
|
var cam = this.camera;
|
|
93
93
|
cam.yaw(-0.5);
|
|
94
|
-
|
|
94
|
+
cam.update();
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -99,7 +99,7 @@ class SimpleNavigation extends Control {
|
|
|
99
99
|
if (this._active) {
|
|
100
100
|
var cam = this.camera;
|
|
101
101
|
cam.roll(-0.5);
|
|
102
|
-
|
|
102
|
+
cam.update();
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -107,7 +107,7 @@ class SimpleNavigation extends Control {
|
|
|
107
107
|
if (this._active) {
|
|
108
108
|
var cam = this.camera;
|
|
109
109
|
cam.roll(0.5);
|
|
110
|
-
|
|
110
|
+
cam.update();
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
}
|
package/src/og/control/Sun.js
CHANGED
|
@@ -1,39 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { ToggleWireframe };
|
|
39
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { input } from "../input/input.js";
|
|
4
|
+
import { Control } from "./Control.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Planet GL draw mode(TRIANGLE_STRIP/LINE_STRING) changer.
|
|
8
|
+
* @class
|
|
9
|
+
* @extends {Control}
|
|
10
|
+
* @param {Object} [options] - Control options.
|
|
11
|
+
*/
|
|
12
|
+
class ToggleWireframe extends Control {
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
super(options);
|
|
15
|
+
this._isActive = options.isActive || false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
oninit() {
|
|
19
|
+
this.renderer.events.on("charkeypress", input.KEY_X, this.toogleWireframe, this);
|
|
20
|
+
if (this._isActive) {
|
|
21
|
+
this.planet.setDrawMode(this.renderer.handler.gl.LINE_STRIP);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
toogleWireframe(e) {
|
|
26
|
+
if (this.planet.drawMode === this.renderer.handler.gl.LINE_STRIP) {
|
|
27
|
+
this.planet.setDrawMode(this.renderer.handler.gl.TRIANGLE_STRIP);
|
|
28
|
+
} else {
|
|
29
|
+
this.planet.setDrawMode(this.renderer.handler.gl.LINE_STRIP);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { ToggleWireframe };
|
|
35
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Control } from "../Control.js";
|
|
4
|
+
import { PolygonDrawingScene } from "./PolygonDrawingScene.js";
|
|
5
|
+
import { LineStringDrawingScene } from "./LineStringDrawingScene.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Activate drawing
|
|
9
|
+
* @class
|
|
10
|
+
* @extends {Control}
|
|
11
|
+
* @param {Object} [options] - Control options.
|
|
12
|
+
*/
|
|
13
|
+
class DrawingControl extends Control {
|
|
14
|
+
constructor(options = {}) {
|
|
15
|
+
super(options);
|
|
16
|
+
|
|
17
|
+
this._drawingScene = new LineStringDrawingScene({
|
|
18
|
+
name: `drawingScene:${this._id}`
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
activatePolygonDrawing(){
|
|
23
|
+
this.deactivate();
|
|
24
|
+
this._drawingScene = new PolygonDrawingScene({
|
|
25
|
+
name: `drawingScene:${this._id}`
|
|
26
|
+
});
|
|
27
|
+
this.activate();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
activateLineStringDrawing() {
|
|
31
|
+
this.deactivate();
|
|
32
|
+
this._drawingScene = new LineStringDrawingScene({
|
|
33
|
+
name: `drawingScene:${this._id}`
|
|
34
|
+
});
|
|
35
|
+
this.activate();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
oninit() {
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onactivate() {
|
|
42
|
+
this._drawingScene.bindPlanet(this.planet);
|
|
43
|
+
this.renderer.addNode(this._drawingScene);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ondeactivate() {
|
|
47
|
+
this.renderer.removeNode(this._drawingScene);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { DrawingControl };
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OUTLINE_ALT,
|
|
3
|
+
CORNER_OPTIONS,
|
|
4
|
+
NUM_SEGMENTS,
|
|
5
|
+
OUTLINE_OPTIONS,
|
|
6
|
+
CENTER_OPTIONS,
|
|
7
|
+
PolygonDrawingScene
|
|
8
|
+
} from "./PolygonDrawingScene.js";
|
|
9
|
+
import { Entity } from "../../entity/Entity.js";
|
|
10
|
+
import { Line3, Vec2, Vec3 } from "../../math/index.js";
|
|
11
|
+
import * as math from "../../math.js";
|
|
12
|
+
import { GeometryType } from "../../entity/Geometry.js";
|
|
13
|
+
|
|
14
|
+
class LineStringDrawingScene extends PolygonDrawingScene {
|
|
15
|
+
constructor(props) {
|
|
16
|
+
super(props);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get geometryType() {
|
|
20
|
+
return "LineString";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_addNew(cart) {
|
|
24
|
+
this._appendCart(cart);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_appendCart(cart) {
|
|
28
|
+
let corners = this._cornerLayer.getEntities();
|
|
29
|
+
|
|
30
|
+
let segNum = corners.length - 1;
|
|
31
|
+
let prevCorn = corners[segNum];
|
|
32
|
+
|
|
33
|
+
let corner = new Entity({
|
|
34
|
+
geoObject: CORNER_OPTIONS,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
corner.setCartesian3v(cart);
|
|
38
|
+
corner.addTo(this._cornerLayer);
|
|
39
|
+
this._checkTerrainCollision(corner);
|
|
40
|
+
|
|
41
|
+
if (prevCorn) {
|
|
42
|
+
|
|
43
|
+
let prevCart = prevCorn.getCartesian();
|
|
44
|
+
|
|
45
|
+
let vecPrev = corner.getCartesian().sub(prevCart);
|
|
46
|
+
|
|
47
|
+
let distPrev = vecPrev.length();
|
|
48
|
+
|
|
49
|
+
vecPrev.normalize();
|
|
50
|
+
|
|
51
|
+
let prevPath = [];
|
|
52
|
+
|
|
53
|
+
for (let i = 0; i <= NUM_SEGMENTS; i++) {
|
|
54
|
+
let p = vecPrev.scaleTo(i * distPrev / NUM_SEGMENTS).addA(prevCart);
|
|
55
|
+
prevPath.push(p);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let entity = new Entity({
|
|
59
|
+
polyline: {
|
|
60
|
+
path3v: [prevPath],
|
|
61
|
+
isClosed: false,
|
|
62
|
+
properties: {
|
|
63
|
+
index: segNum + 1
|
|
64
|
+
},
|
|
65
|
+
...OUTLINE_OPTIONS
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
entity.polyline.altitude = OUTLINE_ALT;
|
|
69
|
+
this._outlineLayer.add(entity);
|
|
70
|
+
|
|
71
|
+
let prevCenterCart = vecPrev.scaleTo(distPrev * 0.5).addA(prevCart);
|
|
72
|
+
|
|
73
|
+
let center = new Entity({
|
|
74
|
+
geoObject: CENTER_OPTIONS,
|
|
75
|
+
});
|
|
76
|
+
center.setCartesian3v(prevCenterCart);
|
|
77
|
+
center.addTo(this._centerLayer);
|
|
78
|
+
this._checkTerrainCollision(center);
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_clearGhostPointer() {
|
|
84
|
+
this._ghostOutlineLayer.getEntities()[0].polyline.clear();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_moveCorner(indexCurrent, indexPrev, indexCenter) {
|
|
88
|
+
let corners = this._cornerLayer.getEntities();
|
|
89
|
+
if (corners.length == 0) return;
|
|
90
|
+
if (corners.length == 1) {
|
|
91
|
+
indexCurrent = indexPrev = indexCenter = 0;
|
|
92
|
+
}
|
|
93
|
+
let cartCurr = corners[indexCurrent].getCartesian();
|
|
94
|
+
let vecCurr = this._pickedCorner.getCartesian().sub(cartCurr);
|
|
95
|
+
let distCurr = vecCurr.length();
|
|
96
|
+
vecCurr.normalize();
|
|
97
|
+
|
|
98
|
+
let path = [];
|
|
99
|
+
for (let i = 0; i <= NUM_SEGMENTS; i++) {
|
|
100
|
+
let p = vecCurr.scaleTo(i * distCurr / NUM_SEGMENTS).addA(cartCurr);
|
|
101
|
+
path.push(p);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let entities = this._outlineLayer.getEntities();
|
|
105
|
+
|
|
106
|
+
let prevPolyline = entities[indexPrev].polyline;
|
|
107
|
+
|
|
108
|
+
prevPolyline.setPath3v([path]);
|
|
109
|
+
|
|
110
|
+
//
|
|
111
|
+
// Move center points
|
|
112
|
+
let centers = this._centerLayer.getEntities();
|
|
113
|
+
let center = centers[indexCenter];
|
|
114
|
+
|
|
115
|
+
if (center) {
|
|
116
|
+
let centerCart = vecCurr.scaleTo(distCurr * 0.5).addA(cartCurr);
|
|
117
|
+
center.setCartesian3v(centerCart);
|
|
118
|
+
this._checkTerrainCollision(center);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
_moveCornerPoint(e) {
|
|
123
|
+
let d = new Vec2(e.x, e.y).sub(this._startClick),
|
|
124
|
+
p = this._startPos.add(d);
|
|
125
|
+
|
|
126
|
+
let groundCoords = this._planet.getCartesianFromPixelTerrain(p);
|
|
127
|
+
|
|
128
|
+
if (groundCoords) {
|
|
129
|
+
|
|
130
|
+
this._pickedCorner.setCartesian3v(groundCoords);
|
|
131
|
+
|
|
132
|
+
let corners = this._cornerLayer.getEntities();
|
|
133
|
+
|
|
134
|
+
if (corners.length) {
|
|
135
|
+
let ind = this._pickedCorner.layerIndex;
|
|
136
|
+
let size = corners.length;
|
|
137
|
+
|
|
138
|
+
if (ind === 0) {
|
|
139
|
+
this._moveCorner(ind + 1, ind + 1, ind);
|
|
140
|
+
} else if (ind === corners.length - 1) {
|
|
141
|
+
this._moveCorner(ind - 1, ind, ind - 1);
|
|
142
|
+
} else {
|
|
143
|
+
this._moveCorner(ind + 1, ind + 1, ind);
|
|
144
|
+
this._moveCorner(ind - 1, ind, ind - 1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
_updateGhostOutlinePointer(groundPos) {
|
|
151
|
+
|
|
152
|
+
let corners = this._cornerLayer.getEntities();
|
|
153
|
+
let size = corners.length;
|
|
154
|
+
|
|
155
|
+
if (size > 0) {
|
|
156
|
+
|
|
157
|
+
let ind = size - 1;
|
|
158
|
+
|
|
159
|
+
this._insertCornerIndex = ind;
|
|
160
|
+
|
|
161
|
+
let cartPrev = corners[ind].getCartesian();
|
|
162
|
+
|
|
163
|
+
let vecPrev = this._ghostCorner.getCartesian().sub(cartPrev);
|
|
164
|
+
|
|
165
|
+
let distPrev = vecPrev.length();
|
|
166
|
+
|
|
167
|
+
vecPrev.normalize();
|
|
168
|
+
|
|
169
|
+
let pathPrev = [];
|
|
170
|
+
|
|
171
|
+
for (let i = 0; i <= NUM_SEGMENTS; i++) {
|
|
172
|
+
let p = vecPrev.scaleTo(i * distPrev / NUM_SEGMENTS).addA(cartPrev);
|
|
173
|
+
pathPrev.push(p);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
let entities = this._ghostOutlineLayer.getEntities();
|
|
177
|
+
|
|
178
|
+
let prevPolyline = entities[0].polyline;
|
|
179
|
+
|
|
180
|
+
prevPolyline.setPath3v([pathPrev]);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
_initGhostLayerPointer() {
|
|
185
|
+
this._ghostOutlineLayer.setEntities([
|
|
186
|
+
new Entity({
|
|
187
|
+
polyline: {
|
|
188
|
+
path3v: [],
|
|
189
|
+
isClosed: false,
|
|
190
|
+
...OUTLINE_OPTIONS
|
|
191
|
+
},
|
|
192
|
+
properties: {
|
|
193
|
+
index: 0
|
|
194
|
+
}
|
|
195
|
+
}),
|
|
196
|
+
this._ghostCorner
|
|
197
|
+
]);
|
|
198
|
+
|
|
199
|
+
this._ghostOutlineLayer.getEntities()[0].polyline.altitude = OUTLINE_ALT;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export { LineStringDrawingScene };
|