zhouenguang 3 anni fa
parent
commit
6befc18485
3 ha cambiato i file con 25 aggiunte e 28 eliminazioni
  1. 4 8
      modules/CameraController.js
  2. 1 0
      modules/CharactorManager.js
  3. 20 20
      modules/index.js

+ 4 - 8
modules/CameraController.js

@@ -55,8 +55,8 @@ export default class CameraController {
         this.camera.upperRadiusLimit = Math.max( info.distance - offset, 0.1 )
         
         // 根据相机位置更新人物显隐
-        if(info.distance - offset < 0.25 && charactorVisi) charactor.visible = false
-        if(info.distance - offset >= 0.25 && !charactorVisi) charactor.visible = true
+        // if(info.distance - offset < 0.25 && charactorVisi) charactor.visible = false
+        // if(info.distance - offset >= 0.25 && !charactorVisi) charactor.visible = true
 
     }
 
@@ -145,22 +145,18 @@ export default class CameraController {
 
     async rotateCamera(alphaOffset, dirc, func) {
 
-        console.log("alphaOffset", alphaOffset)
-
-        let video0 // = this.app.house[1].material._textures.texture_video.video
+        let video0
 
         if(this.lastDirc * dirc <= 0) {
             if(dirc < 0) {   // 顺时针
                 video0 = document.getElementById("houseTexture")
-                // this.app.updateHouseVideo(video0)
             }
             if(dirc > 0) {   // 逆时针
                 video0 = document.getElementById("houseTextureReverse")
-                // this.app.updateHouseVideo(video0)
             }
             this.lastDirc = dirc
         } else {
-            // 当行走结束后,video0是walk视频,所以必须重赋值
+            // 当行走结束后,texture是walk视频,所以必须重赋值
             if(this.lastDirc < 0) {   // 顺时针
                 video0 = document.getElementById("houseTexture")
             }

+ 1 - 0
modules/CharactorManager.js

@@ -61,6 +61,7 @@ export default class CharactorManager {
             self.charactor = new Charactor(newMeshes, particleSystems, skeletons, animationGroups)
 
             self.charactor.mesh.scaling.scaleInPlace(1.4);
+            self.charactor.visible = false
             
             // 初始人物位置
             self.charactor.mesh.position = new BABYLON.Vector3(

+ 20 - 20
modules/index.js

@@ -31,7 +31,6 @@ export default class App {
         skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
         skybox.material = skyboxMaterial;
 
-        this.hasVideoTexture = false
         this.hasVideoTexture = true
 
         this.init()
@@ -49,27 +48,9 @@ export default class App {
             
             self.house = newMeshes
             // self.house[0].position = new BABYLON.Vector3(0, 0, -0.5)
-            // self.house[0].position = new BABYLON.Vector3(-22, 0, 12)
 
             let houseVideo = document.getElementById("houseTexture")
 
-            setTimeout(() => {
-                        
-                window.connection.socket.emit("getRotateVideoUrl", {
-                    videoPath: "0/0",
-                    sceneCode: settings.sceneCode,
-                    roomId: settings.roomId,
-                    userId: settings.userId,
-                });
-                window.connection.socket.emit("getRotateVideoUrl", {
-                    videoPath: "0/0_rotate" ,
-                    sceneCode: settings.sceneCode,
-                    roomId: settings.roomId,
-                    userId: settings.userId,
-                });
-        
-            }, 1500)
-
             newMeshes.forEach(m => {
                 // m.scaling.scaleInPlace(100);
                 m._geometry && (m.checkCollisions = true)
@@ -106,7 +87,25 @@ export default class App {
 
             self.charactorManager = new CharactorManager(self)
             await self.charactorManager.readPointData()
-            self.charactorManager.importCharactorModel("../scenes/charactors/", "man_YXL.glb")
+            
+            setTimeout(() => {
+                        
+                window.connection.socket.emit("getRotateVideoUrl", {
+                    videoPath: "0/0",
+                    sceneCode: settings.sceneCode,
+                    roomId: settings.roomId,
+                    userId: settings.userId,
+                });
+                window.connection.socket.emit("getRotateVideoUrl", {
+                    videoPath: "0/0_rotate" ,
+                    sceneCode: settings.sceneCode,
+                    roomId: settings.roomId,
+                    userId: settings.userId,
+                });
+
+                self.charactorManager.importCharactorModel("../scenes/charactors/", "man_YXL.glb")
+        
+            }, 1000)
         });
 
         this.cameraController = new CameraController(self)
@@ -182,6 +181,7 @@ export default class App {
                 // this.updateHouseVideo(video, true)
                 this.initVideo = false
                 this.cameraController.camera.minZ = 0.001
+                setTimeout(() => this.charactorManager.charactor.visible = true, 1000)
             }
         })