test_light.py 662 B

1234567891011121314151617181920
  1. from panda3d import core
  2. def luminance(col):
  3. return 0.2126 * col[0] + 0.7152 * col[1] + 0.0722 * col[2]
  4. def test_light_colortemp():
  5. # Default is all white, assuming a D65 white point.
  6. light = core.PointLight("light")
  7. assert light.color == (1, 1, 1, 1)
  8. assert light.color_temperature == 6500
  9. # When setting color temp, it should preserve luminance.
  10. for temp in range(2000, 15000):
  11. light.color_temperature = temp
  12. assert abs(luminance(light.color) - 1.0) < 0.001
  13. # Setting it to the white point will make a white color.
  14. light.color_temperature = 6500
  15. assert light.color.almost_equal((1, 1, 1, 1), 0.001)