@openglobus/og 0.20.3 → 0.21.0
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/Globe.d.ts +1 -1
- package/lib/@openglobus/js/Object3d.d.ts +1 -0
- 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/entity/GeometryHandler.d.ts +3 -2
- 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/js/terrain/RgbTerrain.d.ts +9 -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.d.ts +1 -1
- package/lib/js/Globe.js +8 -2
- package/lib/js/Object3d.d.ts +1 -0
- package/lib/js/Object3d.js +18 -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/entity/GeometryHandler.d.ts +3 -2
- package/lib/js/entity/GeometryHandler.js +56 -0
- package/lib/js/layer/Bing.js +1 -0
- package/lib/js/layer/Vector.d.ts +5 -0
- package/lib/js/layer/Vector.js +20 -3
- 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/lib/js/terrain/RgbTerrain.d.ts +9 -0
- package/lib/js/terrain/RgbTerrain.js +215 -213
- package/package.json +14 -14
package/lib/js/Globe.d.ts
CHANGED
package/lib/js/Globe.js
CHANGED
|
@@ -239,7 +239,7 @@ class Globe {
|
|
|
239
239
|
fadeOut() {
|
|
240
240
|
this._canvas.style.opacity = "0";
|
|
241
241
|
}
|
|
242
|
-
attachTo(target) {
|
|
242
|
+
attachTo(target, isFirst) {
|
|
243
243
|
this.detach();
|
|
244
244
|
let t;
|
|
245
245
|
if (target instanceof HTMLElement) {
|
|
@@ -250,7 +250,12 @@ class Globe {
|
|
|
250
250
|
}
|
|
251
251
|
if (t) {
|
|
252
252
|
this.$target = t;
|
|
253
|
-
|
|
253
|
+
if (isFirst && this.$target.firstChild) {
|
|
254
|
+
this.$target.insertBefore(this.$inner, this.$target.firstChild);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
t.appendChild(this.$inner);
|
|
258
|
+
}
|
|
254
259
|
}
|
|
255
260
|
}
|
|
256
261
|
detach() {
|
|
@@ -258,6 +263,7 @@ class Globe {
|
|
|
258
263
|
// Remember that when container is zero
|
|
259
264
|
// sized(display none etc.) renderer frame will be stopped
|
|
260
265
|
this.$target.removeChild(this.$inner);
|
|
266
|
+
this.$target = null;
|
|
261
267
|
}
|
|
262
268
|
}
|
|
263
269
|
destroy() {
|
package/lib/js/Object3d.d.ts
CHANGED
|
@@ -60,5 +60,6 @@ declare class Object3d {
|
|
|
60
60
|
static createCube(length?: number, height?: number, depth?: number, xOffset?: number, yOffset?: number, zOffset?: number): Object3d;
|
|
61
61
|
static createArrow(back?: number, height?: number, front?: number): Object3d;
|
|
62
62
|
static loadObj(src: string): Promise<Object3d[]>;
|
|
63
|
+
merge(other: Object3d): Object3d;
|
|
63
64
|
}
|
|
64
65
|
export { Object3d };
|
package/lib/js/Object3d.js
CHANGED
|
@@ -370,5 +370,23 @@ class Object3d {
|
|
|
370
370
|
texCoords: textures
|
|
371
371
|
}));
|
|
372
372
|
}
|
|
373
|
+
merge(other) {
|
|
374
|
+
const mergedVertices = [...this._vertices, ...other.vertices];
|
|
375
|
+
const mergedNormals = [...this._normals, ...other.normals];
|
|
376
|
+
const mergedTexCoords = [...this._texCoords, ...other.texCoords];
|
|
377
|
+
const offset = this._vertices.length / 3;
|
|
378
|
+
const mergedIndices = [
|
|
379
|
+
...this._indices,
|
|
380
|
+
...other.indices.map(index => index + offset)
|
|
381
|
+
];
|
|
382
|
+
return new Object3d({
|
|
383
|
+
name: `${this._name}_${other.name}`,
|
|
384
|
+
vertices: mergedVertices,
|
|
385
|
+
texCoords: mergedTexCoords,
|
|
386
|
+
indices: mergedIndices,
|
|
387
|
+
normals: mergedNormals,
|
|
388
|
+
color: this.color
|
|
389
|
+
});
|
|
390
|
+
}
|
|
373
391
|
}
|
|
374
392
|
export { Object3d };
|
|
@@ -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;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Extent } from "../Extent";
|
|
2
|
-
import { Handler } from "../webgl/Handler";
|
|
2
|
+
import { Handler, WebGLBufferExt } from "../webgl/Handler";
|
|
3
3
|
import { Vector } from "../layer/Vector";
|
|
4
4
|
import { Node } from "../quadTree/Node";
|
|
5
5
|
import { Vec3 } from "../math/Vec3";
|
|
6
6
|
import { Vec4 } from "../math/Vec4";
|
|
7
7
|
import { CoordinatesType, Geometry } from "./Geometry";
|
|
8
|
-
import { WebGLBufferExt } from "../webgl/Handler";
|
|
9
8
|
declare class GeometryHandler {
|
|
10
9
|
static __counter__: number;
|
|
11
10
|
protected __id: number;
|
|
@@ -80,5 +79,7 @@ declare class GeometryHandler {
|
|
|
80
79
|
createLineThicknessBuffer(): void;
|
|
81
80
|
createLineStrokesBuffer(): void;
|
|
82
81
|
createLineStrokeColorsBuffer(): void;
|
|
82
|
+
clear(): void;
|
|
83
|
+
_deleteBuffers(): void;
|
|
83
84
|
}
|
|
84
85
|
export { GeometryHandler };
|