From e1e1a2d934f6bd630abb67784ba18d38f6bea28e Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期三, 03 十二月 2025 16:53:13 +0800
Subject: [PATCH] #
---
src/main/webapp/views/locMap/locMap.html | 158 ++++++++++++----------------------------------------
1 files changed, 38 insertions(+), 120 deletions(-)
diff --git a/src/main/webapp/views/locMap/locMap.html b/src/main/webapp/views/locMap/locMap.html
index bf5fa32..2fcfd1d 100644
--- a/src/main/webapp/views/locMap/locMap.html
+++ b/src/main/webapp/views/locMap/locMap.html
@@ -238,101 +238,22 @@
}
});
},
- getShuttleStateInfo() {
- this.sendWs(JSON.stringify({
- "url": "/shuttle/table/shuttle/state",
- "data": {}
- }))
- },
- setShuttleStateInfo(res) {
- // 鍥涘悜绌挎杞︿俊鎭〃鑾峰彇
- let that = this
- if (res.code == 200) {
- let currentLevShuttle = []//褰撳墠妤煎眰灏忚溅闆嗗悎
- res.data.forEach((item,idx) => {
- if (item != null && item.point != undefined && item.point != null) {
- if (item.point.z == that.currentLev) {
- currentLevShuttle.push(item);
- }
- }
- })
- that.shuttleList = res.data
- if (that.shuttleColorList.length == 0) {
- let colorList = []//闅忔満灏忚溅棰滆壊
- res.data.forEach((item,idx) => {
- colorList[item.shuttleNo] = that.colorRGB()
- })
- that.shuttleColorList = colorList
- }
-
- const result = this.findShuttleDiffList(this.currentLevShuttleList, currentLevShuttle);
- if (!result) {
- //灏忚溅瀛樺湪鍙樺姩锛岄噸鏂版覆鏌撳叏閮ㄥ皬杞�
- pixiShuttleMap.forEach((shuttle,index) => {
- pixiApp.stage.removeChild(shuttle)
- pixiShuttleMap.delete(index)
- })
-
- currentLevShuttle.forEach((item,index) => {
- pixiApp.loader.load((loader, resources) => {
- // 绾圭悊鍒涘缓灏忚溅
- const shuttle = new PIXI.Sprite(resources.shuttle.texture);
- shuttle.width = width
- shuttle.height = height
- shuttle.x = (item.wcsPoint.y - 0) * width;//鏇存柊鍧愭爣x
- shuttle.y = (item.wcsPoint.x - 1) * height;//鏇存柊鍧愭爣y
- shuttle.updateMoveStatus = true;//鍔ㄧ敾鎵ц瀹屾垚
- shuttle.interactive = true; // 蹇呴』瑕佽缃墠鑳芥帴鏀朵簨浠�
- shuttle.buttonMode = true; // 璁╁厜鏍囧湪hover鏃跺彉涓烘墜鍨嬫寚閽�
- shuttle.on('pointerdown', (e) => {
- this.drawerShuttle = true;
- this.drawerShuttleData = item;
- })
- pixiApp.stage.addChild(shuttle);
- pixiShuttleMap.set(item.shuttleNo, shuttle);
- })
-
- if (item.moveAdvancePath != null && item.moveAdvancePath.length > 0) {//瀛樺湪棰勮璺緞锛岃繘琛屾覆鏌�
- this.addMoveAdvancePath(item.moveAdvancePath, item.shuttleNo);//娣诲姞棰勮璺緞
- }
-
- })
- }else {
- //灏忚溅涓嶅瓨鍦ㄥ彉鍔紝娓叉煋灏忚溅浣嶇疆
- currentLevShuttle.forEach((item,index) => {
- this.updateShuttleXY(item)
- })
-
- const resultPath = this.findShuttlePathDiffList(JSON.parse(JSON.stringify(this.currentLevShuttleList)), JSON.parse(JSON.stringify(currentLevShuttle)));
- if (!resultPath) {
- //棰勮璺緞瀛樺湪鍙樺姩锛屾覆鏌撹矾寰�
- currentLevShuttle.forEach((item,index) => {
- //鍒犻櫎棰勮璺緞
- this.removeMoveAdvancePath(item.shuttleNo);
- if (item.moveAdvancePath != null && item.moveAdvancePath.length > 0) {//瀛樺湪棰勮璺緞锛岃繘琛屾覆鏌�
- this.addMoveAdvancePath(item.moveAdvancePath, item.shuttleNo);//娣诲姞棰勮璺緞
- }
- })
- }
- }
- that.currentLevShuttleList = currentLevShuttle;
- }
- },
//鑾峰彇鍦板浘鏁版嵁
getMap(lev) {
- this.sendWs(JSON.stringify({
- "url": "/console/locMap/auth",
- "data": lev
- }))
- },
- setMap(res) {
- //鑾峰彇鍦板浘鏁版嵁
- let data = res.data
- let tmp = []
- for (let i = 1; i < data.length - 1; i++) {
- tmp.push(data[i])
- }
- this.createMapData(tmp)
+ let that = this;
+ $.ajax({
+ url: baseUrl + "/console/map/" + lev + "/auth",
+ headers: {
+ 'token': localStorage.getItem('token')
+ },
+ data: {},
+ method: 'get',
+ success: function(res) {
+ //鑾峰彇鍦板浘鏁版嵁
+ let data = res.data
+ that.createMapData(data)
+ }
+ })
},
changeFloor(lev) {
this.currentLev = lev
@@ -365,7 +286,7 @@
pixiApp.loader.add('shuttle', '../static/images/sxcar.png');
// 浠嶨raphics瀵硅薄鍒涘缓涓�涓汗鐞�
- graphicsF = pixiApp.renderer.generateTexture(getContainer(1000));
+ graphicsF = pixiApp.renderer.generateTexture(getContainer(1000));
graphics0 = pixiApp.renderer.generateTexture(getContainer(0));
graphics3 = pixiApp.renderer.generateTexture(getContainer(3));
graphics4 = pixiApp.renderer.generateTexture(getContainer(4));
@@ -434,29 +355,16 @@
pixiApp.view.addEventListener('wheel', (event) => {
event.stopPropagation();
event.preventDefault();
- // 鍥犱负鐢诲竷鏄厖婊¤绐楃殑锛屾墍浠lientX绛変簬mouse point鍦╮enderer涓婄殑x鍧愭爣
- const globalPos = [event.clientX, event.clientY];
- const delta = event.deltaY;
+ const sx = event.clientX;
+ const sy = event.clientY;
const oldZoom = pixiApp.stage.scale.x;
+ const delta = event.deltaY;
let newZoom = oldZoom * 0.999 ** delta;
-
- // const oldStageMatrix = app.stage.localTransform.clone();
- // const oldStagePos = oldStageMatrix.applyInverse(pointerGlobalPos);
- const oldStagePos = globalPos;
- const dx = oldStagePos[0] * oldZoom - oldStagePos[0] * newZoom;
- const dy = oldStagePos[1] * oldZoom - oldStagePos[1] * newZoom;
-
- pixiApp.stage.setTransform(
- pixiApp.stage.position.x + dx,
- pixiApp.stage.position.y + dy,
- newZoom,
- newZoom,
- 0,
- 0,
- 0,
- 0,
- 0
- );
+ const worldX = (sx - pixiApp.stage.position.x) / oldZoom;
+ const worldY = (sy - pixiApp.stage.position.y) / oldZoom;
+ const newPosX = sx - worldX * newZoom;
+ const newPosY = sy - worldY * newZoom;
+ pixiApp.stage.setTransform(newPosX, newPosY, newZoom, newZoom, 0, 0, 0, 0, 0);
});
//*******************缂╂斁鐢诲竷*******************
@@ -478,7 +386,6 @@
this.reloadMap = false
pixiStageList = [map.length]//鍒濆鍖栧垪琛�
pixiStaMap = new Map();//閲嶇疆
-
objectsContainer.removeChildren()
map.forEach((item,index) => {
pixiStageList[index] = [item.length]
@@ -542,10 +449,21 @@
}
});
- //瑙嗚灞呬腑
- let containerWidth = (pixiApp.view.width - objectsContainer.width) / 2;
- let containerHeight = (pixiApp.view.height - objectsContainer.height) / 2;
- pixiApp.stage.position.set(containerWidth, containerHeight);
+ const b1 = objectsContainer.getLocalBounds();
+ const b2 = objectsContainer2.getLocalBounds();
+ const minX = Math.min(b1.x, b2.x);
+ const minY = Math.min(b1.y, b2.y);
+ const maxX = Math.max(b1.x + b1.width, b2.x + b2.width);
+ const maxY = Math.max(b1.y + b1.height, b2.y + b2.height);
+ const contentW = Math.max(0, maxX - minX);
+ const contentH = Math.max(0, maxY - minY);
+ const vw = pixiApp.view.width;
+ const vh = pixiApp.view.height;
+ let scale = Math.min(vw / contentW, vh / contentH) * 0.95;
+ if (!isFinite(scale) || scale <= 0) { scale = 1; }
+ const posX = (vw - contentW * scale) / 2 - minX * scale;
+ const posY = (vh - contentH * scale) / 2 - minY * scale;
+ pixiApp.stage.setTransform(posX, posY, scale, scale, 0, 0, 0, 0, 0);
}else {
let diff = this.findDiffList(this.map, map);
diff.forEach((item, index) => {
--
Gitblit v1.9.1