Source: Scene/ShadowMode.js

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