lightConstants.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /** Defines the cross module constantsused by lights to avoid circular dependencies */
  2. export class LightConstants {
  3. /**
  4. * Sort function to order lights for rendering.
  5. * @param a First Light object to compare to second.
  6. * @param b Second Light object to compare first.
  7. * @returns -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8. */
  9. static CompareLightsPriority(a, b) {
  10. //shadow-casting lights have priority over non-shadow-casting lights
  11. //the renderPriority is a secondary sort criterion
  12. if (a.shadowEnabled !== b.shadowEnabled) {
  13. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  14. }
  15. return b.renderPriority - a.renderPriority;
  16. }
  17. }
  18. /**
  19. * Falloff Default: light is falling off following the material specification:
  20. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  21. */
  22. LightConstants.FALLOFF_DEFAULT = 0;
  23. /**
  24. * Falloff Physical: light is falling off following the inverse squared distance law.
  25. */
  26. LightConstants.FALLOFF_PHYSICAL = 1;
  27. /**
  28. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  29. * to enhance interoperability with other engines.
  30. */
  31. LightConstants.FALLOFF_GLTF = 2;
  32. /**
  33. * Falloff Standard: light is falling off like in the standard material
  34. * to enhance interoperability with other materials.
  35. */
  36. LightConstants.FALLOFF_STANDARD = 3;
  37. //lightmapMode Consts
  38. /**
  39. * If every light affecting the material is in this lightmapMode,
  40. * material.lightmapTexture adds or multiplies
  41. * (depends on material.useLightmapAsShadowmap)
  42. * after every other light calculations.
  43. */
  44. LightConstants.LIGHTMAP_DEFAULT = 0;
  45. /**
  46. * material.lightmapTexture as only diffuse lighting from this light
  47. * adds only specular lighting from this light
  48. * adds dynamic shadows
  49. */
  50. LightConstants.LIGHTMAP_SPECULAR = 1;
  51. /**
  52. * material.lightmapTexture as only lighting
  53. * no light calculation from this light
  54. * only adds dynamic shadows from this light
  55. */
  56. LightConstants.LIGHTMAP_SHADOWSONLY = 2;
  57. // Intensity Mode Consts
  58. /**
  59. * Each light type uses the default quantity according to its type:
  60. * point/spot lights use luminous intensity
  61. * directional lights use illuminance
  62. */
  63. LightConstants.INTENSITYMODE_AUTOMATIC = 0;
  64. /**
  65. * lumen (lm)
  66. */
  67. LightConstants.INTENSITYMODE_LUMINOUSPOWER = 1;
  68. /**
  69. * candela (lm/sr)
  70. */
  71. LightConstants.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  72. /**
  73. * lux (lm/m^2)
  74. */
  75. LightConstants.INTENSITYMODE_ILLUMINANCE = 3;
  76. /**
  77. * nit (cd/m^2)
  78. */
  79. LightConstants.INTENSITYMODE_LUMINANCE = 4;
  80. // Light types ids const.
  81. /**
  82. * Light type const id of the point light.
  83. */
  84. LightConstants.LIGHTTYPEID_POINTLIGHT = 0;
  85. /**
  86. * Light type const id of the directional light.
  87. */
  88. LightConstants.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  89. /**
  90. * Light type const id of the spot light.
  91. */
  92. LightConstants.LIGHTTYPEID_SPOTLIGHT = 2;
  93. /**
  94. * Light type const id of the hemispheric light.
  95. */
  96. LightConstants.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  97. //# sourceMappingURL=lightConstants.js.map