1 line
27 KiB
Plaintext
1 line
27 KiB
Plaintext
|
{"version":3,"file":"createVectorTilePolygons.js","sources":["../../../../Source/WorkersES6/createVectorTilePolygons.js"],"sourcesContent":["import AttributeCompression from \"../Core/AttributeCompression.js\";\nimport Cartesian3 from \"../Core/Cartesian3.js\";\nimport Cartographic from \"../Core/Cartographic.js\";\nimport Color from \"../Core/Color.js\";\nimport defined from \"../Core/defined.js\";\nimport Ellipsoid from \"../Core/Ellipsoid.js\";\nimport IndexDatatype from \"../Core/IndexDatatype.js\";\nimport CesiumMath from \"../Core/Math.js\";\nimport OrientedBoundingBox from \"../Core/OrientedBoundingBox.js\";\nimport Rectangle from \"../Core/Rectangle.js\";\nimport createTaskProcessorWorker from \"./createTaskProcessorWorker.js\";\n\nconst scratchCenter = new Cartesian3();\nconst scratchEllipsoid = new Ellipsoid();\nconst scratchRectangle = new Rectangle();\nconst scratchScalars = {\n min: undefined,\n max: undefined,\n indexBytesPerElement: undefined,\n};\n\nfunction unpackBuffer(buffer) {\n const packedBuffer = new Float64Array(buffer);\n\n let offset = 0;\n scratchScalars.indexBytesPerElement = packedBuffer[offset++];\n\n scratchScalars.min = packedBuffer[offset++];\n scratchScalars.max = packedBuffer[offset++];\n\n Cartesian3.unpack(packedBuffer, offset, scratchCenter);\n offset += Cartesian3.packedLength;\n\n Ellipsoid.unpack(packedBuffer, offset, scratchEllipsoid);\n offset += Ellipsoid.packedLength;\n\n Rectangle.unpack(packedBuffer, offset, scratchRectangle);\n}\n\nfunction packedBatchedIndicesLength(batchedIndices) {\n const length = batchedIndices.length;\n let count = 0;\n for (let i = 0; i < length; ++i) {\n count += Color.packedLength + 3 + batchedIndices[i].batchIds.length;\n }\n return count;\n}\n\nfunction packBuffer(indexDatatype, boundingVolumes, batchedIndices) {\n const numBVs = boundingVolumes.length;\n const length =\n 1 +\n 1 +\n numBVs * OrientedBoundingBox.packedLength +\n 1 +\n packedBatchedIndicesLength(batchedIndices);\n\n const packedBuffer = new Float64Array(length);\n\n let offset = 0;\n packedBuffer[offset++] = indexDatatype;\n packedBuffer[offset++] = numBVs;\n\n for (let i = 0; i < numBVs; ++i) {\n OrientedBoundingBox.pack(boundingVolumes[i], packedBuffer, offset);\n offset += OrientedBoundingBox.packedLength;\n }\n\n const indicesLength = batchedIndices.length;\n packedBuffer[offset++] = indicesLength;\n\n for (let j = 0; j < indicesLength; ++j) {\n const batchedIndex = batchedIndices[j];\n\n Color.pack(batchedIndex.color, packedBuffer, offset);\n offset += Color.packedLength;\n\n packedBuffer[offset++] = batchedIndex.offset;\n packedBuffer[offset++] = batchedIndex.count;\n\n const batchIds = batchedIndex.batchIds;\n const batchIdsLength = batchIds.length;\n packedBuffer[offset++] = batchIdsLength;\n\n for (let k = 0; k < batchIdsLength; ++k) {\n packedBuffer[offset++] = batchIds[k];\n }\n }\n\n return packedBuffer;\n}\n\nconst maxShort = 32767;\n\nconst scratchEncodedPosition = new Cartesian3();\nconst scratchNormal = new Cartesian3();\nconst scratchScaledNormal = new Cartesian3();\nconst scratchMinHeightPosition = new Cartesian3();\nconst scratchMaxHeightPosition = new Cartesian3();\nconst scratchBVCartographic = new Cartographic();\nconst scratchBVRectangle = new Rectangle();\n\nfunction createVectorTilePolygons(parameters, transferableObjects) {\n unpackBuffer(parameters.packedBuffer);\n\n let indices;\n const indexBytesPerElement = scratchScalars.indexBytesPerElement;\n if (indexBytesPerElement === 2) {\n indices = new Uint16Array(parameters.indices);\n } else {\n indices = new Uint32Array(parameters.indices);\n }\n\n const positions = new Uint16Array(parameters.positions);\n const counts = new Uint32Array(parameters.counts);\n const indexCounts = new Uint32Array(parameters.indexCounts);\n const batchIds = new Uint32Array(parameters.batchIds);\n const batchTableColors = new Uint32Array(parameters.batchTableColors);\n\n const boundingVolumes = new Array(counts.length);\
|