Three.sj 轮换通过网络发送信息不合适

问题描述 投票:0回答:0

请提出任何建议,不要讨厌标记这个问题。

注意:我现在不通过网络传递的方法与我们不能传递任何类的实例相同。但是 x,y,z,w 正常出现(simle vars),没关系。

视觉呈现:

链接:https://www.youtube.com/watch?v=92wKZpgwFhs&ab_channel=javascriptfanatic

我发送信息的地方:

       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
        });

接收网络数据


 // 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;

更多资料:

来源:https://github.com/zlatnaspirala/magic-three

networking three.js rotation webrtc
© www.soinside.com 2019 - 2024. All rights reserved.