@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.
- package/css/og.css +377 -274
- 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 +18 -17
- package/src/og/Clock.js +218 -194
- package/src/og/Globe.js +1 -3
- package/src/og/Object3d.js +104 -145
- package/src/og/camera/Camera.js +23 -19
- package/src/og/cons.js +107 -107
- package/src/og/control/Atmosphere.js +396 -0
- package/src/og/control/CompassButton.js +11 -18
- package/src/og/control/Control.js +187 -188
- package/src/og/control/GeoImageDragControl.js +84 -66
- package/src/og/control/LayerSwitcher.js +46 -145
- package/src/og/control/Lighting.js +314 -186
- package/src/og/control/RulerSwitcher.js +24 -19
- package/src/og/control/SimpleSkyBackground.js +38 -12
- package/src/og/control/Sun.js +2 -0
- package/src/og/control/ZoomControl.js +30 -42
- package/src/og/control/ruler/RulerScene.js +5 -23
- package/src/og/control/selection/Selection.js +21 -50
- package/src/og/control/selection/SelectionScene.js +15 -29
- package/src/og/control/timeline/TimelineControl.js +99 -0
- package/src/og/control/timeline/TimelineModel.js +133 -0
- package/src/og/control/timeline/TimelineView.js +449 -0
- package/src/og/control/timeline/timelineUtils.js +132 -0
- package/src/og/entity/Entity.js +30 -3
- package/src/og/entity/EntityCollection.js +0 -2
- package/src/og/entity/GeoObject.js +72 -56
- package/src/og/entity/GeoObjectHandler.js +487 -656
- package/src/og/input/input.js +3 -1
- package/src/og/layer/CanvasTiles.js +39 -34
- package/src/og/layer/Layer.js +2 -0
- package/src/og/layer/Material.js +1 -8
- package/src/og/light/LightSource.js +2 -0
- package/src/og/quadTree/Node.js +2 -1
- package/src/og/renderer/Renderer.js +26 -42
- package/src/og/renderer/RendererEvents.js +4 -4
- package/src/og/scene/Planet.js +276 -59
- package/src/og/scene/RenderNode.js +27 -12
- package/src/og/segment/Segment.js +0 -5
- package/src/og/shaders/atmos.js +332 -0
- package/src/og/shaders/drawnode.js +475 -109
- package/src/og/shaders/geoObject.js +96 -51
- package/src/og/shaders/polyline.js +212 -17
- package/src/og/shaders/utils.js +88 -0
- package/src/og/terrain/GlobusTerrain.js +2 -2
- package/src/og/ui/Button.js +106 -0
- package/src/og/ui/ButtonGroup.js +57 -0
- package/src/og/ui/Dialog.js +242 -0
- package/src/og/ui/Slider.js +144 -0
- package/src/og/ui/ToggleButton.js +51 -0
- package/src/og/ui/View.js +190 -0
- package/src/og/utils/shared.js +51 -33
- package/src/og/webgl/Framebuffer.js +308 -387
- package/src/og/webgl/Handler.js +68 -21
- package/src/og/webgl/Multisample.js +8 -0
- package/types/Clock.d.ts +7 -2
- package/types/Object3d.d.ts +14 -3
- package/types/camera/Camera.d.ts +15 -14
- package/types/control/Atmosphere.d.ts +15 -0
- package/types/control/CompassButton.d.ts +1 -2
- package/types/control/GeoImageDragControl.d.ts +7 -1
- package/types/control/LayerSwitcher.d.ts +4 -5
- package/types/control/Lighting.d.ts +32 -7
- package/types/control/SimpleSkyBackground.d.ts +4 -0
- package/types/control/ZoomControl.d.ts +0 -1
- package/types/control/ruler/RulerScene.d.ts +0 -1
- package/types/control/selection/Selection.d.ts +2 -4
- package/types/control/selection/SelectionScene.d.ts +0 -1
- package/types/entity/Entity.d.ts +8 -0
- package/types/entity/GeoObject.d.ts +28 -22
- package/types/entity/GeoObjectHandler.d.ts +16 -56
- package/types/input/input.d.ts +2 -0
- package/types/layer/CanvasTiles.d.ts +1 -0
- package/types/layer/Layer.d.ts +1 -0
- package/types/math/Plane.d.ts +1 -1
- package/types/renderer/Renderer.d.ts +7 -1
- package/types/scene/Planet.d.ts +20 -2
- package/types/scene/RenderNode.d.ts +2 -1
- package/types/segment/Segment.d.ts +1 -1
- package/types/shaders/atmos.d.ts +4 -0
- package/types/shaders/drawnode.d.ts +3 -2
- package/types/shaders/utils.d.ts +1 -0
- package/types/terrain/GlobusTerrain.d.ts +1 -1
- package/types/ui/Button.d.ts +21 -0
- package/types/ui/Dialog.d.ts +41 -0
- package/types/ui/Slider.d.ts +30 -0
- package/types/ui/ToggleButton.d.ts +10 -0
- package/types/ui/View.d.ts +32 -0
- package/types/utils/shared.d.ts +16 -14
- package/types/webgl/Framebuffer.d.ts +2 -5
- package/types/webgl/Handler.d.ts +11 -9
- package/types/webgl/Multisample.d.ts +2 -0
- package/src/og/ajax.js +0 -204
- package/src/og/entity/Object3d.js +0 -504
- package/types/ajax.d.ts +0 -24
- /package/src/og/{control → ui}/UIhelpers.js +0 -0
- /package/types/{control → ui}/UIhelpers.d.ts +0 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { stringTemplate } from '../utils/shared.js';
|
|
5
|
+
import { parseHTML } from "../utils/shared.js";
|
|
6
|
+
import { Events } from '../Events.js';
|
|
7
|
+
|
|
8
|
+
class View {
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
this.__id = View.__staticCounter++;
|
|
11
|
+
this._events = new Events(options.eventList || []);
|
|
12
|
+
this.model = options.model || null;
|
|
13
|
+
this.template = options.template || "";
|
|
14
|
+
this.parent = options.parent || null;
|
|
15
|
+
this._classList = options.classList || [];
|
|
16
|
+
if (options.appendTo) {
|
|
17
|
+
this.appendTo(options.appendTo);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static set __staticCounter(n) {
|
|
22
|
+
this.__counter__ = n;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static get __staticCounter() {
|
|
26
|
+
if (!this.__counter__ && this.__counter__ !== 0) {
|
|
27
|
+
this.__counter__ = 0;
|
|
28
|
+
}
|
|
29
|
+
return this.__counter__;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static getHTML(template, params) {
|
|
33
|
+
return stringTemplate(template, params);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static parseHTML(htmlStr) {
|
|
37
|
+
return parseHTML(htmlStr);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static insertAfter(newNodes, referenceNode) {
|
|
41
|
+
if (!Array.isArray(newNodes)) {
|
|
42
|
+
newNodes = [newNodes];
|
|
43
|
+
}
|
|
44
|
+
for (let i = 0; i < newNodes.length; i++) {
|
|
45
|
+
if (referenceNode.parentNode) {
|
|
46
|
+
referenceNode.parentNode.insertBefore(newNodes[i], referenceNode.nextSibling);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return newNodes;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static insertBefore(newNodes, referenceNode) {
|
|
53
|
+
if (!Array.isArray(newNodes)) {
|
|
54
|
+
newNodes = [newNodes];
|
|
55
|
+
}
|
|
56
|
+
for (let i = 0; i < newNodes.length; i++) {
|
|
57
|
+
if (referenceNode.parentNode) {
|
|
58
|
+
referenceNode.parentNode.insertBefore(newNodes[i], referenceNode);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
on(eventName, callback, sender) {
|
|
64
|
+
return this._events.on(eventName, callback, sender);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
off(eventName, callback) {
|
|
68
|
+
return this._events.off(eventName, callback);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
insertBefore(view) {
|
|
72
|
+
if (!this.el) {
|
|
73
|
+
this.render();
|
|
74
|
+
}
|
|
75
|
+
if (this.el) {
|
|
76
|
+
if (view instanceof HTMLElement && view.parentNode) {
|
|
77
|
+
View.insertBefore(this.el, view);
|
|
78
|
+
}
|
|
79
|
+
if (view instanceof View && view.el.parentNode) {
|
|
80
|
+
View.insertBefore(this.el, view.el);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
insertAfter(view) {
|
|
86
|
+
if (!this.el) {
|
|
87
|
+
this.render();
|
|
88
|
+
}
|
|
89
|
+
if (this.el) {
|
|
90
|
+
if (view instanceof HTMLElement && view.parentNode) {
|
|
91
|
+
View.insertAfter(this.el, view);
|
|
92
|
+
}
|
|
93
|
+
if (view instanceof View && view.el.parentNode) {
|
|
94
|
+
View.insertAfter(this.el, view.el);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
isEqual(view) {
|
|
100
|
+
return view.__id === this.__id;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
appendTo(node, clean, firstPosition) {
|
|
104
|
+
if (node) {
|
|
105
|
+
if (!this.el) {
|
|
106
|
+
this.beforeRender(node);
|
|
107
|
+
this.render();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (this.el && this.el.parentNode) {
|
|
111
|
+
this.el.parentNode.removeChild(this.el);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (clean) {
|
|
115
|
+
node.innerHTML = "";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (firstPosition) {
|
|
119
|
+
if (node.childNodes[0]) {
|
|
120
|
+
View.insertBefore(this.el, node.childNodes[0]);
|
|
121
|
+
} else {
|
|
122
|
+
node.appendChild(this.el);
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
node.appendChild(this.el);
|
|
126
|
+
}
|
|
127
|
+
this.afterRender(node);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
afterRender(parentNode) {
|
|
134
|
+
//virtual
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
beforeRender(parentNode) {
|
|
138
|
+
//virtual
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
stopPropagation() {
|
|
142
|
+
this._events.stopPropagation();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
renderTemplate(params) {
|
|
146
|
+
return View.parseHTML(View.getHTML(this.template, params || {}))[0];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
render(params) {
|
|
150
|
+
this.el = this.renderTemplate(params);
|
|
151
|
+
for (let i = 0, len = this._classList.length; i < len; i++) {
|
|
152
|
+
this.el.classList.add(this._classList[i]);
|
|
153
|
+
}
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
select(queryStr) {
|
|
158
|
+
return this.el.querySelector(queryStr);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
selectRemove(queryStr) {
|
|
162
|
+
if (this.el) {
|
|
163
|
+
let r = this.select(queryStr);
|
|
164
|
+
if (r && r.parentNode) {
|
|
165
|
+
r.parentNode.removeChild(r);
|
|
166
|
+
return r;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
selectAll(queryStr, callback) {
|
|
172
|
+
if (this.el) {
|
|
173
|
+
const res = this.el.querySelectorAll(queryStr);
|
|
174
|
+
if (callback) {
|
|
175
|
+
for (let i = 0, len = res.length; i < len; i++) {
|
|
176
|
+
callback(res[i], i);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return res;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
remove() {
|
|
184
|
+
if (this.el && this.el.parentNode) {
|
|
185
|
+
this.el.parentNode.removeChild(this.el);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export { View };
|
package/src/og/utils/shared.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
|
-
import { ajax } from "../ajax.js";
|
|
8
7
|
import { colorTable } from "./colorTable.js";
|
|
9
8
|
import { Extent } from "../Extent.js";
|
|
10
9
|
import { LonLat } from "../LonLat.js";
|
|
@@ -20,6 +19,20 @@ export function isEmpty(v) {
|
|
|
20
19
|
return v == null;
|
|
21
20
|
}
|
|
22
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Returns true if the object pointer is undefined.
|
|
24
|
+
* @function
|
|
25
|
+
* @param {Object} obj - Object pointer.
|
|
26
|
+
* @returns {boolean} Returns true if object is undefined.
|
|
27
|
+
*/
|
|
28
|
+
export function isUndef(obj) {
|
|
29
|
+
return obj === void 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function isUndefExt(obj, defVal) {
|
|
33
|
+
return isUndef(obj) ? defVal : obj;
|
|
34
|
+
}
|
|
35
|
+
|
|
23
36
|
let _stampCounter = 0;
|
|
24
37
|
|
|
25
38
|
export function stamp(obj) {
|
|
@@ -34,24 +47,6 @@ export function isString(s) {
|
|
|
34
47
|
return typeof s === "string" || s instanceof String;
|
|
35
48
|
}
|
|
36
49
|
|
|
37
|
-
/**
|
|
38
|
-
* Synchronous text file loading. Returns file text.
|
|
39
|
-
* @param {string} fileUrl - File name path.
|
|
40
|
-
* @returns {string} -
|
|
41
|
-
*/
|
|
42
|
-
export function readTextFile(fileUrl) {
|
|
43
|
-
var res = "";
|
|
44
|
-
|
|
45
|
-
ajax.request(fileUrl, {
|
|
46
|
-
async: false,
|
|
47
|
-
success: function (data) {
|
|
48
|
-
res = data;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return res;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
50
|
/**
|
|
56
51
|
* Convert html color string to the RGBA number vector.
|
|
57
52
|
* @param {string} htmlColor - HTML string("#C6C6C6" or "#EF5" or "rgb(8,8,8)" or "rgba(8,8,8)") color.
|
|
@@ -797,34 +792,50 @@ export function makeArray(arr) {
|
|
|
797
792
|
* @param {TypedArray | Array} arr
|
|
798
793
|
* @param {Number} starting
|
|
799
794
|
* @param {Number} deleteCount
|
|
800
|
-
* @param {
|
|
795
|
+
* @param {Object} outArr
|
|
801
796
|
*/
|
|
802
797
|
|
|
803
|
-
export function spliceArray(arr, starting, deleteCount,
|
|
798
|
+
export function spliceArray(arr, starting, deleteCount, out) {
|
|
804
799
|
if (ArrayBuffer.isView(arr)) {
|
|
805
|
-
|
|
800
|
+
if (starting < 0) {
|
|
801
|
+
deleteCount = Math.abs(starting);
|
|
802
|
+
starting += arr.length;
|
|
803
|
+
}
|
|
804
|
+
return spliceTypedArray(arr, starting, deleteCount, out);
|
|
806
805
|
} else {
|
|
807
|
-
|
|
806
|
+
let res;
|
|
807
|
+
if (starting < 0) {
|
|
808
|
+
res = arr.splice(starting);
|
|
809
|
+
} else {
|
|
810
|
+
res = arr.splice(starting, deleteCount);
|
|
811
|
+
}
|
|
812
|
+
if (out) {
|
|
813
|
+
out.result = res;
|
|
814
|
+
}
|
|
808
815
|
return arr;
|
|
809
816
|
}
|
|
810
817
|
}
|
|
811
818
|
|
|
819
|
+
window.spliceArray = spliceArray;
|
|
820
|
+
|
|
812
821
|
/**
|
|
813
822
|
*
|
|
814
823
|
* @param {TypedArray} arr
|
|
815
824
|
* @param {Number} starting
|
|
816
825
|
* @param {Number} deleteCount
|
|
817
|
-
* @param {Array}
|
|
826
|
+
* @param {Array} outArr
|
|
818
827
|
*/
|
|
819
|
-
export function spliceTypedArray(arr, starting, deleteCount,
|
|
828
|
+
export function spliceTypedArray(arr, starting, deleteCount, out) {
|
|
820
829
|
if (arr.length === 0) {
|
|
821
830
|
return arr;
|
|
822
831
|
}
|
|
823
|
-
const newSize = arr.length - deleteCount
|
|
832
|
+
const newSize = arr.length - deleteCount;
|
|
824
833
|
const splicedArray = new arr.constructor(newSize);
|
|
825
834
|
splicedArray.set(arr.subarray(0, starting));
|
|
826
|
-
splicedArray.set(
|
|
827
|
-
|
|
835
|
+
splicedArray.set(arr.subarray(starting + deleteCount), starting);
|
|
836
|
+
if (out) {
|
|
837
|
+
out.result = arr.subarray(starting, starting + deleteCount);
|
|
838
|
+
}
|
|
828
839
|
return splicedArray;
|
|
829
840
|
}
|
|
830
841
|
|
|
@@ -933,11 +944,18 @@ export function cloneArray(items) {
|
|
|
933
944
|
}
|
|
934
945
|
|
|
935
946
|
/**
|
|
936
|
-
*
|
|
947
|
+
* Promise for load images
|
|
937
948
|
* @function
|
|
938
|
-
* @param {
|
|
939
|
-
* @returns {
|
|
949
|
+
* @param {string} url - link to image.
|
|
950
|
+
* @returns {Promise<Image>} Returns promise.
|
|
940
951
|
*/
|
|
941
|
-
export function
|
|
942
|
-
return
|
|
952
|
+
export async function loadImage(url) {
|
|
953
|
+
return new Promise(resolve => {
|
|
954
|
+
const image = new Image();
|
|
955
|
+
image.addEventListener('load', () => {
|
|
956
|
+
resolve(image);
|
|
957
|
+
});
|
|
958
|
+
image.src = url;
|
|
959
|
+
return image;
|
|
960
|
+
});
|
|
943
961
|
}
|