|
|
@ -672,11 +672,8 @@ export default class PtrObject extends THREE.Object3D { |
|
|
const item = this.viewport.entityManager.findItemByLogicXY(data.EndX, data.EndY) |
|
|
const item = this.viewport.entityManager.findItemByLogicXY(data.EndX, data.EndY) |
|
|
|
|
|
|
|
|
if (endDirection != currentStepTask.EndDirection) { |
|
|
if (endDirection != currentStepTask.EndDirection) { |
|
|
// 如果此处不能转弯,忽略结束方向 等待后续任务
|
|
|
// 如果此处不能转弯,忽略结束方向 等待后续任务 此处判断是否包含当前车型的转弯
|
|
|
if (!item.dt?.agvRotation || item.dt?.agvRotation?.length <= 0) { |
|
|
if (item.dt?.agvRotation && item.dt?.agvRotation?.length > 0) { |
|
|
debugger |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
const stepTask: StepTask = { |
|
|
const stepTask: StepTask = { |
|
|
SeqNo: data.SeqNo, |
|
|
SeqNo: data.SeqNo, |
|
|
StepTaskType: 'ROTATION', |
|
|
StepTaskType: 'ROTATION', |
|
|
@ -693,6 +690,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
} |
|
|
} |
|
|
this.currentStepTaskList.push(stepTask) |
|
|
this.currentStepTaskList.push(stepTask) |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (data.OperationType == 3) { |
|
|
if (data.OperationType == 3) { |
|
|
|
|
|
|
|
|
@ -843,8 +841,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
|
|
|
|
|
|
keepSpeed: any |
|
|
keepSpeed: any |
|
|
force: any |
|
|
force: any |
|
|
reverseForce: any |
|
|
stopD: number = 0.01 |
|
|
|
|
|
|
|
|
// 走
|
|
|
// 走
|
|
|
addTravel(logicX: number, logicY: number, direction: number, speed: number = 1): Promise<void> { |
|
|
addTravel(logicX: number, logicY: number, direction: number, speed: number = 1): Promise<void> { |
|
|
|
|
|
|
|
|
@ -856,8 +853,9 @@ export default class PtrObject extends THREE.Object3D { |
|
|
this.__toPos = pos as THREE.Vector3 |
|
|
this.__toPos = pos as THREE.Vector3 |
|
|
//加速度
|
|
|
//加速度
|
|
|
const a = 0.4 * (worldModel.state.runState.timeRate ?? 1) |
|
|
const a = 0.4 * (worldModel.state.runState.timeRate ?? 1) |
|
|
const sa = 0.4 * (worldModel.state.runState.timeRate ?? 1) |
|
|
const sa = 0.4 |
|
|
speed = speed * (worldModel.state.runState.timeRate ?? 1) |
|
|
speed = speed * (worldModel.state.runState.timeRate ?? 1) |
|
|
|
|
|
this.stopD = 0.01 * (worldModel.state.runState.timeRate ?? 1) |
|
|
|
|
|
|
|
|
if (this.position.x < this.__toPos.x || this.position.z < this.__toPos.z) { |
|
|
if (this.position.x < this.__toPos.x || this.position.z < this.__toPos.z) { |
|
|
speed = Math.abs(speed) |
|
|
speed = Math.abs(speed) |
|
|
@ -871,14 +869,11 @@ export default class PtrObject extends THREE.Object3D { |
|
|
|
|
|
|
|
|
this.keepSpeed = new this.viewport.ammoModel.btVector3(0, 0, 0) |
|
|
this.keepSpeed = new this.viewport.ammoModel.btVector3(0, 0, 0) |
|
|
this.force = new this.viewport.ammoModel.btVector3(0, 0, 0) |
|
|
this.force = new this.viewport.ammoModel.btVector3(0, 0, 0) |
|
|
this.reverseForce = new this.viewport.ammoModel.btVector3(0, 0, 0) |
|
|
|
|
|
if (direction == 0 || direction == 2) { |
|
|
if (direction == 0 || direction == 2) { |
|
|
this.force.setValue(accelForce, 0, 0) |
|
|
this.force.setValue(accelForce, 0, 0) |
|
|
this.reverseForce.setValue(-accelForce, 0, 0) |
|
|
|
|
|
this.keepSpeed.setValue(speed, 0, 0) |
|
|
this.keepSpeed.setValue(speed, 0, 0) |
|
|
} else if (direction == 1 || direction == 3) { |
|
|
} else if (direction == 1 || direction == 3) { |
|
|
this.force.setValue(0, 0, accelForce) |
|
|
this.force.setValue(0, 0, accelForce) |
|
|
this.reverseForce.setValue(0, 0, -accelForce) |
|
|
|
|
|
this.keepSpeed.setValue(0, 0, speed) |
|
|
this.keepSpeed.setValue(0, 0, speed) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -905,7 +900,11 @@ export default class PtrObject extends THREE.Object3D { |
|
|
const cSpeed = velocity.length() |
|
|
const cSpeed = velocity.length() |
|
|
const stopTime = cSpeed / a |
|
|
const stopTime = cSpeed / a |
|
|
const stopDistance = a * stopTime * stopTime / 2 |
|
|
const stopDistance = a * stopTime * stopTime / 2 |
|
|
if (distance <= 0.01) { |
|
|
|
|
|
|
|
|
const maxStopTime = speed / a |
|
|
|
|
|
const maxStopDistance = a * stopTime * stopTime / 2 |
|
|
|
|
|
|
|
|
|
|
|
if (distance <= this.stopD) { |
|
|
const stopVel = new this.viewport.ammoModel.btVector3(0, 0, 0) |
|
|
const stopVel = new this.viewport.ammoModel.btVector3(0, 0, 0) |
|
|
this.boxBody.setLinearVelocity(stopVel) |
|
|
this.boxBody.setLinearVelocity(stopVel) |
|
|
this.viewport.ammoModel.destroy(stopVel) |
|
|
this.viewport.ammoModel.destroy(stopVel) |
|
|
@ -920,16 +919,19 @@ export default class PtrObject extends THREE.Object3D { |
|
|
if (cSpeed == 0) { |
|
|
if (cSpeed == 0) { |
|
|
this.boxBody.activate() |
|
|
this.boxBody.activate() |
|
|
} |
|
|
} |
|
|
|
|
|
let keepSpeed = this.keepSpeed |
|
|
if (distance <= stopDistance) { |
|
|
if (distance <= stopDistance) { |
|
|
if (currentPhase != 'decelerate') { |
|
|
if (currentPhase != 'decelerate') { |
|
|
currentPhase = 'decelerate' |
|
|
currentPhase = 'decelerate' |
|
|
const sp = new this.viewport.ammoModel.btVector3(velocity.x(), velocity.y(), velocity.z()) |
|
|
const sp = new this.viewport.ammoModel.btVector3(velocity.x(), velocity.y(), velocity.z()) |
|
|
this.boxBody.setLinearVelocity(sp) |
|
|
this.boxBody.setLinearVelocity(sp) |
|
|
this.viewport.ammoModel.destroy(sp) |
|
|
this.viewport.ammoModel.destroy(sp) |
|
|
|
|
|
keepSpeed = new this.viewport.ammoModel.btVector3(velocity.x(), velocity.y(), velocity.z()) |
|
|
} |
|
|
} |
|
|
} else if (currentPhase == 'decelerate') { |
|
|
|
|
|
currentPhase = 'accelerate' |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
// else if (currentPhase == 'decelerate') {
|
|
|
|
|
|
// currentPhase = 'accelerate'
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
// 运动阶段控制
|
|
|
// 运动阶段控制
|
|
|
switch (currentPhase) { |
|
|
switch (currentPhase) { |
|
|
@ -945,7 +947,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
break |
|
|
break |
|
|
case 'uniform': |
|
|
case 'uniform': |
|
|
currentPhase = 'uniform' |
|
|
currentPhase = 'uniform' |
|
|
this.boxBody.setLinearVelocity(this.keepSpeed) |
|
|
this.boxBody.setLinearVelocity(keepSpeed) |
|
|
this.boxBody.setDamping(0, 0); |
|
|
this.boxBody.setDamping(0, 0); |
|
|
break |
|
|
break |
|
|
case 'decelerate': |
|
|
case 'decelerate': |
|
|
@ -953,6 +955,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
if (cSpeed > 0) { |
|
|
if (cSpeed > 0) { |
|
|
this.boxBody.setDamping(sa, 0); |
|
|
this.boxBody.setDamping(sa, 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.boxBody.activate() |
|
|
this.boxBody.activate() |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
|
@ -983,7 +986,6 @@ export default class PtrObject extends THREE.Object3D { |
|
|
// 取货
|
|
|
// 取货
|
|
|
addLoad(height: number, goodsId: string): void { |
|
|
addLoad(height: number, goodsId: string): void { |
|
|
this.actionAnimation = 'wq' |
|
|
this.actionAnimation = 'wq' |
|
|
console.log('取货') |
|
|
|
|
|
this.TaskMode = 2 |
|
|
this.TaskMode = 2 |
|
|
this.PickMode = 1 |
|
|
this.PickMode = 1 |
|
|
this.OperationType = 4 |
|
|
this.OperationType = 4 |
|
|
@ -1012,7 +1014,6 @@ export default class PtrObject extends THREE.Object3D { |
|
|
// 卸货
|
|
|
// 卸货
|
|
|
addUnload(height: number, goodsId: string): void { |
|
|
addUnload(height: number, goodsId: string): void { |
|
|
this.actionAnimation = 'wq' |
|
|
this.actionAnimation = 'wq' |
|
|
console.log('卸货') |
|
|
|
|
|
this.TaskMode = 2 |
|
|
this.TaskMode = 2 |
|
|
this.PickMode = 2 |
|
|
this.PickMode = 2 |
|
|
this.OperationType = 4 |
|
|
this.OperationType = 4 |
|
|
|