@openglobus/og 0.15.2 → 0.15.4

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.
Files changed (58) hide show
  1. package/css/og.css +24 -15
  2. package/dist/@openglobus/og.css +1 -1
  3. package/dist/@openglobus/og.esm.js +2 -2
  4. package/dist/@openglobus/og.esm.js.map +1 -1
  5. package/dist/@openglobus/og.umd.js +2 -2
  6. package/dist/@openglobus/og.umd.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/og/Globe.js +4 -0
  9. package/src/og/Object3d.js +1 -1
  10. package/src/og/control/DebugInfo.js +263 -165
  11. package/src/og/control/RulerSwitcher.js +4 -1
  12. package/src/og/control/SimpleNavigation.js +123 -128
  13. package/src/og/control/heightRuler/HeightRuler.js +12 -0
  14. package/src/og/control/heightRuler/HeightRulerScene.js +224 -0
  15. package/src/og/control/heightRuler/HeightRulerSwitcher.js +15 -0
  16. package/src/og/control/index.js +2 -0
  17. package/src/og/control/ruler/RulerScene.js +106 -79
  18. package/src/og/entity/Entity.js +6 -6
  19. package/src/og/entity/EntityCollection.js +4 -0
  20. package/src/og/entity/GeoObjectHandler.js +3 -0
  21. package/src/og/layer/BaseGeoImage.js +152 -16
  22. package/src/og/layer/GeoImage.js +0 -91
  23. package/src/og/layer/GeoTexture2d.js +54 -143
  24. package/src/og/layer/GeoVideo.js +6 -107
  25. package/src/og/layer/Material.js +1 -1
  26. package/src/og/layer/Vector.js +1 -0
  27. package/src/og/renderer/Renderer.js +92 -96
  28. package/src/og/renderer/RendererEvents.js +39 -23
  29. package/src/og/scene/BaseNode.js +113 -113
  30. package/src/og/scene/Planet.js +11 -8
  31. package/src/og/scene/RenderNode.js +42 -9
  32. package/src/og/segment/Segment.js +3 -3
  33. package/src/og/shaders/geoObject.js +12 -10
  34. package/src/og/shaders/pickingMask.js +1 -1
  35. package/src/og/shaders/polyline.js +212 -212
  36. package/src/og/utils/GeoImageCreator.js +61 -21
  37. package/src/og/utils/VectorTileCreator.js +32 -49
  38. package/src/og/webgl/Framebuffer.js +5 -0
  39. package/types/control/DebugInfo.d.ts +4 -0
  40. package/types/control/SimpleNavigation.d.ts +1 -0
  41. package/types/control/heightRuler/HeightRuler.d.ts +6 -0
  42. package/types/control/heightRuler/HeightRulerScene.d.ts +23 -0
  43. package/types/control/index.d.ts +2 -1
  44. package/types/control/ruler/RulerScene.d.ts +8 -5
  45. package/types/control/selection/SelectionScene.d.ts +0 -1
  46. package/types/entity/EntityCollection.d.ts +1 -0
  47. package/types/layer/BaseGeoImage.d.ts +17 -3
  48. package/types/layer/GeoImage.d.ts +0 -8
  49. package/types/layer/GeoTexture2d.d.ts +0 -2
  50. package/types/layer/GeoVideo.d.ts +0 -8
  51. package/types/renderer/Renderer.d.ts +12 -3
  52. package/types/scene/Axes.d.ts +1 -1
  53. package/types/scene/BaseNode.d.ts +2 -2
  54. package/types/scene/Planet.d.ts +0 -5
  55. package/types/scene/RenderNode.d.ts +16 -9
  56. package/types/scene/SkyBox.d.ts +1 -1
  57. package/types/utils/VectorTileCreator.d.ts +1 -3
  58. package/types/webgl/Framebuffer.d.ts +1 -0
