|
|
@ -1,4 +1,4 @@ |
|
|
import * as THREE from "three"; |
|
|
import * as THREE from 'three' |
|
|
import { |
|
|
import { |
|
|
AmrErrorCode, |
|
|
AmrErrorCode, |
|
|
AmrMsg, AmrMsg10010, AmrMsg10050, AmrMsg10060, AmrMsg10110, AmrMsg10120, AmrMsg20010, |
|
|
AmrMsg, AmrMsg10010, AmrMsg10050, AmrMsg10060, AmrMsg10110, AmrMsg10120, AmrMsg20010, |
|
|
@ -14,14 +14,14 @@ import { |
|
|
TaskModeChangeData, |
|
|
TaskModeChangeData, |
|
|
TaskStatusChangeData, |
|
|
TaskStatusChangeData, |
|
|
TaskTypeChangeData |
|
|
TaskTypeChangeData |
|
|
} from "@/core/manager/amr/AmrMessageDefine"; |
|
|
} from '@/core/manager/amr/AmrMessageDefine' |
|
|
import {worldModel} from "@/core/manager/WorldModel"; |
|
|
import { worldModel } from '@/core/manager/WorldModel' |
|
|
import Viewport from "@/core/engine/Viewport"; |
|
|
import Viewport from '@/core/engine/Viewport' |
|
|
import {Euler} from "three/src/math/Euler"; |
|
|
import { Euler } from 'three/src/math/Euler' |
|
|
import gsap from "gsap"; |
|
|
import gsap from 'gsap' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type CStepTaskType = "MOVE" | "MOVE_BACKWARD" | "ROTATION" | "LOAD" | "UNLOAD" | "CHARGE" |
|
|
type CStepTaskType = 'MOVE' | 'MOVE_BACKWARD' | 'ROTATION' | 'LOAD' | 'UNLOAD' | 'CHARGE' |
|
|
|
|
|
|
|
|
export interface StepTask { |
|
|
export interface StepTask { |
|
|
SeqNo: number; |
|
|
SeqNo: number; |
|
|
@ -55,8 +55,8 @@ export default class PtrObject extends THREE.Object3D { |
|
|
|
|
|
|
|
|
public clock = new THREE.Clock() |
|
|
public clock = new THREE.Clock() |
|
|
|
|
|
|
|
|
override AGVModel = "" |
|
|
override AGVModel = '' |
|
|
override AGVFnModel = "" |
|
|
override AGVFnModel = '' |
|
|
|
|
|
|
|
|
private boxBody: any = null |
|
|
private boxBody: any = null |
|
|
private __toPos: THREE.Vector3 = null |
|
|
private __toPos: THREE.Vector3 = null |
|
|
@ -159,7 +159,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
private mqRetryTimeCount: number = 0 |
|
|
private mqRetryTimeCount: number = 0 |
|
|
|
|
|
|
|
|
constructor(item: ItemJson, viewport: Viewport) { |
|
|
constructor(item: ItemJson, viewport: Viewport) { |
|
|
super(); |
|
|
super() |
|
|
this.viewport = viewport |
|
|
this.viewport = viewport |
|
|
this.item = item |
|
|
this.item = item |
|
|
this.vehicleId = parseInt(item.id) |
|
|
this.vehicleId = parseInt(item.id) |
|
|
@ -194,23 +194,23 @@ export default class PtrObject extends THREE.Object3D { |
|
|
|
|
|
|
|
|
// 开机
|
|
|
// 开机
|
|
|
boot() { |
|
|
boot() { |
|
|
this.bootTime = Date.now(); |
|
|
this.bootTime = Date.now() |
|
|
this.computeLogicXYAndDirection(); |
|
|
this.computeLogicXYAndDirection() |
|
|
|
|
|
|
|
|
const boxShape = new this.viewport.ammoModel.btBoxShape(new Ammo.btVector3(0.5, 0.5, 0.5)); |
|
|
const boxShape = new this.viewport.ammoModel.btBoxShape(new Ammo.btVector3(0.5, 0.5, 0.5)) |
|
|
|
|
|
|
|
|
const mass = 10 |
|
|
const mass = 10 |
|
|
const localInertia = new this.viewport.ammoModel.btVector3(0, 0, 0) |
|
|
const localInertia = new this.viewport.ammoModel.btVector3(0, 0, 0) |
|
|
boxShape.calculateLocalInertia(mass, localInertia) |
|
|
boxShape.calculateLocalInertia(mass, localInertia) |
|
|
|
|
|
|
|
|
const boxTransform = new this.viewport.ammoModel.btTransform(); |
|
|
const boxTransform = new this.viewport.ammoModel.btTransform() |
|
|
boxTransform.setIdentity(); |
|
|
boxTransform.setIdentity() |
|
|
boxTransform.setOrigin(new this.viewport.ammoModel.btVector3(this.position.x, this.position.y, this.position.z)); |
|
|
boxTransform.setOrigin(new this.viewport.ammoModel.btVector3(this.position.x, this.position.y, this.position.z)) |
|
|
|
|
|
|
|
|
const boxMotionState = new this.viewport.ammoModel.btDefaultMotionState(boxTransform); |
|
|
const boxMotionState = new this.viewport.ammoModel.btDefaultMotionState(boxTransform) |
|
|
const rbInfo = new this.viewport.ammoModel.btRigidBodyConstructionInfo(mass, boxMotionState, boxShape, localInertia) |
|
|
const rbInfo = new this.viewport.ammoModel.btRigidBodyConstructionInfo(mass, boxMotionState, boxShape, localInertia) |
|
|
this.boxBody = new this.viewport.ammoModel.btRigidBody(rbInfo); |
|
|
this.boxBody = new this.viewport.ammoModel.btRigidBody(rbInfo) |
|
|
this.viewport.physicsWorld.addRigidBody(this.boxBody); |
|
|
this.viewport.physicsWorld.addRigidBody(this.boxBody) |
|
|
|
|
|
|
|
|
if (!worldModel.state.runState.isVirtual) { |
|
|
if (!worldModel.state.runState.isVirtual) { |
|
|
return |
|
|
return |
|
|
@ -321,7 +321,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
ActuatorsData: [ |
|
|
ActuatorsData: [ |
|
|
{ |
|
|
{ |
|
|
MechNo: 1, |
|
|
MechNo: 1, |
|
|
Name: "Mech1", |
|
|
Name: 'Mech1', |
|
|
PickMode: this.PickMode |
|
|
PickMode: this.PickMode |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
@ -349,10 +349,10 @@ export default class PtrObject extends THREE.Object3D { |
|
|
content.CurLogicX = this.currentLogicX |
|
|
content.CurLogicX = this.currentLogicX |
|
|
content.CurLogicY = this.currentLogicY |
|
|
content.CurLogicY = this.currentLogicY |
|
|
content.CurOrientation = this.currentOrientation |
|
|
content.CurOrientation = this.currentOrientation |
|
|
content.CurX = this.position.x; |
|
|
content.CurX = this.position.x |
|
|
content.CurY = this.position.z; |
|
|
content.CurY = this.position.z |
|
|
content.X = this.position.x; |
|
|
content.X = this.position.x |
|
|
content.Y = this.position.z; |
|
|
content.Y = this.position.z |
|
|
const m20060 = new AmrMsg<AmrMsg20060>(content) |
|
|
const m20060 = new AmrMsg<AmrMsg20060>(content) |
|
|
this.sendMessage(m20060) |
|
|
this.sendMessage(m20060) |
|
|
} |
|
|
} |
|
|
@ -460,27 +460,27 @@ export default class PtrObject extends THREE.Object3D { |
|
|
} |
|
|
} |
|
|
const ddra = Math.PI / 180 |
|
|
const ddra = Math.PI / 180 |
|
|
if (ra >= Math.PI * 2 - ddra || ra <= ddra) { |
|
|
if (ra >= Math.PI * 2 - ddra || ra <= ddra) { |
|
|
this.currentDirection = 0; |
|
|
this.currentDirection = 0 |
|
|
|
|
|
|
|
|
} else if (ra >= Math.PI / 2 - ddra && ra <= Math.PI / 2 + ddra) { |
|
|
} else if (ra >= Math.PI / 2 - ddra && ra <= Math.PI / 2 + ddra) { |
|
|
this.currentDirection = 3; |
|
|
this.currentDirection = 3 |
|
|
|
|
|
|
|
|
} else if (ra >= Math.PI - ddra && ra <= Math.PI + ddra) { |
|
|
} else if (ra >= Math.PI - ddra && ra <= Math.PI + ddra) { |
|
|
this.currentDirection = 2; |
|
|
this.currentDirection = 2 |
|
|
|
|
|
|
|
|
} else if (ra >= Math.PI / 2 * 3 - ddra && ra <= Math.PI / 2 * 3 + ddra) { |
|
|
} 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 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const pointItem = Model.getItemByXYZ(this.position.x, this.position.y, this.position.z) |
|
|
const pointItem = Model.getItemByXYZ(this.position.x, this.position.y, this.position.z) |
|
|
if (!pointItem || !pointItem.logicX || !pointItem.logicY) { |
|
|
if (!pointItem || !pointItem.logicX || !pointItem.logicY) { |
|
|
this.currentLogicX = -1; |
|
|
this.currentLogicX = -1 |
|
|
this.currentLogicY = -1; |
|
|
this.currentLogicY = -1 |
|
|
} else { |
|
|
} else { |
|
|
this.currentLogicX = pointItem.logicX; |
|
|
this.currentLogicX = pointItem.logicX |
|
|
this.currentLogicY = pointItem.logicY; |
|
|
this.currentLogicY = pointItem.logicY |
|
|
} |
|
|
} |
|
|
this.currentOrientation = this.getAmrOrientation(this.rotation.y) |
|
|
this.currentOrientation = this.getAmrOrientation(this.rotation.y) |
|
|
} |
|
|
} |
|
|
@ -494,7 +494,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
} else { |
|
|
} else { |
|
|
currentStepTask = { |
|
|
currentStepTask = { |
|
|
SeqNo: 0, |
|
|
SeqNo: 0, |
|
|
StepTaskType: "MOVE", |
|
|
StepTaskType: 'MOVE', |
|
|
OperationType: 0, |
|
|
OperationType: 0, |
|
|
PickMode: 0, |
|
|
PickMode: 0, |
|
|
X: this.currentLogicX, |
|
|
X: this.currentLogicX, |
|
|
@ -549,7 +549,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
if (endDirection != currentStepTask.EndDirection) { |
|
|
if (endDirection != currentStepTask.EndDirection) { |
|
|
const stepTask: StepTask = { |
|
|
const stepTask: StepTask = { |
|
|
SeqNo: data.SeqNo, |
|
|
SeqNo: data.SeqNo, |
|
|
StepTaskType: "ROTATION", |
|
|
StepTaskType: 'ROTATION', |
|
|
OperationType: 0, |
|
|
OperationType: 0, |
|
|
PickMode: 0, |
|
|
PickMode: 0, |
|
|
X: prevLink.X, |
|
|
X: prevLink.X, |
|
|
@ -567,7 +567,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
|
|
|
|
|
|
const stepTask: StepTask = { |
|
|
const stepTask: StepTask = { |
|
|
SeqNo: data.SeqNo, |
|
|
SeqNo: data.SeqNo, |
|
|
StepTaskType: link.Speed > 0 ? "MOVE" : "MOVE_BACKWARD", |
|
|
StepTaskType: link.Speed > 0 ? 'MOVE' : 'MOVE_BACKWARD', |
|
|
OperationType: 0, |
|
|
OperationType: 0, |
|
|
PickMode: 0, |
|
|
PickMode: 0, |
|
|
X: link.X, |
|
|
X: link.X, |
|
|
@ -590,7 +590,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
|| (linkCount > 0 && data.Link[linkCount - 1].X == data.EndX && data.Link[linkCount - 1].Y == data.EndY)) { |
|
|
|| (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 |
|
|
} else if (data.OperationType == 3 && data.ChargeDirection >= 0 && data.ChargeDirection <= 3) { |
|
|
} else if (data.OperationType == 3 && data.ChargeDirection >= 0 && data.ChargeDirection <= 3) { |
|
|
endDirection = data.ChargeDirection |
|
|
endDirection = data.ChargeDirection |
|
|
} else if (data.OperationType == 4 && data.GoodsSlotDirection >= 0 && data.GoodsSlotDirection <= 3) { |
|
|
} else if (data.OperationType == 4 && data.GoodsSlotDirection >= 0 && data.GoodsSlotDirection <= 3) { |
|
|
@ -610,7 +610,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
} |
|
|
} |
|
|
const stepTask: StepTask = { |
|
|
const stepTask: StepTask = { |
|
|
SeqNo: data.SeqNo, |
|
|
SeqNo: data.SeqNo, |
|
|
StepTaskType: "ROTATION", |
|
|
StepTaskType: 'ROTATION', |
|
|
OperationType: 0, |
|
|
OperationType: 0, |
|
|
PickMode: 0, |
|
|
PickMode: 0, |
|
|
X: data.EndX, |
|
|
X: data.EndX, |
|
|
@ -629,7 +629,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
|
|
|
|
|
|
const stepTask: StepTask = { |
|
|
const stepTask: StepTask = { |
|
|
SeqNo: data.SeqNo, |
|
|
SeqNo: data.SeqNo, |
|
|
StepTaskType: "CHARGE", |
|
|
StepTaskType: 'CHARGE', |
|
|
OperationType: 3, |
|
|
OperationType: 3, |
|
|
PickMode: 0, |
|
|
PickMode: 0, |
|
|
X: data.EndX, |
|
|
X: data.EndX, |
|
|
@ -647,7 +647,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
|
|
|
|
|
|
const stepTask: StepTask = { |
|
|
const stepTask: StepTask = { |
|
|
SeqNo: data.SeqNo, |
|
|
SeqNo: data.SeqNo, |
|
|
StepTaskType: data.PickMode == 1 ? "LOAD" : "UNLOAD", |
|
|
StepTaskType: data.PickMode == 1 ? 'LOAD' : 'UNLOAD', |
|
|
OperationType: 4, |
|
|
OperationType: 4, |
|
|
PickMode: data.PickMode, |
|
|
PickMode: data.PickMode, |
|
|
X: data.EndX, |
|
|
X: data.EndX, |
|
|
@ -676,7 +676,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
while (this.currentStepTaskList.length > 0) { |
|
|
while (this.currentStepTaskList.length > 0) { |
|
|
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 |
|
|
&& 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)) { |
|
|
@ -693,13 +693,13 @@ export default class PtrObject extends THREE.Object3D { |
|
|
this.runningStepTask = stepTask |
|
|
this.runningStepTask = stepTask |
|
|
this.currentStepTaskList.shift() |
|
|
this.currentStepTaskList.shift() |
|
|
this.runningStepTaskList.push(stepTask) |
|
|
this.runningStepTaskList.push(stepTask) |
|
|
if (stepTask.StepTaskType == "MOVE" || stepTask.StepTaskType == "MOVE_BACKWARD") { |
|
|
if (stepTask.StepTaskType == 'MOVE' || stepTask.StepTaskType == 'MOVE_BACKWARD') { |
|
|
this.addTravel(stepTask.X, stepTask.Y, stepTask.Speed / 1000) |
|
|
this.addTravel(stepTask.X, stepTask.Y, stepTask.Speed / 1000) |
|
|
} else if (stepTask.StepTaskType == "ROTATION") { |
|
|
} else if (stepTask.StepTaskType == 'ROTATION') { |
|
|
this.addRotation(stepTask.EndDirection) |
|
|
this.addRotation(stepTask.EndDirection) |
|
|
} else if (stepTask.StepTaskType == "LOAD") { |
|
|
} else if (stepTask.StepTaskType == 'LOAD') { |
|
|
this.addLoad(stepTask.GoodsSlotHeight / 1000) |
|
|
this.addLoad(stepTask.GoodsSlotHeight / 1000) |
|
|
} else if (stepTask.StepTaskType == "UNLOAD") { |
|
|
} else if (stepTask.StepTaskType == 'UNLOAD') { |
|
|
this.addUnload(stepTask.GoodsSlotHeight / 1000) |
|
|
this.addUnload(stepTask.GoodsSlotHeight / 1000) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -775,7 +775,6 @@ export default class PtrObject extends THREE.Object3D { |
|
|
addTravel(logicX: number, logicY: number, speed: number = 1): Promise<void> { |
|
|
addTravel(logicX: number, logicY: number, speed: number = 1): Promise<void> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.OperationType = 0 |
|
|
this.OperationType = 0 |
|
|
this.PickMode = 0 |
|
|
this.PickMode = 0 |
|
|
const pos = Model.getPositionByLogicXY(logicX, logicY) |
|
|
const pos = Model.getPositionByLogicXY(logicX, logicY) |
|
|
@ -791,13 +790,13 @@ export default class PtrObject extends THREE.Object3D { |
|
|
|
|
|
|
|
|
// 运动参数
|
|
|
// 运动参数
|
|
|
const accelForce = speed > 0 ? 4 : (-4) |
|
|
const accelForce = speed > 0 ? 4 : (-4) |
|
|
let currentPhase = 'accelerate'; |
|
|
let currentPhase = 'accelerate' |
|
|
|
|
|
|
|
|
if (this.viewport.registerPhysicsUpdateCallBack.has(this.item.id)) { |
|
|
if (this.viewport.registerPhysicsUpdateCallBack.has(this.item.id)) { |
|
|
return null |
|
|
return null |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.travelAnimation = "asd" |
|
|
this.travelAnimation = 'asd' |
|
|
|
|
|
|
|
|
const force = new this.viewport.ammoModel.btVector3(accelForce, 0, 0) |
|
|
const force = new this.viewport.ammoModel.btVector3(accelForce, 0, 0) |
|
|
this.viewport.registerPhysicsUpdateCallBack.set(this.item.id, () => { |
|
|
this.viewport.registerPhysicsUpdateCallBack.set(this.item.id, () => { |
|
|
@ -826,7 +825,8 @@ export default class PtrObject extends THREE.Object3D { |
|
|
this.travelAnimation = null |
|
|
this.travelAnimation = null |
|
|
this.onActionCompleted() |
|
|
this.onActionCompleted() |
|
|
|
|
|
|
|
|
} if (distance <= stopDistance) { |
|
|
} |
|
|
|
|
|
if (distance <= stopDistance) { |
|
|
currentPhase = 'decelerate' |
|
|
currentPhase = 'decelerate' |
|
|
} |
|
|
} |
|
|
// 运动阶段控制
|
|
|
// 运动阶段控制
|
|
|
|