zhouenguang 3 years ago
parent
commit
c513b4d312
4 changed files with 31 additions and 12 deletions
  1. 2 2
      index.html
  2. 15 2
      modules/CameraController.js
  3. 3 0
      modules/Charactor.js
  4. 11 8
      modules/index.js

+ 2 - 2
index.html

@@ -24,7 +24,7 @@
 
         #videoTextureBox video {
           display: none;
-          position: fixed; left: 0px; top: 0px; z-index: 1000; width: 300px; height: 300px;
+          position: fixed; left: 0px; top: 0px; z-index: -1000; width: 300px; height: 300px;
         }
 
         @media screen and (orientation: portrait){
@@ -63,7 +63,7 @@
           position: fixed;
           width: 600px;
           height: 600px;
-          z-index: 10000;
+          z-index: -10000;
           top: 0;
           left: 0;
         "

+ 15 - 2
modules/CameraController.js

@@ -99,7 +99,7 @@ export default class CameraController {
             charactor.startWalk([], this.app.charactorManager)
         } 
         // && dirc * this.lastDirc <= 0
-        else if(Math.abs(this.initAlpha) > Math.PI / 30 && dirc != 0 && this.enable) {
+        else if(Math.abs(this.initAlpha) > Math.PI / 30 && dirc != 0) {
 
             // let currentPath = charactor.walkData.pathArr[charactor.walkData.currentPoint]
             // let startPoint = (currentPath && currentPath.point) || charactor.mesh.position
@@ -148,7 +148,7 @@ export default class CameraController {
         console.log("alphaOffset", alphaOffset)
 
         let video0 = this.app.house[1].material._textures.texture_video.video
-        let startTime = (this.camera.alpha + Math.PI * 2) % (Math.PI * 2) / (Math.PI * 2) * video0.duration
+        let startTime = (this.camera.alpha % (Math.PI * 2) + Math.PI * 2) % (Math.PI * 2) / (Math.PI * 2) * video0.duration
 
         if(this.lastDirc * dirc <= 0) {
             if(dirc < 0) {   // 顺时针
@@ -162,7 +162,20 @@ export default class CameraController {
                 // this.app.updateHouseVideo(video0)
             }
             this.lastDirc = dirc
+        } else {
+            // 当行走结束后,video0是walk视频,所以必须重赋值
+            if(this.lastDirc < 0) {   // 顺时针
+                video0 = document.getElementById("houseTexture")
+                this.app.house[1].material._textures.texture_video.video = video0
+            }
+            if(this.lastDirc > 0) {   // 逆时针
+                video0 = document.getElementById("houseTextureReverse")
+                this.app.house[1].material._textures.texture_video.video = video0
+            }
         }
+
+        if(video0.id != "houseTexture" && video0.id != "houseTextureReverse") return
+
         if(dirc < 0) {
             startTime = video0.duration - startTime
         }

+ 3 - 0
modules/Charactor.js

@@ -107,9 +107,12 @@ export default class Charactor {
 
         // 更新房间的视频贴图
         // let video = charactor.walkData.pathArr[charactor.walkData.currentPoint].video
+        // charactorManager.app.updateHouseVideo(video)
         let video = charactor.walkData.pathArr[1].video
         charactor.walkData.currentPoint == 1 && charactorManager.app.updateHouseVideo(video)
 
+
+
         let newPos = charactor.walkData.pathArr[charactor.walkData.currentPoint].point
 
         // 要跳转的位置与当前位置相同的话,就直接跳过,否则动画会出bug

+ 11 - 8
modules/index.js

@@ -172,7 +172,7 @@ export default class App {
             console.log("[3D] getSocketVideo: ", data)
 
             if(this.getWalkVideo) {
-                    
+
                 const blob = new Blob( [data], { type: 'application/video' })
 
                 const url = URL.createObjectURL(blob)
@@ -184,7 +184,7 @@ export default class App {
                 let path = this.currentPoints.map( (point, index) => { 
                     return { 
                         point: new BABYLON.Vector3(-point.location.x, 0, point.location.z), 
-                        video: index == 1 && common.createVideoElement0(url)
+                        video: index == 1 ? common.createVideoElement0(url) : null
                     } 
                 })
     
@@ -230,16 +230,19 @@ export default class App {
 
                 // this.cameraController.rotateCamera(this.cameraController.alphaOffset)
 
+                let video
                 if(this.isReverse) {
-                    document.getElementById("houseTextureReverse").src = url
+                    video = document.getElementById("houseTextureReverse")
                 } else {
-                    document.getElementById("houseTexture").src = url
+                    video = document.getElementById("houseTexture")
                 }
+                video.src = url
 
                 this.isReverse = !this.isReverse
 
                 if(this.initVideo) {
-                    this.updateHouseVideoBlob(url, true)
+                    // this.updateHouseVideoBlob(url, true)
+                    this.updateHouseVideo(video, true)
                     this.initVideo = false
                     this.cameraController.camera.minZ = 0.001
                 }
@@ -280,14 +283,14 @@ export default class App {
  
             let dir = this.charactorManager.getVideoDirecNum()
 
-            let videos = []
+            this.walkVideoNames = []
             for(let i = 0; i < data.length - 1; i++) {
-                videos.push(data[i].id + "/" + data[i].id + "_" + data[i+1].id + "_" + dir)
+                this.walkVideoNames.push(data[i].id + "/" + data[i].id + "_" + data[i+1].id + "_" + dir)
             }
 
             this.getWalkVideo = true
             let sendData = {
-                videoList: videos,
+                videoList: this.walkVideoNames, //[0],
                 sceneCode: settings.sceneCode,
                 roomId: settings.roomId,
                 userId: settings.userId,