zhouenguang 3 年之前
父節點
當前提交
80b6118a30
共有 4 個文件被更改,包括 61 次插入79 次删除
  1. 1 1
      modules/CameraController.js
  2. 1 26
      modules/Charactor.js
  3. 3 32
      modules/CharactorManager.js
  4. 56 20
      modules/index.js

+ 1 - 1
modules/CameraController.js

@@ -11,7 +11,7 @@ export default class CameraController {
         app.scene.activeCamera = camera1;
         // scene.activeCamera.attachControl(scene.canvas, true);
         camera1.inertia = 0
-        camera1.minZ = 0.001
+        camera1.minZ = 100
         camera1.fov = settings.camera.fov
         camera1.fovMode = BABYLON.ArcRotateCamera.FOVMODE_HORIZONTAL_FIXED
         camera1.lowerBetaLimit = Math.PI / 2

+ 1 - 26
modules/Charactor.js

@@ -108,9 +108,6 @@ export default class Charactor {
         // 更新房间的视频贴图
         let video = charactor.walkData.pathArr[charactor.walkData.currentPoint].video
         charactorManager.app.updateHouseVideo(video)
-        // charactorManager.app.updateHouseVideoBlob(videoUrl, false)
-
-        // console.error(video.duration)
 
         let newPos = charactor.walkData.pathArr[charactor.walkData.currentPoint].point
 
@@ -123,7 +120,7 @@ export default class Charactor {
                 charactor.walkByPath(charactorManager)
             } else {
                 charactor.AniTransfromTo("Idle")
-                charactorManager.app.lockCamera(false)
+                charactorManager.app.cameraController.lockCamera(false)
             }
             
             return
@@ -174,28 +171,6 @@ export default class Charactor {
                     charactor.walkByPath(charactorManager)
                 } else {
                     charactor.AniTransfromTo("Idle")
-                    
-                    let endPointId = charactorManager.app.currentPoints[charactorManager.app.currentPoints.length - 1].id
-
-                    window.connection.socket.emit("getRotateVideo", {
-                        videoPath: endPointId + "/" + endPointId,
-                        sangle: 0,
-                        eangle: 360,
-                        reverses: false,
-                        sceneCode: settings.sceneCode,
-                        roomId: settings.roomId,
-                        userId: settings.userId,
-                    });
-                    window.connection.socket.emit("getRotateVideo", {
-                        videoPath: endPointId + "/" + endPointId,
-                        sangle: 0,
-                        eangle: 360,
-                        reverses: true,
-                        sceneCode: settings.sceneCode,
-                        roomId: settings.roomId,
-                        userId: settings.userId,
-                    });
-
                     charactorManager.app.cameraController.lockCamera(false)
                 }
             });

+ 3 - 32
modules/CharactorManager.js

@@ -25,8 +25,7 @@ export default class CharactorManager {
         .then(response => {
             this.pointsData = response
             this.pointsData.forEach(data => {
-                // data.position = common.vec3UE4ToBABYLON(data.position)
-                data.position = new BABYLON.Vector3(data.position.x, data.position.y, data.position.z)
+                data.position = new BABYLON.Vector3(-data.position.x, data.position.y, data.position.z)
             })
         })
     }
@@ -100,9 +99,6 @@ export default class CharactorManager {
         //     dir: this.getVideoDirecNum()
         // }
 
-        // let startPointUE4 = common.vec3BABYLONToUE4(startPoint)
-        // let endPointUE4 = common.vec3BABYLONToUE4(endPoint)
-
         let sendData = {
             sceneCode: settings.sceneCode,
             roomId: settings.roomId,
@@ -116,35 +112,10 @@ export default class CharactorManager {
                 x: endPoint.x,
                 y: endPoint.y,
                 z: endPoint.z,
-            },
-            // s_location: {
-            //     x: startPointUE4.x,
-            //     y: startPointUE4.y,
-            //     z: startPointUE4.z,
-            // },
-            // e_location: {
-            //     x: endPointUE4.x,
-            //     y: endPointUE4.y,
-            //     z: endPointUE4.z,
-            // },
+            }
         }
         window.connection.socket.emit("getRoute", sendData);
-        console.log("[3D] send: ", sendData)
-
-        // // todo
-        // let path = data.walkPath    // response
-        // path.forEach(data => data.point = this.pointsData[data.id].position)
-
-        // path = path.map((data) => { 
-        //     return { 
-        //         point: new BABYLON.Vector3(data.point.x, 0, data.point.z), 
-        //         video: data.video && common.createVideoElement0(data.video)
-        //     } 
-        // })
-
-        // // 行走时锁定camera
-        // this.app.cameraController.lockCamera(true)
-        // this.charactor.startWalk(path, this)
+        console.log("[3D] send(getRoute): ", sendData)
 
     }
 

