Jump to content

Blender Import and Camera Collisions


Recommended Posts

I'm very new to Babylon, and JS altogether. I've made a virtual room in blender, and I've gotten it working with a normal SceneLoader set up. My only issue is that I want the free cam to collide with the bounding boxes of the blender model (interior of room.) I've gotten simple Babylon models working that contain camera collision, but only pertaining to specifically assigned meshes that are solely built in Babylon (like a sphere, box, ground...) 

Simply put, how do I get my free cam to collide with all the provided mesh/bounding boxes of the imported blender model?

Link to comment
Share on other sites

Hiya @mrproko, welcome to the forum.  Likely, you have not set your .checkCollisions = true; on camera, walls, and possibly ground.

Here is a Babylon playground demo that does a model load, then activates a camera (line 39), and a shadowGenerator (line 22), and then sets .checkCollisions = true on everything important (lines 51-53).  It is all done within the sceneLoader onSuccess callback function area (more about that below).


Click on canvas and then up-arrow the camera into the mesh.  Stops dead.  :)  Ground also stops the camera.

Everything is commented, somewhat. 

Take a look at the END of line 7.  See that function (newMesh){   ...out there?  That is the start of the onSuccess callback function.  It ends at line 65.  See how we put almost all of the scene code... inside that func?   It is a "after the mesh loads..." work area.

Setting .checkCollisions on the imported mesh BEFORE export from Blender - I'm not sure how to do that, if it is possible.  Sorry.  The method shown in the playground... will work. 

Feel free to change models, edit like crazy, re-RUN and re-SAVE anything you wish... in that playground demo.  You cannot hurt anything. 

If you make some more edits and saves, and have questions or problems, just ask/holler... we're here to help.  The playground generates a new URL each time you SAVE.  Make sure you post the URL to the playground that you want to talk about.  :)  Welcome again!  I hope this helps.

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...