Merge remote-tracking branch 'origin/v3-agv' into v3
This commit is contained in:
commit
8f0e005200
|
@ -1,7 +1,9 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {
|
import {
|
||||||
useLoadingProgress,
|
useLoadingProgress,
|
||||||
|
useRenameModeStore,
|
||||||
useSaveVersion,
|
useSaveVersion,
|
||||||
|
useSelectedFloorItem,
|
||||||
useSocketStore,
|
useSocketStore,
|
||||||
useWidgetSubOption,
|
useWidgetSubOption,
|
||||||
} from "../../../store/builder/store";
|
} from "../../../store/builder/store";
|
||||||
|
@ -30,6 +32,10 @@ import {
|
||||||
import { useProductContext } from "../../../modules/simulation/products/productContext";
|
import { useProductContext } from "../../../modules/simulation/products/productContext";
|
||||||
import { useProductStore } from "../../../store/simulation/useProductStore";
|
import { useProductStore } from "../../../store/simulation/useProductStore";
|
||||||
import RegularDropDown from "../../ui/inputs/RegularDropDown";
|
import RegularDropDown from "../../ui/inputs/RegularDropDown";
|
||||||
|
import RenameTooltip from "../../ui/features/RenameTooltip";
|
||||||
|
import { setFloorItemApi } from "../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi";
|
||||||
|
import { useAssetsStore } from "../../../store/builder/useAssetStore";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
function MainScene() {
|
function MainScene() {
|
||||||
const { products } = useProductStore();
|
const { products } = useProductStore();
|
||||||
|
@ -47,13 +53,33 @@ function MainScene() {
|
||||||
const { selectedZone } = useSelectedZoneStore();
|
const { selectedZone } = useSelectedZoneStore();
|
||||||
const { setFloatingWidget } = useFloatingWidget();
|
const { setFloatingWidget } = useFloatingWidget();
|
||||||
const { comparisonProduct } = useComparisonProduct();
|
const { comparisonProduct } = useComparisonProduct();
|
||||||
|
const { selectedFloorItem, setSelectedFloorItem } = useSelectedFloorItem();
|
||||||
|
const { setName } = useAssetsStore();
|
||||||
|
const { projectId } = useParams()
|
||||||
|
const { isRenameMode, setIsRenameMode } = useRenameModeStore();
|
||||||
const handleSelectLayout = (option: string) => {
|
const handleSelectLayout = (option: string) => {
|
||||||
const product = products.find((product) => product.productName === option);
|
const product = products.find((product) => product.productName === option);
|
||||||
if (product) {
|
if (product) {
|
||||||
setMainProduct(product.productUuid, product.productName);
|
setMainProduct(product.productUuid, product.productName);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const handleObjectRename = async (newName: string) => {
|
||||||
|
const email = localStorage.getItem("email") ?? "";
|
||||||
|
const organization = email?.split("@")[1]?.split(".")[0];
|
||||||
|
let response = await setFloorItemApi(
|
||||||
|
organization,
|
||||||
|
selectedFloorItem.userData.modelUuid,
|
||||||
|
newName,
|
||||||
|
projectId
|
||||||
|
);
|
||||||
|
selectedFloorItem.userData = {
|
||||||
|
...selectedFloorItem.userData,
|
||||||
|
modelName: newName
|
||||||
|
};
|
||||||
|
setSelectedFloorItem(selectedFloorItem);
|
||||||
|
setIsRenameMode(false);
|
||||||
|
setName(selectedFloorItem.userData.modelUuid, response.modelName);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -79,6 +105,7 @@ function MainScene() {
|
||||||
{(isPlaying || comparisonProduct !== null) &&
|
{(isPlaying || comparisonProduct !== null) &&
|
||||||
activeModule !== "simulation" && <ControlsPlayer />}
|
activeModule !== "simulation" && <ControlsPlayer />}
|
||||||
|
|
||||||
|
{isRenameMode && selectedFloorItem?.userData.modelName && <RenameTooltip name={selectedFloorItem?.userData.modelName} onSubmit={handleObjectRename} />}
|
||||||
{/* remove this later */}
|
{/* remove this later */}
|
||||||
{activeModule === "builder" && !toggleThreeD && <SelectFloorPlan />}
|
{activeModule === "builder" && !toggleThreeD && <SelectFloorPlan />}
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -122,7 +122,7 @@ const List: React.FC<ListProps> = ({ items = [], remove }) => {
|
||||||
zoneUuid: selectedZone.zoneUuid,
|
zoneUuid: selectedZone.zoneUuid,
|
||||||
zoneName: newName,
|
zoneName: newName,
|
||||||
};
|
};
|
||||||
const response = await zoneCameraUpdate(zonesdata, organization,projectId);
|
const response = await zoneCameraUpdate(zonesdata, organization, projectId);
|
||||||
if (response.message === "zone updated") {
|
if (response.message === "zone updated") {
|
||||||
setSelectedZone((prev) => ({ ...prev, zoneName: newName }));
|
setSelectedZone((prev) => ({ ...prev, zoneName: newName }));
|
||||||
setZones((prevZones: any[]) =>
|
setZones((prevZones: any[]) =>
|
||||||
|
@ -143,9 +143,11 @@ const List: React.FC<ListProps> = ({ items = [], remove }) => {
|
||||||
let response = await setFloorItemApi(
|
let response = await setFloorItemApi(
|
||||||
organization,
|
organization,
|
||||||
zoneAssetId.id,
|
zoneAssetId.id,
|
||||||
newName
|
newName,
|
||||||
|
projectId
|
||||||
);
|
);
|
||||||
// console.log("response: ", response);
|
// console.log("response: ", response);
|
||||||
|
console.log(' zoneAssetId.id,: ', zoneAssetId.id,);
|
||||||
|
|
||||||
setName(zoneAssetId.id, response.modelName);
|
setName(zoneAssetId.id, response.modelName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as THREE from "three"
|
import * as THREE from "three"
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { getFloorAssets } from '../../../services/factoryBuilder/assest/floorAsset/getFloorItemsApi';
|
import { getFloorAssets } from '../../../services/factoryBuilder/assest/floorAsset/getFloorItemsApi';
|
||||||
import { useLoadingProgress, useSelectedFloorItem, useSelectedItem, useSocketStore } from '../../../store/builder/store';
|
import { useLoadingProgress, useRenameModeStore, useSelectedFloorItem, useSelectedItem, useSocketStore } from '../../../store/builder/store';
|
||||||
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
||||||
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader";
|
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader";
|
||||||
import { FloorItems, RefGroup, RefMesh } from "../../../types/world/worldTypes";
|
import { FloorItems, RefGroup, RefMesh } from "../../../types/world/worldTypes";
|
||||||
|
@ -13,6 +13,7 @@ import { useThree } from "@react-three/fiber";
|
||||||
import { CameraControls } from "@react-three/drei";
|
import { CameraControls } from "@react-three/drei";
|
||||||
import addAssetModel from "./functions/addAssetModel";
|
import addAssetModel from "./functions/addAssetModel";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
import { useLeftData, useTopData } from "../../../store/visualization/useZone3DWidgetStore";
|
||||||
|
|
||||||
const gltfLoaderWorker = new Worker(
|
const gltfLoaderWorker = new Worker(
|
||||||
new URL(
|
new URL(
|
||||||
|
@ -31,9 +32,12 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
||||||
const { setSelectedFloorItem } = useSelectedFloorItem();
|
const { setSelectedFloorItem } = useSelectedFloorItem();
|
||||||
const { selectedItem, setSelectedItem } = useSelectedItem();
|
const { selectedItem, setSelectedItem } = useSelectedItem();
|
||||||
const { projectId } = useParams();
|
const { projectId } = useParams();
|
||||||
|
const { isRenameMode, setIsRenameMode } = useRenameModeStore();
|
||||||
const email = localStorage.getItem("email");
|
const email = localStorage.getItem("email");
|
||||||
const organization = email!.split("@")[1].split(".")[0];
|
const organization = email!.split("@")[1].split(".")[0];
|
||||||
const userId = localStorage.getItem("userId")!;
|
const userId = localStorage.getItem("userId")!;
|
||||||
|
const { setTop } = useTopData();
|
||||||
|
const { setLeft } = useLeftData();
|
||||||
|
|
||||||
const loader = new GLTFLoader();
|
const loader = new GLTFLoader();
|
||||||
const dracoLoader = new DRACOLoader();
|
const dracoLoader = new DRACOLoader();
|
||||||
|
@ -257,6 +261,7 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const canvasElement = gl.domElement;
|
const canvasElement = gl.domElement;
|
||||||
|
|
||||||
const onDrop = (event: any) => {
|
const onDrop = (event: any) => {
|
||||||
if (!event.dataTransfer?.files[0]) return;
|
if (!event.dataTransfer?.files[0]) return;
|
||||||
|
|
||||||
|
@ -272,11 +277,28 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
||||||
const onDragOver = (event: any) => {
|
const onDragOver = (event: any) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
};
|
};
|
||||||
|
const onMouseMove = (evt: any) => {
|
||||||
|
if (!canvasElement) return;
|
||||||
|
const canvasRect = canvasElement.getBoundingClientRect();
|
||||||
|
const relativeX = evt.clientX - canvasRect.left;
|
||||||
|
const relativeY = evt.clientY - canvasRect.top;
|
||||||
|
if (!isRenameMode) {
|
||||||
|
setTop(relativeY);
|
||||||
|
setLeft(relativeX);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
const onMouseUp = (evt: any) => {
|
||||||
|
setIsRenameMode(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (activeModule === "builder") {
|
if (activeModule === "builder") {
|
||||||
canvasElement.addEventListener("drop", onDrop);
|
canvasElement.addEventListener("drop", onDrop);
|
||||||
canvasElement.addEventListener("dragover", onDragOver);
|
canvasElement.addEventListener("dragover", onDragOver);
|
||||||
|
canvasElement.addEventListener("mousemove", onMouseMove);
|
||||||
|
canvasElement.addEventListener("mouseup", onMouseUp);
|
||||||
} else {
|
} else {
|
||||||
if ((controls as CameraControls)) {
|
if ((controls as CameraControls)) {
|
||||||
const target = (controls as CameraControls).getTarget(new THREE.Vector3());
|
const target = (controls as CameraControls).getTarget(new THREE.Vector3());
|
||||||
|
@ -288,8 +310,10 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
||||||
return () => {
|
return () => {
|
||||||
canvasElement.removeEventListener("drop", onDrop);
|
canvasElement.removeEventListener("drop", onDrop);
|
||||||
canvasElement.removeEventListener("dragover", onDragOver);
|
canvasElement.removeEventListener("dragover", onDragOver);
|
||||||
|
canvasElement.removeEventListener("mousemove", onMouseMove);
|
||||||
|
canvasElement.removeEventListener("mouseup", onMouseUp);
|
||||||
};
|
};
|
||||||
}, [selectedItem, camera, pointer, activeModule, controls]);
|
}, [selectedItem, camera, pointer, activeModule, controls, isRenameMode]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Models />
|
<Models />
|
||||||
|
|
|
@ -87,10 +87,10 @@ const FloorGroup = ({
|
||||||
const canvasRect = canvasElement.getBoundingClientRect();
|
const canvasRect = canvasElement.getBoundingClientRect();
|
||||||
const relativeX = evt.clientX - canvasRect.left;
|
const relativeX = evt.clientX - canvasRect.left;
|
||||||
const relativeY = evt.clientY - canvasRect.top;
|
const relativeY = evt.clientY - canvasRect.top;
|
||||||
if (!isRenameMode) {
|
// if (!isRenameMode) {
|
||||||
setTop(relativeY);
|
// setTop(relativeY);
|
||||||
setLeft(relativeX);
|
// setLeft(relativeX);
|
||||||
}
|
// }
|
||||||
if (isLeftMouseDown) {
|
if (isLeftMouseDown) {
|
||||||
drag = true;
|
drag = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,14 +48,24 @@ function VehicleInstance({ agvDetail }: Readonly<{ agvDetail: VehicleStatus }>)
|
||||||
|
|
||||||
const computePath = useCallback(
|
const computePath = useCallback(
|
||||||
(start: any, end: any) => {
|
(start: any, end: any) => {
|
||||||
|
console.log('end: ', end);
|
||||||
try {
|
try {
|
||||||
const navMeshQuery = new NavMeshQuery(navMesh);
|
const navMeshQuery = new NavMeshQuery(navMesh);
|
||||||
const { path: segmentPath } = navMeshQuery.computePath(start, end);
|
const { path: segmentPath } = navMeshQuery.computePath(start, end);
|
||||||
return (
|
if (
|
||||||
segmentPath?.map(({ x, y, z }) => [x, 0, z] as [number, number, number]) || []
|
segmentPath.length > 0 &&
|
||||||
);
|
Math.round(segmentPath[segmentPath.length - 1].x) == Math.round(end.x) &&
|
||||||
|
Math.round(segmentPath[segmentPath.length - 1].z) == Math.round(end.z)
|
||||||
|
) {
|
||||||
|
console.log('if ', segmentPath);
|
||||||
|
return segmentPath?.map(({ x, y, z }) => [x, 0, z] as [number, number, number]) || [];
|
||||||
|
} else {
|
||||||
|
console.log("There is no path here...Choose valid path")
|
||||||
|
const { path: segmentPaths } = navMeshQuery.computePath(start, start);
|
||||||
|
return segmentPaths.map(({ x, y, z }) => [x, 0, z] as [number, number, number]) || [];
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
echo.error("Failed to compute path");
|
console.error("Failed to compute path");
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -96,6 +106,10 @@ function VehicleInstance({ agvDetail }: Readonly<{ agvDetail: VehicleStatus }>)
|
||||||
new THREE.Vector3(agvDetail?.position[0], agvDetail?.position[1], agvDetail?.position[2]),
|
new THREE.Vector3(agvDetail?.position[0], agvDetail?.position[1], agvDetail?.position[2]),
|
||||||
agvDetail?.point?.action?.pickUpPoint?.position
|
agvDetail?.point?.action?.pickUpPoint?.position
|
||||||
);
|
);
|
||||||
|
// const toPickupPath = computePath(
|
||||||
|
// new THREE.Vector3(agvDetail?.position[0], agvDetail?.position[1], agvDetail?.position[2]),
|
||||||
|
// new THREE.Vector3(agvDetail?.position[0], agvDetail?.position[1], agvDetail?.position[2])
|
||||||
|
// );
|
||||||
setPath(toPickupPath);
|
setPath(toPickupPath);
|
||||||
setCurrentPhase('stationed-pickup');
|
setCurrentPhase('stationed-pickup');
|
||||||
setVehicleState(agvDetail.modelUuid, 'running');
|
setVehicleState(agvDetail.modelUuid, 'running');
|
||||||
|
|
|
@ -61,14 +61,13 @@ const UserAuth: React.FC = () => {
|
||||||
const projects = await recentlyViewed(organization, res.message.userId);
|
const projects = await recentlyViewed(organization, res.message.userId);
|
||||||
console.log('projects: ', projects);
|
console.log('projects: ', projects);
|
||||||
|
|
||||||
if (Object.values(projects.RecentlyViewed).length > 0) {
|
if (res.message.isShare) {
|
||||||
const firstId = (Object.values(projects?.RecentlyViewed || {})[0] as any)?._id;
|
if (Object.values(projects.RecentlyViewed).length > 0) {
|
||||||
setLoadingProgress(1)
|
const firstId = (Object.values(projects?.RecentlyViewed || {})[0] as any)?._id;
|
||||||
navigate(`/${firstId}`)
|
setLoadingProgress(1)
|
||||||
} else {
|
navigate(`/${firstId}`)
|
||||||
if (res.message.isShare) {
|
} else {
|
||||||
setLoadingProgress(1);
|
setLoadingProgress(1);
|
||||||
// navigate("/Project");
|
|
||||||
navigate("/Dashboard");
|
navigate("/Dashboard");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ export const setFloorItemApi = async (
|
||||||
modelUuid?: string,
|
modelUuid?: string,
|
||||||
modelName?: string,
|
modelName?: string,
|
||||||
assetId?: string,
|
assetId?: string,
|
||||||
|
projectId?: string,
|
||||||
position?: Object,
|
position?: Object,
|
||||||
rotation?: Object,
|
rotation?: Object,
|
||||||
isLocked?: boolean,
|
isLocked?: boolean,
|
||||||
|
@ -14,6 +15,7 @@ export const setFloorItemApi = async (
|
||||||
organization,
|
organization,
|
||||||
modelUuid,
|
modelUuid,
|
||||||
modelName,
|
modelName,
|
||||||
|
projectId,
|
||||||
position,
|
position,
|
||||||
rotation,
|
rotation,
|
||||||
assetId,
|
assetId,
|
||||||
|
|
Loading…
Reference in New Issue