I'm using Blender 4.0.2 and Blender2Babylon-3.3x.zip, that I downloaded from github repo here. I created new file with cube model and deleted camera and light, so there is nothing except cube.
During export I'm getting the next error:
bpy.ops.outliner.item_activate(deselect_all=True)
bpy.ops.outliner.delete()
bpy.ops.outliner.item_activate(deselect_all=True)
bpy.ops.outliner.delete()
bpy.context.space_data.system_bookmarks_active = 3
bpy.context.space_data.params.filename = "cube.babylon"
Python: Traceback (most recent call last):
File "C:\Users\melas\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\babylon_js\json_exporter.py", line 118, in execute
mesh = Mesh(object, scene, self)
File "C:\Users\melas\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\babylon_js\mesh.py", line 151, in __init__
recipe = BakingRecipe(bpyMesh, exporter)
File "C:\Users\melas\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\babylon_js\materials\baking_recipe.py", line 43, in __init__
bjsMaterial = BJSMaterial(bpyMaterial, exporter)
File "C:\Users\melas\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\babylon_js\materials\material.py", line 109, in __init__
self.bjsNodeTree = AbstractBJSNode.readMaterialNodeTree(bpyMaterial.node_tree, self.overloadChannels)
File "C:\Users\melas\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\babylon_js\materials\nodes\abstract.py", line 265, in readMaterialNodeTree
return AbstractBJSNode.readNodeTree(node_tree, 'ShaderNodeOutputMaterial', overloadChannels)
File "C:\Users\melas\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\babylon_js\materials\nodes\abstract.py", line 285, in readNodeTree
return AbstractBJSNode(output, topLevelId, overloadChannels)
File "C:\Users\melas\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\babylon_js\materials\nodes\abstract.py", line 84, in __init__
bjsWrapperNode = AbstractBJSNode.GetBJSWrapperNode(nodeSocket.links[0].from_node, nodeSocket.name, overloadChannels)
File "C:\Users\melas\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\babylon_js\materials\nodes\abstract.py", line 335, in GetBJSWrapperNode
return PrincipledBJSNode(bpyNode, socketName, overloadChannels)
File "C:\Users\melas\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\babylon_js\materials\nodes\principled.py", line 25, in __init__
subsurface = self.getDefault('Subsurface')
File "C:\Users\melas\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\babylon_js\materials\nodes\abstract.py", line 217, in getDefault
return self.defaults[socketName]
KeyError: 'Subsurface'
It doesn't look like Blender2Babylon supports Blender 4.0, the last commit to the repository was in September, before even the release of Blender 4.0. The actual issue you are facing could be due to the changes made to the
Subsurfacemodifier in thePrincipled BSDF, as per the release notes "Subsurface scattering [now] uses the base color instead of a separate color input" which could be tripping Blender2Babylon up as it tries to save all the properties.As for a solution here are some options:
\Blender Foundation\Blender\4.0\scripts\addons\babylon_js\materials\nodes\principled.pyline 25 to 31. You could basically just comment out the whole subsurface code (I've attached a screenshot showing the selected code to comment out).As I don't use BabylonJS I haven't been able to test these out but it should at least narrow down what the issue is.