|
@@ -57,18 +57,12 @@ export default class App {
|
|
|
|
|
|
window.connection.socket.emit("getRotateVideoUrl", {
|
|
|
videoPath: "0/0",
|
|
|
- sangle: 0,
|
|
|
- eangle: 360,
|
|
|
- reverses: false,
|
|
|
sceneCode: settings.sceneCode,
|
|
|
roomId: settings.roomId,
|
|
|
userId: settings.userId,
|
|
|
});
|
|
|
window.connection.socket.emit("getRotateVideoUrl", {
|
|
|
- videoPath: "0/0" ,
|
|
|
- sangle: 0,
|
|
|
- eangle: 360,
|
|
|
- reverses: true,
|
|
|
+ videoPath: "0/0_rotate" ,
|
|
|
sceneCode: settings.sceneCode,
|
|
|
roomId: settings.roomId,
|
|
|
userId: settings.userId,
|
|
@@ -171,140 +165,45 @@ export default class App {
|
|
|
bindSocketEvents() {
|
|
|
|
|
|
let walkPointsTemp = []
|
|
|
+
|
|
|
+ // 获得旋转视频
|
|
|
window.connection.socket.on('getRotateVideoUrl', async(data) => {
|
|
|
- console.log("[3D] getSocketVideo: ", data)
|
|
|
+ console.log("[3D] getRotateVideoUrl: ", data)
|
|
|
const url = data
|
|
|
- // 获得旋转视频
|
|
|
|
|
|
- let video = this.isReverse ? document.getElementById("houseTextureReverse")
|
|
|
- : document.getElementById("houseTexture")
|
|
|
+ let video = data.indexOf("_rotate") > -1
|
|
|
+ ? document.getElementById("houseTextureReverse")
|
|
|
+ : document.getElementById("houseTexture")
|
|
|
|
|
|
video.src = url
|
|
|
|
|
|
- this.isReverse = !this.isReverse
|
|
|
-
|
|
|
// 页面刷新后初次加载视频
|
|
|
if(this.initVideo) {
|
|
|
- this.updateHouseVideo(video, true)
|
|
|
- this.initVideo = false
|
|
|
- this.cameraController.camera.minZ = 0.001
|
|
|
+ // this.updateHouseVideo(video, true)
|
|
|
+ this.initVideo = false
|
|
|
+ this.cameraController.camera.minZ = 0.001
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+ // 获得行走视频
|
|
|
window.connection.socket.on('getVideoUrl', async(data) => {
|
|
|
- console.log("[3D] getSocketVideo: ", data)
|
|
|
- const url = data
|
|
|
-
|
|
|
- if(this.getSocketVideoType == "walkPath") {
|
|
|
-
|
|
|
- let dir = this.charactorManager.getVideoDirecNum()
|
|
|
- // 获得行走视频
|
|
|
- let path = walkPointsTemp.map( (point, i) => {
|
|
|
- return {
|
|
|
- id: point.id,
|
|
|
- point: new BABYLON.Vector3(-point.location.x, 0, point.location.z),
|
|
|
- video: i == 0 ? common.createVideoElement0(url) : null,
|
|
|
- videoName: i != walkPointsTemp.length - 1 ? (point.id + "/" + point.id + "_" + walkPointsTemp[i+1].id + "_" + dir) : null
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- this.getSocketVideoType = "nextWalk"
|
|
|
-
|
|
|
- // 行走时锁定camera
|
|
|
- this.cameraController.lockCamera(true)
|
|
|
- this.charactorManager.charactor.startWalk(path, this.charactorManager)
|
|
|
-
|
|
|
- }
|
|
|
- else if(this.getSocketVideoType == "nextWalk") {
|
|
|
-
|
|
|
- let charactor = this.charactorManager.charactor
|
|
|
- let video = common.createVideoElement0(url) //await common.createVideoElement(url)
|
|
|
-
|
|
|
- console.error(charactor.walkData.currentPoint+1)
|
|
|
- charactor.walkData.pathArr[charactor.walkData.currentPoint+1].video = video
|
|
|
-
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- 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)
|
|
|
- setTimeout(function () {
|
|
|
- URL.revokeObjectURL(url)
|
|
|
- }, 3000)
|
|
|
-
|
|
|
- if(this.getSocketVideoType == "walkPath") {
|
|
|
-
|
|
|
- let dir = this.charactorManager.getVideoDirecNum()
|
|
|
- // 获得行走视频
|
|
|
- let path = walkPointsTemp.map( (point, i) => {
|
|
|
- return {
|
|
|
- id: point.id,
|
|
|
- point: new BABYLON.Vector3(-point.location.x, 0, point.location.z),
|
|
|
- video: i == 0 ? common.createVideoElement0(url) : null,
|
|
|
- videoName: i != walkPointsTemp.length - 1 ? (point.id + "/" + point.id + "_" + walkPointsTemp[i+1].id + "_" + dir) : null
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- this.getSocketVideoType = "nextWalk"
|
|
|
-
|
|
|
- // 行走时锁定camera
|
|
|
- this.cameraController.lockCamera(true)
|
|
|
- this.charactorManager.charactor.startWalk(path, this.charactorManager)
|
|
|
-
|
|
|
- }
|
|
|
- else if(this.getSocketVideoType == "nextWalk") {
|
|
|
-
|
|
|
- let charactor = this.charactorManager.charactor
|
|
|
- let video = common.createVideoElement0(url) //await common.createVideoElement(url)
|
|
|
-
|
|
|
- charactor.walkData.pathArr[charactor.walkData.currentPoint+1].video = video
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- // 获得旋转视频
|
|
|
- let video = this.isReverse ? document.getElementById("houseTextureReverse")
|
|
|
- : document.getElementById("houseTexture")
|
|
|
-
|
|
|
- video.src = url
|
|
|
-
|
|
|
- this.isReverse = !this.isReverse
|
|
|
-
|
|
|
- // 页面刷新后初次加载视频
|
|
|
- if(this.initVideo) {
|
|
|
- // this.updateHouseVideo(video, true)
|
|
|
- this.initVideo = false
|
|
|
- this.cameraController.camera.minZ = 0.001
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- window.connection.socket.on('getVideoUrl', async (data) => {
|
|
|
-
|
|
|
console.log("[3D] getVideoUrl: ", data)
|
|
|
-
|
|
|
- // 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 {
|
|
|
- // point: new BABYLON.Vector3(point.location.x, 0, point.location.z),
|
|
|
- // video: url // await common.createVideoElement0(url)
|
|
|
- // }
|
|
|
- // })
|
|
|
-
|
|
|
- // // 行走时锁定camera
|
|
|
- // this.cameraController.lockCamera(true)
|
|
|
- // this.charactorManager.charactor.startWalk(path, this.charactorManager)
|
|
|
+ const urlArr = data
|
|
|
+
|
|
|
+ let path = walkPointsTemp.map((point, i) => {
|
|
|
+ return {
|
|
|
+ id: point.id,
|
|
|
+ point: new BABYLON.Vector3(-point.location.x, 0, point.location.z),
|
|
|
+ video: urlArr[i] ? common.createVideoElement0(urlArr[i]) : null,
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 行走时锁定camera
|
|
|
+ console.log("Walk Start: ", path)
|
|
|
+ this.cameraController.lockCamera(true)
|
|
|
+ this.charactorManager.charactor.startWalk(path, this.charactorManager)
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
// 获得行走路径
|
|
|
window.connection.socket.on("getRoute", (data) => {
|
|
|
|
|
@@ -315,11 +214,14 @@ export default class App {
|
|
|
walkPointsTemp = data
|
|
|
|
|
|
let dir = this.charactorManager.getVideoDirecNum()
|
|
|
- let firstVideoName = data[0].id + "/" + data[0].id + "_" + data[1].id + "_" + dir
|
|
|
+ let videoNames = []
|
|
|
+ for(let i = 0; i < data.length-1; i++) {
|
|
|
+ videoNames.push(data[i].id + "/" + data[i].id + "_" + data[i+1].id + "_" + dir)
|
|
|
+ }
|
|
|
|
|
|
this.getSocketVideoType = "walkPath"
|
|
|
let sendData = {
|
|
|
- videoList: [firstVideoName],
|
|
|
+ videoList: videoNames,
|
|
|
sceneCode: settings.sceneCode,
|
|
|
roomId: settings.roomId,
|
|
|
userId: settings.userId,
|
|
@@ -331,8 +233,8 @@ export default class App {
|
|
|
|
|
|
updateHouseVideo(video, notPlay) {
|
|
|
let videoTexture = new BABYLON.VideoTexture("", video, this.scene)
|
|
|
- this.house.forEach(mesh => {
|
|
|
- // mesh.material && mesh.material.setTexture("texture_video", videoTexture)
|
|
|
+ this.hasVideoTexture && this.house.forEach(mesh => {
|
|
|
+ mesh.material && mesh.material.setTexture("texture_video", videoTexture)
|
|
|
})
|
|
|
!notPlay && video.play()
|
|
|
}
|