Refactor zone visualization components: clean up unused code and improve readability in ZoneAssets and ZoneCentreTarget.

This commit is contained in:
Jerald-Golden-B 2025-05-08 15:15:38 +05:30
parent 7000a5942f
commit 962215d574
6 changed files with 40 additions and 36 deletions

View File

@ -549,7 +549,7 @@ const ZoneGroup: React.FC = () => {
const midpoint = new THREE.Vector3(
(point1.x + point2.x) / 2,
CONSTANTS.zoneConfig.height / 2 +
(zone.layer - 1) * CONSTANTS.zoneConfig.height,
(zone.layer - 1) * CONSTANTS.zoneConfig.height,
(point1.z + point2.z) / 2
);

View File

@ -25,7 +25,6 @@ export function useTravelHandler() {
if (!modelUuid) return;
incrementVehicleLoad(modelUuid, 1);
console.log('material: ', material);
addCurrentMaterial(modelUuid, material.materialType, material.materialId);
travelLogStatus(material.materialId, `is triggering travel from ${modelUuid}`);

View File

@ -85,37 +85,10 @@ function MaterialInstance({ material }: { material: MaterialSchema }) {
const callTrigger = () => {
if (!material.next) return;
const fromModel = getEventByModelUuid(selectedProduct.productId, material.next.modelUuid);
if (!fromModel) return;
const fromPoint = getPointByUuid(selectedProduct.productId, fromModel.modelUuid, material.next.pointUuid);
if (!fromPoint) return;
if (fromModel.type === 'transfer') {
const toModel = getEventByModelUuid(selectedProduct.productId, material.next.modelUuid);
if (!toModel) return;
if (toModel.type === 'transfer') {
const action = getActionByPointUuid(selectedProduct.productId, material.next.pointUuid);
if (action) {
triggerPointActions(action, material.materialId);
}
} else if (toModel?.type === 'vehicle') {
// Transfer to Vehicle
} else if (toModel?.type === 'machine') {
// Transfer to Machine
} else if (toModel?.type === 'roboticArm') {
// Transfer to Robotic Arm
} else if (toModel?.type === 'storageUnit') {
// Transfer to Storage Unit
}
} else if (fromModel.type === 'vehicle') {
} else if (fromModel.type === 'machine') {
} else if (fromModel.type === 'roboticArm') {
} else if (fromModel.type === 'storageUnit') {
const action = getActionByPointUuid(selectedProduct.productId, material.next.pointUuid);
if (action) {
triggerPointActions(action, material.materialId);
}
}
return (

View File

@ -199,6 +199,41 @@ export function useTriggerHandler() {
} else if (toEvent?.type === 'vehicle') {
// Robotic Arm to Vehicle
if (trigger.triggeredAsset && trigger.triggeredAsset.triggeredPoint && trigger.triggeredAsset.triggeredAction) {
const material = getMaterialById(materialId);
if (material) {
const action = getActionByUuid(selectedProduct.productId, trigger.triggeredAsset.triggeredAction.actionUuid);
const vehicle = getVehicleById(trigger.triggeredAsset?.triggeredModel.modelUuid);
setCurrentLocation(material.materialId, {
modelUuid: trigger.triggeredAsset.triggeredModel.modelUuid,
pointUuid: trigger.triggeredAsset.triggeredPoint.pointUuid,
actionUuid: trigger.triggeredAsset?.triggeredAction?.actionUuid,
});
setNextLocation(material.materialId, null);
if (action) {
if (vehicle) {
if (vehicle.isActive === false && vehicle.state === 'idle' && vehicle.currentLoad < vehicle.point.action.loadCapacity) {
setIsVisible(materialId, false);
// Handle current action from vehicle
handleAction(action, materialId);
} else {
// Event Manager Needed
}
}
}
}
}
} else if (toEvent?.type === 'machine') {
// Robotic Arm to Machine

View File

@ -7,6 +7,7 @@ export default function ZoneAssets() {
const { zoneAssetId, setZoneAssetId } = useZoneAssetId();
const { setSelectedFloorItem } = useSelectedFloorItem();
const { raycaster, controls, scene }: any = useThree();
useEffect(() => {
// console.log('zoneAssetId: ', zoneAssetId);
if (!zoneAssetId) return
@ -70,8 +71,6 @@ export default function ZoneAssets() {
}
}, [zoneAssetId, scene, controls])
return (
<>
</>

View File

@ -13,8 +13,6 @@ export default function ZoneCentreTarget() {
const { zoneTarget, setZoneTarget } = usezoneTarget();
const { Edit, setEdit } = useEditPosition();
useEffect(() => {
if (
selectedZone.zoneViewPortTarget &&