我[x,y,z,w]
从传感器获取四元数坐标。我想改变那个坐标,这样我就可以旋转我的 React VR 应用场景来旋转那个场景。我需要将四元数坐标更改为旋转坐标。但是这里的旋转是不平滑的,为了平滑旋转“四元坐标”必须转换为旋转。
import {VRInstance} from 'react-vr-web';
import scene from 'three.js';
//let us assume x,y,z,w are my coordinate in quaternion formate which I //am taking through web socket
function init(bundle, parent, options)
{
//scene=new scene()//three.js
const vr = new VRInstance(bundle, 'musical_exp_react_vr_pusher',
parent, {
// Add custom options here
...options,
});
vr.render = function() {
//but its not working as I took the quaternion coordiate
//smoothness is not there
vr.scene.rotationx=x;
vr.scene.rotationx=y;
vr.scene.rotationx=z;
//it is also not working
vr.scene.quaternion.x=x;
vr.scene.quaternion.y=y;
vr.scene.quaternion.z=z;
// Any custom behavior you want to perform on each frame goes here
};
// Begin the animation loop
vr.start();
return vr;
}
window.ReactVR = {init};
主要问题是我需要从四元数坐标中找到旋转轴坐标。