@openglobus/og 0.15.4 → 0.16.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/README.md +4 -8
- package/css/og.css +1 -1
- 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 +13 -14
- package/src/og/Globe.js +5 -2
- package/src/og/LonLat.js +224 -193
- package/src/og/Object3d.js +21 -2
- package/src/og/bv/index.js +2 -2
- package/src/og/camera/Camera.js +4 -16
- package/src/og/camera/PlanetCamera.js +15 -15
- package/src/og/control/KeyboardNavigation.js +153 -169
- package/src/og/control/MouseNavigation.js +0 -20
- package/src/og/control/RulerSwitcher.js +2 -2
- package/src/og/control/SimpleNavigation.js +10 -10
- package/src/og/control/ZoomControl.js +2 -2
- package/src/og/control/heightRuler/HeightRulerScene.js +6 -2
- package/src/og/control/index.js +5 -2
- package/src/og/control/ruler/RulerScene.js +11 -8
- package/src/og/control/timeline/TimelineControl.js +5 -3
- package/src/og/control/timeline/TimelineModel.js +4 -0
- package/src/og/control/timeline/TimelineView.js +10 -3
- package/src/og/control/visibleExtent/Segment.js +36 -42
- package/src/og/ellipsoid/Ellipsoid.js +41 -11
- package/src/og/entity/Entity.js +3 -3
- package/src/og/entity/EntityCollection.js +2 -2
- package/src/og/entity/Label.js +1 -1
- package/src/og/entity/Polyline.js +4 -2
- package/src/og/index.js +4 -7
- package/src/og/layer/CanvasTiles.js +70 -23
- package/src/og/layer/GeoImage.js +40 -18
- package/src/og/layer/Vector.js +21 -17
- package/src/og/layer/WMS.js +2 -2
- package/src/og/layer/XYZ.js +2 -2
- package/src/og/math.js +2 -1
- package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +26 -0
- package/src/og/quadTree/EntityCollectionNode.js +8 -2
- package/src/og/quadTree/Node.js +44 -50
- package/src/og/quadTree/index.js +2 -0
- package/src/og/renderer/Renderer.js +14 -1
- package/src/og/scene/Planet.js +12 -8
- package/src/og/scene/index.js +3 -3
- package/src/og/segment/Segment.js +125 -120
- package/src/og/terrain/EmptyTerrain.js +19 -7
- package/src/og/terrain/GlobusTerrain.js +23 -18
- package/src/og/terrain/MapboxTerrain.js +7 -8
- package/src/og/terrain/index.js +4 -4
- package/src/og/utils/objParser.js +227 -0
- package/src/og/utils/shared.js +9 -0
- package/src/og/webgl/Handler.js +1 -3
- package/types/Globe.d.ts +2 -0
- package/types/LonLat.d.ts +20 -1
- package/types/Object3d.d.ts +2 -0
- package/types/Popup.d.ts +1 -1
- package/types/bv/index.d.ts +2 -2
- package/types/camera/PlanetCamera.d.ts +1 -8
- package/types/camera/index.d.ts +2 -2
- package/types/control/GeoImageDragControl.d.ts +1 -1
- package/types/control/LayerAnimation.d.ts +1 -1
- package/types/control/Lighting.d.ts +2 -2
- package/types/control/heightRuler/HeightRulerScene.d.ts +1 -1
- package/types/control/index.d.ts +3 -2
- package/types/control/ruler/RulerScene.d.ts +5 -4
- package/types/control/selection/SelectionScene.d.ts +3 -3
- package/types/control/timeline/TimelineControl.d.ts +10 -0
- package/types/control/timeline/TimelineModel.d.ts +33 -0
- package/types/control/timeline/TimelineView.d.ts +57 -0
- package/types/control/timeline/timelineUtils.d.ts +9 -0
- package/types/ellipsoid/Ellipsoid.d.ts +27 -8
- package/types/ellipsoid/index.d.ts +2 -2
- package/types/entity/Entity.d.ts +3 -3
- package/types/entity/EntityCollection.d.ts +2 -2
- package/types/entity/Label.d.ts +1 -1
- package/types/entity/Polyline.d.ts +1 -0
- package/types/index.d.ts +45 -46
- package/types/layer/CanvasTiles.d.ts +2 -1
- package/types/layer/GeoImage.d.ts +7 -1
- package/types/layer/GeoTexture2d.d.ts +1 -1
- package/types/layer/Vector.d.ts +3 -3
- package/types/layer/XYZ.d.ts +1 -1
- package/types/layer/index.d.ts +9 -9
- package/types/math/Line2.d.ts +1 -1
- package/types/math/Line3.d.ts +1 -1
- package/types/math/index.d.ts +10 -10
- package/types/mercator.d.ts +1 -1
- package/types/quadTree/EPSG4326QuadTreeStrategy.d.ts +3 -0
- package/types/quadTree/EntityCollectionNode.d.ts +1 -1
- package/types/quadTree/index.d.ts +2 -0
- package/types/renderer/Renderer.d.ts +2 -2
- package/types/scene/Axes.d.ts +1 -1
- package/types/scene/SkyBox.d.ts +1 -1
- package/types/scene/index.d.ts +3 -3
- package/types/segment/Segment.d.ts +11 -14
- package/types/shaders/atmos.d.ts +1 -1
- package/types/shaders/billboard.d.ts +1 -1
- package/types/shaders/depth.d.ts +1 -1
- package/types/shaders/label.d.ts +1 -1
- package/types/shaders/pickingMask.d.ts +1 -1
- package/types/shaders/pointCloud.d.ts +1 -1
- package/types/shaders/polyline.d.ts +1 -1
- package/types/shaders/ray.d.ts +1 -1
- package/types/shaders/screenFrame.d.ts +1 -1
- package/types/shaders/skybox.d.ts +1 -1
- package/types/shaders/toneMapping.d.ts +1 -1
- package/types/terrain/BilTerrain.d.ts +1 -0
- package/types/terrain/EmptyTerrain.d.ts +13 -2
- package/types/terrain/GlobusTerrain.d.ts +2 -1
- package/types/terrain/MapboxTerrain.d.ts +1 -3
- package/types/terrain/index.d.ts +4 -4
- package/types/ui/Button.d.ts +1 -1
- package/types/ui/ButtonGroup.d.ts +12 -0
- package/types/ui/Dialog.d.ts +2 -2
- package/types/ui/Slider.d.ts +1 -1
- package/types/ui/ToggleButton.d.ts +1 -1
- package/types/ui/View.d.ts +1 -1
- package/types/utils/GeoImageCreator.d.ts +2 -2
- package/types/utils/ImagesCacheManager.d.ts +1 -1
- package/types/utils/Loader.d.ts +1 -1
- package/types/utils/VectorTileCreator.d.ts +1 -1
- package/types/utils/objParser.d.ts +8 -0
- package/types/utils/shared.d.ts +6 -0
- package/types/webgl/Handler.d.ts +2 -2
- package/src/og/index.core.js +0 -116
- package/src/og/index.webgl.js +0 -17
- package/types/index.core.d.ts +0 -65
- package/types/index.webgl.d.ts +0 -7
|
@@ -19,6 +19,7 @@ export function distanceFormat(v) {
|
|
|
19
19
|
return `${v.toFixed(1)} m`;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
|
|
22
23
|
let obj3d = Object3d.createCylinder(1.1, 0, 2.7, 20, 1, true, false, 0, 0, 0)
|
|
23
24
|
|
|
24
25
|
const LABEL_OPTIONS = {
|
|
@@ -65,6 +66,7 @@ class RulerScene extends RenderNode {
|
|
|
65
66
|
relativeToGround: true,
|
|
66
67
|
displayInLayerSwitcher: false
|
|
67
68
|
});
|
|
69
|
+
|
|
68
70
|
this._labelLayer = new Vector("ruler-label", {
|
|
69
71
|
entities: [],
|
|
70
72
|
pickingEnabled: false,
|
|
@@ -118,8 +120,6 @@ class RulerScene extends RenderNode {
|
|
|
118
120
|
'label': LABEL_OPTIONS
|
|
119
121
|
});
|
|
120
122
|
|
|
121
|
-
// this._propsLabel.label.setVisibility(false);
|
|
122
|
-
|
|
123
123
|
this._trackEntity = new Entity({
|
|
124
124
|
polyline: {
|
|
125
125
|
path3v: [],
|
|
@@ -133,7 +133,7 @@ class RulerScene extends RenderNode {
|
|
|
133
133
|
|
|
134
134
|
this._createCorners();
|
|
135
135
|
this._trackLayer.addEntities([this._trackEntity]);
|
|
136
|
-
this._labelLayer.addEntities([
|
|
136
|
+
this._labelLayer.addEntities([this._propsLabel]);
|
|
137
137
|
this._planet.addLayer(this._labelLayer);
|
|
138
138
|
this._planet.addLayer(this._trackLayer);
|
|
139
139
|
this._planet.addLayer(this._cornersLayer);
|
|
@@ -169,7 +169,7 @@ class RulerScene extends RenderNode {
|
|
|
169
169
|
this._onCornerLup_ = this._onCornerLup.bind(this);
|
|
170
170
|
this._cornersLayer.events.on("lup", this._onCornerLup, this);
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
this.setVisibility(false);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
_deactivate() {
|
|
@@ -239,16 +239,19 @@ class RulerScene extends RenderNode {
|
|
|
239
239
|
this._preventClick = true;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
+
setVisibility(visibility) {
|
|
243
|
+
this._cornersLayer.setVisibility(visibility);
|
|
244
|
+
this._trackLayer.setVisibility(visibility);
|
|
245
|
+
this._labelLayer.setVisibility(visibility);
|
|
246
|
+
}
|
|
247
|
+
|
|
242
248
|
_onLclick(e) {
|
|
243
249
|
let startLonLat = this._planet.getLonLatFromPixelTerrain(e);
|
|
244
250
|
this._timeout = setTimeout(() => {
|
|
245
251
|
if (!this._preventClick) {
|
|
246
252
|
if (!this._startLonLat) {
|
|
253
|
+
this.setVisibility(true);
|
|
247
254
|
this._stopDrawing = false;
|
|
248
|
-
this._propsLabel.setVisibility(false);
|
|
249
|
-
this._trackEntity.polyline.setPath3v([]);
|
|
250
|
-
this._cornerEntity[0].setVisibility(true);
|
|
251
|
-
this._cornerEntity[1].setVisibility(true);
|
|
252
255
|
this._startLonLat = startLonLat;
|
|
253
256
|
} else {
|
|
254
257
|
this._startLonLat = null;
|
|
@@ -26,12 +26,14 @@ class TimelineControl extends Control {
|
|
|
26
26
|
}
|
|
27
27
|
super(options);
|
|
28
28
|
|
|
29
|
-
let currentDate = new Date();
|
|
30
|
-
let startDate =
|
|
29
|
+
let currentDate = options.current || new Date();
|
|
30
|
+
let startDate = options.rangeStart || addHours(currentDate, -12);
|
|
31
|
+
let endDate = options.rangeEnd || addHours(currentDate, 12);
|
|
31
32
|
|
|
32
33
|
this._timelineView = new TimelineView({
|
|
33
34
|
rangeStart: startDate,
|
|
34
|
-
rangeEnd: endDate
|
|
35
|
+
rangeEnd: endDate,
|
|
36
|
+
current: currentDate
|
|
35
37
|
});
|
|
36
38
|
|
|
37
39
|
this._toggleBtn = new ToggleButton({
|
|
@@ -112,9 +112,7 @@ class TimelineView extends View {
|
|
|
112
112
|
this._playBtn = new ToggleButton({
|
|
113
113
|
classList: ["og-timeline-control_button"],
|
|
114
114
|
icon: ICON_PLAY_SVG,
|
|
115
|
-
name: "play"
|
|
116
|
-
isActive: true,
|
|
117
|
-
preventClick: true
|
|
115
|
+
name: "play"
|
|
118
116
|
});
|
|
119
117
|
|
|
120
118
|
this._buttons = new ButtonGroup({
|
|
@@ -183,6 +181,15 @@ class TimelineView extends View {
|
|
|
183
181
|
this._playBtn.appendTo(this.$controls);
|
|
184
182
|
this._pauseBtn.appendTo(this.$controls);
|
|
185
183
|
|
|
184
|
+
if (this.model.stopped()) {
|
|
185
|
+
this._pauseBtn.setActive(true, true);
|
|
186
|
+
this._pauseBtn.preventClick = true;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
this._playBtn.setActive(true, true);
|
|
190
|
+
this._playBtn.preventClick = true;
|
|
191
|
+
}
|
|
192
|
+
|
|
186
193
|
this._buttons.on("change", (btn) => {
|
|
187
194
|
switch (btn.name) {
|
|
188
195
|
case "play":
|
|
@@ -268,8 +268,8 @@ class Segment {
|
|
|
268
268
|
* @param {Vec3} [normal] - Terrain point normal.
|
|
269
269
|
* @returns {Vec3} -
|
|
270
270
|
*/
|
|
271
|
-
getEntityTerrainPoint(entity, res
|
|
272
|
-
return this.getTerrainPoint(entity._cartesian, entity._lonlatMerc, res
|
|
271
|
+
getEntityTerrainPoint(entity, res) {
|
|
272
|
+
return this.getTerrainPoint(entity._cartesian, entity._lonlatMerc, res);
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
isEntityInside(e) {
|
|
@@ -285,80 +285,74 @@ class Segment {
|
|
|
285
285
|
* @param {Vec3} [normal] - Terrain point normal.
|
|
286
286
|
* @returns {number} -
|
|
287
287
|
*/
|
|
288
|
-
getTerrainPoint(xyz, insideSegmentPosition, res
|
|
289
|
-
|
|
288
|
+
getTerrainPoint(xyz, insideSegmentPosition, res) {
|
|
289
|
+
let verts = this.tempVertices;
|
|
290
290
|
|
|
291
|
-
|
|
291
|
+
if (verts && verts.length) {
|
|
292
|
+
let norm = this.planet.ellipsoid.getSurfaceNormal3v(xyz);
|
|
293
|
+
_ray.set(xyz, norm.negateTo());
|
|
292
294
|
|
|
293
|
-
|
|
294
|
-
var ne = this._extent.northEast,
|
|
295
|
+
let ne = this._extent.northEast,
|
|
295
296
|
sw = this._extent.southWest,
|
|
296
297
|
size = Math.sqrt(verts.length / 3) - 1;
|
|
297
298
|
|
|
298
|
-
|
|
299
|
+
let xmax = ne.lon,
|
|
299
300
|
ymax = ne.lat,
|
|
300
301
|
xmin = sw.lon,
|
|
301
302
|
ymin = sw.lat,
|
|
302
303
|
x = insideSegmentPosition.lon,
|
|
303
304
|
y = insideSegmentPosition.lat;
|
|
304
305
|
|
|
305
|
-
|
|
306
|
+
let sxn = xmax - xmin,
|
|
306
307
|
syn = ymax - ymin;
|
|
307
308
|
|
|
308
|
-
|
|
309
|
+
let qx = sxn / size,
|
|
309
310
|
qy = syn / size;
|
|
310
311
|
|
|
311
|
-
|
|
312
|
+
let xn = x - xmin,
|
|
312
313
|
yn = y - ymin;
|
|
313
314
|
|
|
314
|
-
|
|
315
|
+
let indX = Math.floor(xn / qx),
|
|
315
316
|
indY = Math.floor(size - yn / qy);
|
|
316
317
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
var ind_v2 = ((size + 1) * (indY + 1) + indX) * 3;
|
|
318
|
+
let ind_v0 = ((size + 1) * indY + indX) * 3;
|
|
319
|
+
let ind_v2 = ((size + 1) * (indY + 1) + indX) * 3;
|
|
320
320
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
321
|
+
_v0.set(verts[ind_v0], verts[ind_v0 + 1], verts[ind_v0 + 2]);
|
|
322
|
+
_v1.set(verts[ind_v0 + 3], verts[ind_v0 + 4], verts[ind_v0 + 5]);
|
|
323
|
+
_v2.set(verts[ind_v2], verts[ind_v2 + 1], verts[ind_v2 + 2]);
|
|
324
324
|
|
|
325
|
-
|
|
325
|
+
let d = _ray.hitTriangle(_v0, _v1, _v2, res);
|
|
326
326
|
|
|
327
|
+
if (d === Ray.INSIDE) {
|
|
328
|
+
return xyz.distance(res);
|
|
329
|
+
} else if (d === Ray.AWAY) {
|
|
330
|
+
_rayEx.set(xyz, norm);
|
|
331
|
+
let d = _rayEx.hitTriangle(_v0, _v1, _v2, res);
|
|
327
332
|
if (d === Ray.INSIDE) {
|
|
328
|
-
return xyz.distance(res);
|
|
329
|
-
} else if (d === Ray.AWAY) {
|
|
330
|
-
_rayEx.set(xyz, xyz);
|
|
331
|
-
let d = _rayEx.hitTriangle(_v0, _v1, _v2, res, normal);
|
|
332
|
-
if (d === Ray.INSIDE) {
|
|
333
|
-
return -xyz.distance(res);
|
|
334
|
-
}
|
|
333
|
+
return -xyz.distance(res);
|
|
335
334
|
}
|
|
335
|
+
}
|
|
336
336
|
|
|
337
|
-
|
|
337
|
+
_v3.set(verts[ind_v2 + 3], verts[ind_v2 + 4], verts[ind_v2 + 5]);
|
|
338
338
|
|
|
339
|
-
|
|
339
|
+
d = _ray.hitTriangle(_v1, _v3, _v2, res);
|
|
340
|
+
if (d === Ray.INSIDE) {
|
|
341
|
+
return xyz.distance(res);
|
|
342
|
+
} else if (d === Ray.AWAY) {
|
|
343
|
+
_rayEx.set(xyz, norm);
|
|
344
|
+
let d = _rayEx.hitTriangle(_v1, _v3, _v2, res);
|
|
340
345
|
if (d === Ray.INSIDE) {
|
|
341
|
-
return xyz.distance(res);
|
|
342
|
-
} else if (d === Ray.AWAY) {
|
|
343
|
-
_rayEx.set(xyz, xyz);
|
|
344
|
-
let d = _rayEx.hitTriangle(_v1, _v3, _v2, res, normal);
|
|
345
|
-
if (d === Ray.INSIDE) {
|
|
346
|
-
return -xyz.distance(res);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
if (d === Ray.AWAY) {
|
|
351
346
|
return -xyz.distance(res);
|
|
352
347
|
}
|
|
348
|
+
}
|
|
353
349
|
|
|
354
|
-
|
|
350
|
+
if (d === Ray.AWAY) {
|
|
351
|
+
return -xyz.distance(res);
|
|
355
352
|
}
|
|
356
353
|
|
|
357
|
-
res.copy(this.planet.ellipsoid.hitRay(_ray.origin, _ray.direction));
|
|
358
|
-
normal && normal.copy(xyz.normal());
|
|
359
354
|
return xyz.distance(res);
|
|
360
355
|
} else {
|
|
361
|
-
normal && normal.copy(xyz.normal());
|
|
362
356
|
return xyz.distance(this.planet.ellipsoid.hitRay(_ray.origin, _ray.direction));
|
|
363
357
|
}
|
|
364
358
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
7
|
import { LonLat } from "../LonLat.js";
|
|
8
|
-
import { DEGREES, EPS1, EPS12, EPS15, RADIANS } from "../math.js";
|
|
8
|
+
import { DEGREES, EPS1, EPS12, EPS15, RADIANS, zeroTwoPI } from "../math.js";
|
|
9
9
|
import { Vec3 } from "../math/Vec3.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -43,6 +43,18 @@ class Ellipsoid {
|
|
|
43
43
|
this._invRadii2 = new Vec3(1.0 / this._a2, 1.0 / this._b2, 1.0 / this._a2);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Returns angle between to bearin angles
|
|
48
|
+
* @param {number} a - First bearing angle
|
|
49
|
+
* @param {number} b - Second bearing angle
|
|
50
|
+
* @returns {number}
|
|
51
|
+
*/
|
|
52
|
+
static getAngleBetweenTwoBearings(a, b) {
|
|
53
|
+
a = zeroTwoPI(a);
|
|
54
|
+
b = zeroTwoPI(b);
|
|
55
|
+
return ((((a - b) % 360) + 360 + 180) % 360) - 180;
|
|
56
|
+
}
|
|
57
|
+
|
|
46
58
|
static getRelativeBearing(a, b) {
|
|
47
59
|
let a_y = Math.cos(a),
|
|
48
60
|
a_x = Math.sin(a),
|
|
@@ -283,9 +295,9 @@ class Ellipsoid {
|
|
|
283
295
|
}
|
|
284
296
|
|
|
285
297
|
/**
|
|
286
|
-
* Gets cartesian ECEF from Wgs84 geodetic
|
|
298
|
+
* Gets cartesian ECEF from Wgs84 geodetic coordinates.
|
|
287
299
|
* @public
|
|
288
|
-
* @param {LonLat} lonlat - Degrees geodetic
|
|
300
|
+
* @param {LonLat} lonlat - Degrees geodetic coordinates.
|
|
289
301
|
* @returns {Vec3} -
|
|
290
302
|
*/
|
|
291
303
|
lonLatToCartesian(lonlat) {
|
|
@@ -305,9 +317,9 @@ class Ellipsoid {
|
|
|
305
317
|
}
|
|
306
318
|
|
|
307
319
|
/**
|
|
308
|
-
* Gets cartesian ECEF from Wgs84 geodetic
|
|
320
|
+
* Gets cartesian ECEF from Wgs84 geodetic coordinates.
|
|
309
321
|
* @public
|
|
310
|
-
* @param {LonLat} lonlat - Degrees geodetic
|
|
322
|
+
* @param {LonLat} lonlat - Degrees geodetic coordinates.
|
|
311
323
|
* @param {Vec3} res - Output result.
|
|
312
324
|
* @returns {Vec3} -
|
|
313
325
|
*/
|
|
@@ -328,7 +340,7 @@ class Ellipsoid {
|
|
|
328
340
|
}
|
|
329
341
|
|
|
330
342
|
/**
|
|
331
|
-
* Gets cartesian ECEF from Wgs84 geodetic
|
|
343
|
+
* Gets cartesian ECEF from Wgs84 geodetic coordinates.
|
|
332
344
|
* @public
|
|
333
345
|
* @param {Number} lon - Longitude.
|
|
334
346
|
* @param {Number} lat - Latitude.
|
|
@@ -352,7 +364,7 @@ class Ellipsoid {
|
|
|
352
364
|
}
|
|
353
365
|
|
|
354
366
|
/**
|
|
355
|
-
* Gets Wgs84 geodetic
|
|
367
|
+
* Gets Wgs84 geodetic coordinates from cartesian ECEF.
|
|
356
368
|
* @public
|
|
357
369
|
* @param {Vec3} p - Cartesian coordinates.
|
|
358
370
|
* @returns {LonLat} -
|
|
@@ -409,13 +421,15 @@ class Ellipsoid {
|
|
|
409
421
|
return new Vec3(pX * m_X, pY * m_Y, pZ * m_Z);
|
|
410
422
|
}
|
|
411
423
|
|
|
424
|
+
/**
|
|
425
|
+
* Converts 3d cartesian coordinates to geodetic
|
|
426
|
+
* @param {Vec3} cart - Cartesian coordinates
|
|
427
|
+
* @returns {LonLat} - Geodetic coordinates
|
|
428
|
+
*/
|
|
412
429
|
cartesianToLonLat(cart) {
|
|
413
|
-
|
|
414
430
|
let p = this.projToSurface(cart);
|
|
415
|
-
|
|
416
431
|
let n = this.getSurfaceNormal3v(p),
|
|
417
432
|
h = cart.sub(p);
|
|
418
|
-
|
|
419
433
|
return new LonLat(
|
|
420
434
|
Math.atan2(n.x, n.z) * DEGREES,
|
|
421
435
|
Math.asin(n.y) * DEGREES,
|
|
@@ -423,10 +437,26 @@ class Ellipsoid {
|
|
|
423
437
|
);
|
|
424
438
|
}
|
|
425
439
|
|
|
440
|
+
/**
|
|
441
|
+
* Converts 3d cartesian coordinates to geodetic
|
|
442
|
+
* @param {Vec3} cart - Cartesian coordinates
|
|
443
|
+
* @param {LonLat} res - Link geodetic coordinates variable
|
|
444
|
+
* @returns {LonLat} - Geodetic coordinates
|
|
445
|
+
*/
|
|
446
|
+
cartesianToLonLatRes(cart, res) {
|
|
447
|
+
let p = this.projToSurface(cart);
|
|
448
|
+
let n = this.getSurfaceNormal3v(p),
|
|
449
|
+
h = cart.sub(p);
|
|
450
|
+
res.lon = Math.atan2(n.x, n.z) * DEGREES;
|
|
451
|
+
res.lat = Math.asin(n.y) * DEGREES;
|
|
452
|
+
res.height = Math.sign(h.dot(cart)) * h.length();
|
|
453
|
+
return res;
|
|
454
|
+
}
|
|
455
|
+
|
|
426
456
|
/**
|
|
427
457
|
* Gets ellipsoid surface normal.
|
|
428
458
|
* @public
|
|
429
|
-
* @param {Vec3} coord - Spatial
|
|
459
|
+
* @param {Vec3} coord - Spatial coordinates.
|
|
430
460
|
* @return {Vec3} -
|
|
431
461
|
*/
|
|
432
462
|
getSurfaceNormal3v(coord) {
|
package/src/og/entity/Entity.js
CHANGED
|
@@ -26,7 +26,7 @@ import { Strip } from "./Strip.js";
|
|
|
26
26
|
* @param {Object} [options] - Entity options:
|
|
27
27
|
* @param {string} [options.name] - A human readable name to display to users. It does not have to be unique.
|
|
28
28
|
* @param {Vec3|Array.<number>} [options.cartesian] - Spatial entities like billboard, label etc. cartesian position.
|
|
29
|
-
* @param {LonLat} [options.lonlat] - Geodetic
|
|
29
|
+
* @param {LonLat} [options.lonlat] - Geodetic coordinates for an entities like billboard, label etc.
|
|
30
30
|
* @param {boolean} [options.aground] - True for entities that have to be placed on the relief.
|
|
31
31
|
* @param {boolean} [options.visibility] - Entity visibility.
|
|
32
32
|
* @param {*} [options.billboard] - Billboard options(see {@link og.Billboard}).
|
|
@@ -86,7 +86,7 @@ class Entity {
|
|
|
86
86
|
this._cartesian = utils.createVector3(options.cartesian);
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* Geodetic entity
|
|
89
|
+
* Geodetic entity coordinates.
|
|
90
90
|
* @protected
|
|
91
91
|
* @type {LonLat}
|
|
92
92
|
*/
|
|
@@ -474,7 +474,7 @@ class Entity {
|
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
/**
|
|
477
|
-
* Returns
|
|
477
|
+
* Returns cartesian position.
|
|
478
478
|
* @public
|
|
479
479
|
* @returns {Vec3} -
|
|
480
480
|
*/
|
|
@@ -506,7 +506,7 @@ class EntityCollection {
|
|
|
506
506
|
}
|
|
507
507
|
|
|
508
508
|
/**
|
|
509
|
-
* Updates
|
|
509
|
+
* Updates coordinates all lonLat entities in collection after collecction attached to the planet node.
|
|
510
510
|
* @private
|
|
511
511
|
* @param {Ellipsoid} ellipsoid - Globe ellipsoid.
|
|
512
512
|
*/
|
|
@@ -590,7 +590,7 @@ class EntityCollection {
|
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
/**
|
|
593
|
-
* Removes all entities from
|
|
593
|
+
* Removes all entities from collection and clear handlers.
|
|
594
594
|
* @public
|
|
595
595
|
*/
|
|
596
596
|
clear() {
|
package/src/og/entity/Label.js
CHANGED
|
@@ -32,7 +32,7 @@ const STR2ALIGN = {
|
|
|
32
32
|
* @extends {BaseBillboard}
|
|
33
33
|
* @param {Object} [options] - Label options:
|
|
34
34
|
* @param {Vec3|Array.<number>} [options.position] - Billboard spatial position.
|
|
35
|
-
* @param {number} [options.rotation] - Screen angle
|
|
35
|
+
* @param {number} [options.rotation] - Screen angle rotation.
|
|
36
36
|
* @param {Vec4|string|Array.<number>} [options.color] - Billboard color.
|
|
37
37
|
* @param {Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector.
|
|
38
38
|
* @param {Vec3|Array.<number>} [options.offset] - Billboard center screen offset.
|
|
@@ -60,6 +60,8 @@ class Polyline {
|
|
|
60
60
|
*/
|
|
61
61
|
this.thickness = options.thickness || 1.5;
|
|
62
62
|
|
|
63
|
+
this._opacity = options.opacity != undefined ? options.opacity : 1.0;
|
|
64
|
+
|
|
63
65
|
/**
|
|
64
66
|
* Polyline RGBA color.
|
|
65
67
|
* @public
|
|
@@ -1708,7 +1710,7 @@ class Polyline {
|
|
|
1708
1710
|
* @param {number} opacity - Opacity.
|
|
1709
1711
|
*/
|
|
1710
1712
|
setOpacity(opacity) {
|
|
1711
|
-
this.
|
|
1713
|
+
this._opacity = opacity;
|
|
1712
1714
|
}
|
|
1713
1715
|
|
|
1714
1716
|
/**
|
|
@@ -2010,7 +2012,7 @@ class Polyline {
|
|
|
2010
2012
|
]);
|
|
2011
2013
|
gl.uniform2fv(shu.viewport, [r.handler.canvas.width, r.handler.canvas.height]);
|
|
2012
2014
|
gl.uniform1f(shu.thickness, this.thickness * 0.5);
|
|
2013
|
-
gl.uniform1f(shu.opacity, ec._fadingOpacity);
|
|
2015
|
+
gl.uniform1f(shu.opacity, this._opacity * ec._fadingOpacity);
|
|
2014
2016
|
|
|
2015
2017
|
gl.bindBuffer(gl.ARRAY_BUFFER, this._colorsBuffer);
|
|
2016
2018
|
gl.vertexAttribPointer(sha.color, this._colorsBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
package/src/og/index.js
CHANGED
|
@@ -34,6 +34,7 @@ import { Events } from './Events.js';
|
|
|
34
34
|
import { Extent } from './Extent.js';
|
|
35
35
|
import { LonLat } from './LonLat.js';
|
|
36
36
|
import { RenderNode } from './scene/RenderNode.js';
|
|
37
|
+
import { Planet } from './scene/Planet.js';
|
|
37
38
|
|
|
38
39
|
import { Popup } from './Popup.js';
|
|
39
40
|
|
|
@@ -45,22 +46,16 @@ import {
|
|
|
45
46
|
Wgs84QuadTreeStrategy
|
|
46
47
|
} from './quadTree/index.js';
|
|
47
48
|
|
|
48
|
-
import pkg from "../../package.json";
|
|
49
49
|
|
|
50
50
|
import { Object3d } from './Object3d.js';
|
|
51
51
|
const { Handler } = webgl, { Control } = control;
|
|
52
|
-
const { Layer, Vector, XYZ} = layer;
|
|
52
|
+
const { Layer, Vector, XYZ, CanvasTiles} = layer;
|
|
53
53
|
const {
|
|
54
54
|
EntityCollection,
|
|
55
55
|
Entity
|
|
56
56
|
} = entity;
|
|
57
57
|
|
|
58
|
-
const version = {
|
|
59
|
-
version: pkg.version
|
|
60
|
-
};
|
|
61
|
-
|
|
62
58
|
export {
|
|
63
|
-
version,
|
|
64
59
|
bv,
|
|
65
60
|
jd,
|
|
66
61
|
math,
|
|
@@ -70,6 +65,7 @@ export {
|
|
|
70
65
|
Layer,
|
|
71
66
|
XYZ,
|
|
72
67
|
Vector,
|
|
68
|
+
CanvasTiles,
|
|
73
69
|
layer,
|
|
74
70
|
terrain,
|
|
75
71
|
Control,
|
|
@@ -78,6 +74,7 @@ export {
|
|
|
78
74
|
wgs84,
|
|
79
75
|
Camera,
|
|
80
76
|
Ellipsoid,
|
|
77
|
+
Planet,
|
|
81
78
|
PlanetCamera,
|
|
82
79
|
Globe,
|
|
83
80
|
LightSource,
|
|
@@ -51,6 +51,7 @@ class CanvasTiles extends Layer {
|
|
|
51
51
|
this.animated = options.animated || false;
|
|
52
52
|
|
|
53
53
|
this.minNativeZoom = options.minNativeZoom || 0;
|
|
54
|
+
this.maxNativeZoom = options.maxNativeZoom || 100;
|
|
54
55
|
/**
|
|
55
56
|
* Current creating tiles couter.
|
|
56
57
|
* @protected
|
|
@@ -176,19 +177,21 @@ class CanvasTiles extends Layer {
|
|
|
176
177
|
that.events.dispatch(e, material);
|
|
177
178
|
}
|
|
178
179
|
requestAnimationFrame(() => {
|
|
179
|
-
that.drawTile(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
180
|
+
that.drawTile(
|
|
181
|
+
material,
|
|
182
|
+
/**
|
|
183
|
+
* Apply canvas.
|
|
184
|
+
* @callback applyCanvasCallback
|
|
185
|
+
* @param {Object} canvas -
|
|
186
|
+
*/
|
|
187
|
+
function (canvas) {
|
|
188
|
+
that._counter--;
|
|
189
|
+
CanvasTiles.__requestsCounter--;
|
|
190
|
+
if (material.isLoading) {
|
|
191
|
+
material.applyImage(canvas);
|
|
192
|
+
}
|
|
193
|
+
that._dequeueRequest();
|
|
194
|
+
});
|
|
192
195
|
});
|
|
193
196
|
} else {
|
|
194
197
|
material.textureNotExists();
|
|
@@ -239,6 +242,12 @@ class CanvasTiles extends Layer {
|
|
|
239
242
|
|
|
240
243
|
applyMaterial(material) {
|
|
241
244
|
if (material.isReady) {
|
|
245
|
+
|
|
246
|
+
// IMPORTANT!
|
|
247
|
+
// Animated doesn't work withMaxNativeZoom
|
|
248
|
+
// It could be fixed with call drawTile method only for parent
|
|
249
|
+
// material (which is rendered on the current segment material),
|
|
250
|
+
// just for one renderer frame
|
|
242
251
|
if (material.layer.animated) {
|
|
243
252
|
requestAnimationFrame(() => {
|
|
244
253
|
this.drawTile(material, function (canvas) {
|
|
@@ -246,15 +255,19 @@ class CanvasTiles extends Layer {
|
|
|
246
255
|
});
|
|
247
256
|
});
|
|
248
257
|
}
|
|
249
|
-
|
|
258
|
+
|
|
259
|
+
return material.texOffset;
|
|
260
|
+
|
|
250
261
|
} else if (material.segment.tileZoom < this.minNativeZoom) {
|
|
251
262
|
material.textureNotExists();
|
|
252
263
|
} else {
|
|
253
264
|
|
|
254
265
|
let segment = material.segment;
|
|
255
|
-
let pn = segment.node,
|
|
266
|
+
let pn = segment.node,
|
|
267
|
+
parentTextureExists = false;
|
|
268
|
+
let maxNativeZoom = material.layer.maxNativeZoom;
|
|
256
269
|
|
|
257
|
-
if (segment.passReady && !material.isLoading) {
|
|
270
|
+
if (segment.passReady && !material.isLoading && segment.tileZoom <= maxNativeZoom) {
|
|
258
271
|
this.loadMaterial(material);
|
|
259
272
|
}
|
|
260
273
|
|
|
@@ -263,14 +276,41 @@ class CanvasTiles extends Layer {
|
|
|
263
276
|
while (pn.parentNode) {
|
|
264
277
|
pn = pn.parentNode;
|
|
265
278
|
psegm = pn.segment.materials[mId];
|
|
266
|
-
if (psegm && psegm.
|
|
267
|
-
|
|
279
|
+
if (psegm && psegm.textureExists) {
|
|
280
|
+
parentTextureExists = true;
|
|
268
281
|
break;
|
|
269
282
|
}
|
|
270
283
|
}
|
|
271
284
|
|
|
272
|
-
if (
|
|
285
|
+
if (segment.passReady) {
|
|
286
|
+
if (pn.segment.tileZoom === maxNativeZoom) {
|
|
287
|
+
if (segment.tileZoom > maxNativeZoom) {
|
|
288
|
+
material.textureNotExists();
|
|
289
|
+
}
|
|
290
|
+
} else if (pn.segment.tileZoom < maxNativeZoom) {
|
|
291
|
+
|
|
292
|
+
let pn = segment.node;
|
|
293
|
+
while (pn.segment.tileZoom > maxNativeZoom) {
|
|
294
|
+
pn = pn.parentNode;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
let pnm = pn.segment.materials[mId];
|
|
298
|
+
if (pnm) {
|
|
299
|
+
!pnm.isLoading && !pnm.isReady && this.loadMaterial(pnm);
|
|
300
|
+
} else {
|
|
301
|
+
pnm = pn.segment.materials[material.layer._id] = material.layer.createMaterial(
|
|
302
|
+
pn.segment
|
|
303
|
+
);
|
|
304
|
+
this.loadMaterial(pnm);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (parentTextureExists) {
|
|
273
310
|
|
|
311
|
+
//
|
|
312
|
+
// Animated doesn't work withMaxNativeZoom
|
|
313
|
+
//
|
|
274
314
|
if (material.layer.animated) {
|
|
275
315
|
requestAnimationFrame(() => {
|
|
276
316
|
this.drawTile(material, function (canvas) {
|
|
@@ -281,20 +321,27 @@ class CanvasTiles extends Layer {
|
|
|
281
321
|
|
|
282
322
|
material.appliedNodeId = pn.nodeId;
|
|
283
323
|
material.texture = psegm.texture;
|
|
284
|
-
|
|
285
324
|
let dZ2 = 1.0 / (2 << (segment.tileZoom - pn.segment.tileZoom - 1));
|
|
286
|
-
|
|
325
|
+
material.texOffset[0] = segment.tileX * dZ2 - pn.segment.tileX;
|
|
326
|
+
material.texOffset[1] = segment.tileY * dZ2 - pn.segment.tileY;
|
|
327
|
+
material.texOffset[2] = dZ2;
|
|
328
|
+
material.texOffset[3] = dZ2;
|
|
287
329
|
} else {
|
|
288
330
|
material.texture = segment.planet.transparentTexture;
|
|
289
|
-
|
|
331
|
+
material.texOffset[0] = 0.0;
|
|
332
|
+
material.texOffset[1] = 0.0;
|
|
333
|
+
material.texOffset[2] = 1.0;
|
|
334
|
+
material.texOffset[3] = 1.0;
|
|
290
335
|
}
|
|
291
336
|
}
|
|
337
|
+
|
|
338
|
+
return material.texOffset;
|
|
292
339
|
}
|
|
293
340
|
|
|
294
341
|
clearMaterial(material) {
|
|
295
342
|
if (material.isReady) {
|
|
296
343
|
material.isReady = false;
|
|
297
|
-
if (material.texture && !material.texture.default) {
|
|
344
|
+
if (material.textureExists && material.texture && !material.texture.default) {
|
|
298
345
|
material.segment.handler.gl.deleteTexture(material.texture);
|
|
299
346
|
material.texture = null;
|
|
300
347
|
}
|