ramkrishna Posted September 22, 2018 Share Posted September 22, 2018 Hello All, Thanks for your help you guys are making through this forum, this is my first question to this forum. I am new to game programming and BabylonJS. I want to create a program that can load 3d model, allows to edit that model by moving some of meshes to another location which will remain that position. Below are the things i have achieved till now. 1. I have created program that can load 3d model in ".babylon" format. 2. I am able to select meshes and move them around. But, i am not able drop mesh which i have selected, it is keep attached to mouse pointer. How can i achieve same. Please help. Attached is the sample file generated from playground and here is the link to playground http://www.babylonjs-playground.com/ sample.zip Quote Link to comment Share on other sites More sharing options...
ramkrishna Posted September 24, 2018 Author Share Posted September 24, 2018 Hello @Deltakosh and @Wingnut, Please help on above question Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 24, 2018 Share Posted September 24, 2018 Hi @ramkrishna. Welcome on board. Here is your playground: http://playground.babylonjs.com/#060K58 And here is a quick fix: http://playground.babylonjs.com/#060K58#1 The problem was line 43 and 51 where your variable camera is undefined. Use scene.activeCamera instead. ps: Take a look at https://doc.babylonjs.com/how_to/meshbehavior. https://www.babylonjs-playground.com/#9UFEBE may it help you. Quote Link to comment Share on other sites More sharing options...
ramkrishna Posted September 24, 2018 Author Share Posted September 24, 2018 Hello @MarianG, Thanks for reply. Provided solution exactly full fill my requirements. But i have few questions regarding it as below. 1. Is it mandatory to define separate ground even in loaded models? how we can use existing ground of loaded scene? 2. How i can make sure my camera will always render my scene as it is designed. I mean in my case i should always looking at entrance of house and my scene should be look like i am actually look like i am standing in front of room. Actually i am trying build model which will load .babylon models and render it as it is designed. Also, if he want to edit he can do so. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 24, 2018 Share Posted September 24, 2018 Hey, sory for late. 1. The ground is used only for moveing. See getGroundPosition functions from here http://playground.babylonjs.com/#UZ23UH#0 Because of this ground the objects move only on x and z axis. Now if you take a look at your playground, it doesn't use ground, (you build it but never use), so the objects can move in all the axis, but a little bit random. And the short answer is yes. You can remove it. http://playground.babylonjs.com/#060K58#2 The scene will still work. Or you can use ground from your scene. like here http://playground.babylonjs.com/#060K58#3. 2. More about how to set camera in scene, how to limit its moves and more, you'll find here: http://doc.babylonjs.com/babylon101/cameras. Quote Link to comment Share on other sites More sharing options...
ramkrishna Posted September 25, 2018 Author Share Posted September 25, 2018 Hello @MarianG, Thanks for reply. I will go through your comments and update you accordingly. MarianG 1 Quote Link to comment Share on other sites More sharing options...
ramkrishna Posted September 30, 2018 Author Share Posted September 30, 2018 Hello @MarianG, Sorry for delayed reply. I am able to move meshes around scene. Now, when i export this code for local testing i get "index.html" and when i try to run it i get below error at scene.render. babylon.js:1 Uncaught Error: No camera defined at E.render (babylon.js:1) at Edit.html:139 at M._renderLoop (babylon.js:1) Any suggestions on it? Thanks Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 30, 2018 Share Posted September 30, 2018 Auch, I don't know. Try to put createDefultCameraorLight outside of importMesh function. I'll check in few hours. Quote Link to comment Share on other sites More sharing options...
MarianG Posted October 1, 2018 Share Posted October 1, 2018 Hey @ramkrishna. I just checked, and yes, it seems, with CreateDefaultCameraorLight at the begining, it works. Quote Link to comment Share on other sites More sharing options...
ramkrishna Posted October 1, 2018 Author Share Posted October 1, 2018 Hello @MarianG, Correct!! it worked. Just one thought came into my mind, can we save changes made by us in model while playing around so that when we re-execute HTML+ JS which refer to model will always point to updated one? Your comments please. Quote Link to comment Share on other sites More sharing options...
MarianG Posted October 1, 2018 Share Posted October 1, 2018 Related to save, take a look at this http://doc.babylonjs.com/api/classes/babylon.sceneserializer. http://doc.babylonjs.com/resources/save_babylon You can save the entire scene or a specific mesh. Quote Link to comment Share on other sites More sharing options...
ramkrishna Posted October 1, 2018 Author Share Posted October 1, 2018 @MarianG, Thank you! I will try this approach and let you know. MarianG 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.