updated navmesh invisible state
This commit is contained in:
@@ -12,11 +12,9 @@ interface RawNavMesh {
|
|||||||
interface NavMesh {
|
interface NavMesh {
|
||||||
raw: RawNavMesh;
|
raw: RawNavMesh;
|
||||||
}
|
}
|
||||||
// interface LineProps{
|
export default function Agv({ lines, plane }: any) {
|
||||||
// lines
|
console.log("planes: ", plane);
|
||||||
// planes:
|
console.log("lines: ", lines);
|
||||||
// }
|
|
||||||
export default function Agv({ }) {
|
|
||||||
const { scene } = useThree();
|
const { scene } = useThree();
|
||||||
const groupRef = useRef<THREE.Group | null>(null);
|
const groupRef = useRef<THREE.Group | null>(null);
|
||||||
const [navMesh, setNavMesh] = useState<RecastNavMesh | null>(null);
|
const [navMesh, setNavMesh] = useState<RecastNavMesh | null>(null);
|
||||||
@@ -1567,7 +1565,12 @@ export default function Agv({ }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PolygonGenerator groupRef={groupRef} processPoint={processPoint} />
|
<PolygonGenerator
|
||||||
|
groupRef={groupRef}
|
||||||
|
processPoint={processPoint}
|
||||||
|
lines={lines}
|
||||||
|
plane={plane}
|
||||||
|
/>
|
||||||
<NavMeshDetails setNavMesh={setNavMesh} />
|
<NavMeshDetails setNavMesh={setNavMesh} />
|
||||||
{pathPoints.map((pair, i) => (
|
{pathPoints.map((pair, i) => (
|
||||||
<PathNavigator navMesh={navMesh} pathPoints={pair} key={i} />
|
<PathNavigator navMesh={navMesh} pathPoints={pair} key={i} />
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ export default function NavMeshDetails({ setNavMesh }: MeshState) {
|
|||||||
// Draw the debug visualization
|
// Draw the debug visualization
|
||||||
const debugDrawer = new DebugDrawer();
|
const debugDrawer = new DebugDrawer();
|
||||||
debugDrawer.drawNavMesh(navMesh);
|
debugDrawer.drawNavMesh(navMesh);
|
||||||
scene.add(debugDrawer); // Uncomment if you want to add the debug drawer to the scene
|
// scene.add(debugDrawer); // Uncomment if you want to add the debug drawer to the scene
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,26 +17,34 @@ type LineData = {
|
|||||||
type PolygonGeneratorProps = {
|
type PolygonGeneratorProps = {
|
||||||
processPoint: LineData[];
|
processPoint: LineData[];
|
||||||
groupRef: React.RefObject<THREE.Group>;
|
groupRef: React.RefObject<THREE.Group>;
|
||||||
|
lines: any;
|
||||||
|
plane: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function PolygonGenerator({
|
export default function PolygonGenerator({
|
||||||
processPoint,
|
processPoint,
|
||||||
groupRef,
|
groupRef,
|
||||||
|
lines,
|
||||||
|
plane,
|
||||||
}: PolygonGeneratorProps) {
|
}: PolygonGeneratorProps) {
|
||||||
const { scene } = useThree();
|
const { scene } = useThree();
|
||||||
let lines : Types.Lines;
|
console.log(
|
||||||
// console.log("storedFloorItems: ", lines);
|
"lines: ",
|
||||||
|
lines.current.map((val: any) => val)
|
||||||
|
);
|
||||||
|
console.log("planes: ", plane);
|
||||||
|
// console.log("storedFloorItems: ", lines);
|
||||||
|
|
||||||
// useEffect(() => {
|
useEffect(() => {
|
||||||
// if (!groupRef?.current) return;
|
if (!groupRef?.current) return;
|
||||||
// const groundGeometry = new THREE.BoxGeometry(80, 1, 60);
|
// const groundGeometry = new THREE.BoxGeometry(80, 1, 60);
|
||||||
// const groundMaterial = new THREE.MeshBasicMaterial({ color: "#99ff99" });
|
// const groundMaterial = new THREE.MeshBasicMaterial({ color: "#99ff99" });
|
||||||
// const groundMesh = new THREE.Mesh(groundGeometry, groundMaterial);
|
// const groundMesh = new THREE.Mesh(groundGeometry, groundMaterial);
|
||||||
// groundMesh.position.set(-10, -0.5, 3);
|
// groundMesh.position.set(-10, -0.5, 3);
|
||||||
// groundMesh.name = "GroundMesh";
|
// groundMesh.name = "GroundMesh";
|
||||||
// groupRef.current.add(groundMesh);
|
groupRef.current.add(plane);
|
||||||
// scene.add(groupRef.current);
|
scene.add(groupRef.current);
|
||||||
// }, [groupRef, scene]);
|
}, [groupRef, scene]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!processPoint) return;
|
if (!processPoint) return;
|
||||||
@@ -97,7 +105,10 @@ export default function PolygonGenerator({
|
|||||||
const height = 3;
|
const height = 3;
|
||||||
|
|
||||||
const geometry = new THREE.BoxGeometry(width, height, depth);
|
const geometry = new THREE.BoxGeometry(width, height, depth);
|
||||||
const material = new THREE.MeshBasicMaterial({ color: "#ff66cc" });
|
const material = new THREE.MeshBasicMaterial({
|
||||||
|
color: "#ff66cc",
|
||||||
|
visible: false,
|
||||||
|
});
|
||||||
const mesh = new THREE.Mesh(geometry, material);
|
const mesh = new THREE.Mesh(geometry, material);
|
||||||
mesh.position.set((minX + maxX) / 2, height / 2, (minZ + maxZ) / 2);
|
mesh.position.set((minX + maxX) / 2, height / 2, (minZ + maxZ) / 2);
|
||||||
|
|
||||||
|
|||||||
@@ -359,8 +359,7 @@ export default function World() {
|
|||||||
|
|
||||||
<DrieHtmlTemp itemsGroup={itemsGroup} />
|
<DrieHtmlTemp itemsGroup={itemsGroup} />
|
||||||
|
|
||||||
<Agv />
|
<Agv lines={lines} plane={plane} />
|
||||||
{/* <Agv lines={lines} plane={plane} /> */}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user