{"version":3,"file":"createVectorTilePoints.js","sources":["../../../../Source/WorkersES6/createVectorTilePoints.js"],"sourcesContent":["import AttributeCompression from \"../Core/AttributeCompression.js\";\nimport Cartesian3 from \"../Core/Cartesian3.js\";\nimport Cartographic from \"../Core/Cartographic.js\";\nimport Ellipsoid from \"../Core/Ellipsoid.js\";\nimport CesiumMath from \"../Core/Math.js\";\nimport Rectangle from \"../Core/Rectangle.js\";\nimport createTaskProcessorWorker from \"./createTaskProcessorWorker.js\";\n\nconst maxShort = 32767;\n\nconst scratchBVCartographic = new Cartographic();\nconst scratchEncodedPosition = new Cartesian3();\n\nconst scratchRectangle = new Rectangle();\nconst scratchEllipsoid = new Ellipsoid();\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}\n\nfunction createVectorTilePoints(parameters, transferableObjects) {\n const positions = new Uint16Array(parameters.positions);\n\n unpackBuffer(parameters.packedBuffer);\n const rectangle = scratchRectangle;\n const ellipsoid = scratchEllipsoid;\n const minimumHeight = scratchMinMaxHeights.min;\n const maximumHeight = scratchMinMaxHeights.max;\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\n transferableObjects.push(decoded.buffer);\n\n return {\n positions: decoded.buffer,\n };\n}\nexport default createTaskProcessorWorker(createVectorTilePoints);\n"],"names":["Cartographic","Cartesian3","Rectangle","Ellipsoid","AttributeCompression","CesiumMath"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAQA,MAAM,QAAQ,GAAG,KAAK,CAAC;AACvB;EACA,MAAM,qBAAqB,GAAG,IAAIA,oBAAY,EAAE,CAAC;EACjD,MAAM,sBAAsB,GAAG,IAAIC,kBAAU,EAAE,CAAC;AAChD;EACA,MAAM,gBAAgB,GAAG,IAAIC,iBAAS,EAAE,CAAC;EACzC,MAAM,gBAAgB,GAAG,IAAIC,iBAAS,EAAE,CAAC;EACzC,MAAM,oBAAoB,GAAG;EAC7B,EAAE,GAAG,EAAE,SAAS;EAChB,EAAE,GAAG,EAAE,SAAS;EAChB,CAAC,CAAC;AACF;EACA,SAAS,YAAY,CAAC,YAAY,EAAE;EACpC,EAAE,YAAY,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;AAChD;EACA,EAAE,IAAI,MAAM,GAAG,CAAC,CAAC;EACjB,EAAE,oBAAoB,CAAC,GAAG,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;EACpD,EAAE,oBAAoB,CAAC,GAAG,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;AACpD;EACA,EAAED,iBAAS,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;EAC3D,EAAE,MAAM,IAAIA,iBAAS,CAAC,YA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