aWeirdo Posted July 5, 2016 Share Posted July 5, 2016 Hi all, i'm trying to find a good way to set a arcRotateCamera.target / setTarget() with an increased height on the Y axis, on a moving target.. right now, it "focuses" on the bottom of the mesh, i'd like it to focus on the top of the mesh, but changing the Y axis while still following the target isn't as easy as i'd hoped.. I've tried: camera.target = movingMesh; // follows the target correctly, but the y axis focus is around ground level, at the bottom of the mesh. camera.target.y += 5; // does nothing when target is set to a mesh as above^. camera.target = new BABYLON.Vector3(movingMesh.position.x, movingMesh.position.y + 5, movingMesh.position.z); // now the Y axis looks good, but it doesn't follow the target.. camera.target = movingMesh.position; //follows the target correctly.. camera.target.y += 5; //Still focusing the bottom of the mesh, now the entire movingMesh is moved upwards on the Y axis by 5.. as if you set movingMesh.position.y += 5; //Even tried editting the babaylonJs source code to apply the height change as target is being set. //but it also increase the Y position of the movingMesh instead of the target y axis of the camera.. //same happens for camera.setTarget().. I hope someone knows, or have a good idea as to how it can be done. and preferably without adding it to any kind of loop if possible, i know it can be done by updating the target x/y/z or vector3 in registerBeforeRender, but it appears rather choppy sometimes, even at 60 fps it is notiseable. PG: http://www.babylonjs-playground.com/#24IFYG Cheers for any help and ideas! Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted July 5, 2016 Author Share Posted July 5, 2016 Hi @adam made a PG: http://www.babylonjs-playground.com/#24IFYG some of the different solutions i've tried is located at the bottom of the code block. Quote Link to comment Share on other sites More sharing options...
adam Posted July 5, 2016 Share Posted July 5, 2016 I would do this: http://www.babylonjs-playground.com/#10JKYM#17 Quote Link to comment Share on other sites More sharing options...
adam Posted July 5, 2016 Share Posted July 5, 2016 Just saw your PG. http://www.babylonjs-playground.com/#24IFYG#1 aWeirdo 1 Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted July 5, 2016 Author Share Posted July 5, 2016 @adam Thanks for your reply, already tried that and it appeared alittle choppy on my scene from time to time, But i suppose it will have to do for now, and copyFrom seems to work slightly better than mesh.position.clone() which i used.. better than before atleast Cheers 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.