From 11b3895f8e164b90ee61e723f633fe1f9e9deb1f Mon Sep 17 00:00:00 2001 From: yuliang <398780299@qq.com> Date: Thu, 26 Jun 2025 15:40:00 +0800 Subject: [PATCH] =?UTF-8?q?cl2=20=E5=9F=BA=E4=BA=8E=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=92=8C=E4=BB=BB=E5=8A=A1=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=88=86=E6=AD=A5=E7=94=9F=E6=88=90=E8=AE=BE=E5=A4=87=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/cl2/Cl23dObject.ts | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/modules/cl2/Cl23dObject.ts b/src/modules/cl2/Cl23dObject.ts index c479481..2649efb 100644 --- a/src/modules/cl2/Cl23dObject.ts +++ b/src/modules/cl2/Cl23dObject.ts @@ -396,13 +396,13 @@ export default class Cl23dObject extends THREE.Object3D { try { // 安全连接配置 const client = - mqtt.connect('mqtt://127.0.0.1:9001', { + mqtt.connect('mqtt://10.10.203.239:9001', { path: '/mqtt', clientId: 'virtual-' + item.id, clean: true, connectTimeout: 10000, - username: 'user', - password: 'user', + username: 'admin', + password: 'admin', unixSocket: true, keepalive: 60, }); @@ -459,7 +459,7 @@ export default class Cl23dObject extends THREE.Object3D { //当队列为空时,检查当前车辆所在位置 const pointItem = Model.getItemByXYZ(this.position.x, this.position.y, this.position.z) if (!pointItem || data.content.StartX != pointItem.logicX || data.content.StartY != pointItem.logicY) { - throw new Error('当前车辆所在位置未找到') + // throw new Error('当前车辆所在位置未找到') } } @@ -530,19 +530,29 @@ export default class Cl23dObject extends THREE.Object3D { } while (this.taskList.length > 0) { const task = this.taskList[0] + if (this.currentTask == null) { + this.currentTask = task + } - if (task.OperationType == 0 && ((task.Speed > 0) != (this.currentTask.Speed > 1) || task.Direction != this.currentTask.Direction)) { + if (task.OperationType == 0 + && ((task.Speed > 0) != (this.currentTask.Speed > 0) || task.Direction != this.currentTask.Direction)) { if (!this.currentAnimation || this.currentAnimation == this.rotationAnimation) { // 转向 - this.addRotation(task.Direction) - this.currentAnimation = task + this.addRotation(task.Direction).then(()=>{ + this.executeTask() + }) + this.currentAnimation = this.rotationAnimation + this.currentTask = task } } else if (task.OperationType === 0) { if (!this.currentAnimation || this.currentAnimation == this.travelAnimation) { this.taskList.shift() this.addTravel(task.X, task.Y, task.Speed / 1000) - this.currentAnimation = task + this.currentAnimation = this.travelAnimation + this.currentTask = task } + } else { + } } } @@ -676,7 +686,8 @@ export default class Cl23dObject extends THREE.Object3D { onComplete: () => { this.travelAnimation = null this.currentAnimation = null - resolve() + this.executeTask() + // resolve() } }) this.currentAnimation = this.travelAnimation