ShadowMode.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * Specifies whether the object casts or receives shadows from light sources when
  3. * shadows are enabled.
  4. *
  5. * @enum {Number}
  6. */
  7. const ShadowMode = {
  8. /**
  9. * The object does not cast or receive shadows.
  10. *
  11. * @type {Number}
  12. * @constant
  13. */
  14. DISABLED: 0,
  15. /**
  16. * The object casts and receives shadows.
  17. *
  18. * @type {Number}
  19. * @constant
  20. */
  21. ENABLED: 1,
  22. /**
  23. * The object casts shadows only.
  24. *
  25. * @type {Number}
  26. * @constant
  27. */
  28. CAST_ONLY: 2,
  29. /**
  30. * The object receives shadows only.
  31. *
  32. * @type {Number}
  33. * @constant
  34. */
  35. RECEIVE_ONLY: 3,
  36. };
  37. /**
  38. * @private
  39. */
  40. ShadowMode.NUMBER_OF_SHADOW_MODES = 4;
  41. /**
  42. * @private
  43. */
  44. ShadowMode.castShadows = function (shadowMode) {
  45. return (
  46. shadowMode === ShadowMode.ENABLED || shadowMode === ShadowMode.CAST_ONLY
  47. );
  48. };
  49. /**
  50. * @private
  51. */
  52. ShadowMode.receiveShadows = function (shadowMode) {
  53. return (
  54. shadowMode === ShadowMode.ENABLED || shadowMode === ShadowMode.RECEIVE_ONLY
  55. );
  56. };
  57. /**
  58. * @private
  59. */
  60. ShadowMode.fromCastReceive = function (castShadows, receiveShadows) {
  61. if (castShadows && receiveShadows) {
  62. return ShadowMode.ENABLED;
  63. } else if (castShadows) {
  64. return ShadowMode.CAST_ONLY;
  65. } else if (receiveShadows) {
  66. return ShadowMode.RECEIVE_ONLY;
  67. }
  68. return ShadowMode.DISABLED;
  69. };
  70. export default Object.freeze(ShadowMode);