Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2020-03-27 20:41:43 +0300
committerJulien Duroure <julien.duroure@gmail.com>2020-03-27 20:41:43 +0300
commitfd6bfbb44af49a97db2ad35ba4f54d83ffec26a4 (patch)
tree6cad2f6ef06b835a2429b9784228ca88293f775b /io_scene_gltf2
parent38531bbfa567d08ccc68012c1829ecf0f66c7e39 (diff)
glTF importer: better retrieve camera & lights names
Diffstat (limited to 'io_scene_gltf2')
-rwxr-xr-xio_scene_gltf2/__init__.py2
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_camera.py3
-rw-r--r--io_scene_gltf2/blender/imp/gltf2_blender_light.py23
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_node.py6
4 files changed, 16 insertions, 18 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 6e3484e0..af0610c1 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
- "version": (1, 2, 53),
+ "version": (1, 2, 54),
'blender': (2, 82, 7),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_camera.py b/io_scene_gltf2/blender/imp/gltf2_blender_camera.py
index ffe79b54..e97bd0b8 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_camera.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_camera.py
@@ -48,5 +48,4 @@ class BlenderCamera():
if hasattr(pycamera, "zfar"):
cam.clip_end = pycamera.zfar
- obj = bpy.data.objects.new(pycamera.name, cam)
- return obj
+ return cam
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_light.py b/io_scene_gltf2/blender/imp/gltf2_blender_light.py
index be1c6c40..e626123c 100644
--- a/io_scene_gltf2/blender/imp/gltf2_blender_light.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_light.py
@@ -28,23 +28,23 @@ class BlenderLight():
"""Light creation."""
pylight = gltf.data.extensions['KHR_lights_punctual']['lights'][light_id]
if pylight['type'] == "directional":
- obj = BlenderLight.create_directional(gltf, light_id)
+ light = BlenderLight.create_directional(gltf, light_id)
elif pylight['type'] == "point":
- obj = BlenderLight.create_point(gltf, light_id)
+ light = BlenderLight.create_point(gltf, light_id)
elif pylight['type'] == "spot":
- obj = BlenderLight.create_spot(gltf, light_id)
+ light = BlenderLight.create_spot(gltf, light_id)
if 'color' in pylight.keys():
- obj.data.color = pylight['color']
+ light.color = pylight['color']
if 'intensity' in pylight.keys():
- obj.data.energy = pylight['intensity']
+ light.energy = pylight['intensity']
# TODO range
- set_extras(obj.data, pylight.get('extras'))
+ set_extras(light, pylight.get('extras'))
- return obj
+ return light
@staticmethod
def create_directional(gltf, light_id):
@@ -54,8 +54,7 @@ class BlenderLight():
pylight['name'] = "Sun"
sun = bpy.data.lights.new(name=pylight['name'], type="SUN")
- obj = bpy.data.objects.new(pylight['name'], sun)
- return obj
+ return sun
@staticmethod
def create_point(gltf, light_id):
@@ -65,8 +64,7 @@ class BlenderLight():
pylight['name'] = "Point"
point = bpy.data.lights.new(name=pylight['name'], type="POINT")
- obj = bpy.data.objects.new(pylight['name'], point)
- return obj
+ return point
@staticmethod
def create_spot(gltf, light_id):
@@ -76,7 +74,6 @@ class BlenderLight():
pylight['name'] = "Spot"
spot = bpy.data.lights.new(name=pylight['name'], type="SPOT")
- obj = bpy.data.objects.new(pylight['name'], spot)
# Angles
if 'spot' in pylight.keys() and 'outerConeAngle' in pylight['spot']:
@@ -89,4 +86,4 @@ class BlenderLight():
else:
spot.spot_blend = 1.0
- return obj
+ return spot
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_node.py b/io_scene_gltf2/blender/imp/gltf2_blender_node.py
index 6ce91ea3..8c732949 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_node.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_node.py
@@ -60,10 +60,12 @@ class BlenderNode():
obj = BlenderNode.create_mesh_object(gltf, pynode, name=vnode.name)
elif vnode.camera_node_idx is not None:
pynode = gltf.data.nodes[vnode.camera_node_idx]
- obj = BlenderCamera.create(gltf, pynode.camera)
+ cam = BlenderCamera.create(gltf, pynode.camera)
+ obj = bpy.data.objects.new(vnode.name, cam)
elif vnode.light_node_idx is not None:
pynode = gltf.data.nodes[vnode.light_node_idx]
- obj = BlenderLight.create(gltf, pynode.extensions['KHR_lights_punctual']['light'])
+ light = BlenderLight.create(gltf, pynode.extensions['KHR_lights_punctual']['light'])
+ obj = bpy.data.objects.new(vnode.name, light)
elif vnode.is_arma:
armature = bpy.data.armatures.new(vnode.arma_name)
obj = bpy.data.objects.new(vnode.name, armature)