|
@@ -12,7 +12,7 @@ import { SrsRTC } from "./srsRtc.js";
|
|
|
import { Connection } from "./connection.js";
|
|
|
|
|
|
|
|
|
-const ossVideoDir = "https://laser-data.oss-cn-shenzhen.aliyuncs.com/new-video/new-nc/"
|
|
|
+const ossVideoDir = "https://laser-data.oss-cn-shenzhen.aliyuncs.com/new-video/720p/"
|
|
|
const walkVideoFrame = 29
|
|
|
|
|
|
window.currentFrame = null
|
|
@@ -68,40 +68,51 @@ export default class ActionsHandler {
|
|
|
let {anglePlus, dircNum} = window.room.sceneManager.correctCameraDirec()
|
|
|
|
|
|
pathArr.forEach(point => {
|
|
|
- // todo 矫正
|
|
|
let ue4Pos = util.xversePosition2Ue4({x: -point.location.x, y: point.location.y, z: point.location.z})
|
|
|
point.location = new BABYLON.Vector3(ue4Pos.x, ue4Pos.y, ue4Pos.z)
|
|
|
})
|
|
|
|
|
|
+ const walkSpeed = 1 // m/s
|
|
|
+ const frameRate = 29 // fps
|
|
|
+
|
|
|
let walkPoints = []
|
|
|
+ let walkFrames = []
|
|
|
let videoArr = []
|
|
|
for(let i = 0; i < pathArr.length - 1; i++) {
|
|
|
|
|
|
- videoArr.push( ossVideoDir + pathArr[i].id + "/" + pathArr[i].id + "_" + pathArr[i+1].id + "_" + dircNum)
|
|
|
-
|
|
|
let point0 = new BABYLON.Vector3(pathArr[i].location.x, pathArr[i].location.y, pathArr[i].location.z)
|
|
|
let point1 = new BABYLON.Vector3(pathArr[i+1].location.x, pathArr[i+1].location.y, pathArr[i+1].location.z)
|
|
|
let distanceVec = point1.clone().subtract(point0)
|
|
|
- let distancePerFrame = distanceVec.length() / walkVideoFrame
|
|
|
+ let distance = distanceVec.length() / 100 // m
|
|
|
+ let distancePerFrame = walkSpeed / frameRate // m/帧 // walkVideoFrame
|
|
|
+ let walkFrame = Math.round(distance / distancePerFrame) // 帧
|
|
|
let dir = distanceVec.normalize()
|
|
|
- for(let currentFrame = 1; currentFrame <= walkVideoFrame; currentFrame++) {
|
|
|
- walkPoints.push(point0.add(dir.scale(distancePerFrame * currentFrame)))
|
|
|
+
|
|
|
+ videoArr.push( {
|
|
|
+ path: ossVideoDir + pathArr[i].id + "/" + pathArr[i].id + "_" + pathArr[i+1].id + "_" + dircNum,
|
|
|
+ frame: walkFrame
|
|
|
+ })
|
|
|
+ walkFrames.push(walkFrame)
|
|
|
+ for(let currentFrame = 1; currentFrame <= walkFrame; currentFrame++) {
|
|
|
+ walkPoints.push(point0.add(dir.scale(distancePerFrame * 100 * currentFrame))) // 单位转换成cm
|
|
|
}
|
|
|
}
|
|
|
|
|
|
console.error(walkPoints)
|
|
|
|
|
|
window.walkSettings = {
|
|
|
- "frameNum": walkVideoFrame * (pathArr.length - 1),
|
|
|
+ "frameNum": walkFrames.reduce(function(prev, curr){
|
|
|
+ // 计算总帧数
|
|
|
+ return prev + curr;
|
|
|
+ }),
|
|
|
"walkPoints": walkPoints,
|
|
|
}
|
|
|
|
|
|
window.walking = true
|
|
|
|
|
|
-
|
|
|
this.mutiFetchData({
|
|
|
type: 'move',
|
|
|
- videoPathArr: videoArr
|
|
|
+ videoDataArr: videoArr
|
|
|
})
|
|
|
});
|
|
|
}
|
|
@@ -648,8 +659,8 @@ export default class ActionsHandler {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- mutiFetchData({type, videoPathArr}){
|
|
|
- console.error(videoPathArr)
|
|
|
+ mutiFetchData({type, videoDataArr}){
|
|
|
+ console.error(videoDataArr)
|
|
|
if(window.workerReady){
|
|
|
// https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/optest/0/0_1_0/
|
|
|
let sendData = []
|
|
@@ -657,15 +668,14 @@ export default class ActionsHandler {
|
|
|
// "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
|
|
|
// "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1",
|
|
|
// ]
|
|
|
- videoPathArr.forEach(path => {
|
|
|
- for(let i = 0; i < walkVideoFrame; i++) {
|
|
|
+ videoDataArr.forEach(data => {
|
|
|
+ for(let i = 0; i < data.frame; i++) {
|
|
|
sendData.push({
|
|
|
- path: path,
|
|
|
+ path: data.path,
|
|
|
frame: i,
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
- // sendData.reverse()
|
|
|
this.vDecoder.mutiFetch(sendData);
|
|
|
}
|
|
|
else{
|