@openglobus/og 0.11.7 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/og.css +5 -2
- package/dist/@openglobus/og.css +1 -0
- package/dist/@openglobus/og.esm.js +21 -0
- package/dist/@openglobus/og.esm.js.map +1 -0
- package/dist/@openglobus/og.umd.js +21 -0
- package/dist/@openglobus/og.umd.js.map +1 -0
- package/package.json +11 -11
- package/src/og/Globe.js +18 -6
- package/src/og/camera/Camera.js +70 -79
- package/src/og/camera/PlanetCamera.js +25 -30
- package/src/og/control/DebugInfo.js +2 -2
- package/src/og/control/EarthNavigation.js +26 -17
- package/src/og/control/Lighting.js +52 -73
- package/src/og/control/MouseNavigation.js +30 -29
- package/src/og/control/MouseWheelZoomControl.js +257 -0
- package/src/og/control/Sun.js +3 -3
- package/src/og/control/index.js +2 -0
- package/src/og/control/visibleExtent/Segment.js +1862 -0
- package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
- package/src/og/control/visibleExtent/drawnode.js +751 -0
- package/src/og/entity/BaseBillboard.js +9 -9
- package/src/og/entity/Entity.js +742 -742
- package/src/og/entity/GeoObjectHandler.js +138 -134
- package/src/og/entity/Label.js +7 -7
- package/src/og/entity/LabelHandler.js +2 -1
- package/src/og/layer/CanvasTiles.js +8 -12
- package/src/og/layer/GeoImage.js +2 -10
- package/src/og/layer/GeoTexture2d.js +2 -10
- package/src/og/layer/GeoVideo.js +2 -10
- package/src/og/layer/KML.js +19 -12
- package/src/og/layer/Layer.js +4 -23
- package/src/og/layer/WMS.js +0 -2
- package/src/og/layer/XYZ.js +31 -33
- package/src/og/math/Vec3.js +18 -2
- package/src/og/quadTree/Node.js +48 -93
- package/src/og/quadTree/quadTree.js +1 -1
- package/src/og/renderer/Renderer.js +69 -96
- package/src/og/renderer/RendererEvents.js +3 -1
- package/src/og/scene/Planet.js +171 -173
- package/src/og/segment/Segment.js +99 -268
- package/src/og/segment/Slice.js +45 -0
- package/src/og/shaders/drawnode.js +171 -350
- package/src/og/shaders/geoObject.js +15 -6
- package/src/og/terrain/EmptyTerrain.js +3 -2
- package/src/og/terrain/GlobusTerrain.js +2 -0
- package/src/og/utils/GeoImageCreator.js +5 -1
- package/src/og/utils/Loader.js +1 -1
- package/src/og/utils/PlainSegmentWorker.js +0 -13
- package/src/og/webgl/Handler.js +14 -10
- package/types/Clock.d.ts +94 -0
- package/types/Deferred.d.ts +6 -0
- package/types/Events.d.ts +77 -0
- package/types/Extent.d.ts +166 -0
- package/types/Globe.d.ts +85 -0
- package/types/ImageCanvas.d.ts +123 -0
- package/types/Lock.d.ts +12 -0
- package/types/LonLat.d.ts +108 -0
- package/types/Popup.d.ts +42 -0
- package/types/QueueArray.d.ts +19 -0
- package/types/Rectangle.d.ts +80 -0
- package/types/Stack.d.ts +19 -0
- package/types/ajax.d.ts +24 -0
- package/types/arial.d.ts +48 -0
- package/types/astro/astro.d.ts +38 -0
- package/types/astro/earth.d.ts +7 -0
- package/types/astro/jd.d.ts +254 -0
- package/types/bv/Box.d.ts +30 -0
- package/types/bv/Sphere.d.ts +38 -0
- package/types/bv/index.d.ts +3 -0
- package/types/camera/Camera.d.ts +312 -0
- package/types/camera/Frustum.d.ts +133 -0
- package/types/camera/PlanetCamera.d.ts +219 -0
- package/types/camera/index.d.ts +3 -0
- package/types/cons.d.ts +40 -0
- package/types/control/CompassButton.d.ts +17 -0
- package/types/control/Control.d.ts +104 -0
- package/types/control/DebugInfo.d.ts +15 -0
- package/types/control/EarthCoordinates.d.ts +47 -0
- package/types/control/EarthNavigation.d.ts +43 -0
- package/types/control/GeoImageDragControl.d.ts +6 -0
- package/types/control/KeyboardNavigation.d.ts +21 -0
- package/types/control/LayerSwitcher.d.ts +21 -0
- package/types/control/Lighting.d.ts +16 -0
- package/types/control/MouseNavigation.d.ts +48 -0
- package/types/control/MouseWheelZoomControl.d.ts +45 -0
- package/types/control/ScaleControl.d.ts +22 -0
- package/types/control/ShowFps.d.ts +11 -0
- package/types/control/SimpleNavigation.d.ts +25 -0
- package/types/control/Sun.d.ts +50 -0
- package/types/control/ToggleWireframe.d.ts +12 -0
- package/types/control/TouchNavigation.d.ts +48 -0
- package/types/control/ZoomControl.d.ts +27 -0
- package/types/control/index.d.ts +18 -0
- package/types/ellipsoid/Ellipsoid.d.ts +146 -0
- package/types/ellipsoid/index.d.ts +3 -0
- package/types/ellipsoid/wgs84.d.ts +6 -0
- package/types/entity/BaseBillboard.d.ts +215 -0
- package/types/entity/Billboard.d.ts +94 -0
- package/types/entity/BillboardHandler.d.ts +79 -0
- package/types/entity/Entity.d.ts +348 -0
- package/types/entity/EntityCollection.d.ts +317 -0
- package/types/entity/GeoObject.d.ts +111 -0
- package/types/entity/GeoObjectHandler.d.ts +81 -0
- package/types/entity/Geometry.d.ts +74 -0
- package/types/entity/GeometryHandler.d.ts +76 -0
- package/types/entity/Label.d.ts +189 -0
- package/types/entity/LabelHandler.d.ts +31 -0
- package/types/entity/LabelWorker.d.ts +11 -0
- package/types/entity/PointCloud.d.ts +174 -0
- package/types/entity/PointCloudHandler.d.ts +38 -0
- package/types/entity/Polyline.d.ts +306 -0
- package/types/entity/PolylineHandler.d.ts +18 -0
- package/types/entity/Ray.d.ts +124 -0
- package/types/entity/RayHandler.d.ts +67 -0
- package/types/entity/ShapeHandler.d.ts +22 -0
- package/types/entity/Strip.d.ts +119 -0
- package/types/entity/StripHandler.d.ts +38 -0
- package/types/entity/index.d.ts +8 -0
- package/types/index.core.d.ts +65 -0
- package/types/index.d.ts +45 -0
- package/types/index.webgl.d.ts +7 -0
- package/types/input/KeyboardHandler.d.ts +10 -0
- package/types/input/MouseHandler.d.ts +5 -0
- package/types/input/TouchHandler.d.ts +5 -0
- package/types/input/input.d.ts +34 -0
- package/types/layer/BaseGeoImage.d.ts +94 -0
- package/types/layer/CanvasTiles.d.ts +67 -0
- package/types/layer/GeoImage.d.ts +52 -0
- package/types/layer/GeoTexture2d.d.ts +8 -0
- package/types/layer/GeoVideo.d.ts +55 -0
- package/types/layer/KML.d.ts +68 -0
- package/types/layer/Layer.d.ts +310 -0
- package/types/layer/Material.d.ts +45 -0
- package/types/layer/Vector.d.ts +208 -0
- package/types/layer/WMS.d.ts +61 -0
- package/types/layer/XYZ.d.ts +119 -0
- package/types/layer/index.d.ts +10 -0
- package/types/light/LightSource.d.ts +178 -0
- package/types/math/Line2.d.ts +11 -0
- package/types/math/Line3.d.ts +10 -0
- package/types/math/Mat3.d.ts +65 -0
- package/types/math/Mat4.d.ts +176 -0
- package/types/math/Plane.d.ts +18 -0
- package/types/math/Quat.d.ts +379 -0
- package/types/math/Ray.d.ts +82 -0
- package/types/math/Vec2.d.ts +309 -0
- package/types/math/Vec3.d.ts +467 -0
- package/types/math/Vec4.d.ts +162 -0
- package/types/math/coder.d.ts +43 -0
- package/types/math/index.d.ts +11 -0
- package/types/math.d.ts +261 -0
- package/types/mercator.d.ts +92 -0
- package/types/proj/EPSG3857.d.ts +6 -0
- package/types/proj/EPSG4326.d.ts +6 -0
- package/types/proj/Proj.d.ts +42 -0
- package/types/quadTree/EntityCollectionNode.d.ts +34 -0
- package/types/quadTree/Node.d.ts +60 -0
- package/types/quadTree/quadTree.d.ts +40 -0
- package/types/renderer/Renderer.d.ts +290 -0
- package/types/renderer/RendererEvents.d.ts +237 -0
- package/types/res/images.d.ts +3 -0
- package/types/scene/Axes.d.ts +11 -0
- package/types/scene/BaseNode.d.ts +60 -0
- package/types/scene/Planet.d.ts +576 -0
- package/types/scene/RenderNode.d.ts +142 -0
- package/types/scene/SkyBox.d.ts +10 -0
- package/types/scene/index.d.ts +4 -0
- package/types/segment/Segment.d.ts +275 -0
- package/types/segment/SegmentLonLat.d.ts +17 -0
- package/types/segment/Slice.d.ts +10 -0
- package/types/segment/segmentHelper.d.ts +13 -0
- package/types/shaders/billboard.d.ts +3 -0
- package/types/shaders/depth.d.ts +2 -0
- package/types/shaders/drawnode.d.ts +7 -0
- package/types/shaders/geoObject.d.ts +3 -0
- package/types/shaders/label.d.ts +4 -0
- package/types/shaders/pointCloud.d.ts +2 -0
- package/types/shaders/polyline.d.ts +3 -0
- package/types/shaders/ray.d.ts +2 -0
- package/types/shaders/screenFrame.d.ts +2 -0
- package/types/shaders/shape.d.ts +4 -0
- package/types/shaders/skybox.d.ts +2 -0
- package/types/shaders/toneMapping.d.ts +2 -0
- package/types/shapes/BaseShape.d.ts +250 -0
- package/types/shapes/Sphere.d.ts +41 -0
- package/types/terrain/BilTerrain.d.ts +7 -0
- package/types/terrain/EmptyTerrain.d.ts +73 -0
- package/types/terrain/Geoid.d.ts +26 -0
- package/types/terrain/GlobusTerrain.d.ts +116 -0
- package/types/terrain/MapboxTerrain.d.ts +7 -0
- package/types/terrain/index.d.ts +5 -0
- package/types/utils/FontAtlas.d.ts +15 -0
- package/types/utils/GeoImageCreator.d.ts +30 -0
- package/types/utils/ImagesCacheManager.d.ts +10 -0
- package/types/utils/Loader.d.ts +25 -0
- package/types/utils/NormalMapCreator.d.ts +39 -0
- package/types/utils/PlainSegmentWorker.d.ts +10 -0
- package/types/utils/TerrainWorker.d.ts +9 -0
- package/types/utils/TextureAtlas.d.ts +111 -0
- package/types/utils/VectorTileCreator.d.ts +16 -0
- package/types/utils/colorTable.d.ts +143 -0
- package/types/utils/earcut.d.ts +6 -0
- package/types/utils/shared.d.ts +231 -0
- package/types/webgl/Framebuffer.d.ts +135 -0
- package/types/webgl/Handler.d.ts +417 -0
- package/types/webgl/Multisample.d.ts +89 -0
- package/types/webgl/Program.d.ts +161 -0
- package/types/webgl/ProgramController.d.ts +89 -0
- package/types/webgl/callbacks.d.ts +1 -0
- package/types/webgl/index.d.ts +6 -0
- package/types/webgl/types.d.ts +2 -0
|
@@ -67,14 +67,10 @@ class GeoTexture2d extends BaseGeoImage {
|
|
|
67
67
|
var sha = sh.attributes,
|
|
68
68
|
shu = sh.uniforms;
|
|
69
69
|
|
|
70
|
-
var tr = this.transparentColor[0],
|
|
71
|
-
tg = this.transparentColor[1],
|
|
72
|
-
tb = this.transparentColor[2];
|
|
73
|
-
|
|
74
70
|
gl.disable(gl.CULL_FACE);
|
|
75
71
|
|
|
76
72
|
f.bindOutputTexture(this._materialTexture);
|
|
77
|
-
gl.clearColor(
|
|
73
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
78
74
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
79
75
|
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
80
76
|
|
|
@@ -117,14 +113,10 @@ class GeoTexture2d extends BaseGeoImage {
|
|
|
117
113
|
var sha = sh.attributes,
|
|
118
114
|
shu = sh.uniforms;
|
|
119
115
|
|
|
120
|
-
var tr = this.transparentColor[0],
|
|
121
|
-
tg = this.transparentColor[1],
|
|
122
|
-
tb = this.transparentColor[2];
|
|
123
|
-
|
|
124
116
|
gl.disable(gl.CULL_FACE);
|
|
125
117
|
|
|
126
118
|
f.bindOutputTexture(this._materialTexture);
|
|
127
|
-
gl.clearColor(
|
|
119
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
128
120
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
129
121
|
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
130
122
|
|
package/src/og/layer/GeoVideo.js
CHANGED
|
@@ -211,14 +211,10 @@ class GeoVideo extends BaseGeoImage {
|
|
|
211
211
|
var sha = sh.attributes,
|
|
212
212
|
shu = sh.uniforms;
|
|
213
213
|
|
|
214
|
-
var tr = this.transparentColor[0],
|
|
215
|
-
tg = this.transparentColor[1],
|
|
216
|
-
tb = this.transparentColor[2];
|
|
217
|
-
|
|
218
214
|
gl.disable(gl.CULL_FACE);
|
|
219
215
|
|
|
220
216
|
f.bindOutputTexture(this._materialTexture);
|
|
221
|
-
gl.clearColor(
|
|
217
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
222
218
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
223
219
|
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
224
220
|
|
|
@@ -265,14 +261,10 @@ class GeoVideo extends BaseGeoImage {
|
|
|
265
261
|
var sha = sh.attributes,
|
|
266
262
|
shu = sh.uniforms;
|
|
267
263
|
|
|
268
|
-
var tr = this.transparentColor[0],
|
|
269
|
-
tg = this.transparentColor[1],
|
|
270
|
-
tb = this.transparentColor[2];
|
|
271
|
-
|
|
272
264
|
gl.disable(gl.CULL_FACE);
|
|
273
265
|
|
|
274
266
|
f.bindOutputTexture(this._materialTexture);
|
|
275
|
-
gl.clearColor(
|
|
267
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
276
268
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
277
269
|
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
278
270
|
|
package/src/og/layer/KML.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
"use strict";
|
|
6
|
+
import { Billboard } from "../entity/Billboard.js";
|
|
6
7
|
import { Entity } from "../entity/Entity.js";
|
|
7
8
|
import { Extent } from "../Extent.js";
|
|
8
9
|
import { LonLat } from "../LonLat.js";
|
|
@@ -40,12 +41,14 @@ export class KML extends Vector {
|
|
|
40
41
|
*/
|
|
41
42
|
_extractCoordonatesFromKml(xmlDoc) {
|
|
42
43
|
const raw = Array.from(xmlDoc.getElementsByTagName("coordinates"));
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
const rawText = raw.map(item => item.textContent.trim());
|
|
45
|
+
const coordinates = rawText.map(item =>
|
|
46
|
+
item
|
|
47
|
+
.replace(/\n/g, " ")
|
|
48
|
+
.replace(/\t/g, " ")
|
|
49
|
+
.replace(/ +/g," ")
|
|
50
|
+
.split(" ")
|
|
51
|
+
.map((co) => co.split(",").map(parseFloat))
|
|
49
52
|
);
|
|
50
53
|
return coordinates;
|
|
51
54
|
}
|
|
@@ -121,15 +124,17 @@ export class KML extends Vector {
|
|
|
121
124
|
/**
|
|
122
125
|
* @public
|
|
123
126
|
* @param {File[]} kmls
|
|
127
|
+
* @param {string} [color]
|
|
128
|
+
* @param {Billboard} [billboard]
|
|
124
129
|
* @returns {Promise<{entities: Entity[], extent: Extent}>}
|
|
125
130
|
*/
|
|
126
|
-
async addKmlFromFiles(kmls) {
|
|
131
|
+
async addKmlFromFiles(kmls, color = null, billboard = null) {
|
|
127
132
|
const kmlObjs = await Promise.all(kmls.map(this._getXmlContent));
|
|
128
133
|
const coordonates = kmlObjs.map(this._extractCoordonatesFromKml);
|
|
129
134
|
const { entities, extent } = this._convertCoordonatesIntoEntities(
|
|
130
135
|
coordonates,
|
|
131
|
-
this._color,
|
|
132
|
-
this._billboard
|
|
136
|
+
color || this._color,
|
|
137
|
+
billboard || this._billboard
|
|
133
138
|
);
|
|
134
139
|
this._extent = this._expandExtents(this._extent, extent);
|
|
135
140
|
entities.forEach(this.add.bind(this));
|
|
@@ -168,15 +173,17 @@ export class KML extends Vector {
|
|
|
168
173
|
/**
|
|
169
174
|
* @public
|
|
170
175
|
* @param {string} url - Url of the KML to display. './myFile.kml' or 'http://mySite/myFile.kml' for example.
|
|
176
|
+
* @param {string} [color]
|
|
177
|
+
* @param {Billboard} [billboard]
|
|
171
178
|
* @returns {Promise<{entities: Entity[], extent: Extent}>}
|
|
172
179
|
*/
|
|
173
|
-
async addKmlFromUrl(url) {
|
|
180
|
+
async addKmlFromUrl(url, color = null, billboard = null) {
|
|
174
181
|
const kml = await this._getKmlFromUrl(url);
|
|
175
182
|
const coordonates = this._extractCoordonatesFromKml(kml);
|
|
176
183
|
const { entities, extent } = this._convertCoordonatesIntoEntities(
|
|
177
184
|
[coordonates],
|
|
178
|
-
this._color,
|
|
179
|
-
this._billboard
|
|
185
|
+
color || this._color,
|
|
186
|
+
billboard || this._billboard
|
|
180
187
|
);
|
|
181
188
|
this._extent = this._expandExtents(this._extent, extent);
|
|
182
189
|
entities.forEach(this.add.bind(this));
|
package/src/og/layer/Layer.js
CHANGED
|
@@ -22,7 +22,6 @@ export const FADING_FACTOR = 0.29;
|
|
|
22
22
|
* @param {String} [name="noname"] - Layer name.
|
|
23
23
|
* @param {Object} [options] - Layer options:
|
|
24
24
|
* @param {number} [options.opacity=1.0] - Layer opacity.
|
|
25
|
-
* @param {Array.<number>} [options.transparentColor=[-1,-1,-1]] - RGB color that defines transparent color. (exactly 3 entries)
|
|
26
25
|
* @param {number} [options.minZoom=0] - Minimal visibility zoom level.
|
|
27
26
|
* @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
|
|
28
27
|
* @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
|
|
@@ -30,11 +29,7 @@ export const FADING_FACTOR = 0.29;
|
|
|
30
29
|
* @param {boolean} [options.visibility=true] - Layer visibility.
|
|
31
30
|
* @param {boolean} [options.isSRGB=false] - Layer image webgl nternal format.
|
|
32
31
|
* @param {Extent} [options.extent=[[-180.0, -90.0], [180.0, 90.0]]] - Visible extent.
|
|
33
|
-
* @param {Vec3} [options.ambient=[0.1, 0.1, 0.1]] - Ambient RGB color.
|
|
34
|
-
* @param {Vec3} [options.diffuse=[0.9, 0.9, 0.9]] - Diffuse RGB color.
|
|
35
|
-
* @param {Vec3} [options.specular=[0.00025, 0.00015, 0.0001]] - Specular RGB color.
|
|
36
32
|
* @param {string} [options.textureFilter="anisotropic"] - Image texture filter. Available values: "nearest", "linear", "mipmap" and "anisotropic".
|
|
37
|
-
* @param {Number} [options.shininess=100] - Shininess.
|
|
38
33
|
*
|
|
39
34
|
* @fires og.Layer#visibilitychange
|
|
40
35
|
* @fires og.Layer#add
|
|
@@ -86,13 +81,6 @@ class Layer {
|
|
|
86
81
|
*/
|
|
87
82
|
this._opacity = options.opacity || 1.0;
|
|
88
83
|
|
|
89
|
-
/**
|
|
90
|
-
* Transparent RGB color mask.
|
|
91
|
-
* @public
|
|
92
|
-
* @type {Array.<number>} - (exactly 3 entries)
|
|
93
|
-
*/
|
|
94
|
-
this.transparentColor = options.transparentColor || [-1, -1, -1];
|
|
95
|
-
|
|
96
84
|
/**
|
|
97
85
|
* Minimal zoom level when layer is visibile.
|
|
98
86
|
* @public
|
|
@@ -107,16 +95,6 @@ class Layer {
|
|
|
107
95
|
*/
|
|
108
96
|
this.maxZoom = options.maxZoom || 50;
|
|
109
97
|
|
|
110
|
-
/**
|
|
111
|
-
* Layer light material parameters.
|
|
112
|
-
* @public
|
|
113
|
-
* @type {Object}
|
|
114
|
-
*/
|
|
115
|
-
this.ambient = utils.createColorRGB(options.ambient, new Vec3(0.2, 0.2, 0.2));
|
|
116
|
-
this.diffuse = utils.createColorRGB(options.diffuse, new Vec3(0.8, 0.8, 0.8));
|
|
117
|
-
this.specular = utils.createColorRGB(options.specular, new Vec3(0.0003, 0.0003, 0.0003));
|
|
118
|
-
this.shininess = options.shininess || 20.0;
|
|
119
|
-
|
|
120
98
|
/**
|
|
121
99
|
* Planet node.
|
|
122
100
|
* @protected
|
|
@@ -519,7 +497,10 @@ class Layer {
|
|
|
519
497
|
if (this._isBaseLayer && visibility) {
|
|
520
498
|
this._planet.setBaseLayer(this);
|
|
521
499
|
}
|
|
522
|
-
this._planet.updateVisibleLayers();
|
|
500
|
+
this._planet.updateVisibleLayers();
|
|
501
|
+
if (visibility) {
|
|
502
|
+
this._planet._preLoad();
|
|
503
|
+
}
|
|
523
504
|
}
|
|
524
505
|
this.events.dispatch(this.events.visibilitychange, this);
|
|
525
506
|
}
|
package/src/og/layer/WMS.js
CHANGED
|
@@ -17,7 +17,6 @@ import { XYZ } from "./XYZ.js";
|
|
|
17
17
|
* @param {string} name - Layer name.
|
|
18
18
|
* @param {Object} options - Options:
|
|
19
19
|
* @param {number} [options.opacity=1.0] - Layer opacity.
|
|
20
|
-
* @param {Array.<number>} [options.transparentColor=[-1,-1,-1]] - RGB color that defines transparent color.
|
|
21
20
|
* @param {number} [options.minZoom=0] - Minimal visibility zoom level.
|
|
22
21
|
* @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
|
|
23
22
|
* @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
|
|
@@ -36,7 +35,6 @@ import { XYZ } from "./XYZ.js";
|
|
|
36
35
|
* opacity: 0.5,
|
|
37
36
|
* zIndex: 50,
|
|
38
37
|
* attribution: 'USA states - geoserver WMS example',
|
|
39
|
-
* transparentColor: [1.0, 1.0, 1.0],
|
|
40
38
|
* version: "1.1.1",
|
|
41
39
|
* visibility: false }
|
|
42
40
|
* );
|
package/src/og/layer/XYZ.js
CHANGED
|
@@ -17,7 +17,6 @@ import { RENDERING } from "../quadTree/quadTree.js";
|
|
|
17
17
|
* @param {string} name - Layer name.
|
|
18
18
|
* @param {Object} options:
|
|
19
19
|
* @param {number} [options.opacity=1.0] - Layer opacity.
|
|
20
|
-
* @param {Array.<number>} [options.transparentColor=[-1,-1,-1]] - RGB color that defines transparent color. (exactly 3 entries)
|
|
21
20
|
* @param {Array.<string>} [options.subdomains=['a','b','c']] - Subdomains of the tile service.
|
|
22
21
|
* @param {number} [options.minZoom=0] - Minimal visibility zoom level.
|
|
23
22
|
* @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
|
|
@@ -51,8 +50,6 @@ class XYZ extends Layer {
|
|
|
51
50
|
|
|
52
51
|
this.events.registerNames(EVENT_NAMES);
|
|
53
52
|
|
|
54
|
-
this.transparentColor = options.transparentColor || [-1, -1, -1];
|
|
55
|
-
|
|
56
53
|
/**
|
|
57
54
|
* Tile url source template.
|
|
58
55
|
* @public
|
|
@@ -103,8 +100,10 @@ class XYZ extends Layer {
|
|
|
103
100
|
* Abort loading tiles.
|
|
104
101
|
* @public
|
|
105
102
|
*/
|
|
106
|
-
abortLoading() {
|
|
107
|
-
this._planet
|
|
103
|
+
abortLoading() {
|
|
104
|
+
if (this._planet) {
|
|
105
|
+
this._planet._tileLoader.abort();
|
|
106
|
+
}
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
/**
|
|
@@ -152,8 +151,9 @@ class XYZ extends Layer {
|
|
|
152
151
|
} else {
|
|
153
152
|
material.texture = seg.planet.transparentTexture;
|
|
154
153
|
}
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
|
|
155
|
+
// Q: Maybe we should change "<2" to material.segment.tileZoom < (material.layer.minZoom + 1)
|
|
156
|
+
if (this._planet.layerLock.isFree() || material.segment.tileZoom < 2) {
|
|
157
157
|
material.isReady = false;
|
|
158
158
|
material.isLoading = true;
|
|
159
159
|
|
|
@@ -238,9 +238,6 @@ class XYZ extends Layer {
|
|
|
238
238
|
if (material.isReady) {
|
|
239
239
|
return material.texOffset;
|
|
240
240
|
} else {
|
|
241
|
-
// if (material.loadingAttempts > 20) {
|
|
242
|
-
// debugger;
|
|
243
|
-
// }
|
|
244
241
|
|
|
245
242
|
let segment = material.segment,
|
|
246
243
|
pn = segment.node,
|
|
@@ -249,34 +246,35 @@ class XYZ extends Layer {
|
|
|
249
246
|
let mId = this._id;
|
|
250
247
|
let psegm = material;
|
|
251
248
|
while (pn.parentNode) {
|
|
249
|
+
pn = pn.parentNode;
|
|
250
|
+
psegm = pn.segment.materials[mId];
|
|
252
251
|
if (psegm && psegm.textureExists) {
|
|
253
252
|
notEmpty = true;
|
|
254
253
|
break;
|
|
255
254
|
}
|
|
256
|
-
pn = pn.parentNode;
|
|
257
|
-
psegm = pn.segment.materials[mId];
|
|
258
255
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
} else {
|
|
267
|
-
let pn = segment.node;
|
|
268
|
-
while (pn.segment.tileZoom > material.layer.maxNativeZoom) {
|
|
269
|
-
pn = pn.parentNode;
|
|
270
|
-
}
|
|
271
|
-
let pnm = pn.segment.materials[material.layer._id];
|
|
272
|
-
if (pnm) {
|
|
273
|
-
!pnm.isLoading && !pnm.isReady && this.loadMaterial(pnm, true);
|
|
256
|
+
|
|
257
|
+
if (segment.passReady) {
|
|
258
|
+
let maxNativeZoom = material.layer.maxNativeZoom;
|
|
259
|
+
if (pn.segment.tileZoom === maxNativeZoom) {
|
|
260
|
+
material.textureNotExists();
|
|
261
|
+
} else if (material.segment.tileZoom <= maxNativeZoom) {
|
|
262
|
+
!material.isLoading && !material.isReady && this.loadMaterial(material);
|
|
274
263
|
} else {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
264
|
+
let pn = segment.node;
|
|
265
|
+
while (pn.segment.tileZoom > material.layer.maxNativeZoom) {
|
|
266
|
+
pn = pn.parentNode;
|
|
267
|
+
}
|
|
268
|
+
let pnm = pn.segment.materials[material.layer._id];
|
|
269
|
+
if (pnm) {
|
|
270
|
+
!pnm.isLoading && !pnm.isReady && this.loadMaterial(pnm, true);
|
|
271
|
+
} else {
|
|
272
|
+
pnm = pn.segment.materials[material.layer._id] = material.layer.createMaterial(
|
|
273
|
+
pn.segment
|
|
274
|
+
);
|
|
275
|
+
this.loadMaterial(pnm, true);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
280
278
|
}
|
|
281
279
|
|
|
282
280
|
if (notEmpty) {
|
|
@@ -314,7 +312,7 @@ class XYZ extends Layer {
|
|
|
314
312
|
|
|
315
313
|
material.isReady = false;
|
|
316
314
|
material.textureExists = false;
|
|
317
|
-
material.isLoading = false;
|
|
315
|
+
material.isLoading = false;
|
|
318
316
|
}
|
|
319
317
|
|
|
320
318
|
/**
|
package/src/og/math/Vec3.js
CHANGED
|
@@ -699,8 +699,24 @@ export class Vec3 {
|
|
|
699
699
|
* @param {Vec3} point3 - Distant point.
|
|
700
700
|
* @returns {number} -
|
|
701
701
|
*/
|
|
702
|
-
distance(point3) {
|
|
703
|
-
|
|
702
|
+
distance(point3) {
|
|
703
|
+
let dx = this.x - point3.x,
|
|
704
|
+
dy = this.y - point3.y,
|
|
705
|
+
dz = this.z - point3.z;
|
|
706
|
+
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Gets square distance to point.
|
|
711
|
+
* @public
|
|
712
|
+
* @param {Vec3} point3 - Distant point.
|
|
713
|
+
* @returns {number} -
|
|
714
|
+
*/
|
|
715
|
+
distance2(point3) {
|
|
716
|
+
let dx = this.x - point3.x,
|
|
717
|
+
dy = this.y - point3.y,
|
|
718
|
+
dz = this.z - point3.z;
|
|
719
|
+
return dx * dx + dy * dy + dz * dz;
|
|
704
720
|
}
|
|
705
721
|
|
|
706
722
|
/**
|
package/src/og/quadTree/Node.js
CHANGED
|
@@ -7,7 +7,6 @@ import { Vec3 } from "../math/Vec3.js";
|
|
|
7
7
|
import { MAX_LAT } from "../mercator.js";
|
|
8
8
|
import { EPSG3857 } from "../proj/EPSG3857.js";
|
|
9
9
|
import { EPSG4326 } from "../proj/EPSG4326.js";
|
|
10
|
-
import { MAX_NORMAL_ZOOM } from "../segment/Segment.js";
|
|
11
10
|
import { getMatrixSubArray, getMatrixSubArrayBoundsExt } from "../utils/shared.js";
|
|
12
11
|
import {
|
|
13
12
|
COMSIDE,
|
|
@@ -30,8 +29,6 @@ import {
|
|
|
30
29
|
WALKTHROUGH
|
|
31
30
|
} from "./quadTree.js";
|
|
32
31
|
|
|
33
|
-
const VISIBLE_HEIGHT = 1400000.0;
|
|
34
|
-
|
|
35
32
|
let _tempHigh = new Vec3(),
|
|
36
33
|
_tempLow = new Vec3();
|
|
37
34
|
|
|
@@ -67,6 +64,7 @@ class Node {
|
|
|
67
64
|
|
|
68
65
|
constructor(SegmentPrototype, planet, partId, parent, id, tileZoom, extent) {
|
|
69
66
|
this.SegmentPrototype = SegmentPrototype;
|
|
67
|
+
planet._createdNodesCount++;
|
|
70
68
|
this.planet = planet;
|
|
71
69
|
this.parentNode = parent;
|
|
72
70
|
this.partId = partId;
|
|
@@ -84,7 +82,6 @@ class Node {
|
|
|
84
82
|
this._cameraInside = false;
|
|
85
83
|
this.inFrustum = 0;
|
|
86
84
|
this.createBounds();
|
|
87
|
-
this.planet._createdNodesCount++;
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
createChildrenNodes() {
|
|
@@ -102,45 +99,10 @@ class Node {
|
|
|
102
99
|
var c = new LonLat(sw.lon + size_x, sw.lat + size_y);
|
|
103
100
|
var nd = this.nodes;
|
|
104
101
|
|
|
105
|
-
nd[NW] = new Node(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this,
|
|
110
|
-
id,
|
|
111
|
-
z,
|
|
112
|
-
new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat))
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
nd[NE] = new Node(
|
|
116
|
-
this.SegmentPrototype,
|
|
117
|
-
p,
|
|
118
|
-
NE,
|
|
119
|
-
this,
|
|
120
|
-
id,
|
|
121
|
-
z,
|
|
122
|
-
new Extent(c, new LonLat(ne.lon, ne.lat))
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
nd[SW] = new Node(
|
|
126
|
-
this.SegmentPrototype,
|
|
127
|
-
p,
|
|
128
|
-
SW,
|
|
129
|
-
this,
|
|
130
|
-
id,
|
|
131
|
-
z,
|
|
132
|
-
new Extent(new LonLat(sw.lon, sw.lat), c)
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
nd[SE] = new Node(
|
|
136
|
-
this.SegmentPrototype,
|
|
137
|
-
p,
|
|
138
|
-
SE,
|
|
139
|
-
this,
|
|
140
|
-
id,
|
|
141
|
-
z,
|
|
142
|
-
new Extent(new LonLat(sw.lon + size_x, sw.lat), new LonLat(ne.lon, sw.lat + size_y))
|
|
143
|
-
);
|
|
102
|
+
nd[NW] = new Node(this.SegmentPrototype, p, NW, this, id, z, new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)));
|
|
103
|
+
nd[NE] = new Node(this.SegmentPrototype, p, NE, this, id, z, new Extent(c, new LonLat(ne.lon, ne.lat)));
|
|
104
|
+
nd[SW] = new Node(this.SegmentPrototype, p, SW, this, id, z, new Extent(new LonLat(sw.lon, sw.lat), c));
|
|
105
|
+
nd[SE] = new Node(this.SegmentPrototype, p, SE, this, id, z, new Extent(new LonLat(sw.lon + size_x, sw.lat), new LonLat(ne.lon, sw.lat + size_y)));
|
|
144
106
|
}
|
|
145
107
|
|
|
146
108
|
createBounds() {
|
|
@@ -153,6 +115,15 @@ class Node {
|
|
|
153
115
|
} else {
|
|
154
116
|
seg.createBoundsByParent();
|
|
155
117
|
}
|
|
118
|
+
|
|
119
|
+
let x = seg.bsphere.center.x,
|
|
120
|
+
y = seg.bsphere.center.y,
|
|
121
|
+
z = seg.bsphere.center.z;
|
|
122
|
+
|
|
123
|
+
let length = 1.0 / Math.sqrt(x * x + y * y + z * z);
|
|
124
|
+
seg.centerNormal.x = x * length;
|
|
125
|
+
seg.centerNormal.y = y * length;
|
|
126
|
+
seg.centerNormal.z = z * length;
|
|
156
127
|
}
|
|
157
128
|
|
|
158
129
|
getState() {
|
|
@@ -204,15 +175,10 @@ class Node {
|
|
|
204
175
|
}
|
|
205
176
|
|
|
206
177
|
renderTree(cam, maxZoom, terrainReadySegment, stopLoading) {
|
|
207
|
-
if (
|
|
208
|
-
this.planet._renderedNodes.length >= MAX_RENDERED_NODES ||
|
|
209
|
-
this.planet._nodeCounterError_ > 2000
|
|
210
|
-
) {
|
|
178
|
+
if (this.planet._renderedNodes.length >= MAX_RENDERED_NODES) {
|
|
211
179
|
return;
|
|
212
180
|
}
|
|
213
181
|
|
|
214
|
-
this.planet._nodeCounterError_++;
|
|
215
|
-
|
|
216
182
|
this.state = WALKTHROUGH;
|
|
217
183
|
|
|
218
184
|
this.neighbors[0] = null;
|
|
@@ -282,27 +248,49 @@ class Node {
|
|
|
282
248
|
if (this.inFrustum || this._cameraInside || seg.tileZoom < 3) {
|
|
283
249
|
let h = cam._lonLat.height;
|
|
284
250
|
|
|
285
|
-
let
|
|
286
|
-
|
|
287
|
-
|
|
251
|
+
let eye = cam.eye;
|
|
252
|
+
let horizonDist = eye.length2() - this.planet.ellipsoid._b2;
|
|
253
|
+
|
|
254
|
+
let altVis = seg.tileZoom > 19 ||
|
|
288
255
|
(seg.tileZoom < 4 && !seg.terrainReady) ||
|
|
289
256
|
seg.tileZoom < 2;
|
|
290
257
|
|
|
258
|
+
if (h > 21000) {
|
|
259
|
+
altVis = altVis || eye.distance2(seg._sw) < horizonDist
|
|
260
|
+
|| eye.distance2(seg._nw) < horizonDist
|
|
261
|
+
|| eye.distance2(seg._ne) < horizonDist
|
|
262
|
+
|| eye.distance2(seg._se) < horizonDist;
|
|
263
|
+
} else {
|
|
264
|
+
altVis = altVis || cam.eye.distance(seg.bsphere.center) - seg.bsphere.radius < VISIBLE_DISTANCE * Math.sqrt(h);
|
|
265
|
+
}
|
|
266
|
+
|
|
291
267
|
if ((this.inFrustum && (altVis || h > 10000.0)) || this._cameraInside) {
|
|
292
268
|
seg._collectVisibleNodes();
|
|
293
269
|
}
|
|
294
270
|
|
|
295
271
|
if (seg.tileZoom < 2 && seg.normalMapReady) {
|
|
296
272
|
this.traverseNodes(cam, maxZoom, terrainReadySegment, stopLoading);
|
|
297
|
-
} else if (
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
273
|
+
} else if (seg.terrainReady && (
|
|
274
|
+
!maxZoom && cam.projectedSize(seg.bsphere.center, seg._plainRadius) < planet._lodSize ||
|
|
275
|
+
maxZoom && ((seg.tileZoom === maxZoom) || !altVis))) {
|
|
276
|
+
|
|
277
|
+
if (altVis) {
|
|
278
|
+
seg.passReady = true;
|
|
279
|
+
this.renderNode(this.inFrustum, !this.inFrustum, terrainReadySegment, stopLoading);
|
|
280
|
+
} else {
|
|
281
|
+
this.state = NOTRENDERING;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
} else if (
|
|
285
|
+
seg.terrainReady &&
|
|
286
|
+
seg.tileZoom < planet.terrain._maxNodeZoom &&
|
|
287
|
+
(!maxZoom || maxZoom && cam.projectedSize(seg.bsphere.center, seg.bsphere.radius) > this.planet._maxLodSize)) {
|
|
303
288
|
this.traverseNodes(cam, maxZoom, seg, stopLoading);
|
|
289
|
+
} else if (altVis) {
|
|
290
|
+
seg.passReady = maxZoom ? seg.terrainReady : false;
|
|
291
|
+
this.renderNode(this.inFrustum, !this.inFrustum, terrainReadySegment, stopLoading);
|
|
304
292
|
} else {
|
|
305
|
-
this.
|
|
293
|
+
this.state = NOTRENDERING;
|
|
306
294
|
}
|
|
307
295
|
} else {
|
|
308
296
|
this.state = NOTRENDERING;
|
|
@@ -322,39 +310,6 @@ class Node {
|
|
|
322
310
|
n[3].renderTree(cam, maxZoom, terrainReadySegment, stopLoading);
|
|
323
311
|
}
|
|
324
312
|
|
|
325
|
-
prepareForRendering(
|
|
326
|
-
cam,
|
|
327
|
-
altVis,
|
|
328
|
-
inFrustum,
|
|
329
|
-
terrainReadySegment,
|
|
330
|
-
stopLoading
|
|
331
|
-
) {
|
|
332
|
-
let seg = this.segment;
|
|
333
|
-
|
|
334
|
-
if (cam._lonLat.height < VISIBLE_HEIGHT) {
|
|
335
|
-
if (altVis) {
|
|
336
|
-
this.renderNode(inFrustum, !inFrustum, terrainReadySegment, stopLoading);
|
|
337
|
-
} else {
|
|
338
|
-
this.state = NOTRENDERING;
|
|
339
|
-
}
|
|
340
|
-
} else {
|
|
341
|
-
if (seg.tileZoom < 2) {
|
|
342
|
-
this.renderNode(inFrustum, !inFrustum, terrainReadySegment, stopLoading);
|
|
343
|
-
} else if (seg.tileZoom > MAX_NORMAL_ZOOM) {
|
|
344
|
-
this.renderNode(inFrustum, !inFrustum, terrainReadySegment, stopLoading);
|
|
345
|
-
} else if (
|
|
346
|
-
seg._swNorm.dot(cam._n) > 0.0 ||
|
|
347
|
-
seg._nwNorm.dot(cam._n) > 0.0 ||
|
|
348
|
-
seg._neNorm.dot(cam._n) > 0.0 ||
|
|
349
|
-
seg._seNorm.dot(cam._n) > 0.0
|
|
350
|
-
) {
|
|
351
|
-
this.renderNode(inFrustum, !inFrustum, terrainReadySegment, stopLoading);
|
|
352
|
-
} else {
|
|
353
|
-
this.state = NOTRENDERING;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
313
|
renderNode(inFrustum, onlyTerrain, terrainReadySegment, stopLoading) {
|
|
359
314
|
var seg = this.segment;
|
|
360
315
|
|
|
@@ -376,7 +331,7 @@ class Node {
|
|
|
376
331
|
}
|
|
377
332
|
|
|
378
333
|
// Create normal map texture
|
|
379
|
-
if (seg.planet.lightEnabled && !seg.normalMapReady
|
|
334
|
+
if (seg.planet.lightEnabled && !seg.normalMapReady /*&& !seg.parentNormalMapReady*/) {
|
|
380
335
|
this.whileNormalMapCreating();
|
|
381
336
|
}
|
|
382
337
|
|