From 3c190ac12e00e0f3435984c5d57351d136530c09 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期五, 15 三月 2024 15:51:26 +0800 Subject: [PATCH] # --- zy-asrs-flow/src/pages/map/utils.js | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 50 insertions(+), 1 deletions(-) diff --git a/zy-asrs-flow/src/pages/map/utils.js b/zy-asrs-flow/src/pages/map/utils.js index c56b8b9..ae5567b 100644 --- a/zy-asrs-flow/src/pages/map/utils.js +++ b/zy-asrs-flow/src/pages/map/utils.js @@ -1,5 +1,6 @@ import * as PIXI from 'pixi.js'; import * as TWEEDLE from 'tweedle.js'; +import Http from '@/utils/http'; let app = null; let mapContainer = null; @@ -76,7 +77,7 @@ dragTarget = event.currentTarget; mapContainer.parent.off('pointermove'); mapContainer.parent.on('pointermove', onDragMove, dragTarget); - + mapContainer.parent.off('pointerup'); mapContainer.parent.on('pointerup', onDragEnd.bind(mapContainer)); } @@ -269,6 +270,20 @@ } } +export const rotationToNum = (rotation) => { + let res = rotation * 180 / Math.PI; + if (res < 0) { + res += 360; + } else if (res > 360) { + res -= 360; + } + return res; +} + +export const rotationParseNum = (num) => { + +} + export const findSpriteByUuid = (uuid) => { return mapContainer?.children?.find(child => child?.data?.uuid === uuid); } @@ -295,4 +310,38 @@ }) return options; +} + +export const fetchMapData = () => { + + +} + +export const saveMapData = async () => { + if (!mapContainer) { + return; + } + + let mapItemList = []; + mapContainer?.children.forEach(child => { + if (child.data?.uuid) { + console.log(child.scale, child.rotation); + mapItemList.push({ + // data + type: child.data.type, + uuid: child.data.uuid, + no: child.data.no, + + // graph + positionX: child.position.x, + positionY: child.position.y, + scaleX: child.scale.x, + scaleY: child.scale.y, + rotation: rotationToNum(child.rotation) + }) + } + }) + + const resp = await Http.doPost('api/map/save', { itemList: mapItemList }) + console.log(resp); } \ No newline at end of file -- Gitblit v1.9.1