I wanna limit rotation by X and Z .
My camera [emiter] need more freedom for ratation angle but my net player needs only Y axis rotation and very small x and z local axis influence …
I hope someone will understand my poor en.
Visual presentation:
Link : Stackoverflow.com - Three.js rotation sending info via network not fit - YouTube
PLACE WHERE I SEND INFO :
if(this.net.connection) this.net.connection.send({
netPos: {x: i.position.x, y: i.position.y, z: i.position.z},
netRot: {
x: this.camera.rotation.x,
y: this.camera.rotation.y,
z: this.camera.rotation.z,
w: this.camera.quaternion.w
},
netQuaternion: this.camera.quaternion,
netObjId: this.net.connection.userid || i.name,
netType: 'netPlayer' // can be shared or enemy comp
});
RECEIVE NET DATA
// IN THIS CASE WORKS FINE BUT I CANT LIMIT ROTATION
const quaternion = new THREE.Quaternion();
// quaternion.fromArray ([
// e.data.netQuaternion._x,
// e.data.netQuaternion._y,
// e.data.netQuaternion._z,
// e.data.netQuaternion._w]);
// this.root.netPlayers['net_' + e.data.netObjId].rotation.setFromQuaternion(quaternion)
// IN THIS CASE NOT FULLY WORK ROTATION MANIFEST
this.root.netPlayers['net_' + e.data.netObjId].rotation.y = e.data.netRot.y;
I tried:
quaternion.setFromAxisAngle(new THREE.Vector3(0,0,1).normalize(), 0);
or
quaternion.setFromAxisAngle(new THREE.Vector3(1,0,0).normalize(), 0);
This block rotation to zero…
Because .rotation is represent of local rotation i also tried:
rotation.y = xx
This flips not full rotation of 360 …
i got from ~ 70 to the -70 deegress not 360 …
Any suggestion.
LAST UPDATE
i found this , it make little more better numbers for .rotation it gives from 0 to 180 and -180
Is there some way to get most basic from 0 to 360 deegre in three.js ?
camera.rotation.order = 'YXZ';
More data: