@openglobus/og 0.15.3 → 0.15.5

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 (71) hide show
  1. package/README.md +3 -7
  2. package/css/og.css +24 -15
  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/Globe.js +4 -0
  10. package/src/og/LonLat.js +207 -193
  11. package/src/og/Object3d.js +1 -1
  12. package/src/og/camera/Camera.js +4 -16
  13. package/src/og/camera/PlanetCamera.js +12 -6
  14. package/src/og/control/DebugInfo.js +263 -165
  15. package/src/og/control/KeyboardNavigation.js +153 -169
  16. package/src/og/control/MouseNavigation.js +0 -20
  17. package/src/og/control/RulerSwitcher.js +4 -1
  18. package/src/og/control/SimpleNavigation.js +123 -128
  19. package/src/og/control/heightRuler/HeightRuler.js +12 -0
  20. package/src/og/control/heightRuler/HeightRulerScene.js +224 -0
  21. package/src/og/control/heightRuler/HeightRulerSwitcher.js +15 -0
  22. package/src/og/control/index.js +2 -0
  23. package/src/og/control/ruler/RulerScene.js +106 -79
  24. package/src/og/ellipsoid/Ellipsoid.js +20 -3
  25. package/src/og/entity/Entity.js +6 -6
  26. package/src/og/entity/EntityCollection.js +4 -0
  27. package/src/og/entity/GeoObjectHandler.js +3 -0
  28. package/src/og/layer/BaseGeoImage.js +152 -16
  29. package/src/og/layer/GeoImage.js +0 -91
  30. package/src/og/layer/GeoTexture2d.js +54 -143
  31. package/src/og/layer/GeoVideo.js +6 -107
  32. package/src/og/layer/Material.js +1 -1
  33. package/src/og/layer/Vector.js +8 -6
  34. package/src/og/layer/XYZ.js +2 -2
  35. package/src/og/quadTree/EntityCollectionNode.js +8 -2
  36. package/src/og/renderer/Renderer.js +91 -94
  37. package/src/og/renderer/RendererEvents.js +39 -23
  38. package/src/og/scene/BaseNode.js +113 -113
  39. package/src/og/scene/Planet.js +20 -13
  40. package/src/og/scene/RenderNode.js +42 -9
  41. package/src/og/segment/Segment.js +38 -45
  42. package/src/og/shaders/geoObject.js +12 -10
  43. package/src/og/shaders/pickingMask.js +1 -1
  44. package/src/og/utils/GeoImageCreator.js +61 -21
  45. package/src/og/utils/VectorTileCreator.js +32 -49
  46. package/src/og/webgl/Framebuffer.js +5 -0
  47. package/types/LonLat.d.ts +8 -0
  48. package/types/camera/PlanetCamera.d.ts +1 -1
  49. package/types/control/DebugInfo.d.ts +4 -0
  50. package/types/control/SimpleNavigation.d.ts +1 -0
  51. package/types/control/heightRuler/HeightRuler.d.ts +6 -0
  52. package/types/control/heightRuler/HeightRulerScene.d.ts +23 -0
  53. package/types/control/index.d.ts +2 -1
  54. package/types/control/ruler/RulerScene.d.ts +8 -5
  55. package/types/control/selection/SelectionScene.d.ts +0 -1
  56. package/types/ellipsoid/Ellipsoid.d.ts +13 -1
  57. package/types/entity/EntityCollection.d.ts +1 -0
  58. package/types/layer/BaseGeoImage.d.ts +17 -3
  59. package/types/layer/GeoImage.d.ts +0 -8
  60. package/types/layer/GeoTexture2d.d.ts +0 -2
  61. package/types/layer/GeoVideo.d.ts +0 -8
  62. package/types/layer/XYZ.d.ts +1 -1
  63. package/types/renderer/Renderer.d.ts +12 -3
  64. package/types/scene/Axes.d.ts +1 -1
  65. package/types/scene/BaseNode.d.ts +2 -2
  66. package/types/scene/Planet.d.ts +0 -5
  67. package/types/scene/RenderNode.d.ts +16 -9
  68. package/types/scene/SkyBox.d.ts +1 -1
  69. package/types/segment/Segment.d.ts +2 -3
  70. package/types/utils/VectorTileCreator.d.ts +1 -3
  71. package/types/webgl/Framebuffer.d.ts +1 -0
