Jump to content

how to change position of imported mesh


gadget
 Share

Recommended Posts

to test if the newMeshes[0] is truly "there", simply use

 

console.log(newMeshes[0])

 

and check to see if it shows the object tree in the console! <3

Or a bit more safely, depending on your browser environment, use 

console.log(Object.keys(newMeshes[0]).length);

(For example, node-webkit logs "" for an object that's unstringified, and stringifying an object with functions results in an error)

Link to comment
Share on other sites

I had tried: 

			scene.position = new BABYLON.Vector3(0,-1000,0);
            BABYLON.SceneLoader.ImportMesh("bmw7", "scenes/", "bmw7.babylon", scene, function (newMeshes) {                // Set the target of the camera to the first imported mesh                camera.target = newMeshes[0];								var car = scene.getMeshByID("bmw7");                car.position = new Babylon.vector3(-1000,-1000, -1000);

did not work

Link to comment
Share on other sites

Hello gadget, 

 

Try this : 

BABYLON.SceneLoader.ImportMesh("bmw7", "scenes/", "bmw7.babylon", scene, function (newMeshes) {   // Set the target of the camera to the first imported mesh   camera.target = newMeshes[0];				   var car = newMeshes[0];   car.position.y = -1000;}

Be careful, -1000 is a very high value. 

 

Cheers, 

Link to comment
Share on other sites

Hi gadget,

 

This is the way to change a mesh's position. I checked your babylon file - you only have one mesh, so newMeshes[0] is the correct object.

 

I can't help but asking - How do you expect to see the change you are doing in the mesh's position? the camera's target is the object itself, so even after you changed the object's position, the camera (you selected the ArcRotateCamera) will focus on that object. without any other reference objects in the area, or position output on the screen/console, you will never notice the object was moved...

 

Maybe help us understand what you really want to do, and we might be able to suggest a better solution. If you just want to be able to see the car from above , maybe change the camera type so you can position it above the object. the free camera might come in handy. 

 

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.

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