@openglobus/og 0.14.4 → 0.15.0

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 (102) hide show
  1. package/css/og.css +377 -274
  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 +18 -17
  8. package/src/og/Clock.js +218 -194
  9. package/src/og/Globe.js +1 -3
  10. package/src/og/Object3d.js +104 -145
  11. package/src/og/camera/Camera.js +23 -19
  12. package/src/og/cons.js +107 -107
  13. package/src/og/control/Atmosphere.js +396 -0
  14. package/src/og/control/CompassButton.js +11 -18
  15. package/src/og/control/Control.js +187 -188
  16. package/src/og/control/GeoImageDragControl.js +84 -66
  17. package/src/og/control/LayerSwitcher.js +46 -145
  18. package/src/og/control/Lighting.js +314 -186
  19. package/src/og/control/RulerSwitcher.js +24 -19
  20. package/src/og/control/SimpleSkyBackground.js +38 -12
  21. package/src/og/control/Sun.js +2 -0
  22. package/src/og/control/ZoomControl.js +30 -42
  23. package/src/og/control/ruler/RulerScene.js +5 -23
  24. package/src/og/control/selection/Selection.js +21 -50
  25. package/src/og/control/selection/SelectionScene.js +15 -29
  26. package/src/og/control/timeline/TimelineControl.js +99 -0
  27. package/src/og/control/timeline/TimelineModel.js +133 -0
  28. package/src/og/control/timeline/TimelineView.js +449 -0
  29. package/src/og/control/timeline/timelineUtils.js +132 -0
  30. package/src/og/entity/Entity.js +30 -3
  31. package/src/og/entity/EntityCollection.js +0 -2
  32. package/src/og/entity/GeoObject.js +72 -56
  33. package/src/og/entity/GeoObjectHandler.js +487 -656
  34. package/src/og/input/input.js +3 -1
  35. package/src/og/layer/CanvasTiles.js +39 -34
  36. package/src/og/layer/Layer.js +2 -0
  37. package/src/og/layer/Material.js +1 -8
  38. package/src/og/light/LightSource.js +2 -0
  39. package/src/og/quadTree/Node.js +2 -1
  40. package/src/og/renderer/Renderer.js +26 -42
  41. package/src/og/renderer/RendererEvents.js +4 -4
  42. package/src/og/scene/Planet.js +276 -59
  43. package/src/og/scene/RenderNode.js +27 -12
  44. package/src/og/segment/Segment.js +0 -5
  45. package/src/og/shaders/atmos.js +332 -0
  46. package/src/og/shaders/drawnode.js +475 -109
  47. package/src/og/shaders/geoObject.js +96 -51
  48. package/src/og/shaders/polyline.js +212 -17
  49. package/src/og/shaders/utils.js +88 -0
  50. package/src/og/terrain/GlobusTerrain.js +2 -2
  51. package/src/og/ui/Button.js +106 -0
  52. package/src/og/ui/ButtonGroup.js +57 -0
  53. package/src/og/ui/Dialog.js +242 -0
  54. package/src/og/ui/Slider.js +144 -0
  55. package/src/og/ui/ToggleButton.js +51 -0
  56. package/src/og/ui/View.js +190 -0
  57. package/src/og/utils/shared.js +51 -33
  58. package/src/og/webgl/Framebuffer.js +308 -387
  59. package/src/og/webgl/Handler.js +68 -21
  60. package/src/og/webgl/Multisample.js +8 -0
  61. package/types/Clock.d.ts +7 -2
  62. package/types/Object3d.d.ts +14 -3
  63. package/types/camera/Camera.d.ts +15 -14
  64. package/types/control/Atmosphere.d.ts +15 -0
  65. package/types/control/CompassButton.d.ts +1 -2
  66. package/types/control/GeoImageDragControl.d.ts +7 -1
  67. package/types/control/LayerSwitcher.d.ts +4 -5
  68. package/types/control/Lighting.d.ts +32 -7
  69. package/types/control/SimpleSkyBackground.d.ts +4 -0
  70. package/types/control/ZoomControl.d.ts +0 -1
  71. package/types/control/ruler/RulerScene.d.ts +0 -1
  72. package/types/control/selection/Selection.d.ts +2 -4
  73. package/types/control/selection/SelectionScene.d.ts +0 -1
  74. package/types/entity/Entity.d.ts +8 -0
  75. package/types/entity/GeoObject.d.ts +28 -22
  76. package/types/entity/GeoObjectHandler.d.ts +16 -56
  77. package/types/input/input.d.ts +2 -0
  78. package/types/layer/CanvasTiles.d.ts +1 -0
  79. package/types/layer/Layer.d.ts +1 -0
  80. package/types/math/Plane.d.ts +1 -1
  81. package/types/renderer/Renderer.d.ts +7 -1
  82. package/types/scene/Planet.d.ts +20 -2
  83. package/types/scene/RenderNode.d.ts +2 -1
  84. package/types/segment/Segment.d.ts +1 -1
  85. package/types/shaders/atmos.d.ts +4 -0
  86. package/types/shaders/drawnode.d.ts +3 -2
  87. package/types/shaders/utils.d.ts +1 -0
  88. package/types/terrain/GlobusTerrain.d.ts +1 -1
  89. package/types/ui/Button.d.ts +21 -0
  90. package/types/ui/Dialog.d.ts +41 -0
  91. package/types/ui/Slider.d.ts +30 -0
  92. package/types/ui/ToggleButton.d.ts +10 -0
  93. package/types/ui/View.d.ts +32 -0
  94. package/types/utils/shared.d.ts +16 -14
  95. package/types/webgl/Framebuffer.d.ts +2 -5
  96. package/types/webgl/Handler.d.ts +11 -9
  97. package/types/webgl/Multisample.d.ts +2 -0
  98. package/src/og/ajax.js +0 -204
  99. package/src/og/entity/Object3d.js +0 -504
  100. package/types/ajax.d.ts +0 -24
  101. /package/src/og/{control → ui}/UIhelpers.js +0 -0
  102. /package/types/{control → ui}/UIhelpers.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openglobus/og",
