@openglobus/og 0.12.3 → 0.13.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 (93) hide show
  1. package/README.md +0 -2
  2. package/dist/@openglobus/og.esm.js +2 -2
  3. package/dist/@openglobus/og.esm.js.map +1 -1
  4. package/dist/@openglobus/og.umd.js +2 -2
  5. package/dist/@openglobus/og.umd.js.map +1 -1
  6. package/package.json +7 -7
  7. package/src/og/Extent.js +3 -3
  8. package/src/og/Globe.js +277 -275
  9. package/src/og/ImageCanvas.js +3 -3
  10. package/src/og/LonLat.js +9 -9
  11. package/src/og/QueueArray.js +2 -2
  12. package/src/og/Rectangle.js +5 -5
  13. package/src/og/bv/Box.js +1 -1
  14. package/src/og/bv/Sphere.js +2 -2
  15. package/src/og/camera/Camera.js +1 -1
  16. package/src/og/camera/PlanetCamera.js +649 -646
  17. package/src/og/control/LayerSwitcher.js +1 -1
  18. package/src/og/control/MouseNavigation.js +22 -13
  19. package/src/og/control/MouseWheelZoomControl.js +2 -2
  20. package/src/og/control/ScaleControl.js +1 -1
  21. package/src/og/control/TouchNavigation.js +319 -319
  22. package/src/og/control/ZoomControl.js +132 -132
  23. package/src/og/control/visibleExtent/Segment.js +12 -12
  24. package/src/og/ellipsoid/Ellipsoid.js +577 -567
  25. package/src/og/entity/BillboardHandler.js +878 -1051
  26. package/src/og/entity/Entity.js +1 -1
  27. package/src/og/entity/EntityCollection.js +847 -857
  28. package/src/og/entity/GeoObjectHandler.js +2 -2
  29. package/src/og/entity/LabelHandler.js +888 -1040
  30. package/src/og/entity/LabelWorker.js +0 -6
  31. package/src/og/entity/PointCloud.js +495 -495
  32. package/src/og/entity/Polyline.js +2218 -2222
  33. package/src/og/entity/RayHandler.js +1 -1
  34. package/src/og/layer/CanvasTiles.js +6 -3
  35. package/src/og/layer/GeoImage.js +1 -1
  36. package/src/og/layer/KML.js +5 -5
  37. package/src/og/layer/Layer.js +804 -752
  38. package/src/og/layer/Vector.js +997 -1010
  39. package/src/og/layer/XYZ.js +359 -357
  40. package/src/og/math/Line2.js +4 -4
  41. package/src/og/math/Quat.js +2 -2
  42. package/src/og/math/Ray.js +2 -2
  43. package/src/og/math/Vec2.js +524 -524
  44. package/src/og/math/Vec3.js +900 -900
  45. package/src/og/math/Vec4.js +261 -261
  46. package/src/og/math.js +397 -398
  47. package/src/og/quadTree/EntityCollectionNode.js +389 -387
  48. package/src/og/renderer/Renderer.js +14 -20
  49. package/src/og/renderer/RendererEvents.js +1034 -1045
  50. package/src/og/scene/Planet.js +12 -9
  51. package/src/og/scene/RenderNode.js +347 -354
  52. package/src/og/segment/Segment.js +3 -1
  53. package/src/og/segment/SegmentLonLat.js +1 -4
  54. package/src/og/shaders/billboard.js +220 -204
  55. package/src/og/shaders/drawnode.js +603 -603
  56. package/src/og/shaders/label.js +595 -456
  57. package/src/og/shaders/polyline.js +365 -361
  58. package/src/og/terrain/MapboxTerrain.js +1 -1
  59. package/src/og/utils/FontAtlas.js +209 -200
  60. package/src/og/utils/GeoImageCreator.js +4 -5
  61. package/src/og/utils/TextureAtlas.js +4 -4
  62. package/src/og/utils/VectorTileCreator.js +414 -414
  63. package/src/og/utils/shared.js +1 -1
  64. package/src/og/webgl/Handler.js +28 -60
  65. package/src/og/webgl/Multisample.js +260 -260
  66. package/src/og/webgl/Program.js +411 -396
  67. package/types/bv/Box.d.ts +1 -1
  68. package/types/bv/Sphere.d.ts +1 -1
  69. package/types/camera/PlanetCamera.d.ts +3 -3
  70. package/types/control/LayerSwitcher.d.ts +1 -1
  71. package/types/ellipsoid/Ellipsoid.d.ts +9 -2
  72. package/types/entity/BillboardHandler.d.ts +0 -4
  73. package/types/entity/EntityCollection.d.ts +0 -8
  74. package/types/entity/LabelHandler.d.ts +0 -2
  75. package/types/entity/Polyline.d.ts +1 -1
  76. package/types/layer/KML.d.ts +11 -11
  77. package/types/layer/Layer.d.ts +5 -0
  78. package/types/layer/Vector.d.ts +1 -8
  79. package/types/math/Line2.d.ts +4 -4
  80. package/types/math/Ray.d.ts +2 -2
  81. package/types/math/Vec2.d.ts +1 -1
  82. package/types/math/Vec3.d.ts +1 -1
  83. package/types/math/Vec4.d.ts +2 -2
  84. package/types/math.d.ts +1 -1
  85. package/types/renderer/Renderer.d.ts +1 -1
  86. package/types/renderer/RendererEvents.d.ts +1 -1
  87. package/types/shaders/label.d.ts +1 -1
  88. package/types/utils/FontAtlas.d.ts +3 -2
  89. package/types/utils/TextureAtlas.d.ts +3 -3
  90. package/types/utils/VectorTileCreator.d.ts +4 -4
  91. package/types/utils/shared.d.ts +1 -1
  92. package/types/webgl/Handler.d.ts +6 -31
  93. package/types/webgl/Program.d.ts +2 -0
