@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.
@@ -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, normal) {
261
- return this.getTerrainPoint(entity._cartesian, entity._lonlatMerc, res, normal);
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, normal) {
278
- var verts = this.tempVertices;
276
+ getTerrainPoint(xyz, insideSegmentPosition, res) {
277
+ let verts = this.tempVertices;
279
278
 
280
- _ray.set(xyz, xyz.negateTo());
279
+ if (verts && verts.length) {
280
+ let norm = this.planet.ellipsoid.getSurfaceNormal3v(xyz);
281
+ _ray.set(xyz, norm.negateTo());
281
282
 
282
- if (verts) {
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
- var xmax = ne.lon,
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
- var sxn = xmax - xmin,
294
+ let sxn = xmax - xmin,
295
295
  syn = ymax - ymin;
296
296
 
297
- var qx = sxn / size,
297
+ let qx = sxn / size,
298
298
  qy = syn / size;
299
299
 
300
- var xn = x - xmin,
300
+ let xn = x - xmin,
301
301
  yn = y - ymin;
302
302
 
303
- var indX = Math.floor(xn / qx),
303
+ let indX = Math.floor(xn / qx),
304
304
  indY = Math.floor(size - yn / qy);
305
305
 
306
- if (verts && verts.length) {
307
- var ind_v0 = ((size + 1) * indY + indX) * 3;
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
- _v0.set(verts[ind_v0], verts[ind_v0 + 1], verts[ind_v0 + 2]);
311
- _v1.set(verts[ind_v0 + 3], verts[ind_v0 + 4], verts[ind_v0 + 5]);
312
- _v2.set(verts[ind_v2], verts[ind_v2 + 1], verts[ind_v2 + 2]);
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
- let d = _ray.hitTriangle(_v0, _v1, _v2, res, normal);
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
- _v3.set(verts[ind_v2 + 3], verts[ind_v2 + 4], verts[ind_v2 + 5]);
325
+ _v3.set(verts[ind_v2 + 3], verts[ind_v2 + 4], verts[ind_v2 + 5]);
327
326
 
328
- d = _ray.hitTriangle(_v1, _v3, _v2, res, normal);
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
- return xyz.distance(res);
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(): void;
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
- cartesianToLonLat(cart: any): LonLat;
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
@@ -33,7 +33,7 @@ export class XYZ extends Layer {
33
33
  * @param {string} name - Layer name.
34
34
  * @param {*} options
35
35
  */
36
- constructor(name: string, options: any);
36
+ constructor(name: string, options?: any);
37
37
  /**
38
38
  * Tile url source template.
39
39
  * @public
@@ -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, normal?: Vec3): 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, normal?: Vec3): number;
179
+ public getTerrainPoint(xyz: Vec3, insideSegmentPosition: LonLat, res?: Vec3): number;
181
180
  /**
182
181
  * Project wgs86 to segment native projection.
183
182
  * @public