3
- "version": "0.14.4",
3
+ "version": "0.15.0",
4
4
  "description": "[OpenGlobus](https://www.openglobus.org/) is a javascript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers and 3d objects. It uses the WebGL technology, open source and completely free.",
5
5
  "directories": {
6
6
  "example": "./sandbox"
@@ -11,7 +11,7 @@
11
11
  "scripts": {
12
12
  "api": "jsdoc -r ./src/ -c ./jsdoc.conf.json -d ./api",
13
13
  "serve": "ws",
14
- "build": "rollup -c",
14
+ "build": "rollup -c --bundleConfigAsCjs",
15
15
  "webgl": "rollup -c --environment entry:webgl",
16
16
  "core": "rollup -c --environment entry:core",
17
17
  "test": "jest --env=jsdom --runInBand --ci --coverage=false",
@@ -44,24 +44,25 @@
44
44
  "./css/og.css": "./css/og.css"
45
45
  },
46
46
  "devDependencies": {
47
- "@babel/preset-env": "^7.18.9",
48
- "@rollup/plugin-json": "^4.1.0",
49
- "@types/jest": "^28.1.6",
50
- "eslint": "^8.20.0",
51
- "jaguarjs-jsdoc": "^1.1.0",
52
- "jest": "^28.1.3",
47
+ "@babel/preset-env": "^7.20.2",
48
+ "@rollup/plugin-json": "^6.0.0",
49
+ "@rollup/plugin-terser": "^0.3.0",
50
+ "@types/jest": "^29.2.6",
51
+ "eslint": "^8.32.0",
52
+ "jaguarjs-jsdoc": "^1.0.2",
53
+ "jest": "^29.3.1",
53
54
  "jest-canvas-mock": "^2.4.0",
54
- "jest-environment-jsdom": "^28.1.3",
55
+ "jest-environment-jsdom": "^29.3.1",
55
56
  "jest-webgl-canvas-mock": "^0.2.3",
56
- "jsdoc": "^3.6.11",
57
- "lint-staged": "^13.0.3",
57
+ "jsdoc": "^4.0.2",
58
+ "lint-staged": "^13.1.0",
58
59
  "local-web-server": "^5.2.1",
59
- "postcss": "^8.4.14",
60
- "prettier": "^2.7.1",
61
- "rollup": "^2.77.1",
60
+ "postcss": "^8.4.21",
61
+ "prettier": "^2.8.3",
62
+ "rollup": "^3.10.0",
62
63
  "rollup-plugin-postcss": "^4.0.2",
63
- "rollup-plugin-terser": "^7.0.2",
64
- "typescript": "^4.7.4"
64
+ "taffydb": "^2.7.3",
65
+ "typescript": "^4.9.4"
65
66
  },
66
67
  "lint-staged": {
67
68
  "*.{js,ts}": [
@@ -81,4 +82,4 @@
81
82
  "globe",
82
83
  "og"
83
84
  ]
84
- }
85
+ }
package/src/og/Clock.js CHANGED
@@ -1,194 +1,218 @@
1
- /**
2
- * @module og/Clock
3
- */
4
-
5
- "use strict";
6
-
7
- import { Events } from "./Events.js";
8
- import * as jd from "./astro/jd.js";
9
-
10
- /**
11
- * Class represents application timer that stores custom current julian datetime, and time speed multiplier.
12
- * @class
13
- * @param {Object} [params] - Clock parameters:
14
- * @param {number} [params.startDate=0.0] - Julian start date.
15
- * @param {number} [params.endDate=0.0] - Julian end date.
16
- * @param {number} [params.currentDate] - Julian current date. Default: current date.
17
- * @param {number} [params.multiplier=1.0] - Time speed multiolier.
18
- */
19
- class Clock {
20
- static get _staticCounter() {
21
- if (!this._counter && this._counter !== 0) {
22
- this._counter = 0;
23
- }
24
- return this._counter;
25
- }
26
-
27
- static set _staticCounter(n) {
28
- this._counter = n;
29
- }
30
-
31
- /**
32
- *
33
- * @param {Object} [params] - Clock parameters:
34
- */
35
- constructor(params) {
36
- params = params || {};
37
-
38
- this._id = Clock._staticCounter++;
39
-
40
- /**
41
- * Clock name.
42
- * @public
43
- * @type {string}
44
- */
45
- this.name = params.name || "";
46
-
47
- /**
48
- * Clock events.
49
- * @public
50
- * @type {Events}
51
- */
52
- this.events = new Events(["tick", "end"], this);
53
-
54
- /**
55
- * Start julian date clock loop.
56
- * @public
57
- * @type {number}
58
- */
59
- this.startDate = params.startDate || 0;
60
-
61
- /**
62
- * End julian date clock loop.
63
- * @public
64
- * @type {number}
65
- */
66
- this.endDate = params.endDate || 0;
67
-
68
- var currentDate = params.currentDate || jd.DateToUTC(new Date());
69
- if (params.startDate && currentDate < params.startDate) {
70
- currentDate = params.startDate;
71
- }
72
- if (params.endDate && currentDate > params.endDate) {
73
- currentDate = params.endDate;
74
- }
75
-
76
- /**
77
- * Current julian datetime.
78
- * @public
79
- * @type {number}
80
- */
81
- this.currentDate = currentDate;
82
-
83
- /**
84
- * Timer speed multiplier.
85
- * @public
86
- * @type {number}
87
- */
88
- this.multiplier = params.multiplier !== undefined ? params.multiplier : 1.0;
89
-
90
- /**
91
- * Animation frame delta time.
92
- * @public
93
- * @readonly
94
- * @type {number}
95
- */
96
- this.deltaTicks = 0;
97
-
98
- /**
99
- * Timer activity.
100
- * @public
101
- * @type {boolean}
102
- */
103
- this.active = true;
104
-
105
- this._intervalDelay = 0;
106
- this._intervalStart = 0;
107
- this._intervalCallback = null;
108
- }
109
-
110
- clearInterval() {
111
- this._intervalDelay = 0;
112
- this._intervalStart = 0;
113
- this._intervalCallback = null;
114
- }
115
-
116
- setInterval(delay, callback) {
117
- this._intervalStart = this.currentDate;
118
- this._intervalDelay = delay * jd.ONE_BY_MILLISECONDS_PER_DAY;
119
- this._intervalCallback = callback;
120
- }
121
-
122
- /**
123
- * Sets current clock datetime.
124
- * @public
125
- * @param {Object} date - JavaScript Date object.
126
- */
127
- setDate(date) {
128
- var d = jd.DateToUTC(date);
129
- if (this.startDate && d < this.startDate) {
130
- d = this.startDate;
131
- }
132
- if (this.endDate && d > this.endDate) {
133
- d = this.endDate;
134
- }
135
- this.currentDate = d;
136
- }
137
-
138
- /**
139
- * Returns current application date.
140
- * @public
141
- * @returns {Date} - Current date.
142
- */
143
- getDate() {
144
- return jd.UTCtoDate(this.currentDate);
145
- }
146
-
147
- reset() {
148
- if (this.startDate) {
149
- this.currentDate = this.startDate;
150
- }
151
- }
152
-
153
- _tick(dt) {
154
- this.deltaTicks = dt * this.multiplier;
155
- if (this.active) {
156
- var cd = jd.addMilliseconds(this.currentDate, this.deltaTicks);
157
- if (this.multiplier > 0) {
158
- if (this.endDate && cd > this.endDate) {
159
- this.currentDate = this.startDate;
160
- this.events.dispatch(this.events.end, this);
161
- } else {
162
- this.currentDate = cd;
163
- }
164
- } else {
165
- if (this.startDate && cd < this.startDate) {
166
- this.currentDate = this.endDate;
167
- this.events.dispatch(this.events.end, this);
168
- } else {
169
- this.currentDate = cd;
170
- }
171
- }
172
-
173
- if (this._intervalCallback) {
174
- if (this.currentDate - this._intervalStart >= this._intervalDelay) {
175
- this._intervalStart = this.currentDate;
176
- this._intervalCallback(this);
177
- }
178
- }
179
-
180
- this.events.dispatch(this.events.tick, this);
181
- }
182
- }
183
-
184
- /**
185
- * @public
186
- * @param {Clock} clock - Clock instance to compare.
187
- * @returns {boolean} - Returns true if a clock is the same instance.
188
- */
189
- equal(clock) {
190
- return this._id === clock._id;
191
- }
192
- }
193
-
194
- export { Clock };
1
+ /**
2
+ * @module og/Clock
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { Events } from "./Events.js";
8
+ import * as jd from "./astro/jd.js";
9
+
10
+ /**
11
+ * Class represents application timer that stores custom current julian datetime, and time speed multiplier.
12
+ * @class
13
+ * @param {Object} [params] - Clock parameters:
14
+ * @param {number} [params.startDate=0.0] - Julian start date.
15
+ * @param {number} [params.endDate=0.0] - Julian end date.
16
+ * @param {number} [params.currentDate] - Julian current date. Default: current date.
17
+ * @param {number} [params.multiplier=1.0] - Time speed multiolier.
18
+ */
19
+ class Clock {
20
+ static get _staticCounter() {
21
+ if (!this._counter && this._counter !== 0) {
22
+ this._counter = 0;
23
+ }
24
+ return this._counter;
25
+ }
26
+
27
+ static set _staticCounter(n) {
28
+ this._counter = n;
29
+ }
30
+
31
+ /**
32
+ *
33
+ * @param {Object} [params] - Clock parameters:
34
+ */
35
+ constructor(params) {
36
+ params = params || {};
37
+
38
+ this._id = Clock._staticCounter++;
39
+
40
+ /**
41
+ * Clock name.
42
+ * @public
43
+ * @type {string}
44
+ */
45
+ this.name = params.name || "";
46
+
47
+ /**
48
+ * Clock events.
49
+ * @public
50
+ * @type {Events}
51
+ */
52
+ this.events = new Events(["tick", "end", "start", "stop"], this);
53
+
54
+ /**
55
+ * Start julian date clock loop.
56
+ * @public
57
+ * @type {number}
58
+ */
59
+ this.startDate = params.startDate || 0;
60
+
61
+ /**
62
+ * End julian date clock loop.
63
+ * @public
64
+ * @type {number}
65
+ */
66
+ this.endDate = params.endDate || 0;
67
+
68
+ var currentDate = params.currentDate || jd.DateToUTC(new Date());
69
+ if (params.startDate && currentDate < params.startDate) {
70
+ currentDate = params.startDate;
71
+ }
72
+ if (params.endDate && currentDate > params.endDate) {
73
+ currentDate = params.endDate;
74
+ }
75
+
76
+ /**
77
+ * Current julian datetime.
78
+ * @public
79
+ * @type {number}
80
+ */
81
+ this.currentDate = currentDate;
82
+
83
+ /**
84
+ * Timer speed multiplier.
85
+ * @public
86
+ * @type {number}
87
+ */
88
+ this._multiplier = params.multiplier !== undefined ? params.multiplier : 1.0;
89
+ this._running = 1;
90
+
91
+ /**
92
+ * Animation frame delta time.
93
+ * @public
94
+ * @readonly
95
+ * @type {number}
96
+ */
97
+ this.deltaTicks = 0;
98
+
99
+ /**
100
+ * Timer activity.
101
+ * @public
102
+ * @type {boolean}
103
+ */
104
+ this.active = true;
105
+
106
+ this._intervalDelay = 0;
107
+ this._intervalStart = 0;
108
+ this._intervalCallback = null;
109
+ }
110
+
111
+ clearInterval() {
112
+ this._intervalDelay = 0;
113
+ this._intervalStart = 0;
114
+ this._intervalCallback = null;
115
+ }
116
+
117
+ setInterval(delay, callback) {
118
+ this._intervalStart = this.currentDate;
119
+ this._intervalDelay = delay * jd.ONE_BY_MILLISECONDS_PER_DAY;
120
+ this._intervalCallback = callback;
121
+ }
122
+
123
+ /**
124
+ * Sets current clock datetime.
125
+ * @public
126
+ * @param {Object} date - JavaScript Date object.
127
+ */
128
+ setDate(date) {
129
+ var d = jd.DateToUTC(date);
130
+ if (this.startDate && d < this.startDate) {
131
+ d = this.startDate;
132
+ }
133
+ if (this.endDate && d > this.endDate) {
134
+ d = this.endDate;
135
+ }
136
+ this.currentDate = d;
137
+ }
138
+
139
+ /**
140
+ * Returns current application date.
141
+ * @public
142
+ * @returns {Date} - Current date.
143
+ */
144
+ getDate() {
145
+ return jd.UTCtoDate(this.currentDate);
146
+ }
147
+
148
+ reset() {
149
+ if (this.startDate) {
150
+ this.currentDate = this.startDate;
151
+ }
152
+ }
153
+
154
+ _tick(dt) {
155
+ let m = this._multiplier * this._running;
156
+ this.deltaTicks = dt * m
157
+ if (this.active) {
158
+ let cd = jd.addMilliseconds(this.currentDate, this.deltaTicks);
159
+ if (m > 0) {
160
+ if (this.endDate && cd > this.endDate) {
161
+ this.currentDate = this.startDate;
162
+ this.events.dispatch(this.events.end, this);
163
+ } else {
164
+ this.currentDate = cd;
165
+ }
166
+ } else {
167
+ if (this.startDate && cd < this.startDate) {
168
+ this.currentDate = this.endDate;
169
+ this.events.dispatch(this.events.end, this);
170
+ } else {
171
+ this.currentDate = cd;
172
+ }
173
+ }
174
+
175
+ if (this._intervalCallback) {
176
+ if (this.currentDate - this._intervalStart >= this._intervalDelay) {
177
+ this._intervalStart = this.currentDate;
178
+ this._intervalCallback(this);
179
+ }
180
+ }
181
+
182
+ this.events.dispatch(this.events.tick, this);
183
+ }
184
+ }
185
+
186
+ /**
187
+ * @public
188
+ * @param {Clock} clock - Clock instance to compare.
189
+ * @returns {boolean} - Returns true if a clock is the same instance.
190
+ */
191
+ isEqual(clock) {
192
+ return this._id === clock._id;
193
+ }
194
+
195
+ start() {
196
+ if (this._running === 0) {
197
+ this._running = 1;
198
+ this.events.dispatch(this.events.start, this);
199
+ }
200
+ }
201
+
202
+ get multiplier() {
203
+ return this._multiplier;
204
+ }
205
+
206
+ set multiplier(value) {
207
+ this._multiplier = value;
208
+ }
209
+
210
+ stop() {
211
+ if (this._running === 1) {
212
+ this._running = 0;
213
+ this.events.dispatch(this.events.stop, this);
214
+ }
215
+ }
216
+ }
217
+
218
+ export { Clock };
package/src/og/Globe.js CHANGED
@@ -20,7 +20,6 @@ import { isEmpty } from "./utils/shared.js";
20
20
  import { Handler } from "./webgl/Handler.js";
21
21
  import { createColorRGB } from "./utils/shared.js";
22
22
  import { Vec3 } from "./math/Vec3.js";
23
- import { SimpleSkyBackground } from "./control/SimpleSkyBackground.js";
24
23
 
25
24
  /** @const {string} */
26
25
  const CANVAS_ID_PREFIX = "globus_viewport_";
@@ -221,8 +220,7 @@ class Globe {
221
220
  new TouchNavigation(),
222
221
  new EarthCoordinates(),
223
222
  new ScaleControl(),
224
- new CompassButton(options),
225
- new SimpleSkyBackground()
223
+ new CompassButton(options)
226
224
  ]);
227
225
  }
228
226