gadget Posted October 28, 2014 Share Posted October 28, 2014 http://yeweiming.asia/bmw7.htmlI want to change position of imported mesh(the car), to a lower position, I have tried something like this: BABYLON.SceneLoader.ImportMesh("", "scenes/", "skull.babylon", scene, function (newMeshes) { newMeshes[0].position.y = -1000;}); does not work. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 28, 2014 Share Posted October 28, 2014 Are you sure that newMeshes[0] is the good object Quote Link to comment Share on other sites More sharing options...
joshcamas Posted October 29, 2014 Share Posted October 29, 2014 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 Quote Link to comment Share on other sites More sharing options...
Stephen Andrews Posted October 29, 2014 Share Posted October 29, 2014 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! <3Or 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) Quote Link to comment Share on other sites More sharing options...
gadget Posted October 29, 2014 Author Share Posted October 29, 2014 newMeshes is not my point.I want to lower down the car, to vertical middle position.how to change position of loaded mesh or scene? Quote Link to comment Share on other sites More sharing options...
gadget Posted October 29, 2014 Author Share Posted October 29, 2014 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 Quote Link to comment Share on other sites More sharing options...
Temechon Posted October 29, 2014 Share Posted October 29, 2014 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, Quote Link to comment Share on other sites More sharing options...
gadget Posted October 29, 2014 Author Share Posted October 29, 2014 does not work can anyone take a try on changing position of a loded scene or imported meshes Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 29, 2014 Share Posted October 29, 2014 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! GameMonetize and Temechon 2 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.