simulation #45
@@ -22,6 +22,7 @@ const Agv = ({
|
|||||||
modelSpeed: number;
|
modelSpeed: number;
|
||||||
bufferTime: number;
|
bufferTime: number;
|
||||||
points: { x: number; y: number; z: number }[];
|
points: { x: number; y: number; z: number }[];
|
||||||
|
hitCount: number;
|
||||||
}[]
|
}[]
|
||||||
>([]);
|
>([]);
|
||||||
const { simulationPaths } = useSimulationPaths();
|
const { simulationPaths } = useSimulationPaths();
|
||||||
@@ -33,6 +34,7 @@ const Agv = ({
|
|||||||
(val: any) => val.modelName === "agv"
|
(val: any) => val.modelName === "agv"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
let findMesh = agvModels.filter(
|
let findMesh = agvModels.filter(
|
||||||
(val: any) =>
|
(val: any) =>
|
||||||
val.modeluuid === selectedActionSphere?.path?.modeluuid &&
|
val.modeluuid === selectedActionSphere?.path?.modeluuid &&
|
||||||
@@ -49,29 +51,30 @@ const Agv = ({
|
|||||||
"x" in findMesh[0].points.actions.end &&
|
"x" in findMesh[0].points.actions.end &&
|
||||||
"y" in findMesh[0].points.actions.end
|
"y" in findMesh[0].points.actions.end
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
modelUuid: findMesh[0].modeluuid, // Ensure it's a number
|
modelUuid: findMesh[0].modeluuid, // Ensure it's a number
|
||||||
modelSpeed: findMesh[0].points.speed,
|
modelSpeed: findMesh[0].points.speed,
|
||||||
bufferTime: findMesh[0].points.actions.buffer,
|
bufferTime: findMesh[0].points.actions.buffer,
|
||||||
points: [
|
hitCount: findMesh[0].points.actions.hitCount,
|
||||||
{
|
points: [
|
||||||
x: findMesh[0].position[0],
|
{
|
||||||
y: findMesh[0].position[1],
|
x: findMesh[0].position[0],
|
||||||
z: findMesh[0].position[2],
|
y: findMesh[0].position[1],
|
||||||
},
|
z: findMesh[0].position[2],
|
||||||
{
|
},
|
||||||
x: findMesh[0].points.actions.start.x,
|
{
|
||||||
y: 0,
|
x: findMesh[0].points.actions.start.x,
|
||||||
z: findMesh[0].points.actions.start.y,
|
y: 0,
|
||||||
},
|
z: findMesh[0].points.actions.start.y,
|
||||||
{
|
},
|
||||||
x: findMesh[0].points.actions.end.x,
|
{
|
||||||
y: 0,
|
x: findMesh[0].points.actions.end.x,
|
||||||
z: findMesh[0].points.actions.end.y,
|
y: 0,
|
||||||
},
|
z: findMesh[0].points.actions.end.y,
|
||||||
],
|
},
|
||||||
},
|
],
|
||||||
]
|
},
|
||||||
|
]
|
||||||
: [];
|
: [];
|
||||||
if (result.length > 0) {
|
if (result.length > 0) {
|
||||||
// setPathPoints((prev) => [...prev, ...result]);
|
// setPathPoints((prev) => [...prev, ...result]);
|
||||||
@@ -119,6 +122,7 @@ const Agv = ({
|
|||||||
key={i}
|
key={i}
|
||||||
speed={pair.modelSpeed}
|
speed={pair.modelSpeed}
|
||||||
bufferTime={pair.bufferTime}
|
bufferTime={pair.bufferTime}
|
||||||
|
hitCount={pair.hitCount}
|
||||||
/>
|
/>
|
||||||
{/* {pair.points.length > 2 && (
|
{/* {pair.points.length > 2 && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ export default function NavMeshDetails({
|
|||||||
const cellSize = 0.35;
|
const cellSize = 0.35;
|
||||||
const cellHeight = 0.7;
|
const cellHeight = 0.7;
|
||||||
const walkableRadius = 0.5;
|
const walkableRadius = 0.5;
|
||||||
|
|
||||||
const { success, navMesh } = generateSoloNavMesh(positions, indices, {
|
const { success, navMesh } = generateSoloNavMesh(positions, indices, {
|
||||||
cs: cellSize,
|
cs: cellSize,
|
||||||
ch: cellHeight,
|
ch: cellHeight,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ interface PathNavigatorProps {
|
|||||||
id: string;
|
id: string;
|
||||||
speed: number;
|
speed: number;
|
||||||
bufferTime: number;
|
bufferTime: number;
|
||||||
|
hitCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PathNavigator({
|
export default function PathNavigator({
|
||||||
@@ -20,6 +21,7 @@ export default function PathNavigator({
|
|||||||
id,
|
id,
|
||||||
speed,
|
speed,
|
||||||
bufferTime,
|
bufferTime,
|
||||||
|
hitCount,
|
||||||
}: PathNavigatorProps) {
|
}: PathNavigatorProps) {
|
||||||
const [path, setPath] = useState<[number, number, number][]>([]);
|
const [path, setPath] = useState<[number, number, number][]>([]);
|
||||||
const progressRef = useRef(0);
|
const progressRef = useRef(0);
|
||||||
@@ -32,7 +34,7 @@ export default function PathNavigator({
|
|||||||
const [startPoint, setStartPoint] = useState(new THREE.Vector3());
|
const [startPoint, setStartPoint] = useState(new THREE.Vector3());
|
||||||
const isWaiting = useRef<boolean>(false); // Flag to track waiting state
|
const isWaiting = useRef<boolean>(false); // Flag to track waiting state
|
||||||
const delayTime = bufferTime;
|
const delayTime = bufferTime;
|
||||||
|
|
||||||
const movingForward = useRef<boolean>(true); // Tracks whether the object is moving forward
|
const movingForward = useRef<boolean>(true); // Tracks whether the object is moving forward
|
||||||
// Compute distances and total distance when the path changes
|
// Compute distances and total distance when the path changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -52,6 +54,7 @@ export default function PathNavigator({
|
|||||||
progressRef.current = 0;
|
progressRef.current = 0;
|
||||||
}, [path]);
|
}, [path]);
|
||||||
|
|
||||||
|
// Compute the path using NavMeshQuery
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!navMesh || selectedPoints.length === 0) return;
|
if (!navMesh || selectedPoints.length === 0) return;
|
||||||
|
|
||||||
@@ -119,17 +122,22 @@ export default function PathNavigator({
|
|||||||
if (!isWaiting.current) {
|
if (!isWaiting.current) {
|
||||||
isWaiting.current = true; // Set waiting flag
|
isWaiting.current = true; // Set waiting flag
|
||||||
|
|
||||||
setTimeout(() => {
|
if (movingForward.current) {
|
||||||
progressRef.current = 0; // Reset progress
|
// Moving forward: reached the end, wait for `delay`
|
||||||
movingForward.current = !movingForward.current; // Toggle direction
|
// console.log(
|
||||||
|
// "Reached end position. Waiting for delay:",
|
||||||
// Reverse the path and distances arrays
|
// delayTime,
|
||||||
path.reverse();
|
// "seconds"
|
||||||
distancesRef.current.reverse();
|
// );
|
||||||
|
setTimeout(() => {
|
||||||
// Reset the waiting flag
|
// After delay, reverse direction
|
||||||
isWaiting.current = false;
|
movingForward.current = false;
|
||||||
}, delayTime * 1000); // Convert seconds to milliseconds
|
progressRef.current = 0; // Reset progress
|
||||||
|
path.reverse(); // Reverse the path
|
||||||
|
distancesRef.current.reverse();
|
||||||
|
isWaiting.current = false; // Reset waiting flag
|
||||||
|
}, delayTime * 1000); // Wait for `delay` seconds
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -154,7 +162,7 @@ export default function PathNavigator({
|
|||||||
findObject.position.copy(startPoint);
|
findObject.position.copy(startPoint);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{path.length > 0 && (
|
{path.length > 0 && (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
let BackEnd_url = `http://${process.env.REACT_APP_SERVER_ASSET_LIBRARY_URL}`;
|
let BackEnd_url = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
|
||||||
export const getCategoryAsset = async (categoryName: any) => {
|
export const getCategoryAsset = async (categoryName: any) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
|
|||||||
Reference in New Issue
Block a user