@openglobus/og 0.20.2 → 0.20.4

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 (57) hide show
  1. package/README.md +1 -1
  2. package/css/og.css +55 -23
  3. package/lib/@openglobus/js/Globe.d.ts +3 -0
  4. package/lib/@openglobus/js/control/Atmosphere.d.ts +27 -3
  5. package/lib/@openglobus/js/control/AtmosphereConfig.d.ts +59 -0
  6. package/lib/@openglobus/js/control/index.d.ts +29 -29
  7. package/lib/@openglobus/js/entity/EntityCollection.d.ts +4 -0
  8. package/lib/@openglobus/js/entity/GeoObject.d.ts +7 -3
  9. package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +5 -8
  10. package/lib/@openglobus/js/layer/Vector.d.ts +5 -0
  11. package/lib/@openglobus/js/math/Quat.d.ts +1 -0
  12. package/lib/@openglobus/js/scene/Planet.d.ts +6 -0
  13. package/lib/@openglobus/js/shaders/atmos.d.ts +19 -3
  14. package/lib/@openglobus/js/shaders/drawnode.d.ts +2 -1
  15. package/lib/@openglobus/js/terrain/GlobusTerrain.d.ts +2 -0
  16. package/lib/@openglobus/js/webgl/Handler.d.ts +3 -1
  17. package/lib/@openglobus/og.css +1 -1
  18. package/lib/@openglobus/og.esm.js +1 -1
  19. package/lib/@openglobus/og.esm.js.map +1 -1
  20. package/lib/@openglobus/og.umd.js +1 -1
  21. package/lib/@openglobus/og.umd.js.map +1 -1
  22. package/lib/js/Globe.d.ts +3 -0
  23. package/lib/js/Globe.js +4 -1
  24. package/lib/js/control/Atmosphere.d.ts +27 -3
  25. package/lib/js/control/Atmosphere.js +109 -43
  26. package/lib/js/control/AtmosphereConfig.d.ts +59 -0
  27. package/lib/js/control/AtmosphereConfig.js +348 -0
  28. package/lib/js/control/DebugInfo.js +5 -4
  29. package/lib/js/control/Lighting.js +13 -5
  30. package/lib/js/control/index.d.ts +29 -29
  31. package/lib/js/control/index.js +29 -29
  32. package/lib/js/entity/EntityCollection.d.ts +4 -0
  33. package/lib/js/entity/EntityCollection.js +7 -0
  34. package/lib/js/entity/GeoObject.d.ts +7 -3
  35. package/lib/js/entity/GeoObject.js +31 -16
  36. package/lib/js/entity/GeoObjectHandler.d.ts +5 -8
  37. package/lib/js/entity/GeoObjectHandler.js +34 -63
  38. package/lib/js/layer/Layer.js +2 -2
  39. package/lib/js/layer/Vector.d.ts +5 -0
  40. package/lib/js/layer/Vector.js +16 -1
  41. package/lib/js/math/Quat.d.ts +1 -0
  42. package/lib/js/math/Quat.js +4 -0
  43. package/lib/js/renderer/RendererEvents.js +1 -3
  44. package/lib/js/scene/Planet.d.ts +6 -0
  45. package/lib/js/scene/Planet.js +25 -11
  46. package/lib/js/shaders/atmos.d.ts +19 -3
  47. package/lib/js/shaders/atmos.js +40 -26
  48. package/lib/js/shaders/drawnode.d.ts +2 -1
  49. package/lib/js/shaders/drawnode.js +15 -12
  50. package/lib/js/shaders/geoObject.js +22 -71
  51. package/lib/js/terrain/GlobusRgbTerrain.js +2 -2
  52. package/lib/js/terrain/GlobusTerrain.d.ts +2 -0
  53. package/lib/js/terrain/GlobusTerrain.js +2 -0
  54. package/lib/js/ui/Slider.js +3 -3
  55. package/lib/js/webgl/Handler.d.ts +3 -1
  56. package/lib/js/webgl/Handler.js +38 -28
  57. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import * as utils from "../utils/shared";
2
2
  import { Quat, Vec3 } from "../math/index";
3
3
  import { Object3d } from "../Object3d";
