CylinderGeometryLibrary-1ace08dc.js 1.7 KB

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