@openglobus/og 0.11.7 → 0.11.8
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/css/og.css +3 -2
- package/package.json +1 -1
- package/src/og/control/Lighting.js +52 -73
- package/src/og/control/MouseNavigation.js +21 -18
- package/src/og/control/MouseWheelZoomControl.js +257 -0
- package/src/og/control/index.js +2 -0
- package/src/og/control/visibleExtent/Segment.js +1862 -0
- package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
- package/src/og/control/visibleExtent/drawnode.js +751 -0
- package/src/og/entity/BaseBillboard.js +9 -9
- package/src/og/entity/Label.js +7 -7
- package/src/og/layer/CanvasTiles.js +0 -1
- package/src/og/layer/GeoImage.js +2 -10
- package/src/og/layer/GeoTexture2d.js +2 -10
- package/src/og/layer/GeoVideo.js +2 -10
- package/src/og/layer/Layer.js +0 -22
- package/src/og/layer/WMS.js +0 -2
- package/src/og/layer/XYZ.js +4 -5
- package/src/og/renderer/Renderer.js +69 -94
- package/src/og/renderer/RendererEvents.js +3 -1
- package/src/og/scene/Planet.js +39 -61
- package/src/og/segment/Segment.js +60 -156
- package/src/og/segment/Slice.js +45 -0
- package/src/og/shaders/drawnode.js +197 -287
- package/src/og/utils/GeoImageCreator.js +5 -1
- package/src/og/webgl/Handler.js +1 -1
|
@@ -133,7 +133,7 @@ class BaseBillboard {
|
|
|
133
133
|
this._position.y = y;
|
|
134
134
|
this._position.z = z;
|
|
135
135
|
Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
|
|
136
|
-
if (this._isReady) {
|
|
136
|
+
if (this._isReady && this._handler) {
|
|
137
137
|
this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
|
|
138
138
|
} else if (this._lockId !== LOCK_FREE) {
|
|
139
139
|
this._lockId = LOCK_UPDATE;
|
|
@@ -150,7 +150,7 @@ class BaseBillboard {
|
|
|
150
150
|
this._position.y = position.y;
|
|
151
151
|
this._position.z = position.z;
|
|
152
152
|
Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow);
|
|
153
|
-
if (this._isReady) {
|
|
153
|
+
if (this._isReady && this._handler) {
|
|
154
154
|
this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
|
|
155
155
|
} else if (this._lockId !== LOCK_FREE) {
|
|
156
156
|
this._lockId = LOCK_UPDATE;
|
|
@@ -177,7 +177,7 @@ class BaseBillboard {
|
|
|
177
177
|
this._offset.x = x;
|
|
178
178
|
this._offset.y = y;
|
|
179
179
|
z != undefined && (this._offset.z = z);
|
|
180
|
-
if (this._isReady) {
|
|
180
|
+
if (this._isReady && this._handler) {
|
|
181
181
|
this._handler.setOffsetArr(this._handlerIndex, this._offset);
|
|
182
182
|
} else if (this._lockId !== LOCK_FREE) {
|
|
183
183
|
this._lockId = LOCK_UPDATE;
|
|
@@ -210,7 +210,7 @@ class BaseBillboard {
|
|
|
210
210
|
setRotation(rotation) {
|
|
211
211
|
if (rotation !== this._rotation) {
|
|
212
212
|
this._rotation = rotation;
|
|
213
|
-
if (this._isReady) {
|
|
213
|
+
if (this._isReady && this._handler) {
|
|
214
214
|
this._handler.setRotationArr(this._handlerIndex, rotation);
|
|
215
215
|
} else if (this._lockId !== LOCK_FREE) {
|
|
216
216
|
this._lockId = LOCK_UPDATE;
|
|
@@ -235,7 +235,7 @@ class BaseBillboard {
|
|
|
235
235
|
setOpacity(a) {
|
|
236
236
|
if (a !== this._color.w) {
|
|
237
237
|
a != undefined && (this._color.w = a);
|
|
238
|
-
if (this._isReady) {
|
|
238
|
+
if (this._isReady && this._handler) {
|
|
239
239
|
this._handler.setRgbaArr(this._handlerIndex, this._color);
|
|
240
240
|
} else if (this._lockId !== LOCK_FREE) {
|
|
241
241
|
this._lockId = LOCK_UPDATE;
|
|
@@ -257,7 +257,7 @@ class BaseBillboard {
|
|
|
257
257
|
this._color.y = g;
|
|
258
258
|
this._color.z = b;
|
|
259
259
|
a != undefined && (this._color.w = a);
|
|
260
|
-
if (this._isReady) {
|
|
260
|
+
if (this._isReady && this._handler) {
|
|
261
261
|
this._handler.setRgbaArr(this._handlerIndex, this._color);
|
|
262
262
|
} else if (this._lockId !== LOCK_FREE) {
|
|
263
263
|
this._lockId = LOCK_UPDATE;
|
|
@@ -300,7 +300,7 @@ class BaseBillboard {
|
|
|
300
300
|
setVisibility(visibility) {
|
|
301
301
|
if (visibility !== this._visibility) {
|
|
302
302
|
this._visibility = visibility;
|
|
303
|
-
if (this._isReady) {
|
|
303
|
+
if (this._isReady && this._handler) {
|
|
304
304
|
this._handler.setVisibility(this._handlerIndex, visibility);
|
|
305
305
|
} else if (this._lockId !== LOCK_FREE) {
|
|
306
306
|
this._lockId = LOCK_UPDATE;
|
|
@@ -328,7 +328,7 @@ class BaseBillboard {
|
|
|
328
328
|
this._alignedAxis.x = x;
|
|
329
329
|
this._alignedAxis.y = y;
|
|
330
330
|
this._alignedAxis.z = z;
|
|
331
|
-
if (this._isReady) {
|
|
331
|
+
if (this._isReady && this._handler) {
|
|
332
332
|
this._handler.setAlignedAxisArr(this._handlerIndex, this._alignedAxis);
|
|
333
333
|
} else if (this._lockId !== LOCK_FREE) {
|
|
334
334
|
this._lockId = LOCK_UPDATE;
|
|
@@ -368,7 +368,7 @@ class BaseBillboard {
|
|
|
368
368
|
* @param {Vec3} color - Picking color.
|
|
369
369
|
*/
|
|
370
370
|
setPickingColor3v(color) {
|
|
371
|
-
if (this._isReady) {
|
|
371
|
+
if (this._isReady && this._handler) {
|
|
372
372
|
this._handler.setPickingColorArr(this._handlerIndex, color);
|
|
373
373
|
} else if (this._lockId !== LOCK_FREE) {
|
|
374
374
|
this._lockId = LOCK_UPDATE;
|
package/src/og/entity/Label.js
CHANGED
|
@@ -122,7 +122,7 @@ class Label extends BaseBillboard {
|
|
|
122
122
|
*/
|
|
123
123
|
setText(text) {
|
|
124
124
|
this._text = text.toString();
|
|
125
|
-
if (this._isReady) {
|
|
125
|
+
if (this._isReady && this._handler) {
|
|
126
126
|
this._handler.setText(this._handlerIndex, text, this._fontIndex, this._align);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -143,7 +143,7 @@ class Label extends BaseBillboard {
|
|
|
143
143
|
*/
|
|
144
144
|
setAlign(align) {
|
|
145
145
|
this._align = STR2ALIGN[align.trim().toLowerCase()];
|
|
146
|
-
if (this._isReady) {
|
|
146
|
+
if (this._isReady && this._handler) {
|
|
147
147
|
this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
|
|
148
148
|
} else if (this._lockId !== LOCK_FREE) {
|
|
149
149
|
this._lockId = LOCK_UPDATE;
|
|
@@ -186,7 +186,7 @@ class Label extends BaseBillboard {
|
|
|
186
186
|
setSize(size) {
|
|
187
187
|
if (size !== this._size) {
|
|
188
188
|
this._size = size;
|
|
189
|
-
if (this._isReady) {
|
|
189
|
+
if (this._isReady && this._handler) {
|
|
190
190
|
this._handler.setSizeArr(this._handlerIndex, size);
|
|
191
191
|
} else if (this._lockId !== LOCK_FREE) {
|
|
192
192
|
this._lockId = LOCK_UPDATE;
|
|
@@ -210,7 +210,7 @@ class Label extends BaseBillboard {
|
|
|
210
210
|
*/
|
|
211
211
|
setOutline(outline) {
|
|
212
212
|
this._outline = outline;
|
|
213
|
-
if (this._isReady) {
|
|
213
|
+
if (this._isReady && this._handler) {
|
|
214
214
|
this._handler.setOutlineArr(this._handlerIndex, outline);
|
|
215
215
|
} else if (this._lockId !== LOCK_FREE) {
|
|
216
216
|
this._lockId = LOCK_UPDATE;
|
|
@@ -250,7 +250,7 @@ class Label extends BaseBillboard {
|
|
|
250
250
|
this._outlineColor.y = g;
|
|
251
251
|
this._outlineColor.z = b;
|
|
252
252
|
this._outlineColor.w = a;
|
|
253
|
-
if (this._isReady) {
|
|
253
|
+
if (this._isReady && this._handler) {
|
|
254
254
|
this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
|
|
255
255
|
} else if (this._lockId !== LOCK_FREE) {
|
|
256
256
|
this._lockId = LOCK_UPDATE;
|
|
@@ -293,7 +293,7 @@ class Label extends BaseBillboard {
|
|
|
293
293
|
setOutlineOpacity(opacity) {
|
|
294
294
|
if (opacity !== this._outlineColor.w) {
|
|
295
295
|
this._outlineColor.w = opacity;
|
|
296
|
-
if (this._isReady) {
|
|
296
|
+
if (this._isReady && this._handler) {
|
|
297
297
|
this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
|
|
298
298
|
} else if (this._lockId !== LOCK_FREE) {
|
|
299
299
|
this._lockId = LOCK_UPDATE;
|
|
@@ -323,7 +323,7 @@ class Label extends BaseBillboard {
|
|
|
323
323
|
|
|
324
324
|
_applyFontIndex(fontIndex) {
|
|
325
325
|
this._fontIndex = fontIndex;
|
|
326
|
-
if (this._isReady) {
|
|
326
|
+
if (this._isReady && this._handler) {
|
|
327
327
|
this._handler.setFontIndexArr(this._handlerIndex, this._fontIndex);
|
|
328
328
|
this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
|
|
329
329
|
} else if (this._lockId !== LOCK_FREE) {
|
|
@@ -35,7 +35,6 @@ const EVENT_NAMES = [
|
|
|
35
35
|
* @param {String} [name="noname"] - Layer name.
|
|
36
36
|
* @param {Object} options:
|
|
37
37
|
* @param {number} [options.opacity=1.0] - Layer opacity.
|
|
38
|
-
* @param {Array.<number>} [options.transparentColor=[-1,-1,-1]] - RGB color that defines transparent color. (exactly 3 entries)
|
|
39
38
|
* @param {number} [options.minZoom=0] - Minimal visibility zoom level.
|
|
40
39
|
* @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
|
|
41
40
|
* @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
|
package/src/og/layer/GeoImage.js
CHANGED
|
@@ -141,14 +141,10 @@ class GeoImage extends BaseGeoImage {
|
|
|
141
141
|
var sha = sh.attributes,
|
|
142
142
|
shu = sh.uniforms;
|
|
143
143
|
|
|
144
|
-
var tr = this.transparentColor[0],
|
|
145
|
-
tg = this.transparentColor[1],
|
|
146
|
-
tb = this.transparentColor[2];
|
|
147
|
-
|
|
148
144
|
gl.disable(gl.CULL_FACE);
|
|
149
145
|
|
|
150
146
|
f.bindOutputTexture(this._materialTexture);
|
|
151
|
-
gl.clearColor(
|
|
147
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
152
148
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
153
149
|
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
154
150
|
|
|
@@ -189,14 +185,10 @@ class GeoImage extends BaseGeoImage {
|
|
|
189
185
|
var sha = sh.attributes,
|
|
190
186
|
shu = sh.uniforms;
|
|
191
187
|
|
|
192
|
-
var tr = this.transparentColor[0],
|
|
193
|
-
tg = this.transparentColor[1],
|
|
194
|
-
tb = this.transparentColor[2];
|
|
195
|
-
|
|
196
188
|
gl.disable(gl.CULL_FACE);
|
|
197
189
|
|
|
198
190
|
f.bindOutputTexture(this._materialTexture);
|
|
199
|
-
gl.clearColor(
|
|
191
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
200
192
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
201
193
|
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
202
194
|
|
|
@@ -67,14 +67,10 @@ class GeoTexture2d extends BaseGeoImage {
|
|
|
67
67
|
var sha = sh.attributes,
|
|
68
68
|
shu = sh.uniforms;
|
|
69
69
|
|
|
70
|
-
var tr = this.transparentColor[0],
|
|
71
|
-
tg = this.transparentColor[1],
|
|
72
|
-
tb = this.transparentColor[2];
|
|
73
|
-
|
|
74
70
|
gl.disable(gl.CULL_FACE);
|
|
75
71
|
|
|
76
72
|
f.bindOutputTexture(this._materialTexture);
|
|
77
|
-
gl.clearColor(
|
|
73
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
78
74
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
79
75
|
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
80
76
|
|
|
@@ -117,14 +113,10 @@ class GeoTexture2d extends BaseGeoImage {
|
|
|
117
113
|
var sha = sh.attributes,
|
|
118
114
|
shu = sh.uniforms;
|
|
119
115
|
|
|
120
|
-
var tr = this.transparentColor[0],
|
|
121
|
-
tg = this.transparentColor[1],
|
|
122
|
-
tb = this.transparentColor[2];
|
|
123
|
-
|
|
124
116
|
gl.disable(gl.CULL_FACE);
|
|
125
117
|
|
|
126
118
|
f.bindOutputTexture(this._materialTexture);
|
|
127
|
-
gl.clearColor(
|
|
119
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
128
120
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
129
121
|
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
130
122
|
|
package/src/og/layer/GeoVideo.js
CHANGED
|
@@ -211,14 +211,10 @@ class GeoVideo extends BaseGeoImage {
|
|
|
211
211
|
var sha = sh.attributes,
|
|
212
212
|
shu = sh.uniforms;
|
|
213
213
|
|
|
214
|
-
var tr = this.transparentColor[0],
|
|
215
|
-
tg = this.transparentColor[1],
|
|
216
|
-
tb = this.transparentColor[2];
|
|
217
|
-
|
|
218
214
|
gl.disable(gl.CULL_FACE);
|
|
219
215
|
|
|
220
216
|
f.bindOutputTexture(this._materialTexture);
|
|
221
|
-
gl.clearColor(
|
|
217
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
222
218
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
223
219
|
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
224
220
|
|
|
@@ -265,14 +261,10 @@ class GeoVideo extends BaseGeoImage {
|
|
|
265
261
|
var sha = sh.attributes,
|
|
266
262
|
shu = sh.uniforms;
|
|
267
263
|
|
|
268
|
-
var tr = this.transparentColor[0],
|
|
269
|
-
tg = this.transparentColor[1],
|
|
270
|
-
tb = this.transparentColor[2];
|
|
271
|
-
|
|
272
264
|
gl.disable(gl.CULL_FACE);
|
|
273
265
|
|
|
274
266
|
f.bindOutputTexture(this._materialTexture);
|
|
275
|
-
gl.clearColor(
|
|
267
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
276
268
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
277
269
|
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
278
270
|
|
package/src/og/layer/Layer.js
CHANGED
|
@@ -22,7 +22,6 @@ export const FADING_FACTOR = 0.29;
|
|
|
22
22
|
* @param {String} [name="noname"] - Layer name.
|
|
23
23
|
* @param {Object} [options] - Layer options:
|
|
24
24
|
* @param {number} [options.opacity=1.0] - Layer opacity.
|
|
25
|
-
* @param {Array.<number>} [options.transparentColor=[-1,-1,-1]] - RGB color that defines transparent color. (exactly 3 entries)
|
|
26
25
|
* @param {number} [options.minZoom=0] - Minimal visibility zoom level.
|
|
27
26
|
* @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
|
|
28
27
|
* @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
|
|
@@ -30,11 +29,7 @@ export const FADING_FACTOR = 0.29;
|
|
|
30
29
|
* @param {boolean} [options.visibility=true] - Layer visibility.
|
|
31
30
|
* @param {boolean} [options.isSRGB=false] - Layer image webgl nternal format.
|
|
32
31
|
* @param {Extent} [options.extent=[[-180.0, -90.0], [180.0, 90.0]]] - Visible extent.
|
|
33
|
-
* @param {Vec3} [options.ambient=[0.1, 0.1, 0.1]] - Ambient RGB color.
|
|
34
|
-
* @param {Vec3} [options.diffuse=[0.9, 0.9, 0.9]] - Diffuse RGB color.
|
|
35
|
-
* @param {Vec3} [options.specular=[0.00025, 0.00015, 0.0001]] - Specular RGB color.
|
|
36
32
|
* @param {string} [options.textureFilter="anisotropic"] - Image texture filter. Available values: "nearest", "linear", "mipmap" and "anisotropic".
|
|
37
|
-
* @param {Number} [options.shininess=100] - Shininess.
|
|
38
33
|
*
|
|
39
34
|
* @fires og.Layer#visibilitychange
|
|
40
35
|
* @fires og.Layer#add
|
|
@@ -86,13 +81,6 @@ class Layer {
|
|
|
86
81
|
*/
|
|
87
82
|
this._opacity = options.opacity || 1.0;
|
|
88
83
|
|
|
89
|
-
/**
|
|
90
|
-
* Transparent RGB color mask.
|
|
91
|
-
* @public
|
|
92
|
-
* @type {Array.<number>} - (exactly 3 entries)
|
|
93
|
-
*/
|
|
94
|
-
this.transparentColor = options.transparentColor || [-1, -1, -1];
|
|
95
|
-
|
|
96
84
|
/**
|
|
97
85
|
* Minimal zoom level when layer is visibile.
|
|
98
86
|
* @public
|
|
@@ -107,16 +95,6 @@ class Layer {
|
|
|
107
95
|
*/
|
|
108
96
|
this.maxZoom = options.maxZoom || 50;
|
|
109
97
|
|
|
110
|
-
/**
|
|
111
|
-
* Layer light material parameters.
|
|
112
|
-
* @public
|
|
113
|
-
* @type {Object}
|
|
114
|
-
*/
|
|
115
|
-
this.ambient = utils.createColorRGB(options.ambient, new Vec3(0.2, 0.2, 0.2));
|
|
116
|
-
this.diffuse = utils.createColorRGB(options.diffuse, new Vec3(0.8, 0.8, 0.8));
|
|
117
|
-
this.specular = utils.createColorRGB(options.specular, new Vec3(0.0003, 0.0003, 0.0003));
|
|
118
|
-
this.shininess = options.shininess || 20.0;
|
|
119
|
-
|
|
120
98
|
/**
|
|
121
99
|
* Planet node.
|
|
122
100
|
* @protected
|
package/src/og/layer/WMS.js
CHANGED
|
@@ -17,7 +17,6 @@ import { XYZ } from "./XYZ.js";
|
|
|
17
17
|
* @param {string} name - Layer name.
|
|
18
18
|
* @param {Object} options - Options:
|
|
19
19
|
* @param {number} [options.opacity=1.0] - Layer opacity.
|
|
20
|
-
* @param {Array.<number>} [options.transparentColor=[-1,-1,-1]] - RGB color that defines transparent color.
|
|
21
20
|
* @param {number} [options.minZoom=0] - Minimal visibility zoom level.
|
|
22
21
|
* @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
|
|
23
22
|
* @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
|
|
@@ -36,7 +35,6 @@ import { XYZ } from "./XYZ.js";
|
|
|
36
35
|
* opacity: 0.5,
|
|
37
36
|
* zIndex: 50,
|
|
38
37
|
* attribution: 'USA states - geoserver WMS example',
|
|
39
|
-
* transparentColor: [1.0, 1.0, 1.0],
|
|
40
38
|
* version: "1.1.1",
|
|
41
39
|
* visibility: false }
|
|
42
40
|
* );
|
package/src/og/layer/XYZ.js
CHANGED
|
@@ -17,7 +17,6 @@ import { RENDERING } from "../quadTree/quadTree.js";
|
|
|
17
17
|
* @param {string} name - Layer name.
|
|
18
18
|
* @param {Object} options:
|
|
19
19
|
* @param {number} [options.opacity=1.0] - Layer opacity.
|
|
20
|
-
* @param {Array.<number>} [options.transparentColor=[-1,-1,-1]] - RGB color that defines transparent color. (exactly 3 entries)
|
|
21
20
|
* @param {Array.<string>} [options.subdomains=['a','b','c']] - Subdomains of the tile service.
|
|
22
21
|
* @param {number} [options.minZoom=0] - Minimal visibility zoom level.
|
|
23
22
|
* @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
|
|
@@ -51,8 +50,6 @@ class XYZ extends Layer {
|
|
|
51
50
|
|
|
52
51
|
this.events.registerNames(EVENT_NAMES);
|
|
53
52
|
|
|
54
|
-
this.transparentColor = options.transparentColor || [-1, -1, -1];
|
|
55
|
-
|
|
56
53
|
/**
|
|
57
54
|
* Tile url source template.
|
|
58
55
|
* @public
|
|
@@ -103,8 +100,10 @@ class XYZ extends Layer {
|
|
|
103
100
|
* Abort loading tiles.
|
|
104
101
|
* @public
|
|
105
102
|
*/
|
|
106
|
-
abortLoading() {
|
|
107
|
-
this._planet
|
|
103
|
+
abortLoading() {
|
|
104
|
+
if (this._planet) {
|
|
105
|
+
this._planet._tileLoader.abort();
|
|
106
|
+
}
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
/**
|
|
@@ -182,8 +182,7 @@ class Renderer {
|
|
|
182
182
|
* @private
|
|
183
183
|
* @type {Array.<number>} - (exactly 3 entries)
|
|
184
184
|
*/
|
|
185
|
-
this._prevPickingColor =
|
|
186
|
-
|
|
185
|
+
this._prevPickingColor = new Uint8Array(4);
|
|
187
186
|
this._tempPickingColor_ = new Uint8Array(4);
|
|
188
187
|
|
|
189
188
|
this._initialized = false;
|
|
@@ -211,6 +210,8 @@ class Renderer {
|
|
|
211
210
|
|
|
212
211
|
this._currentOutput = "screen";
|
|
213
212
|
|
|
213
|
+
this.isActiveBackbuffers = true;
|
|
214
|
+
|
|
214
215
|
this.labelWorker = new LabelWorker();
|
|
215
216
|
}
|
|
216
217
|
|
|
@@ -424,20 +425,10 @@ class Renderer {
|
|
|
424
425
|
useDepth: false
|
|
425
426
|
}).init();
|
|
426
427
|
|
|
427
|
-
//this.depthFramebuffer = new Framebuffer(this.handler, {
|
|
428
|
-
// size: 2,
|
|
429
|
-
// internalFormat: ["RGBA", "RGBA"],
|
|
430
|
-
// format: ["RGBA", "RGBA"],
|
|
431
|
-
// type: ["UNSIGNED_BYTE", "UNSIGNED_BYTE"],
|
|
432
|
-
// attachment: ["COLOR_ATTACHMENT", "COLOR_ATTACHMENT"],
|
|
433
|
-
// useDepth: true
|
|
434
|
-
//}).init();
|
|
435
428
|
this.screenDepthFramebuffer = new Framebuffer(this.handler, {
|
|
436
429
|
useDepth: false
|
|
437
430
|
}).init();
|
|
438
431
|
|
|
439
|
-
this.readPixels = () => {};
|
|
440
|
-
|
|
441
432
|
if (this.handler.gl.type === "webgl") {
|
|
442
433
|
this.sceneFramebuffer = new Framebuffer(this.handler);
|
|
443
434
|
this.sceneFramebuffer.init();
|
|
@@ -530,10 +521,10 @@ class Renderer {
|
|
|
530
521
|
this.toneMappingFramebuffer.setSize(c.width, c.height, true);
|
|
531
522
|
|
|
532
523
|
this.depthFramebuffer &&
|
|
533
|
-
this.depthFramebuffer.setSize(c.
|
|
524
|
+
this.depthFramebuffer.setSize(c.clientWidth, c.clientHeight, true);
|
|
534
525
|
|
|
535
526
|
this.screenDepthFramebuffer &&
|
|
536
|
-
this.screenDepthFramebuffer.setSize(c.
|
|
527
|
+
this.screenDepthFramebuffer.setSize(c.clientWidth, c.clientHeight, true);
|
|
537
528
|
|
|
538
529
|
if (this.handler.gl.type === "webgl") {
|
|
539
530
|
this.screenTexture.screen = this.sceneFramebuffer.textures[0];
|
|
@@ -753,6 +744,8 @@ class Renderer {
|
|
|
753
744
|
|
|
754
745
|
let frustums = this.activeCamera.frustums;
|
|
755
746
|
|
|
747
|
+
let anyEvent = this.events.mouseState.anyEvent() && this.isActiveBackbuffers;
|
|
748
|
+
|
|
756
749
|
// Rendering scene nodes and entityCollections
|
|
757
750
|
let rn = this._renderNodesArr;
|
|
758
751
|
let k = frustums.length;
|
|
@@ -765,17 +758,19 @@ class Renderer {
|
|
|
765
758
|
}
|
|
766
759
|
this._drawEntityCollections();
|
|
767
760
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
this._drawPickingBuffer(k);
|
|
761
|
+
if (anyEvent) {
|
|
762
|
+
this._drawPickingBuffer(k);
|
|
763
|
+
}
|
|
772
764
|
}
|
|
773
765
|
|
|
774
766
|
sfb.deactivate();
|
|
775
767
|
|
|
776
768
|
this.blitFramebuffer && sfb.blitTo(this.blitFramebuffer);
|
|
777
769
|
|
|
778
|
-
if (
|
|
770
|
+
if (anyEvent) {
|
|
771
|
+
// It works ONLY for 0 (closest) frustum
|
|
772
|
+
this._drawDepthBuffer();
|
|
773
|
+
|
|
779
774
|
this._readPickingColor();
|
|
780
775
|
}
|
|
781
776
|
|
|
@@ -846,99 +841,81 @@ class Renderer {
|
|
|
846
841
|
gl.enable(gl.DEPTH_TEST);
|
|
847
842
|
}
|
|
848
843
|
|
|
849
|
-
/**
|
|
850
|
-
* Returns picking object by screen coordinates
|
|
851
|
-
* @param {number} x - X position
|
|
852
|
-
* @param {number} y - Y position
|
|
853
|
-
* @return {Object} -
|
|
854
|
-
*/
|
|
855
|
-
getPickingObject(x, y) {
|
|
856
|
-
let cnv = this.renderer.handler.canvas,
|
|
857
|
-
c = new Uint8Array(3);
|
|
858
|
-
this.readPixels(c, x / cnv.clientWidth, (cnv.clientHeight - y) / cnv.clientHeight, 1);
|
|
859
|
-
return this.colorObjects[c[0] + "_" + c[1] + "_" + c[2]];
|
|
860
|
-
}
|
|
861
|
-
|
|
862
844
|
/**
|
|
863
845
|
* Draw picking objects framebuffer.
|
|
864
846
|
* @private
|
|
865
847
|
*/
|
|
866
848
|
_drawPickingBuffer(frustumIndex) {
|
|
867
|
-
|
|
868
|
-
this.pickingFramebuffer.activate();
|
|
869
|
-
|
|
870
|
-
var h = this.handler;
|
|
871
|
-
var gl = h.gl;
|
|
849
|
+
this.pickingFramebuffer.activate();
|
|
872
850
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
876
|
-
} else {
|
|
877
|
-
gl.clear(gl.DEPTH_BUFFER_BIT);
|
|
878
|
-
}
|
|
851
|
+
var h = this.handler;
|
|
852
|
+
var gl = h.gl;
|
|
879
853
|
|
|
880
|
-
|
|
854
|
+
if (frustumIndex === this.activeCamera.FARTHEST_FRUSTUM_INDEX) {
|
|
855
|
+
gl.clearColor(0.0, 0.0, 0.0, 1.0);
|
|
856
|
+
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
857
|
+
} else {
|
|
858
|
+
gl.clear(gl.DEPTH_BUFFER_BIT);
|
|
859
|
+
}
|
|
881
860
|
|
|
882
|
-
|
|
883
|
-
var i = dp.length;
|
|
884
|
-
while (i--) {
|
|
885
|
-
/**
|
|
886
|
-
* This callback renders picking frame.
|
|
887
|
-
* @callback og.Renderer~pickingCallback
|
|
888
|
-
*/
|
|
889
|
-
dp[i].callback.call(dp[i].sender);
|
|
890
|
-
}
|
|
861
|
+
gl.disable(h.gl.BLEND);
|
|
891
862
|
|
|
892
|
-
|
|
863
|
+
var dp = this._pickingCallbacks;
|
|
864
|
+
var i = dp.length;
|
|
865
|
+
while (i--) {
|
|
866
|
+
/**
|
|
867
|
+
* This callback renders picking frame.
|
|
868
|
+
* @callback og.Renderer~pickingCallback
|
|
869
|
+
*/
|
|
870
|
+
dp[i].callback.call(dp[i].sender);
|
|
893
871
|
}
|
|
894
|
-
}
|
|
895
872
|
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
this.depthFramebuffer.activate();
|
|
873
|
+
this.pickingFramebuffer.deactivate();
|
|
874
|
+
}
|
|
899
875
|
|
|
900
|
-
|
|
901
|
-
|
|
876
|
+
_drawDepthBuffer() {
|
|
877
|
+
this.depthFramebuffer.activate();
|
|
902
878
|
|
|
903
|
-
|
|
904
|
-
|
|
879
|
+
var h = this.handler;
|
|
880
|
+
var gl = h.gl;
|
|
905
881
|
|
|
906
|
-
|
|
882
|
+
gl.clearColor(0.0, 0.0, 0.0, 1.0);
|
|
883
|
+
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
907
884
|
|
|
908
|
-
|
|
909
|
-
var i = dp.length;
|
|
910
|
-
while (i--) {
|
|
911
|
-
/**
|
|
912
|
-
* This callback renders depth frame.
|
|
913
|
-
* @callback og.Renderer~depthCallback
|
|
914
|
-
*/
|
|
915
|
-
dp[i].callback.call(dp[i].sender);
|
|
916
|
-
}
|
|
885
|
+
gl.enable(gl.DEPTH_TEST);
|
|
917
886
|
|
|
918
|
-
|
|
887
|
+
var dp = this._depthCallbacks;
|
|
888
|
+
var i = dp.length;
|
|
889
|
+
while (i--) {
|
|
890
|
+
/**
|
|
891
|
+
* This callback renders depth frame.
|
|
892
|
+
* @callback og.Renderer~depthCallback
|
|
893
|
+
*/
|
|
894
|
+
dp[i].callback.call(dp[i].sender);
|
|
895
|
+
}
|
|
919
896
|
|
|
920
|
-
|
|
921
|
-
// PASS to depth visualization
|
|
922
|
-
var sh = h.programs.depth,
|
|
923
|
-
p = sh._program;
|
|
897
|
+
this.depthFramebuffer.deactivate();
|
|
924
898
|
|
|
925
|
-
|
|
899
|
+
//
|
|
900
|
+
// PASS to depth visualization
|
|
901
|
+
this.screenDepthFramebuffer.activate();
|
|
902
|
+
var sh = h.programs.depth,
|
|
903
|
+
p = sh._program;
|
|
926
904
|
|
|
927
|
-
|
|
928
|
-
gl.vertexAttribPointer(p.attributes.corners, 2, gl.FLOAT, false, 0, 0);
|
|
905
|
+
gl = h.gl;
|
|
929
906
|
|
|
930
|
-
|
|
907
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this._screenFrameCornersBuffer);
|
|
908
|
+
gl.vertexAttribPointer(p.attributes.corners, 2, gl.FLOAT, false, 0, 0);
|
|
931
909
|
|
|
932
|
-
|
|
910
|
+
sh.activate();
|
|
933
911
|
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
912
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
913
|
+
gl.bindTexture(gl.TEXTURE_2D, this.depthFramebuffer.textures[1]);
|
|
914
|
+
gl.uniform1i(p.uniforms.depthTexture, 0);
|
|
937
915
|
|
|
938
|
-
|
|
916
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
939
917
|
|
|
940
|
-
|
|
941
|
-
}
|
|
918
|
+
this.screenDepthFramebuffer.deactivate();
|
|
942
919
|
}
|
|
943
920
|
|
|
944
921
|
_readPickingColor() {
|
|
@@ -952,15 +929,13 @@ class Renderer {
|
|
|
952
929
|
|
|
953
930
|
var pc = this._currPickingColor;
|
|
954
931
|
if (ts.x || ts.y) {
|
|
932
|
+
this.pickingFramebuffer.activate();
|
|
955
933
|
this.pickingFramebuffer.readPixels(pc, ts.nx, 1.0 - ts.ny);
|
|
956
|
-
|
|
957
|
-
this.readPixels(pc, ts.nx, 1.0 - ts.ny, 1);
|
|
958
|
-
}
|
|
934
|
+
this.pickingFramebuffer.deactivate();
|
|
959
935
|
} else {
|
|
936
|
+
this.pickingFramebuffer.activate();
|
|
960
937
|
this.pickingFramebuffer.readPixels(pc, ms.nx, 1.0 - ms.ny);
|
|
961
|
-
|
|
962
|
-
this.readPixels(pc, ms.nx, 1.0 - ms.ny, 1);
|
|
963
|
-
}
|
|
938
|
+
this.pickingFramebuffer.deactivate();
|
|
964
939
|
}
|
|
965
940
|
}
|
|
966
941
|
}
|
|
@@ -828,8 +828,10 @@ class RendererEvents extends Events {
|
|
|
828
828
|
|
|
829
829
|
if (ts.touchStart) {
|
|
830
830
|
var r = this.renderer;
|
|
831
|
-
|
|
831
|
+
|
|
832
|
+
r.pickingFramebuffer.activate();
|
|
832
833
|
r.pickingFramebuffer.readPixels(r._currPickingColor, ts.nx, 1.0 - ts.ny, 1);
|
|
834
|
+
r.pickingFramebuffer.deactivate();
|
|
833
835
|
|
|
834
836
|
var o = r.colorObjects;
|
|
835
837
|
var c = r._currPickingColor;
|