@openglobus/og 0.21.0 → 0.22.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.
Files changed (133) hide show
  1. package/LICENSE.md +2 -2
  2. package/lib/@openglobus/js/Globe.d.ts +4 -0
  3. package/lib/@openglobus/js/Object3d.d.ts +7 -2
  4. package/lib/@openglobus/js/camera/Camera.d.ts +2 -0
  5. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +58 -0
  6. package/lib/@openglobus/js/ellipsoid/Ellipsoid.d.ts +2 -1
  7. package/lib/@openglobus/js/ellipsoid/index.d.ts +4 -3
  8. package/lib/@openglobus/js/ellipsoid/mars.d.ts +6 -0
  9. package/lib/@openglobus/js/ellipsoid/moon.d.ts +6 -0
  10. package/lib/@openglobus/js/entity/Entity.d.ts +4 -2
  11. package/lib/@openglobus/js/entity/EntityCollection.d.ts +3 -2
  12. package/lib/@openglobus/js/entity/GeoObject.d.ts +6 -1
  13. package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +4 -0
  14. package/lib/@openglobus/js/entity/Label.d.ts +14 -0
  15. package/lib/@openglobus/js/entity/LabelHandler.d.ts +1 -1
  16. package/lib/@openglobus/js/index.d.ts +3 -3
  17. package/lib/@openglobus/js/layer/Vector.d.ts +12 -29
  18. package/lib/@openglobus/js/proj/equi.d.ts +9 -0
  19. package/lib/@openglobus/js/quadTree/{EPSG4326QuadTreeStrategy.d.ts → EPSG4326/EPSG4326QuadTreeStrategy.d.ts} +2 -2
  20. package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +5 -13
  21. package/lib/@openglobus/js/quadTree/EntityCollectionsTreeStrategy.d.ts +25 -0
  22. package/lib/@openglobus/js/quadTree/QuadTreeStrategy.d.ts +11 -0
  23. package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +18 -0
  24. package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionsTreeStrategy.d.ts +19 -0
  25. package/lib/@openglobus/js/quadTree/earth/EarthQuadTreeStrategy.d.ts +29 -0
  26. package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +17 -0
  27. package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionsTreeStrategy.d.ts +17 -0
  28. package/lib/@openglobus/js/quadTree/equi/EquiQuadTreeStrategy.d.ts +19 -0
  29. package/lib/@openglobus/js/quadTree/index.d.ts +6 -6
  30. package/lib/{js/quadTree → @openglobus/js/quadTree/wgs84}/Wgs84QuadTreeStrategy.d.ts +2 -2
  31. package/lib/@openglobus/js/renderer/Renderer.d.ts +2 -0
  32. package/lib/@openglobus/js/scene/Planet.d.ts +0 -27
  33. package/lib/@openglobus/js/segment/Segment.d.ts +0 -1
  34. package/lib/@openglobus/js/segment/SegmentLonLat.d.ts +0 -4
  35. package/lib/@openglobus/js/segment/{SegmentLonLatWgs84.d.ts → SegmentLonLatEqui.d.ts} +4 -1
  36. package/lib/@openglobus/js/terrain/RgbTerrain.d.ts +11 -0
  37. package/lib/@openglobus/og.esm.js +1 -1
  38. package/lib/@openglobus/og.esm.js.map +1 -1
  39. package/lib/@openglobus/og.umd.js +1 -1
  40. package/lib/@openglobus/og.umd.js.map +1 -1
  41. package/lib/@openglobus/res/fonts/Ephesis-Regular.json +4648 -0
  42. package/lib/@openglobus/res/fonts/Ephesis-Regular.ttf.cfg +1282 -0
  43. package/lib/@openglobus/res/fonts/Ephesis-Regular.ttf.png +0 -0
  44. package/lib/js/Globe.d.ts +4 -0
  45. package/lib/js/Globe.js +8 -4
  46. package/lib/js/Object3d.d.ts +7 -2
  47. package/lib/js/Object3d.js +46 -6
  48. package/lib/js/camera/Camera.d.ts +2 -0
  49. package/lib/js/camera/Camera.js +8 -0
  50. package/lib/js/control/elevationProfile/ElevationProfileScene.js +2 -0
  51. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +58 -0
  52. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +105 -0
  53. package/lib/js/ellipsoid/Ellipsoid.d.ts +2 -1
  54. package/lib/js/ellipsoid/Ellipsoid.js +17 -1
  55. package/lib/js/ellipsoid/index.d.ts +4 -3
  56. package/lib/js/ellipsoid/index.js +4 -3
  57. package/lib/js/ellipsoid/mars.d.ts +6 -0
  58. package/lib/js/ellipsoid/mars.js +6 -0
  59. package/lib/js/ellipsoid/moon.d.ts +6 -0
  60. package/lib/js/ellipsoid/moon.js +6 -0
  61. package/lib/js/entity/Entity.d.ts +4 -2
  62. package/lib/js/entity/Entity.js +4 -1
  63. package/lib/js/entity/EntityCollection.d.ts +3 -2
  64. package/lib/js/entity/EntityCollection.js +26 -2
  65. package/lib/js/entity/GeoObject.d.ts +6 -1
  66. package/lib/js/entity/GeoObject.js +9 -0
  67. package/lib/js/entity/GeoObjectHandler.d.ts +4 -0
  68. package/lib/js/entity/GeoObjectHandler.js +32 -1
  69. package/lib/js/entity/GeometryHandler.js +16 -14
  70. package/lib/js/entity/Label.d.ts +14 -0
  71. package/lib/js/entity/Label.js +24 -4
  72. package/lib/js/entity/LabelHandler.d.ts +1 -1
  73. package/lib/js/entity/LabelHandler.js +4 -4
  74. package/lib/js/entity/Polyline.js +1 -1
  75. package/lib/js/index.d.ts +3 -3
  76. package/lib/js/index.js +3 -3
  77. package/lib/js/layer/CanvasTiles.js +1 -11
  78. package/lib/js/layer/Layer.js +9 -28
  79. package/lib/js/layer/Vector.d.ts +12 -29
  80. package/lib/js/layer/Vector.js +45 -160
  81. package/lib/js/layer/XYZ.js +10 -10
  82. package/lib/js/proj/equi.d.ts +9 -0
  83. package/lib/js/proj/equi.js +9 -0
  84. package/lib/js/quadTree/{EPSG4326QuadTreeStrategy.d.ts → EPSG4326/EPSG4326QuadTreeStrategy.d.ts} +2 -2
  85. package/lib/js/quadTree/EPSG4326/EPSG4326QuadTreeStrategy.js +16 -0
  86. package/lib/js/quadTree/EntityCollectionNode.d.ts +5 -13
  87. package/lib/js/quadTree/EntityCollectionNode.js +18 -83
  88. package/lib/js/quadTree/EntityCollectionsTreeStrategy.d.ts +25 -0
  89. package/lib/js/quadTree/EntityCollectionsTreeStrategy.js +49 -0
  90. package/lib/js/quadTree/Node.js +6 -12
  91. package/lib/js/quadTree/QuadTreeStrategy.d.ts +11 -0
  92. package/lib/js/quadTree/QuadTreeStrategy.js +12 -0
  93. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +18 -0
  94. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +74 -0
  95. package/lib/js/quadTree/earth/EarthEntityCollectionsTreeStrategy.d.ts +19 -0
  96. package/lib/js/quadTree/earth/EarthEntityCollectionsTreeStrategy.js +103 -0
  97. package/lib/js/quadTree/earth/EarthQuadTreeStrategy.d.ts +29 -0
  98. package/lib/js/quadTree/{EarthQuadTreeStrategy.js → earth/EarthQuadTreeStrategy.js} +29 -6
  99. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +17 -0
  100. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +70 -0
  101. package/lib/js/quadTree/equi/EquiEntityCollectionsTreeStrategy.d.ts +17 -0
  102. package/lib/js/quadTree/equi/EquiEntityCollectionsTreeStrategy.js +75 -0
  103. package/lib/js/quadTree/equi/EquiQuadTreeStrategy.d.ts +19 -0
  104. package/lib/js/quadTree/equi/EquiQuadTreeStrategy.js +62 -0
  105. package/lib/js/quadTree/index.d.ts +6 -6
  106. package/lib/js/quadTree/index.js +6 -6
  107. package/lib/{@openglobus/js/quadTree → js/quadTree/wgs84}/Wgs84QuadTreeStrategy.d.ts +2 -2
  108. package/lib/js/quadTree/wgs84/Wgs84QuadTreeStrategy.js +15 -0
  109. package/lib/js/renderer/Renderer.d.ts +2 -0
  110. package/lib/js/renderer/Renderer.js +2 -2
  111. package/lib/js/scene/Planet.d.ts +0 -27
  112. package/lib/js/scene/Planet.js +2 -9
  113. package/lib/js/segment/Segment.d.ts +0 -1
  114. package/lib/js/segment/Segment.js +0 -3
  115. package/lib/js/segment/SegmentLonLat.d.ts +0 -4
  116. package/lib/js/segment/SegmentLonLat.js +0 -11
  117. package/lib/js/segment/{SegmentLonLatWgs84.d.ts → SegmentLonLatEqui.d.ts} +4 -1
  118. package/lib/js/segment/SegmentLonLatEqui.js +46 -0
  119. package/lib/js/shaders/geoObject.js +10 -5
  120. package/lib/js/shaders/polyline.js +8 -6
  121. package/lib/js/terrain/RgbTerrain.d.ts +11 -0
  122. package/lib/js/terrain/RgbTerrain.js +12 -1
  123. package/lib/js/utils/PlainSegmentWorker.js +3 -1
  124. package/lib/js/webgl/Handler.js +1 -1
  125. package/package.json +4 -4
  126. package/lib/@openglobus/js/quadTree/EarthQuadTreeStrategy.d.ts +0 -9
  127. package/lib/@openglobus/js/quadTree/MarsQuadTreeStrategy.d.ts +0 -11
  128. package/lib/js/quadTree/EPSG4326QuadTreeStrategy.js +0 -16
  129. package/lib/js/quadTree/EarthQuadTreeStrategy.d.ts +0 -9
  130. package/lib/js/quadTree/MarsQuadTreeStrategy.d.ts +0 -11
  131. package/lib/js/quadTree/MarsQuadTreeStrategy.js +0 -43
  132. package/lib/js/quadTree/Wgs84QuadTreeStrategy.js +0 -15
  133. package/lib/js/segment/SegmentLonLatWgs84.js +0 -25
