Wintersun Posted July 26, 2018 Share Posted July 26, 2018 Hello, newbie here coming from both 3d World and Web dev World. currently I'm working on a project and I've made 3 handles for user to rotate the mesh on local Axis everything works fine. when the user finished doing what he does, I save the object rotation by getting the quaternion like this mesh.rotationQuaternion and save it either as separate values for x y z and w or whole object, but after reloading when I apply the same quaternion rotation to the object like mesh.rotationQuaternion = new BABYLON.Quaternion(this.rx, this.ry, this.rz, this.ra); I get a squashed and streched mesh in so many ways and it's not the same shape at all. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
Guest Posted July 26, 2018 Share Posted July 26, 2018 Welcome!! Based on your description it should work can you repro in the PG? Quote Link to comment Share on other sites More sharing options...
Wintersun Posted July 26, 2018 Author Share Posted July 26, 2018 4 minutes ago, Deltakosh said: Welcome!! Based on your description it should work can you repro in the PG? Thank you I used vue.js wrapping it, so it would take some time but sure Quote Link to comment Share on other sites More sharing options...
JohnK Posted July 26, 2018 Share Posted July 26, 2018 Hi @Wintersun and welcome from me. You can just put your basic methods into a PG to see what happens. Here is a simple example where one box is created and rotated, the rotation stored, the box rotated again and the stored rotation applied to a different box obtaining the first rotation. If you want to re-apply it to the original box then take out the comment from the penultimate line. https://www.babylonjs-playground.com/#4GEDM2 Perhaps you can build on this to show how you carry out rotations, store them and re-apply them. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 26, 2018 Share Posted July 26, 2018 4 hours ago, Wintersun said: mesh.rotationQuaternion = new BABYLON.Quaternion(this.rx, this.ry, this.rz, this.ra); Here is another example. Note what the Quaternion is (y,x,z), so different than Vector3. https://www.babylonjs-playground.com/#1ST43U#54 Still that should do any squashing if you get those backwards... edit: oops. the main constructor is x,y,z,a, but I normally use RotationYawPitchRoll. If the rotationQuaternion is NOT set then you need to get the mesh.rotation! Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 26, 2018 Share Posted July 26, 2018 4 hours ago, Wintersun said: I've made 3 handles for user to rotate the mesh Have you found gizmo? https://doc.babylonjs.com/how_to/gizmo Welcome to the forum, by the way. Quote Link to comment Share on other sites More sharing options...
Wintersun Posted July 26, 2018 Author Share Posted July 26, 2018 1 minute ago, brianzinn said: Have you found gizmo? https://doc.babylonjs.com/how_to/gizmo Welcome to the forum, by the way. OMFG I'm gonna cry I made all of it from SCRATCH! :((((((((((( oh no.... I even searched a lot for something similar. OH GOD KILL ME NOW. brianzinn and babbleon 1 1 Quote Link to comment Share on other sites More sharing options...
Wintersun Posted July 26, 2018 Author Share Posted July 26, 2018 I'm gonna try again with gizmo and update you guys. All the time I wasted... Quote Link to comment Share on other sites More sharing options...
Guest Posted July 26, 2018 Share Posted July 26, 2018 That's why the forum is an invaluable resource Quote Link to comment Share on other sites More sharing options...
Wintersun Posted July 26, 2018 Author Share Posted July 26, 2018 You know I searched a lot with keywords like "Axis" or "Moving object with Axis" or "Rotation Axis" the keyword was "GIZMO" I'm such an idiot and all I got was someone else trying to do the same and he had the movement axis. You can't even imagine the code I have right now. It's monster, even with refactoring. Thank you very much guys. should have done it earlier. it will definitely help. hope I don't encounter the same problem. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 26, 2018 Share Posted July 26, 2018 I have definitely some moments where I found something I made from scratch -- WAY too many times to mention! The Gizmo is included with BabylonJS, but here is another one that might give you some ideas - they are separate projects: https://ssatguru.github.io/BabylonJS-EditControl/demo Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 26, 2018 Share Posted July 26, 2018 Knowing how to script your own gizmos too (even though you say a waste of time) is a pretty valid skill/good practice. Quote Link to comment Share on other sites More sharing options...
Wintersun Posted July 27, 2018 Author Share Posted July 27, 2018 17 hours ago, brianzinn said: I have definitely some moments where I found something I made from scratch -- WAY too many times to mention! The Gizmo is included with BabylonJS, but here is another one that might give you some ideas - they are separate projects: https://ssatguru.github.io/BabylonJS-EditControl/demo Thank you very much. I feel you dude. 15 hours ago, Pryme8 said: Knowing how to script your own gizmos too (even though you say a waste of time) is a pretty valid skill/good practice. not that I mean it's wasted because I didn't learn anything but sometimes it's actually more of a trial and error than learning. this wasn't the latter although It helped a lot. Ok, I've setup gizmo didn't know It was on the alpha version of babylon but it's really solid and does everything I wanted it to do although the same problem with camera angle and sometimes inverse moving on x and y axis is still there but that's not a big problem. the problem with squash is gone now but I found a bug : after touching the gizmo doesn't matter if you move or rotate or scale or not, the position of x will be inverted I mean if it's positive it will be negative if it's negative it will be positive. the other thing is the rotation of x and y will be inverted and at the same time swapped with each other so in example If I have something like this => position : (x: 1, y:1, z:1); qRotation: (x:0.5, y:0.4, z:0.2, w:0.1) after just touching the bounding box of gizmo (not even moving) the result will be : position : (x: -1, y:1, z:1); qRotation: (x:-0.4, y: -0.5, z:0.1, w:0.2); the scale won't change. dunno if it's a bug or I'm doing something wrong but I'm not manipulating anything in the process just storing and retrieving. I'm gonna make a playground If I can. edit: z and w will be swapped as well. Scale Y will be inverted too. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 27, 2018 Share Posted July 27, 2018 try to post a repro as a PG (playground) and we can figure out if it's a bug or usage issue. 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.