ovmihai Posted August 24, 2015 Share Posted August 24, 2015 Hello, i have a problem. This is my first intersection with babylon and i tried to create with code from playground and another topic i found here something like a independent axis dragging system. It works fine on X and Z, but i have no idea why on Y it's going crazy. I've attached my index.html. index.html Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 24, 2015 Share Posted August 24, 2015 Hi ovmihai and welcome to the forum! Could you try to set that up in a playground? It's easier to try thing out and people can show you right way what to do to fix your problem. Edit: nevermind, I did it: http://www.babylonjs-playground.com/#11AOBV But... it seems to work... I can move the things along their Y-axis if I move carefully. Just When you move the mosue too far to the left or the right it somehow drops the current mesh under the ground. Quote Link to comment Share on other sites More sharing options...
ovmihai Posted August 24, 2015 Author Share Posted August 24, 2015 Hi iiceman and thank you for your quick reply. Sorry, i should have done this from the beginning, here is the playground : http://www.babylonjs-playground.com/#2ATFP0 . If you click the sphere 3 axis will show and if you click the letters (X / Y / Z) and drag the sphere will move. But it's not ok on the Y axis. Quote Link to comment Share on other sites More sharing options...
ovmihai Posted August 24, 2015 Author Share Posted August 24, 2015 Hi ovmihai and welcome to the forum! Could you try to set that up in a playground? It's easier to try thing out and people can show you right way what to do to fix your problem. Edit: nevermind, I did it: http://www.babylonjs-playground.com/#11AOBV But... it seems to work... I can move the things along their Y-axis if I move carefully. Just When you move the mosue too far to the left or the right it somehow drops the current mesh under the ground.Exactly, that's the problem. Any idea how to solve this? Should i approach this problem in another way? Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 24, 2015 Share Posted August 24, 2015 Sorry, I don't have an idea yet why this acts so weirdly on the Y axis...maybe somebody else know. Maybe you can do some debugging to find the difference between dragging along the Y axis and the other..something must be different, I guess. I assume it's just that you loose the focus on the "Y" because the mouse moves faster than the "Y" does. And if so you cant calculate the correct point in 3D space to do your calculations. Sorry, I know that doesn't help much, but I don't have time do look into it more at the moment Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 24, 2015 Share Posted August 24, 2015 Hello this is because getGroundPosition uses the position on the ground to get the starting point (and ground is on a XZ axis). For Y you have to rely on another plane (which could be hidden) on XY axis Quote Link to comment Share on other sites More sharing options...
ovmihai Posted August 24, 2015 Author Share Posted August 24, 2015 Thank you for your time, iiceman and Deltakosh. Any suggestions how to achieve this? Just create another plane that is perpendicular with the one that i already have? But what if i am not looking at that plan when dragging on the Y axis, then should be 4 hidden "walls" ? Thank you. Edit: i've added some "walls" as DeltaKosh suggested. The Y axis seems to work a little bit better, but if you try to use the X or Z while the object is at some height, there will be some glitches, because of the height the ground point will be a little bit far(I don't know if i explained well this problem). Link: http://www.babylonjs-playground.com/#11AOBV#1 Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 25, 2015 Share Posted August 25, 2015 Maybe you can rely on screen coordinates. since you only drag one axis X and Y value should be good enough and you wouldn't need extra walls since your wall is the screen Quote Link to comment Share on other sites More sharing options...
ovmihai Posted August 25, 2015 Author Share Posted August 25, 2015 Maybe you can rely on screen coordinates. since you only drag one axis X and Y value should be good enough and you wouldn't need extra walls since your wall is the screen Sounds like a plan, i have to find out how to do this. Thank you. Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 25, 2015 Share Posted August 25, 2015 I think you could try using scene.pointerX and scene.pointerY, you already have those in your playground. Quote Link to comment Share on other sites More sharing options...
ovmihai Posted August 25, 2015 Author Share Posted August 25, 2015 I think you could try using scene.pointerX and scene.pointerY, you already have those in your playground.Then, what should i do different ? Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 25, 2015 Share Posted August 25, 2015 Uhm.. like that maybe: http://www.babylonjs-playground.com/#11AOBV#2 ovmihai 1 Quote Link to comment Share on other sites More sharing options...
ovmihai Posted August 25, 2015 Author Share Posted August 25, 2015 Uhm.. like that maybe: http://www.babylonjs-playground.com/#11AOBV#2Damn it works perfect, thank you very much for your time. This forum is one of the best i've ever seen. Keep up the good work guys! Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 25, 2015 Share Posted August 25, 2015 Cool, glad I could help. Don't forget to come back and show us what you created! By the way: you can mark the thread as answered, too, if you like. Quote Link to comment Share on other sites More sharing options...
ovmihai Posted August 26, 2015 Author Share Posted August 26, 2015 Cool, glad I could help. Don't forget to come back and show us what you created! By the way: you can mark the thread as answered, too, if you like.I will post a final result as soon as possible and yes i would mark the thread as answered. One more curiosity: if you rotate the camera, so let's say you are looking at the mesh from X axis(the red one)...the feedback it's a little weird because the axis does not rotate with the camera so you have the feeling to drag the X axis up or down but that's Y axis of the screen. Hope you understood what i mean Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 26, 2015 Share Posted August 26, 2015 Not sure what you mean. I realized that if you look from another side, the directions are mirrored. You drag right but the mesh moves left. But that's only from the X and Z axis... I don't really know what could go wrong with the Y axis. Maybe you could stick with the 3 dimensional coordinates based on the plane and use screen coordinates only for the Y axis? Quote Link to comment Share on other sites More sharing options...
ovmihai Posted August 27, 2015 Author Share Posted August 27, 2015 Not sure what you mean. I realized that if you look from another side, the directions are mirrored. You drag right but the mesh moves left. But that's only from the X and Z axis... I don't really know what could go wrong with the Y axis. Maybe you could stick with the 3 dimensional coordinates based on the plane and use screen coordinates only for the Y axis?Yes, that might be a solution.....but. There is always a but . If you go here: http://www.babylonjs-playground.com/#11AOBV#5 and pull the Y axis so the object is in the "air" and the zoom out a little bit...try to drag the X or Z axis. You will see that the "ground point" it's not correctly calculated because of the object's height. I think that some extra calculations might be needed to get the right ground point, like subtrating the distance according to the alpha angle of the camera when ray casting for picking the X or Z axis ? Z I will attach an image made with my paint skills, maybe help you understand: http://postimg.org/image/zemm3uk3h/ Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 27, 2015 Share Posted August 27, 2015 I think I know what you mean... what about not using your ground but an extra plane that only appears while dragging X or Z axis and has the same position as your object. You just add the plane when mouse down and dispose it on mouse up and calculate your point on this plane (the plane can be invisible). Quote Link to comment Share on other sites More sharing options...
ovmihai Posted August 31, 2015 Author Share Posted August 31, 2015 I am back with the closest example of what i've planned to achieve: http://www.babylonjs-playground.com/#11AOBV#7 . Thank you. c75, Wingnut and iiceman 3 Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 31, 2015 Share Posted August 31, 2015 Cool! Good job! Seems to work pretty well as far as I can tell. I would maybe increase the compensationFactor for the Y axis a bit, it's a little bit too fast compared to the other axis, I think. ovmihai 1 Quote Link to comment Share on other sites More sharing options...
ovmihai Posted September 1, 2015 Author Share Posted September 1, 2015 Yes, but that can be changed after each person's pleasure . Hope to come again with new questions. Quote Link to comment Share on other sites More sharing options...
diamondage Posted September 1, 2015 Share Posted September 1, 2015 Hi Ovmihai, I've got a similar problem as you but with stacked cubes here.The issue you will run into shortly is if your object is looked on directly by the camera. Your selection plane will be almost a sliver if not a line, and you won't be able to select to move the object. This approach of using ground works if you are offset at looking at the ground plane. So I am stuck trying to figure out how to unproject the screen coordinates via:http://forum.unity3d.com/threads/unity-4-3-get-2d-mouse-coordinates-relative-to-the-scene.214091/But I can't figure it out. W Quote Link to comment Share on other sites More sharing options...
ovmihai Posted September 2, 2015 Author Share Posted September 2, 2015 Hello diamondage, If i understood well, you are saying that there are cases when grabbing an axis the helper plane will be a line or even invisible so impossible to hit. Maybe a solution might be to always change the rotation of the helper plane to be perpendicular with the camera? so you will always cast a ray that will hit the plane under a 90 deg angle ? I am also a beginner so this is what i thought might be a possible approach. 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.