@openglobus/og 0.16.2 → 0.17.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 (181) hide show
  1. package/README.md +1 -1
  2. package/css/og.css +24 -2
  3. package/dist/@openglobus/og.css +1 -1
  4. package/dist/@openglobus/og.esm.js +2 -2
  5. package/dist/@openglobus/og.esm.js.map +1 -1
  6. package/dist/@openglobus/og.umd.js +2 -2
  7. package/dist/@openglobus/og.umd.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/og/Clock.js +1 -5
  10. package/src/og/Events.js +0 -4
  11. package/src/og/Extent.js +5 -9
  12. package/src/og/Globe.js +92 -55
  13. package/src/og/ImageCanvas.js +12 -5
  14. package/src/og/Lock.js +44 -48
  15. package/src/og/LonLat.js +0 -4
  16. package/src/og/Object3d.js +1 -1
  17. package/src/og/Stack.js +49 -53
  18. package/src/og/astro/earth.js +112 -116
  19. package/src/og/astro/jd.js +514 -518
  20. package/src/og/astro/orbit.js +119 -123
  21. package/src/og/astro/rotation.js +36 -40
  22. package/src/og/bv/Box.js +77 -81
  23. package/src/og/bv/Sphere.js +57 -61
  24. package/src/og/camera/Camera.js +20 -7
  25. package/src/og/camera/PlanetCamera.js +8 -15
  26. package/src/og/control/Atmosphere.js +0 -4
  27. package/src/og/control/Control.js +9 -8
  28. package/src/og/control/DebugInfo.js +0 -4
  29. package/src/og/control/DrawingSwitcher.js +117 -0
  30. package/src/og/control/EarthCoordinates.js +214 -214
  31. package/src/og/control/GeoImageDragControl.js +0 -4
  32. package/src/og/control/KeyboardNavigation.js +0 -4
  33. package/src/og/control/LayerAnimation.js +0 -4
  34. package/src/og/control/LayerSwitcher.js +2 -4
  35. package/src/og/control/Lighting.js +11 -15
  36. package/src/og/control/MouseNavigation.js +0 -4
  37. package/src/og/control/MouseWheelZoomControl.js +0 -4
  38. package/src/og/control/RulerSwitcher.js +0 -4
  39. package/src/og/control/ScaleControl.js +2 -6
  40. package/src/og/control/ShowFps.js +40 -44
  41. package/src/og/control/SimpleNavigation.js +10 -10
  42. package/src/og/control/SimpleSkyBackground.js +0 -4
  43. package/src/og/control/Sun.js +0 -4
  44. package/src/og/control/ToggleWireframe.js +35 -39
  45. package/src/og/control/ZoomControl.js +0 -4
  46. package/src/og/control/drawing/DrawingControl.js +51 -0
  47. package/src/og/control/drawing/LineStringDrawingScene.js +203 -0
  48. package/src/og/control/drawing/PolygonDrawingScene.js +785 -0
  49. package/src/og/control/elevationProfile/ElevationProfile.js +275 -0
  50. package/src/og/control/index.js +5 -1
  51. package/src/og/control/ruler/Ruler.js +0 -4
  52. package/src/og/control/ruler/RulerScene.js +3 -2
  53. package/src/og/control/selection/Selection.js +0 -4
  54. package/src/og/control/selection/SelectionScene.js +2 -4
  55. package/src/og/control/timeline/TimelineControl.js +4 -4
  56. package/src/og/control/timeline/TimelineModel.js +2 -2
  57. package/src/og/control/timeline/TimelineView.js +1 -0
  58. package/src/og/control/visibleExtent/Segment.js +5 -5
  59. package/src/og/control/visibleExtent/drawnode.js +0 -4
  60. package/src/og/ellipsoid/Ellipsoid.js +205 -275
  61. package/src/og/ellipsoid/wgs84.js +0 -4
  62. package/src/og/entity/BaseBillboard.js +375 -379
  63. package/src/og/entity/Billboard.js +0 -4
  64. package/src/og/entity/BillboardHandler.js +0 -4
  65. package/src/og/entity/Entity.js +22 -22
  66. package/src/og/entity/EntityCollection.js +7 -11
  67. package/src/og/entity/GeoObject.js +0 -4
  68. package/src/og/entity/GeoObjectHandler.js +0 -4
  69. package/src/og/entity/Geometry.js +5 -4
  70. package/src/og/entity/GeometryHandler.js +3 -4
  71. package/src/og/entity/Label.js +0 -4
  72. package/src/og/entity/LabelHandler.js +0 -4
  73. package/src/og/entity/PointCloud.js +0 -4
  74. package/src/og/entity/PointCloudHandler.js +122 -126
  75. package/src/og/entity/Polyline.js +4 -6
  76. package/src/og/entity/PolylineHandler.js +104 -108
  77. package/src/og/entity/Ray.js +29 -29
  78. package/src/og/entity/Strip.js +1 -1
  79. package/src/og/index.js +3 -1
  80. package/src/og/input/KeyboardHandler.js +128 -132
  81. package/src/og/input/MouseHandler.js +94 -98
  82. package/src/og/input/TouchHandler.js +59 -63
  83. package/src/og/input/input.js +44 -48
  84. package/src/og/layer/BaseGeoImage.js +5 -8
  85. package/src/og/layer/CanvasTiles.js +0 -4
  86. package/src/og/layer/GeoImage.js +0 -4
  87. package/src/og/layer/GeoTexture2d.js +0 -4
  88. package/src/og/layer/GeoVideo.js +0 -4
  89. package/src/og/layer/KML.js +2 -3
  90. package/src/og/layer/Layer.js +22 -26
  91. package/src/og/layer/Material.js +0 -4
  92. package/src/og/layer/Vector.js +23 -20
  93. package/src/og/layer/WMS.js +182 -186
  94. package/src/og/layer/XYZ.js +0 -4
  95. package/src/og/light/LightSource.js +0 -4
  96. package/src/og/math/Line2.js +28 -32
  97. package/src/og/math/Mat3.js +152 -156
  98. package/src/og/math/Ray.js +0 -4
  99. package/src/og/math/Vec2.js +0 -4
  100. package/src/og/math/Vec3.js +0 -4
  101. package/src/og/math/Vec4.js +0 -4
  102. package/src/og/math/coder.js +104 -104
  103. package/src/og/math.js +39 -7
  104. package/src/og/proj/EPSG3857.js +13 -13
  105. package/src/og/proj/Proj.js +59 -63
  106. package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +1 -0
  107. package/src/og/quadTree/EarthQuadTreeStrategy.js +1 -0
  108. package/src/og/quadTree/EntityCollectionNode.js +12 -16
  109. package/src/og/quadTree/MarsQuadTreeStrategy.js +1 -0
  110. package/src/og/quadTree/QuadTreeStrategy.js +1 -0
  111. package/src/og/quadTree/Wgs84QuadTreeStrategy.js +1 -0
  112. package/src/og/renderer/Renderer.js +109 -22
  113. package/src/og/renderer/RendererEvents.js +0 -4
  114. package/src/og/scene/Axes.js +74 -78
  115. package/src/og/scene/BaseNode.js +0 -4
  116. package/src/og/scene/Planet.js +114 -112
  117. package/src/og/scene/RenderNode.js +11 -3
  118. package/src/og/scene/SkyBox.js +104 -108
  119. package/src/og/segment/Segment.js +8 -4
  120. package/src/og/segment/SegmentLonLat.js +2 -6
  121. package/src/og/segment/segmentHelper.js +229 -225
  122. package/src/og/shaders/billboard.js +0 -4
  123. package/src/og/shaders/drawnode.js +5 -9
  124. package/src/og/shaders/geoObject.js +0 -4
  125. package/src/og/shaders/label.js +0 -4
  126. package/src/og/shaders/pickingMask.js +0 -4
  127. package/src/og/shaders/pointCloud.js +0 -4
  128. package/src/og/shaders/polyline.js +0 -4
  129. package/src/og/shaders/ray.js +0 -4
  130. package/src/og/shaders/skybox.js +0 -4
  131. package/src/og/terrain/EmptyTerrain.js +0 -4
  132. package/src/og/utils/FontAtlas.js +0 -4
  133. package/src/og/utils/GeoImageCreator.js +1 -2
  134. package/src/og/utils/NormalMapCreator.js +8 -9
  135. package/src/og/utils/VectorTileCreator.js +3 -9
  136. package/src/og/utils/shared.js +20 -1
  137. package/src/og/webgl/Framebuffer.js +0 -4
  138. package/src/og/webgl/Handler.js +45 -19
  139. package/src/og/webgl/Multisample.js +0 -4
  140. package/src/og/webgl/Program.js +0 -4
  141. package/src/og/webgl/ProgramController.js +2 -2
  142. package/types/Clock.d.ts +1 -1
  143. package/types/Extent.d.ts +5 -5
  144. package/types/Globe.d.ts +15 -1
  145. package/types/ImageCanvas.d.ts +5 -0
  146. package/types/bv/Box.d.ts +1 -1
  147. package/types/bv/Sphere.d.ts +3 -3
  148. package/types/camera/Camera.d.ts +3 -2
  149. package/types/camera/PlanetCamera.d.ts +4 -4
  150. package/types/control/DrawingSwitcher.d.ts +13 -0
  151. package/types/control/EarthCoordinates.d.ts +1 -1
  152. package/types/control/Lighting.d.ts +8 -8
  153. package/types/control/drawing/DrawingControl.d.ts +14 -0
  154. package/types/control/drawing/LineStringDrawingScene.d.ts +5 -0
  155. package/types/control/drawing/PolygonDrawingScene.d.ts +99 -0
  156. package/types/control/index.d.ts +3 -1
  157. package/types/control/ruler/RulerScene.d.ts +0 -1
  158. package/types/control/selection/SelectionScene.d.ts +0 -1
  159. package/types/ellipsoid/Ellipsoid.d.ts +50 -63
  160. package/types/entity/Entity.d.ts +3 -2
  161. package/types/entity/Geometry.d.ts +5 -0
  162. package/types/entity/Polyline.d.ts +1 -1
  163. package/types/entity/Ray.d.ts +1 -0
  164. package/types/index.d.ts +1 -0
  165. package/types/layer/BaseGeoImage.d.ts +1 -1
  166. package/types/layer/CanvasTiles.d.ts +1 -1
  167. package/types/layer/Layer.d.ts +1 -1
  168. package/types/layer/Vector.d.ts +1 -0
  169. package/types/math.d.ts +7 -0
  170. package/types/renderer/Renderer.d.ts +7 -1
  171. package/types/scene/Axes.d.ts +0 -1
  172. package/types/scene/Planet.d.ts +26 -24
  173. package/types/scene/RenderNode.d.ts +2 -0
  174. package/types/scene/SkyBox.d.ts +0 -1
  175. package/types/segment/Segment.d.ts +3 -2
  176. package/types/segment/SegmentLonLat.d.ts +0 -1
  177. package/types/utils/GeoImageCreator.d.ts +1 -1
  178. package/types/utils/NormalMapCreator.d.ts +1 -1
  179. package/types/utils/VectorTileCreator.d.ts +2 -2
  180. package/types/utils/shared.d.ts +2 -0
  181. package/types/webgl/Handler.d.ts +6 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openglobus/og",
