@openglobus/og 0.18.1 → 0.18.2
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/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 -1
- package/lib/js/ellipsoid/Ellipsoid.js +3 -0
- package/lib/js/entity/Entity.js +1 -1
- package/lib/js/entity/EntityCollection.d.ts +1 -2
- package/lib/js/entity/EntityCollection.js +6 -6
- package/lib/js/entity/Label.js +1 -1
- package/lib/js/layer/Vector.d.ts +1 -2
- package/lib/js/layer/Vector.js +34 -34
- package/lib/js/renderer/Renderer.d.ts +12 -3
- package/lib/js/renderer/Renderer.js +104 -19
- package/lib/js/renderer/RendererEvents.d.ts +2 -0
- package/lib/js/renderer/RendererEvents.js +24 -1
- package/lib/js/scene/Planet.js +6 -2
- package/lib/js/terrain/GlobusTerrain.js +3 -3
- package/lib/js/utils/FontAtlas.js +1 -1
- package/lib/js/utils/shared.js +1 -1
- package/package.json +1 -1
package/lib/js/Globe.js
CHANGED
|
@@ -153,6 +153,9 @@ class Ellipsoid {
|
|
|
153
153
|
projToSurface(p) {
|
|
154
154
|
let pX = p.x || 0.0, pY = p.y || 0.0, pZ = p.z || 0.0;
|
|
155
155
|
let length = Math.sqrt(pX * pX + pY * pY + pZ * pZ);
|
|
156
|
+
if (length === 0) {
|
|
157
|
+
return this.lonLatToCartesian(new LonLat());
|
|
158
|
+
}
|
|
156
159
|
let invRadii2X = this._invRadii2.x, invRadii2Y = this._invRadii2.y, invRadii2Z = this._invRadii2.z;
|
|
157
160
|
let x2 = pX * pX * invRadii2X, y2 = pY * pY * invRadii2Y, z2 = pZ * pZ * invRadii2Z;
|
|
158
161
|
let norm = x2 + y2 + z2;
|
package/lib/js/entity/Entity.js
CHANGED
|
@@ -178,7 +178,7 @@ class Entity {
|
|
|
178
178
|
this._lonLatMerc.lon = this._lonLatMerc.lat = this._lonLatMerc.height = 0;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
ec && ec.events.dispatch(ec.events.entitymove, this);
|
|
181
|
+
//ec && ec.events.dispatch(ec.events.entitymove, this);
|
|
182
182
|
}
|
|
183
183
|
/**
|
|
184
184
|
* Sets entity cartesian position without event dispatching.
|
|
@@ -37,7 +37,7 @@ interface IEntityCollectionParams {
|
|
|
37
37
|
* @param {number} [options.opacity] - Entity global opacity.
|
|
38
38
|
* @param {boolean} [options.pickingEnabled=true] - Entity picking enable.
|
|
39
39
|
* @param {Number} [options.polygonOffsetUnits=0.0] - The multiplier by which an implementation-specific value is multiplied with to create a constant depth offset. The default value is 0.
|
|
40
|
-
*
|
|
40
|
+
* //@fires EntityCollection#entitymove
|
|
41
41
|
* @fires EntityCollection#draw
|
|
42
42
|
* @fires EntityCollection#drawend
|
|
43
43
|
* @fires EntityCollection#add
|
|
@@ -327,7 +327,6 @@ declare class EntityCollection {
|
|
|
327
327
|
protected _clearEntity(entity: Entity): void;
|
|
328
328
|
}
|
|
329
329
|
type EntityCollectionEventList = [
|
|
330
|
-
"entitymove",
|
|
331
330
|
"draw",
|
|
332
331
|
"drawend",
|
|
333
332
|
"add",
|
|
@@ -21,7 +21,7 @@ import { StripHandler } from "./StripHandler";
|
|
|
21
21
|
* @param {number} [options.opacity] - Entity global opacity.
|
|
22
22
|
* @param {boolean} [options.pickingEnabled=true] - Entity picking enable.
|
|
23
23
|
* @param {Number} [options.polygonOffsetUnits=0.0] - The multiplier by which an implementation-specific value is multiplied with to create a constant depth offset. The default value is 0.
|
|
24
|
-
*
|
|
24
|
+
* //@fires EntityCollection#entitymove
|
|
25
25
|
* @fires EntityCollection#draw
|
|
26
26
|
* @fires EntityCollection#drawend
|
|
27
27
|
* @fires EntityCollection#add
|
|
@@ -452,11 +452,11 @@ class EntityCollection {
|
|
|
452
452
|
}
|
|
453
453
|
EntityCollection.__counter__ = 0;
|
|
454
454
|
const ENTITYCOLLECTION_EVENTS = [
|
|
455
|
-
/**
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
"entitymove",
|
|
455
|
+
// /**
|
|
456
|
+
// * Triggered when entity has moved.
|
|
457
|
+
// * @event EntityCollection#entitymove
|
|
458
|
+
// */
|
|
459
|
+
// "entitymove",
|
|
460
460
|
/**
|
|
461
461
|
* Triggered when collection entities begin draw.
|
|
462
462
|
* @event EntityCollection#draw
|
package/lib/js/entity/Label.js
CHANGED
package/lib/js/layer/Vector.d.ts
CHANGED
|
@@ -21,7 +21,6 @@ export interface IVectorParams extends ILayerParams {
|
|
|
21
21
|
labelMaxLetters?: number;
|
|
22
22
|
}
|
|
23
23
|
type VectorEventsList = [
|
|
24
|
-
"entitymove",
|
|
25
24
|
"draw",
|
|
26
25
|
"entityadd",
|
|
27
26
|
"entityremove"
|
|
@@ -51,7 +50,7 @@ export type VectorEventsType = EventsHandler<VectorEventsList> & EventsHandler<L
|
|
|
51
50
|
* @param {boolean} [options.relativeToGround = false] - Place vector data relative to the ground relief.
|
|
52
51
|
* @param {Number} [options.polygonOffsetUnits=0.0] - The multiplier by which an implementation-specific value is multiplied with to create a constant depth offset.
|
|
53
52
|
*
|
|
54
|
-
*
|
|
53
|
+
* //@fires EventsHandler<VectorEventsList>#entitymove
|
|
55
54
|
* @fires EventsHandler<VectorEventsList>#draw
|
|
56
55
|
* @fires EventsHandler<VectorEventsList>#add
|
|
57
56
|
* @fires EventsHandler<VectorEventsList>#remove
|
package/lib/js/layer/Vector.js
CHANGED
|
@@ -51,7 +51,7 @@ function _entitiesConstructor(entities) {
|
|
|
51
51
|
* @param {boolean} [options.relativeToGround = false] - Place vector data relative to the ground relief.
|
|
52
52
|
* @param {Number} [options.polygonOffsetUnits=0.0] - The multiplier by which an implementation-specific value is multiplied with to create a constant depth offset.
|
|
53
53
|
*
|
|
54
|
-
*
|
|
54
|
+
* //@fires EventsHandler<VectorEventsList>#entitymove
|
|
55
55
|
* @fires EventsHandler<VectorEventsList>#draw
|
|
56
56
|
* @fires EventsHandler<VectorEventsList>#add
|
|
57
57
|
* @fires EventsHandler<VectorEventsList>#remove
|
|
@@ -480,82 +480,82 @@ class Vector extends Layer {
|
|
|
480
480
|
//
|
|
481
481
|
// @todo: replace with arrow functions and '...e'
|
|
482
482
|
//
|
|
483
|
-
entityCollection.events.on("entitymove",
|
|
484
|
-
|
|
485
|
-
});
|
|
486
|
-
entityCollection.events.on("mousemove",
|
|
483
|
+
// entityCollection.events.on("entitymove", (e: any) => {
|
|
484
|
+
// ve.dispatch(ve.entitymove, e);
|
|
485
|
+
// });
|
|
486
|
+
entityCollection.events.on("mousemove", (e) => {
|
|
487
487
|
ve.dispatch(ve.mousemove, e);
|
|
488
488
|
});
|
|
489
|
-
entityCollection.events.on("mouseenter",
|
|
489
|
+
entityCollection.events.on("mouseenter", (e) => {
|
|
490
490
|
ve.dispatch(ve.mouseenter, e);
|
|
491
491
|
});
|
|
492
|
-
entityCollection.events.on("mouseleave",
|
|
492
|
+
entityCollection.events.on("mouseleave", (e) => {
|
|
493
493
|
ve.dispatch(ve.mouseleave, e);
|
|
494
494
|
});
|
|
495
|
-
entityCollection.events.on("lclick",
|
|
495
|
+
entityCollection.events.on("lclick", (e) => {
|
|
496
496
|
ve.dispatch(ve.lclick, e);
|
|
497
497
|
});
|
|
498
|
-
entityCollection.events.on("rclick",
|
|
498
|
+
entityCollection.events.on("rclick", (e) => {
|
|
499
499
|
ve.dispatch(ve.rclick, e);
|
|
500
500
|
});
|
|
501
|
-
entityCollection.events.on("mclick",
|
|
501
|
+
entityCollection.events.on("mclick", (e) => {
|
|
502
502
|
ve.dispatch(ve.mclick, e);
|
|
503
503
|
});
|
|
504
|
-
entityCollection.events.on("ldblclick",
|
|
504
|
+
entityCollection.events.on("ldblclick", (e) => {
|
|
505
505
|
ve.dispatch(ve.ldblclick, e);
|
|
506
506
|
});
|
|
507
|
-
entityCollection.events.on("rdblclick",
|
|
507
|
+
entityCollection.events.on("rdblclick", (e) => {
|
|
508
508
|
ve.dispatch(ve.rdblclick, e);
|
|
509
509
|
});
|
|
510
|
-
entityCollection.events.on("mdblclick",
|
|
510
|
+
entityCollection.events.on("mdblclick", (e) => {
|
|
511
511
|
ve.dispatch(ve.mdblclick, e);
|
|
512
512
|
});
|
|
513
|
-
entityCollection.events.on("lup",
|
|
513
|
+
entityCollection.events.on("lup", (e) => {
|
|
514
514
|
ve.dispatch(ve.lup, e);
|
|
515
515
|
});
|
|
516
|
-
entityCollection.events.on("rup",
|
|
516
|
+
entityCollection.events.on("rup", (e) => {
|
|
517
517
|
ve.dispatch(ve.rup, e);
|
|
518
518
|
});
|
|
519
|
-
entityCollection.events.on("mup",
|
|
519
|
+
entityCollection.events.on("mup", (e) => {
|
|
520
520
|
ve.dispatch(ve.mup, e);
|
|
521
521
|
});
|
|
522
|
-
entityCollection.events.on("ldown",
|
|
522
|
+
entityCollection.events.on("ldown", (e) => {
|
|
523
523
|
ve.dispatch(ve.ldown, e);
|
|
524
524
|
});
|
|
525
|
-
entityCollection.events.on("rdown",
|
|
525
|
+
entityCollection.events.on("rdown", (e) => {
|
|
526
526
|
ve.dispatch(ve.rdown, e);
|
|
527
527
|
});
|
|
528
|
-
entityCollection.events.on("mdown",
|
|
528
|
+
entityCollection.events.on("mdown", (e) => {
|
|
529
529
|
ve.dispatch(ve.mdown, e);
|
|
530
530
|
});
|
|
531
|
-
entityCollection.events.on("lhold",
|
|
531
|
+
entityCollection.events.on("lhold", (e) => {
|
|
532
532
|
ve.dispatch(ve.lhold, e);
|
|
533
533
|
});
|
|
534
|
-
entityCollection.events.on("rhold",
|
|
534
|
+
entityCollection.events.on("rhold", (e) => {
|
|
535
535
|
ve.dispatch(ve.rhold, e);
|
|
536
536
|
});
|
|
537
|
-
entityCollection.events.on("mhold",
|
|
537
|
+
entityCollection.events.on("mhold", (e) => {
|
|
538
538
|
ve.dispatch(ve.mhold, e);
|
|
539
539
|
});
|
|
540
|
-
entityCollection.events.on("mousewheel",
|
|
540
|
+
entityCollection.events.on("mousewheel", (e) => {
|
|
541
541
|
ve.dispatch(ve.mousewheel, e);
|
|
542
542
|
});
|
|
543
|
-
entityCollection.events.on("touchmove",
|
|
543
|
+
entityCollection.events.on("touchmove", (e) => {
|
|
544
544
|
ve.dispatch(ve.touchmove, e);
|
|
545
545
|
});
|
|
546
|
-
entityCollection.events.on("touchstart",
|
|
546
|
+
entityCollection.events.on("touchstart", (e) => {
|
|
547
547
|
ve.dispatch(ve.touchstart, e);
|
|
548
548
|
});
|
|
549
|
-
entityCollection.events.on("touchend",
|
|
549
|
+
entityCollection.events.on("touchend", (e) => {
|
|
550
550
|
ve.dispatch(ve.touchend, e);
|
|
551
551
|
});
|
|
552
|
-
entityCollection.events.on("doubletouch",
|
|
552
|
+
entityCollection.events.on("doubletouch", (e) => {
|
|
553
553
|
ve.dispatch(ve.doubletouch, e);
|
|
554
554
|
});
|
|
555
|
-
entityCollection.events.on("touchleave",
|
|
555
|
+
entityCollection.events.on("touchleave", (e) => {
|
|
556
556
|
ve.dispatch(ve.touchleave, e);
|
|
557
557
|
});
|
|
558
|
-
entityCollection.events.on("touchenter",
|
|
558
|
+
entityCollection.events.on("touchenter", (e) => {
|
|
559
559
|
ve.dispatch(ve.touchenter, e);
|
|
560
560
|
});
|
|
561
561
|
}
|
|
@@ -825,11 +825,11 @@ class Vector extends Layer {
|
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
827
|
const VECTOR_EVENTS = [
|
|
828
|
-
/**
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
"entitymove",
|
|
828
|
+
// /**
|
|
829
|
+
// * Triggered when entity has moved.
|
|
830
|
+
// * @event EventsHandler<VectorEventsList>#draw
|
|
831
|
+
// */
|
|
832
|
+
// "entitymove",
|
|
833
833
|
/**
|
|
834
834
|
* Triggered when layer begin draw.
|
|
835
835
|
* @event EventsHandler<VectorEventsList>#draw
|
|
@@ -152,6 +152,12 @@ declare class Renderer {
|
|
|
152
152
|
screenTexture: Record<string, WebGLTexture>;
|
|
153
153
|
outputTexture: WebGLTexture | null;
|
|
154
154
|
protected _pickingMaskCoordinatesBuffer: WebGLBufferExt | null;
|
|
155
|
+
protected _skipDistanceFrame: boolean;
|
|
156
|
+
protected _distancePixelBuffer: WebGLBuffer | null;
|
|
157
|
+
protected _skipPickingFrame: boolean;
|
|
158
|
+
protected _pickingPixelBuffer: WebGLBuffer | null;
|
|
159
|
+
protected _readDistanceBuffer: () => void;
|
|
160
|
+
protected _readPickingBuffer: () => void;
|
|
155
161
|
constructor(handler: Handler, params?: IRendererParams);
|
|
156
162
|
enableBlendOneSrcAlpha(): void;
|
|
157
163
|
enableBlendDefault(): void;
|
|
@@ -236,6 +242,7 @@ declare class Renderer {
|
|
|
236
242
|
* @public
|
|
237
243
|
*/
|
|
238
244
|
initialize(): void;
|
|
245
|
+
_initReadPixelsBuffers(): void;
|
|
239
246
|
_initializeControls(): void;
|
|
240
247
|
resize(): void;
|
|
241
248
|
setCurrentScreen(screenName: string): void;
|
|
@@ -293,12 +300,14 @@ declare class Renderer {
|
|
|
293
300
|
protected _drawPickingBuffer(): void;
|
|
294
301
|
/**
|
|
295
302
|
* Draw picking objects framebuffer.
|
|
296
|
-
* @
|
|
303
|
+
* @protected
|
|
297
304
|
*/
|
|
298
305
|
protected _drawDistanceBuffer(): void;
|
|
299
306
|
protected _drawDepthBuffer(): void;
|
|
300
|
-
protected
|
|
301
|
-
protected
|
|
307
|
+
protected _readPickingBuffer_webgl1: () => void;
|
|
308
|
+
protected _readPickingBuffer_webgl2: () => void;
|
|
309
|
+
protected _readDistanceBuffer_webgl1: () => void;
|
|
310
|
+
protected _readDistanceBuffer_webgl2: () => void;
|
|
302
311
|
readPickingColor(x: number, y: number, outColor: NumberArray3 | Uint8Array): void;
|
|
303
312
|
readDistanceColor(x: number, y: number, outColor: NumberArray3 | Uint8Array): void;
|
|
304
313
|
/**
|
|
@@ -18,6 +18,23 @@ const MSAA_DEFAULT = 0;
|
|
|
18
18
|
let __pickingCallbackCounter__ = 0;
|
|
19
19
|
let __depthCallbackCounter__ = 0;
|
|
20
20
|
let __distanceCallbackCounter__ = 0;
|
|
21
|
+
function clientWaitAsync(gl, sync, flags) {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
function check() {
|
|
24
|
+
const res = gl.clientWaitSync(sync, flags, 0);
|
|
25
|
+
if (res == gl.WAIT_FAILED) {
|
|
26
|
+
reject();
|
|
27
|
+
}
|
|
28
|
+
else if (res == gl.TIMEOUT_EXPIRED) {
|
|
29
|
+
requestAnimationFrame(check);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
resolve();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
check();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
21
38
|
/**
|
|
22
39
|
* Represents high level WebGL context interface that starts WebGL handler working in real time.
|
|
23
40
|
* @class
|
|
@@ -54,6 +71,64 @@ let __distanceCallbackCounter__ = 0;
|
|
|
54
71
|
let __resizeTimeout;
|
|
55
72
|
class Renderer {
|
|
56
73
|
constructor(handler, params = {}) {
|
|
74
|
+
this._readPickingBuffer_webgl1 = () => {
|
|
75
|
+
this.pickingFramebuffer.activate();
|
|
76
|
+
this.pickingFramebuffer.readAllPixels(this._tempPickingPix_);
|
|
77
|
+
this.pickingFramebuffer.deactivate();
|
|
78
|
+
};
|
|
79
|
+
this._readPickingBuffer_webgl2 = () => {
|
|
80
|
+
const gl = this.handler.gl;
|
|
81
|
+
const buf = this._pickingPixelBuffer;
|
|
82
|
+
if (!this._skipPickingFrame) {
|
|
83
|
+
this._skipPickingFrame = true;
|
|
84
|
+
let dest = this._tempPickingPix_;
|
|
85
|
+
let w = this.pickingFramebuffer.width, h = this.pickingFramebuffer.height;
|
|
86
|
+
this.pickingFramebuffer.activate();
|
|
87
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, buf);
|
|
88
|
+
gl.bufferData(gl.PIXEL_PACK_BUFFER, dest.byteLength, gl.STREAM_READ);
|
|
89
|
+
gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, 0);
|
|
90
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
91
|
+
this.pickingFramebuffer.deactivate();
|
|
92
|
+
const sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
93
|
+
gl.flush();
|
|
94
|
+
clientWaitAsync(gl, sync, 0).then(() => {
|
|
95
|
+
this._skipPickingFrame = false;
|
|
96
|
+
gl.deleteSync(sync);
|
|
97
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, buf);
|
|
98
|
+
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, dest);
|
|
99
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
this._readDistanceBuffer_webgl1 = () => {
|
|
104
|
+
this.distanceFramebuffer.activate();
|
|
105
|
+
this.distanceFramebuffer.readAllPixels(this._tempDistancePix_);
|
|
106
|
+
this.distanceFramebuffer.deactivate();
|
|
107
|
+
};
|
|
108
|
+
this._readDistanceBuffer_webgl2 = () => {
|
|
109
|
+
const gl = this.handler.gl;
|
|
110
|
+
const buf = this._distancePixelBuffer;
|
|
111
|
+
if (!this._skipDistanceFrame) {
|
|
112
|
+
this._skipDistanceFrame = true;
|
|
113
|
+
let dest = this._tempDistancePix_;
|
|
114
|
+
let w = this.distanceFramebuffer.width, h = this.distanceFramebuffer.height;
|
|
115
|
+
this.distanceFramebuffer.activate();
|
|
116
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, buf);
|
|
117
|
+
gl.bufferData(gl.PIXEL_PACK_BUFFER, dest.byteLength, gl.STREAM_READ);
|
|
118
|
+
gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, 0);
|
|
119
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
120
|
+
this.distanceFramebuffer.deactivate();
|
|
121
|
+
const sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
122
|
+
gl.flush();
|
|
123
|
+
clientWaitAsync(gl, sync, 0).then(() => {
|
|
124
|
+
this._skipDistanceFrame = false;
|
|
125
|
+
gl.deleteSync(sync);
|
|
126
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, buf);
|
|
127
|
+
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, dest);
|
|
128
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
57
132
|
this.div = null;
|
|
58
133
|
this.handler = handler;
|
|
59
134
|
this.exposure = 3.01;
|
|
@@ -123,6 +198,12 @@ class Renderer {
|
|
|
123
198
|
this.screenTexture = {};
|
|
124
199
|
this.outputTexture = null;
|
|
125
200
|
this._pickingMaskCoordinatesBuffer = null;
|
|
201
|
+
this._skipDistanceFrame = false;
|
|
202
|
+
this._distancePixelBuffer = null;
|
|
203
|
+
this._skipPickingFrame = false;
|
|
204
|
+
this._pickingPixelBuffer = null;
|
|
205
|
+
this._readDistanceBuffer = this._readDistanceBuffer_webgl2;
|
|
206
|
+
this._readPickingBuffer = this._readPickingBuffer_webgl2;
|
|
126
207
|
if (params.autoActivate || isEmpty(params.autoActivate)) {
|
|
127
208
|
this.start();
|
|
128
209
|
}
|
|
@@ -346,6 +427,7 @@ class Renderer {
|
|
|
346
427
|
});
|
|
347
428
|
this.distanceFramebuffer.init();
|
|
348
429
|
this._tempDistancePix_ = new Uint8Array(this.distanceFramebuffer.width * this.distanceFramebuffer.height * 4);
|
|
430
|
+
//this._tempDistancePix_ = new Uint8Array(4);
|
|
349
431
|
this.depthFramebuffer = new Framebuffer(this.handler, {
|
|
350
432
|
size: 2,
|
|
351
433
|
internalFormat: ["RGBA", "DEPTH_COMPONENT24"],
|
|
@@ -360,6 +442,8 @@ class Renderer {
|
|
|
360
442
|
});
|
|
361
443
|
this.screenDepthFramebuffer.init();
|
|
362
444
|
if (this.handler.gl.type === "webgl") {
|
|
445
|
+
this._readDistanceBuffer = this._readDistanceBuffer_webgl1;
|
|
446
|
+
this._readPickingBuffer = this._readPickingBuffer_webgl1;
|
|
363
447
|
this.sceneFramebuffer = new Framebuffer(this.handler);
|
|
364
448
|
this.sceneFramebuffer.init();
|
|
365
449
|
this._fnScreenFrame = this._screenFrameNoMSAA;
|
|
@@ -405,16 +489,19 @@ class Renderer {
|
|
|
405
489
|
depth: this.screenDepthFramebuffer.textures[0],
|
|
406
490
|
frustum: this.depthFramebuffer.textures[0]
|
|
407
491
|
};
|
|
492
|
+
this._initReadPixelsBuffers();
|
|
408
493
|
}
|
|
409
494
|
this.handler.addProgram(pickingMask());
|
|
410
495
|
this.handler.ONCANVASRESIZE = () => {
|
|
411
496
|
this._resizeStart();
|
|
412
497
|
this.events.dispatch(this.events.resize, this.handler.canvas);
|
|
413
|
-
|
|
414
|
-
__resizeTimeout
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
498
|
+
this._resizeEnd();
|
|
499
|
+
//clearTimeout(__resizeTimeout);
|
|
500
|
+
// __resizeTimeout = setTimeout(() => {
|
|
501
|
+
// this._resizeEnd();
|
|
502
|
+
// this.events.dispatch(this.events.resizeend, this.handler.canvas);
|
|
503
|
+
// }, 320);
|
|
504
|
+
this.events.dispatch(this.events.resizeend, this.handler.canvas);
|
|
418
505
|
};
|
|
419
506
|
this.screenFramePositionBuffer = this.handler.createArrayBuffer(new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]), 2, 4);
|
|
420
507
|
this.outputTexture = this.screenTexture.screen;
|
|
@@ -422,6 +509,17 @@ class Renderer {
|
|
|
422
509
|
this._initializeRenderNodes();
|
|
423
510
|
this._initializeControls();
|
|
424
511
|
}
|
|
512
|
+
_initReadPixelsBuffers() {
|
|
513
|
+
let gl = this.handler.gl;
|
|
514
|
+
this._distancePixelBuffer = gl.createBuffer();
|
|
515
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, this._distancePixelBuffer);
|
|
516
|
+
gl.bufferData(gl.PIXEL_PACK_BUFFER, this.distanceFramebuffer.width * this.distanceFramebuffer.height * 4, gl.STREAM_READ);
|
|
517
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
518
|
+
this._pickingPixelBuffer = gl.createBuffer();
|
|
519
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, this._pickingPixelBuffer);
|
|
520
|
+
gl.bufferData(gl.PIXEL_PACK_BUFFER, this.pickingFramebuffer.width * this.pickingFramebuffer.height * 4, gl.STREAM_READ);
|
|
521
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
522
|
+
}
|
|
425
523
|
_initializeControls() {
|
|
426
524
|
let temp = this.controls;
|
|
427
525
|
this.controls = {};
|
|
@@ -750,7 +848,6 @@ class Renderer {
|
|
|
750
848
|
for (let i = 0, len = dp.length; i < len; i++) {
|
|
751
849
|
/**
|
|
752
850
|
* This callback renders picking frame.
|
|
753
|
-
* @callback og.Renderer~pickingCallback
|
|
754
851
|
*/
|
|
755
852
|
dp[i].callback.call(dp[i].sender);
|
|
756
853
|
}
|
|
@@ -760,7 +857,7 @@ class Renderer {
|
|
|
760
857
|
}
|
|
761
858
|
/**
|
|
762
859
|
* Draw picking objects framebuffer.
|
|
763
|
-
* @
|
|
860
|
+
* @protected
|
|
764
861
|
*/
|
|
765
862
|
_drawDistanceBuffer() {
|
|
766
863
|
this.distanceFramebuffer.activate();
|
|
@@ -779,7 +876,6 @@ class Renderer {
|
|
|
779
876
|
while (i--) {
|
|
780
877
|
/**
|
|
781
878
|
* This callback renders distance frame.
|
|
782
|
-
* @callback og.Renderer~distanceCallback
|
|
783
879
|
*/
|
|
784
880
|
dp[i].callback.call(dp[i].sender);
|
|
785
881
|
}
|
|
@@ -798,7 +894,6 @@ class Renderer {
|
|
|
798
894
|
while (i--) {
|
|
799
895
|
/**
|
|
800
896
|
* This callback renders depth frame.
|
|
801
|
-
* @callback og.Renderer~depthCallback
|
|
802
897
|
*/
|
|
803
898
|
dp[i].callback.call(dp[i].sender);
|
|
804
899
|
}
|
|
@@ -816,16 +911,6 @@ class Renderer {
|
|
|
816
911
|
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
817
912
|
this.screenDepthFramebuffer.deactivate();
|
|
818
913
|
}
|
|
819
|
-
_readPickingBuffer() {
|
|
820
|
-
this.pickingFramebuffer.activate();
|
|
821
|
-
this.pickingFramebuffer.readAllPixels(this._tempPickingPix_);
|
|
822
|
-
this.pickingFramebuffer.deactivate();
|
|
823
|
-
}
|
|
824
|
-
_readDistanceBuffer() {
|
|
825
|
-
this.distanceFramebuffer.activate();
|
|
826
|
-
this.distanceFramebuffer.readAllPixels(this._tempDistancePix_);
|
|
827
|
-
this.distanceFramebuffer.deactivate();
|
|
828
|
-
}
|
|
829
914
|
readPickingColor(x, y, outColor) {
|
|
830
915
|
let w = this.pickingFramebuffer.width;
|
|
831
916
|
let h = this.pickingFramebuffer.height;
|
|
@@ -186,6 +186,8 @@ declare class RendererEvents extends Events<RendererEventsType> implements Rende
|
|
|
186
186
|
protected _rclickY: number;
|
|
187
187
|
protected _mclickX: number;
|
|
188
188
|
protected _mclickY: number;
|
|
189
|
+
protected _isMouseInside: boolean;
|
|
190
|
+
protected _entityPickingEventsActive: boolean;
|
|
189
191
|
constructor(renderer: Renderer);
|
|
190
192
|
pointerEvent(): boolean;
|
|
191
193
|
get active(): boolean;
|
|
@@ -97,6 +97,8 @@ class RendererEvents extends Events {
|
|
|
97
97
|
pickingObject: null,
|
|
98
98
|
renderer: renderer
|
|
99
99
|
};
|
|
100
|
+
this._isMouseInside = false;
|
|
101
|
+
this._entityPickingEventsActive = true;
|
|
100
102
|
this._dblTchCoords = new Vec2();
|
|
101
103
|
this._oneTouchStart = false;
|
|
102
104
|
this._dblTchBegins = 0;
|
|
@@ -257,10 +259,12 @@ class RendererEvents extends Events {
|
|
|
257
259
|
}, 100);
|
|
258
260
|
}
|
|
259
261
|
onMouseLeave(sys) {
|
|
262
|
+
this._isMouseInside = false;
|
|
260
263
|
this.mouseState.sys = sys;
|
|
261
264
|
this.dispatch(this.mouseleave, this.mouseState);
|
|
262
265
|
}
|
|
263
266
|
onMouseEnter(sys) {
|
|
267
|
+
this._isMouseInside = true;
|
|
264
268
|
this.mouseState.sys = sys;
|
|
265
269
|
this.dispatch(this.mouseenter, this.mouseState);
|
|
266
270
|
}
|
|
@@ -422,7 +426,26 @@ class RendererEvents extends Events {
|
|
|
422
426
|
}
|
|
423
427
|
entityPickingEvents() {
|
|
424
428
|
let ts = this.touchState, ms = this.mouseState;
|
|
425
|
-
|
|
429
|
+
// Triggers mouseleave when mouse goes outside the viewport
|
|
430
|
+
if (this._isMouseInside !== this._entityPickingEventsActive) {
|
|
431
|
+
this._entityPickingEventsActive = this._isMouseInside;
|
|
432
|
+
if (!this._entityPickingEventsActive) {
|
|
433
|
+
let r = this.renderer;
|
|
434
|
+
let c = _currPickingColor;
|
|
435
|
+
let co = r.getPickingObjectArr(c);
|
|
436
|
+
if (co) {
|
|
437
|
+
let pe = co.rendererEvents;
|
|
438
|
+
ms.pickingObject = co;
|
|
439
|
+
pe && pe.dispatch(pe.mouseleave, ms);
|
|
440
|
+
ts.pickingObject = co;
|
|
441
|
+
pe && pe.dispatch(pe.touchleave, ts);
|
|
442
|
+
}
|
|
443
|
+
_currPickingColor[0] = _currPickingColor[1] = _currPickingColor[2] = _currPickingColor[3] =
|
|
444
|
+
_prevPickingColor[0] = _prevPickingColor[1] = _prevPickingColor[2] = _prevPickingColor[3] =
|
|
445
|
+
_tempCurrPickingColor[0] = _tempCurrPickingColor[1] = _tempCurrPickingColor[2] = _tempCurrPickingColor[3] = 0.0;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
if (this._isMouseInside && !(ms.leftButtonHold || ms.rightButtonHold || ms.middleButtonHold)) {
|
|
426
449
|
let r = this.renderer;
|
|
427
450
|
let c = _currPickingColor, p = _prevPickingColor, t = _tempCurrPickingColor;
|
|
428
451
|
if (ts.x || ts.y) {
|
package/lib/js/scene/Planet.js
CHANGED
|
@@ -1368,7 +1368,9 @@ export class Planet extends RenderNode {
|
|
|
1368
1368
|
resolve(alt);
|
|
1369
1369
|
});
|
|
1370
1370
|
}
|
|
1371
|
-
|
|
1371
|
+
else {
|
|
1372
|
+
resolve(0);
|
|
1373
|
+
}
|
|
1372
1374
|
});
|
|
1373
1375
|
}
|
|
1374
1376
|
async getHeightAboveELL(lonLat) {
|
|
@@ -1378,7 +1380,9 @@ export class Planet extends RenderNode {
|
|
|
1378
1380
|
resolve(alt + this.terrain.geoid.getHeightLonLat(lonLat));
|
|
1379
1381
|
});
|
|
1380
1382
|
}
|
|
1381
|
-
|
|
1383
|
+
else {
|
|
1384
|
+
resolve(0);
|
|
1385
|
+
}
|
|
1382
1386
|
});
|
|
1383
1387
|
}
|
|
1384
1388
|
onremove() {
|
|
@@ -92,11 +92,11 @@ class GlobusTerrain extends EmptyTerrain {
|
|
|
92
92
|
let tileIndex = Layer.getTileIndex(x, y, z);
|
|
93
93
|
let cache = this._elevationCache[tileIndex];
|
|
94
94
|
if (cache) {
|
|
95
|
-
if (
|
|
96
|
-
callback(
|
|
95
|
+
if (cache.heights) {
|
|
96
|
+
callback(this._getGroundHeightMerc(merc, cache));
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
|
-
callback(
|
|
99
|
+
callback(0);
|
|
100
100
|
}
|
|
101
101
|
return true;
|
|
102
102
|
}
|
|
@@ -62,7 +62,7 @@ class FontAtlas {
|
|
|
62
62
|
let fullName = this.getFullIndex(face);
|
|
63
63
|
// Try to load font from the directory
|
|
64
64
|
if (!this.atlasIndexes[fullName]) {
|
|
65
|
-
this.loadFont(
|
|
65
|
+
this.loadFont(face, this.catalogSrc, `${face}.json`);
|
|
66
66
|
}
|
|
67
67
|
if (!this.atlasIndexesDeferred[fullName]) {
|
|
68
68
|
this.atlasIndexesDeferred[fullName] = new Deferred();
|
package/lib/js/utils/shared.js
CHANGED
|
@@ -146,7 +146,7 @@ export function print2d(id, text, x, y) {
|
|
|
146
146
|
el.style.top = `${y}px`;
|
|
147
147
|
}
|
|
148
148
|
export function defaultString(str, def = "") {
|
|
149
|
-
return str ? str.trim()
|
|
149
|
+
return str ? str.trim() : def;
|
|
150
150
|
}
|
|
151
151
|
export function createVector3(v, def) {
|
|
152
152
|
if (v) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openglobus/og",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"description": "[openglobus](https://www.openglobus.org/) is a javascript/typescript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers, and 3D objects. It uses the WebGL technology, open source, and completely free.",
|
|
5
5
|
"directories": {
|
|
6
6
|
"example": "./sandbox"
|