Hubs-Foundation / hubs-blender-exporter

The Hubs Blender Add-on enables artists to export their creations to the immersive web with Hubs
Mozilla Public License 2.0
165 stars 51 forks source link

Porting to blender 4.x #289

Closed Spiderguy-F closed 4 weeks ago

Spiderguy-F commented 1 month ago

Merged with the windows fix in master, all seems to work in both versions now.

keianhzo commented 1 month ago

I've found some signature issues that I've fixed here: https://github.com/MozillaReality/hubs-blender-exporter/pull/289

keianhzo commented 1 month ago

Aside from the comments I left inline, I found that this is having trouble with video texture targets and lightmaps in 4.0 (and possibly more components, not sure); I don't think they get exported and I believe these are related errors in the terminal:

gather_scene_hook fails on <io_hubs_addon.io.gltf_exporter.glTF2ExportUserExtension object at 0x7fc9055b7be0>
ExportImage.blender_image() takes 1 positional argument but 2 were given
gather_material_hook fails on <io_hubs_addon.io.gltf_exporter.glTF2ExportUserExtension object at 0x7fc9055b7be0>
ExportImage.blender_image() takes 1 positional argument but 2 were given
gather_node_hook fails on <io_hubs_addon.io.gltf_exporter.glTF2ExportUserExtension object at 0x7fc9055b7be0>
ExportImage.blender_image() takes 1 positional argument but 2 were given

There were more, but I think adding in the changes from #292 fixed some of them.

I believe my PR fixes this.

Exairnous commented 1 month ago

I believe my PR fixes this.

This was encountered with the changes in your PR applied while attempting to export this file: Export_dev_test_2_packed.zip

Console Log ``` 06:47:35 | INFO: Starting glTF 2.0 export 06:47:35 | INFO: Extracting primitive: Skybox.001 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Directional Light.001 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Ambient Light.001 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Point Light.002 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Spot Light.002 06:47:35 | INFO: Primitives created: 1 gather_node_hook fails on ExportImage.blender_image() takes 1 positional argument but 2 were given 06:47:35 | INFO: Extracting primitive: Plane.001 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Cube 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Visible 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Nav Mesh 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Video Texture Source 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Ammo Shape 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Particle Emitter 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Waypoint 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Link 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Image 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Audio 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Video 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Billboard 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Text 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Media Frame 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Spawner 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Audio Target 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Audio Source 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Audio Zone 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Shadow 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Uv Scroll 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Loop Animation 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Personal Space Invader 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Video Texture Target 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Frustrum 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Simple Water 06:47:35 | INFO: Primitives created: 1 WARN (bpy.rna): source/blender/python/intern/bpy_rna.cc:1343 pyrna_enum_to_py: current value '524317' matches no enum in 'FloatProperty', 'tideSpeed', 'subtype' WARN (bpy.rna): source/blender/python/intern/bpy_rna.cc:1343 pyrna_enum_to_py: current value '524317' matches no enum in 'FloatProperty', 'tideSpeed', 'subtype' WARN (bpy.rna): source/blender/python/intern/bpy_rna.cc:1343 pyrna_enum_to_py: current value '524317' matches no enum in 'FloatProperty', 'waveSpeed', 'subtype' WARN (bpy.rna): source/blender/python/intern/bpy_rna.cc:1343 pyrna_enum_to_py: current value '524317' matches no enum in 'FloatProperty', 'waveSpeed', 'subtype' 06:47:35 | INFO: Extracting primitive: Hemisphere Light 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Audio Params 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Model 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Suzanne.001 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Plane 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Arrow 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Suzanne 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Image Spherical 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Video Spherical 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Uv Scroll.001 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Ground gather_material_hook fails on ExportImage.blender_image() takes 1 positional argument but 2 were given 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.001 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.003 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.004 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.005 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.006 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.007 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.008 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.009 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.010 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.011 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.012 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.013 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.014 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.015 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.016 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.017 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.018 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.019 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.020 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.023 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.025 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.026 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.027 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.028 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.029 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.030 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.031 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.032 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.033 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Shadow.001 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.034 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.035 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.036 06:47:35 | INFO: Primitives created: 1 06:47:35 | INFO: Extracting primitive: Label.002 06:47:35 | INFO: Primitives created: 1 gather_scene_hook fails on ExportImage.blender_image() takes 1 positional argument but 2 were given 06:47:35 | INFO: Finished glTF 2.0 export in 0.3055851459503174 s ```

Aside from these errors, I just found that there is one spot in the add-on that uses a context override for an operator and Blender 4.0 removed support for context overrides to operators. You now have to use a temp_override context manager. See: https://projects.blender.org/blender/blender/commit/ac263a9bce53e190d07d679a058a230e91e722be and https://docs.blender.org/api/4.0/bpy.types.Context.html#bpy.types.Context.temp_override

Temp overrides were introduced in Blender 3.2, so I think it's safe to just use them. The spot that needs changing begins at line 325 in components/operators.py

keianhzo commented 4 weeks ago

I've updated my related PR to fix some lightmap node issues in 4.0.

Regarding:

Aside from these errors, I just found that there is one spot in the add-on that uses a context override for an operator and Blender 4.0 removed support for context overrides to operators. You now have to use a temp_override context manager. See: https://projects.blender.org/blender/blender/commit/ac263a9bce53e190d07d679a058a230e91e722be and https://docs.blender.org/api/4.0/bpy.types.Context.html#bpy.types.Context.temp_override

Can you to open another PR with that so we can land this and the follow-up PRs?