@@ -8,6 +8,7 @@ import { Extent } from "../Extent.js";
8
8
  import { LonLat } from "../LonLat.js";
9
9
  import * as mercator from "../mercator.js";
10
10
  import { Layer } from "./Layer.js";
11
+ import { doubleToTwoFloats2 } from "../math/coder.js";
11
12
 
12
13
  const EVENT_NAMES = [
13
14
  /**
@@ -37,6 +38,12 @@ class BaseGeoImage extends Layer {
37
38
 
38
39
  this._gridBuffer = null;
39
40
  this._extentWgs84Params = null;
41
+ this._extentWgs84ParamsHigh = new Float32Array(4);
42
+ this._extentWgs84ParamsLow = new Float32Array(4);
43
+
44
+ this._extentMercParams = null;
45
+ this._extentMercParamsHigh = new Float32Array(4);
46
+ this._extentMercParamsLow = new Float32Array(4);
40
47
 
41
48
  this._refreshFrame = true;
42
49
  this._frameCreated = false;
@@ -186,20 +193,33 @@ class BaseGeoImage extends Layer {
186
193
  this._extentWgs84.northEast.forwardMercatorEPS01()
187
194
  );
188
195
 
196
+ let tempArr = new Float32Array(2);
197
+
189
198
  if (this._projType === 0) {
190
- this._extentWgs84Params = [
191
- this._extentWgs84.southWest.lon,
192
- this._extentWgs84.southWest.lat,
193
- 2.0 / this._extentWgs84.getWidth(),
194
- 2.0 / this._extentWgs84.getHeight()
195
- ];
199
+
200
+ doubleToTwoFloats2(this._extentWgs84.southWest.lon, tempArr);
201
+ this._extentWgs84ParamsHigh[0] = tempArr[0];
202
+ this._extentWgs84ParamsLow[0] = tempArr[1];
203
+
204
+ doubleToTwoFloats2(this._extentWgs84.southWest.lat, tempArr);
205
+ this._extentWgs84ParamsHigh[1] = tempArr[0];
206
+ this._extentWgs84ParamsLow[1] = tempArr[1];
207
+
208
+ this._extentWgs84ParamsHigh[2] = 2.0 / this._extentWgs84.getWidth();
209
+ this._extentWgs84ParamsHigh[3] = 2.0 / this._extentWgs84.getHeight();
210
+
196
211
  } else {
197
- this._extentMercParams = [
198
- this._extentMerc.southWest.lon,
199
- this._extentMerc.southWest.lat,
200
- 2.0 / this._extentMerc.getWidth(),
201
- 2.0 / this._extentMerc.getHeight()
202
- ];
212
+
213
+ doubleToTwoFloats2(this._extentMerc.southWest.lon, tempArr);
214
+ this._extentMercParamsHigh[0] = tempArr[0];
215
+ this._extentMercParamsLow[0] = tempArr[1];
216
+
217
+ doubleToTwoFloats2(this._extentMerc.southWest.lat, tempArr);
218
+ this._extentMercParamsHigh[1] = tempArr[0];
219
+ this._extentMercParamsLow[1] = tempArr[1];
220
+
221
+ this._extentMercParamsHigh[2] = 2.0 / this._extentMerc.getWidth();
222
+ this._extentMercParamsHigh[3] = 2.0 / this._extentMerc.getHeight();
203
223
  }
204
224
 
205
225
  // creates material frame textures
@@ -211,11 +231,14 @@ class BaseGeoImage extends Layer {
211
231
  gl.deleteTexture(this._materialTexture);
212
232
  this._materialTexture = h.createEmptyTexture_l(this._frameWidth, this._frameHeight);
213
233
 
214
- this._gridBuffer = this._planet._geoImageCreator.createGridBuffer(
234
+ let gridBufferArr = this._planet._geoImageCreator.createGridBuffer(
215
235
  this._cornersWgs84,
216
236
  this._projType
217
237
  );
218
238
 
239
+ this._gridBufferHigh = gridBufferArr[0];
240
+ this._gridBufferLow = gridBufferArr[1];
241
+
219
242
  this._refreshFrame = false;
220
243
  }
221
244
  }
@@ -235,10 +258,10 @@ class BaseGeoImage extends Layer {
235
258
  * @virtual
236
259
  */
237
260
  clear() {
238
- var p = this._planet;
261
+ let p = this._planet;
239
262
 
240
263
  if (p) {
241
- var gl = p.renderer.handler.gl;
264
+ let gl = p.renderer.handler.gl;
242
265
  this._creationProceeding && p._geoImageCreator.remove(this);
243
266
  p._clearLayerMaterial(this);
244
267
 
@@ -307,7 +330,7 @@ class BaseGeoImage extends Layer {
307
330
  !this._creationProceeding && this.loadMaterial(material);
308
331
  }
309
332
 
310
- var v0s, v0t;
333
+ let v0s, v0t;
311
334
  if (this._projType === 0) {
312
335
  v0s = this._extentWgs84;
313
336
  v0t = segment._extent;
@@ -342,6 +365,119 @@ class BaseGeoImage extends Layer {
342
365
  get getFrameHeight() {
343
366
  return this._frameHeight;
344
367
  }
368
+
369
+ /**
370
+ * Method depends on GeoImage instance
371
+ * @virtual
372
+ * @private
373
+ */
374
+ _createSourceTexture() {
375
+ //empty
376
+ }
377
+
378
+ _renderingProjType1() {
379
+ let p = this._planet,
380
+ h = p.renderer.handler,
381
+ gl = h.gl,
382
+ creator = p._geoImageCreator;
383
+
384
+ this._refreshFrame && this._createFrame();
385
+ this._createSourceTexture();
386
+
387
+ let f = creator._framebuffer;
388
+ f.setSize(this._frameWidth, this._frameHeight);
389
+ f.activate();
390
+
391
+ h.programs.geoImageTransform.activate();
392
+ var sh = h.programs.geoImageTransform._program;
393
+ var sha = sh.attributes,
394
+ shu = sh.uniforms;
395
+
396
+ gl.disable(gl.CULL_FACE);
397
+
398
+ f.bindOutputTexture(this._materialTexture);
399
+ gl.clearColor(0.0, 0.0, 0.0, 0.0);
400
+ gl.clear(gl.COLOR_BUFFER_BIT);
401
+
402
+ gl.uniform1i(shu.isFullExtent, this._isFullExtent);
403
+
404
+ gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
405
+
406
+ gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
407
+
408
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBufferHigh);
409
+ gl.vertexAttribPointer(sha.cornersHigh, this._gridBufferHigh.itemSize, gl.FLOAT, false, 0, 0);
410
+
411
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBufferLow);
412
+ gl.vertexAttribPointer(sha.cornersLow, this._gridBufferLow.itemSize, gl.FLOAT, false, 0, 0);
413
+
414
+ gl.uniform4fv(shu.extentParamsHigh, this._extentMercParamsHigh);
415
+ gl.uniform4fv(shu.extentParamsLow, this._extentMercParamsLow);
416
+
417
+ gl.activeTexture(gl.TEXTURE0);
418
+ gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
419
+ gl.uniform1i(shu.sourceTexture, 0);
420
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
421
+ gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
422
+ f.deactivate();
423
+
424
+ gl.enable(gl.CULL_FACE);
425
+
426
+ this._ready = true;
427
+
428
+ this._creationProceeding = false;
429
+ }
430
+
431
+ _renderingProjType0() {
432
+ let p = this._planet,
433
+ h = p.renderer.handler,
434
+ gl = h.gl,
435
+ creator = p._geoImageCreator;
436
+
437
+ this._refreshFrame && this._createFrame();
438
+ this._createSourceTexture();
439
+
440
+ let f = creator._framebuffer;
441
+ f.setSize(this._frameWidth, this._frameHeight);
442
+ f.activate();
443
+
444
+ h.programs.geoImageTransform.activate();
445
+ let sh = h.programs.geoImageTransform._program;
446
+ let sha = sh.attributes,
447
+ shu = sh.uniforms;
448
+
449
+ gl.disable(gl.CULL_FACE);
450
+
451
+ f.bindOutputTexture(this._materialTexture);
452
+ gl.clearColor(0.0, 0.0, 0.0, 0.0);
453
+ gl.clear(gl.COLOR_BUFFER_BIT);
454
+ gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
455
+
456
+ gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
457
+
458
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBufferHigh);
459
+ gl.vertexAttribPointer(sha.cornersHigh, this._gridBufferHigh.itemSize, gl.FLOAT, false, 0, 0);
460
+
461
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBufferLow);
462
+ gl.vertexAttribPointer(sha.cornersLow, this._gridBufferLow.itemSize, gl.FLOAT, false, 0, 0);
463
+
464
+ gl.uniform4fv(shu.extentParamsHigh, this._extentWgs84ParamsHigh);
465
+ gl.uniform4fv(shu.extentParamsLow, this._extentWgs84ParamsLow);
466
+
467
+ gl.activeTexture(gl.TEXTURE0);
468
+ gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
469
+ gl.uniform1i(shu.sourceTexture, 0);
470
+
471
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
472
+ gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
473
+ f.deactivate();
474
+
475
+ gl.enable(gl.CULL_FACE);
476
+
477
+ this._ready = true;
478
+
479
+ this._creationProceeding = false;
480
+ }
345
481
  }
