Axis.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import Check from '../Core/Check.js';
  2. import freezeObject from '../Core/freezeObject.js';
  3. import CesiumMath from '../Core/Math.js';
  4. import Matrix3 from '../Core/Matrix3.js';
  5. import Matrix4 from '../Core/Matrix4.js';
  6. /**
  7. * An enum describing the x, y, and z axes and helper conversion functions.
  8. *
  9. * @exports Axis
  10. * @private
  11. */
  12. var Axis = {
  13. /**
  14. * Denotes the x-axis.
  15. *
  16. * @type {Number}
  17. * @constant
  18. */
  19. X : 0,
  20. /**
  21. * Denotes the y-axis.
  22. *
  23. * @type {Number}
  24. * @constant
  25. */
  26. Y : 1,
  27. /**
  28. * Denotes the z-axis.
  29. *
  30. * @type {Number}
  31. * @constant
  32. */
  33. Z : 2,
  34. /**
  35. * Matrix used to convert from y-up to z-up
  36. *
  37. * @type {Matrix4}
  38. * @constant
  39. */
  40. Y_UP_TO_Z_UP : Matrix4.fromRotationTranslation(Matrix3.fromRotationX(CesiumMath.PI_OVER_TWO)),
  41. /**
  42. * Matrix used to convert from z-up to y-up
  43. *
  44. * @type {Matrix4}
  45. * @constant
  46. */
  47. Z_UP_TO_Y_UP : Matrix4.fromRotationTranslation(Matrix3.fromRotationX(-CesiumMath.PI_OVER_TWO)),
  48. /**
  49. * Matrix used to convert from x-up to z-up
  50. *
  51. * @type {Matrix4}
  52. * @constant
  53. */
  54. X_UP_TO_Z_UP : Matrix4.fromRotationTranslation(Matrix3.fromRotationY(-CesiumMath.PI_OVER_TWO)),
  55. /**
  56. * Matrix used to convert from z-up to x-up
  57. *
  58. * @type {Matrix4}
  59. * @constant
  60. */
  61. Z_UP_TO_X_UP : Matrix4.fromRotationTranslation(Matrix3.fromRotationY(CesiumMath.PI_OVER_TWO)),
  62. /**
  63. * Matrix used to convert from x-up to y-up
  64. *
  65. * @type {Matrix4}
  66. * @constant
  67. */
  68. X_UP_TO_Y_UP : Matrix4.fromRotationTranslation(Matrix3.fromRotationZ(CesiumMath.PI_OVER_TWO)),
  69. /**
  70. * Matrix used to convert from y-up to x-up
  71. *
  72. * @type {Matrix4}
  73. * @constant
  74. */
  75. Y_UP_TO_X_UP : Matrix4.fromRotationTranslation(Matrix3.fromRotationZ(-CesiumMath.PI_OVER_TWO)),
  76. /**
  77. * Gets the axis by name
  78. *
  79. * @param {String} name The name of the axis.
  80. * @returns {Number} The axis enum.
  81. */
  82. fromName : function(name) {
  83. //>>includeStart('debug', pragmas.debug);
  84. Check.typeOf.string('name', name);
  85. //>>includeEnd('debug');
  86. return Axis[name];
  87. }
  88. };
  89. export default freezeObject(Axis);