//请求池,key是userId,value是数组 var actionRequestPool = {}; var Actions = { Clicking:1, Rotation:1014, Joystick:15 } //用户信息,包括:用户Id var users = {}; var reply = { "traceIds": [], "vehicle": null, "newUserStates": [{ "userId": "dcff36ae4fc1d", "playerState": { "roomTypeId": "", "person": 0, "avatarId": "", "skinId": "", "roomId": "", "isHost": false, "isFollowHost": false, "skinDataVersion": "", "avatarComponents": "", "nickName": "", "movingMode": 0, "attitude": "", "areaName": "", "pathName": "", "pathId": "", "avatarSize": 1, "extra": "", "prioritySync": false, "player": { "position":{"x": -700, "y": 0, "z": 0}, "angle": { "pitch": 0, "yaw": 0, "roll": 0 } }, "camera": { "position": {"x": -1145, "y": 0, "z": 160}, "angle": { "pitch": 0, "yaw": 0, "roll": 0 } }, "cameraCenter": {"x": -700, "y": 0, "z": 0} }, "renderInfo": { "renderType": 0, "videoFrame": null, "cameraStateType": 3, "isMoving": 1, "needIfr": 0, "isVideo": 0, "stillFrame": 0, "isRotating": 0, "isFollowing": 0, "clientPanoTitlesBitmap": [], "clientPanoTreceId": "", "prefetchVideoId": "", "noMedia": false }, "event": null, "relation": 1 }], "actionResponses": [ // { // "actionType": 15, // "pointType": 100, // "extra": "", // "traceId": "d0864cd0-378d-4d49-b7b0-3e8e1b9494c3", // "packetId": "d44bd2f5-f877-4dd7-868b-803c64f99082", // "nps": [], // "peopleNum": 0, // "zoneId": "", // "echoMsg": "", // "reserveDetail": null, // "userWithAvatarList": [], // "newUserStates": [], // "code": 0, // "msg": "" // } ], "getStateType": 0, "code": 0, "msg": "OK" }; function init(app_id,userId){ var user = { appId:null, userId:null, breakPointId:null, player: { "position":{"x": -700, "y": 0, "z": 0}, "angle": { "pitch": 0, "yaw": 0, "roll": 0 } }, camera: { "position": {"x": -1145, "y": 0, "z": 160}, "angle": { "pitch": 0, "yaw": 0, "roll": 0 } }, rotateInfo:{ frameIndex:null, horizontal_move:0, mediaSrc:null }, moveInfo:{ }, traceIds:[] }; user.appId = app_id; user.userId = userId; users[userId] = user; reply["newUserStates"][0]["userId"] = userId; return reply; } function rotate(actionRequest){ let userId = actionRequest["user_id"]; if(actionRequestPool[userId]){ actionRequestPool[userId].push(actionRequest); } else{ actionRequestPool[userId] = []; actionRequestPool[userId].push(actionRequest); } let actionRequests = actionRequestPool[userId]; let user = users[userId]; let horizontal_move = user.rotateInfo.horizontal_move; let traceIds = user.traceIds; let sub = 0; for(let i=0;i