Skip to content

Assign extensions if the didn't exist already #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,6 @@ def gather_object_property(export_settings, blender_object):
return None


def get_hubs_ext(export_settings):
exts = export_settings["gltf_user_extensions"]
import io_hubs_addon
for ext in exts:
if type(ext) is io_hubs_addon.io.gltf_exporter.glTF2ExportUserExtension:
return ext


def add_component_to_node(gltf2_object, dep, value, export_settings):
try:
from io_hubs_addon.io.utils import HUBS_CONFIG
Expand All @@ -154,13 +146,15 @@ def add_component_to_node(gltf2_object, dep, value, export_settings):
else:
extensions = gltf2_object.extensions

existed = True
if extensions is None:
existed = False
extensions = {}

if hubs_ext_name not in extensions:
extensions[hubs_ext_name] = {dep.get_name(): value}
if type(gltf2_object) is tuple:
gltf2_object[0].extensions = extensions
else:
gltf2_object.extensions = extensions
Comment on lines +154 to +157
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine, but it seems kind of hard to reason about to me.
Are you sure this shouldn't be up under the if extensions is None: block?

else:
if hasattr(extensions[hubs_ext_name], "extension"):
if not dep.get_name() in extensions[hubs_ext_name].extension:
Expand All @@ -173,12 +167,6 @@ def add_component_to_node(gltf2_object, dep, value, export_settings):
else:
extensions[hubs_ext_name][dep.get_name()].update(value)

if not existed:
if type(gltf2_object) is tuple:
gltf2_object[0].extensions = extensions
else:
gltf2_object.extensions = extensions


def update_gltf_network_dependencies(node, export_settings, blender_object, dep, value={"networked": "true"}):
if type(blender_object) is bpy.types.Object:
Expand Down