@openglobus/og 0.23.0 → 0.24.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.
Files changed (84) hide show
  1. package/lib/@openglobus/js/Globe.d.ts +0 -1
  2. package/lib/@openglobus/js/camera/Camera.d.ts +48 -15
  3. package/lib/@openglobus/js/camera/PlanetCamera.d.ts +13 -0
  4. package/lib/@openglobus/js/control/MouseNavigation.d.ts +62 -51
  5. package/lib/@openglobus/js/control/OldMouseNavigation.d.ts +64 -0
  6. package/lib/@openglobus/js/control/index.d.ts +1 -2
  7. package/lib/@openglobus/js/entity/Entity.d.ts +24 -20
  8. package/lib/@openglobus/js/entity/GeoObject.d.ts +0 -9
  9. package/lib/@openglobus/js/input/MouseHandler.d.ts +1 -0
  10. package/lib/@openglobus/js/math/Mat3.d.ts +1 -1
  11. package/lib/@openglobus/js/math/Mat4.d.ts +10 -1
  12. package/lib/@openglobus/js/math/Plane.d.ts +3 -1
  13. package/lib/@openglobus/js/math/Quat.d.ts +1 -0
  14. package/lib/@openglobus/js/math/Ray.d.ts +6 -16
  15. package/lib/@openglobus/js/math/Vec2.d.ts +22 -0
  16. package/lib/@openglobus/js/renderer/RendererEvents.d.ts +1 -0
  17. package/lib/@openglobus/js/scene/Planet.d.ts +4 -0
  18. package/lib/@openglobus/js/webgl/Handler.d.ts +21 -12
  19. package/lib/@openglobus/og.esm.js +1 -1
  20. package/lib/@openglobus/og.esm.js.map +1 -1
  21. package/lib/@openglobus/og.umd.js +1 -1
  22. package/lib/@openglobus/og.umd.js.map +1 -1
  23. package/lib/js/Globe.d.ts +0 -1
  24. package/lib/js/Globe.js +4 -2
  25. package/lib/js/Popup.js +1 -1
  26. package/lib/js/camera/Camera.d.ts +48 -15
  27. package/lib/js/camera/Camera.js +82 -28
  28. package/lib/js/camera/PlanetCamera.d.ts +13 -0
  29. package/lib/js/camera/PlanetCamera.js +52 -5
  30. package/lib/js/control/CameraLock.js +1 -1
  31. package/lib/js/control/DebugInfo.js +30 -10
  32. package/lib/js/control/KeyboardNavigation.js +8 -8
  33. package/lib/js/control/MouseNavigation.d.ts +62 -51
  34. package/lib/js/control/MouseNavigation.js +361 -305
  35. package/lib/js/control/MouseWheelZoomControl.d.ts +0 -44
  36. package/lib/js/control/MouseWheelZoomControl.js +270 -181
  37. package/lib/js/control/OldMouseNavigation.d.ts +64 -0
  38. package/lib/js/control/OldMouseNavigation.js +368 -0
  39. package/lib/js/control/ScaleControl.js +2 -2
  40. package/lib/js/control/SimpleNavigation.js +8 -7
  41. package/lib/js/control/Sun.js +5 -5
  42. package/lib/js/control/TouchNavigation.js +11 -8
  43. package/lib/js/control/elevationProfile/ElevationProfileScene.js +2 -1
  44. package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +19 -33
  45. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +18 -18
  46. package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +3 -2
  47. package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +1 -4
  48. package/lib/js/control/geoObjectEditor/RotateEntity.js +1 -1
  49. package/lib/js/control/index.d.ts +1 -2
  50. package/lib/js/control/index.js +1 -2
  51. package/lib/js/control/visibleExtent/Segment.js +4 -4
  52. package/lib/js/entity/Entity.d.ts +24 -20
  53. package/lib/js/entity/Entity.js +62 -47
  54. package/lib/js/entity/GeoObject.d.ts +0 -9
  55. package/lib/js/entity/GeoObject.js +0 -3
  56. package/lib/js/entity/InstanceData.js +6 -3
  57. package/lib/js/input/MouseHandler.d.ts +1 -0
  58. package/lib/js/input/MouseHandler.js +12 -1
  59. package/lib/js/math/Mat3.d.ts +1 -1
  60. package/lib/js/math/Mat3.js +1 -1
  61. package/lib/js/math/Mat4.d.ts +10 -1
  62. package/lib/js/math/Mat4.js +17 -1
  63. package/lib/js/math/Plane.d.ts +3 -1
  64. package/lib/js/math/Plane.js +11 -1
  65. package/lib/js/math/Quat.d.ts +1 -0
  66. package/lib/js/math/Quat.js +1 -0
  67. package/lib/js/math/Ray.d.ts +6 -16
  68. package/lib/js/math/Ray.js +53 -46
  69. package/lib/js/math/Vec2.d.ts +22 -0
  70. package/lib/js/math/Vec2.js +32 -0
  71. package/lib/js/renderer/Renderer.js +10 -6
  72. package/lib/js/renderer/RendererEvents.d.ts +1 -0
  73. package/lib/js/renderer/RendererEvents.js +3 -1
  74. package/lib/js/scene/Planet.d.ts +4 -0
  75. package/lib/js/scene/Planet.js +24 -3
  76. package/lib/js/segment/Segment.js +4 -4
  77. package/lib/js/terrain/GlobusTerrain.js +2 -2
  78. package/lib/js/webgl/Handler.d.ts +21 -12
  79. package/lib/js/webgl/Handler.js +42 -33
  80. package/package.json +2 -2
  81. package/lib/@openglobus/js/control/EarthNavigation.d.ts +0 -50
  82. package/lib/@openglobus/js/control/MouseWheelZoomControl.d.ts +0 -44
  83. package/lib/js/control/EarthNavigation.d.ts +0 -50
  84. package/lib/js/control/EarthNavigation.js +0 -202
