threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {PointLight} from 'threepipe'
  2. const blenderLightTypes = {
  3. point: 0,
  4. sun: 1,
  5. spot: 0,
  6. hemi: 0,
  7. area: 0,
  8. }
  9. export function createLight(lamp: any) {
  10. const ldata = lamp.data
  11. const position = [lamp.loc[0], lamp.loc[2], -lamp.loc[1]]
  12. const color = ldata.r * 255 << 16 | ldata.g * 255 << 8 | ldata.b * 255 << 0
  13. const intensity = ldata.energy
  14. const distance = 0
  15. let light = null
  16. switch (ldata.type) {
  17. case blenderLightTypes.point:
  18. light = new PointLight(color, intensity, distance)
  19. light.position.fromArray(position, 0)
  20. light.castShadow = true
  21. break
  22. case blenderLightTypes.sun:
  23. light = new PointLight(color, intensity, distance)
  24. light.position.fromArray(position, 0)
  25. light.castShadow = true
  26. light.shadow.mapSize.width = 1024
  27. light.shadow.mapSize.height = 1024
  28. light.shadow.camera.near = 0.01
  29. light.shadow.camera.far = 500
  30. break
  31. default:
  32. console.warn('Unsupported light type', ldata.type)
  33. }
  34. return light
  35. }