346
482
 
347
483
  export { BaseGeoImage };
@@ -127,97 +127,6 @@ class GeoImage extends BaseGeoImage {
127
127
  material.isLoading = false;
128
128
  material.isReady = false;
129
129
  }
130
-
131
- _renderingProjType1() {
132
- var p = this._planet,
133
- h = p.renderer.handler,
134
- gl = h.gl,
135
- creator = p._geoImageCreator;
136
-
137
- this._refreshFrame && this._createFrame();
138
- this._createSourceTexture();
139
-
140
- var f = creator._framebuffer;
141
- f.setSize(this._frameWidth, this._frameHeight);
142
- f.activate();
143
-
144
- h.programs.geoImageTransform.activate();
145
- var sh = h.programs.geoImageTransform._program;
146
- var sha = sh.attributes,
147
- shu = sh.uniforms;
148
-
149
- gl.disable(gl.CULL_FACE);
150
-
151
- f.bindOutputTexture(this._materialTexture);
152
- gl.clearColor(0.0, 0.0, 0.0, 0.0);
153
- gl.clear(gl.COLOR_BUFFER_BIT);
154
-
155
- gl.uniform1i(shu.isFullExtent, this._isFullExtent);
156
-
157
- gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
158
-
159
- gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
160
-
161
- gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBuffer);
162
- gl.vertexAttribPointer(sha.corners, this._gridBuffer.itemSize, gl.FLOAT, false, 0, 0);
163
- gl.uniform4fv(shu.extentParams, this._extentMercParams);
164
- gl.activeTexture(gl.TEXTURE0);
165
- gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
166
- gl.uniform1i(shu.sourceTexture, 0);
167
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
168
- gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
169
- f.deactivate();
170
-
171
- gl.enable(gl.CULL_FACE);
172
-
173
- this._ready = true;
174
-
175
- this._creationProceeding = false;
176
- }
177
-
178
- _renderingProjType0() {
179
- var p = this._planet,
180
- h = p.renderer.handler,
181
- gl = h.gl,
182
- creator = p._geoImageCreator;
183
-
184
- this._refreshFrame && this._createFrame();
185
- this._createSourceTexture();
186
-
187
- var f = creator._framebuffer;
188
- f.setSize(this._frameWidth, this._frameHeight);
189
- f.activate();
190
-
191
- h.programs.geoImageTransform.activate();
192
- var sh = h.programs.geoImageTransform._program;
193
- var sha = sh.attributes,
194
- shu = sh.uniforms;
195
-
196
- gl.disable(gl.CULL_FACE);
197
-
198
- f.bindOutputTexture(this._materialTexture);
199
- gl.clearColor(0.0, 0.0, 0.0, 0.0);
200
- gl.clear(gl.COLOR_BUFFER_BIT);
201
- gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
202
-
203
- gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
204
-
205
- gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBuffer);
206
- gl.vertexAttribPointer(sha.corners, this._gridBuffer.itemSize, gl.FLOAT, false, 0, 0);
207
- gl.uniform4fv(shu.extentParams, this._extentWgs84Params);
208
- gl.activeTexture(gl.TEXTURE0);
209
- gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
210
- gl.uniform1i(shu.sourceTexture, 0);
211
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
212
- gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
213
- f.deactivate();
214
-
215
- gl.enable(gl.CULL_FACE);
216
-
217
- this._ready = true;
218
-
219
- this._creationProceeding = false;
220
- }
221
130
  }
