Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Commit

Permalink
Fixed/improved light attenuation export.
Browse files Browse the repository at this point in the history
Moved light type depending parameters "up".
  • Loading branch information
UX3D-nopper committed May 28, 2017
1 parent 7a5b28c commit a414250
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions scripts/addons/io_scene_gltf2/gltf2_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,32 +530,32 @@ def generate_lights(operator,

light = {}

light_type = {}

if blender_light.type == 'SUN':
light['type'] = 'directional'
elif blender_light.type == 'POINT':
light['point'] = light_type
light['type'] = 'point'
elif blender_light.type == 'SPOT':
light['spot'] = light_type
light['type'] = 'spot'
else:
continue

if blender_light.type == 'POINT' or blender_light.type == 'SPOT':
if blender_light.falloff_type == 'CONSTANT':
light_type['constantAttenuation'] = 1.0
light['constantAttenuation'] = 1.0
elif blender_light.falloff_type == 'INVERSE_LINEAR':
light_type['linearAttenuation'] = 1.0
light['linearAttenuation'] = 1.0 / blender_light.distance
elif blender_light.falloff_type == 'INVERSE_SQUARE':
light_type['quadraticAttenuation'] = 1.0
light['quadraticAttenuation'] = 1.0 / blender_light.distance
elif blender_light.falloff_type == 'INVERSE_COEFFICIENTS':
light['constantAttenuation'] = blender_light.constant_coefficient * 1.0
light['linearAttenuation'] = blender_light.linear_coefficient * 1.0 / blender_light.distance
light['quadraticAttenuation'] = blender_light.quadratic_coefficient * 1.0 / blender_light.distance
else:
continue

if blender_light.type == 'SPOT':
light_type['fallOffAngle'] = blender_light.spot_size
light_type['fallOffExponent'] = 128.0 * blender_light.spot_blend
light['fallOffAngle'] = blender_light.spot_size
light['fallOffExponent'] = 128.0 * blender_light.spot_blend

light['color'] = [blender_light.color[0] * blender_light.energy, blender_light.color[1] * blender_light.energy, blender_light.color[2] * blender_light.energy]

Expand Down

0 comments on commit a414250

Please sign in to comment.