@@ -1,5 +1,5 @@
1
1
  import { createEvents } from '../../Events';
2
- import { DEGREES, MAX32, RADIANS } from "../../math";
2
+ import { MAX32 } from "../../math";
3
3
  import { Plane } from "../../math/Plane";
4
4
  import { RenderNode } from '../../scene/RenderNode';
5
5
  import { Vec2 } from '../../math/Vec2';
@@ -17,9 +17,9 @@ import { EntityCollection } from "../../entity/EntityCollection";
17
17
  function dragSimpleRes(unit, eye, clickDir, direction, p0, res) {
18
18
  let p1 = p0.add(Vec3.UP), p2 = p0.add(unit);
19
19
  let px = new Vec3();
20
- if (new Ray(eye, clickDir).hitPlane(p0, p1, p2, px) === Ray.INSIDE) {
20
+ if (new Ray(eye, clickDir).hitPlaneRes(Plane.fromPoints(p0, p1, p2), px) === Ray.INSIDE) {
21
21
  let clickCart = Vec3.proj_b_to_a(px, unit);
22
- if (new Ray(eye, direction).hitPlane(p0, p1, p2, px) === Ray.INSIDE) {
22
+ if (new Ray(eye, direction).hitPlaneRes(Plane.fromPoints(p0, p1, p2), px) === Ray.INSIDE) {
23
23
  let dragCart = Vec3.proj_b_to_a(px, unit);
24
24
  let dragVec = dragCart.sub(clickCart);
25
25
  res.copy(p0.add(dragVec));
@@ -148,9 +148,9 @@ class GeoObjectEditorScene extends RenderNode {
148
148
  let p2 = p0.add(cam.getRight());
149
149
  let px = new Vec3();
150
150
  let clickDir = cam.unproject(this._clickPos.x, this._clickPos.y);
151
- if (new Ray(cam.eye, clickDir).hitPlane(p0, p1, p2, px) === Ray.INSIDE) {
151
+ if (new Ray(cam.eye, clickDir).hitPlaneRes(Plane.fromPoints(p0, p1, p2), px) === Ray.INSIDE) {
152
152
  let clickCart = Vec3.proj_b_to_a(px, groundNormal);
153
- if (new Ray(cam.eye, e.direction).hitPlane(p0, p1, p2, px) === Ray.INSIDE) {
153
+ if (new Ray(cam.eye, e.direction).hitPlaneRes(Plane.fromPoints(p0, p1, p2), px) === Ray.INSIDE) {
154
154
  let dragCart = Vec3.proj_b_to_a(px, groundNormal);
155
155
  let dragVec = dragCart.sub(clickCart);
156
156
  let pos = this._selectedEntityCart.add(dragVec);
@@ -210,8 +210,8 @@ class GeoObjectEditorScene extends RenderNode {
210
210
  else {
211
211
  let p1 = p0.add(Vec3.UNIT_X), p2 = p0.add(Vec3.UNIT_Z);
212
212
  let clickCart = new Vec3(), dragCart = new Vec3();
213
- if (new Ray(cam.eye, clickDir).hitPlane(p0, p1, p2, clickCart) === Ray.INSIDE) {
214
- if (new Ray(cam.eye, e.direction).hitPlane(p0, p1, p2, dragCart) === Ray.INSIDE) {
213
+ if (new Ray(cam.eye, clickDir).hitPlaneRes(Plane.fromPoints(p0, p1, p2), clickCart) === Ray.INSIDE) {
214
+ if (new Ray(cam.eye, e.direction).hitPlaneRes(Plane.fromPoints(p0, p1, p2), dragCart) === Ray.INSIDE) {
215
215
  let dragVec = dragCart.sub(clickCart);
216
216
  px = p0.add(dragVec);
217
217
  }
@@ -233,7 +233,7 @@ class GeoObjectEditorScene extends RenderNode {
233
233
  let cam = this.renderer.activeCamera;
234
234
  let p0 = this._selectedEntityCart;
235
235
  let qp = Quat.xRotation(0);
236
- let qy = Quat.yRotation(this._selectedEntity.getYaw() * RADIANS);
236
+ let qy = Quat.yRotation(this._selectedEntity.getYaw());
237
237
  let qr = Quat.zRotation(0);
238
238
  let qRot = qr.mul(qp).mul(qy).mul(this.getFrameRotation(p0)).conjugate();
239
239
  //let norm = qNorthFrame.mulVec3(new Vec3(1, 0, 0)).normalize();
@@ -241,11 +241,11 @@ class GeoObjectEditorScene extends RenderNode {
241
241
  let clickDir = cam.unproject(this._clickPos.x, this._clickPos.y);
242
242
  let pl = new Plane(p0, norm);
243
243
  let clickCart = new Vec3(), dragCart = new Vec3();
244
- if (new Ray(cam.eye, clickDir).hitPlane2(pl, clickCart) === Ray.INSIDE) {
245
- if (new Ray(cam.eye, e.direction).hitPlane2(pl, dragCart) === Ray.INSIDE) {
244
+ if (new Ray(cam.eye, clickDir).hitPlaneRes(pl, clickCart) === Ray.INSIDE) {
245
+ if (new Ray(cam.eye, e.direction).hitPlaneRes(pl, dragCart) === Ray.INSIDE) {
246
246
  let c0 = clickCart.sub(p0).normalize(), c1 = dragCart.sub(p0).normalize();
247
247
  let sig = Math.sign(c0.cross(c1).dot(norm));
248
- let angle = Math.acos(c0.dot(c1)) * DEGREES;
248
+ let angle = Math.acos(c0.dot(c1));
249
249
  let deg = this._selectedEntityPitch + sig * angle;
250
250
  this._selectedEntity.setAbsolutePitch(deg);
251
251
  this.events.dispatch(this.events.pitch, deg, this._selectedEntity);
@@ -263,11 +263,11 @@ class GeoObjectEditorScene extends RenderNode {
263
263
  let clickDir = cam.unproject(this._clickPos.x, this._clickPos.y);
264
264
  let pl = new Plane(p0, norm);
265
265
  let clickCart = new Vec3(), dragCart = new Vec3();
266
- if (new Ray(cam.eye, clickDir).hitPlane2(pl, clickCart) === Ray.INSIDE) {
267
- if (new Ray(cam.eye, e.direction).hitPlane2(pl, dragCart) === Ray.INSIDE) {
266
+ if (new Ray(cam.eye, clickDir).hitPlaneRes(pl, clickCart) === Ray.INSIDE) {
267
+ if (new Ray(cam.eye, e.direction).hitPlaneRes(pl, dragCart) === Ray.INSIDE) {
268
268
  let c0 = clickCart.sub(p0).normalize(), c1 = dragCart.sub(p0).normalize();
269
269
  let sig = Math.sign(c1.cross(c0).dot(norm));
270
- let angle = Math.acos(c0.dot(c1)) * DEGREES;
270
+ let angle = Math.acos(c0.dot(c1));
271
271
  let deg = this._selectedEntityYaw + sig * angle;
272
272
  this._selectedEntity.setAbsoluteYaw(deg);
273
273
  this.events.dispatch(this.events.yaw, deg, this._selectedEntity);
@@ -282,7 +282,7 @@ class GeoObjectEditorScene extends RenderNode {
282
282
  let p0 = this._selectedEntityCart;
283
283
  let qNorthFrame = this.getFrameRotation(p0).conjugate();
284
284
  let qp = Quat.xRotation(0);
285
- let qy = Quat.yRotation(this._selectedEntity.getYaw() * RADIANS);
285
+ let qy = Quat.yRotation(this._selectedEntity.getYaw());
286
286
  let qr = Quat.zRotation(0);
287
287
  let qRot = qr.mul(qp).mul(qy).mul(this.getFrameRotation(p0)).conjugate();
288
288
  //let norm = qNorthFrame.mulVec3(new Vec3(0, 0, 1)).normalize();
@@ -290,11 +290,11 @@ class GeoObjectEditorScene extends RenderNode {
290
290
  let clickDir = cam.unproject(this._clickPos.x, this._clickPos.y);
291
291
  let pl = new Plane(p0, norm);
292
292
  let clickCart = new Vec3(), dragCart = new Vec3();
293
- if (new Ray(cam.eye, clickDir).hitPlane2(pl, clickCart) === Ray.INSIDE) {
294
- if (new Ray(cam.eye, e.direction).hitPlane2(pl, dragCart) === Ray.INSIDE) {
293
+ if (new Ray(cam.eye, clickDir).hitPlaneRes(pl, clickCart) === Ray.INSIDE) {
294
+ if (new Ray(cam.eye, e.direction).hitPlaneRes(pl, dragCart) === Ray.INSIDE) {
295
295
  let c0 = clickCart.sub(p0).normalize(), c1 = dragCart.sub(p0).normalize();
296
296
  let sig = Math.sign(c0.cross(c1).dot(norm));
297
- let angle = Math.acos(c0.dot(c1)) * DEGREES;
297
+ let angle = Math.acos(c0.dot(c1));
298
298
  let deg = this._selectedEntityRoll + sig * angle;
299
299
  this._selectedEntity.setAbsoluteRoll(deg);
300
300
  this.events.dispatch(this.events.roll, deg, this._selectedEntity);
@@ -2,6 +2,7 @@ import { Entity } from "../../entity/Entity";
2
2
  import { Vec3 } from "../../math/Vec3";
3
3
  import { SEL_X_COLOR, SEL_Y_COLOR, SEL_Z_COLOR, X_COLOR, Y_COLOR, Z_COLOR } from "./colors";
4
4
  import { ArrowEntity } from "./ArrowEntity";
5
+ import { RADIANS } from "../../math";
5
6
  export class MoveAxisEntity extends Entity {
6
7
  constructor(params = {}) {
7
8
  super(params);
@@ -14,7 +15,7 @@ export class MoveAxisEntity extends Entity {
14
15
  color: X_COLOR,
15
16
  yaw: 0,
16
17
  pitch: 0,
17
- roll: 90,
18
+ roll: 90 * RADIANS,
18
19
  properties: {
19
20
  opName: "move_x",
20
21
  noEdit: true,
@@ -41,7 +42,7 @@ export class MoveAxisEntity extends Entity {
41
42
  let arrowZ = new ArrowEntity({
42
43
  color: Z_COLOR,
43
44
  yaw: 0,
44
- pitch: 90,
45
+ pitch: 90 * RADIANS,
45
46
  roll: 0,
46
47
  properties: {
47
48
  opName: "move_z",
@@ -15,10 +15,7 @@ export class MovePlaneEntity extends Entity {
15
15
  geoObject: {
16
16
  color: XZ_COLOR,
17
17
  tag: "plane",
18
- object3d: planeObj,
19
- yaw: 0,
20
- pitch: 0,
21
- roll: 0
18
+ object3d: planeObj
22
19
  },
23
20
  properties: {
24
21
  opName: "move_xz",
@@ -78,7 +78,7 @@ export class RotateEntity extends Entity {
78
78
  let qNorthFrame = rn.getFrameRotation(cart).conjugate();
79
79
  let r = cam.eye.distance(cart) * 0.15;
80
80
  let qp = Quat.xRotation(0);
81
- let qy = Quat.yRotation(yaw * RADIANS);
81
+ let qy = Quat.yRotation(yaw);
82
82
  let qr = Quat.zRotation(0);
83
83
  let qRot = qr.mul(qp).mul(qy).mul(rn.getFrameRotation(cart)).conjugate();
84
84
  for (let i = 0, j = 0, step = 360 / SEG_SIZE; i < SEG_SIZE; i += step, j++) {
@@ -3,14 +3,13 @@ export * from "./Control";
3
3
  export * from "./DebugInfo";
4
4
  export * from "./DrawingSwitcher";
5
5
  export * from "./EarthCoordinates";
6
- export * from "./EarthNavigation";
7
6
  export * from "./GeoImageDragControl";
8
7
  export * from "./KeyboardNavigation";
9
8
  export * from "./LayerAnimation";
10
9
  export * from "./LayerSwitcher";
11
10
  export * from "./Lighting";
11
+ export * from "./OldMouseNavigation";
12
12
  export * from "./MouseNavigation";
13
- export * from "./MouseWheelZoomControl";
14
13
  export * from "./RulerSwitcher";
15
14
  export * from "./ScaleControl";
16
15
  export * from "./ShowFps";
@@ -3,14 +3,13 @@ export * from "./Control";
3
3
  export * from "./DebugInfo";
4
4
  export * from "./DrawingSwitcher";
5
5
  export * from "./EarthCoordinates";
6
- export * from "./EarthNavigation";
7
6
  export * from "./GeoImageDragControl";
8
7
  export * from "./KeyboardNavigation";
9
8
  export * from "./LayerAnimation";
10
9
  export * from "./LayerSwitcher";
11
10
  export * from "./Lighting";
11
+ export * from "./OldMouseNavigation";
12
12
  export * from "./MouseNavigation";
13
- export * from "./MouseWheelZoomControl";
14
13
  export * from "./RulerSwitcher";
15
14
  export * from "./ScaleControl";
16
15
  export * from "./ShowFps";
@@ -240,25 +240,25 @@ class Segment {
240
240
  _v0.set(verts[ind_v0], verts[ind_v0 + 1], verts[ind_v0 + 2]);
241
241
  _v1.set(verts[ind_v0 + 3], verts[ind_v0 + 4], verts[ind_v0 + 5]);
242
242
  _v2.set(verts[ind_v2], verts[ind_v2 + 1], verts[ind_v2 + 2]);
243
- let d = _ray.hitTriangle(_v0, _v1, _v2, res);
243
+ let d = _ray.hitTriangleRes(_v0, _v1, _v2, res);
244
244
  if (d === Ray.INSIDE) {
245
245
  return xyz.distance(res);
246
246
  }
247
247
  else if (d === Ray.AWAY) {
248
248
  _rayEx.set(xyz, norm);
249
- let d = _rayEx.hitTriangle(_v0, _v1, _v2, res);
249
+ let d = _rayEx.hitTriangleRes(_v0, _v1, _v2, res);
250
250
  if (d === Ray.INSIDE) {
251
251
  return -xyz.distance(res);
252
252
  }
253
253
  }
254
254
  _v3.set(verts[ind_v2 + 3], verts[ind_v2 + 4], verts[ind_v2 + 5]);
255
- d = _ray.hitTriangle(_v1, _v3, _v2, res);
255
+ d = _ray.hitTriangleRes(_v1, _v3, _v2, res);
256
256
  if (d === Ray.INSIDE) {
257
257
  return xyz.distance(res);
258
258
  }
259
259
  else if (d === Ray.AWAY) {
260
260
  _rayEx.set(xyz, norm);
261
- let d = _rayEx.hitTriangle(_v1, _v3, _v2, res);
261
+ let d = _rayEx.hitTriangleRes(_v1, _v3, _v2, res);
262
262
  if (d === Ray.INSIDE) {
263
263
  return -xyz.distance(res);
264
264
  }
@@ -37,7 +37,8 @@ import { Quat } from "../math/Quat";
37
37
  * @property {number} [yaw] - Rotation around local Y-axis.
38
38
  * @property {number} [roll] - Rotation around local Z-axis.
39
39
  * @property {number | Vec3 | NumberArray3} [scale] - Scaling factor.
40
- * @property {boolean} [forceGlobalPosition] - Forces global position for children entities make them the same position as the parent.
40
+ * @property {boolean} [forceGlobalPosition] - Forces global position for entity make the same position as its parent.
41
+ * @property {boolean} [forceGlobalRotation] - Forces global rotation for the entity make the same rotation as its parent.
41
42
  */
42
43
  export interface IEntityParams {
43
44
  name?: string;
@@ -61,6 +62,8 @@ export interface IEntityParams {
61
62
  roll?: number;
62
63
  scale?: number | Vec3 | NumberArray3;
63
64
  forceGlobalPosition?: boolean;
65
+ forceGlobalRotation?: boolean;
66
+ forceGlobalScale?: boolean;
64
67
  localPosition?: Vec3 | NumberArray3;
65
68
  }
66
69
  /**
@@ -85,11 +88,13 @@ export interface IEntityParams {
85
88
  * @param {Strip | IStripParams} [options.strip] - Strip object or parameters.
86
89
  * @param {boolean} [options.independentPicking] - Independent picking flag.
87
90
  * @param {boolean} [options.relativePosition] - Parent relative position flag, otherwise position is absolute.
88
- * @param {number} [options.pitch] - Rotation around local X-axis.
89
- * @param {number} [options.yaw] - Rotation around local Y-axis.
90
- * @param {number} [options.roll] - Rotation around local Z-axis.
91
+ * @param {number} [options.pitch] - Rotation around local X-axis in radians.
92
+ * @param {number} [options.yaw] - Rotation around local Y-axis in radians.
93
+ * @param {number} [options.roll] - Rotation around local Z-axis in radians.
91
94
  * @param {number | Vec3 | NumberArray3} [options.scale] - Scaling factor.
92
- * @param {boolean} [options.forceGlobalPosition] - Forces global position for children entities make them the same position as the parent.
95
+ * @param {boolean} [options.forceGlobalPosition] - Forces global position for the entity make the same position as its parent.
96
+ * @param {boolean} [options.forceGlobalRotation] - Forces global rotation for the entity make the same rotation as its parent.
97
+ * @param {boolean} [options.forceGlobalScale] - Forces global scale for the entity make the same scale as its parent.
93
98
  */
94
99
  declare class Entity {
95
100
  static __counter__: number;
@@ -112,6 +117,8 @@ declare class Entity {
112
117
  */
113
118
  childEntities: Entity[];
114
119
  forceGlobalPosition: boolean;
120
+ forceGlobalRotation: boolean;
121
+ forceGlobalScale: boolean;
115
122
  /**
116
123
  * Parent entity.
117
124
  * @public
@@ -238,9 +245,6 @@ declare class Entity {
238
245
  strip: Strip | null;
239
246
  _nodePtr?: EntityCollectionNode;
240
247
  protected _relativePosition: boolean;
241
- protected _pitch: number;
242
- protected _yaw: number;
243
- protected _roll: number;
244
248
  protected _pitchRad: number;
245
249
  protected _yawRad: number;
246
250
  protected _rollRad: number;
@@ -386,72 +390,72 @@ declare class Entity {
386
390
  setRotation(rot: Quat): void;
387
391
  /**
388
392
  * Sets the pitch rotation of the entity.
389
- * @param {number} val - The new pitch angle in degrees.
393
+ * @param {number} val - The new pitch angle in radians.
390
394
  */
391
395
  setPitch(val: number): void;
392
396
  /**
393
397
  * Sets the yaw rotation of the entity.
394
- * @param {number} val - The new yaw angle in degrees.
398
+ * @param {number} val - The new yaw angle in radians.
395
399
  */
396
400
  setYaw(val: number): void;
397
401
  /**
398
402
  * Sets the roll rotation of the entity.
399
403
  * @public
400
- * @param {number} val - The new roll angle in degrees.
404
+ * @param {number} val - The new roll angle in radians.
401
405
  */
402
406
  setRoll(val: number): void;
403
407
  /**
404
408
  * Gets the pitch angle of the entity.
405
409
  * @public
406
- * @returns {number} The pitch angle in degrees.
410
+ * @returns {number} The pitch angle in radians.
407
411
  */
408
412
  getPitch(): number;
409
413
  /**
410
414
  * Gets the yaw angle of the entity.
411
415
  * @public
412
- * @returns {number} The yaw angle in degrees.
416
+ * @returns {number} The yaw angle in radians.
413
417
  */
414
418
  getYaw(): number;
415
419
  /**
416
420
  * Gets the roll angle of the entity.
417
421
  * @public
418
- * @returns {number} The roll angle in degrees.
422
+ * @returns {number} The roll angle in radians.
419
423
  */
420
424
  getRoll(): number;
421
425
  /**
422
426
  * Sets the absolute pitch of the entity.
423
427
  * @public
424
- * @param {number} val - The absolute pitch angle in degrees.
428
+ * @param {number} val - The absolute pitch angle in radians.
425
429
  */
426
430
  setAbsolutePitch(val: number): void;
427
431
  /**
428
432
  * Sets the absolute yaw of the entity.
429
433
  * @public
430
- * @param {number} val - The absolute yaw angle in degrees.
434
+ * @param {number} val - The absolute yaw angle in radians.
431
435
  */
432
436
  setAbsoluteYaw(val: number): void;
433
437
  /**
434
438
  * Sets the absolute roll of the entity.
435
439
  * @public
436
- * @param {number} val - The absolute roll angle in degrees.
440
+ * @param {number} val - The absolute roll angle in radians.
437
441
  */
438
442
  setAbsoluteRoll(val: number): void;
439
443
  /**
440
444
  * Gets the absolute pitch angle of the entity.
441
445
  * @public
442
- * @returns {number} The absolute pitch angle in degrees.
446
+ * @returns {number} The absolute pitch angle in radians.
443
447
  */
444
448
  getAbsolutePitch(): number;
445
449
  /**
446
450
  * Gets the absolute yaw angle of the entity.
447
451
  * @public
448
- * @returns {number} The absolute yaw angle in degrees.
452
+ * @returns {number} The absolute yaw angle in radians.
449
453
  */
450
454
  getAbsoluteYaw(): number;
451
455
  /**
452
456
  * Gets the absolute roll angle of the entity.
453
457
  * @public
454
- * @returns {number} The absolute roll angle in degrees.
458
+ * @returns {number} The absolute roll angle in radians.
455
459
  */
456
460
  getAbsoluteRoll(): number;
457
461
  protected _getScaleByDistance(): number;
@@ -12,7 +12,7 @@ import { Polyline } from "./Polyline";
12
12
  import { Ray } from "./Ray";
13
13
  import { Strip } from "./Strip";
14
14
  import { Quat } from "../math/Quat";
15
- import { RADIANS, clamp, DEGREES } from "../math";
15
+ import { clamp } from "../math";
16
16
  /**
17
17
  * Entity instances aggregate multiple forms of visualization into a single high-level object.
18
18
  * They can be created manually and added to entity collection.
@@ -35,11 +35,13 @@ import { RADIANS, clamp, DEGREES } from "../math";
35
35
  * @param {Strip | IStripParams} [options.strip] - Strip object or parameters.
36
36
  * @param {boolean} [options.independentPicking] - Independent picking flag.
37
37
  * @param {boolean} [options.relativePosition] - Parent relative position flag, otherwise position is absolute.
38
- * @param {number} [options.pitch] - Rotation around local X-axis.
39
- * @param {number} [options.yaw] - Rotation around local Y-axis.
40
- * @param {number} [options.roll] - Rotation around local Z-axis.
38
+ * @param {number} [options.pitch] - Rotation around local X-axis in radians.
39
+ * @param {number} [options.yaw] - Rotation around local Y-axis in radians.
40
+ * @param {number} [options.roll] - Rotation around local Z-axis in radians.
41
41
  * @param {number | Vec3 | NumberArray3} [options.scale] - Scaling factor.
42
- * @param {boolean} [options.forceGlobalPosition] - Forces global position for children entities make them the same position as the parent.
42
+ * @param {boolean} [options.forceGlobalPosition] - Forces global position for the entity make the same position as its parent.
43
+ * @param {boolean} [options.forceGlobalRotation] - Forces global rotation for the entity make the same rotation as its parent.
44
+ * @param {boolean} [options.forceGlobalScale] - Forces global scale for the entity make the same scale as its parent.
43
45
  */
44
46
  class Entity {
45
47
  constructor(options = {}) {
@@ -50,6 +52,8 @@ class Entity {
50
52
  this.childEntities = [];
51
53
  this.parent = null;
52
54
  this.forceGlobalPosition = options.forceGlobalPosition || false;
55
+ this.forceGlobalRotation = options.forceGlobalRotation || false;
56
+ this.forceGlobalScale = options.forceGlobalScale || false;
53
57
  this._cartesian = utils.createVector3(options.cartesian);
54
58
  this._rootCartesian = new Vec3();
55
59
  this._localPosition = utils.createVector3(options.localPosition);
@@ -65,12 +69,9 @@ class Entity {
65
69
  this._pickingColor = new Vec3(0, 0, 0);
66
70
  this._independentPicking = options.independentPicking || false;
67
71
  this._relativePosition = options.relativePosition || false;
68
- this._pitch = options.pitch || 0;
69
- this._yaw = options.yaw || 0;
70
- this._roll = options.roll || 0;
71
- this._pitchRad = this._pitch * RADIANS;
72
- this._yawRad = this._yaw * RADIANS;
73
- this._rollRad = this._roll * RADIANS;
72
+ this._pitchRad = options.pitch || 0;
73
+ this._yawRad = options.yaw || 0;
74
+ this._rollRad = options.roll || 0;
74
75
  this._scale = utils.createVector3(options.scale, new Vec3(1, 1, 1));
75
76
  this._qFrame = Quat.IDENTITY;
76
77
  this._qRot = Quat.IDENTITY;
@@ -270,7 +271,13 @@ class Entity {
270
271
  this._scale.copy(scale);
271
272
  this.geoObject && this.geoObject.setScale3v(this._scale);
272
273
  for (let i = 0; i < this.childEntities.length; i++) {
273
- this.childEntities[i].setScale3v(this.childEntities[i].getScale());
274
+ let chi = this.childEntities[i];
275
+ if (chi.forceGlobalScale) {
276
+ chi.setScale3v(this._scale);
277
+ }
278
+ else {
279
+ chi.setScale3v(this.childEntities[i].getScale());
280
+ }
274
281
  }
275
282
  }
276
283
  /**
@@ -282,7 +289,13 @@ class Entity {
282
289
  this._scale.set(val, val, val);
283
290
  this.geoObject && this.geoObject.setScale(val);
284
291
  for (let i = 0; i < this.childEntities.length; i++) {
285
- this.childEntities[i].setScale3v(this.childEntities[i].getScale());
292
+ let chi = this.childEntities[i];
293
+ if (chi.forceGlobalScale) {
294
+ chi.setScale(val);
295
+ }
296
+ else {
297
+ chi.setScale3v(this.childEntities[i].getScale());
298
+ }
286
299
  }
287
300
  }
288
301
  /**
@@ -351,64 +364,61 @@ class Entity {
351
364
  }
352
365
  /**
353
366
  * Sets the pitch rotation of the entity.
354
- * @param {number} val - The new pitch angle in degrees.
367
+ * @param {number} val - The new pitch angle in radians.
355
368
  */
356
369
  setPitch(val) {
357
- this._pitch = val;
358
- this._pitchRad = val * RADIANS;
370
+ this._pitchRad = val;
359
371
  this._updateAbsolutePosition();
360
372
  }
361
373
  /**
362
374
  * Sets the yaw rotation of the entity.
363
- * @param {number} val - The new yaw angle in degrees.
375
+ * @param {number} val - The new yaw angle in radians.
364
376
  */
365
377
  setYaw(val) {
366
- this._yaw = val;
367
- this._yawRad = val * RADIANS;
378
+ this._yawRad = val;
368
379
  this._updateAbsolutePosition();
369
380
  }
370
381
  /**
371
382
  * Sets the roll rotation of the entity.
372
383
  * @public
373
- * @param {number} val - The new roll angle in degrees.
384
+ * @param {number} val - The new roll angle in radians.
374
385
  */
375
386
  setRoll(val) {
376
- this._roll = val;
377
- this._rollRad = val * RADIANS;
387
+ this._rollRad = val;
378
388
  this._updateAbsolutePosition();
379
389
  }
380
390
  /**
381
391
  * Gets the pitch angle of the entity.
382
392
  * @public
383
- * @returns {number} The pitch angle in degrees.
393
+ * @returns {number} The pitch angle in radians.
384
394
  */
385
395
  getPitch() {
386
- return this._pitch;
396
+ return this._pitchRad;
387
397
  }
388
398
  /**
389
399
  * Gets the yaw angle of the entity.
390
400
  * @public
391
- * @returns {number} The yaw angle in degrees.
401
+ * @returns {number} The yaw angle in radians.
392
402
  */
393
403
  getYaw() {
394
- return this._yaw;
404
+ return this._yawRad;
395
405
  }
396
406
  /**
397
407
  * Gets the roll angle of the entity.
398
408
  * @public
399
- * @returns {number} The roll angle in degrees.
409
+ * @returns {number} The roll angle in radians.
400
410
  */
401
411
  getRoll() {
402
- return this._roll;
412
+ return this._rollRad;
403
413
  }
404
414
  /**
405
415
  * Sets the absolute pitch of the entity.
406
416
  * @public
407
- * @param {number} val - The absolute pitch angle in degrees.
417
+ * @param {number} val - The absolute pitch angle in radians.
408
418
  */
409
419
  setAbsolutePitch(val) {
410
420
  if (this._relativePosition) {
411
- this._absoluteQRot.setPitchYawRoll(val * RADIANS, this.getAbsoluteYaw() * RADIANS, this.getAbsoluteRoll() * RADIANS, this._qFrame);
421
+ this._absoluteQRot.setPitchYawRoll(val, this.getAbsoluteYaw(), this.getAbsoluteRoll(), this._qFrame);
412
422
  this._updatePitchYawRoll();
413
423
  }
414
424
  else {
@@ -418,11 +428,11 @@ class Entity {
418
428
  /**
419
429
  * Sets the absolute yaw of the entity.
420
430
  * @public
421
- * @param {number} val - The absolute yaw angle in degrees.
431
+ * @param {number} val - The absolute yaw angle in radians.
422
432
  */
423
433
  setAbsoluteYaw(val) {
424
434
  if (this._relativePosition) {
425
- this._absoluteQRot.setPitchYawRoll(this.getAbsolutePitch() * RADIANS, val * RADIANS, this.getAbsoluteRoll() * RADIANS, this._qFrame);
435
+ this._absoluteQRot.setPitchYawRoll(this.getAbsolutePitch(), val, this.getAbsoluteRoll(), this._qFrame);
426
436
  this._updatePitchYawRoll();
427
437
  }
428
438
  else {
@@ -432,11 +442,11 @@ class Entity {
432
442
  /**
433
443
  * Sets the absolute roll of the entity.
434
444
  * @public
435
- * @param {number} val - The absolute roll angle in degrees.
445
+ * @param {number} val - The absolute roll angle in radians.
436
446
  */
437
447
  setAbsoluteRoll(val) {
438
448
  if (this._relativePosition) {
439
- this._absoluteQRot.setPitchYawRoll(this.getAbsolutePitch() * RADIANS, this.getAbsoluteYaw() * RADIANS, val * RADIANS, this._qFrame);
449
+ this._absoluteQRot.setPitchYawRoll(this.getAbsolutePitch(), this.getAbsoluteYaw(), val, this._qFrame);
440
450
  this._updatePitchYawRoll();
441
451
  }
442
452
  else {
@@ -446,35 +456,35 @@ class Entity {
446
456
  /**
447
457
  * Gets the absolute pitch angle of the entity.
448
458
  * @public
449
- * @returns {number} The absolute pitch angle in degrees.
459
+ * @returns {number} The absolute pitch angle in radians.
450
460
  */
451
461
  getAbsolutePitch() {
452
462
  if (this.parent && this._relativePosition) {
453
- return this._qFrame.conjugate().inverse().mul(this._absoluteQRot).getPitch() * DEGREES;
463
+ return this._qFrame.conjugate().inverse().mul(this._absoluteQRot).getPitch();
454
464
  }
455
- return this._pitch;
465
+ return this._pitchRad;
456
466
  }
457
467
  /**
458
468
  * Gets the absolute yaw angle of the entity.
459
469
  * @public
460
- * @returns {number} The absolute yaw angle in degrees.
470
+ * @returns {number} The absolute yaw angle in radians.
461
471
  */
462
472
  getAbsoluteYaw() {
463
473
  if (this.parent && this._relativePosition) {
464
- return this._qFrame.conjugate().inverse().mul(this._absoluteQRot).getYaw() * DEGREES;
474
+ return this._qFrame.conjugate().inverse().mul(this._absoluteQRot).getYaw();
465
475
  }
466
- return this._yaw;
476
+ return this._yawRad;
467
477
  }
468
478
  /**
469
479
  * Gets the absolute roll angle of the entity.
470
480
  * @public
471
- * @returns {number} The absolute roll angle in degrees.
481
+ * @returns {number} The absolute roll angle in radians.
472
482
  */
473
483
  getAbsoluteRoll() {
474
484
  if (this.parent && this._relativePosition) {
475
- return this._qFrame.conjugate().inverse().mul(this._absoluteQRot).getRoll() * DEGREES;
485
+ return this._qFrame.conjugate().inverse().mul(this._absoluteQRot).getRoll();
476
486
  }
477
- return this._roll;
487
+ return this._rollRad;
478
488
  }
479
489
  _getScaleByDistance() {
480
490
  let scd = 1;
@@ -553,9 +563,9 @@ class Entity {
553
563
  this._pitchRad = this._qRot.getPitch();
554
564
  this._yawRad = this._qRot.getYaw();
555
565
  this._rollRad = this._qRot.getRoll();
556
- this._pitch = this._pitchRad * DEGREES;
557
- this._yaw = this._yawRad * DEGREES;
558
- this._roll = this._rollRad * DEGREES;
566
+ // this._pitch = this._pitchRad * DEGREES;
567
+ // this._yaw = this._yawRad * DEGREES;
568
+ // this._roll = this._rollRad * DEGREES;
559
569
  if (this.geoObject) {
560
570
  this.geoObject.setRotation(this._absoluteQRot);
561
571
  }
@@ -579,7 +589,12 @@ class Entity {
579
589
  if (this._entityCollection && this._entityCollection.renderNode) {
580
590
  this._qFrame = this._entityCollection.renderNode.getFrameRotation(this._cartesian);
581
591
  }
582
- this._qRot.setPitchYawRoll(this._pitchRad, this._yawRad, this._rollRad, this._qFrame);
592
+ if (parent && this.forceGlobalRotation) {
593
+ this._qRot.setPitchYawRoll(parent._pitchRad, parent._yawRad, parent._rollRad, this._qFrame);
594
+ }
595
+ else {
596
+ this._qRot.setPitchYawRoll(this._pitchRad, this._yawRad, this._rollRad, this._qFrame);
597
+ }
583
598
  this._absoluteQRot.copy(this._qRot);
584
599
  this._rootCartesian.copy(this._cartesian);
585
600
  this._absoluteLocalPosition.copy(this._localPosition);
@@ -13,9 +13,6 @@ export declare const LOCAL_FORWARD: Vec3;
13
13
  * @property {string} [objSrc] - Source url of the 3D object.
14
14
  * @property {string} [tag] - Unique instancing drawing identifier tag.
15
15
  * @property {Vec3 | NumberArray3} [position] - Position in Cartesian coordinates.
16
- * @property {number} [pitch] - Rotation around X-axis in degrees.
17
- * @property {number} [yaw] - Rotation around Y-axis in degrees.
18
- * @property {number} [roll] - Rotation around Z-axis in degrees.
19
16
  * @property {number | Vec3 | NumberArray3} [scale] - Scale of the object.
20
17
  * @property {Vec3 | NumberArray3} [translate] - Translation offset.
21
18
  * @property {Vec4 | NumberArray4 | string} [color] - RGBA color or HTML color string.
@@ -26,9 +23,6 @@ export interface IGeoObjectParams {
26
23
  objSrc?: string;
27
24
  tag?: string;
28
25
  position?: Vec3 | NumberArray3;
29
- pitch?: number;
30
- yaw?: number;
31
- roll?: number;
32
26
  scale?: number | Vec3 | NumberArray3;
33
27
  translate?: Vec3 | NumberArray3;
34
28
  color?: Vec4 | NumberArray4 | string;
@@ -42,9 +36,6 @@ export interface IGeoObjectParams {
42
36
  * @param {string} [options.objSrc] - Source url of the 3D object.
43
37
  * @param {string} [options.tag] - Unique instancing drawing identifier tag.
44
38
  * @param {Vec3 | NumberArray3} [options.position] - Position in Cartesian coordinates.
45
- * @param {number} [options.pitch=0] - Rotation around X-axis in degrees.
46
- * @param {number} [options.yaw=0] - Rotation around Y-axis in degrees.
47
- * @param {number} [options.roll=0] - Rotation around Z-axis in degrees.
48
39
  * @param {number | Vec3 | NumberArray3} [options.scale=1] - Scale of the object.
49
40
  * @param {Vec3 | NumberArray3} [options.translate] - Translation offset.
50
41
  * @param {Vec4 | NumberArray4 | string} [options.color] - RGBA color or HTML color string.
@@ -10,9 +10,6 @@ export const LOCAL_FORWARD = new Vec3(0.0, 0.0, -1.0);
10
10
  * @param {string} [options.objSrc] - Source url of the 3D object.
11
11
  * @param {string} [options.tag] - Unique instancing drawing identifier tag.
12
12
  * @param {Vec3 | NumberArray3} [options.position] - Position in Cartesian coordinates.
13
- * @param {number} [options.pitch=0] - Rotation around X-axis in degrees.
14
- * @param {number} [options.yaw=0] - Rotation around Y-axis in degrees.
15
- * @param {number} [options.roll=0] - Rotation around Z-axis in degrees.
16
13
  * @param {number | Vec3 | NumberArray3} [options.scale=1] - Scale of the object.
17
14
  * @param {Vec3 | NumberArray3} [options.translate] - Translation offset.
18
15
  * @param {Vec4 | NumberArray4 | string} [options.color] - RGBA color or HTML color string.