ShadowMode.js 1.7 KB

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