@openglobus/og 0.13.12 → 0.14.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 +1 -4
- package/css/og.css +1 -1
- 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 +2 -2
- package/src/og/Globe.js +14 -4
- package/src/og/camera/Camera.js +7 -7
- package/src/og/camera/PlanetCamera.js +1 -1
- package/src/og/control/LayerSwitcher.js +48 -31
- package/src/og/control/MouseNavigation.js +2 -2
- package/src/og/control/ScaleControl.js +30 -10
- package/src/og/control/SimpleSkyBackground.js +184 -0
- package/src/og/control/Sun.js +3 -2
- package/src/og/ellipsoid/Ellipsoid.js +119 -92
- package/src/og/ellipsoid/wgs84.js +13 -13
- package/src/og/entity/Entity.js +3 -3
- 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 +106 -95
- package/src/og/layer/GeoVideo.js +1 -0
- package/src/og/layer/Layer.js +62 -3
- package/src/og/layer/XYZ.js +4 -3
- 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/EarthQuadTreeStrategy.js +29 -0
- package/src/og/quadTree/MarsQuadTreeStrategy.js +27 -0
- package/src/og/quadTree/Node.js +55 -218
- package/src/og/quadTree/QuadTreeStrategy.js +93 -0
- package/src/og/quadTree/Wgs84QuadTreeStrategy.js +26 -0
- package/src/og/renderer/Renderer.js +13 -12
- package/src/og/renderer/RendererEvents.js +1065 -1065
- package/src/og/scene/Planet.js +84 -273
- package/src/og/segment/Segment.js +18 -25
- package/src/og/segment/SegmentLonLat.js +34 -31
- package/src/og/segment/SegmentLonLatWgs84.js +41 -0
- package/src/og/shaders/ray.js +13 -6
- package/src/og/shaders/toneMapping.js +5 -5
- package/src/og/terrain/GlobusTerrain.js +3 -2
- package/src/og/terrain/MapboxTerrain.js +231 -52
- package/src/og/utils/quadTreeType.js +11 -0
- package/src/og/utils/shared.js +942 -942
- package/src/og/webgl/Handler.js +22 -9
- package/types/Globe.d.ts +7 -0
- package/types/camera/Camera.d.ts +3 -3
- package/types/camera/PlanetCamera.d.ts +1 -1
- package/types/control/LayerSwitcher.d.ts +1 -1
- package/types/control/ScaleControl.d.ts +2 -1
- package/types/control/SimpleSkyBackground.d.ts +11 -0
- package/types/control/Sun.d.ts +2 -1
- package/types/ellipsoid/Ellipsoid.d.ts +3 -2
- package/types/entity/Ray.d.ts +0 -3
- package/types/entity/RayHandler.d.ts +0 -4
- package/types/index.d.ts +6 -1
- package/types/layer/Layer.d.ts +8 -0
- 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/EarthQuadTreeStrategy.d.ts +3 -0
- package/types/quadTree/MarsQuadTreeStrategy.d.ts +3 -0
- package/types/quadTree/Node.d.ts +0 -1
- package/types/quadTree/QuadTreeStrategy.d.ts +21 -0
- package/types/quadTree/Wgs84QuadTreeStrategy.d.ts +3 -0
- package/types/renderer/Renderer.d.ts +1 -1
- package/types/scene/Planet.d.ts +6 -24
- package/types/segment/Segment.d.ts +4 -4
- package/types/segment/SegmentLonLat.d.ts +6 -2
- package/types/segment/SegmentLonLatWgs84.d.ts +4 -0
- package/types/terrain/MapboxTerrain.d.ts +2 -1
- package/types/utils/quadTreeType.d.ts +8 -0
- package/types/webgl/Handler.d.ts +4 -1
|
@@ -1,1337 +1,1341 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/entity/GeometryHandler
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import * as mercator from "../mercator.js";
|
|
8
|
-
import * as quadTree from "../quadTree/quadTree.js";
|
|
9
|
-
import { earcut, flatten } from "../utils/earcut.js";
|
|
10
|
-
import { GeometryType } from "./Geometry.js";
|
|
11
|
-
import { Vec2 } from "../math/Vec2.js";
|
|
12
|
-
import { doubleToTwoFloatsV2 } from "../math/coder.js";
|
|
13
|
-
|
|
14
|
-
const POLYVERTICES_BUFFER = 0;
|
|
15
|
-
const POLYINDEXES_BUFFER = 1;
|
|
16
|
-
const POLYCOLORS_BUFFER = 2;
|
|
17
|
-
const LINEVERTICES_BUFFER = 3;
|
|
18
|
-
const LINEINDEXES_BUFFER = 4;
|
|
19
|
-
const LINEORDERS_BUFFER = 5;
|
|
20
|
-
const LINECOLORS_BUFFER = 6;
|
|
21
|
-
const LINETHICKNESS_BUFFER = 7;
|
|
22
|
-
const LINESTROKES_BUFFER = 8;
|
|
23
|
-
const LINESTROKECOLORS_BUFFER = 9;
|
|
24
|
-
const POLYPICKINGCOLORS_BUFFER = 10;
|
|
25
|
-
const LINEPICKINGCOLORS_BUFFER = 11;
|
|
26
|
-
|
|
27
|
-
function doubleToTwoFloats(v, high, low) {
|
|
28
|
-
let x = v[0],
|
|
29
|
-
y = v[1];
|
|
30
|
-
|
|
31
|
-
if (x >= 0.0) {
|
|
32
|
-
let doubleHigh = Math.floor(x / 65536.0) * 65536.0;
|
|
33
|
-
high.x = Math.fround(doubleHigh);
|
|
34
|
-
low.x = Math.fround(x - doubleHigh);
|
|
35
|
-
} else {
|
|
36
|
-
let doubleHigh = Math.floor(-x / 65536.0) * 65536.0;
|
|
37
|
-
high.x = Math.fround(-doubleHigh);
|
|
38
|
-
low.x = Math.fround(x + doubleHigh);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (y >= 0.0) {
|
|
42
|
-
let doubleHigh = Math.floor(y / 65536.0) * 65536.0;
|
|
43
|
-
high.y = Math.fround(doubleHigh);
|
|
44
|
-
low.y = Math.fround(y - doubleHigh);
|
|
45
|
-
} else {
|
|
46
|
-
let doubleHigh = Math.floor(-y / 65536.0) * 65536.0;
|
|
47
|
-
high.y = Math.fround(-doubleHigh);
|
|
48
|
-
low.y = Math.fround(y + doubleHigh);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
let tempHigh = new Vec2(),
|
|
53
|
-
tempLow = new Vec2(),
|
|
54
|
-
tempHighLow = new Vec2();
|
|
55
|
-
|
|
56
|
-
class GeometryHandler {
|
|
57
|
-
constructor(layer) {
|
|
58
|
-
this.__staticId = GeometryHandler._staticCounter++;
|
|
59
|
-
|
|
60
|
-
this._layer = layer;
|
|
61
|
-
|
|
62
|
-
this._handler = null;
|
|
63
|
-
|
|
64
|
-
this._geometries = [];
|
|
65
|
-
|
|
66
|
-
this._updatedGeometryArr = [];
|
|
67
|
-
this._updatedGeometry = {};
|
|
68
|
-
|
|
69
|
-
this._removeGeometryExtentArr = [];
|
|
70
|
-
this._removeGeometryExtents = {};
|
|
71
|
-
|
|
72
|
-
// Polygon arrays
|
|
73
|
-
this._polyVerticesHighMerc = [];
|
|
74
|
-
this._polyVerticesLowMerc = [];
|
|
75
|
-
this._polyColors = [];
|
|
76
|
-
this._polyPickingColors = [];
|
|
77
|
-
this._polyIndexes = [];
|
|
78
|
-
|
|
79
|
-
// Line arrays
|
|
80
|
-
this._lineVerticesHighMerc = [];
|
|
81
|
-
this._lineVerticesLowMerc = [];
|
|
82
|
-
this._lineOrders = [];
|
|
83
|
-
this._lineIndexes = [];
|
|
84
|
-
this._lineColors = [];
|
|
85
|
-
this._linePickingColors = [];
|
|
86
|
-
this._lineThickness = [];
|
|
87
|
-
this._lineStrokes = [];
|
|
88
|
-
this._lineStrokeColors = [];
|
|
89
|
-
|
|
90
|
-
// Buffers
|
|
91
|
-
this._polyVerticesHighBufferMerc = null;
|
|
92
|
-
this._polyVerticesLowBufferMerc = null;
|
|
93
|
-
this._polyColorsBuffer = null;
|
|
94
|
-
this._polyPickingColorsBuffer = null;
|
|
95
|
-
this._polyIndexesBuffer = null;
|
|
96
|
-
|
|
97
|
-
this._lineVerticesHighBufferMerc = null;
|
|
98
|
-
this._lineVerticesLowBufferMerc = null;
|
|
99
|
-
this._lineColorsBuffer = null;
|
|
100
|
-
this._linePickingColorsBuffer = null;
|
|
101
|
-
this._lineThicknessBuffer = null;
|
|
102
|
-
this._lineStrokesBuffer = null;
|
|
103
|
-
this._lineStrokeColorsBuffer = null;
|
|
104
|
-
this._lineOrdersBuffer = null;
|
|
105
|
-
this._lineIndexesBuffer = null;
|
|
106
|
-
|
|
107
|
-
this._buffersUpdateCallbacks = [];
|
|
108
|
-
this._buffersUpdateCallbacks[POLYVERTICES_BUFFER] = this.createPolyVerticesBuffer;
|
|
109
|
-
this._buffersUpdateCallbacks[POLYINDEXES_BUFFER] = this.createPolyIndexesBuffer;
|
|
110
|
-
this._buffersUpdateCallbacks[POLYCOLORS_BUFFER] = this.createPolyColorsBuffer;
|
|
111
|
-
this._buffersUpdateCallbacks[LINEVERTICES_BUFFER] = this.createLineVerticesBuffer;
|
|
112
|
-
this._buffersUpdateCallbacks[LINEINDEXES_BUFFER] = this.createLineIndexesBuffer;
|
|
113
|
-
this._buffersUpdateCallbacks[LINEORDERS_BUFFER] = this.createLineOrdersBuffer;
|
|
114
|
-
this._buffersUpdateCallbacks[LINECOLORS_BUFFER] = this.createLineColorsBuffer;
|
|
115
|
-
this._buffersUpdateCallbacks[LINETHICKNESS_BUFFER] = this.createLineThicknessBuffer;
|
|
116
|
-
this._buffersUpdateCallbacks[LINESTROKES_BUFFER] = this.createLineStrokesBuffer;
|
|
117
|
-
this._buffersUpdateCallbacks[LINESTROKECOLORS_BUFFER] = this.createLineStrokeColorsBuffer;
|
|
118
|
-
this._buffersUpdateCallbacks[POLYPICKINGCOLORS_BUFFER] = this.createPolyPickingColorsBuffer;
|
|
119
|
-
this._buffersUpdateCallbacks[LINEPICKINGCOLORS_BUFFER] = this.createLinePickingColorsBuffer;
|
|
120
|
-
|
|
121
|
-
this._changedBuffers = new Array(this._buffersUpdateCallbacks.length);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
static get _staticCounter() {
|
|
125
|
-
if (!this._counter && this._counter !== 0) {
|
|
126
|
-
this._counter = 0;
|
|
127
|
-
}
|
|
128
|
-
return this._counter;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
static set _staticCounter(n) {
|
|
132
|
-
this._counter = n;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
static appendLineData(
|
|
136
|
-
pathArr,
|
|
137
|
-
isClosed,
|
|
138
|
-
color,
|
|
139
|
-
pickingColor,
|
|
140
|
-
thickness,
|
|
141
|
-
strokeColor,
|
|
142
|
-
strokeSize,
|
|
143
|
-
outVerticesHigh,
|
|
144
|
-
outVerticesLow,
|
|
145
|
-
outOrders,
|
|
146
|
-
outIndexes,
|
|
147
|
-
outColors,
|
|
148
|
-
outPickingColors,
|
|
149
|
-
outThickness,
|
|
150
|
-
outStrokeColors,
|
|
151
|
-
outStrokes,
|
|
152
|
-
outVerticesHigh2,
|
|
153
|
-
outVerticesLow2
|
|
154
|
-
) {
|
|
155
|
-
var index = 0;
|
|
156
|
-
|
|
157
|
-
if (outIndexes.length > 0) {
|
|
158
|
-
index = outIndexes[outIndexes.length - 5] + 9;
|
|
159
|
-
outIndexes.push(index, index);
|
|
160
|
-
} else {
|
|
161
|
-
outIndexes.push(0, 0);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
var t = thickness,
|
|
165
|
-
c = [color.x, color.y, color.z, color.w],
|
|
166
|
-
s = strokeSize,
|
|
167
|
-
sc = [strokeColor.x, strokeColor.y, strokeColor.z, strokeColor.w],
|
|
168
|
-
p = [pickingColor.x, pickingColor.y, pickingColor.z, 1.0];
|
|
169
|
-
|
|
170
|
-
for (var j = 0; j < pathArr.length; j++) {
|
|
171
|
-
var path = pathArr[j];
|
|
172
|
-
|
|
173
|
-
if (path.length === 0) {
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
var startIndex = index;
|
|
178
|
-
var last;
|
|
179
|
-
if (isClosed) {
|
|
180
|
-
last = path[path.length - 1];
|
|
181
|
-
} else {
|
|
182
|
-
let p0 = path[0],
|
|
183
|
-
p1 = path[1];
|
|
184
|
-
|
|
185
|
-
if (!p1) {
|
|
186
|
-
p1 = p0;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
last = [p0[0] + p0[0] - p1[0], p0[1] + p0[1] - p1[1]];
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
doubleToTwoFloats(last, tempHigh, tempLow);
|
|
193
|
-
|
|
194
|
-
outVerticesHigh.push(
|
|
195
|
-
tempHigh.x,
|
|
196
|
-
tempHigh.y,
|
|
197
|
-
tempHigh.x,
|
|
198
|
-
tempHigh.y,
|
|
199
|
-
tempHigh.x,
|
|
200
|
-
tempHigh.y,
|
|
201
|
-
tempHigh.x,
|
|
202
|
-
tempHigh.y
|
|
203
|
-
);
|
|
204
|
-
outVerticesLow.push(
|
|
205
|
-
tempLow.x,
|
|
206
|
-
tempLow.y,
|
|
207
|
-
tempLow.x,
|
|
208
|
-
tempLow.y,
|
|
209
|
-
tempLow.x,
|
|
210
|
-
tempLow.y,
|
|
211
|
-
tempLow.x,
|
|
212
|
-
tempLow.y
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
outVerticesHigh2.push(
|
|
216
|
-
tempHigh.x,
|
|
217
|
-
tempHigh.y,
|
|
218
|
-
tempHigh.x,
|
|
219
|
-
tempHigh.y,
|
|
220
|
-
tempHigh.x,
|
|
221
|
-
tempHigh.y,
|
|
222
|
-
tempHigh.x,
|
|
223
|
-
tempHigh.y
|
|
224
|
-
);
|
|
225
|
-
outVerticesLow2.push(
|
|
226
|
-
tempLow.x,
|
|
227
|
-
tempLow.y,
|
|
228
|
-
tempLow.x,
|
|
229
|
-
tempLow.y,
|
|
230
|
-
tempLow.x,
|
|
231
|
-
tempLow.y,
|
|
232
|
-
tempLow.x,
|
|
233
|
-
tempLow.y
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
outOrders.push(1, -1, 2, -2);
|
|
237
|
-
|
|
238
|
-
outThickness.push(t, t, t, t);
|
|
239
|
-
outStrokes.push(s, s, s, s);
|
|
240
|
-
outColors.push(
|
|
241
|
-
c[0],
|
|
242
|
-
c[1],
|
|
243
|
-
c[2],
|
|
244
|
-
c[3],
|
|
245
|
-
c[0],
|
|
246
|
-
c[1],
|
|
247
|
-
c[2],
|
|
248
|
-
c[3],
|
|
249
|
-
c[0],
|
|
250
|
-
c[1],
|
|
251
|
-
c[2],
|
|
252
|
-
c[3],
|
|
253
|
-
c[0],
|
|
254
|
-
c[1],
|
|
255
|
-
c[2],
|
|
256
|
-
c[3]
|
|
257
|
-
);
|
|
258
|
-
outStrokeColors.push(
|
|
259
|
-
sc[0],
|
|
260
|
-
sc[1],
|
|
261
|
-
sc[2],
|
|
262
|
-
sc[3],
|
|
263
|
-
sc[0],
|
|
264
|
-
sc[1],
|
|
265
|
-
sc[2],
|
|
266
|
-
sc[3],
|
|
267
|
-
sc[0],
|
|
268
|
-
sc[1],
|
|
269
|
-
sc[2],
|
|
270
|
-
sc[3],
|
|
271
|
-
sc[0],
|
|
272
|
-
sc[1],
|
|
273
|
-
sc[2],
|
|
274
|
-
sc[3]
|
|
275
|
-
);
|
|
276
|
-
outPickingColors.push(
|
|
277
|
-
p[0],
|
|
278
|
-
p[1],
|
|
279
|
-
p[2],
|
|
280
|
-
p[3],
|
|
281
|
-
p[0],
|
|
282
|
-
p[1],
|
|
283
|
-
p[2],
|
|
284
|
-
p[3],
|
|
285
|
-
p[0],
|
|
286
|
-
p[1],
|
|
287
|
-
p[2],
|
|
288
|
-
p[3],
|
|
289
|
-
p[0],
|
|
290
|
-
p[1],
|
|
291
|
-
p[2],
|
|
292
|
-
p[3]
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
for (var i = 0; i < path.length; i++) {
|
|
296
|
-
var cur = path[i];
|
|
297
|
-
|
|
298
|
-
doubleToTwoFloats(cur, tempHigh, tempLow);
|
|
299
|
-
|
|
300
|
-
outVerticesHigh.push(
|
|
301
|
-
tempHigh.x,
|
|
302
|
-
tempHigh.y,
|
|
303
|
-
tempHigh.x,
|
|
304
|
-
tempHigh.y,
|
|
305
|
-
tempHigh.x,
|
|
306
|
-
tempHigh.y,
|
|
307
|
-
tempHigh.x,
|
|
308
|
-
tempHigh.y
|
|
309
|
-
);
|
|
310
|
-
outVerticesLow.push(
|
|
311
|
-
tempLow.x,
|
|
312
|
-
tempLow.y,
|
|
313
|
-
tempLow.x,
|
|
314
|
-
tempLow.y,
|
|
315
|
-
tempLow.x,
|
|
316
|
-
tempLow.y,
|
|
317
|
-
tempLow.x,
|
|
318
|
-
tempLow.y
|
|
319
|
-
);
|
|
320
|
-
|
|
321
|
-
outVerticesHigh2.push(
|
|
322
|
-
tempHigh.x,
|
|
323
|
-
tempHigh.y,
|
|
324
|
-
tempHigh.x,
|
|
325
|
-
tempHigh.y,
|
|
326
|
-
tempHigh.x,
|
|
327
|
-
tempHigh.y,
|
|
328
|
-
tempHigh.x,
|
|
329
|
-
tempHigh.y
|
|
330
|
-
);
|
|
331
|
-
outVerticesLow2.push(
|
|
332
|
-
tempLow.x,
|
|
333
|
-
tempLow.y,
|
|
334
|
-
tempLow.x,
|
|
335
|
-
tempLow.y,
|
|
336
|
-
tempLow.x,
|
|
337
|
-
tempLow.y,
|
|
338
|
-
tempLow.x,
|
|
339
|
-
tempLow.y
|
|
340
|
-
);
|
|
341
|
-
|
|
342
|
-
outOrders.push(1, -1, 2, -2);
|
|
343
|
-
outThickness.push(t, t, t, t);
|
|
344
|
-
outStrokes.push(s, s, s, s);
|
|
345
|
-
outColors.push(
|
|
346
|
-
c[0],
|
|
347
|
-
c[1],
|
|
348
|
-
c[2],
|
|
349
|
-
c[3],
|
|
350
|
-
c[0],
|
|
351
|
-
c[1],
|
|
352
|
-
c[2],
|
|
353
|
-
c[3],
|
|
354
|
-
c[0],
|
|
355
|
-
c[1],
|
|
356
|
-
c[2],
|
|
357
|
-
c[3],
|
|
358
|
-
c[0],
|
|
359
|
-
c[1],
|
|
360
|
-
c[2],
|
|
361
|
-
c[3]
|
|
362
|
-
);
|
|
363
|
-
outStrokeColors.push(
|
|
364
|
-
sc[0],
|
|
365
|
-
sc[1],
|
|
366
|
-
sc[2],
|
|
367
|
-
sc[3],
|
|
368
|
-
sc[0],
|
|
369
|
-
sc[1],
|
|
370
|
-
sc[2],
|
|
371
|
-
sc[3],
|
|
372
|
-
sc[0],
|
|
373
|
-
sc[1],
|
|
374
|
-
sc[2],
|
|
375
|
-
sc[3],
|
|
376
|
-
sc[0],
|
|
377
|
-
sc[1],
|
|
378
|
-
sc[2],
|
|
379
|
-
sc[3]
|
|
380
|
-
);
|
|
381
|
-
outPickingColors.push(
|
|
382
|
-
p[0],
|
|
383
|
-
p[1],
|
|
384
|
-
p[2],
|
|
385
|
-
p[3],
|
|
386
|
-
p[0],
|
|
387
|
-
p[1],
|
|
388
|
-
p[2],
|
|
389
|
-
p[3],
|
|
390
|
-
p[0],
|
|
391
|
-
p[1],
|
|
392
|
-
p[2],
|
|
393
|
-
p[3],
|
|
394
|
-
p[0],
|
|
395
|
-
p[1],
|
|
396
|
-
p[2],
|
|
397
|
-
p[3]
|
|
398
|
-
);
|
|
399
|
-
outIndexes.push(index++, index++, index++, index++);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
var first;
|
|
403
|
-
if (isClosed) {
|
|
404
|
-
first = path[0];
|
|
405
|
-
outIndexes.push(startIndex, startIndex + 1, startIndex + 1, startIndex + 1);
|
|
406
|
-
} else {
|
|
407
|
-
let p0 = path[path.length - 1],
|
|
408
|
-
p1 = path[path.length - 2];
|
|
409
|
-
|
|
410
|
-
if (!p1) {
|
|
411
|
-
p1 = p0;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
first = [p0[0] + p0[0] - p1[0], p0[1] + p0[1] - p1[1]];
|
|
415
|
-
outIndexes.push(index - 1, index - 1, index - 1, index - 1);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
doubleToTwoFloats(first, tempHigh, tempLow);
|
|
419
|
-
|
|
420
|
-
outVerticesHigh.push(
|
|
421
|
-
tempHigh.x,
|
|
422
|
-
tempHigh.y,
|
|
423
|
-
tempHigh.x,
|
|
424
|
-
tempHigh.y,
|
|
425
|
-
tempHigh.x,
|
|
426
|
-
tempHigh.y,
|
|
427
|
-
tempHigh.x,
|
|
428
|
-
tempHigh.y
|
|
429
|
-
);
|
|
430
|
-
outVerticesLow.push(
|
|
431
|
-
tempLow.x,
|
|
432
|
-
tempLow.y,
|
|
433
|
-
tempLow.x,
|
|
434
|
-
tempLow.y,
|
|
435
|
-
tempLow.x,
|
|
436
|
-
tempLow.y,
|
|
437
|
-
tempLow.x,
|
|
438
|
-
tempLow.y
|
|
439
|
-
);
|
|
440
|
-
|
|
441
|
-
outVerticesHigh2.push(
|
|
442
|
-
tempHigh.x,
|
|
443
|
-
tempHigh.y,
|
|
444
|
-
tempHigh.x,
|
|
445
|
-
tempHigh.y,
|
|
446
|
-
tempHigh.x,
|
|
447
|
-
tempHigh.y,
|
|
448
|
-
tempHigh.x,
|
|
449
|
-
tempHigh.y
|
|
450
|
-
);
|
|
451
|
-
outVerticesLow2.push(
|
|
452
|
-
tempLow.x,
|
|
453
|
-
tempLow.y,
|
|
454
|
-
tempLow.x,
|
|
455
|
-
tempLow.y,
|
|
456
|
-
tempLow.x,
|
|
457
|
-
tempLow.y,
|
|
458
|
-
tempLow.x,
|
|
459
|
-
tempLow.y
|
|
460
|
-
);
|
|
461
|
-
|
|
462
|
-
outOrders.push(1, -1, 2, -2);
|
|
463
|
-
outThickness.push(t, t, t, t);
|
|
464
|
-
outStrokes.push(s, s, s, s);
|
|
465
|
-
outColors.push(
|
|
466
|
-
c[0],
|
|
467
|
-
c[1],
|
|
468
|
-
c[2],
|
|
469
|
-
c[3],
|
|
470
|
-
c[0],
|
|
471
|
-
c[1],
|
|
472
|
-
c[2],
|
|
473
|
-
c[3],
|
|
474
|
-
c[0],
|
|
475
|
-
c[1],
|
|
476
|
-
c[2],
|
|
477
|
-
c[3],
|
|
478
|
-
c[0],
|
|
479
|
-
c[1],
|
|
480
|
-
c[2],
|
|
481
|
-
c[3]
|
|
482
|
-
);
|
|
483
|
-
outStrokeColors.push(
|
|
484
|
-
sc[0],
|
|
485
|
-
sc[1],
|
|
486
|
-
sc[2],
|
|
487
|
-
sc[3],
|
|
488
|
-
sc[0],
|
|
489
|
-
sc[1],
|
|
490
|
-
sc[2],
|
|
491
|
-
sc[3],
|
|
492
|
-
sc[0],
|
|
493
|
-
sc[1],
|
|
494
|
-
sc[2],
|
|
495
|
-
sc[3],
|
|
496
|
-
sc[0],
|
|
497
|
-
sc[1],
|
|
498
|
-
sc[2],
|
|
499
|
-
sc[3]
|
|
500
|
-
);
|
|
501
|
-
outPickingColors.push(
|
|
502
|
-
p[0],
|
|
503
|
-
p[1],
|
|
504
|
-
p[2],
|
|
505
|
-
p[3],
|
|
506
|
-
p[0],
|
|
507
|
-
p[1],
|
|
508
|
-
p[2],
|
|
509
|
-
p[3],
|
|
510
|
-
p[0],
|
|
511
|
-
p[1],
|
|
512
|
-
p[2],
|
|
513
|
-
p[3],
|
|
514
|
-
p[0],
|
|
515
|
-
p[1],
|
|
516
|
-
p[2],
|
|
517
|
-
p[3]
|
|
518
|
-
);
|
|
519
|
-
|
|
520
|
-
if (j < pathArr.length - 1) {
|
|
521
|
-
index += 8;
|
|
522
|
-
outIndexes.push(index, index);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
assignHandler(handler) {
|
|
528
|
-
this._handler = handler;
|
|
529
|
-
this.refresh();
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* @public
|
|
534
|
-
* @param {Geometry} geometry - Geometry object.
|
|
535
|
-
*/
|
|
536
|
-
add(geometry) {
|
|
537
|
-
//
|
|
538
|
-
// Triangulates polygon and sets geometry data.
|
|
539
|
-
if (geometry._handlerIndex === -1) {
|
|
540
|
-
geometry._handler = this;
|
|
541
|
-
geometry._handlerIndex = this._geometries.length;
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
geometry.
|
|
548
|
-
geometry.
|
|
549
|
-
geometry.
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
ci
|
|
556
|
-
for (
|
|
557
|
-
ci[j]
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
for (
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
this.
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
this.
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
);
|
|
865
|
-
this.
|
|
866
|
-
geometry._polyVerticesHandlerIndex,
|
|
867
|
-
geometry._polyVerticesLength
|
|
868
|
-
);
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
geometry.
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
this.
|
|
875
|
-
geometry._polyVerticesHandlerIndex * 2,
|
|
876
|
-
geometry._polyVerticesLength * 2
|
|
877
|
-
);
|
|
878
|
-
this.
|
|
879
|
-
geometry.
|
|
880
|
-
geometry.
|
|
881
|
-
);
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
);
|
|
893
|
-
this.
|
|
894
|
-
geometry._lineVerticesHandlerIndex,
|
|
895
|
-
geometry._lineVerticesLength
|
|
896
|
-
);
|
|
897
|
-
this.
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
);
|
|
903
|
-
this.
|
|
904
|
-
geometry._lineColorsHandlerIndex,
|
|
905
|
-
geometry._lineColorsLength
|
|
906
|
-
);
|
|
907
|
-
this.
|
|
908
|
-
geometry.
|
|
909
|
-
geometry.
|
|
910
|
-
);
|
|
911
|
-
this.
|
|
912
|
-
geometry._lineThicknessHandlerIndex,
|
|
913
|
-
geometry._lineThicknessLength
|
|
914
|
-
);
|
|
915
|
-
this.
|
|
916
|
-
geometry.
|
|
917
|
-
geometry.
|
|
918
|
-
);
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
gi.
|
|
933
|
-
gi.
|
|
934
|
-
gi.
|
|
935
|
-
|
|
936
|
-
gi.
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
geometry.
|
|
946
|
-
geometry.
|
|
947
|
-
|
|
948
|
-
geometry.
|
|
949
|
-
geometry.
|
|
950
|
-
|
|
951
|
-
geometry.
|
|
952
|
-
geometry.
|
|
953
|
-
geometry.
|
|
954
|
-
|
|
955
|
-
geometry.
|
|
956
|
-
geometry.
|
|
957
|
-
geometry.
|
|
958
|
-
geometry.
|
|
959
|
-
geometry.
|
|
960
|
-
geometry.
|
|
961
|
-
geometry.
|
|
962
|
-
geometry.
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
this.
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
m.
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
this.
|
|
1042
|
-
this.
|
|
1043
|
-
this.
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
var
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
this.
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
var
|
|
1172
|
-
geometry.
|
|
1173
|
-
geometry.
|
|
1174
|
-
);
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
this.
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
this.
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
this.
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
this.
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module og/entity/GeometryHandler
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import * as mercator from "../mercator.js";
|
|
8
|
+
import * as quadTree from "../quadTree/quadTree.js";
|
|
9
|
+
import { earcut, flatten } from "../utils/earcut.js";
|
|
10
|
+
import { GeometryType } from "./Geometry.js";
|
|
11
|
+
import { Vec2 } from "../math/Vec2.js";
|
|
12
|
+
import { doubleToTwoFloatsV2 } from "../math/coder.js";
|
|
13
|
+
|
|
14
|
+
const POLYVERTICES_BUFFER = 0;
|
|
15
|
+
const POLYINDEXES_BUFFER = 1;
|
|
16
|
+
const POLYCOLORS_BUFFER = 2;
|
|
17
|
+
const LINEVERTICES_BUFFER = 3;
|
|
18
|
+
const LINEINDEXES_BUFFER = 4;
|
|
19
|
+
const LINEORDERS_BUFFER = 5;
|
|
20
|
+
const LINECOLORS_BUFFER = 6;
|
|
21
|
+
const LINETHICKNESS_BUFFER = 7;
|
|
22
|
+
const LINESTROKES_BUFFER = 8;
|
|
23
|
+
const LINESTROKECOLORS_BUFFER = 9;
|
|
24
|
+
const POLYPICKINGCOLORS_BUFFER = 10;
|
|
25
|
+
const LINEPICKINGCOLORS_BUFFER = 11;
|
|
26
|
+
|
|
27
|
+
function doubleToTwoFloats(v, high, low) {
|
|
28
|
+
let x = v[0],
|
|
29
|
+
y = v[1];
|
|
30
|
+
|
|
31
|
+
if (x >= 0.0) {
|
|
32
|
+
let doubleHigh = Math.floor(x / 65536.0) * 65536.0;
|
|
33
|
+
high.x = Math.fround(doubleHigh);
|
|
34
|
+
low.x = Math.fround(x - doubleHigh);
|
|
35
|
+
} else {
|
|
36
|
+
let doubleHigh = Math.floor(-x / 65536.0) * 65536.0;
|
|
37
|
+
high.x = Math.fround(-doubleHigh);
|
|
38
|
+
low.x = Math.fround(x + doubleHigh);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (y >= 0.0) {
|
|
42
|
+
let doubleHigh = Math.floor(y / 65536.0) * 65536.0;
|
|
43
|
+
high.y = Math.fround(doubleHigh);
|
|
44
|
+
low.y = Math.fround(y - doubleHigh);
|
|
45
|
+
} else {
|
|
46
|
+
let doubleHigh = Math.floor(-y / 65536.0) * 65536.0;
|
|
47
|
+
high.y = Math.fround(-doubleHigh);
|
|
48
|
+
low.y = Math.fround(y + doubleHigh);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let tempHigh = new Vec2(),
|
|
53
|
+
tempLow = new Vec2(),
|
|
54
|
+
tempHighLow = new Vec2();
|
|
55
|
+
|
|
56
|
+
class GeometryHandler {
|
|
57
|
+
constructor(layer) {
|
|
58
|
+
this.__staticId = GeometryHandler._staticCounter++;
|
|
59
|
+
|
|
60
|
+
this._layer = layer;
|
|
61
|
+
|
|
62
|
+
this._handler = null;
|
|
63
|
+
|
|
64
|
+
this._geometries = [];
|
|
65
|
+
|
|
66
|
+
this._updatedGeometryArr = [];
|
|
67
|
+
this._updatedGeometry = {};
|
|
68
|
+
|
|
69
|
+
this._removeGeometryExtentArr = [];
|
|
70
|
+
this._removeGeometryExtents = {};
|
|
71
|
+
|
|
72
|
+
// Polygon arrays
|
|
73
|
+
this._polyVerticesHighMerc = [];
|
|
74
|
+
this._polyVerticesLowMerc = [];
|
|
75
|
+
this._polyColors = [];
|
|
76
|
+
this._polyPickingColors = [];
|
|
77
|
+
this._polyIndexes = [];
|
|
78
|
+
|
|
79
|
+
// Line arrays
|
|
80
|
+
this._lineVerticesHighMerc = [];
|
|
81
|
+
this._lineVerticesLowMerc = [];
|
|
82
|
+
this._lineOrders = [];
|
|
83
|
+
this._lineIndexes = [];
|
|
84
|
+
this._lineColors = [];
|
|
85
|
+
this._linePickingColors = [];
|
|
86
|
+
this._lineThickness = [];
|
|
87
|
+
this._lineStrokes = [];
|
|
88
|
+
this._lineStrokeColors = [];
|
|
89
|
+
|
|
90
|
+
// Buffers
|
|
91
|
+
this._polyVerticesHighBufferMerc = null;
|
|
92
|
+
this._polyVerticesLowBufferMerc = null;
|
|
93
|
+
this._polyColorsBuffer = null;
|
|
94
|
+
this._polyPickingColorsBuffer = null;
|
|
95
|
+
this._polyIndexesBuffer = null;
|
|
96
|
+
|
|
97
|
+
this._lineVerticesHighBufferMerc = null;
|
|
98
|
+
this._lineVerticesLowBufferMerc = null;
|
|
99
|
+
this._lineColorsBuffer = null;
|
|
100
|
+
this._linePickingColorsBuffer = null;
|
|
101
|
+
this._lineThicknessBuffer = null;
|
|
102
|
+
this._lineStrokesBuffer = null;
|
|
103
|
+
this._lineStrokeColorsBuffer = null;
|
|
104
|
+
this._lineOrdersBuffer = null;
|
|
105
|
+
this._lineIndexesBuffer = null;
|
|
106
|
+
|
|
107
|
+
this._buffersUpdateCallbacks = [];
|
|
108
|
+
this._buffersUpdateCallbacks[POLYVERTICES_BUFFER] = this.createPolyVerticesBuffer;
|
|
109
|
+
this._buffersUpdateCallbacks[POLYINDEXES_BUFFER] = this.createPolyIndexesBuffer;
|
|
110
|
+
this._buffersUpdateCallbacks[POLYCOLORS_BUFFER] = this.createPolyColorsBuffer;
|
|
111
|
+
this._buffersUpdateCallbacks[LINEVERTICES_BUFFER] = this.createLineVerticesBuffer;
|
|
112
|
+
this._buffersUpdateCallbacks[LINEINDEXES_BUFFER] = this.createLineIndexesBuffer;
|
|
113
|
+
this._buffersUpdateCallbacks[LINEORDERS_BUFFER] = this.createLineOrdersBuffer;
|
|
114
|
+
this._buffersUpdateCallbacks[LINECOLORS_BUFFER] = this.createLineColorsBuffer;
|
|
115
|
+
this._buffersUpdateCallbacks[LINETHICKNESS_BUFFER] = this.createLineThicknessBuffer;
|
|
116
|
+
this._buffersUpdateCallbacks[LINESTROKES_BUFFER] = this.createLineStrokesBuffer;
|
|
117
|
+
this._buffersUpdateCallbacks[LINESTROKECOLORS_BUFFER] = this.createLineStrokeColorsBuffer;
|
|
118
|
+
this._buffersUpdateCallbacks[POLYPICKINGCOLORS_BUFFER] = this.createPolyPickingColorsBuffer;
|
|
119
|
+
this._buffersUpdateCallbacks[LINEPICKINGCOLORS_BUFFER] = this.createLinePickingColorsBuffer;
|
|
120
|
+
|
|
121
|
+
this._changedBuffers = new Array(this._buffersUpdateCallbacks.length);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static get _staticCounter() {
|
|
125
|
+
if (!this._counter && this._counter !== 0) {
|
|
126
|
+
this._counter = 0;
|
|
127
|
+
}
|
|
128
|
+
return this._counter;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
static set _staticCounter(n) {
|
|
132
|
+
this._counter = n;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static appendLineData(
|
|
136
|
+
pathArr,
|
|
137
|
+
isClosed,
|
|
138
|
+
color,
|
|
139
|
+
pickingColor,
|
|
140
|
+
thickness,
|
|
141
|
+
strokeColor,
|
|
142
|
+
strokeSize,
|
|
143
|
+
outVerticesHigh,
|
|
144
|
+
outVerticesLow,
|
|
145
|
+
outOrders,
|
|
146
|
+
outIndexes,
|
|
147
|
+
outColors,
|
|
148
|
+
outPickingColors,
|
|
149
|
+
outThickness,
|
|
150
|
+
outStrokeColors,
|
|
151
|
+
outStrokes,
|
|
152
|
+
outVerticesHigh2,
|
|
153
|
+
outVerticesLow2
|
|
154
|
+
) {
|
|
155
|
+
var index = 0;
|
|
156
|
+
|
|
157
|
+
if (outIndexes.length > 0) {
|
|
158
|
+
index = outIndexes[outIndexes.length - 5] + 9;
|
|
159
|
+
outIndexes.push(index, index);
|
|
160
|
+
} else {
|
|
161
|
+
outIndexes.push(0, 0);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
var t = thickness,
|
|
165
|
+
c = [color.x, color.y, color.z, color.w],
|
|
166
|
+
s = strokeSize,
|
|
167
|
+
sc = [strokeColor.x, strokeColor.y, strokeColor.z, strokeColor.w],
|
|
168
|
+
p = [pickingColor.x, pickingColor.y, pickingColor.z, 1.0];
|
|
169
|
+
|
|
170
|
+
for (var j = 0; j < pathArr.length; j++) {
|
|
171
|
+
var path = pathArr[j];
|
|
172
|
+
|
|
173
|
+
if (path.length === 0) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
var startIndex = index;
|
|
178
|
+
var last;
|
|
179
|
+
if (isClosed) {
|
|
180
|
+
last = path[path.length - 1];
|
|
181
|
+
} else {
|
|
182
|
+
let p0 = path[0],
|
|
183
|
+
p1 = path[1];
|
|
184
|
+
|
|
185
|
+
if (!p1) {
|
|
186
|
+
p1 = p0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
last = [p0[0] + p0[0] - p1[0], p0[1] + p0[1] - p1[1]];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
doubleToTwoFloats(last, tempHigh, tempLow);
|
|
193
|
+
|
|
194
|
+
outVerticesHigh.push(
|
|
195
|
+
tempHigh.x,
|
|
196
|
+
tempHigh.y,
|
|
197
|
+
tempHigh.x,
|
|
198
|
+
tempHigh.y,
|
|
199
|
+
tempHigh.x,
|
|
200
|
+
tempHigh.y,
|
|
201
|
+
tempHigh.x,
|
|
202
|
+
tempHigh.y
|
|
203
|
+
);
|
|
204
|
+
outVerticesLow.push(
|
|
205
|
+
tempLow.x,
|
|
206
|
+
tempLow.y,
|
|
207
|
+
tempLow.x,
|
|
208
|
+
tempLow.y,
|
|
209
|
+
tempLow.x,
|
|
210
|
+
tempLow.y,
|
|
211
|
+
tempLow.x,
|
|
212
|
+
tempLow.y
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
outVerticesHigh2.push(
|
|
216
|
+
tempHigh.x,
|
|
217
|
+
tempHigh.y,
|
|
218
|
+
tempHigh.x,
|
|
219
|
+
tempHigh.y,
|
|
220
|
+
tempHigh.x,
|
|
221
|
+
tempHigh.y,
|
|
222
|
+
tempHigh.x,
|
|
223
|
+
tempHigh.y
|
|
224
|
+
);
|
|
225
|
+
outVerticesLow2.push(
|
|
226
|
+
tempLow.x,
|
|
227
|
+
tempLow.y,
|
|
228
|
+
tempLow.x,
|
|
229
|
+
tempLow.y,
|
|
230
|
+
tempLow.x,
|
|
231
|
+
tempLow.y,
|
|
232
|
+
tempLow.x,
|
|
233
|
+
tempLow.y
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
outOrders.push(1, -1, 2, -2);
|
|
237
|
+
|
|
238
|
+
outThickness.push(t, t, t, t);
|
|
239
|
+
outStrokes.push(s, s, s, s);
|
|
240
|
+
outColors.push(
|
|
241
|
+
c[0],
|
|
242
|
+
c[1],
|
|
243
|
+
c[2],
|
|
244
|
+
c[3],
|
|
245
|
+
c[0],
|
|
246
|
+
c[1],
|
|
247
|
+
c[2],
|
|
248
|
+
c[3],
|
|
249
|
+
c[0],
|
|
250
|
+
c[1],
|
|
251
|
+
c[2],
|
|
252
|
+
c[3],
|
|
253
|
+
c[0],
|
|
254
|
+
c[1],
|
|
255
|
+
c[2],
|
|
256
|
+
c[3]
|
|
257
|
+
);
|
|
258
|
+
outStrokeColors.push(
|
|
259
|
+
sc[0],
|
|
260
|
+
sc[1],
|
|
261
|
+
sc[2],
|
|
262
|
+
sc[3],
|
|
263
|
+
sc[0],
|
|
264
|
+
sc[1],
|
|
265
|
+
sc[2],
|
|
266
|
+
sc[3],
|
|
267
|
+
sc[0],
|
|
268
|
+
sc[1],
|
|
269
|
+
sc[2],
|
|
270
|
+
sc[3],
|
|
271
|
+
sc[0],
|
|
272
|
+
sc[1],
|
|
273
|
+
sc[2],
|
|
274
|
+
sc[3]
|
|
275
|
+
);
|
|
276
|
+
outPickingColors.push(
|
|
277
|
+
p[0],
|
|
278
|
+
p[1],
|
|
279
|
+
p[2],
|
|
280
|
+
p[3],
|
|
281
|
+
p[0],
|
|
282
|
+
p[1],
|
|
283
|
+
p[2],
|
|
284
|
+
p[3],
|
|
285
|
+
p[0],
|
|
286
|
+
p[1],
|
|
287
|
+
p[2],
|
|
288
|
+
p[3],
|
|
289
|
+
p[0],
|
|
290
|
+
p[1],
|
|
291
|
+
p[2],
|
|
292
|
+
p[3]
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
for (var i = 0; i < path.length; i++) {
|
|
296
|
+
var cur = path[i];
|
|
297
|
+
|
|
298
|
+
doubleToTwoFloats(cur, tempHigh, tempLow);
|
|
299
|
+
|
|
300
|
+
outVerticesHigh.push(
|
|
301
|
+
tempHigh.x,
|
|
302
|
+
tempHigh.y,
|
|
303
|
+
tempHigh.x,
|
|
304
|
+
tempHigh.y,
|
|
305
|
+
tempHigh.x,
|
|
306
|
+
tempHigh.y,
|
|
307
|
+
tempHigh.x,
|
|
308
|
+
tempHigh.y
|
|
309
|
+
);
|
|
310
|
+
outVerticesLow.push(
|
|
311
|
+
tempLow.x,
|
|
312
|
+
tempLow.y,
|
|
313
|
+
tempLow.x,
|
|
314
|
+
tempLow.y,
|
|
315
|
+
tempLow.x,
|
|
316
|
+
tempLow.y,
|
|
317
|
+
tempLow.x,
|
|
318
|
+
tempLow.y
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
outVerticesHigh2.push(
|
|
322
|
+
tempHigh.x,
|
|
323
|
+
tempHigh.y,
|
|
324
|
+
tempHigh.x,
|
|
325
|
+
tempHigh.y,
|
|
326
|
+
tempHigh.x,
|
|
327
|
+
tempHigh.y,
|
|
328
|
+
tempHigh.x,
|
|
329
|
+
tempHigh.y
|
|
330
|
+
);
|
|
331
|
+
outVerticesLow2.push(
|
|
332
|
+
tempLow.x,
|
|
333
|
+
tempLow.y,
|
|
334
|
+
tempLow.x,
|
|
335
|
+
tempLow.y,
|
|
336
|
+
tempLow.x,
|
|
337
|
+
tempLow.y,
|
|
338
|
+
tempLow.x,
|
|
339
|
+
tempLow.y
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
outOrders.push(1, -1, 2, -2);
|
|
343
|
+
outThickness.push(t, t, t, t);
|
|
344
|
+
outStrokes.push(s, s, s, s);
|
|
345
|
+
outColors.push(
|
|
346
|
+
c[0],
|
|
347
|
+
c[1],
|
|
348
|
+
c[2],
|
|
349
|
+
c[3],
|
|
350
|
+
c[0],
|
|
351
|
+
c[1],
|
|
352
|
+
c[2],
|
|
353
|
+
c[3],
|
|
354
|
+
c[0],
|
|
355
|
+
c[1],
|
|
356
|
+
c[2],
|
|
357
|
+
c[3],
|
|
358
|
+
c[0],
|
|
359
|
+
c[1],
|
|
360
|
+
c[2],
|
|
361
|
+
c[3]
|
|
362
|
+
);
|
|
363
|
+
outStrokeColors.push(
|
|
364
|
+
sc[0],
|
|
365
|
+
sc[1],
|
|
366
|
+
sc[2],
|
|
367
|
+
sc[3],
|
|
368
|
+
sc[0],
|
|
369
|
+
sc[1],
|
|
370
|
+
sc[2],
|
|
371
|
+
sc[3],
|
|
372
|
+
sc[0],
|
|
373
|
+
sc[1],
|
|
374
|
+
sc[2],
|
|
375
|
+
sc[3],
|
|
376
|
+
sc[0],
|
|
377
|
+
sc[1],
|
|
378
|
+
sc[2],
|
|
379
|
+
sc[3]
|
|
380
|
+
);
|
|
381
|
+
outPickingColors.push(
|
|
382
|
+
p[0],
|
|
383
|
+
p[1],
|
|
384
|
+
p[2],
|
|
385
|
+
p[3],
|
|
386
|
+
p[0],
|
|
387
|
+
p[1],
|
|
388
|
+
p[2],
|
|
389
|
+
p[3],
|
|
390
|
+
p[0],
|
|
391
|
+
p[1],
|
|
392
|
+
p[2],
|
|
393
|
+
p[3],
|
|
394
|
+
p[0],
|
|
395
|
+
p[1],
|
|
396
|
+
p[2],
|
|
397
|
+
p[3]
|
|
398
|
+
);
|
|
399
|
+
outIndexes.push(index++, index++, index++, index++);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
var first;
|
|
403
|
+
if (isClosed) {
|
|
404
|
+
first = path[0];
|
|
405
|
+
outIndexes.push(startIndex, startIndex + 1, startIndex + 1, startIndex + 1);
|
|
406
|
+
} else {
|
|
407
|
+
let p0 = path[path.length - 1],
|
|
408
|
+
p1 = path[path.length - 2];
|
|
409
|
+
|
|
410
|
+
if (!p1) {
|
|
411
|
+
p1 = p0;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
first = [p0[0] + p0[0] - p1[0], p0[1] + p0[1] - p1[1]];
|
|
415
|
+
outIndexes.push(index - 1, index - 1, index - 1, index - 1);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
doubleToTwoFloats(first, tempHigh, tempLow);
|
|
419
|
+
|
|
420
|
+
outVerticesHigh.push(
|
|
421
|
+
tempHigh.x,
|
|
422
|
+
tempHigh.y,
|
|
423
|
+
tempHigh.x,
|
|
424
|
+
tempHigh.y,
|
|
425
|
+
tempHigh.x,
|
|
426
|
+
tempHigh.y,
|
|
427
|
+
tempHigh.x,
|
|
428
|
+
tempHigh.y
|
|
429
|
+
);
|
|
430
|
+
outVerticesLow.push(
|
|
431
|
+
tempLow.x,
|
|
432
|
+
tempLow.y,
|
|
433
|
+
tempLow.x,
|
|
434
|
+
tempLow.y,
|
|
435
|
+
tempLow.x,
|
|
436
|
+
tempLow.y,
|
|
437
|
+
tempLow.x,
|
|
438
|
+
tempLow.y
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
outVerticesHigh2.push(
|
|
442
|
+
tempHigh.x,
|
|
443
|
+
tempHigh.y,
|
|
444
|
+
tempHigh.x,
|
|
445
|
+
tempHigh.y,
|
|
446
|
+
tempHigh.x,
|
|
447
|
+
tempHigh.y,
|
|
448
|
+
tempHigh.x,
|
|
449
|
+
tempHigh.y
|
|
450
|
+
);
|
|
451
|
+
outVerticesLow2.push(
|
|
452
|
+
tempLow.x,
|
|
453
|
+
tempLow.y,
|
|
454
|
+
tempLow.x,
|
|
455
|
+
tempLow.y,
|
|
456
|
+
tempLow.x,
|
|
457
|
+
tempLow.y,
|
|
458
|
+
tempLow.x,
|
|
459
|
+
tempLow.y
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
outOrders.push(1, -1, 2, -2);
|
|
463
|
+
outThickness.push(t, t, t, t);
|
|
464
|
+
outStrokes.push(s, s, s, s);
|
|
465
|
+
outColors.push(
|
|
466
|
+
c[0],
|
|
467
|
+
c[1],
|
|
468
|
+
c[2],
|
|
469
|
+
c[3],
|
|
470
|
+
c[0],
|
|
471
|
+
c[1],
|
|
472
|
+
c[2],
|
|
473
|
+
c[3],
|
|
474
|
+
c[0],
|
|
475
|
+
c[1],
|
|
476
|
+
c[2],
|
|
477
|
+
c[3],
|
|
478
|
+
c[0],
|
|
479
|
+
c[1],
|
|
480
|
+
c[2],
|
|
481
|
+
c[3]
|
|
482
|
+
);
|
|
483
|
+
outStrokeColors.push(
|
|
484
|
+
sc[0],
|
|
485
|
+
sc[1],
|
|
486
|
+
sc[2],
|
|
487
|
+
sc[3],
|
|
488
|
+
sc[0],
|
|
489
|
+
sc[1],
|
|
490
|
+
sc[2],
|
|
491
|
+
sc[3],
|
|
492
|
+
sc[0],
|
|
493
|
+
sc[1],
|
|
494
|
+
sc[2],
|
|
495
|
+
sc[3],
|
|
496
|
+
sc[0],
|
|
497
|
+
sc[1],
|
|
498
|
+
sc[2],
|
|
499
|
+
sc[3]
|
|
500
|
+
);
|
|
501
|
+
outPickingColors.push(
|
|
502
|
+
p[0],
|
|
503
|
+
p[1],
|
|
504
|
+
p[2],
|
|
505
|
+
p[3],
|
|
506
|
+
p[0],
|
|
507
|
+
p[1],
|
|
508
|
+
p[2],
|
|
509
|
+
p[3],
|
|
510
|
+
p[0],
|
|
511
|
+
p[1],
|
|
512
|
+
p[2],
|
|
513
|
+
p[3],
|
|
514
|
+
p[0],
|
|
515
|
+
p[1],
|
|
516
|
+
p[2],
|
|
517
|
+
p[3]
|
|
518
|
+
);
|
|
519
|
+
|
|
520
|
+
if (j < pathArr.length - 1) {
|
|
521
|
+
index += 8;
|
|
522
|
+
outIndexes.push(index, index);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
assignHandler(handler) {
|
|
528
|
+
this._handler = handler;
|
|
529
|
+
this.refresh();
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* @public
|
|
534
|
+
* @param {Geometry} geometry - Geometry object.
|
|
535
|
+
*/
|
|
536
|
+
add(geometry) {
|
|
537
|
+
//
|
|
538
|
+
// Triangulates polygon and sets geometry data.
|
|
539
|
+
if (geometry._handlerIndex === -1) {
|
|
540
|
+
geometry._handler = this;
|
|
541
|
+
geometry._handlerIndex = this._geometries.length;
|
|
542
|
+
|
|
543
|
+
this._geometries.push(geometry);
|
|
544
|
+
|
|
545
|
+
let pickingColor = geometry._entity._pickingColor.scaleTo(1 / 255);
|
|
546
|
+
|
|
547
|
+
geometry._polyVerticesHighMerc = [];
|
|
548
|
+
geometry._polyVerticesLowMerc = [];
|
|
549
|
+
geometry._lineVerticesHighMerc = [];
|
|
550
|
+
geometry._lineVerticesLowMerc = [];
|
|
551
|
+
|
|
552
|
+
if (geometry._coordinates[0].length) {
|
|
553
|
+
if (geometry._type === GeometryType.POLYGON) {
|
|
554
|
+
let coordinates = geometry._coordinates;
|
|
555
|
+
let ci = [];
|
|
556
|
+
for (let j = 0; j < coordinates.length; j++) {
|
|
557
|
+
ci[j] = [];
|
|
558
|
+
for (var k = 0; k < coordinates[j].length; k++) {
|
|
559
|
+
ci[j][k] = [
|
|
560
|
+
mercator.forward_lon(coordinates[j][k][0]),
|
|
561
|
+
mercator.forward_lat(coordinates[j][k][1])
|
|
562
|
+
];
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
let data = flatten(ci);
|
|
567
|
+
let indexes = earcut(data.vertices, data.holes, 2);
|
|
568
|
+
|
|
569
|
+
geometry._polyVerticesHandlerIndex = this._polyVerticesHighMerc.length;
|
|
570
|
+
geometry._polyIndexesHandlerIndex = this._polyIndexes.length;
|
|
571
|
+
|
|
572
|
+
for (let i = 0; i < indexes.length; i++) {
|
|
573
|
+
this._polyIndexes.push(indexes[i] + geometry._polyVerticesHandlerIndex * 0.5);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
var color = geometry._style.fillColor;
|
|
577
|
+
|
|
578
|
+
let verticesHigh = [],
|
|
579
|
+
verticesLow = [];
|
|
580
|
+
|
|
581
|
+
for (let i = 0; i < data.vertices.length * 0.5; i++) {
|
|
582
|
+
this._polyColors.push(color.x, color.y, color.z, color.w);
|
|
583
|
+
this._polyPickingColors.push(
|
|
584
|
+
pickingColor.x,
|
|
585
|
+
pickingColor.y,
|
|
586
|
+
pickingColor.z,
|
|
587
|
+
1.0
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
for (let i = 0; i < data.vertices.length; i++) {
|
|
592
|
+
doubleToTwoFloatsV2(data.vertices[i], tempHighLow);
|
|
593
|
+
verticesHigh[i] = tempHighLow.x;
|
|
594
|
+
verticesLow[i] = tempHighLow.y;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
geometry._polyVerticesHighMerc = verticesHigh;
|
|
598
|
+
geometry._polyVerticesLowMerc = verticesLow;
|
|
599
|
+
|
|
600
|
+
this._polyVerticesHighMerc.push.apply(this._polyVerticesHighMerc, verticesHigh);
|
|
601
|
+
this._polyVerticesLowMerc.push.apply(this._polyVerticesLowMerc, verticesLow);
|
|
602
|
+
|
|
603
|
+
geometry._polyVerticesLength = data.vertices.length;
|
|
604
|
+
geometry._polyIndexesLength = indexes.length;
|
|
605
|
+
|
|
606
|
+
// Creates polygon stroke data
|
|
607
|
+
geometry._lineVerticesHandlerIndex = this._lineVerticesHighMerc.length;
|
|
608
|
+
geometry._lineOrdersHandlerIndex = this._lineOrders.length;
|
|
609
|
+
geometry._lineIndexesHandlerIndex = this._lineIndexes.length;
|
|
610
|
+
geometry._lineColorsHandlerIndex = this._lineColors.length;
|
|
611
|
+
geometry._lineThicknessHandlerIndex = this._lineThickness.length;
|
|
612
|
+
|
|
613
|
+
GeometryHandler.appendLineData(
|
|
614
|
+
ci,
|
|
615
|
+
true,
|
|
616
|
+
geometry._style.lineColor,
|
|
617
|
+
pickingColor,
|
|
618
|
+
geometry._style.lineWidth,
|
|
619
|
+
geometry._style.strokeColor,
|
|
620
|
+
geometry._style.strokeWidth,
|
|
621
|
+
this._lineVerticesHighMerc,
|
|
622
|
+
this._lineVerticesLowMerc,
|
|
623
|
+
this._lineOrders,
|
|
624
|
+
this._lineIndexes,
|
|
625
|
+
this._lineColors,
|
|
626
|
+
this._linePickingColors,
|
|
627
|
+
this._lineThickness,
|
|
628
|
+
this._lineStrokeColors,
|
|
629
|
+
this._lineStrokes,
|
|
630
|
+
geometry._lineVerticesHighMerc,
|
|
631
|
+
geometry._lineVerticesLowMerc
|
|
632
|
+
);
|
|
633
|
+
|
|
634
|
+
geometry._lineVerticesLength =
|
|
635
|
+
this._lineVerticesHighMerc.length - geometry._lineVerticesHandlerIndex;
|
|
636
|
+
geometry._lineOrdersLength =
|
|
637
|
+
this._lineOrders.length - geometry._lineOrdersHandlerIndex;
|
|
638
|
+
geometry._lineIndexesLength =
|
|
639
|
+
this._lineIndexes.length - geometry._lineIndexesHandlerIndex;
|
|
640
|
+
geometry._lineColorsLength =
|
|
641
|
+
this._lineColors.length - geometry._lineColorsHandlerIndex;
|
|
642
|
+
geometry._lineThicknessLength =
|
|
643
|
+
this._lineThickness.length - geometry._lineThicknessHandlerIndex;
|
|
644
|
+
|
|
645
|
+
} else if (geometry._type === GeometryType.MULTIPOLYGON) {
|
|
646
|
+
let coordinates = geometry._coordinates;
|
|
647
|
+
let vertices = [],
|
|
648
|
+
indexes = [];
|
|
649
|
+
|
|
650
|
+
// Creates polygon stroke data
|
|
651
|
+
geometry._lineVerticesHandlerIndex = this._lineVerticesHighMerc.length;
|
|
652
|
+
geometry._lineOrdersHandlerIndex = this._lineOrders.length;
|
|
653
|
+
geometry._lineIndexesHandlerIndex = this._lineIndexes.length;
|
|
654
|
+
geometry._lineColorsHandlerIndex = this._lineColors.length;
|
|
655
|
+
geometry._lineThicknessHandlerIndex = this._lineThickness.length;
|
|
656
|
+
|
|
657
|
+
for (var i = 0; i < coordinates.length; i++) {
|
|
658
|
+
let cci = coordinates[i];
|
|
659
|
+
let ci = [];
|
|
660
|
+
for (let j = 0; j < cci.length; j++) {
|
|
661
|
+
ci[j] = [];
|
|
662
|
+
for (let k = 0; k < coordinates[i][j].length; k++) {
|
|
663
|
+
ci[j][k] = [
|
|
664
|
+
mercator.forward_lon(cci[j][k][0]),
|
|
665
|
+
mercator.forward_lat(cci[j][k][1])
|
|
666
|
+
];
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
let data = flatten(ci);
|
|
670
|
+
let dataIndexes = earcut(data.vertices, data.holes, 2);
|
|
671
|
+
|
|
672
|
+
for (let j = 0; j < dataIndexes.length; j++) {
|
|
673
|
+
indexes.push(dataIndexes[j] + vertices.length * 0.5);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
vertices.push.apply(vertices, data.vertices);
|
|
677
|
+
|
|
678
|
+
GeometryHandler.appendLineData(
|
|
679
|
+
ci,
|
|
680
|
+
true,
|
|
681
|
+
geometry._style.lineColor,
|
|
682
|
+
pickingColor,
|
|
683
|
+
geometry._style.lineWidth,
|
|
684
|
+
geometry._style.strokeColor,
|
|
685
|
+
geometry._style.strokeWidth,
|
|
686
|
+
this._lineVerticesHighMerc,
|
|
687
|
+
this._lineVerticesLowMerc,
|
|
688
|
+
this._lineOrders,
|
|
689
|
+
this._lineIndexes,
|
|
690
|
+
this._lineColors,
|
|
691
|
+
this._linePickingColors,
|
|
692
|
+
this._lineThickness,
|
|
693
|
+
this._lineStrokeColors,
|
|
694
|
+
this._lineStrokes,
|
|
695
|
+
geometry._lineVerticesHighMerc,
|
|
696
|
+
geometry._lineVerticesLowMerc
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
geometry._polyVerticesHandlerIndex = this._polyVerticesHighMerc.length;
|
|
701
|
+
geometry._polyIndexesHandlerIndex = this._polyIndexes.length;
|
|
702
|
+
|
|
703
|
+
for (let i = 0; i < indexes.length; i++) {
|
|
704
|
+
this._polyIndexes.push(indexes[i] + geometry._polyVerticesHandlerIndex * 0.5);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
let color = geometry._style.fillColor;
|
|
708
|
+
|
|
709
|
+
let verticesHigh = [],
|
|
710
|
+
verticesLow = [];
|
|
711
|
+
|
|
712
|
+
for (let i = 0; i < vertices.length * 0.5; i++) {
|
|
713
|
+
this._polyColors.push(color.x, color.y, color.z, color.w);
|
|
714
|
+
this._polyPickingColors.push(
|
|
715
|
+
pickingColor.x,
|
|
716
|
+
pickingColor.y,
|
|
717
|
+
pickingColor.z,
|
|
718
|
+
1.0
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
for (let i = 0; i < vertices.length; i++) {
|
|
723
|
+
doubleToTwoFloatsV2(vertices[i], tempHighLow);
|
|
724
|
+
verticesHigh[i] = tempHighLow.x;
|
|
725
|
+
verticesLow[i] = tempHighLow.y;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
geometry._polyVerticesHighMerc = verticesHigh;
|
|
729
|
+
geometry._polyVerticesLowMerc = verticesLow;
|
|
730
|
+
|
|
731
|
+
this._polyVerticesHighMerc.push.apply(this._polyVerticesHighMerc, verticesHigh);
|
|
732
|
+
this._polyVerticesLowMerc.push.apply(this._polyVerticesLowMerc, verticesLow);
|
|
733
|
+
|
|
734
|
+
geometry._polyVerticesLength = vertices.length;
|
|
735
|
+
geometry._polyIndexesLength = indexes.length;
|
|
736
|
+
|
|
737
|
+
geometry._lineVerticesLength =
|
|
738
|
+
this._lineVerticesHighMerc.length - geometry._lineVerticesHandlerIndex;
|
|
739
|
+
geometry._lineOrdersLength =
|
|
740
|
+
this._lineOrders.length - geometry._lineOrdersHandlerIndex;
|
|
741
|
+
geometry._lineIndexesLength =
|
|
742
|
+
this._lineIndexes.length - geometry._lineIndexesHandlerIndex;
|
|
743
|
+
geometry._lineColorsLength =
|
|
744
|
+
this._lineColors.length - geometry._lineColorsHandlerIndex;
|
|
745
|
+
geometry._lineThicknessLength =
|
|
746
|
+
this._lineThickness.length - geometry._lineThicknessHandlerIndex;
|
|
747
|
+
} else if (geometry._type === GeometryType.LINESTRING) {
|
|
748
|
+
let coordinates = geometry._coordinates;
|
|
749
|
+
let ci = new Array(coordinates.length);
|
|
750
|
+
for (let j = 0; j < coordinates.length; j++) {
|
|
751
|
+
ci[j] = [
|
|
752
|
+
mercator.forward_lon(coordinates[j][0]),
|
|
753
|
+
mercator.forward_lat(coordinates[j][1])
|
|
754
|
+
];
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// Creates polygon stroke data
|
|
758
|
+
geometry._lineVerticesHandlerIndex = this._lineVerticesHighMerc.length;
|
|
759
|
+
geometry._lineOrdersHandlerIndex = this._lineOrders.length;
|
|
760
|
+
geometry._lineIndexesHandlerIndex = this._lineIndexes.length;
|
|
761
|
+
geometry._lineColorsHandlerIndex = this._lineColors.length;
|
|
762
|
+
geometry._lineThicknessHandlerIndex = this._lineThickness.length;
|
|
763
|
+
|
|
764
|
+
GeometryHandler.appendLineData(
|
|
765
|
+
[ci],
|
|
766
|
+
false,
|
|
767
|
+
geometry._style.lineColor,
|
|
768
|
+
pickingColor,
|
|
769
|
+
geometry._style.lineWidth,
|
|
770
|
+
geometry._style.strokeColor,
|
|
771
|
+
geometry._style.strokeWidth,
|
|
772
|
+
this._lineVerticesHighMerc,
|
|
773
|
+
this._lineVerticesLowMerc,
|
|
774
|
+
this._lineOrders,
|
|
775
|
+
this._lineIndexes,
|
|
776
|
+
this._lineColors,
|
|
777
|
+
this._linePickingColors,
|
|
778
|
+
this._lineThickness,
|
|
779
|
+
this._lineStrokeColors,
|
|
780
|
+
this._lineStrokes,
|
|
781
|
+
geometry._lineVerticesHighMerc,
|
|
782
|
+
geometry._lineVerticesLowMerc
|
|
783
|
+
);
|
|
784
|
+
|
|
785
|
+
geometry._lineVerticesLength =
|
|
786
|
+
this._lineVerticesHighMerc.length - geometry._lineVerticesHandlerIndex;
|
|
787
|
+
geometry._lineOrdersLength =
|
|
788
|
+
this._lineOrders.length - geometry._lineOrdersHandlerIndex;
|
|
789
|
+
geometry._lineIndexesLength =
|
|
790
|
+
this._lineIndexes.length - geometry._lineIndexesHandlerIndex;
|
|
791
|
+
geometry._lineColorsLength =
|
|
792
|
+
this._lineColors.length - geometry._lineColorsHandlerIndex;
|
|
793
|
+
geometry._lineThicknessLength =
|
|
794
|
+
this._lineThickness.length - geometry._lineThicknessHandlerIndex;
|
|
795
|
+
} else if (geometry._type === GeometryType.MULTILINESTRING) {
|
|
796
|
+
let coordinates = geometry._coordinates;
|
|
797
|
+
let ci = [];
|
|
798
|
+
for (let j = 0; j < coordinates.length; j++) {
|
|
799
|
+
ci[j] = [];
|
|
800
|
+
for (let k = 0; k < coordinates[j].length; k++) {
|
|
801
|
+
ci[j][k] = [
|
|
802
|
+
mercator.forward_lon(coordinates[j][k][0]),
|
|
803
|
+
mercator.forward_lat(coordinates[j][k][1])
|
|
804
|
+
];
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// Creates polygon stroke data
|
|
809
|
+
geometry._lineVerticesHandlerIndex = this._lineVerticesHighMerc.length;
|
|
810
|
+
geometry._lineOrdersHandlerIndex = this._lineOrders.length;
|
|
811
|
+
geometry._lineIndexesHandlerIndex = this._lineIndexes.length;
|
|
812
|
+
geometry._lineColorsHandlerIndex = this._lineColors.length;
|
|
813
|
+
geometry._lineThicknessHandlerIndex = this._lineThickness.length;
|
|
814
|
+
|
|
815
|
+
GeometryHandler.appendLineData(
|
|
816
|
+
ci,
|
|
817
|
+
false,
|
|
818
|
+
geometry._style.lineColor,
|
|
819
|
+
pickingColor,
|
|
820
|
+
geometry._style.lineWidth,
|
|
821
|
+
geometry._style.strokeColor,
|
|
822
|
+
geometry._style.strokeWidth,
|
|
823
|
+
this._lineVerticesHighMerc,
|
|
824
|
+
this._lineVerticesLowMerc,
|
|
825
|
+
this._lineOrders,
|
|
826
|
+
this._lineIndexes,
|
|
827
|
+
this._lineColors,
|
|
828
|
+
this._linePickingColors,
|
|
829
|
+
this._lineThickness,
|
|
830
|
+
this._lineStrokeColors,
|
|
831
|
+
this._lineStrokes,
|
|
832
|
+
geometry._lineVerticesHighMerc,
|
|
833
|
+
geometry._lineVerticesLowMerc
|
|
834
|
+
);
|
|
835
|
+
|
|
836
|
+
geometry._lineVerticesLength =
|
|
837
|
+
this._lineVerticesHighMerc.length - geometry._lineVerticesHandlerIndex;
|
|
838
|
+
geometry._lineOrdersLength =
|
|
839
|
+
this._lineOrders.length - geometry._lineOrdersHandlerIndex;
|
|
840
|
+
geometry._lineIndexesLength =
|
|
841
|
+
this._lineIndexes.length - geometry._lineIndexesHandlerIndex;
|
|
842
|
+
geometry._lineColorsLength =
|
|
843
|
+
this._lineColors.length - geometry._lineColorsHandlerIndex;
|
|
844
|
+
geometry._lineThicknessLength =
|
|
845
|
+
this._lineThickness.length - geometry._lineThicknessHandlerIndex;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// Refresh visibility
|
|
850
|
+
this.setGeometryVisibility(geometry);
|
|
851
|
+
|
|
852
|
+
!this._updatedGeometry[geometry._id] && this._updatedGeometryArr.push(geometry);
|
|
853
|
+
this._updatedGeometry[geometry._id] = true;
|
|
854
|
+
this.refresh();
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
remove(geometry) {
|
|
859
|
+
var index = geometry._handlerIndex;
|
|
860
|
+
if (index !== -1) {
|
|
861
|
+
this._geometries.splice(index, 1);
|
|
862
|
+
|
|
863
|
+
// polygon
|
|
864
|
+
// this._polyVerticesLonLat.splice(geometry._polyVerticesHandlerIndex, geometry._polyVerticesLength);
|
|
865
|
+
this._polyVerticesHighMerc.splice(
|
|
866
|
+
geometry._polyVerticesHandlerIndex,
|
|
867
|
+
geometry._polyVerticesLength
|
|
868
|
+
);
|
|
869
|
+
this._polyVerticesLowMerc.splice(
|
|
870
|
+
geometry._polyVerticesHandlerIndex,
|
|
871
|
+
geometry._polyVerticesLength
|
|
872
|
+
);
|
|
873
|
+
|
|
874
|
+
this._polyColors.splice(
|
|
875
|
+
geometry._polyVerticesHandlerIndex * 2,
|
|
876
|
+
geometry._polyVerticesLength * 2
|
|
877
|
+
);
|
|
878
|
+
this._polyPickingColors.splice(
|
|
879
|
+
geometry._polyVerticesHandlerIndex * 2,
|
|
880
|
+
geometry._polyVerticesLength * 2
|
|
881
|
+
);
|
|
882
|
+
this._polyIndexes.splice(
|
|
883
|
+
geometry._polyIndexesHandlerIndex,
|
|
884
|
+
geometry._polyIndexesLength
|
|
885
|
+
);
|
|
886
|
+
var di = geometry._polyVerticesLength * 0.5;
|
|
887
|
+
for (var i = geometry._polyIndexesHandlerIndex; i < this._polyIndexes.length; i++) {
|
|
888
|
+
this._polyIndexes[i] -= di;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// line
|
|
892
|
+
// this._lineVerticesLonLat.splice(geometry._lineVerticesHandlerIndex, geometry._lineVerticesLength);
|
|
893
|
+
this._lineVerticesHighMerc.splice(
|
|
894
|
+
geometry._lineVerticesHandlerIndex,
|
|
895
|
+
geometry._lineVerticesLength
|
|
896
|
+
);
|
|
897
|
+
this._lineVerticesLowMerc.splice(
|
|
898
|
+
geometry._lineVerticesHandlerIndex,
|
|
899
|
+
geometry._lineVerticesLength
|
|
900
|
+
);
|
|
901
|
+
this._lineOrders.splice(geometry._lineOrdersHandlerIndex, geometry._lineOrdersLength);
|
|
902
|
+
this._lineColors.splice(geometry._lineColorsHandlerIndex, geometry._lineColorsLength);
|
|
903
|
+
this._linePickingColors.splice(
|
|
904
|
+
geometry._lineColorsHandlerIndex,
|
|
905
|
+
geometry._lineColorsLength
|
|
906
|
+
);
|
|
907
|
+
this._lineStrokeColors.splice(
|
|
908
|
+
geometry._lineColorsHandlerIndex,
|
|
909
|
+
geometry._lineColorsLength
|
|
910
|
+
);
|
|
911
|
+
this._lineThickness.splice(
|
|
912
|
+
geometry._lineThicknessHandlerIndex,
|
|
913
|
+
geometry._lineThicknessLength
|
|
914
|
+
);
|
|
915
|
+
this._lineStrokes.splice(
|
|
916
|
+
geometry._lineThicknessHandlerIndex,
|
|
917
|
+
geometry._lineThicknessLength
|
|
918
|
+
);
|
|
919
|
+
this._lineIndexes.splice(
|
|
920
|
+
geometry._lineIndexesHandlerIndex,
|
|
921
|
+
geometry._lineIndexesLength
|
|
922
|
+
);
|
|
923
|
+
di = geometry._lineVerticesLength * 0.5;
|
|
924
|
+
for (let i = geometry._lineIndexesHandlerIndex; i < this._lineIndexes.length; i++) {
|
|
925
|
+
this._lineIndexes[i] -= di;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
// reindex
|
|
929
|
+
var g = this._geometries;
|
|
930
|
+
for (let i = index; i < g.length; i++) {
|
|
931
|
+
var gi = g[i];
|
|
932
|
+
gi._handlerIndex = i;
|
|
933
|
+
gi._polyVerticesHandlerIndex -= geometry._polyVerticesLength;
|
|
934
|
+
gi._polyIndexesHandlerIndex -= geometry._polyIndexesLength;
|
|
935
|
+
|
|
936
|
+
gi._lineVerticesHandlerIndex -= geometry._lineVerticesLength;
|
|
937
|
+
gi._lineOrdersHandlerIndex -= geometry._lineOrdersLength;
|
|
938
|
+
gi._lineColorsHandlerIndex -= geometry._lineColorsLength;
|
|
939
|
+
gi._lineThicknessHandlerIndex -= geometry._lineThicknessLength;
|
|
940
|
+
gi._lineIndexesHandlerIndex -= geometry._lineIndexesLength;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
geometry._pickingReady = false;
|
|
944
|
+
|
|
945
|
+
geometry._handler = null;
|
|
946
|
+
geometry._handlerIndex = -1;
|
|
947
|
+
|
|
948
|
+
geometry._polyVerticesHighMerc = [];
|
|
949
|
+
geometry._polyVerticesLowMerc = [];
|
|
950
|
+
geometry._polyVerticesLength = -1;
|
|
951
|
+
geometry._polyIndexesLength = -1;
|
|
952
|
+
geometry._polyVerticesHandlerIndex = -1;
|
|
953
|
+
geometry._polyIndexesHandlerIndex = -1;
|
|
954
|
+
|
|
955
|
+
geometry._lineVerticesHighMerc = [];
|
|
956
|
+
geometry._lineVerticesLowMerc = [];
|
|
957
|
+
geometry._lineVerticesLength = -1;
|
|
958
|
+
geometry._lineOrdersLength = -1;
|
|
959
|
+
geometry._lineIndexesLength = -1;
|
|
960
|
+
geometry._lineColorsLength = -1;
|
|
961
|
+
geometry._lineThicknessLength = -1;
|
|
962
|
+
geometry._lineVerticesHandlerIndex = -1;
|
|
963
|
+
geometry._lineOrdersHandlerIndex = -1;
|
|
964
|
+
geometry._lineIndexesHandlerIndex = -1;
|
|
965
|
+
geometry._lineThicknessHandlerIndex = -1;
|
|
966
|
+
geometry._lineColorsHandlerIndex = -1;
|
|
967
|
+
|
|
968
|
+
!this._removeGeometryExtents[geometry._id] &&
|
|
969
|
+
this._removeGeometryExtentArr.push(geometry.getExtent());
|
|
970
|
+
this._removeGeometryExtents[geometry._id] = true;
|
|
971
|
+
|
|
972
|
+
this.refresh();
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
_refreshRecursevely(geometry, treeNode) {
|
|
977
|
+
if (treeNode.ready) {
|
|
978
|
+
var lid = this._layer._id;
|
|
979
|
+
for (var i = 0; i < treeNode.nodes.length; i++) {
|
|
980
|
+
var ni = treeNode.nodes[i];
|
|
981
|
+
if (geometry._extent.overlaps(ni.segment.getExtentLonLat())) {
|
|
982
|
+
this._refreshRecursevely(geometry, ni);
|
|
983
|
+
var m = ni.segment.materials[lid];
|
|
984
|
+
if (m && m.isReady) {
|
|
985
|
+
if (m.segment.node.getState() !== quadTree.RENDERING) {
|
|
986
|
+
m.layer.clearMaterial(m);
|
|
987
|
+
} else {
|
|
988
|
+
m.pickingReady = m.pickingReady && geometry._pickingReady;
|
|
989
|
+
m.isReady = false;
|
|
990
|
+
m._updateTexture = m.texture;
|
|
991
|
+
m._updatePickingMask = m.pickingMask;
|
|
992
|
+
}
|
|
993
|
+
geometry._pickingReady = true;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
_refreshRecursevelyExt(extent, treeNode) {
|
|
1001
|
+
if (treeNode.ready) {
|
|
1002
|
+
var lid = this._layer._id;
|
|
1003
|
+
for (var i = 0; i < treeNode.nodes.length; i++) {
|
|
1004
|
+
var ni = treeNode.nodes[i];
|
|
1005
|
+
if (extent.overlaps(ni.segment.getExtentLonLat())) {
|
|
1006
|
+
this._refreshRecursevelyExt(extent, ni);
|
|
1007
|
+
var m = ni.segment.materials[lid];
|
|
1008
|
+
if (m && m.isReady) {
|
|
1009
|
+
m.layer.clearMaterial(m);
|
|
1010
|
+
// m.pickingReady = false;
|
|
1011
|
+
// m.isReady = false;
|
|
1012
|
+
// m._updateTexture = m.texture;
|
|
1013
|
+
// m._updatePickingMask = m.pickingMask;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
_refreshPlanetNode(treeNode) {
|
|
1021
|
+
var i = 0;
|
|
1022
|
+
|
|
1023
|
+
var e = this._removeGeometryExtentArr;
|
|
1024
|
+
for (i = 0; i < e.length; i++) {
|
|
1025
|
+
this._refreshRecursevelyExt(e[i], treeNode);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
var g = this._updatedGeometryArr;
|
|
1029
|
+
for (i = 0; i < g.length; i++) {
|
|
1030
|
+
this._refreshRecursevely(g[i], treeNode);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
_updatePlanet() {
|
|
1035
|
+
var p = this._layer._planet;
|
|
1036
|
+
if (p) {
|
|
1037
|
+
p.quadTreeStrategy.quadTreeList.forEach(quadTree => {
|
|
1038
|
+
this._refreshPlanetNode(quadTree);
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
this._updatedGeometryArr.length = 0;
|
|
1042
|
+
this._updatedGeometryArr = [];
|
|
1043
|
+
this._updatedGeometry = {};
|
|
1044
|
+
|
|
1045
|
+
this._removeGeometryExtentArr.length = 0;
|
|
1046
|
+
this._removeGeometryExtentArr = [];
|
|
1047
|
+
this._removeGeometryExtents = {};
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
refresh() {
|
|
1051
|
+
var i = this._changedBuffers.length;
|
|
1052
|
+
while (i--) {
|
|
1053
|
+
this._changedBuffers[i] = true;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
update() {
|
|
1058
|
+
if (this._handler) {
|
|
1059
|
+
var needUpdate = false;
|
|
1060
|
+
var i = this._changedBuffers.length;
|
|
1061
|
+
while (i--) {
|
|
1062
|
+
if (this._changedBuffers[i]) {
|
|
1063
|
+
needUpdate = true;
|
|
1064
|
+
this._buffersUpdateCallbacks[i].call(this);
|
|
1065
|
+
this._changedBuffers[i] = false;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
needUpdate && this._updatePlanet();
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
setGeometryVisibility(geometry) {
|
|
1073
|
+
var v = geometry._visibility ? 1.0 : 0.0;
|
|
1074
|
+
|
|
1075
|
+
var a = this._polyVerticesHighMerc,
|
|
1076
|
+
b = this._polyVerticesLowMerc;
|
|
1077
|
+
|
|
1078
|
+
var l = geometry._polyVerticesLength;
|
|
1079
|
+
var ind = geometry._polyVerticesHandlerIndex;
|
|
1080
|
+
for (var i = 0; i < l; i++) {
|
|
1081
|
+
a[ind + i] = geometry._polyVerticesHighMerc[i] * v;
|
|
1082
|
+
b[ind + i] = geometry._polyVerticesLowMerc[i] * v;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
a = this._lineVerticesHighMerc;
|
|
1086
|
+
b = this._lineVerticesLowMerc;
|
|
1087
|
+
l = geometry._lineVerticesLength;
|
|
1088
|
+
ind = geometry._lineVerticesHandlerIndex;
|
|
1089
|
+
for (i = 0; i < l; i++) {
|
|
1090
|
+
a[ind + i] = geometry._lineVerticesHighMerc[i] * v;
|
|
1091
|
+
b[ind + i] = geometry._lineVerticesLowMerc[i] * v;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
this._changedBuffers[POLYVERTICES_BUFFER] = true;
|
|
1095
|
+
this._changedBuffers[LINEVERTICES_BUFFER] = true;
|
|
1096
|
+
|
|
1097
|
+
!this._updatedGeometry[geometry._id] && this._updatedGeometryArr.push(geometry);
|
|
1098
|
+
this._updatedGeometry[geometry._id] = true;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
setPolyColorArr(geometry, color) {
|
|
1102
|
+
var index = geometry._polyVerticesHandlerIndex * 2, // ... / 2 * 4
|
|
1103
|
+
size = index + geometry._polyVerticesLength * 2; // ... / 2 * 4
|
|
1104
|
+
var a = this._polyColors;
|
|
1105
|
+
for (var i = index; i < size; i += 4) {
|
|
1106
|
+
a[i] = color.x;
|
|
1107
|
+
a[i + 1] = color.y;
|
|
1108
|
+
a[i + 2] = color.z;
|
|
1109
|
+
a[i + 3] = color.w;
|
|
1110
|
+
}
|
|
1111
|
+
this._changedBuffers[POLYCOLORS_BUFFER] = true;
|
|
1112
|
+
!this._updatedGeometry[geometry._id] && this._updatedGeometryArr.push(geometry);
|
|
1113
|
+
this._updatedGeometry[geometry._id] = true;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
setLineStrokeColorArr(geometry, color) {
|
|
1117
|
+
var index = geometry._lineColorsHandlerIndex,
|
|
1118
|
+
size = index + geometry._lineColorsLength;
|
|
1119
|
+
var a = this._lineStrokeColors;
|
|
1120
|
+
for (var i = index; i < size; i += 4) {
|
|
1121
|
+
a[i] = color.x;
|
|
1122
|
+
a[i + 1] = color.y;
|
|
1123
|
+
a[i + 2] = color.z;
|
|
1124
|
+
a[i + 3] = color.w;
|
|
1125
|
+
}
|
|
1126
|
+
this._changedBuffers[LINESTROKECOLORS_BUFFER] = true;
|
|
1127
|
+
!this._updatedGeometry[geometry._id] && this._updatedGeometryArr.push(geometry);
|
|
1128
|
+
this._updatedGeometry[geometry._id] = true;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
setLineColorArr(geometry, color) {
|
|
1132
|
+
var index = geometry._lineColorsHandlerIndex,
|
|
1133
|
+
size = index + geometry._lineColorsLength;
|
|
1134
|
+
var a = this._lineColors;
|
|
1135
|
+
for (var i = index; i < size; i += 4) {
|
|
1136
|
+
a[i] = color.x;
|
|
1137
|
+
a[i + 1] = color.y;
|
|
1138
|
+
a[i + 2] = color.z;
|
|
1139
|
+
a[i + 3] = color.w;
|
|
1140
|
+
}
|
|
1141
|
+
this._changedBuffers[LINECOLORS_BUFFER] = true;
|
|
1142
|
+
!this._updatedGeometry[geometry._id] && this._updatedGeometryArr.push(geometry);
|
|
1143
|
+
this._updatedGeometry[geometry._id] = true;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
setLineStrokeArr(geometry, width) {
|
|
1147
|
+
var index = geometry._lineStrokesHandlerIndex,
|
|
1148
|
+
size = index + geometry._lineStrokesLength;
|
|
1149
|
+
var a = this._lineStrokes;
|
|
1150
|
+
for (var i = index; i < size; i++) {
|
|
1151
|
+
a[i] = width;
|
|
1152
|
+
}
|
|
1153
|
+
this._changedBuffers[LINESTROKES_BUFFER] = true;
|
|
1154
|
+
!this._updatedGeometry[geometry._id] && this._updatedGeometryArr.push(geometry);
|
|
1155
|
+
this._updatedGeometry[geometry._id] = true;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
setLineThicknessArr(geometry, width) {
|
|
1159
|
+
var index = geometry._lineThicknessHandlerIndex,
|
|
1160
|
+
size = index + geometry._lineThicknessLength;
|
|
1161
|
+
var a = this._lineThickness;
|
|
1162
|
+
for (var i = index; i < size; i++) {
|
|
1163
|
+
a[i] = width;
|
|
1164
|
+
}
|
|
1165
|
+
this._changedBuffers[LINETHICKNESS_BUFFER] = true;
|
|
1166
|
+
!this._updatedGeometry[geometry._id] && this._updatedGeometryArr.push(geometry);
|
|
1167
|
+
this._updatedGeometry[geometry._id] = true;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
bringToFront(geometry) {
|
|
1171
|
+
var polyIndexes = this._polyIndexes.splice(
|
|
1172
|
+
geometry._polyIndexesHandlerIndex,
|
|
1173
|
+
geometry._polyIndexesLength
|
|
1174
|
+
);
|
|
1175
|
+
var lineIndexes = this._lineIndexes.splice(
|
|
1176
|
+
geometry._lineIndexesHandlerIndex,
|
|
1177
|
+
geometry._lineIndexesLength
|
|
1178
|
+
);
|
|
1179
|
+
|
|
1180
|
+
this._geometries.splice(geometry._handlerIndex, 1);
|
|
1181
|
+
|
|
1182
|
+
var g = this._geometries;
|
|
1183
|
+
for (var i = geometry._handlerIndex; i < g.length; i++) {
|
|
1184
|
+
var gi = g[i];
|
|
1185
|
+
gi._handlerIndex = i;
|
|
1186
|
+
gi._polyIndexesHandlerIndex -= geometry._polyIndexesLength;
|
|
1187
|
+
gi._lineIndexesHandlerIndex -= geometry._lineIndexesLength;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
geometry._polyIndexesHandlerIndex = this._polyIndexes.length;
|
|
1191
|
+
geometry._lineIndexesHandlerIndex = this._lineIndexes.length;
|
|
1192
|
+
|
|
1193
|
+
geometry._handlerIndex = this._geometries.length;
|
|
1194
|
+
this._geometries.push(geometry);
|
|
1195
|
+
|
|
1196
|
+
this._polyIndexes.push.apply(this._polyIndexes, polyIndexes);
|
|
1197
|
+
this._lineIndexes.push.apply(this._lineIndexes, lineIndexes);
|
|
1198
|
+
|
|
1199
|
+
this._changedBuffers[POLYINDEXES_BUFFER] = true;
|
|
1200
|
+
this._changedBuffers[LINEINDEXES_BUFFER] = true;
|
|
1201
|
+
|
|
1202
|
+
!this._updatedGeometry[geometry._id] && this._updatedGeometryArr.push(geometry);
|
|
1203
|
+
this._updatedGeometry[geometry._id] = true;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
createPolyVerticesBuffer() {
|
|
1207
|
+
var h = this._handler;
|
|
1208
|
+
h.gl.deleteBuffer(this._polyVerticesHighBufferMerc);
|
|
1209
|
+
this._polyVerticesHighBufferMerc = h.createArrayBuffer(
|
|
1210
|
+
new Float32Array(this._polyVerticesHighMerc),
|
|
1211
|
+
2,
|
|
1212
|
+
this._polyVerticesHighMerc.length / 2
|
|
1213
|
+
);
|
|
1214
|
+
|
|
1215
|
+
h.gl.deleteBuffer(this._polyVerticesLowBufferMerc);
|
|
1216
|
+
this._polyVerticesLowBufferMerc = h.createArrayBuffer(
|
|
1217
|
+
new Float32Array(this._polyVerticesLowMerc),
|
|
1218
|
+
2,
|
|
1219
|
+
this._polyVerticesLowMerc.length / 2
|
|
1220
|
+
);
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
createPolyIndexesBuffer() {
|
|
1224
|
+
var h = this._handler;
|
|
1225
|
+
h.gl.deleteBuffer(this._polyIndexesBuffer);
|
|
1226
|
+
this._polyIndexesBuffer = h.createElementArrayBuffer(
|
|
1227
|
+
new Uint32Array(this._polyIndexes),
|
|
1228
|
+
1,
|
|
1229
|
+
this._polyIndexes.length
|
|
1230
|
+
);
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
createPolyColorsBuffer() {
|
|
1234
|
+
var h = this._handler;
|
|
1235
|
+
h.gl.deleteBuffer(this._polyColorsBuffer);
|
|
1236
|
+
this._polyColorsBuffer = h.createArrayBuffer(
|
|
1237
|
+
new Float32Array(this._polyColors),
|
|
1238
|
+
4,
|
|
1239
|
+
this._polyColors.length / 4
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
createPolyPickingColorsBuffer() {
|
|
1244
|
+
var h = this._handler;
|
|
1245
|
+
h.gl.deleteBuffer(this._polyPickingColorsBuffer);
|
|
1246
|
+
this._polyPickingColorsBuffer = h.createArrayBuffer(
|
|
1247
|
+
new Float32Array(this._polyPickingColors),
|
|
1248
|
+
4,
|
|
1249
|
+
this._polyPickingColors.length / 4
|
|
1250
|
+
);
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
createLineVerticesBuffer() {
|
|
1254
|
+
var h = this._handler;
|
|
1255
|
+
h.gl.deleteBuffer(this._lineVerticesHighBufferMerc);
|
|
1256
|
+
this._lineVerticesHighBufferMerc = h.createArrayBuffer(
|
|
1257
|
+
new Float32Array(this._lineVerticesHighMerc),
|
|
1258
|
+
2,
|
|
1259
|
+
this._lineVerticesHighMerc.length / 2
|
|
1260
|
+
);
|
|
1261
|
+
|
|
1262
|
+
h.gl.deleteBuffer(this._lineVerticesLowBufferMerc);
|
|
1263
|
+
this._lineVerticesLowBufferMerc = h.createArrayBuffer(
|
|
1264
|
+
new Float32Array(this._lineVerticesLowMerc),
|
|
1265
|
+
2,
|
|
1266
|
+
this._lineVerticesLowMerc.length / 2
|
|
1267
|
+
);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
createLineIndexesBuffer() {
|
|
1271
|
+
var h = this._handler;
|
|
1272
|
+
h.gl.deleteBuffer(this._lineIndexesBuffer);
|
|
1273
|
+
this._lineIndexesBuffer = h.createElementArrayBuffer(
|
|
1274
|
+
new Uint32Array(this._lineIndexes),
|
|
1275
|
+
1,
|
|
1276
|
+
this._lineIndexes.length
|
|
1277
|
+
);
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
createLineOrdersBuffer() {
|
|
1281
|
+
var h = this._handler;
|
|
1282
|
+
h.gl.deleteBuffer(this._lineOrdersBuffer);
|
|
1283
|
+
this._lineOrdersBuffer = h.createArrayBuffer(
|
|
1284
|
+
new Float32Array(this._lineOrders),
|
|
1285
|
+
1,
|
|
1286
|
+
this._lineOrders.length / 2
|
|
1287
|
+
);
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
createLineColorsBuffer() {
|
|
1291
|
+
var h = this._handler;
|
|
1292
|
+
h.gl.deleteBuffer(this._lineColorsBuffer);
|
|
1293
|
+
this._lineColorsBuffer = h.createArrayBuffer(
|
|
1294
|
+
new Float32Array(this._lineColors),
|
|
1295
|
+
4,
|
|
1296
|
+
this._lineColors.length / 4
|
|
1297
|
+
);
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
createLinePickingColorsBuffer() {
|
|
1301
|
+
var h = this._handler;
|
|
1302
|
+
h.gl.deleteBuffer(this._linePickingColorsBuffer);
|
|
1303
|
+
this._linePickingColorsBuffer = h.createArrayBuffer(
|
|
1304
|
+
new Float32Array(this._linePickingColors),
|
|
1305
|
+
4,
|
|
1306
|
+
this._linePickingColors.length / 4
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
createLineThicknessBuffer() {
|
|
1311
|
+
var h = this._handler;
|
|
1312
|
+
h.gl.deleteBuffer(this._lineThicknessBuffer);
|
|
1313
|
+
this._lineThicknessBuffer = h.createArrayBuffer(
|
|
1314
|
+
new Float32Array(this._lineThickness),
|
|
1315
|
+
1,
|
|
1316
|
+
this._lineThickness.length
|
|
1317
|
+
);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
createLineStrokesBuffer() {
|
|
1321
|
+
var h = this._handler;
|
|
1322
|
+
h.gl.deleteBuffer(this._lineStrokesBuffer);
|
|
1323
|
+
this._lineStrokesBuffer = h.createArrayBuffer(
|
|
1324
|
+
new Float32Array(this._lineStrokes),
|
|
1325
|
+
1,
|
|
1326
|
+
this._lineStrokes.length
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
createLineStrokeColorsBuffer() {
|
|
1331
|
+
var h = this._handler;
|
|
1332
|
+
h.gl.deleteBuffer(this._lineStrokeColorsBuffer);
|
|
1333
|
+
this._lineStrokeColorsBuffer = h.createArrayBuffer(
|
|
1334
|
+
new Float32Array(this._lineStrokeColors),
|
|
1335
|
+
4,
|
|
1336
|
+
this._lineStrokeColors.length / 4
|
|
1337
|
+
);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
export { GeometryHandler };
|