Refactor model identifier naming conventions from 'modeluuid' and 'modelname' to 'modelUuid' and 'modelName' across multiple modules for consistency and clarity. Update related API calls and local storage handling to reflect these changes. Remove unused deleteProductDataApi service and implement deleteProductApi service for product data deletion. Introduce steeringAngle property in vehicle configurations.

This commit is contained in:
2025-04-30 11:46:20 +05:30
parent 882c81a385
commit 014bc3a7ca
31 changed files with 203 additions and 161 deletions

View File

@@ -72,7 +72,7 @@ async function loadInitialFloorItems(
// Check Three.js Cache
const cachedModel = THREE.Cache.get(item.modelfileID!);
if (cachedModel) {
// console.log(`[Cache] Fetching ${item.modelname}`);
// console.log(`[Cache] Fetching ${item.modelName}`);
processLoadedModel(cachedModel.scene.clone(), item, itemsGroup, setFloorItems, addEvent);
modelsLoaded++;
checkLoadingCompletion(modelsLoaded, modelsToLoad, dracoLoader, resolve);
@@ -82,7 +82,7 @@ async function loadInitialFloorItems(
// Check IndexedDB
const indexedDBModel = await retrieveGLTF(item.modelfileID!);
if (indexedDBModel) {
// console.log(`[IndexedDB] Fetching ${item.modelname}`);
// console.log(`[IndexedDB] Fetching ${item.modelName}`);
const blobUrl = URL.createObjectURL(indexedDBModel);
loader.load(blobUrl, (gltf) => {
URL.revokeObjectURL(blobUrl);
@@ -94,7 +94,7 @@ async function loadInitialFloorItems(
},
undefined,
(error) => {
toast.error(`[IndexedDB] Error loading ${item.modelname}:`);
toast.error(`[IndexedDB] Error loading ${item.modelName}:`);
URL.revokeObjectURL(blobUrl);
resolve();
}
@@ -103,7 +103,7 @@ async function loadInitialFloorItems(
}
// Fetch from Backend
// console.log(`[Backend] Fetching ${item.modelname}`);
// console.log(`[Backend] Fetching ${item.modelName}`);
const modelUrl = `${url_Backend_dwinzo}/api/v2/AssetFile/${item.modelfileID!}`;
loader.load(modelUrl, async (gltf) => {
const modelBlob = await fetch(modelUrl).then((res) => res.blob());
@@ -115,18 +115,18 @@ async function loadInitialFloorItems(
},
undefined,
(error) => {
toast.error(`[Backend] Error loading ${item.modelname}:`);
toast.error(`[Backend] Error loading ${item.modelName}:`);
resolve();
}
);
});
} else {
// console.log(`Item ${item.modelname} is not near`);
// console.log(`Item ${item.modelName} is not near`);
setFloorItems((prevItems) => [
...(prevItems || []),
{
modeluuid: item.modeluuid,
modelname: item.modelname,
modelUuid: item.modelUuid,
modelName: item.modelName,
position: item.position,
rotation: item.rotation,
modelfileID: item.modelfileID,
@@ -154,9 +154,9 @@ function processLoadedModel(
addEvent: (event: EventsSchema) => void,
) {
const model = gltf.clone();
model.uuid = item.modeluuid;
model.uuid = item.modelUuid;
model.scale.set(...CONSTANTS.assetConfig.defaultScaleBeforeGsap);
model.userData = { name: item.modelname, modelId: item.modelfileID, modeluuid: item.modeluuid, eventData: item.eventData };
model.userData = { name: item.modelName, modelId: item.modelfileID, modelUuid: item.modelUuid, eventData: item.eventData };
model.position.set(...item.position);
model.rotation.set(item.rotation.x, item.rotation.y, item.rotation.z);
@@ -176,8 +176,8 @@ function processLoadedModel(
setFloorItems((prevItems) => [
...(prevItems || []),
{
modeluuid: item.modeluuid,
modelname: item.modelname,
modelUuid: item.modelUuid,
modelName: item.modelName,
position: item.position,
rotation: item.rotation,
modelfileID: item.modelfileID,
@@ -189,8 +189,8 @@ function processLoadedModel(
if (item.eventData.type === "vehicle") {
const vehicleEvent: VehicleEventSchema = {
modelUuid: item.modeluuid,
modelName: item.modelname,
modelUuid: item.modelUuid,
modelName: item.modelName,
position: item.position,
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
state: "idle",
@@ -206,6 +206,7 @@ function processLoadedModel(
actionType: "travel",
unLoadDuration: 5,
loadCapacity: 10,
steeringAngle:0,
pickUpPoint: null,
unLoadPoint: null,
triggers: []
@@ -215,8 +216,8 @@ function processLoadedModel(
addEvent(vehicleEvent);
} else if (item.eventData.type === "Conveyor") {
const ConveyorEvent: ConveyorEventSchema = {
modelUuid: item.modeluuid,
modelName: item.modelname,
modelUuid: item.modelUuid,
modelName: item.modelName,
position: item.position,
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
state: "idle",
@@ -241,8 +242,8 @@ function processLoadedModel(
addEvent(ConveyorEvent);
} else if (item.eventData.type === "StaticMachine") {
const machineEvent: MachineEventSchema = {
modelUuid: item.modeluuid,
modelName: item.modelname,
modelUuid: item.modelUuid,
modelName: item.modelName,
position: item.position,
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
state: "idle",
@@ -264,8 +265,8 @@ function processLoadedModel(
addEvent(machineEvent);
} else if (item.eventData.type === "ArmBot") {
const roboticArmEvent: RoboticArmEventSchema = {
modelUuid: item.modeluuid,
modelName: item.modelname,
modelUuid: item.modelUuid,
modelName: item.modelName,
position: item.position,
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
state: "idle",
@@ -296,8 +297,8 @@ function processLoadedModel(
setFloorItems((prevItems) => [
...(prevItems || []),
{
modeluuid: item.modeluuid,
modelname: item.modelname,
modelUuid: item.modelUuid,
modelName: item.modelName,
position: item.position,
rotation: item.rotation,
modelfileID: item.modelfileID,

View File

@@ -22,9 +22,9 @@ async function loadInitialWallItems(
const loadedWallItems = await Promise.all(storedWallItems.map(async (item) => {
const loader = new GLTFLoader();
return new Promise<Types.WallItem>((resolve) => {
loader.load(AssetConfigurations[item.modelname!].modelUrl, (gltf) => {
loader.load(AssetConfigurations[item.modelName!].modelUrl, (gltf) => {
const model = gltf.scene;
model.uuid = item.modeluuid!;
model.uuid = item.modelUuid!;
model.children[0].children.forEach((child: any) => {
if (child.name !== "CSG_REF") {
@@ -36,7 +36,7 @@ async function loadInitialWallItems(
resolve({
type: item.type,
model: model,
modelname: item.modelname,
modelName: item.modelName,
scale: item.scale,
csgscale: item.csgscale,
csgposition: item.csgposition,

View File

@@ -117,7 +117,7 @@ async function handleModelLoad(
socket: Socket<any>
) {
const model = gltf.scene.clone();
model.userData = { name: selectedItem.name, modelId: selectedItem.id, modeluuid: model.uuid };
model.userData = { name: selectedItem.name, modelId: selectedItem.id, modelUuid: model.uuid };
model.position.set(intersectPoint!.x, 3 + intersectPoint!.y, intersectPoint!.z);
model.scale.set(...CONSTANTS.assetConfig.defaultScaleBeforeGsap);
@@ -137,8 +137,8 @@ async function handleModelLoad(
}
const newFloorItem: Types.FloorItemType = {
modeluuid: model.uuid,
modelname: selectedItem.name,
modelUuid: model.uuid,
modelName: selectedItem.name,
modelfileID: selectedItem.id,
position: [intersectPoint!.x, intersectPoint!.y, intersectPoint!.z],
rotation: { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
@@ -153,8 +153,8 @@ async function handleModelLoad(
// await setFloorItemApi(
// organization,
// newFloorItem.modeluuid,
// newFloorItem.modelname,
// newFloorItem.modelUuid,
// newFloorItem.modelName,
// newFloorItem.modelfileID,
// newFloorItem.position,
// { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
@@ -179,8 +179,8 @@ async function handleModelLoad(
if (selectedItem.type === "Conveyor") {
const ConveyorEvent: ConveyorEventSchema = {
modelUuid: newFloorItem.modeluuid,
modelName: newFloorItem.modelname,
modelUuid: newFloorItem.modelUuid,
modelName: newFloorItem.modelName,
position: newFloorItem.position,
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
state: "idle",
@@ -211,8 +211,8 @@ async function handleModelLoad(
} else if (selectedItem.type === "Vehicle") {
const vehicleEvent: VehicleEventSchema = {
modelUuid: newFloorItem.modeluuid,
modelName: newFloorItem.modelname,
modelUuid: newFloorItem.modelUuid,
modelName: newFloorItem.modelName,
position: newFloorItem.position,
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
state: "idle",
@@ -228,6 +228,7 @@ async function handleModelLoad(
actionType: "travel",
unLoadDuration: 5,
loadCapacity: 10,
steeringAngle:0,
pickUpPoint: null,
unLoadPoint: null,
triggers: []
@@ -243,8 +244,8 @@ async function handleModelLoad(
} else if (selectedItem.type === "ArmBot") {
const roboticArmEvent: RoboticArmEventSchema = {
modelUuid: newFloorItem.modeluuid,
modelName: newFloorItem.modelname,
modelUuid: newFloorItem.modelUuid,
modelName: newFloorItem.modelName,
position: newFloorItem.position,
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
state: "idle",
@@ -278,8 +279,8 @@ async function handleModelLoad(
} else if (selectedItem.type === "StaticMachine") {
const machineEvent: MachineEventSchema = {
modelUuid: newFloorItem.modeluuid,
modelName: newFloorItem.modelname,
modelUuid: newFloorItem.modelUuid,
modelName: newFloorItem.modelName,
position: newFloorItem.position,
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
state: "idle",
@@ -308,8 +309,8 @@ async function handleModelLoad(
const completeData = {
organization,
modeluuid: newFloorItem.modeluuid,
modelname: newFloorItem.modelname,
modelUuid: newFloorItem.modelUuid,
modelName: newFloorItem.modelName,
modelfileID: newFloorItem.modelfileID,
position: newFloorItem.position,
rotation: { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
@@ -337,8 +338,8 @@ async function handleModelLoad(
const data = {
organization,
modeluuid: newFloorItem.modeluuid,
modelname: newFloorItem.modelname,
modelUuid: newFloorItem.modelUuid,
modelName: newFloorItem.modelName,
modelfileID: newFloorItem.modelfileID,
position: newFloorItem.position,
rotation: { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },

View File

@@ -58,7 +58,7 @@ export default async function assetManager(
// Check Three.js Cache
const cachedModel = THREE.Cache.get(item.modelfileID!);
if (cachedModel) {
// console.log(`[Cache] Fetching ${item.modelname}`);
// console.log(`[Cache] Fetching ${item.modelName}`);
processLoadedModel(cachedModel.scene.clone(), item, itemsGroup, resolve);
return;
}
@@ -66,7 +66,7 @@ export default async function assetManager(
// Check IndexedDB
const indexedDBModel = await retrieveGLTF(item.modelfileID!);
if (indexedDBModel) {
// console.log(`[IndexedDB] Fetching ${item.modelname}`);
// console.log(`[IndexedDB] Fetching ${item.modelName}`);
const blobUrl = URL.createObjectURL(indexedDBModel);
loader.load(
blobUrl,
@@ -78,7 +78,7 @@ export default async function assetManager(
},
undefined,
(error) => {
toast.error(`[IndexedDB] Error loading ${item.modelname}:`);
toast.error(`[IndexedDB] Error loading ${item.modelName}:`);
resolve();
}
);
@@ -86,7 +86,7 @@ export default async function assetManager(
}
// Fetch from Backend
// console.log(`[Backend] Fetching ${item.modelname}`);
// console.log(`[Backend] Fetching ${item.modelName}`);
loader.load(
modelUrl,
async (gltf) => {
@@ -97,7 +97,7 @@ export default async function assetManager(
},
undefined,
(error) => {
toast.error(`[Backend] Error loading ${item.modelname}:`);
toast.error(`[Backend] Error loading ${item.modelName}:`);
resolve();
}
);
@@ -112,16 +112,16 @@ export default async function assetManager(
) {
if (!activePromises.get(taskId)) return; // Stop processing if task is canceled
const existingModel = itemsGroup?.current?.getObjectByProperty("uuid", item.modeluuid);
const existingModel = itemsGroup?.current?.getObjectByProperty("uuid", item.modelUuid);
if (existingModel) {
// console.log(`Model ${item.modelname} already exists in the scene.`);
// console.log(`Model ${item.modelName} already exists in the scene.`);
resolve();
return;
}
const model = gltf;
model.uuid = item.modeluuid;
model.userData = { name: item.modelname, modelId: item.modelfileID, modeluuid: item.modeluuid };
model.uuid = item.modelUuid;
model.userData = { name: item.modelName, modelId: item.modelfileID, modelUuid: item.modelUuid };
model.scale.set(...CONSTANTS.assetConfig.defaultScaleBeforeGsap);
model.position.set(...item.position);
model.rotation.set(item.rotation.x, item.rotation.y, item.rotation.z);

View File

@@ -5,6 +5,8 @@ import * as Types from "../../../../types/world/worldTypes";
// import { deleteFloorItem } from '../../../../services/factoryBuilder/assest/floorAsset/deleteFloorItemApi';
import { Socket } from 'socket.io-client';
import { getFloorAssets } from '../../../../services/factoryBuilder/assest/floorAsset/getFloorItemsApi';
import { useEventsStore } from "../../../../store/simulation/useEventsStore";
import { useProductStore } from "../../../../store/simulation/useProductStore";
async function DeleteFloorItems(
itemsGroup: Types.RefGroup,
@@ -22,7 +24,7 @@ async function DeleteFloorItems(
const items = await getFloorAssets(organization);
const removedItem = items.find(
(item: { modeluuid: string }) => item.modeluuid === hoveredDeletableFloorItem.current?.uuid
(item: { modelUuid: string }) => item.modelUuid === hoveredDeletableFloorItem.current?.uuid
);
if (!removedItem) {
@@ -31,26 +33,29 @@ async function DeleteFloorItems(
//REST
// const response = await deleteFloorItem(organization, removedItem.modeluuid, removedItem.modelname);
// const response = await deleteFloorItem(organization, removedItem.modelUuid, removedItem.modelName);
//SOCKET
const data = {
organization: organization,
modeluuid: removedItem.modeluuid,
modelname: removedItem.modelname,
modelUuid: removedItem.modelUuid,
modelName: removedItem.modelName,
socketId: socket.id
}
const response = socket.emit('v2:model-asset:delete', data)
useEventsStore.getState().removeEvent(removedItem.modelUuid);
useProductStore.getState().deleteEvent(removedItem.modelUuid);
if (response) {
const updatedItems = items.filter(
(item: { modeluuid: string }) => item.modeluuid !== hoveredDeletableFloorItem.current?.uuid
(item: { modelUuid: string }) => item.modelUuid !== hoveredDeletableFloorItem.current?.uuid
);
const storedItems = JSON.parse(localStorage.getItem("FloorItems") || '[]');
const updatedStoredItems = storedItems.filter((item: { modeluuid: string }) => item.modeluuid !== hoveredDeletableFloorItem.current?.uuid);
const updatedStoredItems = storedItems.filter((item: { modelUuid: string }) => item.modelUuid !== hoveredDeletableFloorItem.current?.uuid);
localStorage.setItem("FloorItems", JSON.stringify(updatedStoredItems));
if (hoveredDeletableFloorItem.current) {

View File

@@ -43,7 +43,7 @@ async function AddWallItems(
const newWallItem = {
type: config.type,
model: model,
modelname: selected,
modelName: selected,
scale: config.scale,
csgscale: config.csgscale,
csgposition: config.csgposition,
@@ -59,7 +59,7 @@ async function AddWallItems(
// await setWallItem(
// organization,
// model.uuid,
// newWallItem.modelname,
// newWallItem.modelName,
// newWallItem.type!,
// newWallItem.csgposition!,
// newWallItem.csgscale!,
@@ -72,8 +72,8 @@ async function AddWallItems(
const data = {
organization: organization,
modeluuid: model.uuid,
modelname: newWallItem.modelname,
modelUuid: model.uuid,
modelName: newWallItem.modelName,
type: newWallItem.type!,
csgposition: newWallItem.csgposition!,
csgscale: newWallItem.csgscale!,
@@ -92,7 +92,7 @@ async function AddWallItems(
const { model, ...rest } = item;
return {
...rest,
modeluuid: model?.uuid,
modelUuid: model?.uuid,
};
});

View File

@@ -28,14 +28,14 @@ function DeleteWallItems(
//REST
// await deleteWallItem(organization, removedItem?.model?.uuid!, removedItem?.modelname!)
// await deleteWallItem(organization, removedItem?.model?.uuid!, removedItem?.modelName!)
//SOCKET
const data = {
organization: organization,
modeluuid: removedItem?.model?.uuid!,
modelname: removedItem?.modelname!,
modelUuid: removedItem?.model?.uuid!,
modelName: removedItem?.modelName!,
socketId: socket.id
}
@@ -45,7 +45,7 @@ function DeleteWallItems(
const { model, ...rest } = item;
return {
...rest,
modeluuid: model?.uuid,
modelUuid: model?.uuid,
};
});

View File

@@ -65,7 +65,6 @@ const FloorItemsGroup = ({ itemsGroup, hoveredDeletableFloorItem, AttachedObject
};
getFloorAssets(organization).then((data) => {
console.log('data: ', data);
if (data.length > 0) {
const uniqueItems = (data as Types.FloorItems).filter((item, index, self) => index === self.findIndex((t) => t.modelfileID === item.modelfileID));
totalAssets = uniqueItems.length;

View File

@@ -91,7 +91,7 @@ const WallItemsGroup = ({ currentWallItem, AssetConfigurations, hoveredDeletable
const { model, ...rest } = item;
return {
...rest,
modeluuid: model?.uuid,
modelUuid: model?.uuid,
};
});
@@ -110,7 +110,7 @@ const WallItemsGroup = ({ currentWallItem, AssetConfigurations, hoveredDeletable
// await setWallItem(
// organization,
// currentItem?.model?.uuid,
// currentItem.modelname,
// currentItem.modelName,
// currentItem.type!,
// currentItem.csgposition!,
// currentItem.csgscale!,
@@ -123,8 +123,8 @@ const WallItemsGroup = ({ currentWallItem, AssetConfigurations, hoveredDeletable
const data = {
organization: organization,
modeluuid: currentItem.model?.uuid!,
modelname: currentItem.modelname!,
modelUuid: currentItem.model?.uuid!,
modelName: currentItem.modelName!,
type: currentItem.type!,
csgposition: currentItem.csgposition!,
csgscale: currentItem.csgscale!,