zhouenguang %!s(int64=3) %!d(string=hai) anos
pai
achega
50dedc1aca
Modificáronse 5 ficheiros con 105 adicións e 115 borrados
  1. 65 73
      src/ActionsHandler.js
  2. 2 2
      src/XCameraComponent.js
  3. 29 29
      src/XMaterialComponent.js
  4. 1 4
      src/XSceneManager.js
  5. 8 7
      src/XverseAvatar.js

+ 65 - 73
src/ActionsHandler.js

@@ -15,6 +15,7 @@ export default class ActionsHandler {
         this.room = room
     }
 
+    // 在_handleAvatar时调用
     async avatarComponentsSync(avatarComponents) {
         this.sendData({
             data: {
@@ -128,7 +129,7 @@ export default class ActionsHandler {
         ))
     }
 
-    // Panorama.exit()中调用
+    // 用于Panorama.exit()
     changeRotationRenderType({renderType, player, camera, areaName, attitude, pathName}) 
     {
         return this.transfer({
@@ -160,7 +161,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 设置角色行动类型,如MotionType.Walk。方法未调用
+    // 用于XverseAvatar.setMotionType()。方法未执行
     setMotionType(type) 
     {
         return this.transfer({
@@ -169,7 +170,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 设置角色昵称
+    // 设置角色昵称。用于XverseAvatar.setNickname()
     setNickName(nickname) 
     {
         return this.sendData({
@@ -182,7 +183,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 方法未调用
+    // 方法未执行
     getReserveSeat({routeId, name}) 
     {
         return this.sendData({
@@ -196,7 +197,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 方法未调用
+    // 方法未执行
     getReserveStatus({routeId, name, need_detail}) 
     {
         return this.sendData({
@@ -223,7 +224,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 方法未调用
+    // 方法未执行
     getOnVehicle({routeId, name, camera}) 
     {
         return this.sendData({
@@ -238,7 +239,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 方法未调用
+    // 方法未执行
     getOffVehicle({renderType, player, camera}) 
     {
         return this.sendData({
@@ -281,77 +282,68 @@ export default class ActionsHandler {
         })
     }
 
-    // 方法未调用
-    async changeSkin(e) 
+    // 方法未执行
+    async changeSkin(skinData) 
     {
-        const t = e.special === void 0 ? e.renderType === RenderType.ClientRotationPano : e.special
-          , {skinId: r, mode: n, landingType: o=LandingType.Stay, landingPoint: a, landingCamera: s, renderType: l, areaName: u, attitude: c, pathName: h, person: f, noMedia: d, timeout: _, roomTypeId: g=""} = e
-          , m = this.room.skinList.filter(y=>y.id === r)[0];
-        if (!m) {
-            const y = `skin ${r} is invalid`;
+        const { skinId, mode, landingType=LandingType.Stay, landingPoint, landingCamera, renderType, areaName, attitude, pathName, person, noMedia, timeout, 
+            roomTypeId="", special } = skinData
+
+        const newSkin = this.room.skinList.filter(skin => skin.id === skinId)[0];
+        if (!newSkin) {
+            const y = `skin ${skinId} is invalid`;
             return logger.error(y),
             Promise.reject(new ParamError(y))
         }
-        const v = {
-            action_type: Actions.ChangeSkin,
-            change_skin_action: {
-                skinID: r,
-                mode: n === ChangeMode.Preview ? ChangeMode.Preview : ChangeMode.Confirm,
-                skin_data_version: r + m.versionId,
-                landing_type: o,
-                landing_point: a,
-                landing_camera: s,
-                render_wrapper: {
-                    render_type: l
-                },
-                areaName: u,
-                attitude: c,
-                noMedia: d,
-                person: f,
-                pathName: h,
-                roomTypeId: g
-            }
-        };
+
         return this.sendData({
-            data: v,
-            timeout: _ || 6e3,
-            special: t
-        }).then(async y=>{
-            if (l === RenderType.ClientRotationPano && y) {
-                const b = await this.room.modelManager.findRoute(r, h)
-                  , {camera: T} = util.getRandomItem(b.birthPointList) || {};
-                await this.room.panorama.handleReceivePanorama(y, T)
+            data: {
+                action_type: Actions.ChangeSkin,
+                change_skin_action: {
+                    skinID: skinId,
+                    mode: mode === ChangeMode.Preview ? ChangeMode.Preview : ChangeMode.Confirm,
+                    skin_data_version: skinId + newSkin.versionId,
+                    landing_type: landingType,
+                    landing_point: landingPoint,
+                    landing_camera: landingCamera,
+                    render_wrapper: {
+                        render_type: renderType
+                    },
+                    areaName,
+                    attitude,
+                    noMedia,
+                    person,
+                    pathName,
+                    roomTypeId
+                }
+            },
+            timeout: timeout || 6e3,
+            special: special === void 0 ? renderType === RenderType.ClientRotationPano : special
+        })
+        .then(async y=>{
+            if (renderType === RenderType.ClientRotationPano && y) {
+                const route = await this.room.modelManager.findRoute(skinId, pathName)
+                  , {camera} = util.getRandomItem(route.birthPointList) || {};
+                await this.room.panorama.handleReceivePanorama(y, camera)
             }
-            return this.handleChangeSkin(e)
-        }
-        ).catch(y=>d ? this.handleChangeSkin(e) : Promise.reject(y))
+            return this.handleChangeSkin(skinData)
+        })
+        .catch(e => noMedia ? this.handleChangeSkin(skinData) : Promise.reject(e))
     }
 
-    handleChangeSkin(e) 
+    handleChangeSkin({skinId, mode, renderType, areaName, attitude, pathName}) 
     {
-        const {skinId: t, mode: r, renderType: n, areaName: o, attitude: a, pathName: s} = e;
         return this.room.sceneManager.staticmeshComponent.getCgMesh().show(),
         this.room.sceneManager.cameraComponent.switchToCgCamera(),
-        this.room.engineProxy._updateSkinAssets(t).then(()=>{
+        this.room.engineProxy._updateSkinAssets(skinId).then(()=>{
             this.room.sceneManager.staticmeshComponent.getCgMesh().hide(),
             this.room.sceneManager.cameraComponent.switchToMainCamera(),
-            this.room.pathManager.currentArea = o,
+            this.room.pathManager.currentArea = areaName,
             logger.info("changeSkin _updateSkinAssets susccss"),
-            this.room.updateCurrentNetworkOptions({
-                pathName: s,
-                attitude: a,
-                areaName: o
-            }),
+            this.room.updateCurrentNetworkOptions({ pathName, attitude, areaName }),
             this.room.skinChangedHook(),
-            this.room.emit("skinChanged", {
-                skin: {
-                    id: t
-                },
-                mode: r
-            }),
-            n === RenderType.ClientRotationPano && this.room.sceneManager.cameraComponent.allowMainCameraController()
-        }
-        )
+            this.room.emit("skinChanged", { skin: { id: skinId }, mode }),
+            renderType === RenderType.ClientRotationPano && this.room.sceneManager.cameraComponent.allowMainCameraController()
+        })
     }
 
     // 相机旋转
@@ -360,7 +352,7 @@ export default class ActionsHandler {
         if (
             this.room.disableRotate || 
             this.room.isPano || 
-            (this.room._userAvatar == null ? void 0 : this.room._userAvatar._isChangingComponentsMode)
+            (this.room._userAvatar && this.room._userAvatar._isChangingComponentsMode)
         ) return;
         
         this.sendData({
@@ -375,7 +367,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 方法未调用
+    // 用于XverseAvatar.turnTo()。方法未执行
     turnTo({point, timeout=2e3, offset=8} = {}) 
     {
         return this.sendData({
@@ -390,7 +382,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 人物旋转
+    // 用于XverseAvatar.rotateTo()。方法未执行
     rotateTo({point, offset=0, speed=3} = {}) 
     {
         return this.sendData({
@@ -428,7 +420,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 用于Debug.getPointsAndRender()
+    // 显示呼吸点。用于Debug.getPointsAndRender()
     getNeighborPoints({point, containSelf=!1, searchRange=500}) 
     {
         return this.sendData({
@@ -444,7 +436,7 @@ export default class ActionsHandler {
         }).then(a=>a.nps)
     }
 
-    // 方法未调用
+    // 方法未执行
     playCG(cgName) 
     {
         return this.sendData({
@@ -457,7 +449,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 方法未调用
+    // 方法未执行
     audienceToVisitor({avatarId, avatarComponents, player, camera}) 
     {
         return logger.debug("send data: audience to visitor"),
@@ -474,7 +466,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 方法未调用
+    // 方法未执行
     visitorToAudience({renderType, player, camera, areaName, attitude, pathName, person:personType, noMedia}) 
     {
         return logger.debug("send data: visitor to audience"),
@@ -500,7 +492,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 方法未调用
+    // 方法未执行
     removeVisitor({removeType, userIDList, extraInfo=""}) 
     {
         return logger.debug("send data: remove visitor"),
@@ -516,7 +508,7 @@ export default class ActionsHandler {
         })
     }
 
-    // 方法未调用
+    // 方法未执行
     getUserWithAvatar(userType, roomID) 
     {
         return logger.debug("send data: get user with avatar"),
@@ -545,7 +537,7 @@ export default class ActionsHandler {
         }).then(o => o)
     }
 
-    // 方法未调用
+    // 方法未执行
     setSyncPolicy({syncPolicy}) 
     {
         return this.sendData({

+ 2 - 2
src/XCameraComponent.js

@@ -20,10 +20,10 @@ export default class XCameraComponent {
             this.mainCamera.fov = Math.PI * this.yuvInfo.fov / 180,
             this.mainCamera.maxZ = t,
             this.mainCamera.fovMode = BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED,
-            this.cgCamera = new BABYLON.FreeCamera("camera_temp",new BABYLON.Vector3(0,0,1),this.scene),
+            this.cgCamera = new BABYLON.FreeCamera("camera_temp",new BABYLON.Vector3(0,1e3,0),this.scene),
             this.cgCamera.mode = BABYLON.Camera.PERSPECTIVE_CAMERA,
             this.cgCamera.speed = .1,
-            this.cgCamera.setTarget(new BABYLON.Vector3(0,0,0)),
+            this.cgCamera.setTarget(new BABYLON.Vector3(0,1010,0)),
             this.cgCamera.maxZ = t,
             this.cgCamera.minZ = r,
             this.cgCamera.fovMode = BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED,

+ 29 - 29
src/XMaterialComponent.js

@@ -99,40 +99,40 @@ export default class XMaterialComponent {
         );
     });
 
-      E(this, "updateRawYUVData", (stream, width, height, fov=-1)=>{
-          fov == -1 && (fov = this.yuvInfo.fov);
+    E(this, "updateRawYUVData", (stream, width, height, fov=-1)=>{
+        fov == -1 && (fov = this.yuvInfo.fov);
 
-          if (this._isUpdateYUV == !0) {
-              console.log('执行:updateRawYUVData')
-              const yuvInfo = { width, height, fov }
-              const videosResOriArrayIndex = this._videoRawYUVTexArray.findId(width, height)
-              const currentVideoId = this._videoRawYUVTexArray.getCurrentVideoTexId();
+        if (this._isUpdateYUV == !0) {
+            console.log('执行:updateRawYUVData')
+            const yuvInfo = { width, height, fov }
+            const videosResOriArrayIndex = this._videoRawYUVTexArray.findId(width, height)
+            const currentVideoId = this._videoRawYUVTexArray.getCurrentVideoTexId();
 
-              if(currentVideoId < 0 || videosResOriArrayIndex != currentVideoId || fov != this.yuvInfo.fov)
-              {
-                  this.yuvInfo.width = width;
-                  this.yuvInfo.height = height;
-                  this.yuvInfo.fov = fov;
+            if(currentVideoId < 0 || videosResOriArrayIndex != currentVideoId || fov != this.yuvInfo.fov)
+            {
+                this.yuvInfo.width = width;
+                this.yuvInfo.height = height;
+                this.yuvInfo.fov = fov;
 
-                  this._videoRawYUVTexArray.setCurrentVideoTexId(videosResOriArrayIndex);
-                  this._changeVideoRes(videosResOriArrayIndex);   // 设置texture_video
-                  this._changePureVideoLowModelShaderCanvasSize(yuvInfo); // 设置focal_width_height
-                  this._scenemanager.cameraComponent.cameraFovChange(yuvInfo);
-                  this._scenemanager.yuvInfo = yuvInfo;
-              }
+                this._videoRawYUVTexArray.setCurrentVideoTexId(videosResOriArrayIndex);
+                this._changeVideoRes(videosResOriArrayIndex);   // 设置texture_video
+                this._changePureVideoLowModelShaderCanvasSize(yuvInfo); // 设置focal_width_height
+                this._scenemanager.cameraComponent.cameraFovChange(yuvInfo);
+                this._scenemanager.yuvInfo = yuvInfo;
+            }
 
-              let VideoTexture = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)
-              if(VideoTexture != null){
-                  // 更新视频流
-                  VideoTexture.update(stream)
-                  VideoTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
-              }
+            let VideoTexture = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)
+            if(VideoTexture != null){
+                // 更新视频流
+                VideoTexture.update(stream)
+                VideoTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
+            }
 
-              //var o, a
-              //(o = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || o.update(stream),
-              //(a = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || a.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
-          }
-      });
+            //var o, a
+            //(o = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || o.update(stream),
+            //(a = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || a.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
+        }
+    });
 
     E(this, "_changeVideoRes", (e) => {
       this._lowModelShader.setTexture(

+ 1 - 4
src/XSceneManager.js

@@ -120,10 +120,7 @@ export default class XSceneManager {
         this.engine.doNotHandleContextLost = !0,
         this.scene.clearCachedVertexData(),
         this.scene.cleanCachedTextureBuffer(),
-        // 周恩光加 调试用工具栏
-        // this.scene.debugLayer.show({
-        //     embedMode: true,
-        // })
+        // this.scene.debugLayer.show({ embedMode: true, }),    // BABYLON调试工具栏
         this.urlTransformer = t.urlTransformer || (s=>Promise.resolve(s)),
         t.logger && defaultLog.setLogger(t.logger),
         this.gl = e.getContext("webgl2", {

+ 8 - 7
src/XverseAvatar.js

@@ -475,12 +475,13 @@ export default class XverseAvatar extends EventEmitter {
     avatarStartMovingHook() {}
     avatarStopMovingHook() {}
 
-    async statusSync(e) {
+    // 用于更新非MainAvatar的其他角色
+    async statusSync(userState) {
         try {
             // 旋转
-            if (e.event != null && e.event.rotateEvent) 
+            if (userState.event && userState.event.rotateEvent) 
             {
-                const {angle, speed} = e.event.rotateEvent
+                const { angle, speed } = userState.event.rotateEvent
                   , moveAnimation = this.motionType === MotionType.Run ? "Running" : "Walking";
 
                 this.rotation && (
@@ -496,10 +497,10 @@ export default class XverseAvatar extends EventEmitter {
             }
 
             // 行走
-            if (e.event && ((e.event == null ? void 0 : e.event.points.length) || 0) > 1 && !this.isSelf)
+            if (userState.event && ((userState.event.points && userState.event.points.length) || 0) > 1 && !this.isSelf)
             {
                 this.isMoving = true,
-                e.playerState.attitude && (this._motionType = e.playerState.attitude);
+                userState.playerState.attitude && (this._motionType = userState.playerState.attitude);
 
                 const moveAnimation = this.motionType === MotionType.Run ? "Running" : "Walking"
                   , skinRoute = this._room.skin.routeList.find(l => l.areaName === this._room.currentState.areaName)
@@ -508,10 +509,10 @@ export default class XverseAvatar extends EventEmitter {
                 this.position && (
                     await this._move({
                         start: this.position,
-                        end: e.event.points[e.event.points.length - 1],
+                        end: userState.event.points[userState.event.points.length - 1],
                         walkSpeed,
                         moveAnimation: moveAnimation,
-                        inter: e.event == null ? void 0 : e.event.points.slice(0, -1)
+                        inter: userState.event && userState.event.points.slice(0, -1)
                     }).then(()=>{
                         this.isMoving = false
                     })