+ 56 - 20
modules/index.js

@@ -167,23 +167,25 @@ export default class App {
 
     bindSocketEvents() {
 
-        // 获得旋转视频
         window.connection.socket.on('getSocketVideo', async(data) => {
 
             console.log("[3D] getSocketVideo: ", data)
 
-            const blob = new Blob([data], { type: 'application/video' })
-            const url = URL.createObjectURL(blob)
-            // this.updateHouseVideoBlob(url, true)
-            // let video = common.createVideoElement0(url)
-            // video.loop = "loop"
-            setTimeout(function () {
-                return URL.revokeObjectURL(url)
-            }, 3000)
-
             if(this.getWalkVideo) {
-
+                // 获得行走视频
+                let dataArr = [data]
                 let path = this.currentPoints.map( (point, index) => { 
+                    
+                    const blob = new Blob( dataArr.slice(
+                        index / this.currentPoints.length * dataArr.length,
+                        (index + 1) / this.currentPoints.length * dataArr.length
+                    ), { type: 'application/video' })
+
+                    const url = URL.createObjectURL(blob)
+                    setTimeout(function () {
+                        URL.revokeObjectURL(url)
+                    }, 3000)
+
                     return { 
                         point: new BABYLON.Vector3(point.location.x, 0, point.location.z), 
                         video: common.createVideoElement0(url)
@@ -196,7 +198,40 @@ export default class App {
 
                 this.getWalkVideo = false
 
+                // 获得行走视频后,获取终点旋转视频
+                let endPointId = this.currentPoints[this.currentPoints.length - 1].id
+
+                console.log("[3D] send(getRotateVideo): ", endPointId + "/" + endPointId)
+                window.connection.socket.emit("getRotateVideo", {
+                    videoPath: endPointId + "/" + endPointId,
+                    sangle: 0,
+                    eangle: 360,
+                    reverses: false,
+                    sceneCode: settings.sceneCode,
+                    roomId: settings.roomId,
+                    userId: settings.userId,
+                });
+                window.connection.socket.emit("getRotateVideo", {
+                    videoPath: endPointId + "/" + endPointId,
+                    sangle: 0,
+                    eangle: 360,
+                    reverses: true,
+                    sceneCode: settings.sceneCode,
+                    roomId: settings.roomId,
+                    userId: settings.userId,
+                });
+
             } else {
+                // 获得旋转视频
+                const blob = new Blob([data], { type: 'application/video' })
+                const url = URL.createObjectURL(blob)
+                // this.updateHouseVideoBlob(url, true)
+                // let video = common.createVideoElement0(url)
+                // video.loop = "loop"
+                setTimeout(function () {
+                    return URL.revokeObjectURL(url)
+                }, 3000)
+
                 // this.cameraController.rotateCamera(this.cameraController.alphaOffset)
 
                 if(this.isReverse) {
@@ -210,20 +245,20 @@ export default class App {
                 if(this.initVideo) {
                     this.updateHouseVideoBlob(url, true)
                     this.initVideo = false
+                    this.cameraController.camera.minZ = 0.001
                 }
             }
         })
 
-        // 获得行走视频
         window.connection.socket.on('getVideo', async (data) => {
             
             console.log("[3D] getVideo: ", data)
 
-            const blob = new Blob([data], { type: 'application/video' })
-            const url = URL.createObjectURL(blob)
-            setTimeout(function () {
-                URL.revokeObjectURL(url)
-            }, 3000)
+            // const blob = new Blob([data], { type: 'application/video' })
+            // const url = URL.createObjectURL(blob)
+            // setTimeout(function () {
+            //     URL.revokeObjectURL(url)
+            // }, 3000)
 
             // let path = this.currentPoints.map( (point, index) => { 
             //     return { 
@@ -255,12 +290,14 @@ export default class App {
             }
 
             this.getWalkVideo = true
-            connection.socket.emit("getVideo", {
+            let sendData = {
                 videoList: videos,
                 sceneCode: settings.sceneCode,
                 roomId: settings.roomId,
                 userId: settings.userId,
-            });
+            }
+            console.log("[3D] send(getVideo): ", sendData);
+            connection.socket.emit("getVideo", sendData);
         });
     }
 
@@ -280,7 +317,6 @@ export default class App {
             mesh.material && mesh.material.setTexture("texture_video", videoTexture)
         })
         !notPlay && video.play()
-        return video
     }
 
 }