1 line
32 KiB
Plaintext
1 line
32 KiB
Plaintext
|
{"version":3,"file":"createVectorTileClampedPolylines.js","sources":["../../../../Source/WorkersES6/createVectorTileClampedPolylines.js"],"sourcesContent":["import AttributeCompression from \"../Core/AttributeCompression.js\";\nimport Cartesian3 from \"../Core/Cartesian3.js\";\nimport Cartographic from \"../Core/Cartographic.js\";\nimport combine from \"../Core/combine.js\";\nimport Ellipsoid from \"../Core/Ellipsoid.js\";\nimport IndexDatatype from \"../Core/IndexDatatype.js\";\nimport CesiumMath from \"../Core/Math.js\";\nimport Rectangle from \"../Core/Rectangle.js\";\nimport createTaskProcessorWorker from \"./createTaskProcessorWorker.js\";\n\nconst MAX_SHORT = 32767;\nconst MITER_BREAK = Math.cos(CesiumMath.toRadians(150.0));\n\nconst scratchBVCartographic = new Cartographic();\nconst scratchEncodedPosition = new Cartesian3();\n\nfunction decodePositions(\n uBuffer,\n vBuffer,\n heightBuffer,\n rectangle,\n minimumHeight,\n maximumHeight,\n ellipsoid\n) {\n const positionsLength = uBuffer.length;\n const decodedPositions = new Float64Array(positionsLength * 3);\n for (let i = 0; i < positionsLength; ++i) {\n const u = uBuffer[i];\n const v = vBuffer[i];\n const h = heightBuffer[i];\n\n const lon = CesiumMath.lerp(rectangle.west, rectangle.east, u / MAX_SHORT);\n const lat = CesiumMath.lerp(\n rectangle.south,\n rectangle.north,\n v / MAX_SHORT\n );\n const alt = CesiumMath.lerp(minimumHeight, maximumHeight, h / MAX_SHORT);\n\n const cartographic = Cartographic.fromRadians(\n lon,\n lat,\n alt,\n scratchBVCartographic\n );\n const decodedPosition = ellipsoid.cartographicToCartesian(\n cartographic,\n scratchEncodedPosition\n );\n Cartesian3.pack(decodedPosition, decodedPositions, i * 3);\n }\n return decodedPositions;\n}\n\nfunction getPositionOffsets(counts) {\n const countsLength = counts.length;\n const positionOffsets = new Uint32Array(countsLength + 1);\n let offset = 0;\n for (let i = 0; i < countsLength; ++i) {\n positionOffsets[i] = offset;\n offset += counts[i];\n }\n positionOffsets[countsLength] = offset;\n return positionOffsets;\n}\n\nconst previousCompressedCartographicScratch = new Cartographic();\nconst currentCompressedCartographicScratch = new Cartographic();\nfunction removeDuplicates(uBuffer, vBuffer, heightBuffer, counts) {\n const countsLength = counts.length;\n const positionsLength = uBuffer.length;\n const markRemoval = new Uint8Array(positionsLength);\n const previous = previousCompressedCartographicScratch;\n const current = currentCompressedCartographicScratch;\n let offset = 0;\n for (let i = 0; i < countsLength; i++) {\n const count = counts[i];\n let updatedCount = count;\n for (let j = 1; j < count; j++) {\n const index = offset + j;\n const previousIndex = index - 1;\n current.longitude = uBuffer[index];\n current.latitude = vBuffer[index];\n previous.longitude = uBuffer[previousIndex];\n previous.latitude = vBuffer[previousIndex];\n\n if (Cartographic.equals(current, previous)) {\n updatedCount--;\n markRemoval[previousIndex] = 1;\n }\n }\n counts[i] = updatedCount;\n offset += count;\n }\n\n let nextAvailableIndex = 0;\n for (let k = 0; k < positionsLength; k++) {\n if (markRemoval[k] !== 1) {\n uBuffer[nextAvailableIndex] = uBuffer[k];\n vBuffer[nextAvailableIndex] = vBuffer[k];\n heightBuffer[nextAvailableIndex] = heightBuffer[k];\n nextAvailableIndex++;\n }\n }\n}\n\nfunction VertexAttributesAndIndices(volumesCount) {\n const vertexCount = volumesCount * 8;\n const vec3Floats = vertexCount * 3;\n const vec4Floats = vertexCount * 4;\n this.startEllipsoidNormals = new Float32Array(vec3Floats);\n this.endEllipsoidNormals = new Float32Array(vec3Floats);\n this.startPositionAndHeights = new Float32Array(vec4Floats);\n this.startFaceNormalAndVertexCornerIds = new Float32Array(vec4Floats);\n this.endPositionAndHeights = new Float32Array(vec4Floats);\n this.endFaceNo
|