|
|
@ -62,7 +62,12 @@ export default class PtrObject extends THREE.Object3D { |
|
|
private runningStepTask: StepTask = null |
|
|
private runningStepTask: StepTask = null |
|
|
public runningStepTaskList: StepTask[] = [] |
|
|
public runningStepTaskList: StepTask[] = [] |
|
|
|
|
|
|
|
|
|
|
|
// 移动动画
|
|
|
public travelAnimation: core.Tween = null |
|
|
public travelAnimation: core.Tween = null |
|
|
|
|
|
// 旋转动画
|
|
|
|
|
|
public rotationAnimation: core.Tween = null |
|
|
|
|
|
// 动作动画
|
|
|
|
|
|
public actionAnimation: core.Tween = null |
|
|
|
|
|
|
|
|
// 心跳间隔 UInt32 单位: s
|
|
|
// 心跳间隔 UInt32 单位: s
|
|
|
private heartBeatInterval: number = 0 |
|
|
private heartBeatInterval: number = 0 |
|
|
@ -345,7 +350,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
if (!worldModel.state.runState.isVirtual) { |
|
|
if (!worldModel.state.runState.isVirtual) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
console.log('send message:', JSON.stringify(msg)) |
|
|
// console.log('send message:', JSON.stringify(msg))
|
|
|
if (this.sendMessageQueue.indexOf(msg) < 0) { |
|
|
if (this.sendMessageQueue.indexOf(msg) < 0) { |
|
|
this.sendMessageQueue.push(msg) |
|
|
this.sendMessageQueue.push(msg) |
|
|
} |
|
|
} |
|
|
@ -428,17 +433,17 @@ export default class PtrObject extends THREE.Object3D { |
|
|
while (ra < 0) { |
|
|
while (ra < 0) { |
|
|
ra += Math.PI * 2 |
|
|
ra += Math.PI * 2 |
|
|
} |
|
|
} |
|
|
const ddra = Math.PI / 8 |
|
|
const ddra = Math.PI / 180 |
|
|
if (ra >= ddra * 7 || ra < ddra) { |
|
|
if (ra >= Math.PI * 2 - ddra || ra <= ddra) { |
|
|
this.currentDirection = 0; |
|
|
this.currentDirection = 0; |
|
|
|
|
|
|
|
|
} else if (ra >= ddra && ra < ddra * 3) { |
|
|
} else if (ra >= Math.PI/2 - ddra && ra <= Math.PI/2 + ddra) { |
|
|
this.currentDirection = 3; |
|
|
this.currentDirection = 3; |
|
|
|
|
|
|
|
|
} else if (ra >= ddra * 3 && ra < ddra * 5) { |
|
|
} else if (ra >= Math.PI - ddra && ra <= Math.PI + ddra) { |
|
|
this.currentDirection = 2; |
|
|
this.currentDirection = 2; |
|
|
|
|
|
|
|
|
} else if (ra >= ddra * 5 && ra < ddra * 7) { |
|
|
} else if (ra >= Math.PI/2*3 - ddra && ra <= Math.PI/2*3 + ddra) { |
|
|
this.currentDirection = 1; |
|
|
this.currentDirection = 1; |
|
|
} else { |
|
|
} else { |
|
|
this.currentDirection = 15; |
|
|
this.currentDirection = 15; |
|
|
@ -477,11 +482,13 @@ export default class PtrObject extends THREE.Object3D { |
|
|
} |
|
|
} |
|
|
let endDirection = currentStepTask.EndDirection |
|
|
let endDirection = currentStepTask.EndDirection |
|
|
|
|
|
|
|
|
if (data.Link.length > 0) { |
|
|
const linkCount = data.Link?.length || 0 |
|
|
|
|
|
if (linkCount > 0) { |
|
|
for (let i = 0; i < data.Link.length; i++) { |
|
|
for (let i = 0; i < data.Link.length; i++) { |
|
|
const link = data.Link[i] |
|
|
const link = data.Link[i] |
|
|
if ((currentStepTask.X == link.X && currentStepTask.Y == link.Y) |
|
|
if ((currentStepTask.X == link.X && currentStepTask.Y == link.Y) |
|
|
|| (currentStepTask.X != link.X && currentStepTask.Y != link.Y)) { |
|
|
|| (currentStepTask.X != link.X && currentStepTask.Y != link.Y)) { |
|
|
|
|
|
debugger |
|
|
continue |
|
|
continue |
|
|
} else if (currentStepTask.X < link.X) { |
|
|
} else if (currentStepTask.X < link.X) { |
|
|
if (link.Speed > 0) { |
|
|
if (link.Speed > 0) { |
|
|
@ -547,6 +554,9 @@ export default class PtrObject extends THREE.Object3D { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 如果没有link 或者当前link的XY是任务结束点位
|
|
|
|
|
|
if (linkCount <= 0 |
|
|
|
|
|
|| (linkCount > 0 && data.Link[linkCount - 1].X == data.EndX && data.Link[linkCount - 1].Y == data.EndY)) { |
|
|
|
|
|
|
|
|
if (data.OperationType == 0 && data.EndDirection >= 0 && data.EndDirection <= 3) { |
|
|
if (data.OperationType == 0 && data.EndDirection >= 0 && data.EndDirection <= 3) { |
|
|
endDirection = data.EndDirection; |
|
|
endDirection = data.EndDirection; |
|
|
@ -615,6 +625,10 @@ export default class PtrObject extends THREE.Object3D { |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(JSON.stringify(this.currentStepTaskList)) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -624,6 +638,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
const stepTask = this.currentStepTaskList[0] |
|
|
const stepTask = this.currentStepTaskList[0] |
|
|
if (this.runningStepTask) { |
|
|
if (this.runningStepTask) { |
|
|
if ((stepTask.StepTaskType == "MOVE" || stepTask.StepTaskType == "MOVE_BACKWARD") |
|
|
if ((stepTask.StepTaskType == "MOVE" || stepTask.StepTaskType == "MOVE_BACKWARD") |
|
|
|
|
|
&& this.rotationAnimation == null && this.actionAnimation == null |
|
|
&& stepTask.EndDirection == this.runningStepTask.EndDirection |
|
|
&& stepTask.EndDirection == this.runningStepTask.EndDirection |
|
|
&& (stepTask.Speed > 0) == (this.runningStepTask.Speed > 0)) { |
|
|
&& (stepTask.Speed > 0) == (this.runningStepTask.Speed > 0)) { |
|
|
this.runningStepTask = stepTask |
|
|
this.runningStepTask = stepTask |
|
|
@ -693,12 +708,13 @@ export default class PtrObject extends THREE.Object3D { |
|
|
const duration = time |
|
|
const duration = time |
|
|
|
|
|
|
|
|
return new Promise(resolve => { |
|
|
return new Promise(resolve => { |
|
|
gsap.to(this.rotation, { |
|
|
this.rotationAnimation = gsap.to(this.rotation, { |
|
|
y: tr, |
|
|
y: tr, |
|
|
duration, |
|
|
duration, |
|
|
ease: 'none', |
|
|
ease: 'none', |
|
|
onComplete: ()=>{ |
|
|
onComplete: ()=>{ |
|
|
resolve() |
|
|
resolve() |
|
|
|
|
|
this.rotationAnimation = null |
|
|
this.onActionCompleted() |
|
|
this.onActionCompleted() |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
@ -718,11 +734,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
|
|
|
|
|
|
if (!this.travelAnimation) { |
|
|
if (!this.travelAnimation) { |
|
|
return new Promise(resolve => { |
|
|
return new Promise(resolve => { |
|
|
this.travelAnimation = gsap.fromTo(this.position, { |
|
|
this.travelAnimation = gsap.to(this.position, { |
|
|
x: fromPos.x, |
|
|
|
|
|
y: fromPos.y, |
|
|
|
|
|
z: fromPos.z, |
|
|
|
|
|
}, { |
|
|
|
|
|
x: toPos.x, |
|
|
x: toPos.x, |
|
|
y: toPos.y, |
|
|
y: toPos.y, |
|
|
z: toPos.z, |
|
|
z: toPos.z, |
|
|
@ -776,6 +788,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
()=>this.animationUpFork(height + 0.2).then( |
|
|
()=>this.animationUpFork(height + 0.2).then( |
|
|
()=>this.animationHideFork().then( |
|
|
()=>this.animationHideFork().then( |
|
|
()=>this.animationDownFork().then(()=>{ |
|
|
()=>this.animationDownFork().then(()=>{ |
|
|
|
|
|
this.actionAnimation = null |
|
|
this.onActionCompleted() |
|
|
this.onActionCompleted() |
|
|
}) |
|
|
}) |
|
|
) |
|
|
) |
|
|
@ -792,6 +805,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
()=>this.animationUpFork(height).then( |
|
|
()=>this.animationUpFork(height).then( |
|
|
()=>this.animationHideFork().then( |
|
|
()=>this.animationHideFork().then( |
|
|
()=>this.animationDownFork().then(()=>{ |
|
|
()=>this.animationDownFork().then(()=>{ |
|
|
|
|
|
this.actionAnimation = null |
|
|
this.onActionCompleted() |
|
|
this.onActionCompleted() |
|
|
}) |
|
|
}) |
|
|
) |
|
|
) |
|
|
@ -815,13 +829,13 @@ export default class PtrObject extends THREE.Object3D { |
|
|
|
|
|
|
|
|
//获取ptr的角度朝向
|
|
|
//获取ptr的角度朝向
|
|
|
getAmrOrientation(radY: number) { |
|
|
getAmrOrientation(radY: number) { |
|
|
radY = radY + Math.PI |
|
|
|
|
|
while (radY < 0) { |
|
|
while (radY < 0) { |
|
|
radY += Math.PI * 2 |
|
|
radY += Math.PI * 2 |
|
|
} |
|
|
} |
|
|
while (radY > Math.PI * 2) { |
|
|
while (radY > Math.PI * 2) { |
|
|
radY -= Math.PI * 2 |
|
|
radY -= Math.PI * 2 |
|
|
} |
|
|
} |
|
|
|
|
|
radY = (Math.PI * 2 - radY)%(Math.PI * 2) |
|
|
return THREE.MathUtils.radToDeg(radY) |
|
|
return THREE.MathUtils.radToDeg(radY) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|