qd-changjing/public/static/Build/CesiumUnminified/Workers/createVectorTilePolylines.j...

1 line
17 KiB
Plaintext
Raw Normal View History

2022-07-05 16:56:29 +08:00
{"version":3,"file":"createVectorTilePolylines.js","sources":["../../../../Source/Core/decodeVectorPolylinePositions.js","../../../../Source/WorkersES6/createVectorTilePolylines.js"],"sourcesContent":["import AttributeCompression from \"./AttributeCompression.js\";\nimport Cartesian3 from \"./Cartesian3.js\";\nimport Cartographic from \"./Cartographic.js\";\nimport CesiumMath from \"./Math.js\";\n\nconst maxShort = 32767;\n\nconst scratchBVCartographic = new Cartographic();\nconst scratchEncodedPosition = new Cartesian3();\n\nfunction decodeVectorPolylinePositions(\n positions,\n rectangle,\n minimumHeight,\n maximumHeight,\n ellipsoid\n) {\n const positionsLength = positions.length / 3;\n const uBuffer = positions.subarray(0, positionsLength);\n const vBuffer = positions.subarray(positionsLength, 2 * positionsLength);\n const heightBuffer = positions.subarray(\n 2 * positionsLength,\n 3 * positionsLength\n );\n AttributeCompression.zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer);\n\n const decoded = new Float64Array(positions.length);\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 / maxShort);\n const lat = CesiumMath.lerp(rectangle.south, rectangle.north, v / maxShort);\n const alt = CesiumMath.lerp(minimumHeight, maximumHeight, h / maxShort);\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, decoded, i * 3);\n }\n return decoded;\n}\nexport default decodeVectorPolylinePositions;\n","import Cartesian3 from \"../Core/Cartesian3.js\";\nimport combine from \"../Core/combine.js\";\nimport decodeVectorPolylinePositions from \"../Core/decodeVectorPolylinePositions.js\";\nimport Ellipsoid from \"../Core/Ellipsoid.js\";\nimport IndexDatatype from \"../Core/IndexDatatype.js\";\nimport Rectangle from \"../Core/Rectangle.js\";\nimport createTaskProcessorWorker from \"./createTaskProcessorWorker.js\";\n\nconst scratchRectangle = new Rectangle();\nconst scratchEllipsoid = new Ellipsoid();\nconst scratchCenter = new Cartesian3();\nconst scratchMinMaxHeights = {\n min: undefined,\n max: undefined,\n};\n\nfunction unpackBuffer(packedBuffer) {\n packedBuffer = new Float64Array(packedBuffer);\n\n let offset = 0;\n scratchMinMaxHeights.min = packedBuffer[offset++];\n scratchMinMaxHeights.max = packedBuffer[offset++];\n\n Rectangle.unpack(packedBuffer, offset, scratchRectangle);\n offset += Rectangle.packedLength;\n\n Ellipsoid.unpack(packedBuffer, offset, scratchEllipsoid);\n offset += Ellipsoid.packedLength;\n\n Cartesian3.unpack(packedBuffer, offset, scratchCenter);\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 scratchP0 = new Cartesian3();\nconst scratchP1 = new Cartesian3();\nconst scratchPrev = new Cartesian3();\nconst scratchCur = new Cartesian3();\nconst scratchNext = new Cartesian3();\n\nfunction createVectorTilePolylines(parameters, transferableObjects) {\n const encodedPositions = new Uint16Array(parameters.positions);\n const widths = new Uint16Array(parameters.widths);\n const counts = new Uint32Array(parameters.counts);\n const batchIds = new Uint16Array(parameters.batchIds);\n\n unpackBuffer(parameters.packedBuffer);\n const rectangle = scratchRectangle;\n const ellipsoid = scratchEllipsoid;\n const center = scratchCenter;\n const minimumHeight = scratchMinMaxHeights.min;\n const maximumHeight = scratchMinMaxHeights.max;\n\n const positions = decodeVectorPolylinePositions(\n encoded