Skip to content

Commit

Permalink
feat(version): release 0.27.9 version
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangunduz committed Jan 10, 2024
1 parent 5b98f6a commit a73260f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 67 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.8",
"version": "0.27.9",
"private": true,
"scripts": {
"dev": "react-scripts start",
Expand Down
34 changes: 7 additions & 27 deletions src/components/Machine3D/Machine3D.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import MachineBarcode from "../MachineBarcode/MachineBarcode";

interface IMachine3D {
item: {
barcodes: any[];
barcode: string;
waypoint: {
x: number;
y: number;
Expand Down Expand Up @@ -52,14 +52,10 @@ export default function Machine3D({ item }: IMachine3D) {
onPointerEnter={() => !hovered && setHovered(true)}
onPointerLeave={() => hovered && setHovered(false)}
scale={1}
position={[
item?.waypoint?.y,
item?.barcodes?.length / 3,
item?.waypoint?.x,
]}
position={[item?.waypoint?.y, item?.waypoint?.z, item?.waypoint?.x]}
rotation={[0, item?.waypoint?.z || 0, 0]}
>
<boxBufferGeometry args={[0.75, item.barcodes?.length / 1.5, 0.75]} />
<boxBufferGeometry args={[0.75, 0.75, 0.75]} />
<meshNormalMaterial />
{hovered && (
<group>
Expand All @@ -72,11 +68,7 @@ export default function Machine3D({ item }: IMachine3D) {
occlude
onMouseEnter={() => !hovered && setHovered(true)}
>
{item.barcodes?.map((barcode: any, barcodeIndex: number) => {
return (
<MachineBarcode key={barcodeIndex} barcode={barcode?.barcode} />
);
})}
<MachineBarcode barcode={item.barcode} />
</Html>
{/* Front Face */}

Expand All @@ -89,11 +81,7 @@ export default function Machine3D({ item }: IMachine3D) {
occlude
onMouseEnter={() => !hovered && setHovered(true)}
>
{item.barcodes?.map((barcode: any, barcodeIndex: number) => {
return (
<MachineBarcode key={barcodeIndex} barcode={barcode?.barcode} />
);
})}
<MachineBarcode barcode={item.barcode} />
</Html>
{/* Back Face */}

Expand All @@ -107,11 +95,7 @@ export default function Machine3D({ item }: IMachine3D) {
occlude
onMouseEnter={() => !hovered && setHovered(true)}
>
{item.barcodes?.map((barcode: any, barcodeIndex: number) => {
return (
<MachineBarcode key={barcodeIndex} barcode={barcode?.barcode} />
);
})}
<MachineBarcode barcode={item.barcode} />
</Html>
{/* Right Face */}

Expand All @@ -125,11 +109,7 @@ export default function Machine3D({ item }: IMachine3D) {
occlude
onMouseEnter={() => !hovered && setHovered(true)}
>
{item.barcodes?.map((barcode: any, barcodeIndex: number) => {
return (
<MachineBarcode key={barcodeIndex} barcode={barcode?.barcode} />
);
})}
<MachineBarcode barcode={item.barcode} />
</Html>
{/* Left Face */}
</group>
Expand Down
42 changes: 3 additions & 39 deletions src/contexts/BarcodeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ export default ({ children }: any) => {
});

ros &&
barcodes.subscribe(function (message: any) {
console.log("/barcode", message);
barcodes.subscribe(function ({ data }: any) {
const message = JSON.parse(data);

const messageWithScannerId = JSON.parse(message?.data);

handleBarcodeSetters(messageWithScannerId);
setBarcodeItems((prevData: any) => [...prevData, message]);
});
}, [ros]);

Expand Down Expand Up @@ -60,40 +58,6 @@ export default ({ children }: any) => {
console.log(barcodeItems);
}, [barcodeItems]);

function handleBarcodeSetters(message: any) {
setBarcodeItems((prevBarcodeItems: any) => {
const updatedBarcodeItems = [...prevBarcodeItems];

const barcodeIndex = prevBarcodeItems.findIndex(
(barcodeItem: any) =>
barcodeItem.waypoint &&
Math.sqrt(
Math.pow(barcodeItem.waypoint.x - message?.waypoint.x, 2) +
Math.pow(barcodeItem.waypoint.y - message?.waypoint.y, 2),
) < 0.02,
);

if (barcodeIndex !== -1) {
updatedBarcodeItems[barcodeIndex] = {
...prevBarcodeItems[barcodeIndex],
barcodes: prevBarcodeItems[barcodeIndex].barcodes.map(
(barcode: any, index: number) =>
index === message?.scannerId ? message?.barcode : barcode,
),
};
} else {
updatedBarcodeItems.push({
barcodes: Array.apply(null, Array(3)).map((_, index: number) =>
index === message?.scannerId ? message?.barcode : "",
),
waypoint: message?.waypoint,
});
}

return updatedBarcodeItems;
});
}

function quaternionToEuler(q: {
x: number;
y: number;
Expand Down

0 comments on commit a73260f

Please sign in to comment.