|
@@ -85,8 +85,8 @@ export default class Charactor {
|
|
|
}
|
|
|
|
|
|
if(pathArr.length >= 2 && this.actionType.split("-")[1] != "Walking")
|
|
|
- {
|
|
|
- let video = pathArr[1].video
|
|
|
+ {
|
|
|
+ let video = pathArr[0].video
|
|
|
if(video.isLoaded) {
|
|
|
this.AniTransfromTo("Walking")
|
|
|
this.walkByPath(charactorManager)
|
|
@@ -103,24 +103,69 @@ export default class Charactor {
|
|
|
|
|
|
let charactor = this
|
|
|
|
|
|
- charactor.walkData.currentPoint++
|
|
|
+ let { pathArr, currentPoint } = charactor.walkData
|
|
|
|
|
|
// 更新房间的视频贴图
|
|
|
- // let video = charactor.walkData.pathArr[charactor.walkData.currentPoint].video
|
|
|
- // charactorManager.app.updateHouseVideo(video)
|
|
|
- let video = charactor.walkData.pathArr[1].video
|
|
|
- charactor.walkData.currentPoint == 1 && video && charactorManager.app.updateHouseVideo(video)
|
|
|
+ let video = pathArr[currentPoint].video
|
|
|
+ console.error(currentPoint, video)
|
|
|
+ if(!video) {
|
|
|
+ setTimeout(() => {
|
|
|
+ charactor.walkByPath(charactorManager)
|
|
|
+ }, 50)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ charactorManager.app.updateHouseVideo(video)
|
|
|
+ // let video = charactor.walkData.pathArr[1].video
|
|
|
+ // charactor.walkData.currentPoint == 1 && video && charactorManager.app.updateHouseVideo(video)
|
|
|
|
|
|
+ let nextPos = pathArr[currentPoint+1].point
|
|
|
+ let nextVideoName = pathArr[currentPoint+1].videoName
|
|
|
|
|
|
+ if(nextVideoName)
|
|
|
+ {
|
|
|
+ let sendData = {
|
|
|
+ videoList: [nextVideoName],
|
|
|
+ sceneCode: settings.sceneCode,
|
|
|
+ roomId: settings.roomId,
|
|
|
+ userId: settings.userId,
|
|
|
+ }
|
|
|
+ console.log("[3D] send(getVideo): ", sendData);
|
|
|
+ connection.socket.emit("getVideo", sendData);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.getSocketVideoType = "rotateCamera"
|
|
|
+
|
|
|
+ // 即将走到终点之前,获取终点旋转视频
|
|
|
+ let endPointId = pathArr[currentPoint+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,
|
|
|
+ });
|
|
|
|
|
|
- let newPos = charactor.walkData.pathArr[charactor.walkData.currentPoint].point
|
|
|
+ }
|
|
|
|
|
|
// 要跳转的位置与当前位置相同的话,就直接跳过,否则动画会出bug
|
|
|
- if(newPos.x == this.mesh.position.x && newPos.z == this.mesh.position.z)
|
|
|
+ if(nextPos.x == this.mesh.position.x && nextPos.z == this.mesh.position.z)
|
|
|
{
|
|
|
console.warn("跳转点位与当前点位相同, 已跳过!")
|
|
|
|
|
|
- if(charactor.walkData.pathArr[charactor.walkData.currentPoint+1]) {
|
|
|
+ if(pathArr[currentPoint+1]) {
|
|
|
charactor.walkByPath(charactorManager)
|
|
|
} else {
|
|
|
charactor.AniTransfromTo("Idle")
|
|
@@ -132,20 +177,20 @@ export default class Charactor {
|
|
|
|
|
|
|
|
|
let startingPoint = charactor.mesh.position.clone();
|
|
|
- startingPoint.y = newPos.y;
|
|
|
- let walkDirc = newPos.subtract(startingPoint).normalize();
|
|
|
+ startingPoint.y = nextPos.y;
|
|
|
+ let walkDirc = nextPos.subtract(startingPoint).normalize();
|
|
|
|
|
|
// 行走动画
|
|
|
const walkAni = new BABYLON.Animation("walk", "position", settings.video.frameRate,
|
|
|
BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_RELATIVE);
|
|
|
|
|
|
- let walkFrameNum = settings.video.frameRate * video.duration / (charactorManager.app.currentPoints.length-1)
|
|
|
+ let walkFrameNum = settings.video.frameRate * video.duration
|
|
|
const walkKeyFrames = [{
|
|
|
frame: 0,
|
|
|
value: charactor.mesh.position
|
|
|
},{
|
|
|
frame: walkFrameNum,
|
|
|
- value: newPos
|
|
|
+ value: nextPos
|
|
|
}];
|
|
|
|
|
|
walkAni.setKeys(walkKeyFrames);
|
|
@@ -167,10 +212,11 @@ export default class Charactor {
|
|
|
|
|
|
turnAroundAni.setKeys(turnAroundFrames);
|
|
|
|
|
|
+
|
|
|
charactorManager.app.scene.beginDirectAnimation(charactor.mesh, [walkAni, turnAroundAni], 0, Math.max(walkFrameNum, turnAroundFrameNum), false, 1,
|
|
|
() => {
|
|
|
// 如果还有下一个点位就继续走,否则变为站立
|
|
|
- if(charactor.walkData.pathArr[charactor.walkData.currentPoint+1]) {
|
|
|
+ if(pathArr[++charactor.walkData.currentPoint].videoName) {
|
|
|
charactor.walkByPath(charactorManager)
|
|
|
} else {
|
|
|
charactor.AniTransfromTo("Idle")
|