@openglobus/og 0.12.3 → 0.13.1
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 +0 -2
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +7 -7
- package/src/og/Extent.js +3 -3
- package/src/og/Globe.js +277 -275
- package/src/og/ImageCanvas.js +3 -3
- package/src/og/LonLat.js +9 -9
- package/src/og/QueueArray.js +2 -2
- package/src/og/Rectangle.js +5 -5
- package/src/og/bv/Box.js +1 -1
- package/src/og/bv/Sphere.js +2 -2
- package/src/og/camera/Camera.js +1 -1
- package/src/og/camera/PlanetCamera.js +649 -646
- package/src/og/control/LayerSwitcher.js +1 -1
- package/src/og/control/MouseNavigation.js +22 -13
- package/src/og/control/MouseWheelZoomControl.js +2 -2
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/TouchNavigation.js +319 -319
- package/src/og/control/ZoomControl.js +132 -132
- package/src/og/control/visibleExtent/Segment.js +12 -12
- package/src/og/ellipsoid/Ellipsoid.js +577 -567
- package/src/og/entity/BillboardHandler.js +878 -1051
- package/src/og/entity/Entity.js +1 -1
- package/src/og/entity/EntityCollection.js +847 -857
- package/src/og/entity/GeoObjectHandler.js +2 -2
- package/src/og/entity/LabelHandler.js +888 -1040
- package/src/og/entity/LabelWorker.js +0 -6
- package/src/og/entity/PointCloud.js +495 -495
- package/src/og/entity/Polyline.js +2218 -2222
- package/src/og/entity/RayHandler.js +1 -1
- package/src/og/layer/CanvasTiles.js +6 -3
- package/src/og/layer/GeoImage.js +1 -1
- package/src/og/layer/KML.js +5 -5
- package/src/og/layer/Layer.js +804 -752
- package/src/og/layer/Vector.js +997 -1010
- package/src/og/layer/XYZ.js +359 -357
- package/src/og/math/Line2.js +4 -4
- package/src/og/math/Quat.js +2 -2
- package/src/og/math/Ray.js +2 -2
- package/src/og/math/Vec2.js +524 -524
- package/src/og/math/Vec3.js +900 -900
- package/src/og/math/Vec4.js +261 -261
- package/src/og/math.js +397 -398
- package/src/og/quadTree/EntityCollectionNode.js +389 -387
- package/src/og/renderer/Renderer.js +14 -20
- package/src/og/renderer/RendererEvents.js +1034 -1045
- package/src/og/scene/Planet.js +12 -9
- package/src/og/scene/RenderNode.js +347 -354
- package/src/og/segment/Segment.js +3 -1
- package/src/og/segment/SegmentLonLat.js +1 -4
- package/src/og/shaders/billboard.js +220 -204
- package/src/og/shaders/drawnode.js +603 -603
- package/src/og/shaders/label.js +595 -456
- package/src/og/shaders/polyline.js +365 -361
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/FontAtlas.js +209 -200
- package/src/og/utils/GeoImageCreator.js +4 -5
- package/src/og/utils/TextureAtlas.js +4 -4
- package/src/og/utils/VectorTileCreator.js +414 -414
- package/src/og/utils/shared.js +1 -1
- package/src/og/webgl/Handler.js +28 -60
- package/src/og/webgl/Multisample.js +260 -260
- package/src/og/webgl/Program.js +411 -396
- package/types/bv/Box.d.ts +1 -1
- package/types/bv/Sphere.d.ts +1 -1
- package/types/camera/PlanetCamera.d.ts +3 -3
- package/types/control/LayerSwitcher.d.ts +1 -1
- package/types/ellipsoid/Ellipsoid.d.ts +9 -2
- package/types/entity/BillboardHandler.d.ts +0 -4
- package/types/entity/EntityCollection.d.ts +0 -8
- package/types/entity/LabelHandler.d.ts +0 -2
- package/types/entity/Polyline.d.ts +1 -1
- package/types/layer/KML.d.ts +11 -11
- package/types/layer/Layer.d.ts +5 -0
- package/types/layer/Vector.d.ts +1 -8
- package/types/math/Line2.d.ts +4 -4
- package/types/math/Ray.d.ts +2 -2
- package/types/math/Vec2.d.ts +1 -1
- package/types/math/Vec3.d.ts +1 -1
- package/types/math/Vec4.d.ts +2 -2
- package/types/math.d.ts +1 -1
- package/types/renderer/Renderer.d.ts +1 -1
- package/types/renderer/RendererEvents.d.ts +1 -1
- package/types/shaders/label.d.ts +1 -1
- package/types/utils/FontAtlas.d.ts +3 -2
- package/types/utils/TextureAtlas.d.ts +3 -3
- package/types/utils/VectorTileCreator.d.ts +4 -4
- package/types/utils/shared.d.ts +1 -1
- package/types/webgl/Handler.d.ts +6 -31
- package/types/webgl/Program.d.ts +2 -0
|
@@ -1,354 +1,347 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { BaseNode } from "./BaseNode.js";
|
|
4
|
-
import { Events } from "../Events.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Render node is a logical part of a render mechanism. Represents scene rendering.
|
|
8
|
-
* Forexample one scene node for rendering the Earth, another one for rendering the Moon, another node for rendering stars etc.
|
|
9
|
-
* Each render node has own model view space defined with matrices(scale, rotation, translation, transformation).
|
|
10
|
-
* There are collections of ligh sources, entities and so on in the node.
|
|
11
|
-
* Access to the node is renderer.renderNodes["Earth"]
|
|
12
|
-
* @class
|
|
13
|
-
* @extends {RenderNode}
|
|
14
|
-
* @param {string} name - Node name.
|
|
15
|
-
*/
|
|
16
|
-
class RenderNode extends BaseNode {
|
|
17
|
-
constructor(name) {
|
|
18
|
-
super(name);
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Renderer that calls frame() callback.
|
|
22
|
-
* @public
|
|
23
|
-
* @type {Renderer}
|
|
24
|
-
*/
|
|
25
|
-
this.renderer = null;
|
|
26
|
-
|
|
27
|
-
this.drawMode = null;
|
|
28
|
-
|
|
29
|
-
/** Show rendering.
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
this.show = true;
|
|
33
|
-
|
|
34
|
-
this._isActive = true;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Lighting calculations.
|
|
38
|
-
* @public
|
|
39
|
-
* @type {boolean}
|
|
40
|
-
*/
|
|
41
|
-
this.lightEnabled = false;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Point light array.
|
|
45
|
-
* @private
|
|
46
|
-
* @type {Array.<LightSource>}
|
|
47
|
-
*/
|
|
48
|
-
this._lights = [];
|
|
49
|
-
this._lightsTransformedPositions = [];
|
|
50
|
-
this._lightsParamsv = [];
|
|
51
|
-
this._lightsParamsf = [];
|
|
52
|
-
this._lightsNames = [];
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Entity collection array.
|
|
56
|
-
* @public
|
|
57
|
-
* @type {Array.<EntityCollection>}
|
|
58
|
-
*/
|
|
59
|
-
this.entityCollections = [];
|
|
60
|
-
|
|
61
|
-
this._pickingId = -1;
|
|
62
|
-
|
|
63
|
-
this.events = new Events(null, this);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Adds node to the current hierarchy.
|
|
68
|
-
* @public
|
|
69
|
-
* @type {RenderNode}
|
|
70
|
-
*/
|
|
71
|
-
addNode(node) {
|
|
72
|
-
super.addNode(node);
|
|
73
|
-
node.assign(this.renderer);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Assign render node with renderer.
|
|
78
|
-
* @public
|
|
79
|
-
* @param {Renderer} renderer - Redner node's renderer.
|
|
80
|
-
*/
|
|
81
|
-
assign(renderer) {
|
|
82
|
-
this.renderer = renderer;
|
|
83
|
-
this._pickingId = renderer.addPickingCallback(this, this._entityCollectionPickingCallback);
|
|
84
|
-
|
|
85
|
-
for (var i = 0; i < this.entityCollections.length; i++) {
|
|
86
|
-
this.entityCollections[i].bindRenderNode(this);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
this.init && this.init();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
onremove() {
|
|
93
|
-
//virtual
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
remove() {
|
|
97
|
-
var r = this.renderer,
|
|
98
|
-
n = this.name;
|
|
99
|
-
|
|
100
|
-
if (r) {
|
|
101
|
-
if (r.renderNodes[n] && r.renderNodes[n].isEqual(this)) {
|
|
102
|
-
r.renderNodes[n] = null;
|
|
103
|
-
delete r.renderNodes[n];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
for (var i = 0; i < r._renderNodesArr.length; i++) {
|
|
107
|
-
if (r._renderNodesArr[i].isEqual(this)) {
|
|
108
|
-
r._renderNodesArr.splice(i, 1);
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
r.removePickingCallback(this._pickingId);
|
|
113
|
-
this._pickingId = -1;
|
|
114
|
-
this.onremove && this.onremove();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Adds entity collection.
|
|
120
|
-
* @public
|
|
121
|
-
* @param {EntityCollection} entityCollection - Entity collection.
|
|
122
|
-
* @param {boolean} [isHidden] - If it's true that this collection has specific rendering.
|
|
123
|
-
* @returns {RenderNode} -
|
|
124
|
-
*/
|
|
125
|
-
addEntityCollection(entityCollection, isHidden) {
|
|
126
|
-
entityCollection.addTo(this, isHidden);
|
|
127
|
-
return this;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Removes entity collection.
|
|
132
|
-
* @public
|
|
133
|
-
* @param {EntityCollection} entityCollection - Entity collection for remove.
|
|
134
|
-
*/
|
|
135
|
-
removeEntityCollection(entityCollection) {
|
|
136
|
-
entityCollection.remove();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Adds point light source.
|
|
141
|
-
* @public
|
|
142
|
-
* @param {LightSource} light - Light source.
|
|
143
|
-
* @returns {RenderNode}
|
|
144
|
-
*/
|
|
145
|
-
addLight(light) {
|
|
146
|
-
light.addTo(this);
|
|
147
|
-
return this;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Gets light object by its name.
|
|
152
|
-
* @public
|
|
153
|
-
* @param {string} name - Point light name.
|
|
154
|
-
* @returns {LightSource}
|
|
155
|
-
*/
|
|
156
|
-
getLightByName(name) {
|
|
157
|
-
var li = this._lightsNames.indexOf(name);
|
|
158
|
-
return this._lights[li];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Removes light source.
|
|
163
|
-
* @public
|
|
164
|
-
* @param {LightSource} light - Light source object.
|
|
165
|
-
*/
|
|
166
|
-
removeLight(light) {
|
|
167
|
-
light.remove();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Calls render frame node's callback. Used in renderer.
|
|
172
|
-
* @public
|
|
173
|
-
*/
|
|
174
|
-
drawNode(frustum, frustumIndex) {
|
|
175
|
-
this._isActive && this._drawNodes(frustum, frustumIndex);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Gets render node activity.
|
|
180
|
-
* @public
|
|
181
|
-
* @returns {Boolean} -
|
|
182
|
-
*/
|
|
183
|
-
isActive() {
|
|
184
|
-
return this._isActive;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Rendering activation.
|
|
189
|
-
* @public
|
|
190
|
-
* @param {boolean} isActive - Activation flag.
|
|
191
|
-
*/
|
|
192
|
-
setActive(isActive) {
|
|
193
|
-
this._isActive = isActive;
|
|
194
|
-
|
|
195
|
-
if (this.renderer) {
|
|
196
|
-
if (this._isActive && this._pickingId === -1) {
|
|
197
|
-
this._pickingId = this.renderer.addPickingCallback(
|
|
198
|
-
this,
|
|
199
|
-
this._entityCollectionPickingCallback
|
|
200
|
-
);
|
|
201
|
-
} else if (!this._isActive && this._pickingId !== -1) {
|
|
202
|
-
this.renderer.removePickingCallback(this._pickingId);
|
|
203
|
-
this._pickingId = -1;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
for (var i = 0; i < this.childNodes.length; i++) {
|
|
208
|
-
this.childNodes[i].setActive(isActive);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Sets draw mode
|
|
214
|
-
* @public
|
|
215
|
-
* @param {Number} mode - Draw mode, such as gl.TRIANGLES, gl.TRIANGLE_STRIP, gl.LINES etc.
|
|
216
|
-
*/
|
|
217
|
-
setDrawMode(mode) {
|
|
218
|
-
this.drawMode = mode;
|
|
219
|
-
for (var i = 0; i < this.childNodes.length; i++) {
|
|
220
|
-
this.childNodes[i].setDrawMode(mode);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* IMPORTANT: This function have to be called manualy in each render node frame callback, before drawing scene geometry.
|
|
226
|
-
* @public
|
|
227
|
-
*/
|
|
228
|
-
transformLights() {
|
|
229
|
-
var r = this.renderer;
|
|
230
|
-
for (var i = 0; i < this._lights.length; i++) {
|
|
231
|
-
var ii = i * 4;
|
|
232
|
-
var tp;
|
|
233
|
-
if (this._lights[i].directional) {
|
|
234
|
-
tp = r.activeCamera._normalMatrix.mulVec(this._lights[i]._position);
|
|
235
|
-
this._lightsTransformedPositions[ii + 3] = 0;
|
|
236
|
-
} else {
|
|
237
|
-
tp = r.activeCamera._viewMatrix.mulVec3(this._lights[i]._position);
|
|
238
|
-
this._lightsTransformedPositions[ii + 3] = 1;
|
|
239
|
-
}
|
|
240
|
-
this._lightsTransformedPositions[ii] = tp.x;
|
|
241
|
-
this._lightsTransformedPositions[ii + 1] = tp.y;
|
|
242
|
-
this._lightsTransformedPositions[ii + 2] = tp.z;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
updateBillboardsTexCoords() {
|
|
247
|
-
for (var i = 0; i < this.entityCollections.length; i++) {
|
|
248
|
-
this.entityCollections[i].billboardHandler.refreshTexCoordsArr();
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* @private
|
|
254
|
-
*/
|
|
255
|
-
_drawNodes() {
|
|
256
|
-
for (var i = 0; i < this.childNodes.length; i++) {
|
|
257
|
-
if (this.childNodes[i]._isActive) {
|
|
258
|
-
this.childNodes[i]._drawNodes();
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (this.show) {
|
|
263
|
-
if (this.frame) {
|
|
264
|
-
//this.lightEnabled && this.transformLights();
|
|
265
|
-
this.frame();
|
|
266
|
-
}
|
|
267
|
-
this.drawEntityCollections(this.entityCollections);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
drawEntityCollections(ec) {
|
|
272
|
-
this.renderer.enqueueEntityCollectionsToDraw(ec);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Draw entity collections picking frame.
|
|
277
|
-
* @public
|
|
278
|
-
* @param {Array<og.EntityCollection>} ec - Entity collection array.
|
|
279
|
-
*/
|
|
280
|
-
drawPickingEntityCollections(ec) {
|
|
281
|
-
if (ec.length) {
|
|
282
|
-
var gl = this.renderer.handler.gl;
|
|
283
|
-
|
|
284
|
-
gl.disable(gl.CULL_FACE);
|
|
285
|
-
|
|
286
|
-
//
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
i
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
i
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
//
|
|
332
|
-
i
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
*/
|
|
349
|
-
_entityCollectionPickingCallback() {
|
|
350
|
-
this.drawPickingEntityCollections(this.entityCollections);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
export { RenderNode };
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { BaseNode } from "./BaseNode.js";
|
|
4
|
+
import { Events } from "../Events.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Render node is a logical part of a render mechanism. Represents scene rendering.
|
|
8
|
+
* Forexample one scene node for rendering the Earth, another one for rendering the Moon, another node for rendering stars etc.
|
|
9
|
+
* Each render node has own model view space defined with matrices(scale, rotation, translation, transformation).
|
|
10
|
+
* There are collections of ligh sources, entities and so on in the node.
|
|
11
|
+
* Access to the node is renderer.renderNodes["Earth"]
|
|
12
|
+
* @class
|
|
13
|
+
* @extends {RenderNode}
|
|
14
|
+
* @param {string} name - Node name.
|
|
15
|
+
*/
|
|
16
|
+
class RenderNode extends BaseNode {
|
|
17
|
+
constructor(name) {
|
|
18
|
+
super(name);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Renderer that calls frame() callback.
|
|
22
|
+
* @public
|
|
23
|
+
* @type {Renderer}
|
|
24
|
+
*/
|
|
25
|
+
this.renderer = null;
|
|
26
|
+
|
|
27
|
+
this.drawMode = null;
|
|
28
|
+
|
|
29
|
+
/** Show rendering.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
this.show = true;
|
|
33
|
+
|
|
34
|
+
this._isActive = true;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Lighting calculations.
|
|
38
|
+
* @public
|
|
39
|
+
* @type {boolean}
|
|
40
|
+
*/
|
|
41
|
+
this.lightEnabled = false;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Point light array.
|
|
45
|
+
* @private
|
|
46
|
+
* @type {Array.<LightSource>}
|
|
47
|
+
*/
|
|
48
|
+
this._lights = [];
|
|
49
|
+
this._lightsTransformedPositions = [];
|
|
50
|
+
this._lightsParamsv = [];
|
|
51
|
+
this._lightsParamsf = [];
|
|
52
|
+
this._lightsNames = [];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Entity collection array.
|
|
56
|
+
* @public
|
|
57
|
+
* @type {Array.<EntityCollection>}
|
|
58
|
+
*/
|
|
59
|
+
this.entityCollections = [];
|
|
60
|
+
|
|
61
|
+
this._pickingId = -1;
|
|
62
|
+
|
|
63
|
+
this.events = new Events(null, this);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Adds node to the current hierarchy.
|
|
68
|
+
* @public
|
|
69
|
+
* @type {RenderNode}
|
|
70
|
+
*/
|
|
71
|
+
addNode(node) {
|
|
72
|
+
super.addNode(node);
|
|
73
|
+
node.assign(this.renderer);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Assign render node with renderer.
|
|
78
|
+
* @public
|
|
79
|
+
* @param {Renderer} renderer - Redner node's renderer.
|
|
80
|
+
*/
|
|
81
|
+
assign(renderer) {
|
|
82
|
+
this.renderer = renderer;
|
|
83
|
+
this._pickingId = renderer.addPickingCallback(this, this._entityCollectionPickingCallback);
|
|
84
|
+
|
|
85
|
+
for (var i = 0; i < this.entityCollections.length; i++) {
|
|
86
|
+
this.entityCollections[i].bindRenderNode(this);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.init && this.init();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
onremove() {
|
|
93
|
+
//virtual
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
remove() {
|
|
97
|
+
var r = this.renderer,
|
|
98
|
+
n = this.name;
|
|
99
|
+
|
|
100
|
+
if (r) {
|
|
101
|
+
if (r.renderNodes[n] && r.renderNodes[n].isEqual(this)) {
|
|
102
|
+
r.renderNodes[n] = null;
|
|
103
|
+
delete r.renderNodes[n];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
for (var i = 0; i < r._renderNodesArr.length; i++) {
|
|
107
|
+
if (r._renderNodesArr[i].isEqual(this)) {
|
|
108
|
+
r._renderNodesArr.splice(i, 1);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
r.removePickingCallback(this._pickingId);
|
|
113
|
+
this._pickingId = -1;
|
|
114
|
+
this.onremove && this.onremove();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Adds entity collection.
|
|
120
|
+
* @public
|
|
121
|
+
* @param {EntityCollection} entityCollection - Entity collection.
|
|
122
|
+
* @param {boolean} [isHidden] - If it's true that this collection has specific rendering.
|
|
123
|
+
* @returns {RenderNode} -
|
|
124
|
+
*/
|
|
125
|
+
addEntityCollection(entityCollection, isHidden) {
|
|
126
|
+
entityCollection.addTo(this, isHidden);
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Removes entity collection.
|
|
132
|
+
* @public
|
|
133
|
+
* @param {EntityCollection} entityCollection - Entity collection for remove.
|
|
134
|
+
*/
|
|
135
|
+
removeEntityCollection(entityCollection) {
|
|
136
|
+
entityCollection.remove();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Adds point light source.
|
|
141
|
+
* @public
|
|
142
|
+
* @param {LightSource} light - Light source.
|
|
143
|
+
* @returns {RenderNode}
|
|
144
|
+
*/
|
|
145
|
+
addLight(light) {
|
|
146
|
+
light.addTo(this);
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Gets light object by its name.
|
|
152
|
+
* @public
|
|
153
|
+
* @param {string} name - Point light name.
|
|
154
|
+
* @returns {LightSource}
|
|
155
|
+
*/
|
|
156
|
+
getLightByName(name) {
|
|
157
|
+
var li = this._lightsNames.indexOf(name);
|
|
158
|
+
return this._lights[li];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Removes light source.
|
|
163
|
+
* @public
|
|
164
|
+
* @param {LightSource} light - Light source object.
|
|
165
|
+
*/
|
|
166
|
+
removeLight(light) {
|
|
167
|
+
light.remove();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Calls render frame node's callback. Used in renderer.
|
|
172
|
+
* @public
|
|
173
|
+
*/
|
|
174
|
+
drawNode(frustum, frustumIndex) {
|
|
175
|
+
this._isActive && this._drawNodes(frustum, frustumIndex);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Gets render node activity.
|
|
180
|
+
* @public
|
|
181
|
+
* @returns {Boolean} -
|
|
182
|
+
*/
|
|
183
|
+
isActive() {
|
|
184
|
+
return this._isActive;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Rendering activation.
|
|
189
|
+
* @public
|
|
190
|
+
* @param {boolean} isActive - Activation flag.
|
|
191
|
+
*/
|
|
192
|
+
setActive(isActive) {
|
|
193
|
+
this._isActive = isActive;
|
|
194
|
+
|
|
195
|
+
if (this.renderer) {
|
|
196
|
+
if (this._isActive && this._pickingId === -1) {
|
|
197
|
+
this._pickingId = this.renderer.addPickingCallback(
|
|
198
|
+
this,
|
|
199
|
+
this._entityCollectionPickingCallback
|
|
200
|
+
);
|
|
201
|
+
} else if (!this._isActive && this._pickingId !== -1) {
|
|
202
|
+
this.renderer.removePickingCallback(this._pickingId);
|
|
203
|
+
this._pickingId = -1;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
for (var i = 0; i < this.childNodes.length; i++) {
|
|
208
|
+
this.childNodes[i].setActive(isActive);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Sets draw mode
|
|
214
|
+
* @public
|
|
215
|
+
* @param {Number} mode - Draw mode, such as gl.TRIANGLES, gl.TRIANGLE_STRIP, gl.LINES etc.
|
|
216
|
+
*/
|
|
217
|
+
setDrawMode(mode) {
|
|
218
|
+
this.drawMode = mode;
|
|
219
|
+
for (var i = 0; i < this.childNodes.length; i++) {
|
|
220
|
+
this.childNodes[i].setDrawMode(mode);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* IMPORTANT: This function have to be called manualy in each render node frame callback, before drawing scene geometry.
|
|
226
|
+
* @public
|
|
227
|
+
*/
|
|
228
|
+
transformLights() {
|
|
229
|
+
var r = this.renderer;
|
|
230
|
+
for (var i = 0; i < this._lights.length; i++) {
|
|
231
|
+
var ii = i * 4;
|
|
232
|
+
var tp;
|
|
233
|
+
if (this._lights[i].directional) {
|
|
234
|
+
tp = r.activeCamera._normalMatrix.mulVec(this._lights[i]._position);
|
|
235
|
+
this._lightsTransformedPositions[ii + 3] = 0;
|
|
236
|
+
} else {
|
|
237
|
+
tp = r.activeCamera._viewMatrix.mulVec3(this._lights[i]._position);
|
|
238
|
+
this._lightsTransformedPositions[ii + 3] = 1;
|
|
239
|
+
}
|
|
240
|
+
this._lightsTransformedPositions[ii] = tp.x;
|
|
241
|
+
this._lightsTransformedPositions[ii + 1] = tp.y;
|
|
242
|
+
this._lightsTransformedPositions[ii + 2] = tp.z;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
updateBillboardsTexCoords() {
|
|
247
|
+
for (var i = 0; i < this.entityCollections.length; i++) {
|
|
248
|
+
this.entityCollections[i].billboardHandler.refreshTexCoordsArr();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @private
|
|
254
|
+
*/
|
|
255
|
+
_drawNodes() {
|
|
256
|
+
for (var i = 0; i < this.childNodes.length; i++) {
|
|
257
|
+
if (this.childNodes[i]._isActive) {
|
|
258
|
+
this.childNodes[i]._drawNodes();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (this.show) {
|
|
263
|
+
if (this.frame) {
|
|
264
|
+
//this.lightEnabled && this.transformLights();
|
|
265
|
+
this.frame();
|
|
266
|
+
}
|
|
267
|
+
this.drawEntityCollections(this.entityCollections);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
drawEntityCollections(ec) {
|
|
272
|
+
this.renderer.enqueueEntityCollectionsToDraw(ec);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Draw entity collections picking frame.
|
|
277
|
+
* @public
|
|
278
|
+
* @param {Array<og.EntityCollection>} ec - Entity collection array.
|
|
279
|
+
*/
|
|
280
|
+
drawPickingEntityCollections(ec) {
|
|
281
|
+
if (ec.length) {
|
|
282
|
+
var gl = this.renderer.handler.gl;
|
|
283
|
+
|
|
284
|
+
gl.disable(gl.CULL_FACE);
|
|
285
|
+
|
|
286
|
+
// billoard pass
|
|
287
|
+
var i = ec.length;
|
|
288
|
+
while (i--) {
|
|
289
|
+
ec[i]._fadingOpacity && ec[i].billboardHandler.drawPicking();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// geoObject pass
|
|
293
|
+
i = ec.length;
|
|
294
|
+
while (i--) {
|
|
295
|
+
ec[i]._fadingOpacity && ec[i].geoObjectHandler.drawPicking();
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// label pass
|
|
299
|
+
i = ec.length;
|
|
300
|
+
while (i--) {
|
|
301
|
+
ec[i]._fadingOpacity && ec[i].labelHandler.drawPicking();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// ray pass
|
|
305
|
+
i = ec.length;
|
|
306
|
+
while (i--) {
|
|
307
|
+
ec[i]._fadingOpacity && ec[i].rayHandler.drawPicking();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
gl.enable(gl.CULL_FACE);
|
|
311
|
+
|
|
312
|
+
// polylines pass
|
|
313
|
+
i = ec.length;
|
|
314
|
+
while (i--) {
|
|
315
|
+
ec[i]._visibility && ec[i].polylineHandler.drawPicking();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
//shapes pass
|
|
319
|
+
i = ec.length;
|
|
320
|
+
while (i--) {
|
|
321
|
+
ec[i]._visibility && ec[i].shapeHandler.drawPicking();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
//Strip pass
|
|
325
|
+
i = ec.length;
|
|
326
|
+
while (i--) {
|
|
327
|
+
ec[i]._visibility && ec[i].stripHandler.drawPicking();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// //pointClouds pass
|
|
331
|
+
// i = ec.length;
|
|
332
|
+
// while (i--) {
|
|
333
|
+
// ec[i]._visibility && ec[i].pointCloudHandler.drawPicking();
|
|
334
|
+
// }
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Picking entity frame callback
|
|
340
|
+
* @private
|
|
341
|
+
*/
|
|
342
|
+
_entityCollectionPickingCallback() {
|
|
343
|
+
this.drawPickingEntityCollections(this.entityCollections);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export { RenderNode };
|