BabylonJS / BlenderExporter

Exports From Blender to Babylon.JS in JSON / .babylon format
Apache License 2.0
292 stars 47 forks source link

Invalid JSON with non-scalar custom props #67

Closed mwagner-webdev closed 11 months ago

mwagner-webdev commented 11 months ago

Apparently some versions of blender put data related to the Cycles renderer into the mesh metadata that this exporter then picks up. A line in my exporter logblender console output:

writing custom prop: cycles <bpy id prop: owner="MECone.018", name="cycles", address=0x7f74ebdf8668>

This breaks the JSON output since the code does not handle this non-scalar case and simply adds a comma to the output:

... ,{"name":"boulder.002","id":"boulder.002","billboardMode":0,"position":[83.0941,16.3566,-20.9974],"metadata": {,"bakeSize":1024} ...

(notice the comma before "bakeSize")

I'm making a PR once I have tested my fix. This only happened in one of my files so I am not sure how common this is, but it is definitely a bug.

Palmer-JC commented 11 months ago

Ok, I think I'll need a bare minimum example .blend for testing under separate cover. The only thing I use cycles for is making an .hdr that I convert into a .env

On Thu, Aug 24, 2023 at 9:33 AM Markus Wagner @.***> wrote:

Apparently some versions of blender put data related to the Cycles renderer into the mesh metadata that this exporter then picks up. A line in my exporter log:

writing custom prop: cycles <bpy id prop: owner="MECone.018", name="cycles", address=0x7f74ebdf8668>

This breaks the JSON output since the code does not handle this non-scalar case and simply adds a comma to the output:

... ,{"name":"boulder.002","id":"boulder.002","billboardMode":0,"position":[83.0941,16.3566,-20.9974],"metadata": {,"bakeSize":1024} ...

(notice the comma before "bakeSize")

I'm making a PR once I have tested my fix. This only happened in one of my files so I am not sure how common this is, but it is definitely a bug.

— Reply to this email directly, view it on GitHub https://github.com/BabylonJS/BlenderExporter/issues/67, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4MUY7LYPNEEX4TACHWVV3XW5JZZANCNFSM6AAAAAA35BHC3A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mwagner-webdev commented 11 months ago

There you go (blender file and all files created during export, I used the zip file Blender2Babylon-3.3x.zip in the master branch):

boulder_min_example.zip

Also, the blender console (this was on Linux but Windows should be the same) contained this:

writing custom prop: cycles <bpy id prop: owner="MEIcosphere.000", name="cycles", address=0x7fb92a1bc788>

but the log did not contain this line.

As you can see from the babylon file and the log, the mesh does not even have materials assigned, so I doubt it is directly related to the Cycles render engine.

edit: Blender version 3.3.9 used for everything