package/lib/js/Globe.d.ts CHANGED
@@ -45,6 +45,8 @@ export interface IGlobeParams {
45
45
  fontsSrc?: string;
46
46
  resourcesSrc?: string;
47
47
  atmosphereParameters?: IAtmosphereParams;
48
+ gamma?: number;
49
+ exposure?: number;
48
50
  }
49
51
  /**
50
52
  * Creates a WebGL context with globe.
@@ -97,6 +99,8 @@ export interface IGlobeParams {
97
99
  * @param {boolean} [options.atmosphereEnabled] - Enables atmosphere effect.
98
100
  * @param {boolean} [options.transtitionOpacityEnabled] - Enables terrain smooth opacity transition effect.
99
101
  * @param {IAtmosphereParams} [options.atmosphereParameters] - Atmosphere model parameters.
102
+ * @param {number} [options.gamma] - Gamma
103
+ * @param {number} [options.exposure] - Exposure
100
104
  */
101
105
  declare class Globe {
102
106
  static __counter__: number;
package/lib/js/Globe.js CHANGED
@@ -68,6 +68,8 @@ const PLANET_NAME_PREFIX = "globus_planet_";
68
68
  * @param {boolean} [options.atmosphereEnabled] - Enables atmosphere effect.
69
69
  * @param {boolean} [options.transtitionOpacityEnabled] - Enables terrain smooth opacity transition effect.
70
70
  * @param {IAtmosphereParams} [options.atmosphereParameters] - Atmosphere model parameters.
71
+ * @param {number} [options.gamma] - Gamma
72
+ * @param {number} [options.exposure] - Exposure
71
73
  */
72
74
  class Globe {
73
75
  constructor(options) {
@@ -126,7 +128,9 @@ class Globe {
126
128
  }), {
127
129
  autoActivate: false,
128
130
  msaa: options.msaa,
129
- fontsSrc: options.fontsSrc
131
+ fontsSrc: options.fontsSrc,
132
+ gamma: options.gamma,
133
+ exposure: options.exposure,
130
134
  });
131
135
  this.renderer.div = this.$inner;
132
136
  // Skybox
@@ -139,8 +143,8 @@ class Globe {
139
143
  frustums: options.frustums,
140
144
  ellipsoid: options.ellipsoid,
141
145
  maxGridSize: options.maxGridSize,
142
- nightTextureSrc: options.nightTextureSrc === null ? null : `${options.resourcesSrc || DEFAULT_RESOURCES_SRC}${DEFAULT_NIGHT_SRC}`,
143
- specularTextureSrc: options.specularTextureSrc === null ? null : `${options.resourcesSrc || DEFAULT_RESOURCES_SRC}${DEFAULT_SPEC_SRC}`,
146
+ nightTextureSrc: options.nightTextureSrc === null ? null : options.nightTextureSrc || `${options.resourcesSrc || DEFAULT_RESOURCES_SRC}${DEFAULT_NIGHT_SRC}`,
147
+ specularTextureSrc: options.specularTextureSrc === null ? null : options.specularTextureSrc || `${options.resourcesSrc || DEFAULT_RESOURCES_SRC}${DEFAULT_SPEC_SRC}`,
144
148
  minAltitude: options.minAltitude,
145
149
  maxAltitude: options.maxAltitude || 15000000,
146
150
  maxEqualZoomAltitude: options.maxEqualZoomAltitude,
@@ -150,7 +154,7 @@ class Globe {
150
154
  maxLoadingRequests: options.maxLoadingRequests,
151
155
  atmosphereEnabled: options.atmosphereEnabled,
152
156
  transitionOpacityEnabled: options.transitionOpacityEnabled,
153
- atmosphereParameters: options.atmosphereParameters
157
+ atmosphereParameters: options.atmosphereParameters,
154
158
  });
155
159
  // Attach terrain provider (can be one object or array)
156
160
  if (options.terrain) {
@@ -1,5 +1,6 @@
1
1
  import { TypedArray } from './utils/shared';
2
2
  import { NumberArray3, Vec3 } from './math/Vec3';
3
+ import { Mat4 } from "./math/Mat4";
3
4
  interface IObject3dParams {
4
5
  name?: string;
5
6
  vertices?: number[];
@@ -9,7 +10,7 @@ interface IObject3dParams {
9
10
  center?: boolean;
10
11
  src?: string;
11
12
  color?: number[] | TypedArray | string;
12
- scale?: number;
13
+ scale?: number | Vec3;
13
14
  }
14
15
  declare class Object3d {
15
16
  protected _name: string;
@@ -27,6 +28,10 @@ declare class Object3d {
27
28
  protected _normals: number[];
28
29
  constructor(data?: IObject3dParams);
29
30
  static centering(verts: number[]): void;
31
+ centering(): this;
32
+ applyMat4(m: Mat4): this;
33
+ scale(s: Vec3): this;
34
+ translate(v: Vec3): this;
30
35
  get src(): string | null;
31
36
  set src(src: string | null);
32
37
  get name(): string;
@@ -35,7 +40,7 @@ declare class Object3d {
35
40
  get indices(): number[];
36
41
  get texCoords(): number[];
37
42
  get numVertices(): number;
38
- static scale(vertices: number[], s: number): void;
43
+ static scale(vertices: number[], s: Vec3): void;
39
44
  static centroid(vertices: number[]): number[];
40
45
  static translate(vertices: number[], v: NumberArray3): void;
41
46
  static getNormals(vertices: number[]): number[];
@@ -28,7 +28,15 @@ class Object3d {
28
28
  this._src = data.src || null;
29
29
  this.color = getColor(data.color);
30
30
  if (data.scale) {
31
- Object3d.scale(this._vertices, data.scale);
31
+ let s = data.scale;
32
+ let scale;
33
+ if (typeof s === 'number') {
34
+ scale = new Vec3(s, s, s);
35
+ }
36
+ else {
37
+ scale = s;
38
+ }
39
+ Object3d.scale(this._vertices, scale);
32
40
  }
33
41
  if (data.indices) {
34
42
  this._indices = data.indices;
@@ -68,6 +76,36 @@ class Object3d {
68
76
  verts[i + 2] -= c_z;
69
77
  }
70
78
  }
79
+ centering() {
80
+ Object3d.centering(this._vertices);
81
+ return this;
82
+ }
83
+ applyMat4(m) {
84
+ for (let i = 0, len = this._vertices.length; i < len; i += 3) {
85
+ let v = new Vec3(this._vertices[i], this._vertices[i + 1], this._vertices[i + 2]), n = new Vec3(this._normals[i], this._normals[i + 1], this._normals[i + 2]);
86
+ v = m.mulVec3(v);
87
+ n = m.mulVec3(n);
88
+ this._vertices[i] = v.x;
89
+ this._vertices[i + 1] = v.y;
90
+ this._vertices[i + 2] = v.z;
91
+ this._normals[i] = n.x;
92
+ this._normals[i + 1] = n.y;
93
+ this._normals[i + 2] = n.z;
94
+ }
95
+ return this;
96
+ }
97
+ scale(s) {
98
+ Object3d.scale(this._vertices, s);
99
+ return this;
100
+ }
101
+ translate(v) {
102
+ for (let i = 0, len = this._vertices.length; i < len; i += 3) {
103
+ this._vertices[i] += v.x;
104
+ this._vertices[i + 1] += v.y;
105
+ this._vertices[i + 2] += v.z;
106
+ }
107
+ return this;
108
+ }
71
109
  get src() {
72
110
  return this._src;
73
111
  }
@@ -93,8 +131,10 @@ class Object3d {
93
131
  return this._numVertices;
94
132
  }
95
133
  static scale(vertices, s) {
96
- for (let i = 0; i < vertices.length; i++) {
97
- vertices[i] *= s;
134
+ for (let i = 0; i < vertices.length; i += 3) {
135
+ vertices[i] *= s.x;
136
+ vertices[i + 1] *= s.y;
137
+ vertices[i + 2] *= s.z;
98
138
  }
99
139
  }
100
140
  static centroid(vertices) {
@@ -118,9 +158,9 @@ class Object3d {
118
158
  }
119
159
  static translate(vertices, v) {
120
160
  for (let i = 0; i < vertices.length; i += 3) {
121
- vertices[i] -= v[0];
122
- vertices[i + 1] -= v[1];
123
- vertices[i + 2] -= v[2];
161
+ vertices[i] += v[0];
162
+ vertices[i + 1] += v[1];
163
+ vertices[i + 2] += v[2];
124
164
  }
125
165
  }
126
166
  static getNormals(vertices) {
@@ -5,6 +5,7 @@ import { Mat4, NumberArray16 } from "../math/Mat4";
5
5
  import { Renderer } from "../renderer/Renderer";
6
6
  import { Vec2, NumberArray2 } from "../math/Vec2";
7
7
  import { Vec3 } from "../math/Vec3";
8
+ import { Sphere } from "../bv/Sphere";
8
9
  type CameraEvents = ["viewchange", "moveend"];
9
10
  export interface ICameraParams {
10
11
  eye?: Vec3;
@@ -285,6 +286,7 @@ declare class Camera {
285
286
  getNormalMatrix(): NumberArray9;
286
287
  setCurrentFrustum(k: number): void;
287
288
  getCurrentFrustum(): number;
289
+ containsSphere(sphere: Sphere): boolean;
288
290
  get frustum(): Frustum;
289
291
  /**
290
292
  * Returns projection matrix.
@@ -414,6 +414,14 @@ class Camera {
414
414
  getCurrentFrustum() {
415
415
  return this.currentFrustumIndex;
416
416
  }
417
+ containsSphere(sphere) {
418
+ for (let i = 0; i < this.frustums.length; i++) {
419
+ if (this.frustums[i].containsSphere(sphere)) {
420
+ return true;
421
+ }
422
+ }
423
+ return false;
424
+ }
417
425
  get frustum() {
418
426
  return this.frustums[this.currentFrustumIndex];
419
427
  }
@@ -24,6 +24,7 @@ const POINTER_BILLBOARD_OPTIONS = {
24
24
  };
25
25
  const POINTER_LABEL_OPTIONS = {
26
26
  text: "",
27
+ face: "arial",
27
28
  size: 10.5,
28
29
  color: "rgba(455,455,455,1.0)",
29
30
  outlineColor: "rgba(0,0,0,0.34)",
@@ -32,6 +33,7 @@ const POINTER_LABEL_OPTIONS = {
32
33
  offset: [5, 15, -5]
33
34
  };
34
35
  const LABEL_OPTIONS = {
36
+ face: "arial",
35
37
  text: "",
36
38
  size: 10.5,
37
39
  color: "rgba(455,455,455,1.0)",
@@ -0,0 +1,58 @@
1
+ import { EventsHandler } from '../../Events';
2
+ import { Planet } from "../../scene/Planet";
3
+ import { RenderNode } from '../../scene/RenderNode';
4
+ import { Vector } from '../../layer/Vector';
5
+ import { Vec2 } from '../../math/Vec2';
6
+ import { IMouseState } from "../../renderer/RendererEvents";
7
+ import { Ellipsoid } from "../../ellipsoid/Ellipsoid";
8
+ export interface IGeoObjectEditorSceneParams {
9
+ planet?: Planet;
10
+ }
11
+ type GeoObjectSceneEventsList = [
12
+ "mousemove",
13
+ "mouseenter",
14
+ "mouseleave",
15
+ "lclick",
16
+ "rclick",
17
+ "mclick",
18
+ "ldblclick",
19
+ "rdblclick",
20
+ "mdblclick",
21
+ "lup",
22
+ "rup",
23
+ "mup",
24
+ "ldown",
25
+ "rdown",
26
+ "mdown",
27
+ "lhold",
28
+ "rhold",
29
+ "mhold",
30
+ "mousewheel",
31
+ "touchmove",
32
+ "touchstart",
33
+ "touchend",
34
+ "doubletouch",
35
+ "touchleave",
36
+ "touchenter"
37
+ ];
38
+ declare class GeoObjectEditorScene extends RenderNode {
39
+ events: EventsHandler<GeoObjectSceneEventsList>;
40
+ protected _planet: Planet | null;
41
+ protected _startPos: Vec2 | null;
42
+ protected _startClick: Vec2;
43
+ protected _axisLayer: Vector;
44
+ protected _rotLayer: Vector;
45
+ constructor(options?: IGeoObjectEditorSceneParams);
46
+ init(): void;
47
+ onremove(): void;
48
+ _activate(): void;
49
+ protected _deactivate(): void;
50
+ protected _onLUp: () => void;
51
+ setVisibility(visibility: boolean): void;
52
+ protected _onLclick: (e: IMouseState) => void;
53
+ protected _onMouseMove: (e: IMouseState) => void;
54
+ clear(): void;
55
+ frame(): void;
56
+ get ellipsoid(): Ellipsoid | null;
57
+ }
58
+ export { GeoObjectEditorScene };
@@ -0,0 +1,105 @@
1
+ import { createEvents } from '../../Events';
2
+ import { Object3d } from '../../Object3d';
3
+ import { RenderNode } from '../../scene/RenderNode';
4
+ import { Vector } from '../../layer/Vector';
5
+ import { Vec2 } from '../../math/Vec2';
6
+ let obj3d = Object3d.createCylinder(1.1, 0, 2.7, 20, 1, true, false, 0, 0, 0);
7
+ class GeoObjectEditorScene extends RenderNode {
8
+ constructor(options = {}) {
9
+ super("GeoObjectEditorScene");
10
+ // protected _onCornerLdown = (e: IMouseState) => {
11
+ // this.renderer?.controls.mouseNavigation?.deactivate();
12
+ // this._startClick.set(e.x, e.y);
13
+ // let coords = e.pickingObject.getCartesian();
14
+ // this._startPos = this._planet!.getPixelFromCartesian(coords);
15
+ // }
16
+ this._onLUp = () => {
17
+ this.renderer.controls.mouseNavigation?.activate();
18
+ };
19
+ this._onLclick = (e) => {
20
+ };
21
+ this._onMouseMove = (e) => {
22
+ };
23
+ this.events = createEvents(GEOOBJECTEDITORCENE_EVENTS);
24
+ this._planet = options.planet || null;
25
+ this._startPos = null;
26
+ this._startClick = new Vec2();
27
+ this._axisLayer = new Vector("axis", {
28
+ entities: [],
29
+ pickingEnabled: false,
30
+ polygonOffsetUnits: -1.0,
31
+ relativeToGround: true,
32
+ hideInLayerSwitcher: true
33
+ });
34
+ this._rotLayer = new Vector("rotation", {
35
+ entities: [],
36
+ pickingEnabled: false,
37
+ polygonOffsetUnits: -1.0,
38
+ relativeToGround: true,
39
+ hideInLayerSwitcher: true
40
+ });
41
+ }
42
+ init() {
43
+ this._activate();
44
+ }
45
+ onremove() {
46
+ this._deactivate();
47
+ }
48
+ _activate() {
49
+ this.renderer.events.on("lclick", this._onLclick, this);
50
+ this.renderer.events.on("mousemove", this._onMouseMove, this);
51
+ this.renderer.events.on("lup", this._onLUp, this);
52
+ }
53
+ _deactivate() {
54
+ this.renderer.events.off("lclick", this._onLclick);
55
+ this.renderer.events.off("mousemove", this._onMouseMove);
56
+ this.renderer.events.off("lup", this._onLUp);
57
+ this.clear();
58
+ }
59
+ // protected _onGeoObjectEnter = (e: IMouseState) => {
60
+ // e.renderer.handler.canvas!.style.cursor = "pointer";
61
+ // }
62
+ //
63
+ // protected _onGeoObjectLeave = (e: IMouseState) => {
64
+ // e.renderer.handler.canvas!.style.cursor = "default";
65
+ // }
66
+ setVisibility(visibility) {
67
+ }
68
+ clear() {
69
+ this._planet.removeLayer(this._axisLayer);
70
+ this._planet.removeLayer(this._rotLayer);
71
+ }
72
+ frame() {
73
+ }
74
+ get ellipsoid() {
75
+ return this._planet ? this._planet.ellipsoid : null;
76
+ }
77
+ }
78
+ const GEOOBJECTEDITORCENE_EVENTS = [
79
+ "mousemove",
80
+ "mouseenter",
81
+ "mouseleave",
82
+ "lclick",
83
+ "rclick",
84
+ "mclick",
85
+ "ldblclick",
86
+ "rdblclick",
87
+ "mdblclick",
88
+ "lup",
89
+ "rup",
90
+ "mup",
91
+ "ldown",
92
+ "rdown",
93
+ "mdown",
94
+ "lhold",
95
+ "rhold",
96
+ "mhold",
97
+ "mousewheel",
98
+ "touchmove",
99
+ "touchstart",
100
+ "touchend",
101
+ "doubletouch",
102
+ "touchleave",
103
+ "touchenter"
104
+ ];
105
+ export { GeoObjectEditorScene };
@@ -98,7 +98,7 @@ declare class Ellipsoid {
98
98
  */
99
99
  lonLatToCartesianRes(lonlat: LonLat, res: Vec3): Vec3;
100
100
  /**
101
- * Gets cartesian ECEF from Wgs84 geodetic coordinates.
101
+ * Gets cartesian ECEF 3d coordinates from geodetic coordinates.
102
102
  * @public
103
103
  * @param {Number} lon - Longitude.
104
104
  * @param {Number} lat - Latitude.
@@ -189,5 +189,6 @@ declare class Ellipsoid {
189
189
  */
190
190
  static getIntermediatePointOnGreatCircle(lonLat1: LonLat, lonLat2: LonLat, fraction: number): LonLat;
191
191
  static getRhumbBearing(lonLat1: LonLat, lonLat2: LonLat): number;
192
+ getLonLatVisibilitySimple(eye: Vec3, lonLat: LonLat, forward?: Vec3): boolean;
192
193
  }
193
194
  export { Ellipsoid };
@@ -126,7 +126,7 @@ class Ellipsoid {
126
126
  return this.geodeticToCartesian(lonlat.lon, lonlat.lat, lonlat.height, res);
127
127
  }
128
128
  /**
129
- * Gets cartesian ECEF from Wgs84 geodetic coordinates.
129
+ * Gets cartesian ECEF 3d coordinates from geodetic coordinates.
130
130
  * @public
131
131
  * @param {Number} lon - Longitude.
132
132
  * @param {Number} lat - Latitude.
@@ -439,5 +439,21 @@ class Ellipsoid {
439
439
  }
440
440
  return (Math.atan2(dLon, dPhi) * DEGREES + 360) % 360;
441
441
  }
442
+ getLonLatVisibilitySimple(eye, lonLat, forward) {
443
+ const cart = this.lonLatToCartesian(lonLat);
444
+ const height = lonLat.height;
445
+ const f = this.polarSize + height;
446
+ const g = Math.max(eye.length() - this.polarSize, 0);
447
+ const look = cart.sub(eye);
448
+ let maxVisibleDistance;
449
+ if (g > 0) {
450
+ maxVisibleDistance = Math.sqrt((f + g) ** 2 - f ** 2);
451
+ }
452
+ else {
453
+ maxVisibleDistance = f;
454
+ }
455
+ return maxVisibleDistance > look.length() &&
456
+ (!forward || forward.dot(look.normalize()) > 0.0);
457
+ }
442
458
  }
443
459
  export { Ellipsoid };
@@ -1,3 +1,4 @@
1
- import { Ellipsoid } from './Ellipsoid';
2
- import { wgs84 } from './wgs84';
3
- export { Ellipsoid, wgs84 };
1
+ export * from './Ellipsoid';
2
+ export * from './wgs84';
3
+ export * from './mars';
4
+ export * from './moon';
@@ -1,3 +1,4 @@
1
- import { Ellipsoid } from './Ellipsoid';
2
- import { wgs84 } from './wgs84';
3
- export { Ellipsoid, wgs84 };
1
+ export * from './Ellipsoid';
2
+ export * from './wgs84';
3
+ export * from './mars';
4
+ export * from './moon';
@@ -0,0 +1,6 @@
1
+ import { Ellipsoid } from "./Ellipsoid";
2
+ /**
3
+ * Mars ellipsoid object.
4
+ * @type {Ellipsoid}
5
+ */
6
+ export declare const mars: Ellipsoid;
@@ -0,0 +1,6 @@
1
+ import { Ellipsoid } from "./Ellipsoid";
2
+ /**
3
+ * Mars ellipsoid object.
4
+ * @type {Ellipsoid}
5
+ */
6
+ export const mars = new Ellipsoid(3396200.0, 3389508.0);
@@ -0,0 +1,6 @@
1
+ import { Ellipsoid } from "./Ellipsoid";
2
+ /**
3
+ * Moon ellipsoid object.
4
+ * @type {Ellipsoid}
5
+ */
6
+ export declare const moon: Ellipsoid;
@@ -0,0 +1,6 @@
1
+ import { Ellipsoid } from "./Ellipsoid";
2
+ /**
3
+ * Moon ellipsoid object.
4
+ * @type {Ellipsoid}
5
+ */
6
+ export const moon = new Ellipsoid(1737400.0, 1737400.0); // Equitorial Radius (m), Polar Radius (m)
@@ -10,7 +10,7 @@ import { NumberArray2 } from "../math/Vec2";
10
10
  import { IPointCloudParams, PointCloud } from "./PointCloud";
11
11
  import { IPolylineParams, Polyline } from "./Polyline";
12
12
  import { IRayParams, Ray } from "./Ray";
13
- import { Strip } from "./Strip";
13
+ import { Strip, IStripParams } from "./Strip";
14
14
  import { Vector, VectorEventsType } from "../layer/Vector";
15
15
  import { EntityCollectionNode } from "../quadTree/EntityCollectionNode";
16
16
  export interface IEntityParams {
@@ -27,7 +27,8 @@ export interface IEntityParams {
27
27
  pointCloud?: PointCloud | IPointCloudParams;
28
28
  geometry?: Geometry | IGeometryParams;
29
29
  geoObject?: GeoObject | IGeoObjectParams;
30
- strip?: Strip;
30
+ strip?: Strip | IStripParams;
31
+ independentPicking?: boolean;
31
32
  }
32
33
  /**
33
34
  * Entity instances aggregate multiple forms of visualization into a single high-level object.
@@ -134,6 +135,7 @@ declare class Entity {
134
135
  * @type {Vec3}
135
136
  */
136
137
  _pickingColor: Vec3;
138
+ _independentPicking: boolean;
137
139
  protected _featureConstructorArray: Record<string, [any, Function]>;
138
140
  /**
139
141
  * Billboard entity.
@@ -48,6 +48,7 @@ class Entity {
48
48
  this._layer = null;
49
49
  this._layerIndex = -1;
50
50
  this._pickingColor = new Vec3(0, 0, 0);
51
+ this._independentPicking = options.independentPicking || false;
51
52
  this._featureConstructorArray = {
52
53
  billboard: [Billboard, this.setBillboard],
53
54
  label: [Label, this.setLabel],
@@ -443,7 +444,9 @@ class Entity {
443
444
  */
444
445
  appendChild(entity) {
445
446
  entity._entityCollection = this._entityCollection;
446
- entity._pickingColor = this._pickingColor;
447
+ if (!entity._independentPicking) {
448
+ entity._pickingColor = this._pickingColor;
449
+ }
447
450
  entity.parent = this;
448
451
  this.childrenNodes.push(entity);
449
452
  this._entityCollection && this._entityCollection.appendChildEntity(entity);
@@ -19,7 +19,7 @@ interface IEntityCollectionParams {
19
19
  labelMaxLetters?: number;
20
20
  pickingEnabled?: boolean;
21
21
  scaleByDistance?: NumberArray3;
22
- pickingScale?: number;
22
+ pickingScale?: number | NumberArray3;
23
23
  opacity?: number;
24
24
  useLighting?: boolean;
25
25
  entities?: Entity[];
@@ -160,7 +160,7 @@ declare class EntityCollection {
160
160
  * @type {Array.<number>} - (exactly 3 entries)
161
161
  */
162
162
  scaleByDistance: NumberArray3;
163
- pickingScale: number;
163
+ pickingScale: Float32Array;
164
164
  /**
165
165
  * Global opacity.
166
166
  * @protected
@@ -187,6 +187,7 @@ declare class EntityCollection {
187
187
  _quadNode?: EntityCollectionNode;
188
188
  _useLighting: number;
189
189
  constructor(options?: IEntityCollectionParams);
190
+ isEmpty(): boolean;
190
191
  get id(): number;
191
192
  get useLighting(): boolean;
192
193
  set useLighting(f: boolean);
@@ -75,7 +75,20 @@ class EntityCollection {
75
75
  }
76
76
  this._entities = [];
77
77
  this.scaleByDistance = options.scaleByDistance || [math.MAX32, math.MAX32, math.MAX32];
78
- this.pickingScale = options.pickingScale || 1.0;
78
+ let pickingScale = new Float32Array([1.0, 1.0, 1.0]);
79
+ if (options.pickingScale !== undefined) {
80
+ if (options.pickingScale instanceof Array) {
81
+ pickingScale[0] = options.pickingScale[0] || pickingScale[0];
82
+ pickingScale[1] = options.pickingScale[1] || pickingScale[1];
83
+ pickingScale[2] = options.pickingScale[2] || pickingScale[2];
84
+ }
85
+ else if (typeof options.pickingScale === 'number') {
86
+ pickingScale[0] = options.pickingScale;
87
+ pickingScale[1] = options.pickingScale;
88
+ pickingScale[2] = options.pickingScale;
89
+ }
90
+ }
91
+ this.pickingScale = pickingScale;
79
92
  this._opacity = options.opacity == undefined ? 1.0 : options.opacity;
80
93
  this._fadingOpacity = this._opacity;
81
94
  this.events = this.rendererEvents = createEvents(ENTITYCOLLECTION_EVENTS, this);
@@ -85,6 +98,9 @@ class EntityCollection {
85
98
  this.addEntities(options.entities);
86
99
  }
87
100
  }
101
+ isEmpty() {
102
+ return this._entities.length == 0;
103
+ }
88
104
  get id() {
89
105
  return this.__id;
90
106
  }
@@ -176,10 +192,18 @@ class EntityCollection {
176
192
  //geoObject
177
193
  entity.geoObject && this.geoObjectHandler.add(entity.geoObject);
178
194
  this.events.dispatch(this.events.entityadd, entity);
195
+ let rn = this.renderNode;
179
196
  for (let i = 0; i < entity.childrenNodes.length; i++) {
180
197
  entity.childrenNodes[i]._entityCollection = this;
181
198
  entity.childrenNodes[i]._entityCollectionIndex = entity._entityCollectionIndex;
182
- entity.childrenNodes[i]._pickingColor = entity._pickingColor;
199
+ if (entity.childrenNodes[i]._independentPicking) {
200
+ if (rn) {
201
+ rn.renderer && rn.renderer.assignPickingColor(entity.childrenNodes[i]);
202
+ }
203
+ }
204
+ else {
205
+ entity.childrenNodes[i]._pickingColor = entity._pickingColor;
206
+ }
183
207
  this._addRecursively(entity.childrenNodes[i]);
184
208
  }
185
209
  }
@@ -13,7 +13,8 @@ export interface IGeoObjectParams {
13
13
  pitch?: number;
14
14
  yaw?: number;
15
15
  roll?: number;
16
- scale?: number | Vec3;
16
+ scale?: number | Vec3 | NumberArray3;
17
+ translate?: Vec3 | NumberArray3;
17
18
  color?: Vec4 | NumberArray4 | string;
18
19
  visibility?: boolean;
19
20
  }
@@ -49,6 +50,7 @@ declare class GeoObject {
49
50
  protected _yawRad: number;
50
51
  protected _rollRad: number;
51
52
  protected _scale: Vec3;
53
+ protected _translate: Vec3;
52
54
  /**
53
55
  * RGBA color.
54
56
  * @public
@@ -66,6 +68,7 @@ declare class GeoObject {
66
68
  protected _qNorthFrame: Quat;
67
69
  private _textureSrc?;
68
70
  _objectSrc?: string;
71
+ protected _children: GeoObject[];
69
72
  constructor(options: IGeoObjectParams);
70
73
  get tag(): string;
71
74
  getPosition(): Vec3;
@@ -139,6 +142,8 @@ declare class GeoObject {
139
142
  setScale(scale: number): void;
140
143
  setScale3v(scale: Vec3): void;
141
144
  getScale(): Vec3;
145
+ setTranslate3v(translate: Vec3): void;
146
+ getTranslate(): Vec3;
142
147
  /**
143
148
  * Removes geo object from handler.
144
149
  * @public
@@ -27,6 +27,7 @@ class GeoObject {
27
27
  this._yawRad = this._yaw * RADIANS;
28
28
  this._rollRad = this._roll * RADIANS;
29
29
  this._scale = utils.createVector3(options.scale, new Vec3(1, 1, 1));
30
+ this._translate = utils.createVector3(options.translate, new Vec3());
30
31
  this._color = utils.createColorRGBA(options.color);
31
32
  this._qRot = Quat.IDENTITY;
32
33
  this._handler = null;
@@ -46,6 +47,7 @@ class GeoObject {
46
47
  this.setTextureSrc(options.textureSrc);
47
48
  }
48
49
  this._visibility = (options.visibility != undefined ? options.visibility : true);
50
+ this._children = [];
49
51
  this._direction = new Vec3();
50
52
  this._qNorthFrame = new Quat();
51
53
  }
@@ -215,6 +217,13 @@ class GeoObject {
215
217
  getScale() {
216
218
  return this._scale;
217
219
  }
220
+ setTranslate3v(translate) {
221
+ this._translate.copy(translate);
222
+ this._handler && this._handler.setTranslateArr(this._tagData, this._tagDataIndex, translate);
223
+ }
224
+ getTranslate() {
225
+ return this._translate;
226
+ }
218
227
  /**
219
228
  * Removes geo object from handler.
220
229
  * @public