| | |
| | | import * as PIXI from 'pixi.js'; |
| | | import * as TWEEDLE from 'tweedle.js'; |
| | | import { |
| | | MAP_DEFAULT_ROTATION, |
| | | DEVICE_TYPE, |
| | | DEVICE_Z_INDEX, |
| | | AGV_STATUS_MODE, |
| | |
| | | |
| | | |
| | | export const getRealPosition = (x, y) => { |
| | | const rect = app.view.getBoundingClientRect(); |
| | | return { |
| | | mapX: (x - rect.left) / mapContainer.scale.x - mapContainer.x / mapContainer.scale.x, |
| | | mapY: (y - rect.top) / mapContainer.scale.y - mapContainer.y / mapContainer.scale.y |
| | | } |
| | | const globalPoint = new PIXI.Point(); |
| | | app.renderer.plugins.interaction.mapPositionToPoint(globalPoint, x, y); |
| | | const mapPoint = mapContainer.toLocal(globalPoint); |
| | | return { mapX: mapPoint.x, mapY: mapPoint.y }; |
| | | } |
| | | |
| | | export const generateSprite = (deviceType, texture) => { |
| | |
| | | const agvRotationOffset = rotationParseNum(agvRotationOffsetDegrees); |
| | | |
| | | const showAgvSprite = (curZone, agvVo, setCurSprite) => { |
| | | const { agvNo, code, direction, battery, backpack } = agvVo; |
| | | const { agvNo, code, direction, battery, backpack, error } = agvVo; |
| | | if (!code) { return; } |
| | | const codeSprite = querySprite(DEVICE_TYPE.POINT, code); |
| | | if (!codeSprite) { return; } |
| | |
| | | |
| | | agvSprite.updateTextRotation = () => { |
| | | if (agvText && agvSprite) { |
| | | agvText.rotation = -agvSprite.rotation; |
| | | agvText.rotation = -agvSprite.rotation - rotationParseNum(MAP_DEFAULT_ROTATION); |
| | | } |
| | | }; |
| | | agvSprite.updateTextRotation(); |
| | |
| | | animateRotation(agvSprite, targetRotation + agvRotationOffset, agvRotationOffset); |
| | | } |
| | | |
| | | if (error) { |
| | | agvSprite.tint = 0xff3f34; |
| | | } else { |
| | | agvSprite.tint = 0xffffff; |
| | | } |
| | | |
| | | beInsight(agvSprite, setCurSprite); |
| | | |
| | | new TWEEDLE.Tween(agvSprite.position) |