@@ -1,363 +1,365 @@
1
- /**
2
- * @module og/layer/XYZ
3
- */
4
-
5
- "use strict";
6
-
7
- import * as mercator from "../mercator.js";
8
- import { EPSG3857 } from "../proj/EPSG3857.js";
9
- import { Layer } from "./Layer.js";
10
- import { stringTemplate } from "../utils/shared.js";
11
- import { RENDERING } from "../quadTree/quadTree.js";
12
-
13
- /**
14
- * Represents an imagery tiles source provider.
15
- * @class
16
- * @extends {Layer}
17
- * @param {string} name - Layer name.
18
- * @param {Object} options:
19
- * @param {number} [options.opacity=1.0] - Layer opacity.
20
- * @param {Array.<string>} [options.subdomains=['a','b','c']] - Subdomains of the tile service.
21
- * @param {number} [options.minZoom=0] - Minimal visibility zoom level.
22
- * @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
23
- * @param {number} [options.minNativeZoom=0] - Minimal available zoom level.
24
- * @param {number} [options.maxNativeZoom=19] - Maximal available zoom level.
25
- * @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
26
- * @param {boolean} [options.isBaseLayer=false] - Base layer flag.
27
- * @param {boolean} [options.visibility=true] - Layer visibility.
28
- * @param {string} [options.crossOrigin=true] - If true, all tiles will have their crossOrigin attribute set to ''.
29
- * @param {string} options.url - Tile url source template(see example below).
30
- * @param {string} options.textureFilter - texture gl filter. NEAREST, LINEAR, MIPMAP, ANISOTROPHIC.
31
- * @param {layer.XYZ~_urlRewriteCallback} options.urlRewrite - Url rewrite function.
32
- * @fires og.layer.XYZ#load
33
- * @fires og.layer.XYZ#loadend
34
- *
35
- * @example <caption>Creates OpenStreetMap base tile layer</caption>
36
- * new og.layer.XYZ("OpenStreetMap", {
37
- * isBaseLayer: true,
38
- * url: "http://b.tile.openstreetmap.org/{z}/{x}/{y}.png",
39
- * visibility: true,
40
- * attribution: 'Data @ <a href="http://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="http://www.openstreetmap.org/copyright">ODbL</a>'
41
- * });
42
- */
43
- class XYZ extends Layer {
44
- /**
45
- * @param {string} name - Layer name.
46
- * @param {*} options
47
- */
48
- constructor(name, options) {
49
- super(name, options);
50
-
51
- this.events.registerNames(EVENT_NAMES);
52
-
53
- /**
54
- * Tile url source template.
55
- * @public
56
- * @type {string}
57
- */
58
- this.url = options.url || "";
59
-
60
- /**
61
- * @protected
62
- */
63
- this._s = options.subdomains || ["a", "b", "c"];
64
-
65
- /**
66
- * Minimal native zoom level when tiles are available.
67
- * @public
68
- * @type {number}
69
- */
70
- this.minNativeZoom = options.minNativeZoom || 0;
71
-
72
- /**
73
- * Maximal native zoom level when tiles are available.
74
- * @public
75
- * @type {number}
76
- */
77
- this.maxNativeZoom = options.maxNativeZoom || 19;
78
-
79
- /**
80
- * @protected
81
- */
82
- this._crossOrigin = options.crossOrigin === undefined ? "" : options.crossOrigin;
83
-
84
- /**
85
- * Rewrites imagery tile url query.
86
- * @private
87
- * @callback og.layer.XYZ~_urlRewriteCallback
88
- * @param {Segment} segment - Segment to load.
89
- * @param {string} url - Created url.
90
- * @returns {string} - Url query string.
91
- */
92
- this._urlRewriteCallback = options.urlRewrite || null;
93
- }
94
-
95
- get instanceName() {
96
- return "XYZ";
97
- }
98
-
99
- /**
100
- * Abort loading tiles.
101
- * @public
102
- */
1
+ /**
2
+ * @module og/layer/XYZ
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import * as mercator from "../mercator.js";
8
+ import { EPSG3857 } from "../proj/EPSG3857.js";
9
+ import { Layer } from "./Layer.js";
10
+ import { stringTemplate } from "../utils/shared.js";
11
+ import { RENDERING } from "../quadTree/quadTree.js";
12
+
13
+ /**
14
+ * Represents an imagery tiles source provider.
15
+ * @class
16
+ * @extends {Layer}
17
+ * @param {string} name - Layer name.
18
+ * @param {Object} options:
19
+ * @param {number} [options.opacity=1.0] - Layer opacity.
20
+ * @param {Array.<string>} [options.subdomains=['a','b','c']] - Subdomains of the tile service.
21
+ * @param {number} [options.minZoom=0] - Minimal visibility zoom level.
22
+ * @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
23
+ * @param {number} [options.minNativeZoom=0] - Minimal available zoom level.
24
+ * @param {number} [options.maxNativeZoom=19] - Maximal available zoom level.
25
+ * @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
26
+ * @param {boolean} [options.isBaseLayer=false] - Base layer flag.
27
+ * @param {boolean} [options.visibility=true] - Layer visibility.
28
+ * @param {string} [options.crossOrigin=true] - If true, all tiles will have their crossOrigin attribute set to ''.
29
+ * @param {string} options.url - Tile url source template(see example below).
30
+ * @param {string} options.textureFilter - texture gl filter. NEAREST, LINEAR, MIPMAP, ANISOTROPHIC.
31
+ * @param {layer.XYZ~_urlRewriteCallback} options.urlRewrite - Url rewrite function.
32
+ * @fires og.layer.XYZ#load
33
+ * @fires og.layer.XYZ#loadend
34
+ *
35
+ * @example <caption>Creates OpenStreetMap base tile layer</caption>
36
+ * new og.layer.XYZ("OpenStreetMap", {
37
+ * isBaseLayer: true,
38
+ * url: "http://b.tile.openstreetmap.org/{z}/{x}/{y}.png",
39
+ * visibility: true,
40
+ * attribution: 'Data @ <a href="http://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="http://www.openstreetmap.org/copyright">ODbL</a>'
41
+ * });
42
+ */
43
+ class XYZ extends Layer {
44
+ /**
45
+ * @param {string} name - Layer name.
46
+ * @param {*} options
47
+ */
48
+ constructor(name, options) {
49
+ super(name, options);
50
+
51
+ this.events.registerNames(EVENT_NAMES);
52
+
53
+ /**
54
+ * Tile url source template.
55
+ * @public
56
+ * @type {string}
57
+ */
58
+ this.url = options.url || "";
59
+
60
+ /**
61
+ * @protected
62
+ */
63
+ this._s = options.subdomains || ["a", "b", "c"];
64
+
65
+ /**
66
+ * Minimal native zoom level when tiles are available.
67
+ * @public
68
+ * @type {number}
69
+ */
70
+ this.minNativeZoom = options.minNativeZoom || 0;
71
+
72
+ /**
73
+ * Maximal native zoom level when tiles are available.
74
+ * @public
75
+ * @type {number}
76
+ */
77
+ this.maxNativeZoom = options.maxNativeZoom || 19;
78
+
79
+ /**
80
+ * @protected
81
+ */
82
+ this._crossOrigin = options.crossOrigin === undefined ? "" : options.crossOrigin;
83
+
84
+ /**
85
+ * Rewrites imagery tile url query.
86
+ * @private
87
+ * @callback og.layer.XYZ~_urlRewriteCallback
88
+ * @param {Segment} segment - Segment to load.
89
+ * @param {string} url - Created url.
90
+ * @returns {string} - Url query string.
91
+ */
92
+ this._urlRewriteCallback = options.urlRewrite || null;
93
+ }
94
+
95
+ get instanceName() {
96
+ return "XYZ";
97
+ }
98
+
99
+ /**
100
+ * Abort loading tiles.
101
+ * @public
102
+ */
103
103
  abortLoading() {
104
- if (this._planet) {
104
+ if (this._planet) {
105
105
  this._planet._tileLoader.abort();
106
- }
107
- }
108
-
109
- /**
110
- * Sets layer visibility.
111
- * @public
112
- * @param {boolean} visibility - Layer visibility.
113
- */
114
- setVisibility(visibility) {
115
- if (visibility !== this._visibility) {
116
- super.setVisibility(visibility);
117
-
118
- if (!visibility) {
119
- this.abortLoading();
120
- }
121
- }
122
- }
123
-
124
- /**
125
- * Sets imagery tiles url source template.
126
- * @public
127
- * @param {string} url - Url template.
128
- * @example
129
- * http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
130
- * where {z}, {x} and {y} - replaces by current tile values, {s} - random domen.
131
- */
132
- setUrl(url) {
133
- this.url = url;
134
- }
135
-
136
- _checkSegment(segment) {
137
- return segment._projection.id === EPSG3857.id;
138
- }
139
-
140
- /**
141
- * Start to load tile material.
142
- * @public
143
- * @virtual
144
- * @param {Material} material - Loads current material.
145
- */
146
- loadMaterial(material, forceLoading) {
147
- let seg = material.segment;
148
-
149
- if (this._isBaseLayer) {
150
- material.texture = seg.getDefaultTexture();
151
- } else {
152
- material.texture = seg.planet.transparentTexture;
153
- }
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
- material.isReady = false;
158
- material.isLoading = true;
159
-
160
- if (this._checkSegment(seg)) {
161
- material.loadingAttempts++;
162
-
163
- this._planet._tileLoader.load(
164
- {
165
- src: this._getHTTPRequestString(material.segment),
166
- type: "imageBitmap",
167
- filter: () =>
168
- (seg.initialized && seg.node.getState() === RENDERING) || forceLoading,
169
- options: {}
170
- },
171
- (response) => {
172
- if (response.status === "ready") {
173
- if (material.isLoading) {
174
- let e = this.events.load;
175
- if (e.handlers.length) {
176
- this.events.dispatch(e, material);
177
- }
178
- material.applyImage(response.data);
179
- response.data = null;
180
- }
181
- } else if (response.status === "abort") {
182
- material.isLoading = false;
183
- } else if (response.status === "error") {
184
- if (material.isLoading) {
185
- material.textureNotExists();
186
- }
187
- }
188
- }
189
- );
190
- } else {
191
- material.textureNotExists();
192
- }
193
- }
194
- }
195
-
196
- /**
197
- * Creates query url.
198
- * @protected
199
- * @virtual
200
- * @param {Segment} segment - Creates specific url for current segment.
201
- * @returns {String} - Returns url string.
202
- */
203
- _createUrl(segment) {
204
- return stringTemplate(this.url, {
205
- s: this._getSubdomain(),
206
- x: segment.tileX.toString(),
207
- y: segment.tileY.toString(),
208
- z: segment.tileZoom.toString()
209
- });
210
- }
211
-
212
- _getSubdomain() {
213
- return this._s[Math.floor(Math.random() * this._s.length)];
214
- }
215
-
216
- /**
217
- * Returns actual url query string.
218
- * @protected
219
- * @param {Segment} segment - Segment that loads image data.
220
- * @returns {string} - Url string.
221
- */
222
- _getHTTPRequestString(segment) {
223
- return this._urlRewriteCallback
224
- ? this._urlRewriteCallback(segment, this.url)
225
- : this._createUrl(segment);
226
- }
227
-
228
- /**
229
- * Sets url rewrite callback, used for custom url rewriting for every tile laoding.
230
- * @public
231
- * @param {layer.XYZ~_urlRewriteCallback} ur - The callback that returns tile custom created url.
232
- */
233
- setUrlRewriteCallback(ur) {
234
- this._urlRewriteCallback = ur;
235
- }
236
-
237
- applyMaterial(material) {
238
- if (material.isReady) {
239
- return material.texOffset;
240
- } else {
241
-
242
- let segment = material.segment,
243
- pn = segment.node,
244
- notEmpty = false;
245
-
246
- let mId = this._id;
247
- let psegm = material;
248
- while (pn.parentNode) {
249
- pn = pn.parentNode;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Sets layer visibility.
111
+ * @public
112
+ * @param {boolean} visibility - Layer visibility.
113
+ */
114
+ setVisibility(visibility) {
115
+ if (visibility !== this._visibility) {
116
+ super.setVisibility(visibility);
117
+
118
+ if (!visibility) {
119
+ this.abortLoading();
120
+ }
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Sets imagery tiles url source template.
126
+ * @public
127
+ * @param {string} url - Url template.
128
+ * @example
129
+ * http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
130
+ * where {z}, {x} and {y} - replaces by current tile values, {s} - random domen.
131
+ */
132
+ setUrl(url) {
133
+ this.url = url;
134
+ }
135
+
136
+ _checkSegment(segment) {
137
+ return segment._projection.id === EPSG3857.id;
138
+ }
139
+
140
+ /**
141
+ * Start to load tile material.
142
+ * @public
143
+ * @virtual
144
+ * @param {Material} material - Loads current material.
145
+ */
146
+ loadMaterial(material, forceLoading) {
147
+ let seg = material.segment;
148
+
149
+ if (this._isBaseLayer) {
150
+ material.texture = seg.getDefaultTexture();
151
+ } else {
152
+ material.texture = seg.planet.transparentTexture;
153
+ }
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
+ material.isReady = false;
158
+ material.isLoading = true;
159
+
160
+ if (this._checkSegment(seg)) {
161
+ material.loadingAttempts++;
162
+
163
+ this._planet._tileLoader.load(
164
+ {
165
+ src: this._getHTTPRequestString(material.segment),
166
+ type: "imageBitmap",
167
+ filter: () =>
168
+ (seg.initialized && seg.node.getState() === RENDERING) || forceLoading,
169
+ options: {}
170
+ },
171
+ (response) => {
172
+ if (response.status === "ready") {
173
+ if (material.isLoading) {
174
+ let e = this.events.load;
175
+ if (e.handlers.length) {
176
+ this.events.dispatch(e, material);
177
+ }
178
+ material.applyImage(response.data);
179
+ response.data = null;
180
+ }
181
+ } else if (response.status === "abort") {
182
+ material.isLoading = false;
183
+ } else if (response.status === "error") {
184
+ if (material.isLoading) {
185
+ material.textureNotExists();
186
+ }
187
+ }
188
+ }
189
+ );
190
+ } else {
191
+ material.textureNotExists();
192
+ }
193
+ }
194
+ }
195
+
196
+ /**
197
+ * Creates query url.
198
+ * @protected
199
+ * @virtual
200
+ * @param {Segment} segment - Creates specific url for current segment.
201
+ * @returns {String} - Returns url string.
202
+ */
203
+ _createUrl(segment) {
204
+ return stringTemplate(this.url, {
205
+ s: this._getSubdomain(),
206
+ x: segment.tileX.toString(),
207
+ y: segment.tileY.toString(),
208
+ z: segment.tileZoom.toString()
209
+ });
210
+ }
211
+
212
+ _getSubdomain() {
213
+ return this._s[Math.floor(Math.random() * this._s.length)];
214
+ }
215
+
216
+ /**
217
+ * Returns actual url query string.
218
+ * @protected
219
+ * @param {Segment} segment - Segment that loads image data.
220
+ * @returns {string} - Url string.
221
+ */
222
+ _getHTTPRequestString(segment) {
223
+ return this._urlRewriteCallback
224
+ ? this._urlRewriteCallback(segment, this.url)
225
+ : this._createUrl(segment);
226
+ }
227
+
228
+ /**
229
+ * Sets url rewrite callback, used for custom url rewriting for every tile laoding.
230
+ * @public
231
+ * @param {layer.XYZ~_urlRewriteCallback} ur - The callback that returns tile custom created url.
232
+ */
233
+ setUrlRewriteCallback(ur) {
234
+ this._urlRewriteCallback = ur;
235
+ }
236
+
237
+ applyMaterial(material) {
238
+ if (material.isReady) {
239
+ return material.texOffset;
240
+ } else if (material.segment.tileZoom <= this.minNativeZoom) {
241
+ material.textureNotExists();
242
+ } else {
243
+
244
+ let segment = material.segment,
245
+ pn = segment.node,
246
+ notEmpty = false;
247
+
248
+ let mId = this._id;
249
+ let psegm = material;
250
+ while (pn.parentNode) {
251
+ pn = pn.parentNode;
250
252
  psegm = pn.segment.materials[mId];
251
- if (psegm && psegm.textureExists) {
252
- notEmpty = true;
253
- break;
254
- }
255
- }
253
+ if (psegm && psegm.textureExists) {
254
+ notEmpty = true;
255
+ break;
256
+ }
257
+ }
256
258
 
257
259
  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);
263
- } else {
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
- }
260
+ let maxNativeZoom = material.layer.maxNativeZoom;
261
+ if (pn.segment.tileZoom === maxNativeZoom) {
262
+ material.textureNotExists();
263
+ } else if (material.segment.tileZoom <= maxNativeZoom) {
264
+ !material.isLoading && !material.isReady && this.loadMaterial(material);
265
+ } else {
266
+ let pn = segment.node;
267
+ while (pn.segment.tileZoom > material.layer.maxNativeZoom) {
268
+ pn = pn.parentNode;
269
+ }
270
+ let pnm = pn.segment.materials[material.layer._id];
271
+ if (pnm) {
272
+ !pnm.isLoading && !pnm.isReady && this.loadMaterial(pnm, true);
273
+ } else {
274
+ pnm = pn.segment.materials[material.layer._id] = material.layer.createMaterial(
275
+ pn.segment
276
+ );
277
+ this.loadMaterial(pnm, true);
278
+ }
277
279
  }
278
- }
279
-
280
- if (notEmpty) {
281
- material.appliedNode = pn;
282
- material.appliedNodeId = pn.nodeId;
283
- material.texture = psegm.texture;
284
- let dZ2 = 1.0 / (2 << (segment.tileZoom - pn.segment.tileZoom - 1));
285
- material.texOffset[0] = segment.tileX * dZ2 - pn.segment.tileX;
286
- material.texOffset[1] = segment.tileY * dZ2 - pn.segment.tileY;
287
- material.texOffset[2] = dZ2;
288
- material.texOffset[3] = dZ2;
289
- } else {
290
- material.texture = segment.planet.transparentTexture;
291
- material.texOffset[0] = 0.0;
292
- material.texOffset[1] = 0.0;
293
- material.texOffset[2] = 1.0;
294
- material.texOffset[3] = 1.0;
295
- }
296
- }
297
-
298
- return material.texOffset;
299
- }
300
-
301
- clearMaterial(material) {
302
- if (material.isReady && material.textureExists) {
303
- !material.texture.default &&
304
- material.segment.handler.gl.deleteTexture(material.texture);
305
- material.texture = null;
306
-
307
- if (material.image) {
308
- material.image.src = "";
309
- material.image = null;
310
- }
311
- }
312
-
313
- material.isReady = false;
314
- material.textureExists = false;
315
- material.isLoading = false;
316
- }
317
-
318
- /**
319
- * @protected
320
- */
321
- _correctFullExtent() {
322
- var e = this._extent,
323
- em = this._extentMerc;
324
- var ENLARGE_MERCATOR_LON = mercator.POLE + 50000;
325
- var ENLARGE_MERCATOR_LAT = mercator.POLE + 50000;
326
- if (e.northEast.lat === 90.0) {
327
- em.northEast.lat = ENLARGE_MERCATOR_LAT;
328
- }
329
- if (e.northEast.lon === 180.0) {
330
- em.northEast.lon = ENLARGE_MERCATOR_LON;
331
- }
332
- if (e.southWest.lat === -90.0) {
333
- em.southWest.lat = -ENLARGE_MERCATOR_LAT;
334
- }
335
- if (e.southWest.lon === -180.0) {
336
- em.southWest.lon = -ENLARGE_MERCATOR_LON;
337
- }
338
-
339
- if (e.northEast.lat >= mercator.MAX_LAT) {
340
- e.northEast.lat = mercator.MAX_LAT;
341
- }
342
-
343
- if (e.northEast.lat <= mercator.MIN_LAT) {
344
- e.northEast.lat = mercator.MIN_LAT;
345
- }
346
- }
347
- }
348
-
349
- const EVENT_NAMES = [
350
- /**
351
- * Triggered when current tile image has loaded before rendereing.
352
- * @event og.layer.XYZ#load
353
- */
354
- "load",
355
-
356
- /**
357
- * Triggered when all tiles have loaded or loading has stopped.
358
- * @event og.layer.XYZ#loadend
359
- */
360
- "loadend"
361
- ];
362
-
363
- export { XYZ };
280
+ }
281
+
282
+ if (notEmpty) {
283
+ material.appliedNode = pn;
284
+ material.appliedNodeId = pn.nodeId;
285
+ material.texture = psegm.texture;
286
+ let dZ2 = 1.0 / (2 << (segment.tileZoom - pn.segment.tileZoom - 1));
287
+ material.texOffset[0] = segment.tileX * dZ2 - pn.segment.tileX;
288
+ material.texOffset[1] = segment.tileY * dZ2 - pn.segment.tileY;
289
+ material.texOffset[2] = dZ2;
290
+ material.texOffset[3] = dZ2;
291
+ } else {
292
+ material.texture = segment.planet.transparentTexture;
293
+ material.texOffset[0] = 0.0;
294
+ material.texOffset[1] = 0.0;
295
+ material.texOffset[2] = 1.0;
296
+ material.texOffset[3] = 1.0;
297
+ }
298
+ }
299
+
300
+ return material.texOffset;
301
+ }
302
+
303
+ clearMaterial(material) {
304
+ if (material.isReady && material.textureExists) {
305
+ !material.texture.default &&
306
+ material.segment.handler.gl.deleteTexture(material.texture);
307
+ material.texture = null;
308
+
309
+ if (material.image) {
310
+ material.image.src = "";
311
+ material.image = null;
312
+ }
313
+ }
314
+
315
+ material.isReady = false;
316
+ material.textureExists = false;
317
+ material.isLoading = false;
318
+ }
319
+
320
+ /**
321
+ * @protected
322
+ */
323
+ _correctFullExtent() {
324
+ var e = this._extent,
325
+ em = this._extentMerc;
326
+ var ENLARGE_MERCATOR_LON = mercator.POLE + 50000;
327
+ var ENLARGE_MERCATOR_LAT = mercator.POLE + 50000;
328
+ if (e.northEast.lat === 90.0) {
329
+ em.northEast.lat = ENLARGE_MERCATOR_LAT;
330
+ }
331
+ if (e.northEast.lon === 180.0) {
332
+ em.northEast.lon = ENLARGE_MERCATOR_LON;
333
+ }
334
+ if (e.southWest.lat === -90.0) {
335
+ em.southWest.lat = -ENLARGE_MERCATOR_LAT;
336
+ }
337
+ if (e.southWest.lon === -180.0) {
338
+ em.southWest.lon = -ENLARGE_MERCATOR_LON;
339
+ }
340
+
341
+ if (e.northEast.lat >= mercator.MAX_LAT) {
342
+ e.northEast.lat = mercator.MAX_LAT;
343
+ }
344
+
345
+ if (e.northEast.lat <= mercator.MIN_LAT) {
346
+ e.northEast.lat = mercator.MIN_LAT;
347
+ }
348
+ }
349
+ }
350
+
351
+ const EVENT_NAMES = [
352
+ /**
353
+ * Triggered when current tile image has loaded before rendereing.
354
+ * @event og.layer.XYZ#load
355
+ */
356
+ "load",
357
+
358
+ /**
359
+ * Triggered when all tiles have loaded or loading has stopped.
360
+ * @event og.layer.XYZ#loadend
361
+ */
362
+ "loadend"
363
+ ];
364
+
365
+ export { XYZ };