4
+ import { RADIANS } from "../math";
4
5
  /**
5
6
  * @class
6
7
  * @param {Object} options - Geo object parameters:
@@ -22,9 +23,12 @@ class GeoObject {
22
23
  this._pitch = options.pitch || 0.0;
23
24
  this._yaw = options.yaw || 0.0;
24
25
  this._roll = options.roll || 0.0;
26
+ this._pitchRad = this._pitch * RADIANS;
27
+ this._yawRad = this._yaw * RADIANS;
28
+ this._rollRad = this._roll * RADIANS;
25
29
  this._scale = utils.createVector3(options.scale, new Vec3(1, 1, 1));
26
30
  this._color = utils.createColorRGBA(options.color);
27
- this._direction = new Vec3(0, 1, 0);
31
+ this._qRot = Quat.IDENTITY;
28
32
  this._handler = null;
29
33
  this._handlerIndex = -1;
30
34
  this._tagData = null;
@@ -42,6 +46,7 @@ class GeoObject {
42
46
  this.setTextureSrc(options.textureSrc);
43
47
  }
44
48
  this._visibility = (options.visibility != undefined ? options.visibility : true);
49
+ this._direction = new Vec3();
45
50
  this._qNorthFrame = new Quat();
46
51
  }
47
52
  get tag() {
@@ -59,9 +64,6 @@ class GeoObject {
59
64
  getRoll() {
60
65
  return this._roll;
61
66
  }
62
- getDirection() {
63
- return this._direction;
64
- }
65
67
  get object3d() {
66
68
  return this._object3d;
67
69
  }
@@ -144,7 +146,7 @@ class GeoObject {
144
146
  Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
145
147
  this._handler &&
146
148
  this._handler.setPositionArr(this._tagData, this._tagDataIndex, this._positionHigh, this._positionLow);
147
- this.updateDirection();
149
+ this.updateRotation();
148
150
  }
149
151
  /**
150
152
  * Sets geo object position.
@@ -157,11 +159,12 @@ class GeoObject {
157
159
  this._position.z = position.z;
158
160
  Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow);
159
161
  this._handler && this._handler.setPositionArr(this._tagData, this._tagDataIndex, this._positionHigh, this._positionLow);
160
- this.updateDirection();
162
+ this.updateRotation();
161
163
  }
162
164
  setYaw(yaw) {
163
165
  this._yaw = yaw;
164
- this.updateDirection();
166
+ this._yawRad = yaw * RADIANS;
167
+ this.updateRotation();
165
168
  }
166
169
  setObject(object) {
167
170
  this._object3d = object;
@@ -184,16 +187,22 @@ class GeoObject {
184
187
  */
185
188
  setPitch(pitch) {
186
189
  this._pitch = pitch;
187
- this._handler && this._handler.setPitchRollArr(this._tagData, this._tagDataIndex, pitch, this._roll);
190
+ this._pitchRad = pitch * RADIANS;
191
+ this.updateRotation();
188
192
  }
189
193
  setRoll(roll) {
190
194
  this._roll = roll;
191
- this._handler && this._handler.setPitchRollArr(this._tagData, this._tagDataIndex, this._pitch, roll);
195
+ this._rollRad = roll * RADIANS;
196
+ this.updateRotation();
192
197
  }
193
198
  setPitchYawRoll(pitch, yaw, roll) {
194
- this.setPitch(pitch);
195
- this.setYaw(yaw);
196
- this.setRoll(roll);
199
+ this._pitch = pitch;
200
+ this._yaw = yaw;
201
+ this._roll = roll;
202
+ this._pitchRad = pitch * RADIANS;
203
+ this._yawRad = yaw * RADIANS;
204
+ this._rollRad = roll * RADIANS;
205
+ this.updateRotation();
197
206
  }