222
131
 
223
132
  export { GeoImage };
@@ -1,143 +1,54 @@
1
- /**
2
- * @module og/layer/GeoTexture2d
3
- */
4
-
5
- 'use strict';
6
-
7
- import * as math from '../math.js';
8
- import { BaseGeoImage } from './BaseGeoImage.js';
9
-
10
- class GeoTexture2d extends BaseGeoImage {
11
- constructor(name, options) {
12
- super(name, options);
13
-
14
- this._sourceTexture = options.texture || null;
15
-
16
- if (options.texture) {
17
- this._sourceReady = true;
18
- this._sourceCreated = true;
19
- }
20
-
21
- this._frameWidth = options.frameWidth ? math.nextHighestPowerOfTwo(options.frameWidth) : 256;
22
- this._frameHeight = options.frameHeight ? math.nextHighestPowerOfTwo(options.frameHeight) : 256;
23
-
24
- this._animate = true;
25
- }
26
-
27
- get instanceName() {
28
- return "GeoTexture2d";
29
- }
30
-
31
- loadMaterial(material) {
32
- this._planet._geoImageCreator.add(this);
33
- }
34
-
35
- bindTexture(texture) {
36
- this._sourceReady = true;
37
- this._sourceCreated = true;
38
- this._sourceTexture = texture;
39
- }
40
-
41
- setSize(width, height) {
42
- this._frameWidth = width;
43
- this._frameHeight = height;
44
- this._frameCreated = false;
45
- }
46
-
47
- abortMaterialLoading(material) {
48
- this._creationProceeding = false;
49
- material.isLoading = false;
50
- material.isReady = false;
51
- }
52
-
53
- _renderingProjType1() {
54
- var p = this._planet,
55
- h = p.renderer.handler,
56
- gl = h.gl,
57
- creator = p._geoImageCreator;
58
-
59
- this._refreshFrame && this._createFrame();
60
-
61
- var f = creator._framebuffer;
62
- f.setSize(this._frameWidth, this._frameHeight);
63
- f.activate();
64
-
65
- h.programs.geoImageTransform.activate();
66
- var sh = h.programs.geoImageTransform._program;
67
- var sha = sh.attributes,
68
- shu = sh.uniforms;
69
-
70
- gl.disable(gl.CULL_FACE);
71
-
72
- f.bindOutputTexture(this._materialTexture);
73
- gl.clearColor(0.0, 0.0, 0.0, 0.0);
74
- gl.clear(gl.COLOR_BUFFER_BIT);
75
- gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
76
-
77
- gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
78
-
79
- gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBuffer);
80
- gl.vertexAttribPointer(sha.corners, this._gridBuffer.itemSize, gl.FLOAT, false, 0, 0);
81
- gl.uniform4fv(shu.extentParams, this._extentMercParams);
82
- gl.activeTexture(gl.TEXTURE0);
83
- gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
84
- gl.uniform1i(shu.sourceTexture, 0);
85
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
86
- gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
87
- f.deactivate();
88
-
89
- gl.enable(gl.CULL_FACE);
90
-
91
- this._ready = true;
92
-
93
- this._creationProceeding = false;
94
- }
95
-
96
- _renderingProjType0() {
97
- var p = this._planet,
98
- h = p.renderer.handler,
99
- gl = h.gl,
100
- creator = p._geoImageCreator;
101
-
102
- var width = this._frameWidth,
103
- height = this._frameHeight;
104
-
105
- this._refreshFrame && this._createFrame();
106
-
107
- var f = creator._framebuffer;
108
- f.setSize(width, height);
109
- f.activate();
110
-
111
- h.programs.geoImageTransform.activate();
112
- var sh = h.programs.geoImageTransform._program;
113
- var sha = sh.attributes,
114
- shu = sh.uniforms;
115
-
116
- gl.disable(gl.CULL_FACE);
117
-
118
- f.bindOutputTexture(this._materialTexture);
119
- gl.clearColor(0.0, 0.0, 0.0, 0.0);
120
- gl.clear(gl.COLOR_BUFFER_BIT);
121
- gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
122
-
123
- gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
124
-
125
- gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBuffer);
126
- gl.vertexAttribPointer(sha.corners, this._gridBuffer.itemSize, gl.FLOAT, false, 0, 0);
127
- gl.uniform4fv(shu.extentParams, this._extentWgs84Params);
128
- gl.activeTexture(gl.TEXTURE0);
129
- gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
130
- gl.uniform1i(shu.sourceTexture, 0);
131
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
132
- gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
133
- f.deactivate();
134
-
135
- gl.enable(gl.CULL_FACE);
136
-
137
- this._ready = true;
138
-
139
- this._creationProceeding = false;
140
- }
141
- }
142
-
143
- export { GeoTexture2d };
1
+ /**
2
+ * @module og/layer/GeoTexture2d
3
+ */
4
+
5
+ 'use strict';
6
+
7
+ import * as math from '../math.js';
8
+ import { BaseGeoImage } from './BaseGeoImage.js';
9
+
10
+ class GeoTexture2d extends BaseGeoImage {
11
+ constructor(name, options) {
12
+ super(name, options);
13
+
14
+ this._sourceTexture = options.texture || null;
15
+
16
+ if (options.texture) {
17
+ this._sourceReady = true;
18
+ this._sourceCreated = true;
19
+ }
20
+
21
+ this._frameWidth = options.frameWidth ? math.nextHighestPowerOfTwo(options.frameWidth) : 256;
22
+ this._frameHeight = options.frameHeight ? math.nextHighestPowerOfTwo(options.frameHeight) : 256;
23
+
24
+ this._animate = true;
25
+ }
26
+
27
+ get instanceName() {
28
+ return "GeoTexture2d";
29
+ }
30
+
31
+ loadMaterial(material) {
32
+ this._planet._geoImageCreator.add(this);
33
+ }
34
+
35
+ bindTexture(texture) {
36
+ this._sourceReady = true;
37
+ this._sourceCreated = true;
38
+ this._sourceTexture = texture;
39
+ }
40
+
41
+ setSize(width, height) {
42
+ this._frameWidth = width;
43
+ this._frameHeight = height;
44
+ this._frameCreated = false;
45
+ }
46
+
47
+ abortMaterialLoading(material) {
48
+ this._creationProceeding = false;
49
+ material.isLoading = false;
50
+ material.isReady = false;
51
+ }
52
+ }
53
+
54
+ export { GeoTexture2d };
@@ -90,13 +90,13 @@ class GeoVideo extends BaseGeoImage {
90
90
  * @protected
91
91
  */
92
92
  _createSourceTexture() {
93
- if (!this._sourceCreated) {
94
- this._sourceTexture = this._planet.renderer.handler.createTexture_n_webgl1(this._video);
95
- this._sourceCreated = true;
96
- } else {
97
- var gl = this._planet.renderer.handler.gl;
93
+ let gl = this._planet.renderer.handler.gl;
94
+ if (this._sourceCreated) {
98
95
  gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
99
96
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._video);
97
+ } else {
98
+ this._sourceTexture = this._planet.renderer.handler.createTexture_n_webgl1(this._video);
99
+ this._sourceCreated = true;
100
100
  }
101
101
  }
102
102
 
@@ -117,7 +117,7 @@ class GeoVideo extends BaseGeoImage {
117
117
  * @private
118
118
  */
119
119
  _onError(video) {
120
- var err = "unknown error";
120
+ let err = "unknown error";
121
121
  switch (video.error.code) {
122
122
  case 1:
123
123
  err = "video loading aborted";
@@ -186,107 +186,6 @@ class GeoVideo extends BaseGeoImage {
186
186
  material.isLoading = false;
187
187
  material.isReady = false;
188
188
  }
189
-
190
- _renderingProjType1() {
191
- var p = this._planet,
192
- h = p.renderer.handler,
193
- gl = h.gl,
194
- creator = p._geoImageCreator;
195
-
196
- this._refreshFrame && this._createFrame();
197
-
198
- if (this._sourceCreated) {
199
- gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
200
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._video);
201
- } else {
202
- this._sourceTexture = this._planet.renderer.handler.createTexture_n_webgl1(this._video);
203
- this._sourceCreated = true;
204
- }
205
-
206
- var f = creator._framebuffer;
207
- f.setSize(this._frameWidth, this._frameHeight);
208
- f.activate();
209
-
210
- h.programs.geoImageTransform.activate();
211
- var sh = h.programs.geoImageTransform._program;
212
- var sha = sh.attributes,
213
- shu = sh.uniforms;
214
-
215
- gl.disable(gl.CULL_FACE);
216
-
217
- f.bindOutputTexture(this._materialTexture);
218
- gl.clearColor(0.0, 0.0, 0.0, 0.0);
219
- gl.clear(gl.COLOR_BUFFER_BIT);
220
- gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
221
-
222
- gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
223
-
224
- gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBuffer);
225
- gl.vertexAttribPointer(sha.corners, this._gridBuffer.itemSize, gl.FLOAT, false, 0, 0);
226
- gl.uniform4fv(shu.extentParams, this._extentMercParams);
227
- gl.activeTexture(gl.TEXTURE0);
228
- gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
229
- gl.uniform1i(shu.sourceTexture, 0);
230
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
231
- gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
232
- f.deactivate();
233
-
234
- gl.enable(gl.CULL_FACE);
235
-
236
- this._ready = true;
237
-
238
- this._creationProceeding = false;
239
- }
240
-
241
- _renderingProjType0() {
242
- var p = this._planet,
243
- h = p.renderer.handler,
244
- gl = h.gl,
245
- creator = p._geoImageCreator;
246
-
247
- this._refreshFrame && this._createFrame();
248
- if (!this._sourceCreated) {
249
- this._sourceTexture = this._planet.renderer.handler.createTexture_n_webgl1(this._video);
250
- this._sourceCreated = true;
251
- } else {
252
- gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
253
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._video);
254
- }
255
-
256
- var f = creator._framebuffer;
257
- f.setSize(this._frameWidth, this._frameHeight);
258
- f.activate();
259
-
260
- h.programs.geoImageTransform.activate();
261
- var sh = h.programs.geoImageTransform._program;
262
- var sha = sh.attributes,
263
- shu = sh.uniforms;
264
-
265
- gl.disable(gl.CULL_FACE);
266
-
267
- f.bindOutputTexture(this._materialTexture);
268
- gl.clearColor(0.0, 0.0, 0.0, 0.0);
269
- gl.clear(gl.COLOR_BUFFER_BIT);
270
- gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
271
-
272
- gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
273
-
274
- gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBuffer);
275
- gl.vertexAttribPointer(sha.corners, this._gridBuffer.itemSize, gl.FLOAT, false, 0, 0);
276
- gl.uniform4fv(shu.extentParams, this._extentWgs84Params);
277
- gl.activeTexture(gl.TEXTURE0);
278
- gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
279
- gl.uniform1i(shu.sourceTexture, 0);
280
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
281
- gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
282
- f.deactivate();
283
-
284
- gl.enable(gl.CULL_FACE);
285
-
286
- this._ready = true;
287
-
288
- this._creationProceeding = false;
289
- }
290
189
  }
