@openglobus/og 0.20.3 → 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.
- package/README.md +1 -1
- package/lib/@openglobus/js/entity/EntityCollection.d.ts +4 -0
- package/lib/@openglobus/js/entity/GeoObject.d.ts +7 -3
- package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +5 -8
- package/lib/@openglobus/js/layer/Vector.d.ts +5 -0
- package/lib/@openglobus/js/math/Quat.d.ts +1 -0
- package/lib/@openglobus/js/terrain/GlobusTerrain.d.ts +2 -0
- package/lib/@openglobus/og.esm.js +1 -1
- package/lib/@openglobus/og.esm.js.map +1 -1
- package/lib/@openglobus/og.umd.js +1 -1
- package/lib/@openglobus/og.umd.js.map +1 -1
- package/lib/js/Globe.js +1 -0
- package/lib/js/entity/EntityCollection.d.ts +4 -0
- package/lib/js/entity/EntityCollection.js +7 -0
- package/lib/js/entity/GeoObject.d.ts +7 -3
- package/lib/js/entity/GeoObject.js +31 -16
- package/lib/js/entity/GeoObjectHandler.d.ts +5 -8
- package/lib/js/entity/GeoObjectHandler.js +34 -63
- package/lib/js/layer/Vector.d.ts +5 -0
- package/lib/js/layer/Vector.js +16 -1
- package/lib/js/math/Quat.d.ts +1 -0
- package/lib/js/math/Quat.js +4 -0
- package/lib/js/renderer/RendererEvents.js +1 -3
- package/lib/js/scene/Planet.js +1 -1
- package/lib/js/shaders/geoObject.js +22 -71
- package/lib/js/terrain/GlobusRgbTerrain.js +2 -2
- package/lib/js/terrain/GlobusTerrain.d.ts +2 -0
- package/lib/js/terrain/GlobusTerrain.js +2 -0
- package/package.json +1 -1
package/lib/js/Globe.js
CHANGED
|
@@ -21,6 +21,7 @@ interface IEntityCollectionParams {
|
|
|
21
21
|
scaleByDistance?: NumberArray3;
|
|
22
22
|
pickingScale?: number;
|
|
23
23
|
opacity?: number;
|
|
24
|
+
useLighting?: boolean;
|
|
24
25
|
entities?: Entity[];
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
@@ -184,8 +185,11 @@ declare class EntityCollection {
|
|
|
184
185
|
*/
|
|
185
186
|
_layer?: Vector;
|
|
186
187
|
_quadNode?: EntityCollectionNode;
|
|
188
|
+
_useLighting: number;
|
|
187
189
|
constructor(options?: IEntityCollectionParams);
|
|
188
190
|
get id(): number;
|
|
191
|
+
get useLighting(): boolean;
|
|
192
|
+
set useLighting(f: boolean);
|
|
189
193
|
isEqual(ec: EntityCollection): boolean;
|
|
190
194
|
/**
|
|
191
195
|
* Sets collection visibility.
|
|
@@ -79,6 +79,7 @@ class EntityCollection {
|
|
|
79
79
|
this._opacity = options.opacity == undefined ? 1.0 : options.opacity;
|
|
80
80
|
this._fadingOpacity = this._opacity;
|
|
81
81
|
this.events = this.rendererEvents = createEvents(ENTITYCOLLECTION_EVENTS, this);
|
|
82
|
+
this._useLighting = options.useLighting != undefined ? (options.useLighting ? 1.0 : 0.0) : 1.0;
|
|
82
83
|
// initialize current entities
|
|
83
84
|
if (options.entities) {
|
|
84
85
|
this.addEntities(options.entities);
|
|
@@ -87,6 +88,12 @@ class EntityCollection {
|
|
|
87
88
|
get id() {
|
|
88
89
|
return this.__id;
|
|
89
90
|
}
|
|
91
|
+
get useLighting() {
|
|
92
|
+
return Boolean(this._useLighting);
|
|
93
|
+
}
|
|
94
|
+
set useLighting(f) {
|
|
95
|
+
this._useLighting = Number(f);
|
|
96
|
+
}
|
|
90
97
|
isEqual(ec) {
|
|
91
98
|
return this.__id === ec.__id;
|
|
92
99
|
}
|
|
@@ -45,6 +45,9 @@ declare class GeoObject {
|
|
|
45
45
|
protected _pitch: number;
|
|
46
46
|
protected _yaw: number;
|
|
47
47
|
protected _roll: number;
|
|
48
|
+
protected _pitchRad: number;
|
|
49
|
+
protected _yawRad: number;
|
|
50
|
+
protected _rollRad: number;
|
|
48
51
|
protected _scale: Vec3;
|
|
49
52
|
/**
|
|
50
53
|
* RGBA color.
|
|
@@ -52,7 +55,8 @@ declare class GeoObject {
|
|
|
52
55
|
* @type {Vec4}
|
|
53
56
|
*/
|
|
54
57
|
_color: Vec4;
|
|
55
|
-
|
|
58
|
+
_qRot: Quat;
|
|
59
|
+
protected _direction: Vec3;
|
|
56
60
|
_handler: GeoObjectHandler | null;
|
|
57
61
|
_handlerIndex: number;
|
|
58
62
|
_tagData: InstanceData | null;
|
|
@@ -68,7 +72,6 @@ declare class GeoObject {
|
|
|
68
72
|
getPitch(): number;
|
|
69
73
|
getYaw(): number;
|
|
70
74
|
getRoll(): number;
|
|
71
|
-
getDirection(): Vec3;
|
|
72
75
|
get object3d(): Object3d;
|
|
73
76
|
get vertices(): number[];
|
|
74
77
|
get normals(): number[];
|
|
@@ -147,6 +150,7 @@ declare class GeoObject {
|
|
|
147
150
|
* @param {Vec3} color - Picking color.
|
|
148
151
|
*/
|
|
149
152
|
setPickingColor3v(color: Vec3): void;
|
|
150
|
-
|
|
153
|
+
updateRotation(): void;
|
|
154
|
+
getDirection(): Vec3;
|
|
151
155
|
}
|
|
152
156
|
export { GeoObject };
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
162
|
+
this.updateRotation();
|
|
161
163
|
}
|
|
162
164
|
setYaw(yaw) {
|
|
163
165
|
this._yaw = yaw;
|
|
164
|
-
this.
|
|
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.
|
|
190
|
+
this._pitchRad = pitch * RADIANS;
|
|
191
|
+
this.updateRotation();
|
|
188
192
|
}
|
|
189
193
|
setRoll(roll) {
|
|
190
194
|
this._roll = roll;
|
|
191
|
-
this.
|
|
195
|
+
this._rollRad = roll * RADIANS;
|
|
196
|
+
this.updateRotation();
|
|
192
197
|
}
|
|
193
198
|
setPitchYawRoll(pitch, yaw, roll) {
|
|
194
|
-
this.
|
|
195
|
-
this.
|
|
196
|
-
this.
|
|
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
|
-
|
|
234
|
+
updateRotation() {
|
|
226
235
|
if (this._handler && this._handler._planet) {
|
|
227
236
|
this._qNorthFrame = this._handler._planet.getNorthFrameRotation(this._position);
|
|
228
|
-
let
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
192
|
-
let h = this._geoObjectHandler._planet.renderer.handler, numItems = this.
|
|
193
|
-
if (!this.
|
|
194
|
-
h.gl.deleteBuffer(this.
|
|
195
|
-
this.
|
|
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.
|
|
198
|
-
h.setStreamArrayBuffer(this.
|
|
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].
|
|
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.
|
|
389
|
-
gl.vertexAttribPointer(a.
|
|
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.
|
|
440
|
-
gl.vertexAttribPointer(a.
|
|
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
|
-
|
|
469
|
-
setParametersToArray(tagData.
|
|
470
|
-
tagData._changedBuffers[
|
|
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.
|
|
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.
|
|
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;
|
package/lib/js/layer/Vector.d.ts
CHANGED
|
@@ -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;
|
package/lib/js/layer/Vector.js
CHANGED
|
@@ -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
|
});
|
package/lib/js/math/Quat.d.ts
CHANGED
|
@@ -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
|
package/lib/js/math/Quat.js
CHANGED
|
@@ -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.
|
|
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) {
|
package/lib/js/scene/Planet.js
CHANGED
|
@@ -1075,7 +1075,7 @@ export class Planet extends RenderNode {
|
|
|
1075
1075
|
let transparentSegments = [];
|
|
1076
1076
|
let isEq = this.terrain.equalizeVertices;
|
|
1077
1077
|
let i = renderedNodes.length;
|
|
1078
|
-
if (cam.slope > 0.8 /*|| cam.getAltitude() > 10000*/) {
|
|
1078
|
+
if (cam.slope > 0.8 || !this.terrain || this.terrain.isEmpty /*|| cam.getAltitude() > 10000*/) {
|
|
1079
1079
|
while (i--) {
|
|
1080
1080
|
let ri = renderedNodes[i];
|
|
1081
1081
|
let s = ri.segment;
|