CylinderGeometryLibrary-09101d37.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* This file is automatically rebuilt by the Cesium build process. */
  2. define(['exports', './Math-392d0035'], function (exports, _Math) { 'use strict';
  3. /**
  4. * @private
  5. */
  6. var CylinderGeometryLibrary = {};
  7. /**
  8. * @private
  9. */
  10. CylinderGeometryLibrary.computePositions = function (
  11. length,
  12. topRadius,
  13. bottomRadius,
  14. slices,
  15. fill
  16. ) {
  17. var topZ = length * 0.5;
  18. var bottomZ = -topZ;
  19. var twoSlice = slices + slices;
  20. var size = fill ? 2 * twoSlice : twoSlice;
  21. var positions = new Float64Array(size * 3);
  22. var i;
  23. var index = 0;
  24. var tbIndex = 0;
  25. var bottomOffset = fill ? twoSlice * 3 : 0;
  26. var topOffset = fill ? (twoSlice + slices) * 3 : slices * 3;
  27. for (i = 0; i < slices; i++) {
  28. var angle = (i / slices) * _Math.CesiumMath.TWO_PI;
  29. var x = Math.cos(angle);
  30. var y = Math.sin(angle);
  31. var bottomX = x * bottomRadius;
  32. var bottomY = y * bottomRadius;
  33. var topX = x * topRadius;
  34. var 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. });