From 443b9b204ec2f09f6f0b412f0faabf12fa4cd9a8 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期二, 22 十月 2024 15:42:28 +0800 Subject: [PATCH] # --- zy-acs-flow/src/map/tool.js | 63 ++++++++++++++++++------------- 1 files changed, 37 insertions(+), 26 deletions(-) diff --git a/zy-acs-flow/src/map/tool.js b/zy-acs-flow/src/map/tool.js index 4af5a42..c3a15d6 100644 --- a/zy-acs-flow/src/map/tool.js +++ b/zy-acs-flow/src/map/tool.js @@ -111,8 +111,8 @@ if (texture) { sprite = new PIXI.Sprite(PIXI.Texture.from(texture, { resourceOptions: { scale: 1 } })); } - sprite.width = 300; - sprite.height = 500; + sprite.width = 400; + sprite.height = 700; sprite.zIndex = DEVICE_Z_INDEX.AGV; break case DEVICE_TYPE.POINT: @@ -544,6 +544,37 @@ return num * (Math.PI / 180); } +const animateRotation = (sprite, targetRotation, rotationOffset = 0) => { + if (!mapContainer || !sprite) { + return; + } + // origin + let currentRotation = sprite.rotation + rotationOffset; + // target + targetRotation += rotationOffset; + + // diff + let rotationDifference = targetRotation - currentRotation; + if (rotationDifference === 0) { + return; + } + rotationDifference = ((rotationDifference + Math.PI) % (2 * Math.PI)) - Math.PI; + + // destination + const endRotation = sprite.rotation + rotationDifference; + + new TWEEDLE.Tween(sprite) + .to({ rotation: endRotation }, 1000) + .easing(TWEEDLE.Easing.Linear.None) + .onUpdate(() => { + // agv + if (sprite.updateTextRotation) { + sprite.updateTextRotation(); + } + }) + .start(); +}; + export const incrementSpriteNo = (str, incrementValue) => { const match = str.match(/(\D*)(\d+)/); if (match) { @@ -633,11 +664,11 @@ if (!code) { return; } const codeSprite = querySprite(DEVICE_TYPE.POINT, code); if (!codeSprite) { return; } - let agvSprite = querySprite(DEVICE_TYPE.AGV, agvNo); - const targetRotation = rotationParseNum(direction); + const targetRotation = rotationParseNum(direction); const backpackCount = backpack?.filter(item => item.loaded === true).length || 0; + let agvSprite = querySprite(DEVICE_TYPE.AGV, agvNo); if (!agvSprite) { const agvStatusMode = getAgvStatusMode(backpackCount, battery); const agvTexture = generateAgvSpriteTexture(agvStatusMode); @@ -662,6 +693,7 @@ agvText.anchor.set(0.5, 0.5); agvText.position.set(0, 0); agvSprite.addChild(agvText); + agvSprite.updateTextRotation = () => { if (agvText && agvSprite) { agvText.rotation = -agvSprite.rotation; @@ -694,27 +726,6 @@ .start(); } -const animateRotation = (sprite, targetRotation, agvRotationOffset) => { - let currentRotation = sprite.rotation + agvRotationOffset; - targetRotation += agvRotationOffset; - - let rotationDifference = targetRotation - currentRotation; - - rotationDifference = ((rotationDifference + Math.PI) % (2 * Math.PI)) - Math.PI; - - const endRotation = sprite.rotation + rotationDifference; - - new TWEEDLE.Tween(sprite) - .to({ rotation: endRotation }, 1000) - .easing(TWEEDLE.Easing.Linear.None) - .onUpdate(() => { - if (sprite.updateTextRotation) { - sprite.updateTextRotation(); - } - }) - .start(); -}; - const drawerAgvPath = (curZone, agvVo) => { if (!mapContainer) { return; @@ -730,7 +741,7 @@ agvPath.name = agvPathName; agvPath.lineStyle(Math.max(20, 4 * (1 / mapContainer.scale.x)), 0x2f68ac, 0.8); agvPath.zIndex = DEVICE_Z_INDEX.DYNAMIC_ROUTE; - agvPath.blendMode = PIXI.BLEND_MODES.NORMAL; + // agvPath.blendMode = PIXI.BLEND_MODES.NORMAL; let firstNode = true; for (let i = Math.max(0, dynamicRoute.indexOf(curCode)); i < dynamicRoute.length; i++) { -- Gitblit v1.9.1