3
- "version": "0.16.2",
3
+ "version": "0.17.0",
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/Clock.js CHANGED
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/Clock
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import * as jd from "./astro/jd.js";
@@ -14,7 +10,7 @@ import { Events } from "./Events.js";
14
10
  * @param {number} [params.startDate=0.0] - Julian start date.
15
11
  * @param {number} [params.endDate=0.0] - Julian end date.
16
12
  * @param {number} [params.currentDate] - Julian current date. Default: current date.
17
- * @param {number} [params.multiplier=1.0] - Time speed multiolier.
13
+ * @param {number} [params.multiplier=1.0] - Time speed multiplier.
18
14
  */
19
15
  class Clock {
20
16
  static get _staticCounter() {
package/src/og/Events.js CHANGED
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/Events
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import { binaryInsert, stamp } from "./utils/shared.js";
package/src/og/Extent.js CHANGED
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/Extent
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import { LonLat } from "./LonLat.js";
@@ -11,13 +7,13 @@ import * as mercator from "./mercator.js";
11
7
  /**
12
8
  * Represents geographical coordinates extent.
13
9
  * @class
14
- * @param {LonLat} [sw] - South West extent corner coordiantes.
15
- * @param {LonLat} [ne] - North East extent corner coordiantes.
10
+ * @param {LonLat} [sw] - South West extent corner coordinates.
11
+ * @param {LonLat} [ne] - North East extent corner coordinates.
16
12
  */
17
13
  export class Extent {
18
14
  /**
19
- * @param {LonLat} [sw] - South West extent corner coordiantes.
20
- * @param {LonLat} [ne] - North East extent corner coordiantes.
15
+ * @param {LonLat} [sw] - South West extent corner coordinates.
16
+ * @param {LonLat} [ne] - North East extent corner coordinates.
21
17
  */
22
18
  constructor(sw = new LonLat(), ne = new LonLat()) {
23
19
  /**
@@ -86,7 +82,7 @@ export class Extent {
86
82
  }
87
83
 
88
84
  /**
89
- * Creates bound extent instance by coordinate array.
85
+ * Creates bound extent instance by coordinates array.
90
86
  * @static
91
87
  * @param {Array.<Array<number>>} arr - Coordinate array. (exactly 2 entries)
92
88
  * @return {Extent} Extent object.
package/src/og/Globe.js CHANGED
@@ -1,4 +1,4 @@
1
- // StandWithUkraine
1
+ // #StandWithUkraine
2
2
 
3
3
  /**
4
4
  * @module og/Globe
@@ -18,11 +18,9 @@ import { Vec3 } from "./math/Vec3.js";
18
18
  import { Renderer } from "./renderer/Renderer.js";
19
19
  import { Planet } from "./scene/Planet.js";
20
20
  import { EmptyTerrain } from "./terrain/EmptyTerrain.js";
21
- import { createColorRGB, isEmpty } from "./utils/shared.js";
21
+ import { createColorRGB, getUrlParam, isEmpty } from "./utils/shared.js";
22
22
  import { Handler } from "./webgl/Handler.js";
23
23
 
24
- /** @const {string} */
25
- const CANVAS_ID_PREFIX = "globus_viewport_";
26
24
  /** @const {string} */
27
25
  const PLANET_NAME_PREFIX = "globus_planet_";
28
26
 
@@ -73,6 +71,7 @@ const PLANET_NAME_PREFIX = "globus_planet_";
73
71
  * @param {Number} [options.quadTreeStrategyPrototype] - Prototype of quadTree. QuadTreeStrategy for Earth is default.
74
72
  * @param {Number} [options.msaa] - MSAA antialiasing parameter: 2,4,8,16. Default is 4.
75
73
  * @param {Number} [options.dpi] - Device pixel ratio. Default is current screen DPI.
74
+ * @param {Boolean} [options.atmosphereEnabled] - Enables atmosphere effect.
76
75
  */
77
76
 
78
77
  class Globe {
@@ -80,45 +79,53 @@ class Globe {
80
79
  * @param {*} options
81
80
  */
82
81
  constructor(options) {
83
- window.__globus__ = this;
84
82
 
85
- // Canvas creation
86
- var _canvasId = CANVAS_ID_PREFIX + Globe._staticCounter++;
83
+ this.$target = null;
84
+
85
+ this._instanceID = `__globus${Globe.__staticCounter++ ? Globe.__staticCounter : ""}__`;
86
+ window[this._instanceID] = this;
87
87
 
88
+ //
89
+ // Canvas creation
90
+ //
88
91
  this._canvas = document.createElement("canvas");
89
- this._canvas.id = _canvasId;
92
+ this._canvas.id = `canvas${this._instanceID}`;
90
93
  this._canvas.style.width = "100%";
91
94
  this._canvas.style.height = "100%";
92
95
  this._canvas.style.display = "block";
93
96
  this._canvas.style.opacity = "0.0";
94
- this._canvas.style.transition = "opacity 1.0s";
97
+ this._canvas.style.transition = "opacity 150ms";
95
98
 
96
99
  /**
97
100
  * Dom element where WebGL canvas creates
98
101
  * @public
99
102
  * @type {Element}
100
103
  */
101
- if (options.target instanceof HTMLElement) {
102
- this.div = options.target;
104
+ this.$inner = document.createElement('div');
105
+ this.$inner.classList.add("og-inner");
106
+ this.$inner.appendChild(this._canvas);
107
+
108
+ this.$inner.attributions = document.createElement('div');
109
+ if (options.attributionContainer) {
110
+ options.attributionContainer.appendChild(this.$inner.attributions);
103
111
  } else {
104
- this.div =
105
- document.getElementById(options.target) || document.querySelector(options.target);
112
+ this.$inner.attributions.classList.add("og-attribution");
113
+ this.$inner.appendChild(this.$inner.attributions);
106
114
  }
107
115
 
108
- this.div.appendChild(this._canvas);
109
- this.div.classList.add("ogViewport");
116
+ this.attachTo(options.target);
110
117
 
111
- function _disableWheel(e) {
118
+ const _disableWheel = (e) => {
112
119
  e.preventDefault();
113
120
  }
114
121
 
115
- this.div.onmouseenter = function () {
122
+ this._canvas.onmouseenter = function () {
116
123
  document.addEventListener("mousewheel", _disableWheel, {
117
124
  capture: false,
118
125
  passive: false
119
126
  });
120
127
  };
121
- this.div.onmouseleave = function () {
128
+ this._canvas.onmouseleave = function () {
122
129
  document.removeEventListener("mousewheel", _disableWheel);
123
130
  };
124
131
 
@@ -128,7 +135,8 @@ class Globe {
128
135
  * @type {Renderer}
129
136
  */
130
137
  this.renderer = new Renderer(
131
- new Handler(_canvasId, {
138
+ new Handler(this._canvas, {
139
+ autoActivate: false,
132
140
  pixelRatio: options.dpi || (window.devicePixelRatio + 0.15),
133
141
  context: {
134
142
  alpha: false,
@@ -137,19 +145,11 @@ class Globe {
137
145
  }
138
146
  }), {
139
147
  autoActivate: false,
140
- backgroundColor: createColorRGB(options.backgroundColor, new Vec3(115 / 255, 203 / 255, 249 / 255)),
141
148
  msaa: options.msaa
142
149
  }
143
150
  );
144
- this.renderer.initialize();
145
- this.renderer.div = this.div;
146
- this.renderer.div.attributions = document.createElement("div");
147
- if (options.attributionContainer) {
148
- options.attributionContainer.appendChild(this.div.attributions);
149
- } else {
150
- this.div.attributions.classList.add("og-attribution");
151
- this.div.appendChild(this.div.attributions);
152
- }
151
+
152
+ this.renderer.div = this.$inner;
153
153
 
154
154
  // Skybox
155
155
  if (options.skybox) {
@@ -170,30 +170,22 @@ class Globe {
170
170
  */
171
171
  this._quadTreeType = options.quadTreeType;
172
172
 
173
- if (options.atmosphere) {
174
- /**
175
- * Render node renders a planet.
176
- * @public
177
- * @type {Planet|og.scene.PlanetAtmosphere}
178
- */
179
- // TODO:
180
- } else {
181
- this.planet = new Planet({
182
- name: this._planetName,
183
- frustums: options.frustums,
184
- ellipsoid: options.ellipsoid,
185
- maxGridSize: options.maxGridSize,
186
- useNightTexture: options.useNightTexture,
187
- useSpecularTexture: options.useSpecularTexture,
188
- minAltitude: options.minAltitude,
189
- maxAltitude: options.maxAltitude || 15000000,
190
- maxEqualZoomAltitude: options.maxEqualZoomAltitude,
191
- minEqualZoomAltitude: options.minEqualZoomAltitude,
192
- minEqualZoomCameraSlope: options.minEqualZoomCameraSlope,
193
- quadTreeStrategyPrototype: options.quadTreeStrategyPrototype,
194
- maxLoadingRequests: options.maxLoadingRequests
195
- });
196
- }
173
+ this.planet = new Planet({
174
+ name: this._planetName,
175
+ frustums: options.frustums,
176
+ ellipsoid: options.ellipsoid,
177
+ maxGridSize: options.maxGridSize,
178
+ useNightTexture: options.useNightTexture,
179
+ useSpecularTexture: options.useSpecularTexture,
180
+ minAltitude: options.minAltitude,
181
+ maxAltitude: options.maxAltitude || 15000000,
182
+ maxEqualZoomAltitude: options.maxEqualZoomAltitude,
183
+ minEqualZoomAltitude: options.minEqualZoomAltitude,
184
+ minEqualZoomCameraSlope: options.minEqualZoomCameraSlope,
185
+ quadTreeStrategyPrototype: options.quadTreeStrategyPrototype,
186
+ maxLoadingRequests: options.maxLoadingRequests,
187
+ atmosphereEnabled: options.atmosphereEnabled
188
+ });
197
189
 
198
190
  // Attach terrain provider (can be one object or array)
199
191
  if (options.terrain) {
@@ -268,9 +260,24 @@ class Globe {
268
260
 
269
261
  // Run!
270
262
  if (options.autoActivate || isEmpty(options.autoActivate)) {
271
- this.renderer.start();
272
- this.fadeIn();
263
+ this.start();
264
+ }
265
+ }
266
+
267
+ static get __staticCounter() {
268
+ if (!this.__counter && this.__counter !== 0) {
269
+ this.__counter = 0;
273
270
  }
271
+ return this.__counter;
272
+ }
273
+
274
+ static set __staticCounter(n) {
275
+ this.__counter = n;
276
+ }
277
+
278
+ start() {
279
+ this.renderer.start();
280
+ this.fadeIn();
274
281
  }
275
282
 
276
283
  /**
@@ -290,6 +297,36 @@ class Globe {
290
297
  this._canvas.style.opacity = 0.0;
291
298
  }
292
299
 
300
+ attachTo(target) {
301
+
302
+ this.detach();
303
+
304
+ let t;
305
+ if (target instanceof HTMLElement) {
306
+ t = target;
307
+ } else {
308
+ t = document.getElementById(target) || document.querySelector(target);
309
+ }
310
+
311
+ if (t) {
312
+ this.$target = t;
313
+ t.appendChild(this.$inner);
314
+ }
315
+ }
316
+
317
+ detach() {
318
+ if (this.$target) {
319
+ // Remember that when container is zero
320
+ // sized(display none etc.) renderer frame will be stopped
321
+ this.$target.removeChild(this.$inner);
322
+ }
323
+ }
324
+
325
+ destroy() {
326
+ this.detach();
327
+ this.renderer.destroy();
328
+ }
329
+
293
330
  static get _staticCounter() {
294
331
  if (!this._counter && this._counter !== 0) {
295
332
  this._counter = 0;
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/ImageCanvas
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  /**
@@ -28,7 +24,9 @@ class ImageCanvas {
28
24
  * @protected
29
25
  * @type {Object}
30
26
  */
31
- this._context = this._canvas.getContext("2d");
27
+ this._context = this._canvas.getContext("2d", {
28
+ willReadFrequently: true
29
+ });
32
30
  }
33
31
 
34
32
  /**
@@ -62,6 +60,15 @@ class ImageCanvas {
62
60
  this._context.putImageData(imgd, 0, 0);
63
61
  }
64
62
 
63
+ /**
64
+ * Fills canvas RGBA with color.
65
+ * @public
66
+ */
67
+ fill(c) {
68
+ this._context.fillStyle = color
69
+ this._context.fill()
70
+ }
71
+
65
72
  /**
66
73
  * Gets canvas pixels RGBA data.
67
74
  * @public
package/src/og/Lock.js CHANGED
@@ -1,48 +1,44 @@
1
- /**
2
- * @module og/Lock
3
- */
4
-
5
- 'use strict';
6
-
7
- class Lock {
8
-
9
- constructor() {
10
- this._lock = 0;
11
- }
12
-
13
- lock(key) {
14
- this._lock |= (1 << key._id);
15
- }
16
-
17
- free(key) {
18
- this._lock &= ~(1 << key._id);
19
- }
20
-
21
- isFree() {
22
- return this._lock === 0;
23
- }
24
-
25
- isLocked() {
26
- return this._lock !== 0;
27
- }
28
- }
29
-
30
- class Key {
31
-
32
- static get _staticCounter() {
33
- if (!this._counter && this._counter !== 0) {
34
- this._counter = 0;
35
- }
36
- return this._counter;
37
- }
38
-
39
- static set _staticCounter(n) {
40
- this._counter = n;
41
- }
42
-
43
- constructor() {
44
- this._id = Key._staticCounter++;
45
- }
46
- }
47
-
48
- export { Lock, Key };
1
+ 'use strict';
2
+
3
+ class Lock {
4
+
5
+ constructor() {
6
+ this._lock = 0;
7
+ }
8
+
9
+ lock(key) {
10
+ this._lock |= (1 << key._id);
11
+ }
12
+
13
+ free(key) {
14
+ this._lock &= ~(1 << key._id);
15
+ }
16
+
17
+ isFree() {
18
+ return this._lock === 0;
19
+ }
20
+
21
+ isLocked() {
22
+ return this._lock !== 0;
23
+ }
24
+ }
25
+
26
+ class Key {
27
+
28
+ static get _staticCounter() {
29
+ if (!this._counter && this._counter !== 0) {
30
+ this._counter = 0;
31
+ }
32
+ return this._counter;
33
+ }
34
+
35
+ static set _staticCounter(n) {
36
+ this._counter = n;
37
+ }
38
+
39
+ constructor() {
40
+ this._id = Key._staticCounter++;
41
+ }
42
+ }
43
+
44
+ export { Lock, Key };
package/src/og/LonLat.js CHANGED
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/LonLat
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import * as mercator from "./mercator.js";
@@ -379,7 +379,7 @@ class Object3d {
379
379
 
380
380
 
381
381
  static async loadObj(src) {
382
- const obj = await fetch(src)
382
+ const obj = await fetch(src, { mode: "cors", })
383
383
  .then((response) => response.text())
384
384
  .then((data) => transformLeftToRightCoordinateSystem(objParser(data)))
385
385
  .catch(() => []);
package/src/og/Stack.js CHANGED
@@ -1,53 +1,49 @@
1
- /**
2
- * @module og/Stack
3
- */
4
-
5
- "use strict";
6
-
7
- class Node {
8
- constructor() {
9
- this.next = null;
10
- this.prev = null;
11
- this.data = null;
12
- }
13
- }
14
-
15
- class Stack {
16
- /**
17
- *
18
- * @param {number} [size]
19
- */
20
- constructor(size = 256) {
21
- this._current = new Node();
22
- this._head = this._current;
23
-
24
- for (var i = 0; i < size; i++) {
25
- var n = new Node();
26
- n.prev = this._current;
27
- this._current.next = n;
28
- this._current = n;
29
- }
30
- this._current = this._head;
31
- }
32
-
33
- current() {
34
- return this._current;
35
- }
36
-
37
- push(data) {
38
- this._current = this._current.next;
39
- this._current.data = data;
40
- }
41
-
42
- pop(data) {
43
- this._current = this._current.prev;
44
- return this._current.next.data;
45
- }
46
-
47
- popPrev(data) {
48
- this._current = this._current.prev;
49
- return this._current.data;
50
- }
51
- }
52
-
53
- export { Stack };
1
+ "use strict";
2
+
3
+ class Node {
4
+ constructor() {
5
+ this.next = null;
6
+ this.prev = null;
7
+ this.data = null;
8
+ }
9
+ }
10
+
11
+ class Stack {
12
+ /**
13
+ *
14
+ * @param {number} [size]
15
+ */
16
+ constructor(size = 256) {
17
+ this._current = new Node();
18
+ this._head = this._current;
19
+
20
+ for (var i = 0; i < size; i++) {
21
+ var n = new Node();
22
+ n.prev = this._current;
23
+ this._current.next = n;
24
+ this._current = n;
25
+ }
26
+ this._current = this._head;
27
+ }
28
+
29
+ current() {
30
+ return this._current;
31
+ }
32
+
33
+ push(data) {
34
+ this._current = this._current.next;
35
+ this._current.data = data;
36
+ }
37
+
38
+ pop(data) {
39
+ this._current = this._current.prev;
40
+ return this._current.next.data;
41
+ }
42
+
43
+ popPrev(data) {
44
+ this._current = this._current.prev;
45
+ return this._current.data;
46
+ }
47
+ }
48
+
49
+ export { Stack };