mrproko Posted April 3, 2017 Share Posted April 3, 2017 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? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 3, 2017 Share Posted April 3, 2017 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). http://www.babylonjs-playground.com/#1CMD3G#42 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. Quote Link to comment Share on other sites More sharing options...
mrproko Posted April 4, 2017 Author Share Posted April 4, 2017 Thank you so much @Wingnut! That model is exactly the example I was scouring the internet for. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.