Jump to content

Importing LDraw (open LEGO CAD standard) model

Recommended Posts

Hi everyone!
Newbie to 3D game development here (but not in general programming), and Babylon.js enthusiast :)

For my project, I want to import Lego models in a Babylon scene.
I'm working in a Linux environment and the models are created with LeoCAD.

Actually, I manage to import successfully the models, but I do observe inconsistent results regarding physics (using Cannon.js) depending on the conversions pathway used:

  • raw LDraw model ⇨ imported as LDraw model in Blender ⇨ exported as .babylon 
    • no physics, the model goes through the ground.
  • LDraw model exported as .3DS in LeoCAD ⇨ imported as .3DS in Blender ⇨ exported as .babylon
    • physics OK but each submesh is handled separately (moving a mesh moves only this one). I tried then to use:

but the colors are of course lost.

  • LDdraw model exported as .3DS in LeoCAD ⇨ exported as .blend file with LDraw utility scripts ⇨ opened in Blender ⇨ exported as .babylon
    • physics OK and model appears as a single mesh 


So far so good, the single mesh is very convenient for positioning. The problem is I want to be able to target submeshes (eg. wheels in a car model).

So, this is more of a Blender question, but how could I import a model with a parent mesh that would allow me to handle to whole model, still having references to submeshes in order to animate them (for example)?

Please let me know if you need extra information or clarification (my english is made in France :-s)

Many thanks in advance!

Note: I've tried every combination of exports/imports, using Wavefront format, COLLADA, glTF - as far as I remember I always had physics issues.

Link to comment
Share on other sites

I got some help and the object I was looking for in Blender is the empty object.

However it does not work as expected regarding physics: I expected the empty object - which is set as parent of all meshes - to be able to handle the physics impostor on its own, but it does not.

A simple workaround is not using any empty object and setting programmatically the [1...n] meshes as children of the mesh 0 (which in this case is a simple Lego plate assimilated to the car frame) on load.
By doing so, the physics seem at first sight ok, but I don't know why (compared to the empty object setup). Can anybody give an explanation?

Also, the third case of my first post:


LDdraw model exported as .3DS in LeoCAD ⇨ exported as .blend file with LDraw utility scripts ⇨ opened in Blender ⇨ exported as .babylon

was working because the script joins all the meshes. But I would then be impossible to keep reference to wheels and animate them.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...