CylinderGeometryLibrary-7bf291b4.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. define(['exports', './Math-0a2ac845'], (function (exports, Math$1) { 'use strict';
  2. /**
  3. * @private
  4. */
  5. const CylinderGeometryLibrary = {};
  6. /**
  7. * @private
  8. */
  9. CylinderGeometryLibrary.computePositions = function (
  10. length,
  11. topRadius,
  12. bottomRadius,
  13. slices,
  14. fill
  15. ) {
  16. const topZ = length * 0.5;
  17. const bottomZ = -topZ;
  18. const twoSlice = slices + slices;
  19. const size = fill ? 2 * twoSlice : twoSlice;
  20. const positions = new Float64Array(size * 3);
  21. let i;
  22. let index = 0;
  23. let tbIndex = 0;
  24. const bottomOffset = fill ? twoSlice * 3 : 0;
  25. const topOffset = fill ? (twoSlice + slices) * 3 : slices * 3;
  26. for (i = 0; i < slices; i++) {
  27. const angle = (i / slices) * Math$1.CesiumMath.TWO_PI;
  28. const x = Math.cos(angle);
  29. const y = Math.sin(angle);
  30. const bottomX = x * bottomRadius;
  31. const bottomY = y * bottomRadius;
  32. const topX = x * topRadius;
  33. const topY = y * topRadius;
  34. positions[tbIndex + bottomOffset] = bottomX;
  35. positions[tbIndex + bottomOffset + 1] = bottomY;
  36. positions[tbIndex + bottomOffset + 2] = bottomZ;
  37. positions[tbIndex + topOffset] = topX;
  38. positions[tbIndex + topOffset + 1] = topY;
  39. positions[tbIndex + topOffset + 2] = topZ;
  40. tbIndex += 3;
  41. if (fill) {
  42. positions[index++] = bottomX;
  43. positions[index++] = bottomY;
  44. positions[index++] = bottomZ;
  45. positions[index++] = topX;
  46. positions[index++] = topY;
  47. positions[index++] = topZ;
  48. }
  49. }
  50. return positions;
  51. };
  52. var CylinderGeometryLibrary$1 = CylinderGeometryLibrary;
  53. exports.CylinderGeometryLibrary = CylinderGeometryLibrary$1;
  54. }));