@openglobus/og 0.14.10 → 0.15.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/css/og.css +378 -275
- package/dist/@openglobus/og.css +1 -1
- 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 +18 -17
- package/src/og/Clock.js +218 -194
- package/src/og/Globe.js +5 -5
- package/src/og/Object3d.js +104 -145
- package/src/og/camera/Camera.js +31 -27
- package/src/og/camera/PlanetCamera.js +22 -14
- package/src/og/cons.js +107 -107
- package/src/og/control/Atmosphere.js +396 -0
- package/src/og/control/CompassButton.js +11 -18
- package/src/og/control/Control.js +187 -188
- package/src/og/control/GeoImageDragControl.js +84 -66
- package/src/og/control/LayerSwitcher.js +56 -138
- package/src/og/control/Lighting.js +314 -186
- package/src/og/control/MouseNavigation.js +2 -2
- package/src/og/control/RulerSwitcher.js +24 -19
- package/src/og/control/ScaleControl.js +30 -10
- package/src/og/control/SimpleSkyBackground.js +210 -0
- package/src/og/control/Sun.js +2 -0
- package/src/og/control/ZoomControl.js +30 -42
- package/src/og/control/index.js +6 -0
- package/src/og/control/ruler/RulerScene.js +5 -23
- package/src/og/control/selection/Selection.js +99 -0
- package/src/og/control/selection/SelectionScene.js +350 -0
- package/src/og/control/timeline/TimelineControl.js +99 -0
- package/src/og/control/timeline/TimelineModel.js +133 -0
- package/src/og/control/timeline/TimelineView.js +449 -0
- package/src/og/control/timeline/timelineUtils.js +132 -0
- package/src/og/ellipsoid/Ellipsoid.js +120 -93
- package/src/og/ellipsoid/wgs84.js +13 -13
- package/src/og/entity/Entity.js +36 -9
- package/src/og/entity/EntityCollection.js +0 -2
- package/src/og/entity/GeoObject.js +72 -56
- package/src/og/entity/GeoObjectHandler.js +487 -656
- package/src/og/entity/GeometryHandler.js +1341 -1337
- package/src/og/entity/Polyline.js +0 -16
- package/src/og/entity/Ray.js +0 -10
- package/src/og/entity/RayHandler.js +3 -44
- package/src/og/entity/Strip.js +1 -6
- package/src/og/index.js +10 -6
- package/src/og/input/input.js +3 -1
- package/src/og/layer/CanvasTiles.js +39 -34
- package/src/og/layer/Layer.js +69 -9
- package/src/og/layer/Material.js +1 -8
- package/src/og/layer/WMS.js +16 -5
- package/src/og/light/LightSource.js +2 -0
- package/src/og/math/Line3.js +140 -139
- package/src/og/math/Plane.js +118 -117
- package/src/og/math/Ray.js +242 -239
- package/src/og/math/Vec3.js +56 -37
- package/src/og/math/Vec4.js +3 -4
- package/src/og/math.js +21 -21
- package/src/og/quadTree/Node.js +5 -4
- package/src/og/quadTree/index.js +12 -0
- package/src/og/renderer/Renderer.js +64 -37
- package/src/og/renderer/RendererEvents.js +1071 -1065
- package/src/og/scene/Planet.js +352 -172
- package/src/og/scene/RenderNode.js +27 -12
- package/src/og/segment/Segment.js +0 -5
- package/src/og/shaders/atmos.js +332 -0
- package/src/og/shaders/drawnode.js +475 -109
- package/src/og/shaders/geoObject.js +96 -51
- package/src/og/shaders/polyline.js +212 -17
- package/src/og/shaders/ray.js +13 -6
- package/src/og/shaders/toneMapping.js +5 -5
- package/src/og/shaders/utils.js +88 -0
- package/src/og/terrain/GlobusTerrain.js +5 -4
- package/src/og/terrain/MapboxTerrain.js +231 -52
- package/src/og/ui/Button.js +106 -0
- package/src/og/ui/ButtonGroup.js +57 -0
- package/src/og/ui/Dialog.js +242 -0
- package/src/og/ui/Slider.js +144 -0
- package/src/og/ui/ToggleButton.js +51 -0
- package/src/og/{control → ui}/UIhelpers.js +11 -2
- package/src/og/ui/View.js +190 -0
- package/src/og/utils/shared.js +960 -942
- package/src/og/webgl/Framebuffer.js +308 -387
- package/src/og/webgl/Handler.js +90 -30
- package/src/og/webgl/Multisample.js +8 -0
- package/types/Clock.d.ts +7 -2
- package/types/Object3d.d.ts +14 -3
- package/types/camera/Camera.d.ts +18 -17
- package/types/camera/PlanetCamera.d.ts +3 -1
- package/types/control/Atmosphere.d.ts +15 -0
- package/types/control/CompassButton.d.ts +1 -2
- package/types/control/GeoImageDragControl.d.ts +7 -1
- package/types/control/LayerSwitcher.d.ts +5 -6
- package/types/control/Lighting.d.ts +32 -7
- package/types/control/ScaleControl.d.ts +2 -1
- package/types/control/SimpleSkyBackground.d.ts +15 -0
- package/types/control/ZoomControl.d.ts +0 -1
- package/types/control/index.d.ts +4 -1
- package/types/control/ruler/RulerScene.d.ts +0 -1
- package/types/control/selection/Selection.d.ts +49 -0
- package/types/control/selection/SelectionScene.d.ts +34 -0
- package/types/ellipsoid/Ellipsoid.d.ts +3 -2
- package/types/entity/Entity.d.ts +8 -0
- package/types/entity/GeoObject.d.ts +28 -22
- package/types/entity/GeoObjectHandler.d.ts +16 -56
- package/types/entity/Ray.d.ts +0 -3
- package/types/entity/RayHandler.d.ts +0 -4
- package/types/index.d.ts +7 -5
- package/types/input/input.d.ts +2 -0
- package/types/layer/CanvasTiles.d.ts +1 -0
- package/types/layer/Layer.d.ts +9 -0
- package/types/layer/WMS.d.ts +7 -3
- package/types/math/Plane.d.ts +1 -1
- package/types/math/Vec3.d.ts +19 -16
- package/types/math/Vec4.d.ts +2 -3
- package/types/math.d.ts +20 -20
- package/types/quadTree/index.d.ts +10 -0
- package/types/renderer/Renderer.d.ts +11 -37
- package/types/scene/Planet.d.ts +27 -1
- package/types/scene/RenderNode.d.ts +2 -1
- package/types/segment/Segment.d.ts +1 -1
- package/types/shaders/atmos.d.ts +4 -0
- package/types/shaders/drawnode.d.ts +3 -2
- package/types/shaders/utils.d.ts +1 -0
- package/types/terrain/GlobusTerrain.d.ts +1 -1
- package/types/terrain/MapboxTerrain.d.ts +2 -1
- package/types/ui/Button.d.ts +21 -0
- package/types/ui/Dialog.d.ts +41 -0
- package/types/ui/Slider.d.ts +30 -0
- package/types/ui/ToggleButton.d.ts +10 -0
- package/types/{control → ui}/UIhelpers.d.ts +1 -1
- package/types/ui/View.d.ts +32 -0
- package/types/utils/shared.d.ts +16 -14
- package/types/webgl/Framebuffer.d.ts +2 -5
- package/types/webgl/Handler.d.ts +15 -10
- package/types/webgl/Multisample.d.ts +2 -0
- package/src/og/ajax.js +0 -204
- package/src/og/entity/Object3d.js +0 -504
- package/src/og/utils/quadTreeType.js +0 -11
- package/types/ajax.d.ts +0 -24
- package/types/utils/quadTreeType.d.ts +0 -8
|
@@ -4,18 +4,19 @@
|
|
|
4
4
|
* @module og/entity/ShapeHandler
|
|
5
5
|
*/
|
|
6
6
|
import * as shaders from "../shaders/geoObject.js";
|
|
7
|
-
import { concatArrays, makeArrayTyped, spliceArray } from "../utils/shared.js";
|
|
8
|
-
|
|
9
|
-
const VERTEX_BUFFER = 0
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
import { concatArrays, loadImage, makeArrayTyped, spliceArray } from "../utils/shared.js";
|
|
8
|
+
|
|
9
|
+
const VERTEX_BUFFER = 0;
|
|
10
|
+
const POSITION_BUFFER = 1;
|
|
11
|
+
const RGBA_BUFFER = 2;
|
|
12
|
+
const NORMALS_BUFFER = 3;
|
|
13
|
+
const INDEX_BUFFER = 4;
|
|
14
|
+
const DIRECTION_BUFFER = 5;
|
|
15
|
+
const PITCH_ROLL_BUFFER = 6;
|
|
16
|
+
const SIZE_BUFFER = 7;
|
|
17
|
+
const PICKINGCOLOR_BUFFER = 8;
|
|
18
|
+
const VISIBLE_BUFFER = 9;
|
|
19
|
+
const TEXCOORD_BUFFER = 10;
|
|
19
20
|
|
|
20
21
|
const setParametersToArray = (arr = [], index = 0, length, itemSize, ...params) => {
|
|
21
22
|
const currIndex = index * length;
|
|
@@ -25,149 +26,296 @@ const setParametersToArray = (arr = [], index = 0, length, itemSize, ...params)
|
|
|
25
26
|
return arr;
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.pickingEnabled = true;
|
|
29
|
+
const setParametersToArrayArr = (arr = [], index = 0, length, itemSize, paramsArr) => {
|
|
30
|
+
const currIndex = index * length;
|
|
31
|
+
for (let i = currIndex, len = currIndex + length; i < len; i++) {
|
|
32
|
+
arr[i] = paramsArr[i % itemSize];
|
|
33
|
+
}
|
|
34
|
+
return arr;
|
|
35
|
+
};
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this._planet = null;
|
|
37
|
+
class InstanceData {
|
|
38
|
+
constructor(geoObjectHandler) {
|
|
40
39
|
|
|
41
|
-
this.
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
this.
|
|
48
|
-
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
51
|
-
|
|
52
|
-
this.
|
|
53
|
-
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
60
|
-
this.
|
|
61
|
-
this.
|
|
62
|
-
this.
|
|
63
|
-
this.
|
|
64
|
-
|
|
40
|
+
this.isFree = true;
|
|
41
|
+
|
|
42
|
+
this._geoObjectHandler = geoObjectHandler;
|
|
43
|
+
|
|
44
|
+
this.geoObjects = [];
|
|
45
|
+
|
|
46
|
+
this.numInstances = 0;
|
|
47
|
+
|
|
48
|
+
this._texture = null;
|
|
49
|
+
this._textureSrc = null;
|
|
50
|
+
|
|
51
|
+
this._pitchRollArr = [];
|
|
52
|
+
this._sizeArr = [];
|
|
53
|
+
this._vertexArr = [];
|
|
54
|
+
this._positionHighArr = [];
|
|
55
|
+
this._positionLowArr = [];
|
|
56
|
+
this._directionArr = [];
|
|
57
|
+
this._rgbaArr = [];
|
|
58
|
+
this._normalsArr = [];
|
|
59
|
+
this._indicesArr = [];
|
|
60
|
+
this._pickingColorArr = [];
|
|
61
|
+
this._visibleArr = [];
|
|
62
|
+
this._texCoordArr = [];
|
|
63
|
+
|
|
64
|
+
this._pitchRollBuffer = null;
|
|
65
|
+
this._sizeBuffer = null;
|
|
66
|
+
this._vertexBuffer = null;
|
|
67
|
+
this._positionHighBuffer = null;
|
|
68
|
+
this._positionLowBuffer = null;
|
|
69
|
+
this._directionBuffer = null;
|
|
70
|
+
this._rgbaBuffer = null;
|
|
71
|
+
this._normalsBuffer = null;
|
|
72
|
+
this._indicesBuffer = null;
|
|
73
|
+
this._pickingColorBuffer = null;
|
|
74
|
+
this._visibleBuffer = null;
|
|
75
|
+
this._texCoordBuffer = null;
|
|
65
76
|
|
|
66
|
-
this.__staticId = GeoObjectHandler._staticCounter++;
|
|
67
77
|
this._buffersUpdateCallbacks = [];
|
|
68
78
|
this._buffersUpdateCallbacks[PICKINGCOLOR_BUFFER] = this.createPickingColorBuffer;
|
|
69
79
|
this._buffersUpdateCallbacks[POSITION_BUFFER] = this.createPositionBuffer;
|
|
70
80
|
this._buffersUpdateCallbacks[DIRECTION_BUFFER] = this.createDirectionBuffer;
|
|
71
81
|
this._buffersUpdateCallbacks[NORMALS_BUFFER] = this.createNormalsBuffer;
|
|
72
82
|
this._buffersUpdateCallbacks[RGBA_BUFFER] = this.createRgbaBuffer;
|
|
73
|
-
this._buffersUpdateCallbacks[
|
|
83
|
+
this._buffersUpdateCallbacks[INDEX_BUFFER] = this.createIndicesBuffer;
|
|
74
84
|
this._buffersUpdateCallbacks[VERTEX_BUFFER] = this.createVertexBuffer;
|
|
75
85
|
this._buffersUpdateCallbacks[SIZE_BUFFER] = this.createSizeBuffer;
|
|
76
86
|
this._buffersUpdateCallbacks[PITCH_ROLL_BUFFER] = this.createPitchRollBuffer;
|
|
77
87
|
this._buffersUpdateCallbacks[VISIBLE_BUFFER] = this.createVisibleBuffer;
|
|
88
|
+
this._buffersUpdateCallbacks[TEXCOORD_BUFFER] = this.createTexCoordBuffer;
|
|
78
89
|
|
|
79
90
|
this._changedBuffers = new Array(this._buffersUpdateCallbacks.length);
|
|
91
|
+
}
|
|
80
92
|
|
|
81
|
-
|
|
93
|
+
createTexture(image) {
|
|
94
|
+
if (this._geoObjectHandler && this._geoObjectHandler._planet) {
|
|
95
|
+
this._texture = this._geoObjectHandler._planet.renderer.handler.createTextureDefault(image);
|
|
96
|
+
}
|
|
82
97
|
}
|
|
83
98
|
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
clear() {
|
|
100
|
+
|
|
101
|
+
this.numInstances = 0;
|
|
102
|
+
|
|
103
|
+
this.geoObjects = [];
|
|
104
|
+
|
|
105
|
+
this._pitchRollArr = [];
|
|
106
|
+
this._sizeArr = [];
|
|
107
|
+
this._vertexArr = [];
|
|
108
|
+
this._positionHighArr = [];
|
|
109
|
+
this._positionLowArr = [];
|
|
110
|
+
this._directionArr = [];
|
|
111
|
+
this._rgbaArr = [];
|
|
112
|
+
this._normalsArr = [];
|
|
113
|
+
this._indicesArr = [];
|
|
114
|
+
this._pickingColorArr = [];
|
|
115
|
+
this._visibleArr = [];
|
|
116
|
+
this._texCoordArr = [];
|
|
117
|
+
|
|
118
|
+
let h = this._geoObjectHandler._planet.renderer.handler, gl = h.gl;
|
|
119
|
+
|
|
120
|
+
h.deleteTexture(this._texture);
|
|
121
|
+
|
|
122
|
+
this._texture = null;
|
|
123
|
+
|
|
124
|
+
gl.deleteBuffer(this._pitchRollBuffer);
|
|
125
|
+
gl.deleteBuffer(this._sizeBuffer);
|
|
126
|
+
gl.deleteBuffer(this._vertexBuffer);
|
|
127
|
+
gl.deleteBuffer(this._positionHighBuffer);
|
|
128
|
+
gl.deleteBuffer(this._positionLowBuffer);
|
|
129
|
+
gl.deleteBuffer(this._directionBuffer);
|
|
130
|
+
gl.deleteBuffer(this._rgbaBuffer);
|
|
131
|
+
gl.deleteBuffer(this._normalsBuffer);
|
|
132
|
+
gl.deleteBuffer(this._indicesBuffer);
|
|
133
|
+
gl.deleteBuffer(this._pickingColorBuffer);
|
|
134
|
+
gl.deleteBuffer(this._visibleBuffer);
|
|
135
|
+
gl.deleteBuffer(this._texCoordBuffer);
|
|
136
|
+
|
|
137
|
+
this._pitchRollBuffer = null;
|
|
138
|
+
this._sizeBuffer = null;
|
|
139
|
+
this._vertexBuffer = null;
|
|
140
|
+
this._positionHighBuffer = null;
|
|
141
|
+
this._positionLowBuffer = null;
|
|
142
|
+
this._directionBuffer = null;
|
|
143
|
+
this._rgbaBuffer = null;
|
|
144
|
+
this._normalsBuffer = null;
|
|
145
|
+
this._indicesBuffer = null;
|
|
146
|
+
this._pickingColorBuffer = null;
|
|
147
|
+
this._visibleBuffer = null;
|
|
148
|
+
this._texCoordBuffer = null;
|
|
149
|
+
|
|
150
|
+
this.isFree = false;
|
|
151
|
+
this._geoObjectHandler = null;
|
|
86
152
|
}
|
|
87
153
|
|
|
88
|
-
//Create buffers
|
|
89
154
|
createVertexBuffer() {
|
|
90
|
-
const h = this.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
155
|
+
const h = this._geoObjectHandler._planet.renderer.handler;
|
|
156
|
+
h.gl.deleteBuffer(this._vertexBuffer);
|
|
157
|
+
this._vertexArr = makeArrayTyped(this._vertexArr);
|
|
158
|
+
this._vertexBuffer = h.createArrayBuffer(this._vertexArr, 3, this._vertexArr.length / 3);
|
|
95
159
|
}
|
|
96
160
|
|
|
97
161
|
createPitchRollBuffer() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
162
|
+
let h = this._geoObjectHandler._planet.renderer.handler, numItems = this._pitchRollArr.length / 2;
|
|
163
|
+
|
|
164
|
+
if (!this._pitchRollBuffer || this._pitchRollBuffer.numItems !== numItems) {
|
|
165
|
+
h.gl.deleteBuffer(this._pitchRollBuffer);
|
|
166
|
+
this._pitchRollBuffer = h.createStreamArrayBuffer(2, numItems);
|
|
102
167
|
}
|
|
168
|
+
|
|
169
|
+
this._pitchRollArr = makeArrayTyped(this._pitchRollArr);
|
|
170
|
+
|
|
171
|
+
h.setStreamArrayBuffer(this._pitchRollBuffer, this._pitchRollArr);
|
|
103
172
|
}
|
|
104
173
|
|
|
105
174
|
createVisibleBuffer() {
|
|
106
|
-
const h = this.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
175
|
+
const h = this._geoObjectHandler._planet.renderer.handler, numItems = this._visibleArr.length;
|
|
176
|
+
|
|
177
|
+
if (!this._visibleBuffer || this._visibleBuffer.numItems !== numItems) {
|
|
178
|
+
h.gl.deleteBuffer(this._visibleBuffer);
|
|
179
|
+
this._visibleBuffer = h.createStreamArrayBuffer(1, numItems);
|
|
110
180
|
}
|
|
181
|
+
|
|
182
|
+
this._visibleArr = makeArrayTyped(this._visibleArr);
|
|
183
|
+
|
|
184
|
+
h.setStreamArrayBuffer(this._visibleBuffer, this._visibleArr);
|
|
111
185
|
}
|
|
112
186
|
|
|
113
187
|
createSizeBuffer() {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
188
|
+
let h = this._geoObjectHandler._planet.renderer.handler, numItems = this._sizeArr.length;
|
|
189
|
+
|
|
190
|
+
if (!this._sizeBuffer || this._sizeBuffer.numItems !== numItems) {
|
|
191
|
+
h.gl.deleteBuffer(this._sizeBuffer);
|
|
192
|
+
this._sizeBuffer = h.createStreamArrayBuffer(1, numItems);
|
|
118
193
|
}
|
|
194
|
+
|
|
195
|
+
this._sizeArr = makeArrayTyped(this._sizeArr);
|
|
196
|
+
|
|
197
|
+
h.setStreamArrayBuffer(this._sizeBuffer, this._sizeArr);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
createTexCoordBuffer() {
|
|
201
|
+
const h = this._geoObjectHandler._planet.renderer.handler;
|
|
202
|
+
h.gl.deleteBuffer(this._texCoordBuffer);
|
|
203
|
+
this._texCoordArr = makeArrayTyped(this._texCoordArr);
|
|
204
|
+
this._texCoordBuffer = h.createArrayBuffer(this._texCoordArr, 2, this._texCoordArr.length / 2);
|
|
119
205
|
}
|
|
120
206
|
|
|
121
207
|
createPositionBuffer() {
|
|
122
|
-
let h = this.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
this.
|
|
208
|
+
let h = this._geoObjectHandler._planet.renderer.handler, numItems = this._positionHighArr.length / 3;
|
|
209
|
+
|
|
210
|
+
if (!this._positionHighBuffer || this._positionHighBuffer.numItems !== numItems) {
|
|
211
|
+
h.gl.deleteBuffer(this._positionHighBuffer);
|
|
212
|
+
h.gl.deleteBuffer(this._positionLowBuffer);
|
|
213
|
+
this._positionHighBuffer = h.createStreamArrayBuffer(3, numItems);
|
|
214
|
+
this._positionLowBuffer = h.createStreamArrayBuffer(3, numItems);
|
|
128
215
|
}
|
|
216
|
+
|
|
217
|
+
this._positionHighArr = makeArrayTyped(this._positionHighArr);
|
|
218
|
+
this._positionLowArr = makeArrayTyped(this._positionLowArr);
|
|
219
|
+
|
|
220
|
+
h.setStreamArrayBuffer(this._positionHighBuffer, this._positionHighArr);
|
|
221
|
+
h.setStreamArrayBuffer(this._positionLowBuffer, this._positionLowArr);
|
|
129
222
|
}
|
|
130
223
|
|
|
131
224
|
createRgbaBuffer() {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
225
|
+
let h = this._geoObjectHandler._planet.renderer.handler, numItems = this._rgbaArr.length / 4;
|
|
226
|
+
|
|
227
|
+
if (!this._rgbaBuffer || this._rgbaBuffer.numItems !== numItems) {
|
|
228
|
+
h.gl.deleteBuffer(this._rgbaBuffer);
|
|
229
|
+
this._rgbaBuffer = h.createStreamArrayBuffer(4, numItems);
|
|
136
230
|
}
|
|
231
|
+
|
|
232
|
+
this._rgbaArr = makeArrayTyped(this._rgbaArr);
|
|
233
|
+
|
|
234
|
+
h.setStreamArrayBuffer(this._rgbaBuffer, this._rgbaArr);
|
|
137
235
|
}
|
|
138
236
|
|
|
139
237
|
createDirectionBuffer() {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
238
|
+
let h = this._geoObjectHandler._planet.renderer.handler, numItems = this._directionArr.length / 3;
|
|
239
|
+
|
|
240
|
+
if (!this._directionBuffer || this._directionBuffer.numItems !== numItems) {
|
|
241
|
+
h.gl.deleteBuffer(this._directionBuffer);
|
|
242
|
+
this._directionBuffer = h.createStreamArrayBuffer(3, numItems);
|
|
144
243
|
}
|
|
244
|
+
|
|
245
|
+
this._directionArr = makeArrayTyped(this._directionArr);
|
|
246
|
+
|
|
247
|
+
h.setStreamArrayBuffer(this._directionBuffer, this._directionArr);
|
|
145
248
|
}
|
|
146
249
|
|
|
147
250
|
createNormalsBuffer() {
|
|
148
|
-
const h = this.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
251
|
+
const h = this._geoObjectHandler._planet.renderer.handler;
|
|
252
|
+
h.gl.deleteBuffer(this._normalsBuffer);
|
|
253
|
+
this._normalsArr = makeArrayTyped(this._normalsArr);
|
|
254
|
+
this._normalsBuffer = h.createArrayBuffer(this._normalsArr, 3, this._normalsArr.length / 3);
|
|
153
255
|
}
|
|
154
256
|
|
|
155
257
|
createIndicesBuffer() {
|
|
156
|
-
const h = this.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
258
|
+
const h = this._geoObjectHandler._planet.renderer.handler;
|
|
259
|
+
h.gl.deleteBuffer(this._indicesBuffer);
|
|
260
|
+
this._indicesArr = makeArrayTyped(this._indicesArr, Uint16Array);
|
|
261
|
+
this._indicesBuffer = h.createElementArrayBuffer(this._indicesArr, 1, this._indicesArr.length);
|
|
161
262
|
}
|
|
162
263
|
|
|
163
264
|
createPickingColorBuffer() {
|
|
164
|
-
const h = this.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
265
|
+
const h = this._geoObjectHandler._planet.renderer.handler;
|
|
266
|
+
h.gl.deleteBuffer(this._pickingColorBuffer);
|
|
267
|
+
this._pickingColorArr = makeArrayTyped(this._pickingColorArr);
|
|
268
|
+
this._pickingColorBuffer = h.createArrayBuffer(this._pickingColorArr, 3, this._pickingColorArr.length / 3);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
refresh() {
|
|
272
|
+
let i = this._changedBuffers.length;
|
|
273
|
+
while (i--) {
|
|
274
|
+
this._changedBuffers[i] = true;
|
|
168
275
|
}
|
|
169
276
|
}
|
|
170
277
|
|
|
278
|
+
update() {
|
|
279
|
+
if (this._geoObjectHandler._planet) {
|
|
280
|
+
let i = this._changedBuffers.length;
|
|
281
|
+
while (i--) {
|
|
282
|
+
if (this._changedBuffers[i]) {
|
|
283
|
+
this._buffersUpdateCallbacks[i].call(this);
|
|
284
|
+
this._changedBuffers[i] = false;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
this.isFree = true;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
class GeoObjectHandler {
|
|
293
|
+
constructor(entityCollection) {
|
|
294
|
+
|
|
295
|
+
this.__staticId = GeoObjectHandler._staticCounter++;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Picking rendering option.
|
|
299
|
+
* @public
|
|
300
|
+
* @type {boolean}
|
|
301
|
+
*/
|
|
302
|
+
this.pickingEnabled = true;
|
|
303
|
+
|
|
304
|
+
this._entityCollection = entityCollection;
|
|
305
|
+
|
|
306
|
+
this._planet = null;
|
|
307
|
+
|
|
308
|
+
this._geoObjects = [];
|
|
309
|
+
|
|
310
|
+
this._instanceDataMap = new Map();
|
|
311
|
+
this._instanceDataMapValues = [];
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
this._dataTagUpdateQueue = [];
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
//Create buffers
|
|
318
|
+
|
|
171
319
|
static get _staticCounter() {
|
|
172
320
|
if (!this._counter && this._counter !== 0) {
|
|
173
321
|
this._counter = 0;
|
|
@@ -180,115 +328,73 @@ class GeoObjectHandler {
|
|
|
180
328
|
}
|
|
181
329
|
|
|
182
330
|
initProgram() {
|
|
183
|
-
if (this.
|
|
184
|
-
if (!this.
|
|
185
|
-
this.
|
|
331
|
+
if (this._planet && this._planet.renderer) {
|
|
332
|
+
if (!this._planet.renderer.handler.programs.geo_object) {
|
|
333
|
+
this._planet.renderer.handler.addProgram(shaders.geo_object());
|
|
186
334
|
}
|
|
187
|
-
if (!this.
|
|
188
|
-
this.
|
|
335
|
+
if (!this._planet.renderer.handler.programs.geo_object_picking) {
|
|
336
|
+
this._planet.renderer.handler.addProgram(shaders.geo_object_picking());
|
|
189
337
|
}
|
|
190
338
|
}
|
|
191
339
|
}
|
|
192
340
|
|
|
193
341
|
setRenderNode(renderNode) {
|
|
194
|
-
this._renderer = renderNode.renderer;
|
|
195
342
|
this._planet = renderNode;
|
|
196
343
|
this.initProgram();
|
|
197
|
-
}
|
|
198
344
|
|
|
199
|
-
|
|
200
|
-
|
|
345
|
+
//
|
|
346
|
+
// in case of lazy initialization loading data here
|
|
347
|
+
for (let i = 0; i < this._instanceDataMapValues.length; i++) {
|
|
348
|
+
this._loadDataTagTexture(this._instanceDataMapValues[i]);
|
|
349
|
+
}
|
|
201
350
|
}
|
|
202
351
|
|
|
203
352
|
_addGeoObjectToArray(geoObject) {
|
|
204
|
-
|
|
353
|
+
const tag = geoObject.tag;
|
|
354
|
+
|
|
355
|
+
let tagData = this._instanceDataMap.get(tag);
|
|
356
|
+
|
|
357
|
+
if (!tagData) {
|
|
358
|
+
tagData = new InstanceData(this);
|
|
359
|
+
this._instanceDataMap.set(tag, tagData);
|
|
360
|
+
this._instanceDataMapValues = Array.from(this._instanceDataMap.values());
|
|
361
|
+
|
|
362
|
+
//
|
|
363
|
+
// Setting instanced data
|
|
364
|
+
tagData._vertexArr = geoObject.vertices
|
|
365
|
+
tagData._normalsArr = geoObject.normals;
|
|
366
|
+
tagData._indicesArr = geoObject.indices;
|
|
367
|
+
tagData._texCoordArr = geoObject.texCoords;
|
|
368
|
+
tagData._textureSrc = geoObject.object3d.src;
|
|
205
369
|
|
|
206
|
-
|
|
207
|
-
alreadyAdded = this._instancedTags.has(tag);
|
|
208
|
-
|
|
209
|
-
if (!alreadyAdded) {
|
|
210
|
-
this._instancedTags.set(tag, {
|
|
211
|
-
iCounts: 1,
|
|
212
|
-
maxIndex: Math.max(...geoObject._indices),
|
|
213
|
-
index: this._instancedTags.size
|
|
214
|
-
});
|
|
215
|
-
} else {
|
|
216
|
-
const prevState = this._instancedTags.get(tag),
|
|
217
|
-
nextCount = prevState.iCounts + 1;
|
|
218
|
-
this._instancedTags.set(tag, {
|
|
219
|
-
...prevState,
|
|
220
|
-
iCounts: nextCount
|
|
221
|
-
});
|
|
370
|
+
this._loadDataTagTexture(tagData);
|
|
222
371
|
}
|
|
223
|
-
const tagData = this._instancedTags.get(tag),
|
|
224
|
-
ti = tagData.index;
|
|
225
372
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
0,
|
|
238
|
-
geoObject._verticesCount * itemSize,
|
|
239
|
-
geoObject._verticesCount * itemSize,
|
|
240
|
-
...geoObject._vertices
|
|
241
|
-
)
|
|
242
|
-
);
|
|
243
|
-
this._normalsArr[ti] = concatArrays(
|
|
244
|
-
this._normalsArr[ti],
|
|
245
|
-
setParametersToArray(
|
|
246
|
-
[],
|
|
247
|
-
0,
|
|
248
|
-
geoObject._verticesCount * itemSize,
|
|
249
|
-
geoObject._verticesCount * itemSize,
|
|
250
|
-
...geoObject._normals
|
|
251
|
-
// ...getTriangleNormals(geoObject._vertices, geoObject._indices)
|
|
252
|
-
)
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
this._vehicleVisibleArr[ti] = concatArrays(
|
|
256
|
-
this._vehicleVisibleArr[ti],
|
|
257
|
-
setParametersToArray([], 0, 1, 1, geoObject._visibility ? 1 : 0)
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
let x = geoObject._positionHigh.x,
|
|
261
|
-
y = geoObject._positionHigh.y,
|
|
262
|
-
z = geoObject._positionHigh.z,
|
|
263
|
-
w;
|
|
264
|
-
|
|
265
|
-
this._positionHighArr[ti] = concatArrays(
|
|
266
|
-
this._positionHighArr[ti],
|
|
267
|
-
setParametersToArray([], 0, itemSize, itemSize, x, y, z)
|
|
268
|
-
);
|
|
373
|
+
geoObject._tagDataIndex = tagData.numInstances++;
|
|
374
|
+
geoObject._tagData = tagData;
|
|
375
|
+
tagData.geoObjects.push(geoObject);
|
|
376
|
+
|
|
377
|
+
let itemSize = 3;
|
|
378
|
+
|
|
379
|
+
tagData._visibleArr = concatArrays(tagData._visibleArr, setParametersToArray([], 0, 1, 1, geoObject._visibility ? 1 : 0));
|
|
380
|
+
|
|
381
|
+
let x = geoObject._positionHigh.x, y = geoObject._positionHigh.y, z = geoObject._positionHigh.z, w;
|
|
382
|
+
tagData._positionHighArr = concatArrays(tagData._positionHighArr, setParametersToArray([], 0, itemSize, itemSize, x, y, z));
|
|
383
|
+
|
|
269
384
|
x = geoObject._positionLow.x;
|
|
270
385
|
y = geoObject._positionLow.y;
|
|
271
386
|
z = geoObject._positionLow.z;
|
|
272
|
-
|
|
273
|
-
this._positionLowArr[ti],
|
|
274
|
-
setParametersToArray([], 0, itemSize, itemSize, x, y, z)
|
|
275
|
-
);
|
|
387
|
+
tagData._positionLowArr = concatArrays(tagData._positionLowArr, setParametersToArray([], 0, itemSize, itemSize, x, y, z));
|
|
276
388
|
|
|
277
389
|
x = geoObject._entity._pickingColor.x / 255;
|
|
278
390
|
y = geoObject._entity._pickingColor.y / 255;
|
|
279
391
|
z = geoObject._entity._pickingColor.z / 255;
|
|
280
|
-
|
|
281
|
-
this._pickingColorArr[ti],
|
|
282
|
-
setParametersToArray([], 0, itemSize, itemSize, x, y, z)
|
|
283
|
-
);
|
|
392
|
+
tagData._pickingColorArr = concatArrays(tagData._pickingColorArr, setParametersToArray([], 0, itemSize, itemSize, x, y, z));
|
|
284
393
|
|
|
285
394
|
x = geoObject._direction.x;
|
|
286
395
|
y = geoObject._direction.y;
|
|
287
396
|
z = geoObject._direction.z;
|
|
288
|
-
|
|
289
|
-
this._directionArr[ti],
|
|
290
|
-
setParametersToArray([], 0, itemSize, itemSize, x, y, z)
|
|
291
|
-
);
|
|
397
|
+
tagData._directionArr = concatArrays(tagData._directionArr, setParametersToArray([], 0, itemSize, itemSize, x, y, z));
|
|
292
398
|
|
|
293
399
|
itemSize = 4;
|
|
294
400
|
|
|
@@ -296,41 +402,28 @@ class GeoObjectHandler {
|
|
|
296
402
|
y = geoObject._color.y;
|
|
297
403
|
z = geoObject._color.z;
|
|
298
404
|
w = geoObject._color.w;
|
|
299
|
-
|
|
300
|
-
this._rgbaArr[ti],
|
|
301
|
-
setParametersToArray([], 0, itemSize, itemSize, x, y, z, w)
|
|
302
|
-
);
|
|
303
|
-
|
|
304
|
-
x = geoObject._pitch;
|
|
305
|
-
y = geoObject._roll;
|
|
405
|
+
tagData._rgbaArr = concatArrays(tagData._rgbaArr, setParametersToArray([], 0, itemSize, itemSize, x, y, z, w));
|
|
306
406
|
|
|
307
407
|
itemSize = 2;
|
|
308
408
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
);
|
|
409
|
+
x = geoObject._pitch;
|
|
410
|
+
y = geoObject._roll;
|
|
411
|
+
tagData._pitchRollArr = concatArrays(tagData._pitchRollArr, setParametersToArray([], 0, itemSize, itemSize, x, y));
|
|
313
412
|
|
|
314
413
|
itemSize = 1;
|
|
315
414
|
|
|
316
|
-
|
|
317
|
-
this._sizeArr[ti],
|
|
318
|
-
setParametersToArray([], 0, itemSize, itemSize, geoObject.scale)
|
|
319
|
-
);
|
|
320
|
-
this._addIndices(geoObject);
|
|
415
|
+
tagData._sizeArr = concatArrays(tagData._sizeArr, setParametersToArray([], 0, itemSize, itemSize, geoObject._scale));
|
|
321
416
|
}
|
|
322
417
|
|
|
323
418
|
_displayPASS() {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
p = sh._program,
|
|
327
|
-
u = p.uniforms,
|
|
328
|
-
a = p.attributes,
|
|
329
|
-
gl = r.handler.gl,
|
|
330
|
-
ec = this._entityCollection;
|
|
419
|
+
let r = this._planet.renderer, sh = r.handler.programs.geo_object, p = sh._program, u = p.uniforms,
|
|
420
|
+
a = p.attributes, gl = r.handler.gl, ec = this._entityCollection;
|
|
331
421
|
|
|
332
422
|
sh.activate();
|
|
333
423
|
|
|
424
|
+
//
|
|
425
|
+
// Could be in VAO
|
|
426
|
+
//
|
|
334
427
|
gl.enable(gl.CULL_FACE);
|
|
335
428
|
gl.uniform3fv(u.uScaleByDistance, ec.scaleByDistance);
|
|
336
429
|
|
|
@@ -339,75 +432,59 @@ class GeoObjectHandler {
|
|
|
339
432
|
|
|
340
433
|
gl.uniformMatrix4fv(u.projectionMatrix, false, r.activeCamera.getProjectionMatrix());
|
|
341
434
|
gl.uniformMatrix4fv(u.viewMatrix, false, r.activeCamera.getViewMatrix());
|
|
342
|
-
gl.uniformMatrix3fv(u.normalMatrix, false, r.activeCamera._normalMatrix._m);
|
|
343
435
|
|
|
344
|
-
gl.
|
|
436
|
+
gl.uniform3fv(u.lightsPositions, this._planet._lightsPositions);
|
|
345
437
|
gl.uniform3fv(u.lightsParamsv, this._planet._lightsParamsv);
|
|
346
438
|
gl.uniform1fv(u.lightsParamsf, this._planet._lightsParamsf);
|
|
347
439
|
|
|
348
|
-
for (
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
gl.
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
gl.
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
gl.
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
gl.
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
gl.
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
gl.
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
gl.bindBuffer(gl.ARRAY_BUFFER,
|
|
384
|
-
gl.vertexAttribPointer(
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
);
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
p.drawElementsInstanced(
|
|
397
|
-
gl.TRIANGLES,
|
|
398
|
-
this._indicesBuffer[ti].numItems / tagData.iCounts,
|
|
399
|
-
gl.UNSIGNED_SHORT,
|
|
400
|
-
0,
|
|
401
|
-
tagData.iCounts
|
|
402
|
-
);
|
|
403
|
-
} else {
|
|
404
|
-
gl.drawElements(
|
|
405
|
-
gl.TRIANGLES,
|
|
406
|
-
this._indicesBuffer[ti].numItems,
|
|
407
|
-
gl.UNSIGNED_SHORT,
|
|
408
|
-
0
|
|
409
|
-
);
|
|
410
|
-
}
|
|
440
|
+
for (let i = 0; i < this._instanceDataMapValues.length; i++) {
|
|
441
|
+
let tagData = this._instanceDataMapValues[i];
|
|
442
|
+
|
|
443
|
+
//
|
|
444
|
+
// Instance individual data
|
|
445
|
+
//
|
|
446
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._directionBuffer);
|
|
447
|
+
gl.vertexAttribPointer(a.aDirection, tagData._directionBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
448
|
+
|
|
449
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._sizeBuffer);
|
|
450
|
+
gl.vertexAttribPointer(a.aScale, tagData._sizeBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
451
|
+
|
|
452
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._pitchRollBuffer);
|
|
453
|
+
gl.vertexAttribPointer(a.aPitchRoll, tagData._pitchRollBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
454
|
+
|
|
455
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._rgbaBuffer);
|
|
456
|
+
gl.vertexAttribPointer(a.aColor, tagData._rgbaBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
457
|
+
|
|
458
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._visibleBuffer);
|
|
459
|
+
gl.vertexAttribPointer(a.aDispose, tagData._visibleBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
460
|
+
|
|
461
|
+
gl.uniform1f(u.uUseTexture, tagData._texture ? 1 : 0);
|
|
462
|
+
|
|
463
|
+
//
|
|
464
|
+
// Instance common data(could be in VAO)
|
|
465
|
+
//
|
|
466
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._positionHighBuffer);
|
|
467
|
+
gl.vertexAttribPointer(a.aPositionHigh, tagData._positionHighBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
468
|
+
|
|
469
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._positionLowBuffer);
|
|
470
|
+
gl.vertexAttribPointer(a.aPositionLow, tagData._positionLowBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
471
|
+
|
|
472
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._normalsBuffer);
|
|
473
|
+
gl.vertexAttribPointer(a.aVertexNormal, tagData._normalsBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
474
|
+
|
|
475
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._vertexBuffer);
|
|
476
|
+
gl.vertexAttribPointer(a.aVertexPosition, tagData._vertexBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
477
|
+
|
|
478
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
479
|
+
gl.bindTexture(gl.TEXTURE_2D, tagData._texture || r.handler.defaultTexture);
|
|
480
|
+
gl.uniform1i(u.uTexture, 0);
|
|
481
|
+
|
|
482
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._texCoordBuffer);
|
|
483
|
+
gl.vertexAttribPointer(a.aTexCoord, tagData._texCoordBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, tagData._indicesBuffer);
|
|
487
|
+
p.drawElementsInstanced(gl.TRIANGLES, tagData._indicesBuffer.numItems, gl.UNSIGNED_SHORT, 0, tagData.numInstances);
|
|
411
488
|
}
|
|
412
489
|
gl.disable(gl.CULL_FACE);
|
|
413
490
|
}
|
|
@@ -419,13 +496,8 @@ class GeoObjectHandler {
|
|
|
419
496
|
}
|
|
420
497
|
|
|
421
498
|
_pickingPASS() {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
p = sh._program,
|
|
425
|
-
u = p.uniforms,
|
|
426
|
-
a = p.attributes,
|
|
427
|
-
gl = r.handler.gl,
|
|
428
|
-
ec = this._entityCollection;
|
|
499
|
+
let r = this._planet.renderer, sh = r.handler.programs.geo_object_picking, p = sh._program, u = p.uniforms,
|
|
500
|
+
a = p.attributes, gl = r.handler.gl, ec = this._entityCollection;
|
|
429
501
|
|
|
430
502
|
sh.activate();
|
|
431
503
|
|
|
@@ -440,380 +512,139 @@ class GeoObjectHandler {
|
|
|
440
512
|
gl.uniformMatrix4fv(u.projectionMatrix, false, r.activeCamera.getProjectionMatrix());
|
|
441
513
|
gl.uniformMatrix4fv(u.viewMatrix, false, r.activeCamera.getViewMatrix());
|
|
442
514
|
|
|
443
|
-
for (
|
|
444
|
-
|
|
445
|
-
ti = tagData.index;
|
|
446
|
-
|
|
447
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer[ti]);
|
|
448
|
-
gl.vertexAttribPointer(
|
|
449
|
-
a.aVertexPosition,
|
|
450
|
-
this._vertexBuffer[ti].itemSize,
|
|
451
|
-
gl.FLOAT,
|
|
452
|
-
false,
|
|
453
|
-
0,
|
|
454
|
-
0
|
|
455
|
-
);
|
|
456
|
-
|
|
457
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this._directionBuffer[ti]);
|
|
458
|
-
gl.vertexAttribPointer(
|
|
459
|
-
a.aDirection,
|
|
460
|
-
this._directionBuffer[ti].itemSize,
|
|
461
|
-
gl.FLOAT,
|
|
462
|
-
false,
|
|
463
|
-
0,
|
|
464
|
-
0
|
|
465
|
-
);
|
|
466
|
-
|
|
467
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this._sizeBuffer[ti]);
|
|
468
|
-
gl.vertexAttribPointer(a.aScale, this._sizeBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
|
|
469
|
-
|
|
470
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this._pitchRollBuffer[ti]);
|
|
471
|
-
gl.vertexAttribPointer(
|
|
472
|
-
a.aPitchRoll,
|
|
473
|
-
this._pitchRollBuffer[ti].itemSize,
|
|
474
|
-
gl.FLOAT,
|
|
475
|
-
false,
|
|
476
|
-
0,
|
|
477
|
-
0
|
|
478
|
-
);
|
|
479
|
-
|
|
480
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this._pickingColorBuffer[ti]);
|
|
481
|
-
gl.vertexAttribPointer(
|
|
482
|
-
a.aPickingColor,
|
|
483
|
-
this._pickingColorBuffer[ti].itemSize,
|
|
484
|
-
gl.FLOAT,
|
|
485
|
-
false,
|
|
486
|
-
0,
|
|
487
|
-
0
|
|
488
|
-
);
|
|
489
|
-
|
|
490
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this._positionHighBuffer[ti]);
|
|
491
|
-
gl.vertexAttribPointer(
|
|
492
|
-
a.aPositionHigh,
|
|
493
|
-
this._positionHighBuffer[ti].itemSize,
|
|
494
|
-
gl.FLOAT,
|
|
495
|
-
false,
|
|
496
|
-
0,
|
|
497
|
-
0
|
|
498
|
-
);
|
|
499
|
-
|
|
500
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this._positionLowBuffer[ti]);
|
|
501
|
-
gl.vertexAttribPointer(
|
|
502
|
-
a.aPositionLow,
|
|
503
|
-
this._positionLowBuffer[ti].itemSize,
|
|
504
|
-
gl.FLOAT,
|
|
505
|
-
false,
|
|
506
|
-
0,
|
|
507
|
-
0
|
|
508
|
-
);
|
|
509
|
-
|
|
510
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this._vehicleVisibleBuffer[ti]);
|
|
511
|
-
gl.vertexAttribPointer(a.aDispose, this._vehicleVisibleBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
|
|
512
|
-
|
|
513
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indicesBuffer[ti]);
|
|
514
|
-
|
|
515
|
-
if (tagData.iCounts) {
|
|
516
|
-
p.drawElementsInstanced(
|
|
517
|
-
gl.TRIANGLES,
|
|
518
|
-
this._indicesBuffer[ti].numItems / tagData.iCounts,
|
|
519
|
-
gl.UNSIGNED_SHORT,
|
|
520
|
-
0,
|
|
521
|
-
tagData.iCounts
|
|
522
|
-
);
|
|
523
|
-
} else {
|
|
524
|
-
gl.drawElements(
|
|
525
|
-
gl.TRIANGLES,
|
|
526
|
-
this._indicesBuffer[ti].numItems,
|
|
527
|
-
gl.UNSIGNED_SHORT,
|
|
528
|
-
0
|
|
529
|
-
);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
gl.disable(gl.CULL_FACE);
|
|
533
|
-
}
|
|
515
|
+
for (let i = 0; i < this._instanceDataMapValues.length; i++) {
|
|
516
|
+
let tagData = this._instanceDataMapValues[i];
|
|
534
517
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
for (let gi = 0; gi < goArr.length; gi++) {
|
|
541
|
-
const go = goArr[gi],
|
|
542
|
-
ti = this.getTagIndexByObjectIndex(go._handlerIndex),
|
|
543
|
-
gIndices = go._indices;
|
|
544
|
-
|
|
545
|
-
for (let ii = 0; ii < gIndices.length; ii++) {
|
|
546
|
-
const gIndex = gIndices[ii];
|
|
547
|
-
|
|
548
|
-
const i = go._indicesCount * go._tagIndex + ii;
|
|
549
|
-
if (go._tagIndex > 0) {
|
|
550
|
-
allIndices[ti][i] = gIndex + maxIndicesByTags[ti];
|
|
551
|
-
if (allIndices[ti][i] > maxIndicesByTags[ti]) {
|
|
552
|
-
maxIndicesByTags[ti] = allIndices[ti][i] + 1;
|
|
553
|
-
}
|
|
554
|
-
} else {
|
|
555
|
-
allIndices[ti][i] = gIndex;
|
|
556
|
-
if (gIndex > maxIndicesByTags[ti]) {
|
|
557
|
-
maxIndicesByTags[ti] = gIndex + 1;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
_addIndices(g) {
|
|
565
|
-
let i = g._handlerIndex;
|
|
566
|
-
const allIndices = this._indicesArr,
|
|
567
|
-
gArr = this._geoObjects,
|
|
568
|
-
iLen = g._indices.length,
|
|
569
|
-
tagData = this._instancedTags.get(g.tag),
|
|
570
|
-
maxIndex = tagData.maxIndex,
|
|
571
|
-
ti = tagData.index;
|
|
572
|
-
|
|
573
|
-
allIndices[ti] = concatArrays(allIndices[ti], g._indices);
|
|
574
|
-
|
|
575
|
-
while (gArr[i]) {
|
|
576
|
-
const g = gArr[i];
|
|
518
|
+
//
|
|
519
|
+
// Instance individual data
|
|
520
|
+
//
|
|
521
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._directionBuffer);
|
|
522
|
+
gl.vertexAttribPointer(a.aDirection, tagData._directionBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
577
523
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
acc.push(cur + ((maxIndex + 1) * g._tagIndex));
|
|
581
|
-
return acc;
|
|
582
|
-
}, []));
|
|
583
|
-
}
|
|
584
|
-
i++;
|
|
524
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._sizeBuffer);
|
|
525
|
+
gl.vertexAttribPointer(a.aScale, tagData._sizeBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
585
526
|
|
|
586
|
-
|
|
527
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._pitchRollBuffer);
|
|
528
|
+
gl.vertexAttribPointer(a.aPitchRoll, tagData._pitchRollBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
587
529
|
|
|
588
|
-
|
|
530
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._pickingColorBuffer);
|
|
531
|
+
gl.vertexAttribPointer(a.aPickingColor, tagData._pickingColorBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
589
532
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
gArr = this._geoObjects,
|
|
593
|
-
iLen = geoObject._indices.length,
|
|
594
|
-
tagData = this._instancedTags.get(geoObject.tag),
|
|
595
|
-
maxIndex = tagData.maxIndex,
|
|
596
|
-
ti = tagData.index,
|
|
597
|
-
count = tagData.iCounts;
|
|
533
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._positionHighBuffer);
|
|
534
|
+
gl.vertexAttribPointer(a.aPositionHigh, tagData._positionHighBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
598
535
|
|
|
599
|
-
|
|
536
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._positionLowBuffer);
|
|
537
|
+
gl.vertexAttribPointer(a.aPositionLow, tagData._positionLowBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
600
538
|
|
|
601
|
-
|
|
539
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._visibleBuffer);
|
|
540
|
+
gl.vertexAttribPointer(a.aDispose, tagData._visibleBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
602
541
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
while (stopI > startI) {
|
|
609
|
-
this._indicesArr[ti][stopI - 1] = allIndices[ti][stopI - 1] - maxIndex - 1;
|
|
610
|
-
stopI--;
|
|
611
|
-
}
|
|
612
|
-
} else {
|
|
613
|
-
allIndices[ti] = geoObject._indices;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
i++;
|
|
542
|
+
//
|
|
543
|
+
// Instance common data(could be in VAO)
|
|
544
|
+
//
|
|
545
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, tagData._vertexBuffer);
|
|
546
|
+
gl.vertexAttribPointer(a.aVertexPosition, tagData._vertexBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
617
547
|
|
|
548
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, tagData._indicesBuffer);
|
|
549
|
+
p.drawElementsInstanced(gl.TRIANGLES, tagData._indicesBuffer.numItems, gl.UNSIGNED_SHORT, 0, tagData.numInstances);
|
|
618
550
|
}
|
|
619
|
-
|
|
551
|
+
gl.disable(gl.CULL_FACE);
|
|
620
552
|
}
|
|
621
553
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
let length = ob._verticesCount * itemSize;
|
|
627
|
-
|
|
628
|
-
if (ob.instanced) {
|
|
629
|
-
length = itemSize;
|
|
554
|
+
async _loadDataTagTexture(tagData) {
|
|
555
|
+
if (this._planet && tagData._textureSrc) {
|
|
556
|
+
const image = await loadImage(tagData._textureSrc);
|
|
557
|
+
tagData.createTexture(image);
|
|
630
558
|
}
|
|
631
|
-
|
|
632
|
-
setParametersToArray(this._directionArr[ti], ob._tagIndex, length, itemSize, direction.x, direction.y, direction.z);
|
|
633
|
-
this._changedBuffers[DIRECTION_BUFFER] = true;
|
|
634
559
|
}
|
|
635
560
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
setParametersToArray(this._vehicleVisibleArr[ti], ob._tagIndex, 1, 1, visibility ? 1 : 0);
|
|
641
|
-
|
|
642
|
-
this._changedBuffers[VISIBLE_BUFFER] = true;
|
|
561
|
+
setDirectionArr(tagData, tagDataIndex, direction) {
|
|
562
|
+
setParametersToArray(tagData._directionArr, tagDataIndex, 3, 3, direction.x, direction.y, direction.z);
|
|
563
|
+
tagData._changedBuffers[DIRECTION_BUFFER] = true;
|
|
564
|
+
this._updateTag(tagData);
|
|
643
565
|
}
|
|
644
566
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
let length = ob._verticesCount * itemSize;
|
|
650
|
-
|
|
651
|
-
if (ob.instanced) {
|
|
652
|
-
length = itemSize;
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
setParametersToArray(this._positionHighArr[ti], ob._tagIndex, length, itemSize, positionHigh.x, positionHigh.y, positionHigh.z);
|
|
656
|
-
|
|
657
|
-
// Low
|
|
658
|
-
setParametersToArray(this._positionLowArr[ti], ob._tagIndex, length, itemSize, positionLow.x, positionLow.y, positionLow.z);
|
|
659
|
-
|
|
660
|
-
this._changedBuffers[POSITION_BUFFER] = true;
|
|
567
|
+
setVisibility(tagData, tagDataIndex, visibility) {
|
|
568
|
+
setParametersToArray(tagData._visibleArr, tagDataIndex, 1, 1, visibility ? 1 : 0);
|
|
569
|
+
tagData._changedBuffers[VISIBLE_BUFFER] = true;
|
|
570
|
+
this._updateTag(tagData);
|
|
661
571
|
}
|
|
662
572
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
if (ob.instanced) {
|
|
670
|
-
length = itemSize;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
setParametersToArray(this._rgbaArr[ti], ob._tagIndex, length, itemSize, rgba.x, rgba.y, rgba.z, rgba.w);
|
|
674
|
-
|
|
675
|
-
this._changedBuffers[RGBA_BUFFER] = true;
|
|
573
|
+
setPositionArr(tagData, tagDataIndex, positionHigh, positionLow) {
|
|
574
|
+
setParametersToArray(tagData._positionHighArr, tagDataIndex, 3, 3, positionHigh.x, positionHigh.y, positionHigh.z);
|
|
575
|
+
setParametersToArray(tagData._positionLowArr, tagDataIndex, 3, 3, positionLow.x, positionLow.y, positionLow.z);
|
|
576
|
+
tagData._changedBuffers[POSITION_BUFFER] = true;
|
|
577
|
+
this._updateTag(tagData);
|
|
676
578
|
}
|
|
677
579
|
|
|
678
|
-
|
|
679
|
-
|
|
580
|
+
setRgbaArr(tagData, tagDataIndex, rgba) {
|
|
581
|
+
setParametersToArray(tagData._rgbaArr, tagDataIndex, 4, 4, rgba.x, rgba.y, rgba.z, rgba.w);
|
|
582
|
+
tagData._changedBuffers[RGBA_BUFFER] = true;
|
|
583
|
+
this._updateTag(tagData);
|
|
680
584
|
}
|
|
681
585
|
|
|
682
|
-
|
|
683
|
-
|
|
586
|
+
setPickingColorArr(tagData, tagDataIndex, color) {
|
|
587
|
+
setParametersToArray(tagData._pickingColorArr, tagDataIndex, 3, 3, color.x / 255, color.y / 255, color.z / 255);
|
|
588
|
+
tagData._changedBuffers[PICKINGCOLOR_BUFFER] = true;
|
|
589
|
+
this._updateTag(tagData);
|
|
684
590
|
}
|
|
685
591
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
y = color.y / 255,
|
|
692
|
-
z = color.z / 255;
|
|
693
|
-
|
|
694
|
-
let length = ob._verticesCount * itemSize;
|
|
592
|
+
// setTexCoordArr(tagData, tagDataIndex, tcoordArr) {
|
|
593
|
+
// setParametersToArray(tagData._texCoordArr, tagDataIndex, 2, 2, ...tcoordArr);
|
|
594
|
+
// tagData._changedBuffers[TEXCOORD_BUFFER] = true;
|
|
595
|
+
// this._updateTag(tagData);
|
|
596
|
+
// }
|
|
695
597
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
setParametersToArray(this._pickingColorArr[ti], ob._tagIndex, length, itemSize, x, y, z);
|
|
701
|
-
this._changedBuffers[PICKINGCOLOR_BUFFER] = true;
|
|
598
|
+
setPitchRollArr(tagData, tagDataIndex, pitch, roll) {
|
|
599
|
+
setParametersToArray(tagData._pitchRollArr, tagDataIndex, 2, 2, pitch, roll);
|
|
600
|
+
tagData._changedBuffers[PITCH_ROLL_BUFFER] = true;
|
|
601
|
+
this._updateTag(tagData);
|
|
702
602
|
}
|
|
703
603
|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
let length = ob._verticesCount * itemSize;
|
|
709
|
-
|
|
710
|
-
if (ob.instanced) {
|
|
711
|
-
length = itemSize;
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
setParametersToArray(this._pitchRollArr[ti], ob._tagIndex, length, itemSize, pitch, roll);
|
|
715
|
-
this._changedBuffers[PITCH_ROLL_BUFFER] = true;
|
|
604
|
+
setScaleArr(tagData, tagDataIndex, scale) {
|
|
605
|
+
setParametersToArray(tagData._sizeArr, tagDataIndex, 1, 1, scale);
|
|
606
|
+
tagData._changedBuffers[SIZE_BUFFER] = true;
|
|
607
|
+
this._updateTag(tagData);
|
|
716
608
|
}
|
|
717
609
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
let length = ob._verticesCount * itemSize;
|
|
723
|
-
|
|
724
|
-
if (ob.instanced) {
|
|
725
|
-
length = itemSize;
|
|
610
|
+
_updateTag(dataTag) {
|
|
611
|
+
if (dataTag.isFree) {
|
|
612
|
+
dataTag.isFree = false;
|
|
613
|
+
this._dataTagUpdateQueue.push(dataTag);
|
|
726
614
|
}
|
|
727
|
-
|
|
728
|
-
setParametersToArray(this._sizeArr[ti], ob._tagIndex, length, itemSize, scale);
|
|
729
|
-
this._changedBuffers[SIZE_BUFFER] = true;
|
|
730
615
|
}
|
|
731
616
|
|
|
732
|
-
|
|
733
|
-
let i = this.
|
|
734
|
-
|
|
735
|
-
this._changedBuffers[i] = true;
|
|
617
|
+
update() {
|
|
618
|
+
for (let i = 0, len = this._dataTagUpdateQueue.length; i < len; i++) {
|
|
619
|
+
this._dataTagUpdateQueue[i].update();
|
|
736
620
|
}
|
|
621
|
+
this._dataTagUpdateQueue = [];
|
|
737
622
|
}
|
|
738
623
|
|
|
739
|
-
|
|
624
|
+
_removeAll() {
|
|
740
625
|
let i = this._geoObjects.length;
|
|
741
626
|
while (i--) {
|
|
742
|
-
const
|
|
743
|
-
|
|
744
|
-
|
|
627
|
+
const gi = this._geoObjects[i];
|
|
628
|
+
|
|
629
|
+
gi._tagDataIndex = -1;
|
|
630
|
+
gi._tagData = undefined;
|
|
631
|
+
|
|
632
|
+
gi._handlerIndex = -1;
|
|
633
|
+
gi._handler = undefined;
|
|
745
634
|
}
|
|
746
635
|
this._geoObjects.length = 0;
|
|
747
636
|
this._geoObjects = [];
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
clear() {
|
|
751
|
-
this._sizeArr = null;
|
|
752
|
-
this._pitchRollArr = null;
|
|
753
|
-
this._vertexArr = null;
|
|
754
|
-
this._positionHighArr = null;
|
|
755
|
-
this._positionLowArr = null;
|
|
756
|
-
this._directionArr = null;
|
|
757
|
-
this._rgbaArr = null;
|
|
758
|
-
this._normalsArr = null;
|
|
759
|
-
this._indicesArr = null;
|
|
760
|
-
this._pickingColorArr = null;
|
|
761
|
-
this._vehicleVisibleArr = null;
|
|
762
637
|
|
|
763
|
-
this.
|
|
764
|
-
|
|
765
|
-
this._vertexArr = [];
|
|
766
|
-
this._positionHighArr = [];
|
|
767
|
-
this._positionLowArr = [];
|
|
768
|
-
this._rgbaArr = [];
|
|
769
|
-
this._directionArr = [];
|
|
770
|
-
this._normalsArr = [];
|
|
771
|
-
this._indicesArr = [];
|
|
772
|
-
this._pickingColorArr = [];
|
|
773
|
-
this._vehicleVisibleArr = [];
|
|
774
|
-
|
|
775
|
-
this._removeGeoObjects();
|
|
776
|
-
this._deleteBuffers();
|
|
777
|
-
this.refresh();
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
_deleteBuffers() {
|
|
781
|
-
if (this._renderer) {
|
|
782
|
-
const gl = this._renderer.handler.gl;
|
|
783
|
-
gl.deleteBuffer(this._sizeBuffer);
|
|
784
|
-
gl.deleteBuffer(this._pitchRollBuffer);
|
|
785
|
-
gl.deleteBuffer(this._vertexBuffer);
|
|
786
|
-
gl.deleteBuffer(this._positionHighBuffer);
|
|
787
|
-
gl.deleteBuffer(this._positionLowBuffer);
|
|
788
|
-
gl.deleteBuffer(this._rgbaBuffer);
|
|
789
|
-
gl.deleteBuffer(this._indicesBuffer);
|
|
790
|
-
gl.deleteBuffer(this._normalsBuffer);
|
|
791
|
-
gl.deleteBuffer(this._directionBuffer);
|
|
792
|
-
gl.deleteBuffer(this._pickingColorBuffer);
|
|
638
|
+
for (let i = 0; this._instanceDataMapValues.length; i++) {
|
|
639
|
+
this._instanceDataMapValues[i].clear();
|
|
793
640
|
}
|
|
794
641
|
|
|
795
|
-
this.
|
|
796
|
-
this.
|
|
797
|
-
this._vertexBuffer = null;
|
|
798
|
-
this._positionHighBuffer = null;
|
|
799
|
-
this._positionLowBuffer = null;
|
|
800
|
-
this._rgbaBuffer = null;
|
|
801
|
-
this._indicesBuffer = null;
|
|
802
|
-
this._normalsBuffer = null;
|
|
803
|
-
this._directionBuffer = null;
|
|
804
|
-
this._pickingColorBuffer = null;
|
|
642
|
+
this._instanceDataMap.clear();
|
|
643
|
+
this._instanceDataMapValues = [];
|
|
805
644
|
}
|
|
806
645
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
let i = this._changedBuffers.length;
|
|
810
|
-
while (i--) {
|
|
811
|
-
if (this._changedBuffers[i]) {
|
|
812
|
-
this._buffersUpdateCallbacks[i].call(this);
|
|
813
|
-
this._changedBuffers[i] = false;
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
}
|
|
646
|
+
clear() {
|
|
647
|
+
this._removeAll();
|
|
817
648
|
}
|
|
818
649
|
|
|
819
650
|
draw() {
|
|
@@ -823,26 +654,17 @@ class GeoObjectHandler {
|
|
|
823
654
|
}
|
|
824
655
|
}
|
|
825
656
|
|
|
826
|
-
_reindexGeoObjects(startIndex, tag) {
|
|
827
|
-
const b = this._geoObjects;
|
|
828
|
-
|
|
829
|
-
for (let i = startIndex; i < b.length; i++) {
|
|
830
|
-
const go = b[i];
|
|
831
|
-
|
|
832
|
-
b[i]._handlerIndex = i;
|
|
833
|
-
if (tag === go.tag) {
|
|
834
|
-
--b[i]._tagIndex;
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
|
|
839
657
|
add(geoObject) {
|
|
840
658
|
if (geoObject._handlerIndex === -1) {
|
|
659
|
+
|
|
841
660
|
geoObject._handler = this;
|
|
842
661
|
geoObject._handlerIndex = this._geoObjects.length;
|
|
662
|
+
|
|
843
663
|
this._geoObjects.push(geoObject);
|
|
844
664
|
this._addGeoObjectToArray(geoObject);
|
|
845
|
-
|
|
665
|
+
|
|
666
|
+
geoObject._tagData.refresh();
|
|
667
|
+
this._updateTag(geoObject._tagData);
|
|
846
668
|
}
|
|
847
669
|
}
|
|
848
670
|
|
|
@@ -852,51 +674,60 @@ class GeoObjectHandler {
|
|
|
852
674
|
}
|
|
853
675
|
}
|
|
854
676
|
|
|
677
|
+
_clearDataTagQueue() {
|
|
678
|
+
this._dataTagUpdateQueue = [];
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
|
|
855
682
|
_removeGeoObject(geoObject) {
|
|
856
|
-
const gi = geoObject._handlerIndex,
|
|
857
|
-
tag = geoObject.tag,
|
|
858
|
-
ti = this.getTagIndexByObjectIndex(gi),
|
|
859
|
-
prevState = this._instancedTags.get(tag),
|
|
860
|
-
iCount = prevState.iCounts - 1;
|
|
861
|
-
|
|
862
|
-
this._instancedTags.set(tag, {
|
|
863
|
-
...prevState,
|
|
864
|
-
iCounts: iCount
|
|
865
|
-
});
|
|
866
|
-
|
|
867
|
-
this._geoObjects.splice(gi, 1);
|
|
868
|
-
|
|
869
|
-
let i = geoObject._tagIndex * 4;
|
|
870
|
-
this._rgbaArr[ti] = spliceArray(this._rgbaArr[ti], i, 4);
|
|
871
|
-
|
|
872
|
-
i = geoObject._tagIndex * 3;
|
|
873
|
-
if (prevState.iCounts <= 1) {
|
|
874
|
-
this._vertexArr[ti] = spliceArray(this._vertexArr[ti], 0, geoObject._verticesCount * 3);
|
|
875
|
-
this._normalsArr[ti] = spliceArray(
|
|
876
|
-
this._normalsArr[ti],
|
|
877
|
-
0,
|
|
878
|
-
geoObject._verticesCount * 3
|
|
879
|
-
);
|
|
880
|
-
}
|
|
881
|
-
this._positionHighArr[ti] = spliceArray(this._positionHighArr[ti], i, 3);
|
|
882
|
-
this._positionLowArr[ti] = spliceArray(this._positionLowArr[ti], i, 3);
|
|
883
|
-
this._directionArr[ti] = spliceArray(this._directionArr[ti], i, 3);
|
|
884
|
-
this._pickingColorArr[ti] = spliceArray(this._pickingColorArr[ti], i, 3);
|
|
885
683
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
i = geoObject._tagIndex;
|
|
889
|
-
this._sizeArr[ti] = spliceArray(this._sizeArr[ti], i, 1);
|
|
890
|
-
this._vehicleVisibleArr[ti] = spliceArray(this._vehicleVisibleArr[ti], i, 1);
|
|
684
|
+
let tagData = geoObject._tagData;
|
|
685
|
+
let tag = geoObject.tag;
|
|
891
686
|
|
|
892
|
-
|
|
687
|
+
tagData.numInstances--;
|
|
893
688
|
|
|
894
|
-
|
|
689
|
+
let isEmpty = false;
|
|
690
|
+
// dataTag becomes empty, remove it from the rendering
|
|
691
|
+
if (tagData.numInstances === 0) {
|
|
692
|
+
tagData.clear();
|
|
693
|
+
this._instanceDataMap.delete(tag);
|
|
694
|
+
this._instanceDataMapValues = [];
|
|
695
|
+
this._clearDataTagQueue();
|
|
696
|
+
isEmpty = true;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
this._geoObjects.splice(geoObject._handlerIndex, 1);
|
|
700
|
+
for (let i = geoObject._handlerIndex, len = this._geoObjects.length; i < len; i++) {
|
|
701
|
+
let gi = this._geoObjects[i];
|
|
702
|
+
gi._handlerIndex = gi._handlerIndex - 1;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
let tdi = geoObject._tagDataIndex;
|
|
706
|
+
tagData.geoObjects.splice(tdi, 1);
|
|
707
|
+
for (let i = geoObject._tagDataIndex, len = tagData.geoObjects.length; i < len; i++) {
|
|
708
|
+
let gi = tagData.geoObjects[i];
|
|
709
|
+
gi._tagDataIndex = gi._tagDataIndex - 1;
|
|
710
|
+
}
|
|
895
711
|
|
|
896
|
-
|
|
712
|
+
tagData._rgbaArr = spliceArray(tagData._rgbaArr, tdi * 4, 4);
|
|
713
|
+
tagData._positionHighArr = spliceArray(tagData._positionHighArr, tdi * 3, 3);
|
|
714
|
+
tagData._positionLowArr = spliceArray(tagData._positionLowArr, tdi * 3, 3);
|
|
715
|
+
tagData._directionArr = spliceArray(tagData._directionArr, tdi * 3, 3);
|
|
716
|
+
tagData._pickingColorArr = spliceArray(tagData._pickingColorArr, tdi * 3, 3);
|
|
717
|
+
tagData._pitchRollArr = spliceArray(tagData._pitchRollArr, tdi * 2, 2);
|
|
718
|
+
tagData._sizeArr = spliceArray(tagData._sizeArr, tdi, 1);
|
|
719
|
+
tagData._visibleArr = spliceArray(tagData._visibleArr, tdi, 1);
|
|
897
720
|
|
|
898
721
|
geoObject._handlerIndex = -1;
|
|
899
|
-
geoObject._handler =
|
|
722
|
+
geoObject._handler = undefined;
|
|
723
|
+
|
|
724
|
+
geoObject._tagDataIndex = -1;
|
|
725
|
+
geoObject._tagData = undefined;
|
|
726
|
+
|
|
727
|
+
if (!isEmpty) {
|
|
728
|
+
tagData.refresh();
|
|
729
|
+
this._updateTag(tagData);
|
|
730
|
+
}
|
|
900
731
|
}
|
|
901
732
|
}
|
|
902
733
|
|