Skip to content

Commit

Permalink
feat(version): release 0.27.7 version
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangunduz committed Jan 10, 2024
1 parent 75df761 commit 3f87f1e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui",
"version": "0.27.6",
"version": "0.27.7",
"private": true,
"scripts": {
"dev": "react-scripts start",
Expand Down
8 changes: 4 additions & 4 deletions src/components/Machine3D/Machine3D.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import MachineBarcode from "../MachineBarcode/MachineBarcode";
interface IMachine3D {
item: {
barcodes: any[];
coordinates: {
waypoint: {
x: number;
y: number;
z: number;
Expand Down Expand Up @@ -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]}
>
<boxBufferGeometry args={[0.75, item.barcodes?.length / 1.5, 0.75]} />
<meshNormalMaterial />
Expand Down
14 changes: 10 additions & 4 deletions src/contexts/BarcodeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
);

Expand All @@ -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,
});
}

Expand Down

0 comments on commit 3f87f1e

Please sign in to comment.