onurhanaytac Posted August 3, 2017 Share Posted August 3, 2017 Hello everyone, I want to set my DeviceOrientationCamera initial rotation. I dig forum and found something about resetToCurrentRotation() but im not able to make it work. I want my DeviceOrientationCamera start with looking a target like ArcRotateCam What i mean by this I place my cam to right place but it look to wrong direction for initial position. cam = new babylon.DeviceOrientationCamera("DeviceOrientationCamera", position, scene); cam.rotationQuaternion.y = Math.PI / 2; cam.resetToCurrentRotation(); For example i want to turn my DeviceOrientationCamera X degree in Y axis then start controlling with device. What should i do? Thanks in advence! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 3, 2017 Share Posted August 3, 2017 Hello you are doing it correctly except for the rotationQuaternion. If is not angles for rotation but a quaternion you can affect it like this: cam.rotationQuaternion = BABYLON.FromRotationMatrix(BABYLON.Matrix.RotationY(Math.PI / 2)); onurhanaytac 1 Quote Link to comment Share on other sites More sharing options...
onurhanaytac Posted August 4, 2017 Author Share Posted August 4, 2017 Thanks for the answer @Deltakosh self.cam.rotationQuaternion = babylon.Quaternion.FromRotationMatrix(babylon.Matrix.RotationY(self.toRadians(self.compassDegree))); I did fix the angle. My scene know shows up correctly but after a second cam turns the same position i think i am not able to reset the rotationQuaternion https://www.babylonjs-playground.com/#8FFPCG#4 here is a code similar to what im doing. when i open this with my phone i need to turn the device X degree to see the scene. But just for a sec in the beginning it is rotate the cam i think I cannot reset the cam at that moment. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 4, 2017 Share Posted August 4, 2017 Perhaps try to do it in the scene.registerBeforeRender ? 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.