Merge remote-tracking branch 'origin/simulation-agv-v2' into v2
This commit is contained in:
@@ -1,14 +1,56 @@
|
||||
import React from 'react'
|
||||
import React, { useEffect } from 'react'
|
||||
import VehicleAnimator from '../animator/vehicleAnimator'
|
||||
import { NavMeshQuery } from '@recast-navigation/core';
|
||||
|
||||
function VehicleInstance() {
|
||||
return (
|
||||
<>
|
||||
|
||||
<VehicleAnimator />
|
||||
useEffect(() => {
|
||||
try {
|
||||
const navMeshQuery = new NavMeshQuery(navMesh);
|
||||
const { path: segmentPath } = navMeshQuery.computePath(start, end);
|
||||
return (
|
||||
segmentPath?.map(
|
||||
({ x, y, z }) => [x, y + 0.1, z] as [number, number, number]
|
||||
) || []
|
||||
);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}, [navMesh]);
|
||||
|
||||
</>
|
||||
)
|
||||
useEffect(() => {
|
||||
// const pickupToDropPath = computePath(pickup, drop);
|
||||
// const dropToPickupPath = computePath(drop, pickup);
|
||||
|
||||
if (isPlaying) {
|
||||
if (!agvDetails.isActive && agvDetails.state == "idle" && currentPhase == "stationed") {
|
||||
const toPickupPath = computePath(new THREE.Vector3(agvDetails.position[0], agvDetails.position[1], agvDetails.position[2]), agvDetails.point.action.pickUpPoint);
|
||||
setPath(toPickupPath)
|
||||
setVehicleActive(agvDetails.modelUuid, true)
|
||||
setVehicleState(agvDetails.modelUuid, "running")
|
||||
setCurrentPhase("stationed-pickup")
|
||||
//
|
||||
}
|
||||
}
|
||||
}, [agvDetails, currentPhase, path, isPlaying])
|
||||
|
||||
function handleCallBack() {
|
||||
if (currentPhase === "stationed-pickup") {
|
||||
setVehicleActive(agvDetails.modelUuid, false)
|
||||
setVehicleState(agvDetails.modelUuid, "idle")
|
||||
setCurrentPhase("picking")
|
||||
setPath([])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
<VehicleAnimator path={path} handleCallBack={handleCallBack} currentPhase={currentPhase} agvUuid={agvDetails?.modelUuid} />
|
||||
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default VehicleInstance
|
||||
Reference in New Issue
Block a user