@@ -1,128 +1,123 @@
1
- "use strict";
2
-
3
- import { input } from "../input/input.js";
4
- import { Control } from "./Control.js";
5
-
6
- /**
7
- * Simple keyboard camera navigation with W,S,A,D and shift keys to fly around the scene.
8
- * @class
9
- * @extends {Control}
10
- * @param {Object} [options] - Control options.
11
- */
12
- class SimpleNavigation extends Control {
13
- constructor(options) {
14
- options = options || {};
15
- super(options);
16
-
17
- this.camera = null;
18
- this.speed = options.speed || 1.0;
19
- }
20
-
21
- onactivate() {}
22
-
23
- ondeactivate() {}
24
-
25
- oninit() {
26
- this.camera = this.renderer.activeCamera;
27
- this.renderer.events.on("keypress", input.KEY_W, this.onCameraMoveForward, this);
28
- this.renderer.events.on("keypress", input.KEY_S, this.onCameraMoveBackward, this);
29
- this.renderer.events.on("keypress", input.KEY_A, this.onCameraStrifeLeft, this);
30
- this.renderer.events.on("keypress", input.KEY_D, this.onCameraStrifeRight, this);
31
- this.renderer.events.on("keypress", input.KEY_UP, this.onCameraLookUp, this);
32
- this.renderer.events.on("keypress", input.KEY_DOWN, this.onCameraLookDown, this);
33
- this.renderer.events.on("keypress", input.KEY_LEFT, this.onCameraTurnLeft, this);
34
- this.renderer.events.on("keypress", input.KEY_RIGHT, this.onCameraTurnRight, this);
35
- this.renderer.events.on("keypress", input.KEY_Q, this.onCameraRollLeft, this);
36
- this.renderer.events.on("keypress", input.KEY_E, this.onCameraRollRight, this);
37
- }
38
-
39
- onCameraMoveForward() {
40
- if (this._active) {
41
- var camera = this.camera;
42
- camera.slide(0, 0, -this.speed);
43
- camera.update();
44
- }
45
- }
46
-
47
- onCameraMoveBackward() {
48
- if (this._active) {
49
- var camera = this.camera;
50
- camera.slide(0, 0, this.speed);
51
- camera.update();
52
- }
53
- }
54
-
55
- onCameraStrifeLeft() {
56
- if (this._active) {
57
- var camera = this.camera;
58
- camera.slide(-this.speed, 0, 0);
59
- camera.update();
60
- }
61
- }
62
-
63
- onCameraStrifeRight() {
64
- if (this._active) {
65
- var camera = this.camera;
66
- camera.slide(this.speed, 0, 0);
67
- camera.update();
68
- }
69
- }
70
-
71
- onCameraLookUp() {
72
- if (this._active) {
73
- var cam = this.camera;
74
- cam.pitch(0.5);
75
- cam.update();
76
- }
77
- }
78
-
79
- onCameraLookDown() {
80
- if (this._active) {
81
- var cam = this.camera;
82
- cam.pitch(-0.5);
83
- cam.update();
84
- }
85
- }
86
-
87
- onCameraTurnLeft() {
88
- if (this._active) {
89
- var cam = this.camera;
90
- cam.yaw(0.5);
91
- cam.update();
92
- }
93
- }
94
-
95
- onCameraTurnRight() {
96
- if (this._active) {
97
- var cam = this.camera;
98
- cam.yaw(-0.5);
99
- cam.update();
100
- }
101
- }
102
-
103
- onCameraRollLeft() {
104
- if (this._active) {
105
- var cam = this.camera;
106
- cam.roll(-0.5);
107
- cam.update();
108
- }
109
- }
110
-
111
- onCameraRollRight() {
112
- if (this._active) {
113
- var cam = this.camera;
114
- cam.roll(0.5);
115
- cam.update();
116
- }
117
- }
118
- }
119
-
120
- /**
121
- * Creates simple navigation control instance.
122
- */
123
- export function simpleNavigation(options) {
124
- return new SimpleNavigation(options);
125
- }
126
-
127
- export { SimpleNavigation };
128
-
1
+ "use strict";
2
+
3
+ import { input } from "../input/input.js";
4
+ import { Control } from "./Control.js";
5
+
6
+ /**
7
+ * Simple keyboard camera navigation with W,S,A,D and shift keys to fly around the scene.
8
+ * @class
9
+ * @extends {Control}
10
+ * @param {Object} [options] - Control options.
11
+ */
12
+ class SimpleNavigation extends Control {
13
+ constructor(options = {}) {
14
+ super({ autoActivate: true, ...options });
15
+
16
+ this.camera = null;
17
+ this.speed = options.speed || 1.0;
18
+ }
19
+
20
+ oninit() {
21
+ this.camera = this.renderer.activeCamera;
22
+ this.renderer.events.on("keypress", input.KEY_W, this.onCameraMoveForward, this);
23
+ this.renderer.events.on("keypress", input.KEY_S, this.onCameraMoveBackward, this);
24
+ this.renderer.events.on("keypress", input.KEY_A, this.onCameraStrifeLeft, this);
25
+ this.renderer.events.on("keypress", input.KEY_D, this.onCameraStrifeRight, this);
26
+ this.renderer.events.on("keypress", input.KEY_UP, this.onCameraLookUp, this);
27
+ this.renderer.events.on("keypress", input.KEY_DOWN, this.onCameraLookDown, this);
28
+ this.renderer.events.on("keypress", input.KEY_LEFT, this.onCameraTurnLeft, this);
29
+ this.renderer.events.on("keypress", input.KEY_RIGHT, this.onCameraTurnRight, this);
30
+ this.renderer.events.on("keypress", input.KEY_Q, this.onCameraRollLeft, this);
31
+ this.renderer.events.on("keypress", input.KEY_E, this.onCameraRollRight, this);
32
+ }
33
+
34
+ onCameraMoveForward() {
35
+ if (this._active) {
36
+ var camera = this.camera;
37
+ camera.slide(0, 0, -this.speed);
38
+ camera.update();
39
+ }
40
+ }
41
+
42
+ onCameraMoveBackward() {
43
+ if (this._active) {
44
+ var camera = this.camera;
45
+ camera.slide(0, 0, this.speed);
46
+ camera.update();
47
+ }
48
+ }
49
+
50
+ onCameraStrifeLeft() {
51
+ if (this._active) {
52
+ var camera = this.camera;
53
+ camera.slide(-this.speed, 0, 0);
54
+ camera.update();
55
+ }
56
+ }
57
+
58
+ onCameraStrifeRight() {
59
+ if (this._active) {
60
+ var camera = this.camera;
61
+ camera.slide(this.speed, 0, 0);
62
+ camera.update();
63
+ }
64
+ }
65
+
66
+ onCameraLookUp() {
67
+ if (this._active) {
68
+ var cam = this.camera;
69
+ cam.pitch(0.5);
70
+ cam.update();
71
+ }
72
+ }
73
+
74
+ onCameraLookDown() {
75
+ if (this._active) {
76
+ var cam = this.camera;
77
+ cam.pitch(-0.5);
78
+ cam.update();
79
+ }
80
+ }
81
+
82
+ onCameraTurnLeft() {
83
+ if (this._active) {
84
+ var cam = this.camera;
85
+ cam.yaw(0.5);
86
+ cam.update();
87
+ }
88
+ }
89
+
90
+ onCameraTurnRight() {
91
+ if (this._active) {
92
+ var cam = this.camera;
93
+ cam.yaw(-0.5);
94
+ cam.update();
95
+ }
96
+ }
97
+
98
+ onCameraRollLeft() {
99
+ if (this._active) {
100
+ var cam = this.camera;
101
+ cam.roll(-0.5);
102
+ cam.update();
103
+ }
104
+ }
105
+
106
+ onCameraRollRight() {
107
+ if (this._active) {
108
+ var cam = this.camera;
109
+ cam.roll(0.5);
110
+ cam.update();
111
+ }
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Creates simple navigation control instance.
117
+ */
118
+ export function simpleNavigation(options) {
119
+ return new SimpleNavigation(options);
120
+ }
121
+
122
+ export { SimpleNavigation };
123
+
@@ -0,0 +1,12 @@
1
+ import { Ruler } from "../ruler/Ruler.js";
2
+ import { HeightRulerScene } from "./HeightRulerScene.js";
3
+
4
+ export class HeightRuler extends Ruler {
5
+ constructor(options) {
6
+ super({ ...options });
7
+ this._rulerScene = new HeightRulerScene({
8
+ name: `heightRulerScene:${this._id}`,
9
+ ignoreTerrain: false
10
+ });
11
+ }
12
+ }
@@ -0,0 +1,224 @@
1
+ 'use strict';
2
+
3
+ import { Entity } from '../../entity/Entity.js';
4
+ import { RulerScene } from "../ruler/RulerScene.js";
5
+ import { Vector } from "../../layer/Vector.js";
6
+ import { Object3d } from "../../Object3d.js";
7
+
8
+ let obj3d = Object3d.createCylinder(1.1, 0, 2, 6, 1, true, true, 0, 0, 0)
9
+
10
+ const RAYS_OPTIONS = {
11
+ startColor: "rgb(255,131,0)",
12
+ endColor: "rgb(255,131,0)",
13
+ thickness: 5
14
+ }
15
+ const LABEL_OPTIONS = {
16
+ text: "",
17
+ size: 11,
18
+ color: "rgba(455,455,455,1.0)",
19
+ outlineColor: "rgba(0,0,0,0.34)",
20
+ outline: 0.23,
21
+ align: "center",
22
+ offset: [0, 18]
23
+ };
24
+
25
+ const RULER_CORNER_OPTIONS = {
26
+ scale: 1,
27
+ instanced: true,
28
+ tag: "height-ruler",
29
+ color: "rgb(255,131,0)",
30
+ object3d: obj3d
31
+ };
32
+
33
+ class HeightRulerScene extends RulerScene {
34
+ constructor(options = {}) {
35
+ super(options);
36
+
37
+
38
+ this._cornersLayer = new Vector("corners", {
39
+ entities: [],
40
+ pickingEnabled: true,
41
+ displayInLayerSwitcher: false,
42
+ scaleByDistance: [100, 4000000, 1.0],
43
+ pickingScale: 2
44
+ });
45
+
46
+
47
+ this._geoRulerLayer = new Vector("rayHeightRuler", {
48
+ entities: [],
49
+ pickingEnabled: false,
50
+ polygonOffsetUnits: -2.0,
51
+ relativeToGround: false,
52
+ displayInLayerSwitcher: false
53
+ });
54
+
55
+ }
56
+
57
+ get deltaLabel() {
58
+ return this._heightLabels[2]
59
+ }
60
+
61
+ get startLabel() {
62
+ return this._heightLabels[0]
63
+ }
64
+
65
+ get endLabel() {
66
+ return this._heightLabels[1]
67
+ }
68
+
69
+ get corners() {
70
+ return this._cornerEntity;
71
+ }
72
+
73
+ get startCorner() {
74
+ return this.corners[0];
75
+ }
76
+
77
+ get endCorner() {
78
+ return this.corners[1];
79
+ }
80
+
81
+ get startCornerLonLat() {
82
+ return this.startCorner.getLonLat();
83
+ }
84
+
85
+ get startCornerHeight() {
86
+ return this.startCornerLonLat.height;
87
+ }
88
+
89
+ get endCornerLonLat() {
90
+ return this.endCorner.getLonLat();
91
+ }
92
+
93
+ get endCornerHeight() {
94
+ return this.endCornerLonLat.height;
95
+ }
96
+
97
+ get maxHeightCornerLonLat() {
98
+ if (this.startCornerHeight <= this.endCornerHeight) {
99
+ return this.endCornerLonLat;
100
+ } else {
101
+ return this.startCornerLonLat;
102
+ }
103
+ }
104
+
105
+ get minHeightCornerLonLat() {
106
+ if (this.startCornerHeight > this.endCornerHeight) {
107
+ return this.endCornerLonLat;
108
+ } else {
109
+ return this.startCornerLonLat;
110
+ }
111
+ }
112
+
113
+ get deltaHeight() {
114
+ return Math.abs(this.startCornerHeight - this.endCornerHeight);
115
+ }
116
+
117
+ _drawLine(startLonLat, endLonLat, startPos) {
118
+
119
+ super._drawLine(startLonLat, endLonLat, startPos);
120
+ this._updateHeightRaysAndLabels();
121
+ }
122
+
123
+ async _updateHeightRaysAndLabels() {
124
+ const middleLonLat = this.minHeightCornerLonLat.clone();
125
+ middleLonLat.height = this.maxHeightCornerLonLat.height;
126
+
127
+ this._rayH.ray.setStartPosition3v(this._planet.ellipsoid.lonLatToCartesian(this.maxHeightCornerLonLat))
128
+ this._rayH.ray.setEndPosition3v(this._planet.ellipsoid.lonLatToCartesian(middleLonLat))
129
+ this._rayV.ray.setStartPosition3v(this._planet.ellipsoid.lonLatToCartesian(this.minHeightCornerLonLat));
130
+ this._rayV.ray.setEndPosition3v(this._planet.ellipsoid.lonLatToCartesian(middleLonLat));
131
+
132
+ middleLonLat.height = this.minHeightCornerLonLat.height + this.deltaHeight / 2;
133
+
134
+ this.deltaLabel.setLonLat(middleLonLat);
135
+ this.startLabel.setLonLat(this.startCornerLonLat);
136
+ this.endLabel.setLonLat(this.endCornerLonLat);
137
+
138
+ const startHeight = await this._planet.getHeightDefault(this.startCornerLonLat),
139
+ endHeight = await this._planet.getHeightDefault(this.endCornerLonLat)
140
+
141
+ this.deltaLabel.label.setText(`\u0394 ${Math.abs(startHeight - endHeight).toFixed(1)} m`);
142
+ this.startLabel.label.setText(`P1 ${startHeight.toFixed(1)} m`)
143
+ this.endLabel.label.setText(`P2 ${endHeight.toFixed(1)} m`)
144
+ }
145
+
146
+ clear() {
147
+ this._rayH.remove();
148
+ this._rayV.remove();
149
+ this.startCorner.remove();
150
+ this.endCorner.remove();
151
+ this.startLabel.remove();
152
+ this.endLabel.remove();
153
+ this.deltaLabel.remove();
154
+ super.clear()
155
+ this._rayH = undefined;
156
+ this._rayV = undefined;
157
+
158
+ this._planet.removeLayer(this._geoRulerLayer);
159
+ }
160
+
161
+ _createCorners() {
162
+ this._cornerEntity = [
163
+ new Entity({
164
+ geoObject: RULER_CORNER_OPTIONS,
165
+ properties: {
166
+ name: "start"
167
+ }
168
+ }),
169
+ new Entity({
170
+ geoObject: RULER_CORNER_OPTIONS,
171
+ properties: {
172
+ name: "end"
173
+ }
174
+ })
175
+ ];
176
+ this._cornersLayer.addEntities(this._cornerEntity)
177
+ }
178
+
179
+ init() {
180
+
181
+ super.init();
182
+ this._createCorners();
183
+ this._rayV = new Entity({
184
+ 'name': 'verticalRay',
185
+ 'ray': RAYS_OPTIONS
186
+ });
187
+ this._rayH = new Entity({
188
+ 'name': 'heightRay',
189
+ 'ray': RAYS_OPTIONS
190
+ });
191
+ this._heightLabels = [
192
+ new Entity({
193
+ 'name': 'startCornerLabel',
194
+ 'label': {
195
+ ...LABEL_OPTIONS
196
+ }
197
+ }),
198
+ new Entity({
199
+ 'name': 'endCornerLabel',
200
+ 'label': {
201
+ ...LABEL_OPTIONS
202
+ }
203
+ }),
204
+ new Entity({
205
+ 'name': 'deltaLabel',
206
+ 'label': {
207
+ ...LABEL_OPTIONS
208
+ }
209
+ })
210
+ ];
211
+ this._labelLayer.addEntities(this._heightLabels);
212
+ this._geoRulerLayer.addEntities([this._rayH, this._rayV]);
213
+
214
+ this._planet.addLayer(this._geoRulerLayer);
215
+ }
216
+
217
+ frame() {
218
+ super.frame()
219
+ this._updateHeightRaysAndLabels();
220
+ }
221
+ }
222
+
223
+
224
+ export { HeightRulerScene };
@@ -0,0 +1,15 @@
1
+ import { RulerSwitcher } from "../RulerSwitcher.js";
2
+ import { HeightRuler } from "./HeightRuler.js";
3
+
4
+ export class HeightRulerSwitcher extends RulerSwitcher {
5
+ constructor(options = {}) {
6
+ super({
7
+ name: `HeightRulerSwitcher`,
8
+ ...options
9
+ });
10
+ this.ruler = new HeightRuler({
11
+ ignoreTerrain: options.ignoreTerrain
12
+ });
13
+ }
14
+
15
+ }
@@ -11,6 +11,7 @@ import { Lighting } from "./Lighting.js";
11
11
  import { MouseNavigation } from "./MouseNavigation.js";
12
12
  import { MouseWheelZoomControl } from "./MouseWheelZoomControl.js";
13
13
  import { Ruler } from "./ruler/Ruler.js";
14
+ import { HeightRuler } from "./heightRuler/HeightRuler.js";
14
15
  import { ScaleControl } from "./ScaleControl.js";
15
16
  import { Selection } from "./selection/Selection.js";
16
17
  import { ShowFps } from "./ShowFps.js";
@@ -41,6 +42,7 @@ export {
41
42
  MouseWheelZoomControl,
42
43
  Lighting,
43
44
  Ruler,
45
+ HeightRuler,
44
46
  SimpleSkyBackground,
45
47
  Selection,
46
48
  LayerAnimation