xushiting 3 tahun lalu
induk
melakukan
fb6f3b969f
4 mengubah file dengan 124 tambahan dan 15 penghapusan
  1. 2 0
      dist/index.html
  2. 21 4
      src/ActionsHandler.js
  3. 83 0
      src/Response.js
  4. 18 11
      src/XAvatar.js

+ 2 - 0
dist/index.html

@@ -69,6 +69,8 @@
     const VERSION$1 = "1.0.75"
     , ENV = "production";
   
+    const nickname = "1f7acca1db9d5";
+
     const COMPONENT_LIST_PREFIX = "/component_list.json";
     const isFunction = i=>typeof i == "function";
 

+ 21 - 4
src/ActionsHandler.js

@@ -5,11 +5,12 @@ import Person from "./enum/Person.js"
 import ClickType from "./enum/ClickType.js"
 import Logger from "./Logger.js"
 
-
+import Response from "./Response.js"
 import { VDecoder } from "./h264Decoder/VDecoder.js";
 
 const logger = new Logger('actions-handler')
 const QueueActions = [Actions.Transfer, Actions.ChangeSkin, Actions.GetOnVehicle, Actions.GetOffVehicle];
+
 export default class ActionsHandler {
     constructor(e) {
         this.currentActiveAction = null
@@ -373,7 +374,7 @@ export default class ActionsHandler {
     }
     */
     
-
+    /*
     rotate({type: type, angle: angle}) {
         let endRotation = window.room.sceneManager.cameraComponent.mainCamera.rotation.y
         if(endRotation<0){
@@ -404,9 +405,25 @@ export default class ActionsHandler {
  
         // this.room.sceneManager.cameraComponent.mainCamera.rotation.y = endRotation
         // window.room.sceneManager.cameraComponent._cameraPose.rotation._y = endRotation
-        window.room.sceneManager.cameraComponent.mainCamera.rotation.y=endRotation
-    }
+        // window.room.sceneManager.cameraComponent.mainCamera.rotation.y=endRotation
+        let response = JSON.parse(JSON.stringify(Response))
+        response.signal.newUserStates[0].playerState.player.position.x = this.room.avatarManager.avatars.get(nickname).position.x
+        response.signal.newUserStates[0].playerState.player.position.y = this.room.avatarManager.avatars.get(nickname).position.y
+        response.signal.newUserStates[0].playerState.player.position.z = this.room.avatarManager.avatars.get(nickname).position.z
 
+        response.signal.newUserStates[0].playerState.player.angle.pitch = this.room.avatarManager.avatars.get(nickname).rotation.pitch
+        response.signal.newUserStates[0].playerState.player.angle.yaw = this.room.avatarManager.avatars.get(nickname).rotation.yaw
+        response.signal.newUserStates[0].playerState.player.angle.roll = this.room.avatarManager.avatars.get(nickname).rotation.roll
+
+        response.signal.newUserStates[0].playerState.camera.position = 
+        response.signal.newUserStates[0].playerState.camera.angle = 
+
+        response.signal.newUserStates[0].playerState.cameraCenter.x = this.room.avatarManager.avatars.get(nickname).position.x
+        response.signal.newUserStates[0].playerState.cameraCenter.y = this.room.avatarManager.avatars.get(nickname).position.y
+        response.signal.newUserStates[0].playerState.cameraCenter.z = this.room.avatarManager.avatars.get(nickname).position.z
+ 
+    }
+    */
     fetchData({sFrame: sfns, eFrame: efns}){
         if(window.workerReady){
             this.vDecoder.fetch({

+ 83 - 0
src/Response.js

@@ -0,0 +1,83 @@
+var Response = {
+	"signal": {
+		"traceIds": [],
+		"vehicle": null,
+		"newUserStates": [{
+			"userId": null,    //要补充
+			"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": null,
+						"y": null,
+						"z": null
+					},
+					"angle": {                 //要补充
+						"pitch": 0,
+						"yaw": 0,
+						"roll": 0
+					}
+				},
+				"camera": {
+					"position": {              //要补充
+						"x": null,
+						"y": null,
+						"z": null
+					},
+					"angle": {                 //要补充
+						"pitch": 0,          
+                        "yaw": 0,
+						"roll": 0
+					}
+				},
+				"cameraCenter": {               //要补充
+                    "x": null,
+                    "y": null,
+                    "z": null
+				}
+			},
+			"renderInfo": {
+				"renderType": 0,
+				"videoFrame": null,
+				"cameraStateType": 0,
+				"isMoving": 0,
+				"needIfr": 0,
+				"isVideo": 0,
+				"stillFrame": 0,
+				"isRotating": 0,
+				"isFollowing": 0,
+				"clientPanoTitlesBitmap": [],
+				"clientPanoTreceId": "",
+				"prefetchVideoId": "",
+				"noMedia": false
+			},
+			"event": null,
+			"relation": 1
+		}],
+		"actionResponses": [],
+		"getStateType": 0,
+		"code": 0,
+		"msg": "OK"
+	},
+	"pts": null,
+	"alreadyUpdateYUV": true
+}
+export default Response

+ 18 - 11
src/XAvatar.js

@@ -216,12 +216,18 @@ export default class XAvatar {
         return e || []
     }
     setPosition(e, t=!1) {
-        if (this._avatarPosition = e,
-        this.rootNode) {
+        this._avatarPosition = e;
+        if (this.rootNode) {
             const r = util.ue4Position2Xverse(this._avatarPosition);
             let n = !1;
-            this.avatarManager.getMainAvatar() && (this.id != this.avatarManager.getMainAvatar().id || (Math.abs(r.y - this._previousReceivedPosition.y) > castRayOffsetY && (n = !0),
-            r.subtract(this._previousReceivedPosition).length() > castRayTeleportationOffset && (n = !0))),
+            if(this.avatarManager.getMainAvatar()){
+                if(this.id == this.avatarManager.getMainAvatar().id){
+                    Math.abs(r.y - this._previousReceivedPosition.y) > castRayOffsetY && (n = !0);
+                    if(r.subtract(this._previousReceivedPosition).length() > castRayTeleportationOffset){
+                        n = !0
+                    }
+                }
+            }
             this._isRayCastEnable ? n || t ? this._castRay(e).then(o=>{
                 this.rootNode.position = r,
                 this.rootNode.position.y -= o
@@ -236,23 +242,24 @@ export default class XAvatar {
         return Promise.resolve(e)
     }
     setRotation(e) {
-        if (this._avatarRotation = e,
-        this.rootNode) {
+        this._avatarRotation = e;
+        if (this.rootNode) {
             const t = {
                 pitch: e.pitch,
                 yaw: e.yaw + 180,
                 roll: e.roll
             }
-              , r = util.ue4Rotation2Xverse(t);
+            const r = util.ue4Rotation2Xverse(t);
             this.rootNode.rotation = r
         }
     }
     setAvatarVisible(e) {
-        this.rootNode && (this.rootNode.setEnabled(e),
-        this.rootNode.getChildMeshes().forEach(t=>{
-            t.setEnabled(e)
+        if(this.rootNode){
+            this.rootNode.setEnabled(e),
+            this.rootNode.getChildMeshes().forEach(t=>{
+                t.setEnabled(e)
+            })
         }
-        ))
     }
     setScale(e) {
         this._avatarScale = e,