@openglobus/og 0.15.4 → 0.15.5
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 +3 -7
- 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/LonLat.js +207 -193
- package/src/og/camera/Camera.js +4 -16
- package/src/og/camera/PlanetCamera.js +12 -6
- package/src/og/control/KeyboardNavigation.js +153 -169
- package/src/og/control/MouseNavigation.js +0 -20
- package/src/og/control/SimpleNavigation.js +10 -10
- package/src/og/ellipsoid/Ellipsoid.js +20 -3
- package/src/og/layer/Vector.js +7 -6
- package/src/og/layer/XYZ.js +2 -2
- package/src/og/quadTree/EntityCollectionNode.js +8 -2
- package/src/og/renderer/Renderer.js +1 -0
- package/src/og/scene/Planet.js +9 -5
- package/src/og/segment/Segment.js +37 -44
- package/types/LonLat.d.ts +8 -0
- package/types/camera/PlanetCamera.d.ts +1 -1
- package/types/ellipsoid/Ellipsoid.d.ts +13 -1
- package/types/layer/XYZ.d.ts +1 -1
- package/types/segment/Segment.d.ts +2 -3
|
@@ -254,11 +254,10 @@ class Segment {
|
|
|
254
254
|
* @public
|
|
255
255
|
* @param {Entity} entity - Entity.
|
|
256
256
|
* @param {Vec3} res - Point coordinates.
|
|
257
|
-
* @param {Vec3} [normal] - Terrain point normal.
|
|
258
257
|
* @returns {Vec3} -
|
|
259
258
|
*/
|
|
260
|
-
getEntityTerrainPoint(entity, res
|
|
261
|
-
return this.getTerrainPoint(entity._cartesian, entity._lonlatMerc, res
|
|
259
|
+
getEntityTerrainPoint(entity, res) {
|
|
260
|
+
return this.getTerrainPoint(entity._cartesian, entity._lonlatMerc, res);
|
|
262
261
|
}
|
|
263
262
|
|
|
264
263
|
isEntityInside(e) {
|
|
@@ -274,80 +273,74 @@ class Segment {
|
|
|
274
273
|
* @param {Vec3} [normal] - Terrain point normal.
|
|
275
274
|
* @returns {number} -
|
|
276
275
|
*/
|
|
277
|
-
getTerrainPoint(xyz, insideSegmentPosition, res
|
|
278
|
-
|
|
276
|
+
getTerrainPoint(xyz, insideSegmentPosition, res) {
|
|
277
|
+
let verts = this.tempVertices;
|
|
279
278
|
|
|
280
|
-
|
|
279
|
+
if (verts && verts.length) {
|
|
280
|
+
let norm = this.planet.ellipsoid.getSurfaceNormal3v(xyz);
|
|
281
|
+
_ray.set(xyz, norm.negateTo());
|
|
281
282
|
|
|
282
|
-
|
|
283
|
-
var ne = this._extent.northEast,
|
|
283
|
+
let ne = this._extent.northEast,
|
|
284
284
|
sw = this._extent.southWest,
|
|
285
285
|
size = Math.sqrt(verts.length / 3) - 1;
|
|
286
286
|
|
|
287
|
-
|
|
287
|
+
let xmax = ne.lon,
|
|
288
288
|
ymax = ne.lat,
|
|
289
289
|
xmin = sw.lon,
|
|
290
290
|
ymin = sw.lat,
|
|
291
291
|
x = insideSegmentPosition.lon,
|
|
292
292
|
y = insideSegmentPosition.lat;
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
let sxn = xmax - xmin,
|
|
295
295
|
syn = ymax - ymin;
|
|
296
296
|
|
|
297
|
-
|
|
297
|
+
let qx = sxn / size,
|
|
298
298
|
qy = syn / size;
|
|
299
299
|
|
|
300
|
-
|
|
300
|
+
let xn = x - xmin,
|
|
301
301
|
yn = y - ymin;
|
|
302
302
|
|
|
303
|
-
|
|
303
|
+
let indX = Math.floor(xn / qx),
|
|
304
304
|
indY = Math.floor(size - yn / qy);
|
|
305
305
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
var ind_v2 = ((size + 1) * (indY + 1) + indX) * 3;
|
|
306
|
+
let ind_v0 = ((size + 1) * indY + indX) * 3;
|
|
307
|
+
let ind_v2 = ((size + 1) * (indY + 1) + indX) * 3;
|
|
309
308
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
309
|
+
_v0.set(verts[ind_v0], verts[ind_v0 + 1], verts[ind_v0 + 2]);
|
|
310
|
+
_v1.set(verts[ind_v0 + 3], verts[ind_v0 + 4], verts[ind_v0 + 5]);
|
|
311
|
+
_v2.set(verts[ind_v2], verts[ind_v2 + 1], verts[ind_v2 + 2]);
|
|
313
312
|
|
|
314
|
-
|
|
313
|
+
let d = _ray.hitTriangle(_v0, _v1, _v2, res);
|
|
315
314
|
|
|
315
|
+
if (d === Ray.INSIDE) {
|
|
316
|
+
return xyz.distance(res);
|
|
317
|
+
} else if (d === Ray.AWAY) {
|
|
318
|
+
_rayEx.set(xyz, norm);
|
|
319
|
+
let d = _rayEx.hitTriangle(_v0, _v1, _v2, res);
|
|
316
320
|
if (d === Ray.INSIDE) {
|
|
317
|
-
return xyz.distance(res);
|
|
318
|
-
} else if (d === Ray.AWAY) {
|
|
319
|
-
_rayEx.set(xyz, this.planet.ellipsoid.getSurfaceNormal3v(xyz));
|
|
320
|
-
let d = _rayEx.hitTriangle(_v0, _v1, _v2, res, normal);
|
|
321
|
-
if (d === Ray.INSIDE) {
|
|
322
|
-
return -xyz.distance(res);
|
|
323
|
-
}
|
|
321
|
+
return -xyz.distance(res);
|
|
324
322
|
}
|
|
323
|
+
}
|
|
325
324
|
|
|
326
|
-
|
|
325
|
+
_v3.set(verts[ind_v2 + 3], verts[ind_v2 + 4], verts[ind_v2 + 5]);
|
|
327
326
|
|
|
328
|
-
|
|
327
|
+
d = _ray.hitTriangle(_v1, _v3, _v2, res);
|
|
328
|
+
if (d === Ray.INSIDE) {
|
|
329
|
+
return xyz.distance(res);
|
|
330
|
+
} else if (d === Ray.AWAY) {
|
|
331
|
+
_rayEx.set(xyz, norm);
|
|
332
|
+
let d = _rayEx.hitTriangle(_v1, _v3, _v2, res);
|
|
329
333
|
if (d === Ray.INSIDE) {
|
|
330
|
-
return xyz.distance(res);
|
|
331
|
-
} else if (d === Ray.AWAY) {
|
|
332
|
-
_rayEx.set(xyz, this.planet.ellipsoid.getSurfaceNormal3v(xyz));
|
|
333
|
-
let d = _rayEx.hitTriangle(_v1, _v3, _v2, res, normal);
|
|
334
|
-
if (d === Ray.INSIDE) {
|
|
335
|
-
return -xyz.distance(res);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if (d === Ray.AWAY) {
|
|
340
334
|
return -xyz.distance(res);
|
|
341
335
|
}
|
|
336
|
+
}
|
|
342
337
|
|
|
343
|
-
|
|
338
|
+
if (d === Ray.AWAY) {
|
|
339
|
+
return -xyz.distance(res);
|
|
344
340
|
}
|
|
345
341
|
|
|
346
|
-
res.copy(this.planet.ellipsoid.hitRay(_ray.origin, _ray.direction));
|
|
347
|
-
normal && normal.copy(xyz.normal());
|
|
348
342
|
return xyz.distance(res);
|
|
349
343
|
} else {
|
|
350
|
-
normal && normal.copy(xyz.normal());
|
|
351
344
|
return xyz.distance(this.planet.ellipsoid.hitRay(_ray.origin, _ray.direction));
|
|
352
345
|
}
|
|
353
346
|
}
|
|
@@ -1597,7 +1590,7 @@ class Segment {
|
|
|
1597
1590
|
shu = sh.uniforms;
|
|
1598
1591
|
|
|
1599
1592
|
var currHeight;
|
|
1600
|
-
if (layerSlice.length) {
|
|
1593
|
+
if (layerSlice && layerSlice.length) {
|
|
1601
1594
|
currHeight = layerSlice[0]._height;
|
|
1602
1595
|
} else {
|
|
1603
1596
|
currHeight = 0;
|
package/types/LonLat.d.ts
CHANGED
|
@@ -29,6 +29,14 @@ export class LonLat {
|
|
|
29
29
|
* @returns {LonLat} -
|
|
30
30
|
*/
|
|
31
31
|
static forwardMercator(lon: number, lat: number, height?: number): LonLat;
|
|
32
|
+
/**
|
|
33
|
+
* Converts degrees to mercator coordinates.
|
|
34
|
+
* @static
|
|
35
|
+
* @param {LonLat} lonLat - Input geodetic degree coordinates
|
|
36
|
+
* @param {LonLat} res - Output mercator coordinates
|
|
37
|
+
* @returns {LonLat} - Output mercator coordinates
|
|
38
|
+
*/
|
|
39
|
+
static forwardMercatorRes(lonLat: LonLat, res: LonLat): LonLat;
|
|
32
40
|
/**
|
|
33
41
|
* Converts mercator to degrees coordinates.
|
|
34
42
|
* @static
|
|
@@ -215,7 +215,7 @@ export class PlanetCamera extends Camera {
|
|
|
215
215
|
* @public
|
|
216
216
|
*/
|
|
217
217
|
public checkFly(): void;
|
|
218
|
-
checkTerrainCollision():
|
|
218
|
+
checkTerrainCollision(): Vec3;
|
|
219
219
|
getSurfaceVisibleDistance(d: any): number;
|
|
220
220
|
getHeading(): number;
|
|
221
221
|
isVisible(poi: any): boolean;
|
|
@@ -118,7 +118,19 @@ export class Ellipsoid {
|
|
|
118
118
|
* @returns {LonLat} -
|
|
119
119
|
*/
|
|
120
120
|
public projToSurface(p: Vec3): LonLat;
|
|
121
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Converts 3d cartesian coordinates to geodetic
|
|
123
|
+
* @param {Vec3} cart - Cartesian coordiantes
|
|
124
|
+
* @returns {LonLat} - Geodetic coordinates
|
|
125
|
+
*/
|
|
126
|
+
cartesianToLonLat(cart: Vec3): LonLat;
|
|
127
|
+
/**
|
|
128
|
+
* Converts 3d cartesian coordinates to geodetic
|
|
129
|
+
* @param {Vec3} cart - Cartesian coordiantes
|
|
130
|
+
* @param {LonLat} res - Link geodetic coordinates variable
|
|
131
|
+
* @returns {LonLat} - Geodetic coordinates
|
|
132
|
+
*/
|
|
133
|
+
cartesianToLonLatRes(cart: Vec3, res: LonLat): LonLat;
|
|
122
134
|
/**
|
|
123
135
|
* Gets ellipsoid surface normal.
|
|
124
136
|
* @public
|
package/types/layer/XYZ.d.ts
CHANGED
|
@@ -163,10 +163,9 @@ export class Segment {
|
|
|
163
163
|
* @public
|
|
164
164
|
* @param {Entity} entity - Entity.
|
|
165
165
|
* @param {Vec3} res - Point coordinates.
|
|
166
|
-
* @param {Vec3} [normal] - Terrain point normal.
|
|
167
166
|
* @returns {Vec3} -
|
|
168
167
|
*/
|
|
169
|
-
public getEntityTerrainPoint(entity: Entity, res: Vec3
|
|
168
|
+
public getEntityTerrainPoint(entity: Entity, res: Vec3): Vec3;
|
|
170
169
|
isEntityInside(e: any): boolean;
|
|
171
170
|
/**
|
|
172
171
|
* Returns distance from object to terrain coordinates and terrain point that calculates out in the res parameter.
|
|
@@ -177,7 +176,7 @@ export class Segment {
|
|
|
177
176
|
* @param {Vec3} [normal] - Terrain point normal.
|
|
178
177
|
* @returns {number} -
|
|
179
178
|
*/
|
|
180
|
-
public getTerrainPoint(xyz: Vec3, insideSegmentPosition: LonLat, res?: Vec3
|
|
179
|
+
public getTerrainPoint(xyz: Vec3, insideSegmentPosition: LonLat, res?: Vec3): number;
|
|
181
180
|
/**
|
|
182
181
|
* Project wgs86 to segment native projection.
|
|
183
182
|
* @public
|