@pggis/pg-sdk 3.2.10 → 3.2.12
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/dist/index.js +10 -0
- package/dist/pggis.min.css +1 -1
- package/dist/pggis.min.js +14789 -35
- package/dist/resources/Workers/{chunk-MY3VNFGQ.js → chunk-23UFSGND.js} +7 -7
- package/dist/resources/Workers/{chunk-IQBYFRVW.js → chunk-2A75IWRS.js} +7 -7
- package/dist/resources/Workers/{chunk-VRGFV2UO.js → chunk-2FRVPMCS.js} +10 -10
- package/dist/resources/Workers/{chunk-46UD5ABS.js → chunk-2FWRMUTY.js} +4 -4
- package/dist/resources/Workers/{chunk-DTAIXKTO.js → chunk-2UPKWTMJ.js} +6 -6
- package/dist/resources/Workers/{chunk-6VJVYK2V.js → chunk-34FXV7D7.js} +2 -2
- package/dist/resources/Workers/{chunk-ODW7WYM4.js → chunk-3VAZEH7M.js} +2 -2
- package/dist/resources/Workers/{chunk-U2VCRRQW.js → chunk-4DO5W5XZ.js} +6 -6
- package/dist/resources/Workers/{chunk-VK3EJHWI.js → chunk-4H7PY4U5.js} +2 -2
- package/dist/resources/Workers/{chunk-RV7ZYPFT.js → chunk-5QULIR53.js} +4 -4
- package/dist/resources/Workers/{chunk-JY5YEZFA.js → chunk-7TC63SJW.js} +8 -8
- package/dist/resources/Workers/{chunk-JJ4VBOQ3.js → chunk-7ZFGPDJA.js} +4 -4
- package/dist/resources/Workers/{chunk-FP6GYBFX.js → chunk-A5DWLWCY.js} +10 -10
- package/dist/resources/Workers/{chunk-5M3U6ZMA.js → chunk-BBWDMCVU.js} +1 -1
- package/dist/resources/Workers/{chunk-WZU2YLWG.js → chunk-BG4UCVXN.js} +3 -3
- package/dist/resources/Workers/{chunk-5WQ523AW.js → chunk-BIKA3NRA.js} +5 -5
- package/dist/resources/Workers/{chunk-PTQQUQC3.js → chunk-BROJAZRZ.js} +13 -13
- package/dist/resources/Workers/{chunk-YUCVWAY6.js → chunk-DDUQAJ4P.js} +7 -7
- package/dist/resources/Workers/{chunk-2HJWSU7B.js → chunk-EERJKOAF.js} +4 -4
- package/dist/resources/Workers/{chunk-LZGHD6NY.js → chunk-EG6PTBY2.js} +15 -15
- package/dist/resources/Workers/{chunk-IX2JCCNM.js → chunk-EHWHNOEX.js} +1 -1
- package/dist/resources/Workers/{chunk-NKPBIX7F.js → chunk-F3YA3Y2Z.js} +1 -1
- package/dist/resources/Workers/{chunk-L2ZN645J.js → chunk-F4HFJMGM.js} +6 -6
- package/dist/resources/Workers/{chunk-F6SE42BK.js → chunk-FJKNFAKQ.js} +15 -472
- package/dist/resources/Workers/{chunk-PNBGBETF.js → chunk-FNIRWHJB.js} +10 -10
- package/dist/resources/Workers/{chunk-RAEV7K66.js → chunk-FZRIVR7Y.js} +5 -5
- package/dist/resources/Workers/{chunk-AIPU2VSX.js → chunk-G43QFN4Q.js} +6 -6
- package/dist/resources/Workers/{chunk-ZUA2UUNV.js → chunk-GATZHF3K.js} +2 -2
- package/dist/resources/Workers/{chunk-ZK5JOS3D.js → chunk-GRC2ZTAF.js} +14 -14
- package/dist/resources/Workers/{chunk-5YLJ77FF.js → chunk-HU6N6EXB.js} +10 -10
- package/dist/resources/Workers/{chunk-4EBHOMFX.js → chunk-I46ZRR5W.js} +17 -17
- package/dist/resources/Workers/{chunk-LZ7JIV3K.js → chunk-JURN7NPV.js} +17 -17
- package/dist/resources/Workers/{chunk-JCNXK6EL.js → chunk-KKCR2YOP.js} +11 -11
- package/dist/resources/Workers/{chunk-S6SKF6DT.js → chunk-LPR3YNP2.js} +5 -5
- package/dist/resources/Workers/{chunk-UDO6BFSF.js → chunk-M7ERACJJ.js} +13 -13
- package/dist/resources/Workers/{chunk-BZP4T2JJ.js → chunk-MDWEGWPA.js} +10 -10
- package/dist/resources/Workers/{chunk-72SANQJV.js → chunk-OGXZVPPM.js} +9 -5
- package/dist/resources/Workers/{chunk-AR5DNBJ4.js → chunk-PGSJK77E.js} +6 -6
- package/dist/resources/Workers/{chunk-GEJTYLCO.js → chunk-PPH7OFP3.js} +5 -5
- package/dist/resources/Workers/{chunk-OVLG3FRS.js → chunk-SH5USDPI.js} +6 -6
- package/dist/resources/Workers/{chunk-6HZQPRUS.js → chunk-SOWMRMWA.js} +1 -1
- package/dist/resources/Workers/{chunk-JXDC723O.js → chunk-STW2DGFI.js} +2 -2
- package/dist/resources/Workers/{chunk-5HDYHG3F.js → chunk-T3XIFPYR.js} +13 -13
- package/dist/resources/Workers/chunk-TTUZP4BO.js +501 -0
- package/dist/resources/Workers/{chunk-7XEAYGZK.js → chunk-UEXTBDBE.js} +10 -10
- package/dist/resources/Workers/{chunk-GV56Q4LU.js → chunk-VOXYEYJT.js} +11 -11
- package/dist/resources/Workers/{chunk-NY3K4IM3.js → chunk-X4356LRH.js} +12 -12
- package/dist/resources/Workers/{chunk-S4MAZ3SS.js → chunk-XGI5BXZY.js} +2 -2
- package/dist/resources/Workers/{chunk-UAEW6HKG.js → chunk-Y2ME2IJV.js} +13 -13
- package/dist/resources/Workers/{chunk-XWXM2O2R.js → chunk-Y5UQJLYE.js} +6 -6
- package/dist/resources/Workers/{chunk-QZAD5O7I.js → chunk-YJEBABKH.js} +7 -7
- package/dist/resources/Workers/{chunk-UGK3FCDY.js → chunk-YWTJ2B4B.js} +1 -1
- package/dist/resources/Workers/{chunk-R5X4OQT4.js → chunk-Z3TIFFGF.js} +7 -7
- package/dist/resources/Workers/{chunk-WBQCVXR3.js → chunk-ZT7KWISZ.js} +4 -4
- package/dist/resources/Workers/combineGeometry.js +24 -23
- package/dist/resources/Workers/createBoxGeometry.js +18 -17
- package/dist/resources/Workers/createBoxOutlineGeometry.js +16 -15
- package/dist/resources/Workers/createCircleGeometry.js +26 -25
- package/dist/resources/Workers/createCircleOutlineGeometry.js +19 -18
- package/dist/resources/Workers/createCoplanarPolygonGeometry.js +33 -32
- package/dist/resources/Workers/createCoplanarPolygonOutlineGeometry.js +31 -30
- package/dist/resources/Workers/createCorridorGeometry.js +29 -28
- package/dist/resources/Workers/createCorridorOutlineGeometry.js +28 -27
- package/dist/resources/Workers/createCylinderGeometry.js +20 -19
- package/dist/resources/Workers/createCylinderOutlineGeometry.js +18 -17
- package/dist/resources/Workers/createEllipseGeometry.js +26 -25
- package/dist/resources/Workers/createEllipseOutlineGeometry.js +19 -18
- package/dist/resources/Workers/createEllipsoidGeometry.js +19 -18
- package/dist/resources/Workers/createEllipsoidOutlineGeometry.js +18 -17
- package/dist/resources/Workers/createFrustumGeometry.js +18 -17
- package/dist/resources/Workers/createFrustumOutlineGeometry.js +18 -17
- package/dist/resources/Workers/createGeometry.js +54 -33
- package/dist/resources/Workers/createGroundPolylineGeometry.js +22 -21
- package/dist/resources/Workers/createPlaneGeometry.js +16 -15
- package/dist/resources/Workers/createPlaneOutlineGeometry.js +15 -14
- package/dist/resources/Workers/createPolygonGeometry.js +32 -31
- package/dist/resources/Workers/createPolygonOutlineGeometry.js +30 -29
- package/dist/resources/Workers/createPolylineGeometry.js +25 -24
- package/dist/resources/Workers/createPolylineVolumeGeometry.js +31 -30
- package/dist/resources/Workers/createPolylineVolumeOutlineGeometry.js +27 -26
- package/dist/resources/Workers/createRectangleGeometry.js +27 -26
- package/dist/resources/Workers/createRectangleOutlineGeometry.js +20 -19
- package/dist/resources/Workers/createSimplePolylineGeometry.js +23 -22
- package/dist/resources/Workers/createSphereGeometry.js +19 -18
- package/dist/resources/Workers/createSphereOutlineGeometry.js +18 -17
- package/dist/resources/Workers/createTaskProcessorWorker.js +3 -3
- package/dist/resources/Workers/createVectorTileClampedPolylines.js +14 -14
- package/dist/resources/Workers/createVectorTileGeometries.js +24 -23
- package/dist/resources/Workers/createVectorTilePoints.js +12 -12
- package/dist/resources/Workers/createVectorTilePolygons.js +22 -21
- package/dist/resources/Workers/createVectorTilePolylines.js +14 -14
- package/dist/resources/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -21
- package/dist/resources/Workers/createVerticesFromHeightmap.js +22 -21
- package/dist/resources/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -18
- package/dist/resources/Workers/createWallGeometry.js +24 -23
- package/dist/resources/Workers/createWallOutlineGeometry.js +23 -22
- package/dist/resources/Workers/decodeDraco.js +11 -11
- package/dist/resources/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/dist/resources/Workers/decodeI3S.js +601 -92
- package/dist/resources/Workers/transcodeKTX2.js +7 -7
- package/dist/resources/Workers/transferTypedArrayTest.js +1 -1
- package/dist/resources/Workers/upsampleQuantizedTerrainMesh.js +22 -21
- package/package.json +7 -10
- package/dist/index.cjs +0 -43
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* Cesium - https://github.com/CesiumGS/cesium
|
|
4
|
-
* Version 1.
|
|
4
|
+
* Version 1.115
|
|
5
5
|
*
|
|
6
6
|
* Copyright 2011-2022 Cesium Contributors
|
|
7
7
|
*
|
|
@@ -25,31 +25,55 @@
|
|
|
25
25
|
|
|
26
26
|
import {
|
|
27
27
|
require_draco_decoder_nodejs
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-GATZHF3K.js";
|
|
29
|
+
import {
|
|
30
|
+
Color_default
|
|
31
|
+
} from "./chunk-PGSJK77E.js";
|
|
29
32
|
import {
|
|
30
33
|
createTaskProcessorWorker_default
|
|
31
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-3VAZEH7M.js";
|
|
32
35
|
import {
|
|
33
36
|
WebMercatorProjection_default
|
|
34
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-2UPKWTMJ.js";
|
|
38
|
+
import "./chunk-TTUZP4BO.js";
|
|
35
39
|
import {
|
|
36
40
|
Cartesian3_default,
|
|
37
41
|
Cartographic_default,
|
|
38
42
|
Ellipsoid_default,
|
|
39
43
|
Matrix3_default
|
|
40
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-OGXZVPPM.js";
|
|
41
45
|
import {
|
|
42
46
|
Math_default
|
|
43
|
-
} from "./chunk-
|
|
44
|
-
import
|
|
45
|
-
|
|
47
|
+
} from "./chunk-5QULIR53.js";
|
|
48
|
+
import {
|
|
49
|
+
defaultValue_default
|
|
50
|
+
} from "./chunk-BBWDMCVU.js";
|
|
51
|
+
import {
|
|
52
|
+
Check_default
|
|
53
|
+
} from "./chunk-XGI5BXZY.js";
|
|
46
54
|
import {
|
|
47
55
|
__toESM,
|
|
48
56
|
defined_default
|
|
49
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-YWTJ2B4B.js";
|
|
50
58
|
|
|
51
59
|
// packages/engine/Source/Workers/decodeI3S.js
|
|
52
60
|
var import_draco_decoder_nodejs = __toESM(require_draco_decoder_nodejs(), 1);
|
|
61
|
+
|
|
62
|
+
// packages/engine/Source/Core/srgbToLinear.js
|
|
63
|
+
function srgbToLinear(value) {
|
|
64
|
+
Check_default.defined("value", value);
|
|
65
|
+
if (value <= 0.04045) {
|
|
66
|
+
return value * 0.07739938080495357;
|
|
67
|
+
}
|
|
68
|
+
return Math.pow(
|
|
69
|
+
// eslint-disable-next-line no-loss-of-precision
|
|
70
|
+
(value + 0.055) * 0.9478672985781991,
|
|
71
|
+
2.4
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
var srgbToLinear_default = srgbToLinear;
|
|
75
|
+
|
|
76
|
+
// packages/engine/Source/Workers/decodeI3S.js
|
|
53
77
|
var draco;
|
|
54
78
|
function bilinearInterpolate(tx, ty, h00, h10, h01, h11) {
|
|
55
79
|
const a = h00 * (1 - tx) + h10 * tx;
|
|
@@ -171,7 +195,317 @@ function cropUVs(vertexCount, uv0s, uvRegions) {
|
|
|
171
195
|
uv0s[vertexIndex * 2 + 1] += minV;
|
|
172
196
|
}
|
|
173
197
|
}
|
|
174
|
-
function
|
|
198
|
+
function generateIndexArray(vertexCount, indices, colors, splitGeometryByColorTransparency) {
|
|
199
|
+
const indexArray = new Uint32Array(vertexCount);
|
|
200
|
+
const vertexIndexFn = defined_default(indices) ? (vertexIndex) => indices[vertexIndex] : (vertexIndex) => vertexIndex;
|
|
201
|
+
let transparentVertexOffset = 0;
|
|
202
|
+
if (splitGeometryByColorTransparency && defined_default(colors)) {
|
|
203
|
+
const isVertexTransparentFn = (vertexIndex) => colors[vertexIndexFn(vertexIndex) * 4 + 3] < 255;
|
|
204
|
+
for (let vertexIndex = 0; vertexIndex < vertexCount; vertexIndex += 3) {
|
|
205
|
+
if (!isVertexTransparentFn(vertexIndex) && !isVertexTransparentFn(vertexIndex + 1) && !isVertexTransparentFn(vertexIndex + 2)) {
|
|
206
|
+
indexArray[transparentVertexOffset++] = vertexIndexFn(vertexIndex);
|
|
207
|
+
indexArray[transparentVertexOffset++] = vertexIndexFn(vertexIndex + 1);
|
|
208
|
+
indexArray[transparentVertexOffset++] = vertexIndexFn(vertexIndex + 2);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (transparentVertexOffset > 0) {
|
|
212
|
+
let offset = transparentVertexOffset;
|
|
213
|
+
for (let vertexIndex = 0; vertexIndex < vertexCount; vertexIndex += 3) {
|
|
214
|
+
if (isVertexTransparentFn(vertexIndex) || isVertexTransparentFn(vertexIndex + 1) || isVertexTransparentFn(vertexIndex + 2)) {
|
|
215
|
+
indexArray[offset++] = vertexIndexFn(vertexIndex);
|
|
216
|
+
indexArray[offset++] = vertexIndexFn(vertexIndex + 1);
|
|
217
|
+
indexArray[offset++] = vertexIndexFn(vertexIndex + 2);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
for (let vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex) {
|
|
222
|
+
indexArray[vertexIndex] = vertexIndexFn(vertexIndex);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
transparentVertexOffset = vertexCount;
|
|
227
|
+
for (let vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex) {
|
|
228
|
+
indexArray[vertexIndex] = vertexIndexFn(vertexIndex);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
indexArray,
|
|
233
|
+
transparentVertexOffset
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function getFeatureHash(symbologyData, outlinesHash, featureIndex) {
|
|
237
|
+
const featureHash = outlinesHash[featureIndex];
|
|
238
|
+
if (defined_default(featureHash)) {
|
|
239
|
+
return featureHash;
|
|
240
|
+
}
|
|
241
|
+
const newFeatureHash = outlinesHash[featureIndex] = {
|
|
242
|
+
positions: {},
|
|
243
|
+
indices: {},
|
|
244
|
+
edges: {}
|
|
245
|
+
};
|
|
246
|
+
const featureSymbology = defaultValue_default(
|
|
247
|
+
symbologyData[featureIndex],
|
|
248
|
+
symbologyData.default
|
|
249
|
+
);
|
|
250
|
+
newFeatureHash.hasOutline = defined_default(featureSymbology?.edges);
|
|
251
|
+
return newFeatureHash;
|
|
252
|
+
}
|
|
253
|
+
function addVertexToHash(indexHash, positionHash, vertexIndex, positions) {
|
|
254
|
+
if (!defined_default(indexHash[vertexIndex])) {
|
|
255
|
+
const startPositionIndex = vertexIndex * 3;
|
|
256
|
+
let coordinateHash = positionHash;
|
|
257
|
+
for (let index = 0; index < 3; index++) {
|
|
258
|
+
const coordinate = positions[startPositionIndex + index];
|
|
259
|
+
if (!defined_default(coordinateHash[coordinate])) {
|
|
260
|
+
coordinateHash[coordinate] = {};
|
|
261
|
+
}
|
|
262
|
+
coordinateHash = coordinateHash[coordinate];
|
|
263
|
+
}
|
|
264
|
+
if (!defined_default(coordinateHash.index)) {
|
|
265
|
+
coordinateHash.index = vertexIndex;
|
|
266
|
+
}
|
|
267
|
+
indexHash[vertexIndex] = coordinateHash.index;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function addEdgeToHash(edgeHash, vertexAIndex, vertexBIndex, vertexAIndexUnique, vertexBIndexUnique, normalIndex) {
|
|
271
|
+
let startVertexIndex;
|
|
272
|
+
let endVertexIndex;
|
|
273
|
+
if (vertexAIndexUnique < vertexBIndexUnique) {
|
|
274
|
+
startVertexIndex = vertexAIndexUnique;
|
|
275
|
+
endVertexIndex = vertexBIndexUnique;
|
|
276
|
+
} else {
|
|
277
|
+
startVertexIndex = vertexBIndexUnique;
|
|
278
|
+
endVertexIndex = vertexAIndexUnique;
|
|
279
|
+
}
|
|
280
|
+
let edgeStart = edgeHash[startVertexIndex];
|
|
281
|
+
if (!defined_default(edgeStart)) {
|
|
282
|
+
edgeStart = edgeHash[startVertexIndex] = {};
|
|
283
|
+
}
|
|
284
|
+
let edgeEnd = edgeStart[endVertexIndex];
|
|
285
|
+
if (!defined_default(edgeEnd)) {
|
|
286
|
+
edgeEnd = edgeStart[endVertexIndex] = {
|
|
287
|
+
normalsIndex: [],
|
|
288
|
+
outlines: []
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
edgeEnd.normalsIndex.push(normalIndex);
|
|
292
|
+
if (edgeEnd.outlines.length === 0 || vertexAIndex !== vertexAIndexUnique || vertexBIndex !== vertexBIndexUnique) {
|
|
293
|
+
edgeEnd.outlines.push(vertexAIndex, vertexBIndex);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function generateOutlinesHash(symbologyData, featureIndexArray, indexArray, positions) {
|
|
297
|
+
const outlinesHash = [];
|
|
298
|
+
for (let i = 0; i < indexArray.length; i += 3) {
|
|
299
|
+
const featureIndex = defined_default(featureIndexArray) ? featureIndexArray[indexArray[i]] : "default";
|
|
300
|
+
const featureHash = getFeatureHash(
|
|
301
|
+
symbologyData,
|
|
302
|
+
outlinesHash,
|
|
303
|
+
featureIndex
|
|
304
|
+
);
|
|
305
|
+
if (!featureHash.hasOutline) {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
const indexHash = featureHash.indices;
|
|
309
|
+
const positionHash = featureHash.positions;
|
|
310
|
+
for (let vertex = 0; vertex < 3; vertex++) {
|
|
311
|
+
const vertexIndex = indexArray[i + vertex];
|
|
312
|
+
addVertexToHash(indexHash, positionHash, vertexIndex, positions);
|
|
313
|
+
}
|
|
314
|
+
const edgeHash = featureHash.edges;
|
|
315
|
+
for (let vertex = 0; vertex < 3; vertex++) {
|
|
316
|
+
const vertexIndex = indexArray[i + vertex];
|
|
317
|
+
const nextVertexIndex = indexArray[i + (vertex + 1) % 3];
|
|
318
|
+
const uniqueVertexIndex = indexHash[vertexIndex];
|
|
319
|
+
const uniqueNextVertexIndex = indexHash[nextVertexIndex];
|
|
320
|
+
addEdgeToHash(
|
|
321
|
+
edgeHash,
|
|
322
|
+
vertexIndex,
|
|
323
|
+
nextVertexIndex,
|
|
324
|
+
uniqueVertexIndex,
|
|
325
|
+
uniqueNextVertexIndex,
|
|
326
|
+
i
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return outlinesHash;
|
|
331
|
+
}
|
|
332
|
+
var calculateFaceNormalA = new Cartesian3_default();
|
|
333
|
+
var calculateFaceNormalB = new Cartesian3_default();
|
|
334
|
+
var calculateFaceNormalC = new Cartesian3_default();
|
|
335
|
+
function calculateFaceNormal(normals, vertexAIndex, indexArray, positions) {
|
|
336
|
+
const positionAIndex = indexArray[vertexAIndex] * 3;
|
|
337
|
+
const positionBIndex = indexArray[vertexAIndex + 1] * 3;
|
|
338
|
+
const positionCIndex = indexArray[vertexAIndex + 2] * 3;
|
|
339
|
+
Cartesian3_default.fromArray(positions, positionAIndex, calculateFaceNormalA);
|
|
340
|
+
Cartesian3_default.fromArray(positions, positionBIndex, calculateFaceNormalB);
|
|
341
|
+
Cartesian3_default.fromArray(positions, positionCIndex, calculateFaceNormalC);
|
|
342
|
+
Cartesian3_default.subtract(
|
|
343
|
+
calculateFaceNormalB,
|
|
344
|
+
calculateFaceNormalA,
|
|
345
|
+
calculateFaceNormalB
|
|
346
|
+
);
|
|
347
|
+
Cartesian3_default.subtract(
|
|
348
|
+
calculateFaceNormalC,
|
|
349
|
+
calculateFaceNormalA,
|
|
350
|
+
calculateFaceNormalC
|
|
351
|
+
);
|
|
352
|
+
Cartesian3_default.cross(
|
|
353
|
+
calculateFaceNormalB,
|
|
354
|
+
calculateFaceNormalC,
|
|
355
|
+
calculateFaceNormalA
|
|
356
|
+
);
|
|
357
|
+
const magnitude = Cartesian3_default.magnitude(calculateFaceNormalA);
|
|
358
|
+
if (magnitude !== 0) {
|
|
359
|
+
Cartesian3_default.divideByScalar(
|
|
360
|
+
calculateFaceNormalA,
|
|
361
|
+
magnitude,
|
|
362
|
+
calculateFaceNormalA
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
const normalAIndex = vertexAIndex * 3;
|
|
366
|
+
const normalBIndex = (vertexAIndex + 1) * 3;
|
|
367
|
+
const normalCIndex = (vertexAIndex + 2) * 3;
|
|
368
|
+
Cartesian3_default.pack(calculateFaceNormalA, normals, normalAIndex);
|
|
369
|
+
Cartesian3_default.pack(calculateFaceNormalA, normals, normalBIndex);
|
|
370
|
+
Cartesian3_default.pack(calculateFaceNormalA, normals, normalCIndex);
|
|
371
|
+
}
|
|
372
|
+
var isEdgeSmoothA = new Cartesian3_default();
|
|
373
|
+
var isEdgeSmoothB = new Cartesian3_default();
|
|
374
|
+
function isEdgeSmooth(normals, normalAIndex, normalBIndex) {
|
|
375
|
+
Cartesian3_default.fromArray(normals, normalAIndex, isEdgeSmoothA);
|
|
376
|
+
Cartesian3_default.fromArray(normals, normalBIndex, isEdgeSmoothB);
|
|
377
|
+
const cosine = Cartesian3_default.dot(isEdgeSmoothA, isEdgeSmoothB);
|
|
378
|
+
const sine = Cartesian3_default.magnitude(
|
|
379
|
+
Cartesian3_default.cross(isEdgeSmoothA, isEdgeSmoothB, isEdgeSmoothA)
|
|
380
|
+
);
|
|
381
|
+
return Math.atan2(sine, cosine) < 0.25;
|
|
382
|
+
}
|
|
383
|
+
function addOutlinesForEdge(outlines, edgeData, indexArray, positions, normals) {
|
|
384
|
+
if (edgeData.normalsIndex.length > 1) {
|
|
385
|
+
const normalsByIndex = positions.length === normals.length;
|
|
386
|
+
for (let indexA = 0; indexA < edgeData.normalsIndex.length; indexA++) {
|
|
387
|
+
const vertexAIndex = edgeData.normalsIndex[indexA];
|
|
388
|
+
if (!defined_default(normals[vertexAIndex * 3])) {
|
|
389
|
+
calculateFaceNormal(normals, vertexAIndex, indexArray, positions);
|
|
390
|
+
}
|
|
391
|
+
if (indexA === 0) {
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
for (let indexB = 0; indexB < indexA; indexB++) {
|
|
395
|
+
const vertexBIndex = edgeData.normalsIndex[indexB];
|
|
396
|
+
const normalAIndex = normalsByIndex ? indexArray[vertexAIndex] * 3 : vertexAIndex * 3;
|
|
397
|
+
const normalBIndex = normalsByIndex ? indexArray[vertexBIndex] * 3 : vertexBIndex * 3;
|
|
398
|
+
if (isEdgeSmooth(normals, normalAIndex, normalBIndex)) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
outlines.push(...edgeData.outlines);
|
|
405
|
+
}
|
|
406
|
+
function addOutlinesForFeature(outlines, edgeHash, indexArray, positions, normals) {
|
|
407
|
+
const edgeStartKeys = Object.keys(edgeHash);
|
|
408
|
+
for (let startIndex = 0; startIndex < edgeStartKeys.length; startIndex++) {
|
|
409
|
+
const edgeEnds = edgeHash[edgeStartKeys[startIndex]];
|
|
410
|
+
const edgeEndKeys = Object.keys(edgeEnds);
|
|
411
|
+
for (let endIndex = 0; endIndex < edgeEndKeys.length; endIndex++) {
|
|
412
|
+
const edgeData = edgeEnds[edgeEndKeys[endIndex]];
|
|
413
|
+
addOutlinesForEdge(outlines, edgeData, indexArray, positions, normals);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function generateOutlinesFromHash(outlinesHash, indexArray, positions, normals) {
|
|
418
|
+
const outlines = [];
|
|
419
|
+
const features = Object.keys(outlinesHash);
|
|
420
|
+
for (let featureIndex = 0; featureIndex < features.length; featureIndex++) {
|
|
421
|
+
const edgeHash = outlinesHash[features[featureIndex]].edges;
|
|
422
|
+
addOutlinesForFeature(outlines, edgeHash, indexArray, positions, normals);
|
|
423
|
+
}
|
|
424
|
+
return outlines;
|
|
425
|
+
}
|
|
426
|
+
function generateOutlinesIndexArray(symbologyData, featureIndexArray, indexArray, positions, normals) {
|
|
427
|
+
if (!defined_default(symbologyData) || Object.keys(symbologyData).length === 0) {
|
|
428
|
+
return void 0;
|
|
429
|
+
}
|
|
430
|
+
const outlinesHash = generateOutlinesHash(
|
|
431
|
+
symbologyData,
|
|
432
|
+
featureIndexArray,
|
|
433
|
+
indexArray,
|
|
434
|
+
positions
|
|
435
|
+
);
|
|
436
|
+
if (!defined_default(normals) || indexArray.length * 3 !== normals.length) {
|
|
437
|
+
normals = [];
|
|
438
|
+
}
|
|
439
|
+
const outlines = generateOutlinesFromHash(
|
|
440
|
+
outlinesHash,
|
|
441
|
+
indexArray,
|
|
442
|
+
positions,
|
|
443
|
+
normals
|
|
444
|
+
);
|
|
445
|
+
const outlinesIndexArray = outlines.length > 0 ? new Uint32Array(outlines) : void 0;
|
|
446
|
+
return outlinesIndexArray;
|
|
447
|
+
}
|
|
448
|
+
function convertColorsArray(colors) {
|
|
449
|
+
const colorsArray = new Float32Array(colors.length);
|
|
450
|
+
for (let index = 0; index < colors.length; index += 4) {
|
|
451
|
+
colorsArray[index] = srgbToLinear_default(Color_default.byteToFloat(colors[index]));
|
|
452
|
+
colorsArray[index + 1] = srgbToLinear_default(Color_default.byteToFloat(colors[index + 1]));
|
|
453
|
+
colorsArray[index + 2] = srgbToLinear_default(Color_default.byteToFloat(colors[index + 2]));
|
|
454
|
+
colorsArray[index + 3] = Color_default.byteToFloat(colors[index + 3]);
|
|
455
|
+
}
|
|
456
|
+
return colorsArray;
|
|
457
|
+
}
|
|
458
|
+
function generateNormals(vertexCount, indices, positions, normals, uv0s, colors, featureIndex) {
|
|
459
|
+
const result = {
|
|
460
|
+
normals: void 0,
|
|
461
|
+
positions: void 0,
|
|
462
|
+
uv0s: void 0,
|
|
463
|
+
colors: void 0,
|
|
464
|
+
featureIndex: void 0,
|
|
465
|
+
vertexCount: void 0
|
|
466
|
+
};
|
|
467
|
+
if (vertexCount === 0 || !defined_default(positions) || positions.length === 0 || defined_default(normals)) {
|
|
468
|
+
return result;
|
|
469
|
+
}
|
|
470
|
+
if (defined_default(indices)) {
|
|
471
|
+
result.vertexCount = indices.length;
|
|
472
|
+
result.positions = new Float32Array(indices.length * 3);
|
|
473
|
+
result.uv0s = defined_default(uv0s) ? new Float32Array(indices.length * 2) : void 0;
|
|
474
|
+
result.colors = defined_default(colors) ? new Uint8Array(indices.length * 4) : void 0;
|
|
475
|
+
result.featureIndex = defined_default(featureIndex) ? new Array(indices.length) : void 0;
|
|
476
|
+
for (let i = 0; i < indices.length; i++) {
|
|
477
|
+
const index = indices[i];
|
|
478
|
+
result.positions[i * 3] = positions[index * 3];
|
|
479
|
+
result.positions[i * 3 + 1] = positions[index * 3 + 1];
|
|
480
|
+
result.positions[i * 3 + 2] = positions[index * 3 + 2];
|
|
481
|
+
if (defined_default(result.uv0s)) {
|
|
482
|
+
result.uv0s[i * 2] = uv0s[index * 2];
|
|
483
|
+
result.uv0s[i * 2 + 1] = uv0s[index * 2 + 1];
|
|
484
|
+
}
|
|
485
|
+
if (defined_default(result.colors)) {
|
|
486
|
+
result.colors[i * 4] = colors[index * 4];
|
|
487
|
+
result.colors[i * 4 + 1] = colors[index * 4 + 1];
|
|
488
|
+
result.colors[i * 4 + 2] = colors[index * 4 + 2];
|
|
489
|
+
result.colors[i * 4 + 3] = colors[index * 4 + 3];
|
|
490
|
+
}
|
|
491
|
+
if (defined_default(result.featureIndex)) {
|
|
492
|
+
result.featureIndex[i] = featureIndex[index];
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
vertexCount = indices.length;
|
|
496
|
+
positions = result.positions;
|
|
497
|
+
}
|
|
498
|
+
indices = new Array(vertexCount);
|
|
499
|
+
for (let i = 0; i < vertexCount; i++) {
|
|
500
|
+
indices[i] = i;
|
|
501
|
+
}
|
|
502
|
+
result.normals = new Float32Array(indices.length * 3);
|
|
503
|
+
for (let i = 0; i < indices.length; i += 3) {
|
|
504
|
+
calculateFaceNormal(result.normals, i, indices, positions);
|
|
505
|
+
}
|
|
506
|
+
return result;
|
|
507
|
+
}
|
|
508
|
+
function generateGltfBuffer(vertexCount, indices, positions, normals, uv0s, colors, featureIndex, parameters) {
|
|
175
509
|
if (vertexCount === 0 || !defined_default(positions) || positions.length === 0) {
|
|
176
510
|
return {
|
|
177
511
|
buffers: [],
|
|
@@ -188,22 +522,45 @@ function generateGltfBuffer(vertexCount, indices, positions, normals, uv0s, colo
|
|
|
188
522
|
const meshes = [];
|
|
189
523
|
const nodes = [];
|
|
190
524
|
const nodesInScene = [];
|
|
525
|
+
const rootExtensions = {};
|
|
526
|
+
const extensionsUsed = [];
|
|
191
527
|
if (defined_default(indices)) {
|
|
192
528
|
vertexCount = indices.length;
|
|
193
529
|
}
|
|
194
|
-
const indexArray =
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
for (let newVertexIndex = 0; newVertexIndex < vertexCount; ++newVertexIndex) {
|
|
201
|
-
indexArray[newVertexIndex] = newVertexIndex;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
530
|
+
const { indexArray, transparentVertexOffset } = generateIndexArray(
|
|
531
|
+
vertexCount,
|
|
532
|
+
indices,
|
|
533
|
+
colors,
|
|
534
|
+
parameters.splitGeometryByColorTransparency
|
|
535
|
+
);
|
|
204
536
|
const indicesBlob = new Blob([indexArray], { type: "application/binary" });
|
|
205
537
|
const indicesURL = URL.createObjectURL(indicesBlob);
|
|
206
538
|
const endIndex = vertexCount;
|
|
539
|
+
const featureIndexArray = parameters.enableFeatures && defined_default(featureIndex) ? new Float32Array(featureIndex.length) : void 0;
|
|
540
|
+
let featureCount = 0;
|
|
541
|
+
if (defined_default(featureIndexArray)) {
|
|
542
|
+
for (let index = 0; index < featureIndex.length; ++index) {
|
|
543
|
+
featureIndexArray[index] = featureIndex[index];
|
|
544
|
+
const countByIndex = featureIndex[index] + 1;
|
|
545
|
+
if (featureCount < countByIndex) {
|
|
546
|
+
featureCount = countByIndex;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
let outlinesIndicesURL;
|
|
551
|
+
const outlinesIndexArray = generateOutlinesIndexArray(
|
|
552
|
+
parameters.symbologyData,
|
|
553
|
+
featureIndex,
|
|
554
|
+
indexArray,
|
|
555
|
+
positions,
|
|
556
|
+
normals
|
|
557
|
+
);
|
|
558
|
+
if (defined_default(outlinesIndexArray)) {
|
|
559
|
+
const outlinesIndicesBlob = new Blob([outlinesIndexArray], {
|
|
560
|
+
type: "application/binary"
|
|
561
|
+
});
|
|
562
|
+
outlinesIndicesURL = URL.createObjectURL(outlinesIndicesBlob);
|
|
563
|
+
}
|
|
207
564
|
const meshPositions = positions.subarray(0, endIndex * 3);
|
|
208
565
|
const positionsBlob = new Blob([meshPositions], {
|
|
209
566
|
type: "application/binary"
|
|
@@ -237,7 +594,7 @@ function generateGltfBuffer(vertexCount, indices, positions, normals, uv0s, colo
|
|
|
237
594
|
const uv0Blob = new Blob([meshUv0s], { type: "application/binary" });
|
|
238
595
|
uv0URL = URL.createObjectURL(uv0Blob);
|
|
239
596
|
}
|
|
240
|
-
const meshColorsInBytes = defined_default(colors) ? colors.subarray(0, endIndex * 4) : void 0;
|
|
597
|
+
const meshColorsInBytes = defined_default(colors) ? convertColorsArray(colors.subarray(0, endIndex * 4)) : void 0;
|
|
241
598
|
let colorsURL;
|
|
242
599
|
if (defined_default(meshColorsInBytes)) {
|
|
243
600
|
const colorsBlob = new Blob([meshColorsInBytes], {
|
|
@@ -245,127 +602,254 @@ function generateGltfBuffer(vertexCount, indices, positions, normals, uv0s, colo
|
|
|
245
602
|
});
|
|
246
603
|
colorsURL = URL.createObjectURL(colorsBlob);
|
|
247
604
|
}
|
|
248
|
-
const
|
|
249
|
-
let
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
605
|
+
const meshFeatureId0 = defined_default(featureIndexArray) ? featureIndexArray.subarray(0, endIndex) : void 0;
|
|
606
|
+
let featureId0URL;
|
|
607
|
+
if (defined_default(meshFeatureId0)) {
|
|
608
|
+
const featureId0Blob = new Blob([meshFeatureId0], {
|
|
609
|
+
type: "application/binary"
|
|
610
|
+
});
|
|
611
|
+
featureId0URL = URL.createObjectURL(featureId0Blob);
|
|
612
|
+
}
|
|
613
|
+
const meshPropertyTable0 = defined_default(featureIndexArray) ? new Float32Array(featureCount) : void 0;
|
|
614
|
+
let propertyTable0URL;
|
|
615
|
+
if (defined_default(meshPropertyTable0)) {
|
|
616
|
+
for (let index = 0; index < meshPropertyTable0.length; ++index) {
|
|
617
|
+
meshPropertyTable0[index] = index;
|
|
618
|
+
}
|
|
619
|
+
const propertyTable0Blob = new Blob([meshPropertyTable0], {
|
|
620
|
+
type: "application/binary"
|
|
621
|
+
});
|
|
622
|
+
propertyTable0URL = URL.createObjectURL(propertyTable0Blob);
|
|
623
|
+
}
|
|
254
624
|
const attributes = {};
|
|
255
|
-
|
|
625
|
+
const extensions = {};
|
|
626
|
+
attributes.POSITION = accessors.length;
|
|
256
627
|
buffers.push({
|
|
257
628
|
uri: positionsURL,
|
|
258
629
|
byteLength: meshPositions.byteLength
|
|
259
630
|
});
|
|
260
631
|
bufferViews.push({
|
|
261
|
-
buffer:
|
|
632
|
+
buffer: buffers.length - 1,
|
|
262
633
|
byteOffset: 0,
|
|
263
634
|
byteLength: meshPositions.byteLength,
|
|
264
635
|
target: 34962
|
|
265
636
|
});
|
|
266
637
|
accessors.push({
|
|
267
|
-
bufferView:
|
|
638
|
+
bufferView: bufferViews.length - 1,
|
|
268
639
|
byteOffset: 0,
|
|
269
640
|
componentType: 5126,
|
|
270
|
-
count:
|
|
641
|
+
count: meshPositions.length / 3,
|
|
271
642
|
type: "VEC3",
|
|
272
643
|
max: [minX, minY, minZ],
|
|
273
644
|
min: [maxX, maxY, maxZ]
|
|
274
645
|
});
|
|
275
646
|
if (defined_default(normalsURL)) {
|
|
276
|
-
|
|
277
|
-
normalIndex = currentIndex;
|
|
278
|
-
attributes.NORMAL = normalIndex;
|
|
647
|
+
attributes.NORMAL = accessors.length;
|
|
279
648
|
buffers.push({
|
|
280
649
|
uri: normalsURL,
|
|
281
650
|
byteLength: meshNormals.byteLength
|
|
282
651
|
});
|
|
283
652
|
bufferViews.push({
|
|
284
|
-
buffer:
|
|
653
|
+
buffer: buffers.length - 1,
|
|
285
654
|
byteOffset: 0,
|
|
286
655
|
byteLength: meshNormals.byteLength,
|
|
287
656
|
target: 34962
|
|
288
657
|
});
|
|
289
658
|
accessors.push({
|
|
290
|
-
bufferView:
|
|
659
|
+
bufferView: bufferViews.length - 1,
|
|
291
660
|
byteOffset: 0,
|
|
292
661
|
componentType: 5126,
|
|
293
|
-
count:
|
|
662
|
+
count: meshNormals.length / 3,
|
|
294
663
|
type: "VEC3"
|
|
295
664
|
});
|
|
296
665
|
}
|
|
297
666
|
if (defined_default(uv0URL)) {
|
|
298
|
-
|
|
299
|
-
uv0Index = currentIndex;
|
|
300
|
-
attributes.TEXCOORD_0 = uv0Index;
|
|
667
|
+
attributes.TEXCOORD_0 = accessors.length;
|
|
301
668
|
buffers.push({
|
|
302
669
|
uri: uv0URL,
|
|
303
670
|
byteLength: meshUv0s.byteLength
|
|
304
671
|
});
|
|
305
672
|
bufferViews.push({
|
|
306
|
-
buffer:
|
|
673
|
+
buffer: buffers.length - 1,
|
|
307
674
|
byteOffset: 0,
|
|
308
675
|
byteLength: meshUv0s.byteLength,
|
|
309
676
|
target: 34962
|
|
310
677
|
});
|
|
311
678
|
accessors.push({
|
|
312
|
-
bufferView:
|
|
679
|
+
bufferView: bufferViews.length - 1,
|
|
313
680
|
byteOffset: 0,
|
|
314
681
|
componentType: 5126,
|
|
315
|
-
count:
|
|
682
|
+
count: meshUv0s.length / 2,
|
|
316
683
|
type: "VEC2"
|
|
317
684
|
});
|
|
318
685
|
}
|
|
319
686
|
if (defined_default(colorsURL)) {
|
|
320
|
-
|
|
321
|
-
colorIndex = currentIndex;
|
|
322
|
-
attributes.COLOR_0 = colorIndex;
|
|
687
|
+
attributes.COLOR_0 = accessors.length;
|
|
323
688
|
buffers.push({
|
|
324
689
|
uri: colorsURL,
|
|
325
690
|
byteLength: meshColorsInBytes.byteLength
|
|
326
691
|
});
|
|
327
692
|
bufferViews.push({
|
|
328
|
-
buffer:
|
|
693
|
+
buffer: buffers.length - 1,
|
|
329
694
|
byteOffset: 0,
|
|
330
695
|
byteLength: meshColorsInBytes.byteLength,
|
|
331
696
|
target: 34962
|
|
332
697
|
});
|
|
333
698
|
accessors.push({
|
|
334
|
-
bufferView:
|
|
699
|
+
bufferView: bufferViews.length - 1,
|
|
335
700
|
byteOffset: 0,
|
|
336
|
-
componentType:
|
|
337
|
-
|
|
338
|
-
count: vertexCount,
|
|
701
|
+
componentType: 5126,
|
|
702
|
+
count: meshColorsInBytes.length / 4,
|
|
339
703
|
type: "VEC4"
|
|
340
704
|
});
|
|
341
705
|
}
|
|
342
|
-
|
|
343
|
-
|
|
706
|
+
if (defined_default(featureId0URL)) {
|
|
707
|
+
attributes._FEATURE_ID_0 = accessors.length;
|
|
708
|
+
buffers.push({
|
|
709
|
+
uri: featureId0URL,
|
|
710
|
+
byteLength: meshFeatureId0.byteLength
|
|
711
|
+
});
|
|
712
|
+
bufferViews.push({
|
|
713
|
+
buffer: buffers.length - 1,
|
|
714
|
+
byteOffset: 0,
|
|
715
|
+
byteLength: meshFeatureId0.byteLength,
|
|
716
|
+
target: 34963
|
|
717
|
+
});
|
|
718
|
+
accessors.push({
|
|
719
|
+
bufferView: bufferViews.length - 1,
|
|
720
|
+
byteOffset: 0,
|
|
721
|
+
componentType: 5126,
|
|
722
|
+
count: meshFeatureId0.length,
|
|
723
|
+
type: "SCALAR"
|
|
724
|
+
});
|
|
725
|
+
extensions.EXT_mesh_features = {
|
|
726
|
+
featureIds: [
|
|
727
|
+
{
|
|
728
|
+
attribute: 0,
|
|
729
|
+
propertyTable: 0,
|
|
730
|
+
featureCount
|
|
731
|
+
}
|
|
732
|
+
]
|
|
733
|
+
};
|
|
734
|
+
extensionsUsed.push("EXT_mesh_features");
|
|
735
|
+
}
|
|
736
|
+
if (defined_default(propertyTable0URL)) {
|
|
737
|
+
buffers.push({
|
|
738
|
+
uri: propertyTable0URL,
|
|
739
|
+
byteLength: meshPropertyTable0.byteLength
|
|
740
|
+
});
|
|
741
|
+
bufferViews.push({
|
|
742
|
+
buffer: buffers.length - 1,
|
|
743
|
+
byteOffset: 0,
|
|
744
|
+
byteLength: meshPropertyTable0.byteLength,
|
|
745
|
+
target: 34963
|
|
746
|
+
});
|
|
747
|
+
rootExtensions.EXT_structural_metadata = {
|
|
748
|
+
schema: {
|
|
749
|
+
id: "i3s-metadata-schema-001",
|
|
750
|
+
name: "I3S metadata schema 001",
|
|
751
|
+
description: "The schema for I3S metadata",
|
|
752
|
+
version: "1.0",
|
|
753
|
+
classes: {
|
|
754
|
+
feature: {
|
|
755
|
+
name: "feature",
|
|
756
|
+
description: "Feature metadata",
|
|
757
|
+
properties: {
|
|
758
|
+
index: {
|
|
759
|
+
description: "The feature index",
|
|
760
|
+
type: "SCALAR",
|
|
761
|
+
componentType: "FLOAT32",
|
|
762
|
+
required: true
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
},
|
|
768
|
+
propertyTables: [
|
|
769
|
+
{
|
|
770
|
+
name: "feature-indices-mapping",
|
|
771
|
+
class: "feature",
|
|
772
|
+
count: featureCount,
|
|
773
|
+
properties: {
|
|
774
|
+
index: {
|
|
775
|
+
values: bufferViews.length - 1
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
]
|
|
780
|
+
};
|
|
781
|
+
extensionsUsed.push("EXT_structural_metadata");
|
|
782
|
+
}
|
|
783
|
+
if (defined_default(outlinesIndicesURL)) {
|
|
784
|
+
buffers.push({
|
|
785
|
+
uri: outlinesIndicesURL,
|
|
786
|
+
byteLength: outlinesIndexArray.byteLength
|
|
787
|
+
});
|
|
788
|
+
bufferViews.push({
|
|
789
|
+
buffer: buffers.length - 1,
|
|
790
|
+
byteOffset: 0,
|
|
791
|
+
byteLength: outlinesIndexArray.byteLength,
|
|
792
|
+
target: 34963
|
|
793
|
+
});
|
|
794
|
+
accessors.push({
|
|
795
|
+
bufferView: bufferViews.length - 1,
|
|
796
|
+
byteOffset: 0,
|
|
797
|
+
componentType: 5125,
|
|
798
|
+
count: outlinesIndexArray.length,
|
|
799
|
+
type: "SCALAR"
|
|
800
|
+
});
|
|
801
|
+
extensions.CESIUM_primitive_outline = {
|
|
802
|
+
indices: accessors.length - 1
|
|
803
|
+
};
|
|
804
|
+
extensionsUsed.push("CESIUM_primitive_outline");
|
|
805
|
+
}
|
|
344
806
|
buffers.push({
|
|
345
807
|
uri: indicesURL,
|
|
346
808
|
byteLength: indexArray.byteLength
|
|
347
809
|
});
|
|
348
810
|
bufferViews.push({
|
|
349
|
-
buffer:
|
|
811
|
+
buffer: buffers.length - 1,
|
|
350
812
|
byteOffset: 0,
|
|
351
813
|
byteLength: indexArray.byteLength,
|
|
352
814
|
target: 34963
|
|
353
815
|
});
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
816
|
+
const meshPrimitives = [];
|
|
817
|
+
if (transparentVertexOffset > 0) {
|
|
818
|
+
accessors.push({
|
|
819
|
+
bufferView: bufferViews.length - 1,
|
|
820
|
+
byteOffset: 0,
|
|
821
|
+
componentType: 5125,
|
|
822
|
+
count: transparentVertexOffset,
|
|
823
|
+
type: "SCALAR"
|
|
824
|
+
});
|
|
825
|
+
meshPrimitives.push({
|
|
826
|
+
attributes,
|
|
827
|
+
indices: accessors.length - 1,
|
|
828
|
+
material: meshPrimitives.length,
|
|
829
|
+
extensions
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
if (transparentVertexOffset < vertexCount) {
|
|
833
|
+
accessors.push({
|
|
834
|
+
bufferView: bufferViews.length - 1,
|
|
835
|
+
byteOffset: 4 * transparentVertexOffset,
|
|
836
|
+
// skip 4 bytes for each opaque vertex
|
|
837
|
+
componentType: 5125,
|
|
838
|
+
count: vertexCount - transparentVertexOffset,
|
|
839
|
+
type: "SCALAR"
|
|
840
|
+
});
|
|
841
|
+
meshPrimitives.push({
|
|
842
|
+
attributes,
|
|
843
|
+
indices: accessors.length - 1,
|
|
844
|
+
material: meshPrimitives.length,
|
|
845
|
+
extensions,
|
|
846
|
+
extra: {
|
|
847
|
+
isTransparent: true
|
|
367
848
|
}
|
|
368
|
-
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
meshes.push({
|
|
852
|
+
primitives: meshPrimitives
|
|
369
853
|
});
|
|
370
854
|
nodesInScene.push(0);
|
|
371
855
|
nodes.push({ mesh: 0 });
|
|
@@ -375,7 +859,9 @@ function generateGltfBuffer(vertexCount, indices, positions, normals, uv0s, colo
|
|
|
375
859
|
accessors,
|
|
376
860
|
meshes,
|
|
377
861
|
nodes,
|
|
378
|
-
nodesInScene
|
|
862
|
+
nodesInScene,
|
|
863
|
+
rootExtensions,
|
|
864
|
+
extensionsUsed
|
|
379
865
|
};
|
|
380
866
|
}
|
|
381
867
|
function decode(data, schema, bufferInfo, featureData) {
|
|
@@ -774,39 +1260,62 @@ function decodeAndCreateGltf(parameters) {
|
|
|
774
1260
|
geometryData["uv-region"]
|
|
775
1261
|
);
|
|
776
1262
|
}
|
|
777
|
-
|
|
778
|
-
geometryData.vertexCount,
|
|
779
|
-
geometryData.indices,
|
|
780
|
-
geometryData.positions,
|
|
781
|
-
geometryData.normals,
|
|
782
|
-
geometryData.uv0s,
|
|
783
|
-
geometryData.colors
|
|
784
|
-
);
|
|
785
|
-
const customAttributes = {};
|
|
1263
|
+
let featureIndex;
|
|
786
1264
|
if (defined_default(geometryData["feature-index"])) {
|
|
787
|
-
|
|
788
|
-
customAttributes.indices = geometryData.indices;
|
|
789
|
-
customAttributes.featureIndex = geometryData["feature-index"];
|
|
790
|
-
customAttributes.cartesianCenter = parameters.cartesianCenter;
|
|
791
|
-
customAttributes.parentRotation = parameters.parentRotation;
|
|
1265
|
+
featureIndex = geometryData["feature-index"];
|
|
792
1266
|
} else if (defined_default(geometryData["faceRange"])) {
|
|
793
|
-
|
|
794
|
-
customAttributes.indices = geometryData.indices;
|
|
795
|
-
customAttributes.sourceURL = parameters.url;
|
|
796
|
-
customAttributes.cartesianCenter = parameters.cartesianCenter;
|
|
797
|
-
customAttributes.parentRotation = parameters.parentRotation;
|
|
798
|
-
customAttributes.featureIndex = new Array(geometryData.positions.length);
|
|
1267
|
+
featureIndex = new Array(geometryData.vertexCount);
|
|
799
1268
|
for (let range = 0; range < geometryData["faceRange"].length - 1; range += 2) {
|
|
800
1269
|
const curIndex = range / 2;
|
|
801
1270
|
const rangeStart = geometryData["faceRange"][range];
|
|
802
1271
|
const rangeEnd = geometryData["faceRange"][range + 1];
|
|
803
1272
|
for (let i = rangeStart; i <= rangeEnd; i++) {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
1273
|
+
featureIndex[i * 3] = curIndex;
|
|
1274
|
+
featureIndex[i * 3 + 1] = curIndex;
|
|
1275
|
+
featureIndex[i * 3 + 2] = curIndex;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
if (parameters.calculateNormals) {
|
|
1280
|
+
const data = generateNormals(
|
|
1281
|
+
geometryData.vertexCount,
|
|
1282
|
+
geometryData.indices,
|
|
1283
|
+
geometryData.positions,
|
|
1284
|
+
geometryData.normals,
|
|
1285
|
+
geometryData.uv0s,
|
|
1286
|
+
geometryData.colors,
|
|
1287
|
+
featureIndex
|
|
1288
|
+
);
|
|
1289
|
+
if (defined_default(data.normals)) {
|
|
1290
|
+
geometryData.normals = data.normals;
|
|
1291
|
+
if (defined_default(data.vertexCount)) {
|
|
1292
|
+
geometryData.vertexCount = data.vertexCount;
|
|
1293
|
+
geometryData.indices = data.indices;
|
|
1294
|
+
geometryData.positions = data.positions;
|
|
1295
|
+
geometryData.uv0s = data.uv0s;
|
|
1296
|
+
geometryData.colors = data.colors;
|
|
1297
|
+
featureIndex = data.featureIndex;
|
|
807
1298
|
}
|
|
808
1299
|
}
|
|
809
1300
|
}
|
|
1301
|
+
const meshData = generateGltfBuffer(
|
|
1302
|
+
geometryData.vertexCount,
|
|
1303
|
+
geometryData.indices,
|
|
1304
|
+
geometryData.positions,
|
|
1305
|
+
geometryData.normals,
|
|
1306
|
+
geometryData.uv0s,
|
|
1307
|
+
geometryData.colors,
|
|
1308
|
+
featureIndex,
|
|
1309
|
+
parameters
|
|
1310
|
+
);
|
|
1311
|
+
const customAttributes = {
|
|
1312
|
+
positions: geometryData.positions,
|
|
1313
|
+
indices: geometryData.indices,
|
|
1314
|
+
featureIndex,
|
|
1315
|
+
sourceURL: parameters.url,
|
|
1316
|
+
cartesianCenter: parameters.cartesianCenter,
|
|
1317
|
+
parentRotation: parameters.parentRotation
|
|
1318
|
+
};
|
|
810
1319
|
meshData._customAttributes = customAttributes;
|
|
811
1320
|
const results = {
|
|
812
1321
|
meshData
|