Blender Exporter 6.1.1 issues with BJSMaterial

I just tried it and I get the error:
ERROR: ‘BJSMaterial’ object has no attribute ‘materialNameSpace’

Here the full log:

Here was the answer of JCPalmer:

@JCPalmer, I am not sure I understand what I need to do to make it work…?

I opened an issue in Github to track it: ERROR: 'BJSMaterial' object has no attribute 'materialNameSpace' · Issue #3 · BabylonJS/BlenderExporter · GitHub

Hope that helps.

I double checked line 49 of materials.py in the zip file, and it is setting the environmentIntensity. When an error stack, in the last line, shows something that is not even referenced in the error statement, it means that the code must have changed, after it was loaded into memory, usually upgrading.

I always restart after loading (many times a day during dev). The first thing I would do is either

  • delete c:\Users\goeff\Appdata\Roaming\Blender foundation\Blender\2.80\scripts\addons\babylon_js
  • Start Blender
  • install from scratch

or

  • Bring up preferences.
  • goto Addons / BabylonJS
  • expand & cleck the remove btn

I do not know what went wrong, but chasing ghosts is not recommended.

I also tried exporting a material by baking, which you export is triggering, and it work on my system. Even if doing a clean install of addon clears issue, results might not be as expected when baking in the exporter.

I did your first solution, and here is the new error I’ve got:

> Exporter version: 6.1.1, Blender version: 2.80 (sub 74)
> ========= Conversion from Blender to Babylon.js =========
> 	Scene settings used :
> 		inline textures     :  false
> 		Material Type       :  PBR
> 		Positions Precision :  4
> 		Normals Precision   :  3
> 		UVs Precision       :  3
> 		Vert Color Precision:  3
> 		Mat Weight Precision:  2
> 		texture directory   :  D:\Creation\Gamedev\BabylonJS\Maze-Project\Maze-Demo\misc\3D\NewWorld1\
> 	Python World class constructor completed
> 	WARNING: No active camera has been assigned, or is not in a currently selected Blender layer
> 	processing begun of node:  5_0
> 	processing begun of mesh:  5_0_00_MSH
> 		processing begun of material:  Bark
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.0509 secs
> 		Custom split normals with tangents being used
> 		num positions      :  1161
> 		num normals        :  1161
> 		num tangents       :  1161
> 		num uvs            :  2322
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  1161
> 	processing begun of node:  7_0
> 	processing begun of mesh:  7_0_01_MSH
> 		processing begun of material:  Bark
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.047 secs
> 		Custom split normals with tangents being used
> 		num positions      :  1161
> 		num normals        :  1161
> 		num tangents       :  1161
> 		num uvs            :  2322
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  1161
> 	processing begun of node:  17_0
> 	processing begun of mesh:  17_0_02_MSH
> 		processing begun of material:  Bark
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.0719 secs
> 		Custom split normals with tangents being used
> 		num positions      :  1548
> 		num normals        :  1548
> 		num tangents       :  1548
> 		num uvs            :  3096
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  1548
> 	processing begun of node:  31_0
> 	processing begun of mesh:  31_0_03_MSH
> 		processing begun of material:  Bark
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.027 secs
> 		Custom split normals with tangents being used
> 		num positions      :  774
> 		num normals        :  774
> 		num tangents       :  774
> 		num uvs            :  1548
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  774
> 	processing begun of node:  127_0
> 	processing begun of mesh:  127_0_04_MSH
> 		processing begun of material:  Bark
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.008 secs
> 		Custom split normals with tangents being used
> 		num positions      :  129
> 		num normals        :  129
> 		num tangents       :  129
> 		num uvs            :  258
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  129
> 	processing begun of node:  255_0
> 	processing begun of mesh:  255_0_05_MSH
> 		processing begun of material:  Grass
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.006 secs
> 		Custom split normals with tangents being used
> 		num positions      :  96
> 		num normals        :  96
> 		num tangents       :  96
> 		num uvs            :  192
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  96
> 	processing begun of node:  95_0
> 	processing begun of mesh:  95_0_06_MSH
> 		processing begun of material:  Bark
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.009 secs
> 		Custom split normals with tangents being used
> 		num positions      :  258
> 		num normals        :  258
> 		num tangents       :  258
> 		num uvs            :  516
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  258
> 	processing begun of mesh:  127_0_07_MSH
> 		processing begun of material:  Grass
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.005 secs
> 		Custom split normals with tangents being used
> 		num positions      :  90
> 		num normals        :  90
> 		num tangents       :  90
> 		num uvs            :  180
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  90
> 	processing begun of mesh:  127_0_08_MSH
> 		processing begun of material:  Path
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.005 secs
> 		Custom split normals with tangents being used
> 		num positions      :  48
> 		num normals        :  48
> 		num tangents       :  48
> 		num uvs            :  96
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  48
> 	processing begun of mesh:  127_0_09_MSH
> 		processing begun of material:  Leaves
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.011 secs
> 		Custom split normals with tangents being used
> 		num positions      :  318
> 		num normals        :  318
> 		num tangents       :  318
> 		num uvs            :  636
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  318
> 	processing begun of mesh:  17_0_10_MSH
> 		processing begun of material:  Grass
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.006 secs
> 		Custom split normals with tangents being used
> 		num positions      :  96
> 		num normals        :  96
> 		num tangents       :  96
> 		num uvs            :  192
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  96
> 	processing begun of mesh:  17_0_11_MSH
> 		processing begun of material:  Path
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.004 secs
> 		Custom split normals with tangents being used
> 		num positions      :  48
> 		num normals        :  48
> 		num tangents       :  48
> 		num uvs            :  96
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  48
> 	processing begun of mesh:  17_0_12_MSH
> 		processing begun of material:  Leaves
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.3756 secs
> 		Custom split normals with tangents being used
> 		num positions      :  3816
> 		num normals        :  3816
> 		num tangents       :  3816
> 		num uvs            :  7632
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  3816
> 	processing begun of mesh:  31_0_13_MSH
> 		processing begun of material:  Grass
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.005 secs
> 		Custom split normals with tangents being used
> 		num positions      :  96
> 		num normals        :  96
> 		num tangents       :  96
> 		num uvs            :  192
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  96
> 	processing begun of mesh:  31_0_14_MSH
> 		processing begun of material:  Path
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.004 secs
> 		Custom split normals with tangents being used
> 		num positions      :  48
> 		num normals        :  48
> 		num tangents       :  48
> 		num uvs            :  96
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  48
> 	processing begun of mesh:  31_0_15_MSH
> 		processing begun of material:  Leaves
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.1119 secs
> 		Custom split normals with tangents being used
> 		num positions      :  2034
> 		num normals        :  2034
> 		num tangents       :  2034
> 		num uvs            :  4068
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  2034
> 	processing begun of mesh:  5_0_16_MSH
> 		processing begun of material:  Grass
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.005 secs
> 		Custom split normals with tangents being used
> 		num positions      :  90
> 		num normals        :  90
> 		num tangents       :  90
> 		num uvs            :  180
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  90
> 	processing begun of mesh:  5_0_17_MSH
> 		processing begun of material:  Path
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.006 secs
> 		Custom split normals with tangents being used
> 		num positions      :  48
> 		num normals        :  48
> 		num tangents       :  48
> 		num uvs            :  96
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  48
> 	processing begun of mesh:  5_0_18_MSH
> 		processing begun of material:  Leaves
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.2447 secs
> 		Custom split normals with tangents being used
> 		num positions      :  3102
> 		num normals        :  3102
> 		num tangents       :  3102
> 		num uvs            :  6204
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  3102
> 	processing begun of mesh:  7_0_19_MSH
> 		processing begun of material:  Grass
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.005 secs
> 		Custom split normals with tangents being used
> 		num positions      :  90
> 		num normals        :  90
> 		num tangents       :  90
> 		num uvs            :  180
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  90
> 	processing begun of mesh:  7_0_20_MSH
> 		processing begun of material:  Path
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.004 secs
> 		Custom split normals with tangents being used
> 		num positions      :  48
> 		num normals        :  48
> 		num tangents       :  48
> 		num uvs            :  96
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  48
> 	processing begun of mesh:  7_0_21_MSH
> 		processing begun of material:  Leaves
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.2408 secs
> 		Custom split normals with tangents being used
> 		num positions      :  3102
> 		num normals        :  3102
> 		num tangents       :  3102
> 		num uvs            :  6204
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  3102
> 	processing begun of mesh:  95_0_22_MSH
> 		processing begun of material:  Grass
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.005 secs
> 		Custom split normals with tangents being used
> 		num positions      :  102
> 		num normals        :  102
> 		num tangents       :  102
> 		num uvs            :  204
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  102
> 	processing begun of mesh:  95_0_23_MSH
> 		processing begun of material:  Path
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.004 secs
> 		Custom split normals with tangents being used
> 		num positions      :  66
> 		num normals        :  66
> 		num tangents       :  66
> 		num uvs            :  132
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  66
> 	processing begun of mesh:  95_0_24_MSH
> 		processing begun of material:  Leaves
> 			WARNING: unsupported node type(ShaderNodeAddShader) will trigger baking
> 			bake time:  0 min, 0.023 secs
> 		Custom split normals with tangents being used
> 		num positions      :  702
> 		num normals        :  702
> 		num tangents       :  702
> 		num uvs            :  1404
> 		num uvs2           :  0
> 		num colors         :  0
> 		num indices        :  702
> ========= Writing of JSON file started =========
> ========= An error was encountered =========
>   File "C:\Users\geoff\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\json_exporter.py", line 154, in execute
>     self.to_json_file()
>   File "C:\Users\geoff\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\json_exporter.py", line 183, in to_json_file
>     material.to_json_file(file_handler)
>   File "C:\Users\geoff\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\materials\material.py", line 281, in to_json_file
>     write_color(file_handler, 'emissiveIntensity', self.bjsNodeTree.emissiveIntensity)
>   File "C:\Users\geoff\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\package_level.py", line 279, in write_color
>     file_handler.write(',"' + name + '":[' + format_color(color, precision) + ']')
>   File "C:\Users\geoff\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\package_level.py", line 159, in format_color
>     return format_float(color[0], fmt) + ',' + format_float(color[1], fmt) + ',' + format_float(color[2], fmt)
> ERROR:  'float' object is not subscriptable
> ========= end of processing =========
> elapsed time:  0 min, 1.7832 secs

Also, is it possible not to trigger the baking?

Ok I can reproduce with
emissive

If you do not wish baking, remove ‘Add Shader’. A ‘Mix Shader’ is supported, so a bake might be avoided with a substitution. Hanging everything off a ‘Principled Shader’ works best.

Also, every mesh is using Custom split normals. Where did these meshes come from a CAD system?

Fixed with 6.1.2

The mesh comes from 3Ds max, in FBX format. I believe that my colleague used a tool in 3Ds max to make hard edges… not sure.