#
luxiaotao1123
2024-03-26 7fd88186222943f45d4b9f97a0a7ebb645a055ab
zy-asrs-flow/src/pages/map/utils.js
@@ -3,6 +3,7 @@
import Http from '@/utils/http';
import { message } from 'antd';
import { API_TIMEOUT } from '@/config/setting'
import agv from '/public/img/map/agv.svg'
import shelf from '/public/img/map/shelf.png'
import point from '/public/img/map/point.svg'
@@ -60,6 +61,35 @@
        mapX: (x - rect.left) / mapContainer.scale.x - mapContainer.x / mapContainer.scale.x,
        mapY: (y - rect.top) / mapContainer.scale.y - mapContainer.y / mapContainer.scale.y
    }
}
export const generateSprite = (sensorType) => {
    let sprite;
    switch (sensorType) {
        case SENSOR_TYPE.SHUTTLE:
            sprite = new PIXI.Sprite(PIXI.Texture.from(shuttle, { resourceOptions: { scale: 5 } }));
            sprite.width = 50;
            sprite.height = 50;
            break;
        case SENSOR_TYPE.AGV:
            sprite = new PIXI.Sprite(PIXI.Texture.from(agv, { resourceOptions: { scale: 5 } }));
            sprite.width = 50;
            sprite.height = 50;
            break;
        case SENSOR_TYPE.SHELF:
            sprite = new PIXI.Sprite(PIXI.Texture.from(shelf, { resourceOptions: { scale: 5 } }));
            sprite.width = 60;
            sprite.height = 60;
            break;
        case SENSOR_TYPE.POINT:
            sprite = new PIXI.Sprite(PIXI.Texture.from(point, { resourceOptions: { scale: 5 } }));
            sprite.width = 10;
            sprite.height = 10;
            break;
        default:
            break;
    }
    return sprite;
}
export const initSprite = (sprite, type) => {
@@ -359,25 +389,7 @@
    await Http.doPostPromise('api/map/list', { floor: curFloor }, (res) => {
        const mapItemList = eval(res.data);
        mapItemList.forEach(item => {
            let sprite;
            switch (item.type) {
                case SENSOR_TYPE.SHUTTLE:
                    sprite = PIXI.Sprite.from({ source: shuttle, scaleMode: PIXI.SCALE_MODES.HIGH });
                    break;
                case SENSOR_TYPE.SHELF:
                    sprite = PIXI.Sprite.from(shelf);
                    break;
                case SENSOR_TYPE.AGV:
                    sprite = new PIXI.Sprite(PIXI.Texture.from(agv, { resourceOptions: { scale: 5 } }));
                    sprite.width = 50;
                    sprite.height = 50;
                    break;
                case SENSOR_TYPE.POINT:
                    sprite = PIXI.Sprite.from(point);
                    break;
                default:
                    break;
            }
            const sprite = generateSprite(item.type);
            if (sprite) {
                initSprite(sprite, item.type);
                // data