Jump to content

How to move the camera in front of a mesh


MehdiZagouri
 Share

Recommended Posts

Hi @Arte

I really appreciate your help !

I tried this solution before , the issue is that , when i click in mesh "picture"' , the camera get the position of the mesh , that's not what i need , i need the camera just in front of the picture with a distance.

so when camera.position = picture.position ; i cannot see the picture , but i'm in the picture if you know what i mean !

Thank you so much.

Link to comment
Share on other sites

Thanks for all your answers !

I tried your solutions, but sometimes i don't know how to use them ,so i get a lot of unknown errors !

I tried this solution ! so i get  next to the mesh, know i need only to focus the direction of the camera in to the mesh " picture '" wich is Tableau[t] in my code :

 

                     if (pickResult.pickedMesh==Tableau[t])
                        {
                         console.log("Coucou");
                         
                            while (BABYLON.Vector3.Distance(camera.position,Tableau[t].position) > 5)
                            {
                                
                                console.log(BABYLON.Vector3.Distance(camera.position,Tableau[t].position));
                                
                                if (camera.position.x >Tableau[t].position.x + 2 )
                                {
                                    camera.position.x -= 0.5;
                                }
                                else if (camera.position.x <Tableau[t].position.x + 2 )
                                {
                                    camera.position.x += 0.5;
                                }
                                
                                if (camera.position.z >Tableau[t].position.z +2)
                                {
                                    camera.position.z -= 0.5;
                                }
                                else if (camera.position.z <Tableau[t].position.z +2 )
                                {
                                    camera.position.z += 0.5;
                                }     
                                
                                
                            }
                            
                             //camera.setTarget = Tableau[t].position;    
                            
                            
                        }

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