solved few bugs in agv
This commit is contained in:
@@ -19,7 +19,9 @@ const Agv = ({
|
||||
}) => {
|
||||
const [pathPoints, setPathPoints] = useState<
|
||||
{
|
||||
uuid: string;
|
||||
modelUuid: string;
|
||||
modelSpeed: number;
|
||||
bufferTime: number;
|
||||
points: { x: number; y: number; z: number }[];
|
||||
}[]
|
||||
>([]);
|
||||
@@ -32,6 +34,7 @@ const Agv = ({
|
||||
(val: any) => val.modelName === "agv"
|
||||
);
|
||||
|
||||
console.log("agvModels: ", agvModels);
|
||||
let findMesh = agvModels.filter(
|
||||
(val: any) =>
|
||||
val.modeluuid === selectedActionSphere?.path?.modeluuid &&
|
||||
@@ -49,8 +52,9 @@ const Agv = ({
|
||||
"y" in findMesh[0].point.actions.end
|
||||
? [
|
||||
{
|
||||
uuid: findMesh[0].modeluuid, // Ensure it's a number
|
||||
|
||||
modelUuid: findMesh[0].modeluuid, // Ensure it's a number
|
||||
modelSpeed: findMesh[0].point.speed,
|
||||
bufferTime: findMesh[0].point.actions.buffer,
|
||||
points: [
|
||||
{
|
||||
x: findMesh[0].position[0],
|
||||
@@ -72,15 +76,29 @@ const Agv = ({
|
||||
]
|
||||
: [];
|
||||
if (result.length > 0) {
|
||||
// setPathPoints((prev) => [...prev, ...result]);
|
||||
setPathPoints((prev) => {
|
||||
const existingUUIDs = new Set(prev.map((item) => item.uuid));
|
||||
const newItems = result.filter(
|
||||
(item) => !existingUUIDs.has(item.uuid)
|
||||
const existingIndex = prev.findIndex(
|
||||
(item) => item.modelUuid === result[0].modelUuid
|
||||
);
|
||||
return [...prev, ...newItems];
|
||||
|
||||
if (existingIndex !== -1) {
|
||||
const updatedPathPoints = [...prev];
|
||||
updatedPathPoints[existingIndex] = result[0];
|
||||
return updatedPathPoints;
|
||||
} else {
|
||||
return [...prev, ...result];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// setPathPoints((prev) => {
|
||||
// const existingUUIDs = new Set(prev.map((item) => item.uuid));
|
||||
// const newItems = result.filter(
|
||||
// (item) => !existingUUIDs.has(item.uuid)
|
||||
// );
|
||||
// return [...prev, ...newItems];
|
||||
// });
|
||||
}, [simulationPaths, selectedActionSphere]);
|
||||
|
||||
let groupRef = useRef() as Types.RefGroup;
|
||||
@@ -96,12 +114,40 @@ const Agv = ({
|
||||
plane={plane}
|
||||
/>
|
||||
{pathPoints.map((pair, i) => (
|
||||
<PathNavigator
|
||||
navMesh={navMesh}
|
||||
selectedPoints={pair.points}
|
||||
id={pair.uuid}
|
||||
key={i}
|
||||
/>
|
||||
<>
|
||||
<PathNavigator
|
||||
navMesh={navMesh}
|
||||
selectedPoints={pair.points}
|
||||
id={pair.modelUuid}
|
||||
key={i}
|
||||
speed={pair.modelSpeed}
|
||||
bufferTime={pair.bufferTime}
|
||||
/>
|
||||
{/* {pair.points.length > 2 && (
|
||||
<>
|
||||
<mesh
|
||||
position={[
|
||||
pair.points[1].x,
|
||||
pair.points[1].y,
|
||||
pair.points[1].z,
|
||||
]}
|
||||
>
|
||||
<sphereGeometry args={[0.3, 15, 15]} />
|
||||
<meshStandardMaterial color="red" />
|
||||
</mesh>
|
||||
<mesh
|
||||
position={[
|
||||
pair.points[2].x,
|
||||
pair.points[2].y,
|
||||
pair.points[2].z,
|
||||
]}
|
||||
>
|
||||
<sphereGeometry args={[0.3, 15, 15]} />
|
||||
<meshStandardMaterial color="red" />
|
||||
</mesh>
|
||||
</>
|
||||
)} */}
|
||||
</>
|
||||
))}
|
||||
<group ref={groupRef} visible={false} name="Meshes"></group>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user