198
207
  setScale(scale) {
199
208
  this._scale.x = this._scale.y = this._scale.z = scale;
@@ -222,13 +231,19 @@ class GeoObject {
222
231
  setPickingColor3v(color) {
223
232
  this._handler && this._handler.setPickingColorArr(this._tagData, this._tagDataIndex, color);
224
233
  }
225
- updateDirection() {
234
+ updateRotation() {
226
235
  if (this._handler && this._handler._planet) {
227
236
  this._qNorthFrame = this._handler._planet.getNorthFrameRotation(this._position);
228
- let qq = Quat.yRotation(this._yaw).mul(this._qNorthFrame).conjugate();
229
- this._direction = qq.mulVec3(new Vec3(0.0, 0.0, -1.0)).normalize();
230
- this._handler.setDirectionArr(this._tagData, this._tagDataIndex, this._direction);
237
+ let qp = Quat.xRotation(-this._pitchRad);
238
+ let qy = Quat.yRotation(this._yawRad);
239
+ let qr = Quat.zRotation(-this._rollRad);
240
+ this._qRot = qr.mul(qp).mul(qy).mul(this._qNorthFrame).conjugate();
241
+ this._direction = this._qRot.mulVec3(new Vec3(0.0, 0.0, -1.0)).normalize();
242
+ this._handler.setQRotArr(this._tagData, this._tagDataIndex, this._qRot);
231
243
  }
232
244
  }
245
+ getDirection() {
246
+ return this._direction.clone();
247
+ }
233
248
  }
234
249
  export { GeoObject };
@@ -4,6 +4,7 @@ import { GeoObject } from "./GeoObject";
4
4
  import { Planet } from "../scene/Planet";
5
5
  import { Vec3 } from "../math/Vec3";
6
6
  import { Vec4 } from "../math/Vec4";
7
+ import { Quat } from "../math/Quat";
7
8
  import { WebGLBufferExt, WebGLTextureExt } from "../webgl/Handler";
8
9
  import { Object3d } from "../Object3d";
9
10
  declare class InstanceData {
@@ -14,24 +15,22 @@ declare class InstanceData {
14
15
  _texture: WebGLTextureExt | null;
15
16
  _textureSrc: string | null;
16
17
  _objectSrc?: string;
17
- _pitchRollArr: number[] | TypedArray;
18
18
  _sizeArr: number[] | TypedArray;
19
19
  _vertexArr: number[] | TypedArray;
20
20
  _positionHighArr: number[] | TypedArray;
21
21
  _positionLowArr: number[] | TypedArray;
22
- _directionArr: number[] | TypedArray;
22
+ _qRotArr: number[] | TypedArray;
23
23
  _rgbaArr: number[] | TypedArray;
24
24
  _normalsArr: number[] | TypedArray;
25
25
  _indicesArr: number[] | TypedArray;
26
26
  _pickingColorArr: number[] | TypedArray;
27
27
  _visibleArr: number[] | TypedArray;
28
28
  _texCoordArr: number[] | TypedArray;
29
- _pitchRollBuffer: WebGLBufferExt | null;
30
29
  _sizeBuffer: WebGLBufferExt | null;
31
30
  _vertexBuffer: WebGLBufferExt | null;
32
31
  _positionHighBuffer: WebGLBufferExt | null;
33
32
  _positionLowBuffer: WebGLBufferExt | null;
34
- _directionBuffer: WebGLBufferExt | null;
33
+ _qRotBuffer: WebGLBufferExt | null;
35
34
  _rgbaBuffer: WebGLBufferExt | null;
36
35
  _normalsBuffer: WebGLBufferExt | null;
37
36
  _indicesBuffer: WebGLBufferExt | null;
@@ -45,13 +44,12 @@ declare class InstanceData {
45
44
  clear(): void;
46
45
  _deleteBuffers(): void;
47
46
  createVertexBuffer(): void;
48
- createPitchRollBuffer(): void;
49
47
  createVisibleBuffer(): void;
50
48
  createSizeBuffer(): void;
51
49
  createTexCoordBuffer(): void;
52
50
  createPositionBuffer(): void;
53
51
  createRgbaBuffer(): void;
54
- createDirectionBuffer(): void;
52
+ createQRotBuffer(): void;
55
53
  createNormalsBuffer(): void;
56
54
  createIndicesBuffer(): void;
57
55
  createPickingColorBuffer(): void;
@@ -84,12 +82,11 @@ declare class GeoObjectHandler {
84
82
  drawPicking(): void;
85
83
  protected _pickingPASS(): void;
86
84
  _loadDataTagTexture(tagData: InstanceData): Promise<void>;
87
- setDirectionArr(tagData: InstanceData, tagDataIndex: number, direction: Vec3): void;
85
+ setQRotArr(tagData: InstanceData, tagDataIndex: number, qRot: Quat): void;
88
86
  setVisibility(tagData: InstanceData, tagDataIndex: number, visibility: boolean): void;
89
87
  setPositionArr(tagData: InstanceData, tagDataIndex: number, positionHigh: Vec3, positionLow: Vec3): void;
90
88
  setRgbaArr(tagData: InstanceData, tagDataIndex: number, rgba: Vec4): void;
91
89
  setPickingColorArr(tagData: InstanceData, tagDataIndex: number, color: Vec3): void;
92
- setPitchRollArr(tagData: InstanceData, tagDataIndex: number, pitch: number, roll: number): void;
93
90
  setScaleArr(tagData: InstanceData, tagDataIndex: number, scale: Vec3): void;
94
91
  protected _updateTag(dataTag: InstanceData): void;
95
92
  update(): void;
@@ -6,12 +6,11 @@ const POSITION_BUFFER = 1;
6
6
  const RGBA_BUFFER = 2;
7
7
  const NORMALS_BUFFER = 3;
8
8
  const INDEX_BUFFER = 4;
9
- const DIRECTION_BUFFER = 5;
10
- const PITCH_ROLL_BUFFER = 6;
11
- const SIZE_BUFFER = 7;
12
- const PICKINGCOLOR_BUFFER = 8;
13
- const VISIBLE_BUFFER = 9;
14
- const TEXCOORD_BUFFER = 10;
9
+ const QROT_BUFFER = 5;
10
+ const SIZE_BUFFER = 6;
11
+ const PICKINGCOLOR_BUFFER = 7;
12
+ const VISIBLE_BUFFER = 8;
13
+ const TEXCOORD_BUFFER = 9;
15
14
  function setParametersToArray(arr, index = 0, length = 0, itemSize = 1, ...params) {
16
15
  const currIndex = index * length;
17
16
  for (let i = currIndex, len = currIndex + length; i < len; i++) {
@@ -34,24 +33,22 @@ class InstanceData {
34
33
  this.numInstances = 0;
35
34
  this._texture = null;
36
35
  this._textureSrc = null;
37
- this._pitchRollArr = [];
38
36
  this._sizeArr = [];
39
37
  this._vertexArr = [];
40
38
  this._positionHighArr = [];
41
39
  this._positionLowArr = [];
42
- this._directionArr = [];
40
+ this._qRotArr = [];
43
41
  this._rgbaArr = [];
44
42
  this._normalsArr = [];
45
43
  this._indicesArr = [];
46
44
  this._pickingColorArr = [];
47
45
  this._visibleArr = [];
48
46
  this._texCoordArr = [];
49
- this._pitchRollBuffer = null;
50
47
  this._sizeBuffer = null;
51
48
  this._vertexBuffer = null;
52
49
  this._positionHighBuffer = null;
53
50
  this._positionLowBuffer = null;
54
- this._directionBuffer = null;
51
+ this._qRotBuffer = null;
55
52
  this._rgbaBuffer = null;
56
53
  this._normalsBuffer = null;
57
54
  this._indicesBuffer = null;
@@ -61,15 +58,14 @@ class InstanceData {
61
58
  this._buffersUpdateCallbacks = [];
62
59
  this._buffersUpdateCallbacks[PICKINGCOLOR_BUFFER] = this.createPickingColorBuffer;
63
60
  this._buffersUpdateCallbacks[POSITION_BUFFER] = this.createPositionBuffer;
64
- this._buffersUpdateCallbacks[DIRECTION_BUFFER] = this.createDirectionBuffer;
65
61
  this._buffersUpdateCallbacks[NORMALS_BUFFER] = this.createNormalsBuffer;
66
62
  this._buffersUpdateCallbacks[RGBA_BUFFER] = this.createRgbaBuffer;
67
63
  this._buffersUpdateCallbacks[INDEX_BUFFER] = this.createIndicesBuffer;
68
64
  this._buffersUpdateCallbacks[VERTEX_BUFFER] = this.createVertexBuffer;
69
65
  this._buffersUpdateCallbacks[SIZE_BUFFER] = this.createSizeBuffer;
70
- this._buffersUpdateCallbacks[PITCH_ROLL_BUFFER] = this.createPitchRollBuffer;
71
66
  this._buffersUpdateCallbacks[VISIBLE_BUFFER] = this.createVisibleBuffer;
72
67
  this._buffersUpdateCallbacks[TEXCOORD_BUFFER] = this.createTexCoordBuffer;
68
+ this._buffersUpdateCallbacks[QROT_BUFFER] = this.createQRotBuffer;
73
69
  this._changedBuffers = new Array(this._buffersUpdateCallbacks.length);
74
70
  }
75
71
  createTexture(image) {
@@ -80,12 +76,11 @@ class InstanceData {
80
76
  clear() {
81
77
  this.numInstances = 0;
82
78
  this.geoObjects = [];
83
- this._pitchRollArr = [];
84
79
  this._sizeArr = [];
85
80
  this._vertexArr = [];
86
81
  this._positionHighArr = [];
87
82
  this._positionLowArr = [];
88
- this._directionArr = [];
83
+ this._qRotArr = [];
89
84
  this._rgbaArr = [];
90
85
  this._normalsArr = [];
91
86
  this._indicesArr = [];
@@ -101,12 +96,11 @@ class InstanceData {
101
96
  let h = this._geoObjectHandler._planet.renderer.handler, gl = h.gl;
102
97
  h.deleteTexture(this._texture);
103
98
  this._texture = null;
104
- gl.deleteBuffer(this._pitchRollBuffer);
105
99
  gl.deleteBuffer(this._sizeBuffer);
106
100
  gl.deleteBuffer(this._vertexBuffer);
107
101
  gl.deleteBuffer(this._positionHighBuffer);
108
102
  gl.deleteBuffer(this._positionLowBuffer);
109
- gl.deleteBuffer(this._directionBuffer);
103
+ gl.deleteBuffer(this._qRotBuffer);
110
104
  gl.deleteBuffer(this._rgbaBuffer);
111
105
  gl.deleteBuffer(this._normalsBuffer);
112
106
  gl.deleteBuffer(this._indicesBuffer);
@@ -114,12 +108,11 @@ class InstanceData {
114
108
  gl.deleteBuffer(this._visibleBuffer);
115
109
  gl.deleteBuffer(this._texCoordBuffer);
116
110
  }
117
- this._pitchRollBuffer = null;
118
111
  this._sizeBuffer = null;
119
112
  this._vertexBuffer = null;
120
113
  this._positionHighBuffer = null;
121
114
  this._positionLowBuffer = null;
122
- this._directionBuffer = null;
115
+ this._qRotBuffer = null;
123
116
  this._rgbaBuffer = null;
124
117
  this._normalsBuffer = null;
125
118
  this._indicesBuffer = null;
@@ -133,15 +126,6 @@ class InstanceData {
133
126
  this._vertexArr = makeArrayTyped(this._vertexArr);
134
127
  this._vertexBuffer = h.createArrayBuffer(this._vertexArr, 3, this._vertexArr.length / 3);
135
128
  }
136
- createPitchRollBuffer() {
137
- let h = this._geoObjectHandler._planet.renderer.handler, numItems = this._pitchRollArr.length / 2;
138
- if (!this._pitchRollBuffer || this._pitchRollBuffer.numItems !== numItems) {
139
- h.gl.deleteBuffer(this._pitchRollBuffer);
140
- this._pitchRollBuffer = h.createStreamArrayBuffer(2, numItems);
141
- }
142
- this._pitchRollArr = makeArrayTyped(this._pitchRollArr);
143
- h.setStreamArrayBuffer(this._pitchRollBuffer, this._pitchRollArr);
144
- }
145
129
  createVisibleBuffer() {
146
130
  const h = this._geoObjectHandler._planet.renderer.handler, numItems = this._visibleArr.length;
147
131
  if (!this._visibleBuffer || this._visibleBuffer.numItems !== numItems) {
@@ -188,14 +172,14 @@ class InstanceData {
188
172
  this._rgbaArr = makeArrayTyped(this._rgbaArr);
189
173
  h.setStreamArrayBuffer(this._rgbaBuffer, this._rgbaArr);
190
174
  }
191
- createDirectionBuffer() {
192
- let h = this._geoObjectHandler._planet.renderer.handler, numItems = this._directionArr.length / 3;
193
- if (!this._directionBuffer || this._directionBuffer.numItems !== numItems) {
194
- h.gl.deleteBuffer(this._directionBuffer);
195
- this._directionBuffer = h.createStreamArrayBuffer(3, numItems);
175
+ createQRotBuffer() {
176
+ let h = this._geoObjectHandler._planet.renderer.handler, numItems = this._qRotArr.length / 4;
177
+ if (!this._qRotBuffer || this._qRotBuffer.numItems !== numItems) {
178
+ h.gl.deleteBuffer(this._qRotBuffer);
179
+ this._qRotBuffer = h.createStreamArrayBuffer(4, numItems);
196
180
  }
197
- this._directionArr = makeArrayTyped(this._directionArr);
198
- h.setStreamArrayBuffer(this._directionBuffer, this._directionArr);
181
+ this._qRotArr = makeArrayTyped(this._qRotArr);
182
+ h.setStreamArrayBuffer(this._qRotBuffer, this._qRotArr);
199
183
  }
200
184
  createNormalsBuffer() {
201
185
  const h = this._geoObjectHandler._planet.renderer.handler;
@@ -264,7 +248,7 @@ class GeoObjectHandler {
264
248
  this._loadDataTagTexture(this._instanceDataMapValues[i]);
265
249
  }
266
250
  for (let i = 0; i < this._geoObjects.length; i++) {
267
- this._geoObjects[i].updateDirection();
251
+ this._geoObjects[i].updateRotation();
268
252
  }
269
253
  this.update();
270
254
  }
@@ -293,7 +277,6 @@ class GeoObjectHandler {
293
277
  if (object.vertices.length !== tagData._vertexArr.length) {
294
278
  tagData._vertexArr = object.vertices;
295
279
  tagData._changedBuffers[VERTEX_BUFFER] = true;
296
- tagData._changedBuffers[DIRECTION_BUFFER] = true;
297
280
  }
298
281
  if (object.normals.length !== tagData._normalsArr.length) {
299
282
  tagData._normalsArr = object.normals;
@@ -344,20 +327,17 @@ class GeoObjectHandler {
344
327
  y = geoObject._entity._pickingColor.y / 255;
345
328
  z = geoObject._entity._pickingColor.z / 255;
346
329
  tagData._pickingColorArr = concatArrays(tagData._pickingColorArr, setParametersToArray([], 0, itemSize, itemSize, x, y, z));
347
- x = geoObject._direction.x;
348
- y = geoObject._direction.y;
349
- z = geoObject._direction.z;
350
- tagData._directionArr = concatArrays(tagData._directionArr, setParametersToArray([], 0, itemSize, itemSize, x, y, z));
351
330
  itemSize = 4;
331
+ x = geoObject._qRot.x;
332
+ y = geoObject._qRot.y;
333
+ z = geoObject._qRot.z;
334
+ w = geoObject._qRot.w;
335
+ tagData._qRotArr = concatArrays(tagData._qRotArr, setParametersToArray([], 0, itemSize, itemSize, x, y, z, w));
352
336
  x = geoObject._color.x;
353
337
  y = geoObject._color.y;
354
338
  z = geoObject._color.z;
355
339
  w = geoObject._color.w;
356
340
  tagData._rgbaArr = concatArrays(tagData._rgbaArr, setParametersToArray([], 0, itemSize, itemSize, x, y, z, w));
357
- itemSize = 2;
358
- x = geoObject.getPitch();
359
- y = geoObject.getRoll();
360
- tagData._pitchRollArr = concatArrays(tagData._pitchRollArr, setParametersToArray([], 0, itemSize, itemSize, x, y));
361
341
  itemSize = 3;
362
342
  let scale = geoObject.getScale();
363
343
  x = scale.x;
@@ -373,6 +353,7 @@ class GeoObjectHandler {
373
353
  // Could be in VAO
374
354
  //
375
355
  gl.uniform3fv(u.uScaleByDistance, ec.scaleByDistance);
356
+ gl.uniform1f(u.useLighting, ec._useLighting);
376
357
  gl.uniform3fv(u.eyePositionHigh, r.activeCamera.eyeHigh);
377
358
  gl.uniform3fv(u.eyePositionLow, r.activeCamera.eyeLow);
378
359
  gl.uniformMatrix4fv(u.projectionMatrix, false, r.activeCamera.getProjectionMatrix());
@@ -385,12 +366,10 @@ class GeoObjectHandler {
385
366
  //
386
367
  // Instance individual data
387
368
  //
388
- gl.bindBuffer(gl.ARRAY_BUFFER, tagData._directionBuffer);
389
- gl.vertexAttribPointer(a.aDirection, tagData._directionBuffer.itemSize, gl.FLOAT, false, 0, 0);
369
+ gl.bindBuffer(gl.ARRAY_BUFFER, tagData._qRotBuffer);
370
+ gl.vertexAttribPointer(a.qRot, tagData._qRotBuffer.itemSize, gl.FLOAT, false, 0, 0);
390
371
  gl.bindBuffer(gl.ARRAY_BUFFER, tagData._sizeBuffer);
391
372
  gl.vertexAttribPointer(a.aScale, tagData._sizeBuffer.itemSize, gl.FLOAT, false, 0, 0);
392
- gl.bindBuffer(gl.ARRAY_BUFFER, tagData._pitchRollBuffer);
393
- gl.vertexAttribPointer(a.aPitchRoll, tagData._pitchRollBuffer.itemSize, gl.FLOAT, false, 0, 0);
394
373
  gl.bindBuffer(gl.ARRAY_BUFFER, tagData._rgbaBuffer);
395
374
  gl.vertexAttribPointer(a.aColor, tagData._rgbaBuffer.itemSize, gl.FLOAT, false, 0, 0);
396
375
  gl.bindBuffer(gl.ARRAY_BUFFER, tagData._visibleBuffer);
@@ -436,12 +415,10 @@ class GeoObjectHandler {
436
415
  //
437
416
  // Instance individual data
438
417
  //
439
- gl.bindBuffer(gl.ARRAY_BUFFER, tagData._directionBuffer);
440
- gl.vertexAttribPointer(a.aDirection, tagData._directionBuffer.itemSize, gl.FLOAT, false, 0, 0);
418
+ gl.bindBuffer(gl.ARRAY_BUFFER, tagData._qRotBuffer);
419
+ gl.vertexAttribPointer(a.qRot, tagData._qRotBuffer.itemSize, gl.FLOAT, false, 0, 0);
441
420
  gl.bindBuffer(gl.ARRAY_BUFFER, tagData._sizeBuffer);
442
421
  gl.vertexAttribPointer(a.aScale, tagData._sizeBuffer.itemSize, gl.FLOAT, false, 0, 0);
443
- gl.bindBuffer(gl.ARRAY_BUFFER, tagData._pitchRollBuffer);
444
- gl.vertexAttribPointer(a.aPitchRoll, tagData._pitchRollBuffer.itemSize, gl.FLOAT, false, 0, 0);
445
422
  gl.bindBuffer(gl.ARRAY_BUFFER, tagData._pickingColorBuffer);
446
423
  gl.vertexAttribPointer(a.aPickingColor, tagData._pickingColorBuffer.itemSize, gl.FLOAT, false, 0, 0);
447
424
  gl.bindBuffer(gl.ARRAY_BUFFER, tagData._positionHighBuffer);
@@ -465,9 +442,9 @@ class GeoObjectHandler {
465
442
  tagData.createTexture(image);
466
443
  }
467
444
  }
468
- setDirectionArr(tagData, tagDataIndex, direction) {
469
- setParametersToArray(tagData._directionArr, tagDataIndex, 3, 3, direction.x, direction.y, direction.z);
470
- tagData._changedBuffers[DIRECTION_BUFFER] = true;
445
+ setQRotArr(tagData, tagDataIndex, qRot) {
446
+ setParametersToArray(tagData._qRotArr, tagDataIndex, 4, 4, qRot.x, qRot.y, qRot.z, qRot.w);
447
+ tagData._changedBuffers[QROT_BUFFER] = true;
471
448
  this._updateTag(tagData);
472
449
  }
473
450
  setVisibility(tagData, tagDataIndex, visibility) {
@@ -496,11 +473,6 @@ class GeoObjectHandler {
496
473
  // tagData._changedBuffers[TEXCOORD_BUFFER] = true;
497
474
  // this._updateTag(tagData);
498
475
  // }
499
- setPitchRollArr(tagData, tagDataIndex, pitch, roll) {
500
- setParametersToArray(tagData._pitchRollArr, tagDataIndex, 2, 2, pitch, roll);
501
- tagData._changedBuffers[PITCH_ROLL_BUFFER] = true;
502
- this._updateTag(tagData);
503
- }
504
476
  setScaleArr(tagData, tagDataIndex, scale) {
505
477
  setParametersToArray(tagData._sizeArr, tagDataIndex, 3, 3, scale.x, scale.y, scale.z);
506
478
  tagData._changedBuffers[SIZE_BUFFER] = true;
@@ -550,7 +522,7 @@ class GeoObjectHandler {
550
522
  geoObject._handlerIndex = this._geoObjects.length;
551
523
  this._geoObjects.push(geoObject);
552
524
  this._addGeoObjectToArray(geoObject);
553
- geoObject.updateDirection();
525
+ geoObject.updateRotation();
554
526
  geoObject._tagData.refresh();
555
527
  this._updateTag(geoObject._tagData);
556
528
  geoObject.setObjectSrc(geoObject._objectSrc);
@@ -591,10 +563,9 @@ class GeoObjectHandler {
591
563
  tagData._rgbaArr = spliceArray(tagData._rgbaArr, tdi * 4, 4);
592
564
  tagData._positionHighArr = spliceArray(tagData._positionHighArr, tdi * 3, 3);
593
565
  tagData._positionLowArr = spliceArray(tagData._positionLowArr, tdi * 3, 3);
594
- tagData._directionArr = spliceArray(tagData._directionArr, tdi * 3, 3);
566
+ tagData._qRotArr = spliceArray(tagData._qRotArr, tdi * 4, 4);
595
567
  tagData._pickingColorArr = spliceArray(tagData._pickingColorArr, tdi * 3, 3);
596
568
  tagData._sizeArr = spliceArray(tagData._sizeArr, tdi * 3, 3);
597
- tagData._pitchRollArr = spliceArray(tagData._pitchRollArr, tdi * 2, 2);
598
569
  tagData._visibleArr = spliceArray(tagData._visibleArr, tdi, 1);
599
570
  geoObject._handlerIndex = -1;
600
571
  geoObject._handler = null;
@@ -62,9 +62,9 @@ class Layer {
62
62
  this.properties = options.properties || {};
63
63
  this.hideInLayerSwitcher = options.hideInLayerSwitcher || false;
64
64
  this._hasImageryTiles = true;
65
- this._opacity = options.opacity || 1.0;
65
+ this._opacity = options.opacity != undefined ? options.opacity : 1.0;
66
66
  this.minZoom = options.minZoom || 0;
67
- this.maxZoom = options.maxZoom || 50;
67
+ this.maxZoom = options.maxZoom != undefined ? options.maxZoom : 50;
68
68
  this._planet = null;
69
69
  this.isVector = false;
70
70
  this._attribution = options.attribution || "";
@@ -19,6 +19,7 @@ export interface IVectorParams extends ILayerParams {
19
19
  pickingScale?: number;
20
20
  scaleByDistance?: NumberArray3;
21
21
  labelMaxLetters?: number;
22
+ useLighting?: boolean;
22
23
  }
23
24
  type VectorEventsList = [
24
25
  "draw",
@@ -44,6 +45,7 @@ export type VectorEventsType = EventsHandler<VectorEventsList> & EventsHandler<L
44
45
  * First index - near distance to the entity, after entity becomes full scale.
45
46
  * Second index - far distance to the entity, when entity becomes zero scale.
46
47
  * Third index - far distance to the entity, when entity becomes invisible.
48
+ * Use [1.0, 1.0, 1.0] for real sized objects
47
49
  * @param {number} [options.nodeCapacity=30] - Maximum entities quantity in the tree node. Rendering optimization parameter. 30 is default.
48
50
  * @param {boolean} [options.async=true] - Asynchronous vector data handling before rendering. True for optimization huge data.
49
51
  * @param {boolean} [options.clampToGround = false] - Clamp vector data to the ground.
@@ -121,7 +123,10 @@ declare class Vector extends Layer {
121
123
  polygonOffsetUnits: number;
122
124
  _secondPASS: EntityCollectionNode[];
123
125
  protected _labelMaxLetters: number;
126
+ protected _useLighting: boolean;
124
127
  constructor(name?: string | null, options?: IVectorParams);
128
+ get useLighting(): boolean;
129
+ set useLighting(f: boolean);
125
130
  get labelMaxLetters(): number;
126
131
  get instanceName(): string;
127
132
  protected _bindPicking(): void;
@@ -45,6 +45,7 @@ function _entitiesConstructor(entities) {
45
45
  * First index - near distance to the entity, after entity becomes full scale.
46
46
  * Second index - far distance to the entity, when entity becomes zero scale.
47
47
  * Third index - far distance to the entity, when entity becomes invisible.
48
+ * Use [1.0, 1.0, 1.0] for real sized objects
48
49
  * @param {number} [options.nodeCapacity=30] - Maximum entities quantity in the tree node. Rendering optimization parameter. 30 is default.
49
50
  * @param {boolean} [options.async=true] - Asynchronous vector data handling before rendering. True for optimization huge data.
50
51
  * @param {boolean} [options.clampToGround = false] - Clamp vector data to the ground.
@@ -67,6 +68,7 @@ class Vector extends Layer {
67
68
  this.isVector = true;
68
69
  this._hasImageryTiles = false;
69
70
  this.scaleByDistance = options.scaleByDistance || [math.MAX32, math.MAX32, math.MAX32];
71
+ this._useLighting = options.useLighting !== undefined ? options.useLighting : true;
70
72
  this.pickingScale = options.pickingScale || 1;
71
73
  this.async = options.async !== undefined ? options.async : true;
72
74
  this.clampToGround = options.clampToGround || false;
@@ -83,7 +85,8 @@ class Vector extends Layer {
83
85
  });
84
86
  this._bindEventsDefault(this._polylineEntityCollection);
85
87
  this._geoObjectEntityCollection = new EntityCollection({
86
- pickingEnabled: this.pickingEnabled
88
+ pickingEnabled: this.pickingEnabled,
89
+ useLighting: this._useLighting
87
90
  });
88
91
  this._bindEventsDefault(this._geoObjectEntityCollection);
89
92
  this._geometryHandler = new GeometryHandler(this);
@@ -101,6 +104,15 @@ class Vector extends Layer {
101
104
  this.pickingEnabled = this._pickingEnabled;
102
105
  this._secondPASS = [];
103
106
  }
107
+ get useLighting() {
108
+ return this._useLighting;
109
+ }
110
+ set useLighting(f) {
111
+ if (f !== this._useLighting) {
112
+ this._geoObjectEntityCollection.useLighting = f;
113
+ this._useLighting = f;
114
+ }
115
+ }
104
116
  get labelMaxLetters() {
105
117
  return this._labelMaxLetters;
106
118
  }
@@ -329,6 +341,9 @@ class Vector extends Layer {
329
341
  this._stripEntityCollection.setPickingEnabled(picking);
330
342
  this._polylineEntityCollection.setPickingEnabled(picking);
331
343
  this._geoObjectEntityCollection.setPickingEnabled(picking);
344
+ /**
345
+ * todo: it must be in the quadtree strategy
346
+ */
332
347
  this._entityCollectionsTree && this._entityCollectionsTree.traverseTree((node) => {
333
348
  node.entityCollection.setPickingEnabled(picking);
334
349
  });
@@ -118,6 +118,7 @@ export declare class Quat {
118
118
  * @returns {Quat} -
119
119
  */
120
120
  static getRotationBetweenVectorsUp(source: Vec3, dest: Vec3, up: Vec3): Quat;
121
+ static setFromEulerAngles(pitch: number, yaw: number, roll: number): Quat;
121
122
  /**
122
123
  * Returns true if the components are zero.
123
124
  * @public
@@ -166,6 +166,10 @@ export class Quat {
166
166
  let rotAxis = source.cross(dest).normalize();
167
167
  return Quat.axisAngleToQuat(rotAxis, rotAngle);
168
168
  }
169
+ static setFromEulerAngles(pitch, yaw, roll) {
170
+ let res = new Quat();
171
+ return res.setFromEulerAngles(pitch, yaw, roll);
172
+ }
169
173
  /**
170
174
  * Returns true if the components are zero.
171
175
  * @public
@@ -663,9 +663,7 @@ class RendererEvents extends Events {
663
663
  }
664
664
  if (ts.touchStart) {
665
665
  let r = this.renderer;
666
- r.pickingFramebuffer.activate();
667
- r.pickingFramebuffer.readPixels(_currPickingColor, ts.nx, 1.0 - ts.ny, 1);
668
- r.pickingFramebuffer.deactivate();
666
+ r.readPickingColor(ts.nx, 1 - ts.ny, _currPickingColor);
669
667
  let co = r.getPickingObjectArr(_currPickingColor);
670
668
  tpo = ts.pickingObject = co;
671
669
  if (tpo) {
@@ -1,3 +1,4 @@
1
+ import { Atmosphere, IAtmosphereParams } from "../control/Atmosphere";
1
2
  import { Control } from "../control/Control";
2
3
  import { EventsHandler } from "../Events";
3
4
  import { EmptyTerrain } from "../terrain/EmptyTerrain";
@@ -25,6 +26,7 @@ import { VectorTileCreator } from "../utils/VectorTileCreator";
25
26
  import { WebGLBufferExt, WebGLTextureExt, IDefaultTextureParams } from "../webgl/Handler";
26
27
  import { Program } from "../webgl/Program";
27
28
  import { Segment } from "../segment/Segment";
29
+ import { AtmosphereParameters } from "../shaders/atmos";
28
30
  export interface IPlanetParams {
29
31
  name?: string;
30
32
  ellipsoid?: Ellipsoid;
@@ -45,6 +47,7 @@ export interface IPlanetParams {
45
47
  maxLoadingRequests?: number;
46
48
  atmosphereEnabled?: boolean;
47
49
  transitionOpacityEnabled?: boolean;
50
+ atmosphereParameters?: IAtmosphereParams;
48
51
  }
49
52
  export type PlanetEventsList = [
50
53
  "draw",
@@ -324,6 +327,7 @@ export declare class Planet extends RenderNode {
324
327
  _prevNodes: Map<number, Node>;
325
328
  _currNodes: Map<number, Node>;
326
329
  protected _transitionOpacityEnabled: boolean;
330
+ protected _atmosphere: Atmosphere;
327
331
  constructor(options?: IPlanetParams);
328
332
  /**
329
333
  * Returns true if current terrain data set is loaded
@@ -422,6 +426,8 @@ export declare class Planet extends RenderNode {
422
426
  * @param {EmptyTerrain} terrain - Terrain provider.
423
427
  */
424
428
  setTerrain(terrain: EmptyTerrain): void;
429
+ initAtmosphereShader(atmosParams?: AtmosphereParameters): void;
430
+ get atmosphereControl(): Atmosphere;
425
431
  protected _initializeAtmosphere(): void;
426
432
  protected _initializeShaders(): void;
427
433
  protected _onLayerLoadend(layer: Layer): void;