Jump to content

Drop mesh picked from imported .babylon file


ramkrishna
 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.
 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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