@openglobus/og 0.17.0 → 0.17.1
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/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 +1 -1
- package/src/og/Events.js +2 -2
- package/src/og/Globe.js +1 -1
- package/src/og/ImageCanvas.js +2 -2
- package/src/og/LonLat.js +1 -1
- package/src/og/Object3d.js +1 -1
- package/src/og/QueueArray.js +1 -1
- package/src/og/Stack.js +1 -1
- package/src/og/astro/earth.js +3 -3
- package/src/og/camera/Frustum.js +4 -4
- package/src/og/camera/PlanetCamera.js +7 -7
- package/src/og/cons.js +1 -1
- package/src/og/control/DebugInfo.js +3 -3
- package/src/og/control/EarthNavigation.js +6 -13
- package/src/og/control/Lighting.js +1 -1
- package/src/og/control/MouseNavigation.js +1 -1
- package/src/og/control/visibleExtent/Segment.js +2 -2
- package/src/og/ellipsoid/Ellipsoid.js +31 -50
- package/src/og/entity/BillboardHandler.js +3 -3
- package/src/og/entity/EntityCollection.js +7 -7
- package/src/og/entity/GeoObject.js +6 -4
- package/src/og/entity/GeoObjectHandler.js +30 -20
- package/src/og/entity/GeometryHandler.js +15 -15
- package/src/og/entity/LabelHandler.js +10 -10
- package/src/og/entity/LabelWorker.js +1 -1
- package/src/og/entity/PointCloud.js +2 -2
- package/src/og/entity/PointCloudHandler.js +2 -2
- package/src/og/entity/Polyline.js +11 -11
- package/src/og/entity/PolylineHandler.js +2 -2
- package/src/og/entity/RayHandler.js +2 -2
- package/src/og/entity/StripHandler.js +2 -2
- package/src/og/input/KeyboardHandler.js +6 -6
- package/src/og/layer/BaseGeoImage.js +1 -1
- package/src/og/layer/CanvasTiles.js +1 -1
- package/src/og/layer/Vector.js +2 -2
- package/src/og/math/Vec3.js +5 -0
- package/src/og/math.js +3 -3
- package/src/og/mercator.js +1 -1
- package/src/og/quadTree/Node.js +15 -14
- package/src/og/renderer/Renderer.js +5 -5
- package/src/og/scene/BaseNode.js +1 -1
- package/src/og/scene/Planet.js +16 -21
- package/src/og/scene/RenderNode.js +9 -9
- package/src/og/segment/Segment.js +2 -2
- package/src/og/segment/SegmentLonLat.js +1 -1
- package/src/og/segment/segmentHelper.js +12 -12
- package/src/og/shaders/atmos.js +1 -1
- package/src/og/utils/GeoImageCreator.js +1 -1
- package/src/og/utils/NormalMapCreator.js +3 -3
- package/src/og/utils/PlainSegmentWorker.js +9 -9
- package/src/og/utils/TerrainWorker.js +2 -2
- package/src/og/utils/TextureAtlas.js +1 -1
- package/src/og/utils/earcut.js +8 -8
- package/src/og/utils/shared.js +10 -10
- package/src/og/webgl/Framebuffer.js +2 -2
- package/src/og/webgl/Handler.js +1 -1
- package/src/og/webgl/Multisample.js +2 -2
- package/src/og/webgl/Program.js +4 -4
- package/types/ImageCanvas.d.ts +1 -1
- package/types/ellipsoid/Ellipsoid.d.ts +3 -1
- package/types/entity/GeoObject.d.ts +1 -2
- package/types/math/Vec3.d.ts +2 -0
- package/types/scene/Planet.d.ts +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openglobus/og",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
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"
|
package/src/og/Events.js
CHANGED
|
@@ -57,7 +57,7 @@ class Events {
|
|
|
57
57
|
* @param {Array.<string>} eventNames - Specified event names list.
|
|
58
58
|
*/
|
|
59
59
|
registerNames(eventNames) {
|
|
60
|
-
for (
|
|
60
|
+
for (let i = 0; i < eventNames.length; i++) {
|
|
61
61
|
this[eventNames[i]] = { active: true, handlers: [] };
|
|
62
62
|
this._eventNames.push(eventNames[i]);
|
|
63
63
|
}
|
|
@@ -172,7 +172,7 @@ class Events {
|
|
|
172
172
|
* @public
|
|
173
173
|
*/
|
|
174
174
|
clear() {
|
|
175
|
-
for (
|
|
175
|
+
for (let i = 0; i < this._eventNames.length; i++) {
|
|
176
176
|
var e = this[this._eventNames[i]];
|
|
177
177
|
e.handlers.length = 0;
|
|
178
178
|
e.handlers = [];
|
package/src/og/Globe.js
CHANGED
package/src/og/ImageCanvas.js
CHANGED
|
@@ -54,7 +54,7 @@ class ImageCanvas {
|
|
|
54
54
|
fillEmpty() {
|
|
55
55
|
var imgd = this._context.getImageData(0, 0, this._canvas.width, this._canvas.height);
|
|
56
56
|
var pixels = imgd.data;
|
|
57
|
-
for (
|
|
57
|
+
for (let i = 0, n = pixels.length; i < n; i += 4) {
|
|
58
58
|
pixels[i] = pixels[i + 1] = pixels[i + 2] = pixels[i + 3] = 0;
|
|
59
59
|
}
|
|
60
60
|
this._context.putImageData(imgd, 0, 0);
|
|
@@ -64,7 +64,7 @@ class ImageCanvas {
|
|
|
64
64
|
* Fills canvas RGBA with color.
|
|
65
65
|
* @public
|
|
66
66
|
*/
|
|
67
|
-
fill(
|
|
67
|
+
fill(color) {
|
|
68
68
|
this._context.fillStyle = color
|
|
69
69
|
this._context.fill()
|
|
70
70
|
}
|
package/src/og/LonLat.js
CHANGED
package/src/og/Object3d.js
CHANGED
|
@@ -140,7 +140,7 @@ class Object3d {
|
|
|
140
140
|
static getNormals(vertices) {
|
|
141
141
|
let res = new Array(vertices.length);
|
|
142
142
|
|
|
143
|
-
for (
|
|
143
|
+
for (let i = 0; i < vertices.length; i += 9) {
|
|
144
144
|
|
|
145
145
|
let t03 = i, t13 = i + 3, t23 = i + 6, v0_x = vertices[t03], v0_y = vertices[t03 + 1],
|
|
146
146
|
v0_z = vertices[t03 + 2], v1_x = vertices[t13], v1_y = vertices[t13 + 1], v1_z = vertices[t13 + 2],
|
package/src/og/QueueArray.js
CHANGED
package/src/og/Stack.js
CHANGED
package/src/og/astro/earth.js
CHANGED
|
@@ -98,11 +98,11 @@ export function getSunPosition(jDate) {
|
|
|
98
98
|
|
|
99
99
|
var theta = math.TWO_PI * ((d * 24.0) / 23.9344694 - 259.853 / 360.0); // Siderial spin time
|
|
100
100
|
|
|
101
|
-
return Quat.
|
|
101
|
+
return Quat.zRotation(-theta).mulVec3(
|
|
102
102
|
new Vec3(
|
|
103
|
+
-xequat * astro.AU_TO_METERS,
|
|
103
104
|
-yequat * astro.AU_TO_METERS,
|
|
104
|
-
zequat * astro.AU_TO_METERS
|
|
105
|
-
-xequat * astro.AU_TO_METERS
|
|
105
|
+
zequat * astro.AU_TO_METERS
|
|
106
106
|
)
|
|
107
107
|
);
|
|
108
108
|
|
package/src/og/camera/Frustum.js
CHANGED
|
@@ -25,7 +25,7 @@ class Frustum {
|
|
|
25
25
|
* @type {Array.<Array.<number>>}
|
|
26
26
|
*/
|
|
27
27
|
this._f = new Array(6);
|
|
28
|
-
for (
|
|
28
|
+
for (let i = 0; i < 6; i++) {
|
|
29
29
|
this._f[i] = new Array(4);
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -224,7 +224,7 @@ class Frustum {
|
|
|
224
224
|
*/
|
|
225
225
|
containsPoint(point) {
|
|
226
226
|
var d;
|
|
227
|
-
for (
|
|
227
|
+
for (let p = 0; p < 6; p++) {
|
|
228
228
|
d = point.dotArr(this._f[p]) + this._f[p][3];
|
|
229
229
|
if (d <= 0) {
|
|
230
230
|
return false;
|
|
@@ -304,11 +304,11 @@ class Frustum {
|
|
|
304
304
|
cout,
|
|
305
305
|
cin;
|
|
306
306
|
|
|
307
|
-
for (
|
|
307
|
+
for (let i = 0; i < 6; i++) {
|
|
308
308
|
cout = 0;
|
|
309
309
|
cin = 0;
|
|
310
310
|
|
|
311
|
-
for (
|
|
311
|
+
for (let k = 0; k < 8 && (cin === 0 || cout === 0); k++) {
|
|
312
312
|
var d = box.vertices[k].dotArr(this._f[i]) + this._f[i][3];
|
|
313
313
|
if (d < 0) {
|
|
314
314
|
cout++;
|
|
@@ -184,7 +184,7 @@ class PlanetCamera extends Camera {
|
|
|
184
184
|
var el = this.planet.ellipsoid;
|
|
185
185
|
var newEye = el.lonLatToCartesian(this._lonLat);
|
|
186
186
|
var newLook = lookLonLat ? el.lonLatToCartesian(lookLonLat) : Vec3.ZERO;
|
|
187
|
-
this.set(newEye, newLook, up || Vec3.
|
|
187
|
+
this.set(newEye, newLook, up || Vec3.NORTH);
|
|
188
188
|
this.update();
|
|
189
189
|
}
|
|
190
190
|
|
|
@@ -249,7 +249,7 @@ class PlanetCamera extends Camera {
|
|
|
249
249
|
southWest.subA(center);
|
|
250
250
|
|
|
251
251
|
var direction = center.normal(); // ellipsoid.getSurfaceNormal(center).negate().normalize();
|
|
252
|
-
var right = direction.cross(Vec3.
|
|
252
|
+
var right = direction.cross(Vec3.NORTH).normalize();
|
|
253
253
|
var up = right.cross(direction).normalize();
|
|
254
254
|
|
|
255
255
|
var _h = Math.max(
|
|
@@ -283,7 +283,7 @@ class PlanetCamera extends Camera {
|
|
|
283
283
|
*/
|
|
284
284
|
viewExtent(extent, height) {
|
|
285
285
|
this.stopFlying();
|
|
286
|
-
this.set(this.getExtentPosition(extent, height), Vec3.ZERO, Vec3.
|
|
286
|
+
this.set(this.getExtentPosition(extent, height), Vec3.ZERO, Vec3.NORTH);
|
|
287
287
|
this.update();
|
|
288
288
|
}
|
|
289
289
|
|
|
@@ -362,7 +362,7 @@ class PlanetCamera extends Camera {
|
|
|
362
362
|
* @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
|
|
363
363
|
* @param [frameCallback]
|
|
364
364
|
*/
|
|
365
|
-
flyCartesian(cartesian, look = Vec3.ZERO, up = Vec3.
|
|
365
|
+
flyCartesian(cartesian, look = Vec3.ZERO, up = Vec3.NORTH, ampl = 1.0, completeCallback = () => {
|
|
366
366
|
}, startCallback = () => {
|
|
367
367
|
}, frameCallback = () => {
|
|
368
368
|
}) {
|
|
@@ -370,7 +370,7 @@ class PlanetCamera extends Camera {
|
|
|
370
370
|
this.stopFlying();
|
|
371
371
|
|
|
372
372
|
look = look || Vec3.ZERO;
|
|
373
|
-
up = up || Vec3.
|
|
373
|
+
up = up || Vec3.NORTH;
|
|
374
374
|
|
|
375
375
|
this._completeCallback = completeCallback;
|
|
376
376
|
|
|
@@ -416,7 +416,7 @@ class PlanetCamera extends Camera {
|
|
|
416
416
|
var zero = Vec3.ZERO;
|
|
417
417
|
|
|
418
418
|
// camera path and orientations calculation
|
|
419
|
-
for (
|
|
419
|
+
for (let i = 0; i <= this._numFrames; i++) {
|
|
420
420
|
var d = 1 - i / this._numFrames;
|
|
421
421
|
d = d * d * (3 - 2 * d);
|
|
422
422
|
d *= d;
|
|
@@ -640,7 +640,7 @@ class PlanetCamera extends Camera {
|
|
|
640
640
|
this.slope >= 0.97 ? this.getUp() : this.getForward(),
|
|
641
641
|
u
|
|
642
642
|
).normalize(),
|
|
643
|
-
n = Vec3.proj_b_to_plane(Vec3.
|
|
643
|
+
n = Vec3.proj_b_to_plane(Vec3.NORTH, u).normalize();
|
|
644
644
|
let res = Math.sign(u.dot(f.cross(n))) * Math.acos(f.dot(n)) * math.DEGREES;
|
|
645
645
|
if (res < 0.0) {
|
|
646
646
|
return 360.0 + res;
|
package/src/og/cons.js
CHANGED
|
@@ -90,7 +90,7 @@ class DebugInfo extends Control {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
addWatches(watches) {
|
|
93
|
-
for (
|
|
93
|
+
for (let i = 0; i < watches.length; i++) {
|
|
94
94
|
this.addWatch(watches[i]);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -124,7 +124,7 @@ class DebugInfo extends Control {
|
|
|
124
124
|
|
|
125
125
|
var temp = this._watch;
|
|
126
126
|
this._watch = [];
|
|
127
|
-
for (
|
|
127
|
+
for (let i = 0; i < temp.length; i++) {
|
|
128
128
|
this.addWatch(temp[i]);
|
|
129
129
|
}
|
|
130
130
|
this._dialog.container.appendChild(this.el);
|
|
@@ -245,7 +245,7 @@ class DebugInfo extends Control {
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
_frame() {
|
|
248
|
-
for (
|
|
248
|
+
for (let i = 0; i < this._watch.length; i++) {
|
|
249
249
|
var w = this._watch[i];
|
|
250
250
|
w.valEl.innerHTML = w.frame ? w.frame() : "";
|
|
251
251
|
}
|
|
@@ -153,12 +153,12 @@ class EarthNavigation extends Control {
|
|
|
153
153
|
var rot = this._hRot.mul(this._vRot);
|
|
154
154
|
|
|
155
155
|
var state = this.positionState[this.currState];
|
|
156
|
-
var lim = rot.mulVec3(cam.eye).normal().dot(Vec3.
|
|
156
|
+
var lim = rot.mulVec3(cam.eye).normal().dot(Vec3.NORTH);
|
|
157
157
|
if (lim > state.max || lim < state.min) {
|
|
158
158
|
rot = Quat.yRotation(rot.getYaw());
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, Vec3.
|
|
161
|
+
cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, Vec3.NORTH);
|
|
162
162
|
cam.update();
|
|
163
163
|
}
|
|
164
164
|
}
|
|
@@ -204,7 +204,6 @@ class EarthNavigation extends Control {
|
|
|
204
204
|
let rot = this._vRot = Quat.axisAngleToQuat(cam._u, this._a);
|
|
205
205
|
|
|
206
206
|
cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, rot.mulVec3(cam.getUp()));
|
|
207
|
-
//cam.update();
|
|
208
207
|
|
|
209
208
|
this._hRot = Quat.getRotationBetweenVectors(
|
|
210
209
|
new Vec3(targetPoint.x, 0.0, targetPoint.z).normal(),
|
|
@@ -213,14 +212,8 @@ class EarthNavigation extends Control {
|
|
|
213
212
|
|
|
214
213
|
rot = this._hRot;
|
|
215
214
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
//if (lim > state.max || lim < state.min) {
|
|
220
|
-
// rot = Quat.yRotation(rot.getYaw());
|
|
221
|
-
cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, rot.mulVec3(cam.getUp()));
|
|
222
|
-
cam.update();
|
|
223
|
-
//}
|
|
215
|
+
cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, rot.mulVec3(cam.getUp()));
|
|
216
|
+
cam.update();
|
|
224
217
|
}
|
|
225
218
|
} else {
|
|
226
219
|
this.scaleRot = 0;
|
|
@@ -240,7 +233,7 @@ class EarthNavigation extends Control {
|
|
|
240
233
|
this._vRot = Quat.axisAngleToQuat(cam._u, this._a);
|
|
241
234
|
var rot = this._vRot.mul(this._hRot);
|
|
242
235
|
|
|
243
|
-
var lim = rot.mulVec3(cam.eye).normal().dot(Vec3.
|
|
236
|
+
var lim = rot.mulVec3(cam.eye).normal().dot(Vec3.NORTH);
|
|
244
237
|
|
|
245
238
|
var state = this.positionState[this.currState];
|
|
246
239
|
|
|
@@ -256,7 +249,7 @@ class EarthNavigation extends Control {
|
|
|
256
249
|
this.scaleRot = 0;
|
|
257
250
|
}
|
|
258
251
|
|
|
259
|
-
cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, Vec3.
|
|
252
|
+
cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, Vec3.NORTH);
|
|
260
253
|
cam.update();
|
|
261
254
|
}
|
|
262
255
|
}
|
|
@@ -465,7 +465,7 @@ class Lighting extends Control {
|
|
|
465
465
|
|
|
466
466
|
_fetchLayers() {
|
|
467
467
|
if (this.planet) {
|
|
468
|
-
for (
|
|
468
|
+
for (let i = 0; i < this.planet.layers.length; i++) {
|
|
469
469
|
this._onLayerAdd(this.planet.layers[i]);
|
|
470
470
|
}
|
|
471
471
|
}
|
|
@@ -88,7 +88,7 @@ class MouseNavigation extends Control {
|
|
|
88
88
|
eyeArr = [];
|
|
89
89
|
|
|
90
90
|
var breaked = false;
|
|
91
|
-
for (
|
|
91
|
+
for (let i = 0; i < stepsCount; i++) {
|
|
92
92
|
eye.addA(scaled_n);
|
|
93
93
|
var b = new Ray(eye, dir).hitSphere(grabbedSpheroid);
|
|
94
94
|
eyeArr[i] = eye.clone();
|
|
@@ -861,7 +861,7 @@ class Segment {
|
|
|
861
861
|
*/
|
|
862
862
|
deleteMaterials() {
|
|
863
863
|
var m = this.materials;
|
|
864
|
-
for (
|
|
864
|
+
for (let i = 0; i < m.length; i++) {
|
|
865
865
|
var mi = m[i];
|
|
866
866
|
if (mi) {
|
|
867
867
|
mi.clear();
|
|
@@ -1368,7 +1368,7 @@ class Segment {
|
|
|
1368
1368
|
nmVertsLow = this.normalMapVerticesLow,
|
|
1369
1369
|
nmNorms = this.normalMapNormals;
|
|
1370
1370
|
|
|
1371
|
-
for (
|
|
1371
|
+
for (let k = 0; k < gsgs; k++) {
|
|
1372
1372
|
var j = k % gs,
|
|
1373
1373
|
i = ~~(k / gs);
|
|
1374
1374
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { LonLat } from "../LonLat.js";
|
|
4
4
|
import { DEGREES, EPS1, EPS12, EPS15, RADIANS, zeroTwoPI } from "../math.js";
|
|
5
5
|
import { Vec3 } from "../math/Vec3.js";
|
|
6
|
+
import { Quat } from "../math/Quat.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Class represents a plant ellipsoid.
|
|
@@ -33,10 +34,10 @@ class Ellipsoid {
|
|
|
33
34
|
this._k = qa2b2 / polarSize;
|
|
34
35
|
this._k2 = this._k * this._k;
|
|
35
36
|
|
|
36
|
-
this._radii = new Vec3(equatorialSize,
|
|
37
|
-
this._radii2 = new Vec3(this._a2, this.
|
|
38
|
-
this._invRadii = new Vec3(1.0 / equatorialSize, 1.0 /
|
|
39
|
-
this._invRadii2 = new Vec3(1.0 / this._a2, 1.0 / this.
|
|
37
|
+
this._radii = new Vec3(equatorialSize, equatorialSize, polarSize);
|
|
38
|
+
this._radii2 = new Vec3(this._a2, this._a2, this._b2);
|
|
39
|
+
this._invRadii = new Vec3(1.0 / equatorialSize, 1.0 / equatorialSize, 1.0 / polarSize);
|
|
40
|
+
this._invRadii2 = new Vec3(1.0 / this._a2, 1.0 / this._a2, 1.0 / this._b2);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
/**
|
|
@@ -120,19 +121,7 @@ class Ellipsoid {
|
|
|
120
121
|
* @returns {Vec3} -
|
|
121
122
|
*/
|
|
122
123
|
lonLatToCartesian(lonlat) {
|
|
123
|
-
|
|
124
|
-
lonrad = RADIANS * lonlat.lon;
|
|
125
|
-
|
|
126
|
-
var slt = Math.sin(latrad);
|
|
127
|
-
|
|
128
|
-
var N = this._a / Math.sqrt(1.0 - this._e2 * slt * slt);
|
|
129
|
-
var nc = (N + lonlat.height) * Math.cos(latrad);
|
|
130
|
-
|
|
131
|
-
return new Vec3(
|
|
132
|
-
nc * Math.sin(lonrad),
|
|
133
|
-
(N * (1.0 - this._e2) + lonlat.height) * slt,
|
|
134
|
-
nc * Math.cos(lonrad)
|
|
135
|
-
);
|
|
124
|
+
return this.geodeticToCartesian(lonlat.lon, lonlat.lat, lonlat.height);
|
|
136
125
|
}
|
|
137
126
|
|
|
138
127
|
/**
|
|
@@ -143,19 +132,7 @@ class Ellipsoid {
|
|
|
143
132
|
* @returns {Vec3} -
|
|
144
133
|
*/
|
|
145
134
|
lonLatToCartesianRes(lonlat, res) {
|
|
146
|
-
|
|
147
|
-
lonrad = RADIANS * lonlat.lon;
|
|
148
|
-
|
|
149
|
-
var slt = Math.sin(latrad);
|
|
150
|
-
|
|
151
|
-
var N = this._a / Math.sqrt(1.0 - this._e2 * slt * slt);
|
|
152
|
-
var nc = (N + lonlat.height) * Math.cos(latrad);
|
|
153
|
-
|
|
154
|
-
res.x = nc * Math.sin(lonrad);
|
|
155
|
-
res.y = (N * (1.0 - this._e2) + lonlat.height) * slt;
|
|
156
|
-
res.z = nc * Math.cos(lonrad);
|
|
157
|
-
|
|
158
|
-
return res;
|
|
135
|
+
return this.geodeticToCartesian(lonlat.lon, lonlat.lat, lonlat.height, res);
|
|
159
136
|
}
|
|
160
137
|
|
|
161
138
|
/**
|
|
@@ -166,20 +143,22 @@ class Ellipsoid {
|
|
|
166
143
|
* @param {Number} height - Height.
|
|
167
144
|
* @returns {Vec3} -
|
|
168
145
|
*/
|
|
169
|
-
geodeticToCartesian(lon, lat, height = 0) {
|
|
170
|
-
|
|
146
|
+
geodeticToCartesian(lon, lat, height = 0, res) {
|
|
147
|
+
res = res || new Vec3();
|
|
148
|
+
|
|
149
|
+
let latrad = RADIANS * lat,
|
|
171
150
|
lonrad = RADIANS * lon;
|
|
172
151
|
|
|
173
|
-
|
|
152
|
+
let slt = Math.sin(latrad);
|
|
174
153
|
|
|
175
|
-
|
|
176
|
-
|
|
154
|
+
let N = this._a / Math.sqrt(1 - this._e2 * slt * slt);
|
|
155
|
+
let nc = (N + height) * Math.cos(latrad);
|
|
177
156
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
157
|
+
res.x = nc * Math.cos(lonrad);
|
|
158
|
+
res.y = nc * Math.sin(lonrad);
|
|
159
|
+
res.z = (N * (1 - this._e2) + height) * slt;
|
|
160
|
+
|
|
161
|
+
return res;
|
|
183
162
|
}
|
|
184
163
|
|
|
185
164
|
/**
|
|
@@ -248,14 +227,7 @@ class Ellipsoid {
|
|
|
248
227
|
* @returns {LonLat} - Geodetic coordinates
|
|
249
228
|
*/
|
|
250
229
|
cartesianToLonLat(cart) {
|
|
251
|
-
|
|
252
|
-
let n = this.getSurfaceNormal3v(p),
|
|
253
|
-
h = cart.sub(p);
|
|
254
|
-
return new LonLat(
|
|
255
|
-
Math.atan2(n.x, n.z) * DEGREES,
|
|
256
|
-
Math.asin(n.y) * DEGREES,
|
|
257
|
-
Math.sign(h.dot(cart)) * h.length()
|
|
258
|
-
);
|
|
230
|
+
return this.cartesianToLonLatRes(cart);
|
|
259
231
|
}
|
|
260
232
|
|
|
261
233
|
/**
|
|
@@ -265,12 +237,15 @@ class Ellipsoid {
|
|
|
265
237
|
* @returns {LonLat} - Geodetic coordinates
|
|
266
238
|
*/
|
|
267
239
|
cartesianToLonLatRes(cart, res) {
|
|
240
|
+
res = res || new LonLat();
|
|
268
241
|
let p = this.projToSurface(cart);
|
|
269
242
|
let n = this.getSurfaceNormal3v(p),
|
|
270
243
|
h = cart.sub(p);
|
|
271
|
-
|
|
272
|
-
res.
|
|
244
|
+
|
|
245
|
+
res.lon = Math.atan2(n.y, n.x) * DEGREES;
|
|
246
|
+
res.lat = Math.asin(n.z) * DEGREES;
|
|
273
247
|
res.height = Math.sign(h.dot(cart)) * h.length();
|
|
248
|
+
|
|
274
249
|
return res;
|
|
275
250
|
}
|
|
276
251
|
|
|
@@ -495,6 +470,12 @@ class Ellipsoid {
|
|
|
495
470
|
}
|
|
496
471
|
}
|
|
497
472
|
|
|
473
|
+
getNorthFrameRotation(cartesian) {
|
|
474
|
+
let n = this.getSurfaceNormal3v(cartesian);
|
|
475
|
+
let t = Vec3.proj_b_to_plane(Vec3.NORTH, n);
|
|
476
|
+
return Quat.getLookRotation(t, n);
|
|
477
|
+
}
|
|
478
|
+
|
|
498
479
|
/**
|
|
499
480
|
* @todo this is not precise function, needs to be replaced or removed
|
|
500
481
|
* @param lonLat1
|
|
@@ -91,7 +91,7 @@ class BillboardHandler {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
static concArr(dest, curr) {
|
|
94
|
-
for (
|
|
94
|
+
for (let i = 0; i < curr.length; i++) {
|
|
95
95
|
dest.push(curr[i]);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -463,7 +463,7 @@ class BillboardHandler {
|
|
|
463
463
|
|
|
464
464
|
reindexBillbordsArray(startIndex) {
|
|
465
465
|
var b = this._billboards;
|
|
466
|
-
for (
|
|
466
|
+
for (let i = startIndex; i < b.length; i++) {
|
|
467
467
|
b[i]._handlerIndex = i;
|
|
468
468
|
}
|
|
469
469
|
}
|
|
@@ -866,7 +866,7 @@ class BillboardHandler {
|
|
|
866
866
|
var bc = this._entityCollection;
|
|
867
867
|
if (bc && this._renderer) {
|
|
868
868
|
var ta = this._renderer.billboardsTextureAtlas;
|
|
869
|
-
for (
|
|
869
|
+
for (let i = 0; i < this._billboards.length; i++) {
|
|
870
870
|
var bi = this._billboards[i];
|
|
871
871
|
var img = bi._image;
|
|
872
872
|
if (img) {
|
|
@@ -303,7 +303,7 @@ class EntityCollection {
|
|
|
303
303
|
|
|
304
304
|
this.events.dispatch(this.events.entityadd, entity);
|
|
305
305
|
|
|
306
|
-
for (
|
|
306
|
+
for (let i = 0; i < entity.childrenNodes.length; i++) {
|
|
307
307
|
entity.childrenNodes[i]._entityCollection = this;
|
|
308
308
|
entity.childrenNodes[i]._entityCollectionIndex = entity._entityCollectionIndex;
|
|
309
309
|
entity.childrenNodes[i]._pickingColor = entity._pickingColor;
|
|
@@ -386,7 +386,7 @@ class EntityCollection {
|
|
|
386
386
|
// geoObject
|
|
387
387
|
entity.geoObject && this.geoObjectHandler.remove(entity.geoObject);
|
|
388
388
|
|
|
389
|
-
for (
|
|
389
|
+
for (let i = 0; i < entity.childrenNodes.length; i++) {
|
|
390
390
|
this._removeRecursively(entity.childrenNodes[i]);
|
|
391
391
|
}
|
|
392
392
|
}
|
|
@@ -434,7 +434,7 @@ class EntityCollection {
|
|
|
434
434
|
*/
|
|
435
435
|
createPickingColors() {
|
|
436
436
|
var e = this._entities;
|
|
437
|
-
for (
|
|
437
|
+
for (let i = 0; i < e.length; i++) {
|
|
438
438
|
if (!e[i].parent) {
|
|
439
439
|
this.renderNode.renderer.assignPickingColor(e[i]);
|
|
440
440
|
e[i].setPickingColor();
|
|
@@ -449,7 +449,7 @@ class EntityCollection {
|
|
|
449
449
|
*/
|
|
450
450
|
reindexEntitiesArray(startIndex) {
|
|
451
451
|
var e = this._entities;
|
|
452
|
-
for (
|
|
452
|
+
for (let i = startIndex; i < e.length; i++) {
|
|
453
453
|
e[i]._entityCollectionIndex = i;
|
|
454
454
|
}
|
|
455
455
|
}
|
|
@@ -521,7 +521,7 @@ class EntityCollection {
|
|
|
521
521
|
*/
|
|
522
522
|
updateBillboardsTextureAtlas() {
|
|
523
523
|
var b = this.billboardHandler._billboards;
|
|
524
|
-
for (
|
|
524
|
+
for (let i = 0; i < b.length; i++) {
|
|
525
525
|
b[i].setSrc(b[i]._src);
|
|
526
526
|
}
|
|
527
527
|
}
|
|
@@ -534,7 +534,7 @@ class EntityCollection {
|
|
|
534
534
|
if (this.renderNode) {
|
|
535
535
|
var l = [].concat(this.labelHandler._billboards);
|
|
536
536
|
this.labelHandler._billboards = [];
|
|
537
|
-
for (
|
|
537
|
+
for (let i = 0; i < l.length; i++) {
|
|
538
538
|
this.labelHandler.assignFontAtlas(l[i]);
|
|
539
539
|
}
|
|
540
540
|
}
|
|
@@ -621,7 +621,7 @@ class EntityCollection {
|
|
|
621
621
|
_clearEntity(entity) {
|
|
622
622
|
entity._entityCollection = null;
|
|
623
623
|
entity._entityCollectionIndex = -1;
|
|
624
|
-
for (
|
|
624
|
+
for (let i = 0; i < entity.childrenNodes.length; i++) {
|
|
625
625
|
this._clearEntity(entity.childrenNodes[i]);
|
|
626
626
|
}
|
|
627
627
|
}
|
|
@@ -232,10 +232,12 @@ class GeoObject {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
updateDirection() {
|
|
235
|
-
this.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
235
|
+
if (this._handler && this._handler._planet) {
|
|
236
|
+
this._qNorthFrame = this._handler._planet.getNorthFrameRotation(this._position);
|
|
237
|
+
let qq = Quat.yRotation(this._yaw).mul(this._qNorthFrame).conjugate();
|
|
238
|
+
this._direction = qq.mulVec3(new Vec3(0.0, 0.0, -1.0)).normalize();
|
|
239
|
+
this._handler.setDirectionArr(this._tagData, this._tagDataIndex, this._direction);
|
|
240
|
+
}
|
|
239
241
|
}
|
|
240
242
|
}
|
|
241
243
|
|