291
190
 
292
191
  export { GeoVideo };
@@ -49,11 +49,11 @@ class Material {
49
49
  this._updateTexture = null;
50
50
  //this.image = img;
51
51
  this.texture = this._createTexture(img);
52
- this.appliedNodeId = this.segment.node.nodeId;
53
52
  this.isReady = true;
54
53
  this.pickingReady = true;
55
54
  this.textureExists = true;
56
55
  this.isLoading = false;
56
+ this.appliedNodeId = this.segment.node.nodeId;
57
57
  this.texOffset = [0.0, 0.0, 1.0, 1.0];
58
58
  }
59
59
  }
@@ -757,12 +757,13 @@ class Vector extends Layer {
757
757
  if (seg._extent.isInside(ll)) {
758
758
  let cart = p._path3v[c_j][c_j_h];
759
759
  seg.getTerrainPoint(cart, ll, res);
760
- p.setPoint3v(
761
- res.addA(res.normal().scale((rtg && p.altitude) || 0.0)),
762
- c_j_h,
763
- c_j,
764
- true
765
- );
760
+ let alt = (rtg && p.altitude) || 0.0;
761
+ if (alt) {
762
+ let n = this._planet.ellipsoid.getSurfaceNormal3v(res);
763
+ p.setPoint3v(res.addA(n.scale(alt)), c_j_h, c_j, true);
764
+ } else {
765
+ p.setPoint3v(res, c_j_h, c_j, true);
766
+ }
766
767
  break;
767
768
  }
768
769
  }
@@ -990,6 +991,7 @@ class Vector extends Layer {
990
991
  material.texture = segment.planet.transparentTexture;
991
992
  material.pickingMask = segment.planet.transparentTexture;
992
993
  }
994
+ material.pickingReady = true;
993
995
  return [0, 0, 1, 1];
994
996
  }
995
997
  }