createVectorTilePoints.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* This file is automatically rebuilt by the Cesium build process. */
  2. define(['./defined-26bd4a03', './Check-da037458', './freezeObject-2d83f591', './defaultValue-f2e68450', './Math-fa6e45cb', './Cartesian2-2a723276', './defineProperties-6f7a50f2', './when-ee12a2cb', './AttributeCompression-87682214', './createTaskProcessorWorker'], function (defined, Check, freezeObject, defaultValue, _Math, Cartesian2, defineProperties, when, AttributeCompression, createTaskProcessorWorker) { 'use strict';
  3. var maxShort = 32767;
  4. var scratchBVCartographic = new Cartesian2.Cartographic();
  5. var scratchEncodedPosition = new Cartesian2.Cartesian3();
  6. var scratchRectangle = new Cartesian2.Rectangle();
  7. var scratchEllipsoid = new Cartesian2.Ellipsoid();
  8. var scratchMinMaxHeights = {
  9. min : undefined,
  10. max : undefined
  11. };
  12. function unpackBuffer(packedBuffer) {
  13. packedBuffer = new Float64Array(packedBuffer);
  14. var offset = 0;
  15. scratchMinMaxHeights.min = packedBuffer[offset++];
  16. scratchMinMaxHeights.max = packedBuffer[offset++];
  17. Cartesian2.Rectangle.unpack(packedBuffer, offset, scratchRectangle);
  18. offset += Cartesian2.Rectangle.packedLength;
  19. Cartesian2.Ellipsoid.unpack(packedBuffer, offset, scratchEllipsoid);
  20. }
  21. function createVectorTilePoints(parameters, transferableObjects) {
  22. var positions = new Uint16Array(parameters.positions);
  23. unpackBuffer(parameters.packedBuffer);
  24. var rectangle = scratchRectangle;
  25. var ellipsoid = scratchEllipsoid;
  26. var minimumHeight = scratchMinMaxHeights.min;
  27. var maximumHeight = scratchMinMaxHeights.max;
  28. var positionsLength = positions.length / 3;
  29. var uBuffer = positions.subarray(0, positionsLength);
  30. var vBuffer = positions.subarray(positionsLength, 2 * positionsLength);
  31. var heightBuffer = positions.subarray(2 * positionsLength, 3 * positionsLength);
  32. AttributeCompression.AttributeCompression.zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer);
  33. var decoded = new Float64Array(positions.length);
  34. for (var i = 0; i < positionsLength; ++i) {
  35. var u = uBuffer[i];
  36. var v = vBuffer[i];
  37. var h = heightBuffer[i];
  38. var lon = _Math.CesiumMath.lerp(rectangle.west, rectangle.east, u / maxShort);
  39. var lat = _Math.CesiumMath.lerp(rectangle.south, rectangle.north, v / maxShort);
  40. var alt = _Math.CesiumMath.lerp(minimumHeight, maximumHeight, h / maxShort);
  41. var cartographic = Cartesian2.Cartographic.fromRadians(lon, lat, alt, scratchBVCartographic);
  42. var decodedPosition = ellipsoid.cartographicToCartesian(cartographic, scratchEncodedPosition);
  43. Cartesian2.Cartesian3.pack(decodedPosition, decoded, i * 3);
  44. }
  45. transferableObjects.push(decoded.buffer);
  46. return {
  47. positions : decoded.buffer
  48. };
  49. }
  50. var createVectorTilePoints$1 = createTaskProcessorWorker(createVectorTilePoints);
  51. return createVectorTilePoints$1;
  52. });