From 3f87f1ee4e21407e1c7903d1cc224caa537c0af7 Mon Sep 17 00:00:00 2001 From: gokhangunduz Date: Wed, 10 Jan 2024 11:37:35 +0300 Subject: [PATCH] feat(version): release 0.27.7 version --- package.json | 2 +- src/components/Machine3D/Machine3D.tsx | 8 ++++---- src/contexts/BarcodeContext.tsx | 14 ++++++++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 5ffc1c41..769fe05c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "0.27.6", + "version": "0.27.7", "private": true, "scripts": { "dev": "react-scripts start", diff --git a/src/components/Machine3D/Machine3D.tsx b/src/components/Machine3D/Machine3D.tsx index faf0c1e4..70c2d80d 100644 --- a/src/components/Machine3D/Machine3D.tsx +++ b/src/components/Machine3D/Machine3D.tsx @@ -7,7 +7,7 @@ import MachineBarcode from "../MachineBarcode/MachineBarcode"; interface IMachine3D { item: { barcodes: any[]; - coordinates: { + waypoint: { x: number; y: number; z: number; @@ -53,11 +53,11 @@ export default function Machine3D({ item }: IMachine3D) { onPointerLeave={() => hovered && setHovered(false)} scale={1} position={[ - item?.coordinates?.y, + item?.waypoint?.y, item?.barcodes?.length / 3, - item?.coordinates?.x, + item?.waypoint?.x, ]} - rotation={[0, item?.coordinates?.z || 0, 0]} + rotation={[0, item?.waypoint?.z || 0, 0]} > diff --git a/src/contexts/BarcodeContext.tsx b/src/contexts/BarcodeContext.tsx index 9605e8a5..8c5028d6 100644 --- a/src/contexts/BarcodeContext.tsx +++ b/src/contexts/BarcodeContext.tsx @@ -27,6 +27,8 @@ export default ({ children }: any) => { ros && barcodes.subscribe(function (message: any) { + console.log("/barcode", message); + const messageWithScannerId = JSON.parse(message?.data); handleBarcodeSetters(messageWithScannerId); @@ -54,16 +56,20 @@ export default ({ children }: any) => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [ros]); + useEffect(() => { + console.log(barcodeItems); + }, [barcodeItems]); + function handleBarcodeSetters(message: any) { setBarcodeItems((prevBarcodeItems: any) => { const updatedBarcodeItems = [...prevBarcodeItems]; const barcodeIndex = prevBarcodeItems.findIndex( (barcodeItem: any) => - barcodeItem.coordinates && + barcodeItem.waypoint && Math.sqrt( - Math.pow(barcodeItem.coordinates.x - message?.coordinates.x, 2) + - Math.pow(barcodeItem.coordinates.y - message?.coordinates.y, 2), + Math.pow(barcodeItem.waypoint.x - message?.waypoint.x, 2) + + Math.pow(barcodeItem.waypoint.y - message?.waypoint.y, 2), ) < 0.02, ); @@ -80,7 +86,7 @@ export default ({ children }: any) => { barcodes: Array.apply(null, Array(3)).map((_, index: number) => index === message?.scannerId ? message?.barcode : "", ), - coordinates: message?.coordinates, + waypoint: message?.waypoint, }); }