@openglobus/og 0.13.7 → 0.13.10

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 (106) hide show
  1. package/README.md +1 -1
  2. package/css/og.css +388 -129
  3. package/dist/@openglobus/og.css +1 -1
  4. package/dist/@openglobus/og.esm.js +2 -2
  5. package/dist/@openglobus/og.esm.js.map +1 -1
  6. package/dist/@openglobus/og.umd.js +2 -2
  7. package/dist/@openglobus/og.umd.js.map +1 -1
  8. package/package.json +20 -19
  9. package/src/og/Globe.js +15 -16
  10. package/src/og/Object3d.js +417 -0
  11. package/src/og/arial.js +1705 -1703
  12. package/src/og/camera/Camera.js +640 -640
  13. package/src/og/control/EarthCoordinates.js +1 -1
  14. package/src/og/control/GeoImageDragControl.js +102 -75
  15. package/src/og/control/LayerAnimation.js +383 -0
  16. package/src/og/control/LayerSwitcher.js +506 -159
  17. package/src/og/control/Lighting.js +27 -27
  18. package/src/og/control/MouseNavigation.js +460 -460
  19. package/src/og/control/RulerSwitcher.js +69 -0
  20. package/src/og/control/Sun.js +170 -170
  21. package/src/og/control/UIhelpers.js +146 -0
  22. package/src/og/control/ZoomControl.js +0 -2
  23. package/src/og/control/index.js +5 -1
  24. package/src/og/control/ruler/Ruler.js +43 -0
  25. package/src/og/control/ruler/RulerScene.js +374 -0
  26. package/src/og/control/visibleExtent/Segment.js +3 -5
  27. package/src/og/ellipsoid/Ellipsoid.js +19 -0
  28. package/src/og/ellipsoid/wgs84.js +1 -1
  29. package/src/og/entity/Entity.js +1 -1
  30. package/src/og/entity/GeoObject.js +1 -1
  31. package/src/og/entity/LabelHandler.js +6 -2
  32. package/src/og/entity/LabelWorker.js +38 -53
  33. package/src/og/layer/BaseGeoImage.js +347 -312
  34. package/src/og/layer/CanvasTiles.js +312 -290
  35. package/src/og/layer/GeoImage.js +222 -214
  36. package/src/og/layer/GeoVideo.js +291 -291
  37. package/src/og/layer/Layer.js +94 -70
  38. package/src/og/layer/Material.js +109 -109
  39. package/src/og/layer/Vector.js +81 -14
  40. package/src/og/layer/XYZ.js +23 -11
  41. package/src/og/light/LightSource.js +364 -363
  42. package/src/og/math/Vec3.js +1 -1
  43. package/src/og/math.js +6 -6
  44. package/src/og/quadTree/Node.js +8 -6
  45. package/src/og/renderer/Renderer.js +2 -3
  46. package/src/og/res/images.js +0 -2
  47. package/src/og/scene/Planet.js +106 -44
  48. package/src/og/segment/Segment.js +34 -64
  49. package/src/og/segment/Slice.js +1 -1
  50. package/src/og/shaders/drawnode.js +1 -1
  51. package/src/og/shaders/label.js +30 -42
  52. package/src/og/terrain/GlobusTerrain.js +31 -20
  53. package/src/og/terrain/MapboxTerrain.js +1 -1
  54. package/src/og/utils/BaseWorker.js +46 -0
  55. package/src/og/utils/FontAtlas.js +1 -2
  56. package/src/og/utils/GeoImageCreator.js +164 -161
  57. package/src/og/utils/Loader.js +187 -153
  58. package/src/og/utils/NormalMapCreator.js +403 -412
  59. package/src/og/utils/PlainSegmentWorker.js +29 -55
  60. package/src/og/utils/TerrainWorker.js +572 -589
  61. package/src/og/utils/VectorTileCreator.js +1 -1
  62. package/src/og/utils/functionComposition.js +13 -0
  63. package/src/og/webgl/Handler.js +42 -41
  64. package/src/og/webgl/ProgramController.js +143 -143
  65. package/types/Object3d.d.ts +22 -0
  66. package/types/arial.d.ts +1 -0
  67. package/types/camera/PlanetCamera.d.ts +4 -0
  68. package/types/control/GeoImageDragControl.d.ts +2 -0
  69. package/types/control/LayerAnimation.d.ts +73 -0
  70. package/types/control/LayerSwitcher.d.ts +55 -11
  71. package/types/control/MouseNavigation.d.ts +1 -0
  72. package/types/control/MouseWheelZoomControl.d.ts +1 -0
  73. package/types/control/Sun.d.ts +2 -1
  74. package/types/control/TouchNavigation.d.ts +1 -0
  75. package/types/control/UIhelpers.d.ts +13 -0
  76. package/types/control/index.d.ts +3 -1
  77. package/types/control/ruler/Ruler.d.ts +13 -0
  78. package/types/control/ruler/RulerScene.d.ts +48 -0
  79. package/types/ellipsoid/Ellipsoid.d.ts +8 -0
  80. package/types/entity/LabelHandler.d.ts +2 -0
  81. package/types/entity/LabelWorker.d.ts +5 -7
  82. package/types/layer/BaseGeoImage.d.ts +9 -1
  83. package/types/layer/CanvasTiles.d.ts +5 -1
  84. package/types/layer/GeoImage.d.ts +1 -0
  85. package/types/layer/GeoTexture2d.d.ts +1 -0
  86. package/types/layer/Layer.d.ts +28 -32
  87. package/types/layer/Vector.d.ts +9 -0
  88. package/types/layer/WMS.d.ts +1 -0
  89. package/types/layer/XYZ.d.ts +8 -5
  90. package/types/math.d.ts +2 -2
  91. package/types/quadTree/EntityCollectionNode.d.ts +7 -0
  92. package/types/quadTree/Node.d.ts +1 -2
  93. package/types/renderer/Renderer.d.ts +1 -1
  94. package/types/renderer/RendererEvents.d.ts +16 -0
  95. package/types/res/images.d.ts +0 -1
  96. package/types/scene/Planet.d.ts +21 -6
  97. package/types/segment/SegmentLonLat.d.ts +2 -0
  98. package/types/terrain/BilTerrain.d.ts +6 -0
  99. package/types/terrain/GlobusTerrain.d.ts +7 -0
  100. package/types/terrain/MapboxTerrain.d.ts +8 -0
  101. package/types/utils/BaseWorker.d.ts +14 -0
  102. package/types/utils/Loader.d.ts +4 -1
  103. package/types/utils/PlainSegmentWorker.d.ts +4 -6
  104. package/types/utils/TerrainWorker.d.ts +4 -6
  105. package/types/utils/functionComposition.d.ts +5 -0
  106. package/types/webgl/Handler.d.ts +4 -1
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @module og/control/Ruler
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { Control } from "./Control.js";
8
+ import { Ruler } from "./ruler/Ruler.js";
9
+ import { elementFactory, btnClickHandler } from "./UIhelpers.js";
10
+
11
+ /**
12
+ * Activate ruler
13
+ * @class
14
+ * @extends {Control}
15
+ * @param {Object} [options] - Control options.
16
+ */
17
+ class RulerSwitcher extends Control {
18
+ constructor(options = {}) {
19
+ super(options);
20
+
21
+ this.ruler = new Ruler({
22
+ ignoreTerrain: options.ignoreTerrain
23
+ });
24
+ }
25
+
26
+ oninit() {
27
+ this.planet.addControl(this.ruler);
28
+ this._createMenuBtn();
29
+ }
30
+
31
+ onactivate() {
32
+ this.ruler.activate();
33
+ }
34
+
35
+ ondeactivate() {
36
+ this.ruler.deactivate();
37
+ }
38
+
39
+ _createMenuBtn() {
40
+ let btn = elementFactory(
41
+ 'div',
42
+ { id: 'og-ruler-menu-btn', class: 'og-ruler og-menu-btn og-OFF' },
43
+ elementFactory(
44
+ 'div',
45
+ { id: 'og-ruler-menu-icon', class: 'og-icon-holder' }
46
+ )
47
+ );
48
+
49
+ this.renderer.div.appendChild(btn);
50
+
51
+ btn.addEventListener('click', () => {
52
+ if (btn.classList.contains('og-OFF')) {
53
+ this.onactivate();
54
+ } else {
55
+ this.ondeactivate();
56
+ }
57
+ });
58
+
59
+ btnClickHandler(
60
+ btn,
61
+ null,
62
+ null,
63
+ '#og-ruler-menu-icon'
64
+ );
65
+ }
66
+ }
67
+
68
+ export { RulerSwitcher };
69
+
@@ -1,170 +1,170 @@
1
- /**
2
- * @module og/control/Sun
3
- */
4
-
5
- "use strict";
6
-
7
- import { Control } from "./Control.js";
8
- import { getSunPosition } from "../astro/earth.js";
9
- import { LightSource } from "../light/LightSource.js";
10
- import { Quat } from "../math/Quat.js";
11
- import { Vec3 } from "../math/Vec3.js";
12
-
13
- const ACTIVATION_HEIGHT = 12079000.0;
14
- /**
15
- * Real Sun geocentric position control that place the Sun on the right place by the Earth.
16
- * @class
17
- * @extends {Control}
18
- * @param {Object} [options] - Control options.
19
- */
20
- class Sun extends Control {
21
- constructor(options) {
22
- super(options);
23
-
24
- this._name = "sun";
25
-
26
- options = options || {};
27
-
28
- /**
29
- * Earth planet node.
30
- * @public
31
- * @type {Planet}
32
- */
33
- this.planet = null;
34
-
35
- /**
36
- * Sunlight position placed in the camera eye.
37
- * @private
38
- * @type {boolean}
39
- */
40
- // this._isCameraSunlight = false;
41
-
42
- this.offsetVertical = options.offsetVertical || -5000000;
43
-
44
- this.offsetHorizontal = options.offsetHorizontal || 5000000;
45
-
46
- /**
47
- * Light source.
48
- * @public
49
- * @type {LightSource}
50
- */
51
- this.sunlight = null;
52
-
53
- /**
54
- * Current frame handler clock date and time.
55
- * @private
56
- * @type {Number}
57
- */
58
- this._currDate = 0;
59
-
60
- /**
61
- * Previous frame handler clock date and time.
62
- * @private
63
- * @type {Number}
64
- */
65
- this._prevDate = 0;
66
-
67
- this._clockPtr = null;
68
-
69
- this._lightOn = false;
70
-
71
- this._stopped = options.stopped || false;
72
- }
73
-
74
- oninit() {
75
- this.planet.lightEnabled = true;
76
-
77
- // sunlight initialization
78
- this.sunlight = new LightSource("Sun", {
79
- ambient: new Vec3(0.15, 0.15, 0.25),
80
- diffuse: new Vec3(0.9, 0.9, 0.8),
81
- specular: new Vec3(0.1, 0.1, 0.06),
82
- shininess: 110
83
- });
84
- this.sunlight.addTo(this.planet);
85
-
86
- this.renderer.events.on("draw", this._draw, this);
87
-
88
- if (!this._clockPtr) {
89
- this._clockPtr = this.renderer.handler.defaultClock;
90
- }
91
- }
92
-
93
- stop() {
94
- this._stopped = true;
95
- }
96
-
97
- onactivate() {
98
- this._stopped = false;
99
- }
100
-
101
- bindClock(clock) {
102
- this._clockPtr = clock;
103
- }
104
-
105
- _draw() {
106
- this._currDate = this._clockPtr.currentDate;
107
- if (!this._stopped) {
108
- var cam = this.renderer.activeCamera;
109
- if (cam.getHeight() < ACTIVATION_HEIGHT || !this._active) {
110
- this._lightOn = true;
111
- this._f = 1;
112
- var n = cam.eye.normal(),
113
- u = cam.getForward();
114
-
115
- u.scale(Math.sign(cam._u.dot(n))); // up
116
-
117
- if (cam.slope > 0.99) {
118
- u = cam._u;
119
- }
120
-
121
- var tu = Vec3.proj_b_to_plane(u, n, u).normalize().scale(this.offsetVertical);
122
- var tr = Vec3.proj_b_to_plane(cam._r, n, cam._r)
123
- .normalize()
124
- .scale(this.offsetHorizontal); // right
125
- var d = tu.add(tr);
126
- var pos = cam.eye.add(d);
127
- if (this._k > 0) {
128
- this._k -= 0.01;
129
- let rot = Quat.getRotationBetweenVectors(
130
- this.sunlight._position.normal(),
131
- pos.normal()
132
- );
133
- let r = rot.slerp(Quat.IDENTITY, this._k).normalize();
134
- this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
135
- } else {
136
- this.sunlight.setPosition3v(pos);
137
- }
138
- } else {
139
- this._k = 1;
140
- if (this._f > 0) {
141
- this._f -= 0.01;
142
- let rot = Quat.getRotationBetweenVectors(
143
- this.sunlight._position.normal(),
144
- getSunPosition(this._currDate).normal()
145
- );
146
- let r = rot.slerp(Quat.IDENTITY, this._f).normalize();
147
- this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
148
- } else {
149
- if (
150
- (Math.abs(this._currDate - this._prevDate) > 0.00034 && this._active) ||
151
- this._lightOn
152
- ) {
153
- this._lightOn = false;
154
- this._prevDate = this._currDate;
155
- this.sunlight.setPosition3v(getSunPosition(this._currDate));
156
- this._f = 0;
157
- }
158
- }
159
- }
160
- } else {
161
- this.sunlight.setPosition3v(getSunPosition(this._currDate));
162
- }
163
- }
164
- }
165
-
166
- export function sun(options) {
167
- return Sun(options);
168
- }
169
-
170
- export { Sun };
1
+ /**
2
+ * @module og/control/Sun
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { Control } from "./Control.js";
8
+ import { getSunPosition } from "../astro/earth.js";
9
+ import { LightSource } from "../light/LightSource.js";
10
+ import { Quat } from "../math/Quat.js";
11
+ import { Vec3 } from "../math/Vec3.js";
12
+
13
+ const ACTIVATION_HEIGHT = 12079000.0;
14
+ /**
15
+ * Real Sun geocentric position control that place the Sun on the right place by the Earth.
16
+ * @class
17
+ * @extends {Control}
18
+ * @param {Object} [options] - Control options.
19
+ */
20
+ class Sun extends Control {
21
+ constructor(options) {
22
+ super(options);
23
+
24
+ this._name = "sun";
25
+
26
+ options = options || {};
27
+
28
+ /**
29
+ * Earth planet node.
30
+ * @public
31
+ * @type {Planet}
32
+ */
33
+ this.planet = null;
34
+
35
+ /**
36
+ * Sunlight position placed in the camera eye.
37
+ * @private
38
+ * @type {boolean}
39
+ */
40
+ // this._isCameraSunlight = false;
41
+
42
+ this.offsetVertical = options.offsetVertical || -5000000;
43
+
44
+ this.offsetHorizontal = options.offsetHorizontal || 5000000;
45
+
46
+ /**
47
+ * Light source.
48
+ * @public
49
+ * @type {LightSource}
50
+ */
51
+ this.sunlight = null;
52
+
53
+ /**
54
+ * Current frame handler clock date and time.
55
+ * @private
56
+ * @type {Number}
57
+ */
58
+ this._currDate = 0;
59
+
60
+ /**
61
+ * Previous frame handler clock date and time.
62
+ * @private
63
+ * @type {Number}
64
+ */
65
+ this._prevDate = 0;
66
+
67
+ this._clockPtr = null;
68
+
69
+ this._lightOn = false;
70
+
71
+ this._stopped = options.stopped || false;
72
+ }
73
+
74
+ oninit() {
75
+ this.planet.lightEnabled = true;
76
+
77
+ // sunlight initialization
78
+ this.sunlight = new LightSource("Sun", {
79
+ ambient: new Vec3(0.15, 0.15, 0.25),
80
+ diffuse: new Vec3(0.9, 0.9, 0.8),
81
+ specular: new Vec3(0.1, 0.1, 0.06),
82
+ shininess: 110
83
+ });
84
+ this.sunlight.addTo(this.planet);
85
+
86
+ this.renderer.events.on("draw", this._draw, this);
87
+
88
+ if (!this._clockPtr) {
89
+ this._clockPtr = this.renderer.handler.defaultClock;
90
+ }
91
+ }
92
+
93
+ stop() {
94
+ this._stopped = true;
95
+ }
96
+
97
+ onactivate() {
98
+ this._stopped = false;
99
+ }
100
+
101
+ bindClock(clock) {
102
+ this._clockPtr = clock;
103
+ }
104
+
105
+ _draw() {
106
+ this._currDate = this._clockPtr.currentDate;
107
+ if (!this._stopped) {
108
+ var cam = this.renderer.activeCamera;
109
+ if (cam.getHeight() < ACTIVATION_HEIGHT || !this._active) {
110
+ this._lightOn = true;
111
+ this._f = 1;
112
+ var n = cam.eye.normal(),
113
+ u = cam.getForward();
114
+
115
+ u.scale(Math.sign(cam._u.dot(n))); // up
116
+
117
+ if (cam.slope > 0.99) {
118
+ u = cam._u;
119
+ }
120
+
121
+ var tu = Vec3.proj_b_to_plane(u, n, u).normalize().scale(this.offsetVertical);
122
+ var tr = Vec3.proj_b_to_plane(cam._r, n, cam._r)
123
+ .normalize()
124
+ .scale(this.offsetHorizontal); // right
125
+ var d = tu.add(tr);
126
+ var pos = cam.eye.add(d);
127
+ if (this._k > 0) {
128
+ this._k -= 0.01;
129
+ let rot = Quat.getRotationBetweenVectors(
130
+ this.sunlight._position.normal(),
131
+ pos.normal()
132
+ );
133
+ let r = rot.slerp(Quat.IDENTITY, this._k).normalize();
134
+ this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
135
+ } else {
136
+ this.sunlight.setPosition3v(pos);
137
+ }
138
+ } else {
139
+ this._k = 1;
140
+ if (this._f > 0) {
141
+ this._f -= 0.01;
142
+ let rot = Quat.getRotationBetweenVectors(
143
+ this.sunlight._position.normal(),
144
+ getSunPosition(this._currDate).normal()
145
+ );
146
+ let r = rot.slerp(Quat.IDENTITY, this._f).normalize();
147
+ this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
148
+ } else {
149
+ if (
150
+ (Math.abs(this._currDate - this._prevDate) > 0.00034 && this._active) ||
151
+ this._lightOn
152
+ ) {
153
+ this._lightOn = false;
154
+ this._prevDate = this._currDate;
155
+ this.sunlight.setPosition3v(getSunPosition(this._currDate));
156
+ this._f = 0;
157
+ }
158
+ }
159
+ }
160
+ } else {
161
+ this.sunlight.setPosition3v(getSunPosition(this._currDate));
162
+ }
163
+ }
164
+ }
165
+
166
+ export function sun(options) {
167
+ return new Sun(options);
168
+ }
169
+
170
+ export { Sun };
@@ -0,0 +1,146 @@
1
+ 'use strict';
2
+
3
+ /*
4
+ * Helper functions for UI/UX
5
+ */
6
+
7
+ // Creates new DOM elements and assigns attributes
8
+ export function elementFactory(type, attributes, ...children) {
9
+ const el = document.createElement(type)
10
+ let key = null;
11
+ for (key in attributes) {
12
+ el.setAttribute(key, attributes[key])
13
+ }
14
+
15
+ children.forEach(child => {
16
+ if (typeof child === 'string') {
17
+ el.appendChild(document.createTextNode(child))
18
+ } else {
19
+ el.appendChild(child)
20
+ }
21
+ })
22
+
23
+ return el;
24
+ }
25
+
26
+ // Appends array of children to parent
27
+ export function appendChildren(parent, childrenArray) {
28
+ childrenArray.forEach(child => parent.appendChild(child))
29
+ }
30
+
31
+ // Cycles an array of text and outputs next
32
+ export function toggleText(elementText, textArray) {
33
+ let textIndex = textArray.indexOf(elementText);
34
+ let nextIndex;
35
+ textIndex >= 0 && textIndex < textArray.length - 1 ?
36
+ nextIndex = textIndex + 1 :
37
+ nextIndex = 0;
38
+ return textArray[nextIndex];
39
+ }
40
+
41
+ // Enables a movement of a DOM element. Also disables/enables mouse navigations for og-planet
42
+ export function enableElmovement(el, planet) {
43
+
44
+ let newPosX = 0,
45
+ newPosY = 0,
46
+ startPosX = 0,
47
+ startPosY = 0;
48
+
49
+ const behaviour = (e) => {
50
+ e.preventDefault();
51
+ planet.renderer.controls.mouseNavigation.deactivate()
52
+ // get the starting position of the cursor
53
+ startPosX = e.clientX;
54
+ startPosY = e.clientY;
55
+
56
+ document.addEventListener('mousemove', mouseMove);
57
+
58
+ document.addEventListener('mouseup', function (e) {
59
+ document.removeEventListener('mousemove', mouseMove);
60
+ planet.renderer.controls.mouseNavigation.activate();
61
+ });
62
+ }
63
+
64
+ const mouseMove = (e) => {
65
+ // calculate the new position
66
+ newPosX = startPosX - e.clientX;
67
+ newPosY = startPosY - e.clientY;
68
+
69
+ // with each move we also want to update the start X and Y
70
+ startPosX = e.clientX;
71
+ startPosY = e.clientY;
72
+
73
+ // set the element's new position:
74
+ el.style.top = (el.offsetTop - newPosY) + "px";
75
+ el.style.left = (el.offsetLeft - newPosX) + "px";
76
+ }
77
+
78
+ return { behaviour, mouseMove }
79
+ }
80
+
81
+ // Get all nodes of a class
82
+ export function getAllnodes(CSSclass) {
83
+ return document.querySelectorAll(CSSclass);
84
+ }
85
+
86
+ // Convert nodelist to an Array
87
+ export function nodesToArray(nodeList) {
88
+ return Array.from(nodeList);
89
+ }
90
+
91
+ // Adds a class to all elements selected
92
+ export function setAllCSSclass(CSSclass, nodeArray) {
93
+ return nodeArray.forEach(x => x.classList.add(CSSclass));
94
+ }
95
+
96
+ // Sets all menu buttons to off
97
+ export function allMenuBtnOFF() {
98
+ setAllCSSclass('og-OFF', nodesToArray(getAllnodes('.og-menu-btn')));
99
+ }
100
+
101
+ // Hides all dialoges of main menu
102
+ export function allDialogsHide() {
103
+ setAllCSSclass('og-hide', nodesToArray(getAllnodes('.og-dialog')));
104
+ }
105
+
106
+ function isString(v) {
107
+ return typeof v === 'string' || v instanceof String;
108
+ }
109
+
110
+ // Handles the click inside/outside a dialog - closes dialog when click outside
111
+ export function btnClickHandler(btn_id, dialog_id, dialog_selector, btn_icon_id) {
112
+ let btn = isString(btn_id) ? document.getElementById(btn_id) : btn_id;
113
+ let dialog = document.getElementById(dialog_id);
114
+ btn.onclick = function (e) {
115
+ if (this.classList.contains('og-OFF')) {
116
+ // Turn to ON
117
+ allMenuBtnOFF();
118
+ allDialogsHide();
119
+ this.classList.remove('og-OFF');
120
+ if (dialog) {
121
+ dialog.classList.remove('og-hide');
122
+ }
123
+
124
+ if (this.classList.contains('og-has-dialog')) {
125
+ document.addEventListener('click', (e) => {
126
+ if (e.target.matches(dialog_selector) || e.target.matches(btn_icon_id)) { //inside
127
+ return;
128
+ } else {//outside
129
+ btn.classList.add('og-OFF');
130
+ if (dialog) {
131
+ dialog.classList.add('og-hide')
132
+ }
133
+ // TODO needs fix
134
+ // this.removeEventListener('click', arguments.callee);
135
+ }
136
+ })
137
+ }
138
+ } else {
139
+ // Turn to OFF
140
+ this.classList.add('og-OFF');
141
+ if (dialog) {
142
+ dialog.classList.add('og-hide');
143
+ }
144
+ }
145
+ }
146
+ }
@@ -17,8 +17,6 @@ class ZoomControl extends Control {
17
17
  constructor(options) {
18
18
  super(options);
19
19
 
20
- options = options || {};
21
-
22
20
  this._keyLock = new Key();
23
21
 
24
22
  this.planet = null;
@@ -10,11 +10,13 @@ import { MouseNavigation } from "./MouseNavigation.js";
10
10
  import { ToggleWireframe } from "./ToggleWireframe.js";
11
11
  import { TouchNavigation } from "./TouchNavigation.js";
12
12
  import { SimpleNavigation } from "./SimpleNavigation.js";
13
+ import { Ruler } from "./ruler/Ruler.js";
13
14
  import { ShowFps } from "./ShowFps.js";
14
15
  import { Sun } from "./Sun.js";
15
16
  import { ZoomControl } from "./ZoomControl.js";
16
17
  import { MouseWheelZoomControl } from "./MouseWheelZoomControl.js";
17
18
  import { Lighting } from "./Lighting.js";
19
+ import { LayerAnimation } from "./LayerAnimation.js";
18
20
 
19
21
  export {
20
22
  Control,
@@ -33,5 +35,7 @@ export {
33
35
  Sun,
34
36
  ZoomControl,
35
37
  MouseWheelZoomControl,
36
- Lighting
38
+ Lighting,
39
+ Ruler,
40
+ LayerAnimation
37
41
  };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @module og/control/Ruler
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { Control } from "../Control.js";
8
+ import { RulerScene } from "./RulerScene.js";
9
+
10
+ /**
11
+ * Activate ruler
12
+ * @class
13
+ * @extends {Control}
14
+ * @param {Object} [options] - Control options.
15
+ */
16
+ class Ruler extends Control {
17
+ constructor(options = {}) {
18
+ super(options);
19
+
20
+ this._rulerScene = new RulerScene({
21
+ name: `rulerScene:${this._id}`,
22
+ ignoreTerrain: options.ignoreTerrain
23
+ });
24
+ }
25
+
26
+ set ignoreTerrain(v) {
27
+ this._rulerScene.ignoreTerrain = v;
28
+ }
29
+
30
+ oninit() {
31
+ this._rulerScene.bindPlanet(this.planet);
32
+ }
33
+
34
+ onactivate() {
35
+ this.renderer.addNode(this._rulerScene);
36
+ }
37
+
38
+ ondeactivate() {
39
+ this.renderer.removeNode(this._rulerScene);
40
+ }
41
+ }
42
+
43
+ export { Ruler };