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:
@@ -18,6 +18,8 @@ import EditWidgetOption from "../../../ui/menu/EditWidgetOption";
|
|||||||
import { handleAddEventToProduct } from "../../../../modules/simulation/events/points/functions/handleAddEventToProduct";
|
import { handleAddEventToProduct } from "../../../../modules/simulation/events/points/functions/handleAddEventToProduct";
|
||||||
import { useEventsStore } from "../../../../store/simulation/useEventsStore";
|
import { useEventsStore } from "../../../../store/simulation/useEventsStore";
|
||||||
import { deleteEventDataApi } from "../../../../services/simulation/deleteEventDataApi";
|
import { deleteEventDataApi } from "../../../../services/simulation/deleteEventDataApi";
|
||||||
|
import { upsertProductOrEventApi } from "../../../../services/simulation/UpsertProductOrEventApi";
|
||||||
|
import { deleteProductApi } from "../../../../services/simulation/deleteProductApi";
|
||||||
|
|
||||||
interface Event {
|
interface Event {
|
||||||
pathName: string;
|
pathName: string;
|
||||||
@@ -41,9 +43,14 @@ const Simulations: React.FC = () => {
|
|||||||
const { selectedProduct, setSelectedProduct } = useSelectedProduct();
|
const { selectedProduct, setSelectedProduct } = useSelectedProduct();
|
||||||
const { getEventByModelUuid } = useEventsStore();
|
const { getEventByModelUuid } = useEventsStore();
|
||||||
const { selectedAsset, clearSelectedAsset } = useSelectedAsset();
|
const { selectedAsset, clearSelectedAsset } = useSelectedAsset();
|
||||||
|
const email = localStorage.getItem('email')
|
||||||
|
const organization = (email!.split("@")[1]).split(".")[0];
|
||||||
|
|
||||||
const handleAddProduct = () => {
|
const handleAddProduct = () => {
|
||||||
addProduct(`Product ${products.length + 1}`, generateUUID());
|
const id = generateUUID();
|
||||||
|
const name = `Product ${products.length + 1}`;
|
||||||
|
addProduct(name, id);
|
||||||
|
upsertProductOrEventApi({ productName: name, productId: id, organization: organization });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemoveProduct = (productId: string) => {
|
const handleRemoveProduct = (productId: string) => {
|
||||||
@@ -68,6 +75,7 @@ const Simulations: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeProduct(productId);
|
removeProduct(productId);
|
||||||
|
deleteProductApi(productId, organization);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRenameProduct = (productId: string, newName: string) => {
|
const handleRenameProduct = (productId: string, newName: string) => {
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ const DropDownList: React.FC<DropDownListProps> = ({
|
|||||||
return isPointInsidePolygon([x, z], polygon2D);
|
return isPointInsidePolygon([x, z], polygon2D);
|
||||||
})
|
})
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({
|
||||||
id: item.modeluuid,
|
id: item.modelUuid,
|
||||||
name: item.modelname,
|
name: item.modelName,
|
||||||
position: item.position,
|
position: item.position,
|
||||||
rotation: item.rotation
|
rotation: item.rotation
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -136,8 +136,8 @@ const List: React.FC<ListProps> = ({ items = [], remove }) => {
|
|||||||
console.log('response: ', response);
|
console.log('response: ', response);
|
||||||
setFloorItems((prevFloorItems: any[]) =>
|
setFloorItems((prevFloorItems: any[]) =>
|
||||||
prevFloorItems.map((floorItems) =>
|
prevFloorItems.map((floorItems) =>
|
||||||
floorItems.modeluuid === zoneAssetId.id
|
floorItems.modelUuid === zoneAssetId.id
|
||||||
? { ...floorItems, modelname: response.modelname }
|
? { ...floorItems, modelName: response.modelName }
|
||||||
: floorItems
|
: floorItems
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ async function loadInitialFloorItems(
|
|||||||
// Check Three.js Cache
|
// Check Three.js Cache
|
||||||
const cachedModel = THREE.Cache.get(item.modelfileID!);
|
const cachedModel = THREE.Cache.get(item.modelfileID!);
|
||||||
if (cachedModel) {
|
if (cachedModel) {
|
||||||
// console.log(`[Cache] Fetching ${item.modelname}`);
|
// console.log(`[Cache] Fetching ${item.modelName}`);
|
||||||
processLoadedModel(cachedModel.scene.clone(), item, itemsGroup, setFloorItems, addEvent);
|
processLoadedModel(cachedModel.scene.clone(), item, itemsGroup, setFloorItems, addEvent);
|
||||||
modelsLoaded++;
|
modelsLoaded++;
|
||||||
checkLoadingCompletion(modelsLoaded, modelsToLoad, dracoLoader, resolve);
|
checkLoadingCompletion(modelsLoaded, modelsToLoad, dracoLoader, resolve);
|
||||||
@@ -82,7 +82,7 @@ async function loadInitialFloorItems(
|
|||||||
// Check IndexedDB
|
// Check IndexedDB
|
||||||
const indexedDBModel = await retrieveGLTF(item.modelfileID!);
|
const indexedDBModel = await retrieveGLTF(item.modelfileID!);
|
||||||
if (indexedDBModel) {
|
if (indexedDBModel) {
|
||||||
// console.log(`[IndexedDB] Fetching ${item.modelname}`);
|
// console.log(`[IndexedDB] Fetching ${item.modelName}`);
|
||||||
const blobUrl = URL.createObjectURL(indexedDBModel);
|
const blobUrl = URL.createObjectURL(indexedDBModel);
|
||||||
loader.load(blobUrl, (gltf) => {
|
loader.load(blobUrl, (gltf) => {
|
||||||
URL.revokeObjectURL(blobUrl);
|
URL.revokeObjectURL(blobUrl);
|
||||||
@@ -94,7 +94,7 @@ async function loadInitialFloorItems(
|
|||||||
},
|
},
|
||||||
undefined,
|
undefined,
|
||||||
(error) => {
|
(error) => {
|
||||||
toast.error(`[IndexedDB] Error loading ${item.modelname}:`);
|
toast.error(`[IndexedDB] Error loading ${item.modelName}:`);
|
||||||
URL.revokeObjectURL(blobUrl);
|
URL.revokeObjectURL(blobUrl);
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ async function loadInitialFloorItems(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch from Backend
|
// 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!}`;
|
const modelUrl = `${url_Backend_dwinzo}/api/v2/AssetFile/${item.modelfileID!}`;
|
||||||
loader.load(modelUrl, async (gltf) => {
|
loader.load(modelUrl, async (gltf) => {
|
||||||
const modelBlob = await fetch(modelUrl).then((res) => res.blob());
|
const modelBlob = await fetch(modelUrl).then((res) => res.blob());
|
||||||
@@ -115,18 +115,18 @@ async function loadInitialFloorItems(
|
|||||||
},
|
},
|
||||||
undefined,
|
undefined,
|
||||||
(error) => {
|
(error) => {
|
||||||
toast.error(`[Backend] Error loading ${item.modelname}:`);
|
toast.error(`[Backend] Error loading ${item.modelName}:`);
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// console.log(`Item ${item.modelname} is not near`);
|
// console.log(`Item ${item.modelName} is not near`);
|
||||||
setFloorItems((prevItems) => [
|
setFloorItems((prevItems) => [
|
||||||
...(prevItems || []),
|
...(prevItems || []),
|
||||||
{
|
{
|
||||||
modeluuid: item.modeluuid,
|
modelUuid: item.modelUuid,
|
||||||
modelname: item.modelname,
|
modelName: item.modelName,
|
||||||
position: item.position,
|
position: item.position,
|
||||||
rotation: item.rotation,
|
rotation: item.rotation,
|
||||||
modelfileID: item.modelfileID,
|
modelfileID: item.modelfileID,
|
||||||
@@ -154,9 +154,9 @@ function processLoadedModel(
|
|||||||
addEvent: (event: EventsSchema) => void,
|
addEvent: (event: EventsSchema) => void,
|
||||||
) {
|
) {
|
||||||
const model = gltf.clone();
|
const model = gltf.clone();
|
||||||
model.uuid = item.modeluuid;
|
model.uuid = item.modelUuid;
|
||||||
model.scale.set(...CONSTANTS.assetConfig.defaultScaleBeforeGsap);
|
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.position.set(...item.position);
|
||||||
model.rotation.set(item.rotation.x, item.rotation.y, item.rotation.z);
|
model.rotation.set(item.rotation.x, item.rotation.y, item.rotation.z);
|
||||||
|
|
||||||
@@ -176,8 +176,8 @@ function processLoadedModel(
|
|||||||
setFloorItems((prevItems) => [
|
setFloorItems((prevItems) => [
|
||||||
...(prevItems || []),
|
...(prevItems || []),
|
||||||
{
|
{
|
||||||
modeluuid: item.modeluuid,
|
modelUuid: item.modelUuid,
|
||||||
modelname: item.modelname,
|
modelName: item.modelName,
|
||||||
position: item.position,
|
position: item.position,
|
||||||
rotation: item.rotation,
|
rotation: item.rotation,
|
||||||
modelfileID: item.modelfileID,
|
modelfileID: item.modelfileID,
|
||||||
@@ -189,8 +189,8 @@ function processLoadedModel(
|
|||||||
|
|
||||||
if (item.eventData.type === "vehicle") {
|
if (item.eventData.type === "vehicle") {
|
||||||
const vehicleEvent: VehicleEventSchema = {
|
const vehicleEvent: VehicleEventSchema = {
|
||||||
modelUuid: item.modeluuid,
|
modelUuid: item.modelUuid,
|
||||||
modelName: item.modelname,
|
modelName: item.modelName,
|
||||||
position: item.position,
|
position: item.position,
|
||||||
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
|
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
|
||||||
state: "idle",
|
state: "idle",
|
||||||
@@ -206,6 +206,7 @@ function processLoadedModel(
|
|||||||
actionType: "travel",
|
actionType: "travel",
|
||||||
unLoadDuration: 5,
|
unLoadDuration: 5,
|
||||||
loadCapacity: 10,
|
loadCapacity: 10,
|
||||||
|
steeringAngle:0,
|
||||||
pickUpPoint: null,
|
pickUpPoint: null,
|
||||||
unLoadPoint: null,
|
unLoadPoint: null,
|
||||||
triggers: []
|
triggers: []
|
||||||
@@ -215,8 +216,8 @@ function processLoadedModel(
|
|||||||
addEvent(vehicleEvent);
|
addEvent(vehicleEvent);
|
||||||
} else if (item.eventData.type === "Conveyor") {
|
} else if (item.eventData.type === "Conveyor") {
|
||||||
const ConveyorEvent: ConveyorEventSchema = {
|
const ConveyorEvent: ConveyorEventSchema = {
|
||||||
modelUuid: item.modeluuid,
|
modelUuid: item.modelUuid,
|
||||||
modelName: item.modelname,
|
modelName: item.modelName,
|
||||||
position: item.position,
|
position: item.position,
|
||||||
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
|
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
|
||||||
state: "idle",
|
state: "idle",
|
||||||
@@ -241,8 +242,8 @@ function processLoadedModel(
|
|||||||
addEvent(ConveyorEvent);
|
addEvent(ConveyorEvent);
|
||||||
} else if (item.eventData.type === "StaticMachine") {
|
} else if (item.eventData.type === "StaticMachine") {
|
||||||
const machineEvent: MachineEventSchema = {
|
const machineEvent: MachineEventSchema = {
|
||||||
modelUuid: item.modeluuid,
|
modelUuid: item.modelUuid,
|
||||||
modelName: item.modelname,
|
modelName: item.modelName,
|
||||||
position: item.position,
|
position: item.position,
|
||||||
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
|
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
|
||||||
state: "idle",
|
state: "idle",
|
||||||
@@ -264,8 +265,8 @@ function processLoadedModel(
|
|||||||
addEvent(machineEvent);
|
addEvent(machineEvent);
|
||||||
} else if (item.eventData.type === "ArmBot") {
|
} else if (item.eventData.type === "ArmBot") {
|
||||||
const roboticArmEvent: RoboticArmEventSchema = {
|
const roboticArmEvent: RoboticArmEventSchema = {
|
||||||
modelUuid: item.modeluuid,
|
modelUuid: item.modelUuid,
|
||||||
modelName: item.modelname,
|
modelName: item.modelName,
|
||||||
position: item.position,
|
position: item.position,
|
||||||
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
|
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
|
||||||
state: "idle",
|
state: "idle",
|
||||||
@@ -296,8 +297,8 @@ function processLoadedModel(
|
|||||||
setFloorItems((prevItems) => [
|
setFloorItems((prevItems) => [
|
||||||
...(prevItems || []),
|
...(prevItems || []),
|
||||||
{
|
{
|
||||||
modeluuid: item.modeluuid,
|
modelUuid: item.modelUuid,
|
||||||
modelname: item.modelname,
|
modelName: item.modelName,
|
||||||
position: item.position,
|
position: item.position,
|
||||||
rotation: item.rotation,
|
rotation: item.rotation,
|
||||||
modelfileID: item.modelfileID,
|
modelfileID: item.modelfileID,
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ async function loadInitialWallItems(
|
|||||||
const loadedWallItems = await Promise.all(storedWallItems.map(async (item) => {
|
const loadedWallItems = await Promise.all(storedWallItems.map(async (item) => {
|
||||||
const loader = new GLTFLoader();
|
const loader = new GLTFLoader();
|
||||||
return new Promise<Types.WallItem>((resolve) => {
|
return new Promise<Types.WallItem>((resolve) => {
|
||||||
loader.load(AssetConfigurations[item.modelname!].modelUrl, (gltf) => {
|
loader.load(AssetConfigurations[item.modelName!].modelUrl, (gltf) => {
|
||||||
const model = gltf.scene;
|
const model = gltf.scene;
|
||||||
model.uuid = item.modeluuid!;
|
model.uuid = item.modelUuid!;
|
||||||
|
|
||||||
model.children[0].children.forEach((child: any) => {
|
model.children[0].children.forEach((child: any) => {
|
||||||
if (child.name !== "CSG_REF") {
|
if (child.name !== "CSG_REF") {
|
||||||
@@ -36,7 +36,7 @@ async function loadInitialWallItems(
|
|||||||
resolve({
|
resolve({
|
||||||
type: item.type,
|
type: item.type,
|
||||||
model: model,
|
model: model,
|
||||||
modelname: item.modelname,
|
modelName: item.modelName,
|
||||||
scale: item.scale,
|
scale: item.scale,
|
||||||
csgscale: item.csgscale,
|
csgscale: item.csgscale,
|
||||||
csgposition: item.csgposition,
|
csgposition: item.csgposition,
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ async function handleModelLoad(
|
|||||||
socket: Socket<any>
|
socket: Socket<any>
|
||||||
) {
|
) {
|
||||||
const model = gltf.scene.clone();
|
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.position.set(intersectPoint!.x, 3 + intersectPoint!.y, intersectPoint!.z);
|
||||||
model.scale.set(...CONSTANTS.assetConfig.defaultScaleBeforeGsap);
|
model.scale.set(...CONSTANTS.assetConfig.defaultScaleBeforeGsap);
|
||||||
|
|
||||||
@@ -137,8 +137,8 @@ async function handleModelLoad(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newFloorItem: Types.FloorItemType = {
|
const newFloorItem: Types.FloorItemType = {
|
||||||
modeluuid: model.uuid,
|
modelUuid: model.uuid,
|
||||||
modelname: selectedItem.name,
|
modelName: selectedItem.name,
|
||||||
modelfileID: selectedItem.id,
|
modelfileID: selectedItem.id,
|
||||||
position: [intersectPoint!.x, intersectPoint!.y, intersectPoint!.z],
|
position: [intersectPoint!.x, intersectPoint!.y, intersectPoint!.z],
|
||||||
rotation: { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
|
rotation: { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
|
||||||
@@ -153,8 +153,8 @@ async function handleModelLoad(
|
|||||||
|
|
||||||
// await setFloorItemApi(
|
// await setFloorItemApi(
|
||||||
// organization,
|
// organization,
|
||||||
// newFloorItem.modeluuid,
|
// newFloorItem.modelUuid,
|
||||||
// newFloorItem.modelname,
|
// newFloorItem.modelName,
|
||||||
// newFloorItem.modelfileID,
|
// newFloorItem.modelfileID,
|
||||||
// newFloorItem.position,
|
// newFloorItem.position,
|
||||||
// { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
|
// { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
|
||||||
@@ -179,8 +179,8 @@ async function handleModelLoad(
|
|||||||
|
|
||||||
if (selectedItem.type === "Conveyor") {
|
if (selectedItem.type === "Conveyor") {
|
||||||
const ConveyorEvent: ConveyorEventSchema = {
|
const ConveyorEvent: ConveyorEventSchema = {
|
||||||
modelUuid: newFloorItem.modeluuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
modelName: newFloorItem.modelname,
|
modelName: newFloorItem.modelName,
|
||||||
position: newFloorItem.position,
|
position: newFloorItem.position,
|
||||||
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
||||||
state: "idle",
|
state: "idle",
|
||||||
@@ -211,8 +211,8 @@ async function handleModelLoad(
|
|||||||
|
|
||||||
} else if (selectedItem.type === "Vehicle") {
|
} else if (selectedItem.type === "Vehicle") {
|
||||||
const vehicleEvent: VehicleEventSchema = {
|
const vehicleEvent: VehicleEventSchema = {
|
||||||
modelUuid: newFloorItem.modeluuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
modelName: newFloorItem.modelname,
|
modelName: newFloorItem.modelName,
|
||||||
position: newFloorItem.position,
|
position: newFloorItem.position,
|
||||||
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
||||||
state: "idle",
|
state: "idle",
|
||||||
@@ -228,6 +228,7 @@ async function handleModelLoad(
|
|||||||
actionType: "travel",
|
actionType: "travel",
|
||||||
unLoadDuration: 5,
|
unLoadDuration: 5,
|
||||||
loadCapacity: 10,
|
loadCapacity: 10,
|
||||||
|
steeringAngle:0,
|
||||||
pickUpPoint: null,
|
pickUpPoint: null,
|
||||||
unLoadPoint: null,
|
unLoadPoint: null,
|
||||||
triggers: []
|
triggers: []
|
||||||
@@ -243,8 +244,8 @@ async function handleModelLoad(
|
|||||||
|
|
||||||
} else if (selectedItem.type === "ArmBot") {
|
} else if (selectedItem.type === "ArmBot") {
|
||||||
const roboticArmEvent: RoboticArmEventSchema = {
|
const roboticArmEvent: RoboticArmEventSchema = {
|
||||||
modelUuid: newFloorItem.modeluuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
modelName: newFloorItem.modelname,
|
modelName: newFloorItem.modelName,
|
||||||
position: newFloorItem.position,
|
position: newFloorItem.position,
|
||||||
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
||||||
state: "idle",
|
state: "idle",
|
||||||
@@ -278,8 +279,8 @@ async function handleModelLoad(
|
|||||||
|
|
||||||
} else if (selectedItem.type === "StaticMachine") {
|
} else if (selectedItem.type === "StaticMachine") {
|
||||||
const machineEvent: MachineEventSchema = {
|
const machineEvent: MachineEventSchema = {
|
||||||
modelUuid: newFloorItem.modeluuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
modelName: newFloorItem.modelname,
|
modelName: newFloorItem.modelName,
|
||||||
position: newFloorItem.position,
|
position: newFloorItem.position,
|
||||||
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
||||||
state: "idle",
|
state: "idle",
|
||||||
@@ -308,8 +309,8 @@ async function handleModelLoad(
|
|||||||
|
|
||||||
const completeData = {
|
const completeData = {
|
||||||
organization,
|
organization,
|
||||||
modeluuid: newFloorItem.modeluuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
modelname: newFloorItem.modelname,
|
modelName: newFloorItem.modelName,
|
||||||
modelfileID: newFloorItem.modelfileID,
|
modelfileID: newFloorItem.modelfileID,
|
||||||
position: newFloorItem.position,
|
position: newFloorItem.position,
|
||||||
rotation: { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
|
rotation: { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
|
||||||
@@ -337,8 +338,8 @@ async function handleModelLoad(
|
|||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
organization,
|
organization,
|
||||||
modeluuid: newFloorItem.modeluuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
modelname: newFloorItem.modelname,
|
modelName: newFloorItem.modelName,
|
||||||
modelfileID: newFloorItem.modelfileID,
|
modelfileID: newFloorItem.modelfileID,
|
||||||
position: newFloorItem.position,
|
position: newFloorItem.position,
|
||||||
rotation: { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
|
rotation: { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export default async function assetManager(
|
|||||||
// Check Three.js Cache
|
// Check Three.js Cache
|
||||||
const cachedModel = THREE.Cache.get(item.modelfileID!);
|
const cachedModel = THREE.Cache.get(item.modelfileID!);
|
||||||
if (cachedModel) {
|
if (cachedModel) {
|
||||||
// console.log(`[Cache] Fetching ${item.modelname}`);
|
// console.log(`[Cache] Fetching ${item.modelName}`);
|
||||||
processLoadedModel(cachedModel.scene.clone(), item, itemsGroup, resolve);
|
processLoadedModel(cachedModel.scene.clone(), item, itemsGroup, resolve);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ export default async function assetManager(
|
|||||||
// Check IndexedDB
|
// Check IndexedDB
|
||||||
const indexedDBModel = await retrieveGLTF(item.modelfileID!);
|
const indexedDBModel = await retrieveGLTF(item.modelfileID!);
|
||||||
if (indexedDBModel) {
|
if (indexedDBModel) {
|
||||||
// console.log(`[IndexedDB] Fetching ${item.modelname}`);
|
// console.log(`[IndexedDB] Fetching ${item.modelName}`);
|
||||||
const blobUrl = URL.createObjectURL(indexedDBModel);
|
const blobUrl = URL.createObjectURL(indexedDBModel);
|
||||||
loader.load(
|
loader.load(
|
||||||
blobUrl,
|
blobUrl,
|
||||||
@@ -78,7 +78,7 @@ export default async function assetManager(
|
|||||||
},
|
},
|
||||||
undefined,
|
undefined,
|
||||||
(error) => {
|
(error) => {
|
||||||
toast.error(`[IndexedDB] Error loading ${item.modelname}:`);
|
toast.error(`[IndexedDB] Error loading ${item.modelName}:`);
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -86,7 +86,7 @@ export default async function assetManager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch from Backend
|
// Fetch from Backend
|
||||||
// console.log(`[Backend] Fetching ${item.modelname}`);
|
// console.log(`[Backend] Fetching ${item.modelName}`);
|
||||||
loader.load(
|
loader.load(
|
||||||
modelUrl,
|
modelUrl,
|
||||||
async (gltf) => {
|
async (gltf) => {
|
||||||
@@ -97,7 +97,7 @@ export default async function assetManager(
|
|||||||
},
|
},
|
||||||
undefined,
|
undefined,
|
||||||
(error) => {
|
(error) => {
|
||||||
toast.error(`[Backend] Error loading ${item.modelname}:`);
|
toast.error(`[Backend] Error loading ${item.modelName}:`);
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -112,16 +112,16 @@ export default async function assetManager(
|
|||||||
) {
|
) {
|
||||||
if (!activePromises.get(taskId)) return; // Stop processing if task is canceled
|
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) {
|
if (existingModel) {
|
||||||
// console.log(`Model ${item.modelname} already exists in the scene.`);
|
// console.log(`Model ${item.modelName} already exists in the scene.`);
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const model = gltf;
|
const model = gltf;
|
||||||
model.uuid = item.modeluuid;
|
model.uuid = item.modelUuid;
|
||||||
model.userData = { name: item.modelname, modelId: item.modelfileID, modeluuid: item.modeluuid };
|
model.userData = { name: item.modelName, modelId: item.modelfileID, modelUuid: item.modelUuid };
|
||||||
model.scale.set(...CONSTANTS.assetConfig.defaultScaleBeforeGsap);
|
model.scale.set(...CONSTANTS.assetConfig.defaultScaleBeforeGsap);
|
||||||
model.position.set(...item.position);
|
model.position.set(...item.position);
|
||||||
model.rotation.set(item.rotation.x, item.rotation.y, item.rotation.z);
|
model.rotation.set(item.rotation.x, item.rotation.y, item.rotation.z);
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import * as Types from "../../../../types/world/worldTypes";
|
|||||||
// import { deleteFloorItem } from '../../../../services/factoryBuilder/assest/floorAsset/deleteFloorItemApi';
|
// import { deleteFloorItem } from '../../../../services/factoryBuilder/assest/floorAsset/deleteFloorItemApi';
|
||||||
import { Socket } from 'socket.io-client';
|
import { Socket } from 'socket.io-client';
|
||||||
import { getFloorAssets } from '../../../../services/factoryBuilder/assest/floorAsset/getFloorItemsApi';
|
import { getFloorAssets } from '../../../../services/factoryBuilder/assest/floorAsset/getFloorItemsApi';
|
||||||
|
import { useEventsStore } from "../../../../store/simulation/useEventsStore";
|
||||||
|
import { useProductStore } from "../../../../store/simulation/useProductStore";
|
||||||
|
|
||||||
async function DeleteFloorItems(
|
async function DeleteFloorItems(
|
||||||
itemsGroup: Types.RefGroup,
|
itemsGroup: Types.RefGroup,
|
||||||
@@ -22,7 +24,7 @@ async function DeleteFloorItems(
|
|||||||
|
|
||||||
const items = await getFloorAssets(organization);
|
const items = await getFloorAssets(organization);
|
||||||
const removedItem = items.find(
|
const removedItem = items.find(
|
||||||
(item: { modeluuid: string }) => item.modeluuid === hoveredDeletableFloorItem.current?.uuid
|
(item: { modelUuid: string }) => item.modelUuid === hoveredDeletableFloorItem.current?.uuid
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!removedItem) {
|
if (!removedItem) {
|
||||||
@@ -31,26 +33,29 @@ async function DeleteFloorItems(
|
|||||||
|
|
||||||
//REST
|
//REST
|
||||||
|
|
||||||
// const response = await deleteFloorItem(organization, removedItem.modeluuid, removedItem.modelname);
|
// const response = await deleteFloorItem(organization, removedItem.modelUuid, removedItem.modelName);
|
||||||
|
|
||||||
//SOCKET
|
//SOCKET
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
organization: organization,
|
organization: organization,
|
||||||
modeluuid: removedItem.modeluuid,
|
modelUuid: removedItem.modelUuid,
|
||||||
modelname: removedItem.modelname,
|
modelName: removedItem.modelName,
|
||||||
socketId: socket.id
|
socketId: socket.id
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = socket.emit('v2:model-asset:delete', data)
|
const response = socket.emit('v2:model-asset:delete', data)
|
||||||
|
|
||||||
|
useEventsStore.getState().removeEvent(removedItem.modelUuid);
|
||||||
|
useProductStore.getState().deleteEvent(removedItem.modelUuid);
|
||||||
|
|
||||||
if (response) {
|
if (response) {
|
||||||
const updatedItems = items.filter(
|
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 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));
|
localStorage.setItem("FloorItems", JSON.stringify(updatedStoredItems));
|
||||||
|
|
||||||
if (hoveredDeletableFloorItem.current) {
|
if (hoveredDeletableFloorItem.current) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ async function AddWallItems(
|
|||||||
const newWallItem = {
|
const newWallItem = {
|
||||||
type: config.type,
|
type: config.type,
|
||||||
model: model,
|
model: model,
|
||||||
modelname: selected,
|
modelName: selected,
|
||||||
scale: config.scale,
|
scale: config.scale,
|
||||||
csgscale: config.csgscale,
|
csgscale: config.csgscale,
|
||||||
csgposition: config.csgposition,
|
csgposition: config.csgposition,
|
||||||
@@ -59,7 +59,7 @@ async function AddWallItems(
|
|||||||
// await setWallItem(
|
// await setWallItem(
|
||||||
// organization,
|
// organization,
|
||||||
// model.uuid,
|
// model.uuid,
|
||||||
// newWallItem.modelname,
|
// newWallItem.modelName,
|
||||||
// newWallItem.type!,
|
// newWallItem.type!,
|
||||||
// newWallItem.csgposition!,
|
// newWallItem.csgposition!,
|
||||||
// newWallItem.csgscale!,
|
// newWallItem.csgscale!,
|
||||||
@@ -72,8 +72,8 @@ async function AddWallItems(
|
|||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
organization: organization,
|
organization: organization,
|
||||||
modeluuid: model.uuid,
|
modelUuid: model.uuid,
|
||||||
modelname: newWallItem.modelname,
|
modelName: newWallItem.modelName,
|
||||||
type: newWallItem.type!,
|
type: newWallItem.type!,
|
||||||
csgposition: newWallItem.csgposition!,
|
csgposition: newWallItem.csgposition!,
|
||||||
csgscale: newWallItem.csgscale!,
|
csgscale: newWallItem.csgscale!,
|
||||||
@@ -92,7 +92,7 @@ async function AddWallItems(
|
|||||||
const { model, ...rest } = item;
|
const { model, ...rest } = item;
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
modeluuid: model?.uuid,
|
modelUuid: model?.uuid,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -28,14 +28,14 @@ function DeleteWallItems(
|
|||||||
|
|
||||||
//REST
|
//REST
|
||||||
|
|
||||||
// await deleteWallItem(organization, removedItem?.model?.uuid!, removedItem?.modelname!)
|
// await deleteWallItem(organization, removedItem?.model?.uuid!, removedItem?.modelName!)
|
||||||
|
|
||||||
//SOCKET
|
//SOCKET
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
organization: organization,
|
organization: organization,
|
||||||
modeluuid: removedItem?.model?.uuid!,
|
modelUuid: removedItem?.model?.uuid!,
|
||||||
modelname: removedItem?.modelname!,
|
modelName: removedItem?.modelName!,
|
||||||
socketId: socket.id
|
socketId: socket.id
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ function DeleteWallItems(
|
|||||||
const { model, ...rest } = item;
|
const { model, ...rest } = item;
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
modeluuid: model?.uuid,
|
modelUuid: model?.uuid,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ const FloorItemsGroup = ({ itemsGroup, hoveredDeletableFloorItem, AttachedObject
|
|||||||
};
|
};
|
||||||
|
|
||||||
getFloorAssets(organization).then((data) => {
|
getFloorAssets(organization).then((data) => {
|
||||||
console.log('data: ', data);
|
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
const uniqueItems = (data as Types.FloorItems).filter((item, index, self) => index === self.findIndex((t) => t.modelfileID === item.modelfileID));
|
const uniqueItems = (data as Types.FloorItems).filter((item, index, self) => index === self.findIndex((t) => t.modelfileID === item.modelfileID));
|
||||||
totalAssets = uniqueItems.length;
|
totalAssets = uniqueItems.length;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ const WallItemsGroup = ({ currentWallItem, AssetConfigurations, hoveredDeletable
|
|||||||
const { model, ...rest } = item;
|
const { model, ...rest } = item;
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
modeluuid: model?.uuid,
|
modelUuid: model?.uuid,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ const WallItemsGroup = ({ currentWallItem, AssetConfigurations, hoveredDeletable
|
|||||||
// await setWallItem(
|
// await setWallItem(
|
||||||
// organization,
|
// organization,
|
||||||
// currentItem?.model?.uuid,
|
// currentItem?.model?.uuid,
|
||||||
// currentItem.modelname,
|
// currentItem.modelName,
|
||||||
// currentItem.type!,
|
// currentItem.type!,
|
||||||
// currentItem.csgposition!,
|
// currentItem.csgposition!,
|
||||||
// currentItem.csgscale!,
|
// currentItem.csgscale!,
|
||||||
@@ -123,8 +123,8 @@ const WallItemsGroup = ({ currentWallItem, AssetConfigurations, hoveredDeletable
|
|||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
organization: organization,
|
organization: organization,
|
||||||
modeluuid: currentItem.model?.uuid!,
|
modelUuid: currentItem.model?.uuid!,
|
||||||
modelname: currentItem.modelname!,
|
modelName: currentItem.modelName!,
|
||||||
type: currentItem.type!,
|
type: currentItem.type!,
|
||||||
csgposition: currentItem.csgposition!,
|
csgposition: currentItem.csgposition!,
|
||||||
csgscale: currentItem.csgscale!,
|
csgscale: currentItem.csgscale!,
|
||||||
|
|||||||
@@ -99,13 +99,13 @@ export default function SocketResponses({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
isTempLoader.current = true;
|
isTempLoader.current = true;
|
||||||
const cachedModel = THREE.Cache.get(data.data.modelname);
|
const cachedModel = THREE.Cache.get(data.data.modelName);
|
||||||
let url;
|
let url;
|
||||||
if (cachedModel) {
|
if (cachedModel) {
|
||||||
// console.log(`Getting ${data.data.modelname} from cache`);
|
// console.log(`Getting ${data.data.modelName} from cache`);
|
||||||
const model = cachedModel.scene.clone();
|
const model = cachedModel.scene.clone();
|
||||||
model.uuid = data.data.modeluuid;
|
model.uuid = data.data.modelUuid;
|
||||||
model.userData = { name: data.data.modelname, modelId: data.data.modelfileID, modeluuid: data.data.modeluuid };
|
model.userData = { name: data.data.modelName, modelId: data.data.modelfileID, modelUuid: data.data.modelUuid };
|
||||||
model.position.set(...data.data.position as [number, number, number]);
|
model.position.set(...data.data.position as [number, number, number]);
|
||||||
model.rotation.set(data.data.rotation.x, data.data.rotation.y, data.data.rotation.z);
|
model.rotation.set(data.data.rotation.x, data.data.rotation.y, data.data.rotation.z);
|
||||||
model.scale.set(...CONSTANTS.assetConfig.defaultScaleBeforeGsap);
|
model.scale.set(...CONSTANTS.assetConfig.defaultScaleBeforeGsap);
|
||||||
@@ -130,8 +130,8 @@ export default function SocketResponses({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newFloorItem: Types.FloorItemType = {
|
const newFloorItem: Types.FloorItemType = {
|
||||||
modeluuid: data.data.modeluuid,
|
modelUuid: data.data.modelUuid,
|
||||||
modelname: data.data.modelname,
|
modelName: data.data.modelName,
|
||||||
modelfileID: data.data.modelfileID,
|
modelfileID: data.data.modelfileID,
|
||||||
position: [...data.data.position as [number, number, number]],
|
position: [...data.data.position as [number, number, number]],
|
||||||
rotation: {
|
rotation: {
|
||||||
@@ -153,12 +153,12 @@ export default function SocketResponses({
|
|||||||
gsap.to(model.scale, { x: 1, y: 1, z: 1, duration: 1.5, ease: 'power2.out', onComplete: () => { toast.success("Model Added!") } });
|
gsap.to(model.scale, { x: 1, y: 1, z: 1, duration: 1.5, ease: 'power2.out', onComplete: () => { toast.success("Model Added!") } });
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const indexedDBModel = await retrieveGLTF(data.data.modelname);
|
const indexedDBModel = await retrieveGLTF(data.data.modelName);
|
||||||
if (indexedDBModel) {
|
if (indexedDBModel) {
|
||||||
// console.log(`Getting ${data.data.modelname} from IndexedDB`);
|
// console.log(`Getting ${data.data.modelName} from IndexedDB`);
|
||||||
url = URL.createObjectURL(indexedDBModel);
|
url = URL.createObjectURL(indexedDBModel);
|
||||||
} else {
|
} else {
|
||||||
// console.log(`Getting ${data.data.modelname} from Backend`);
|
// console.log(`Getting ${data.data.modelName} from Backend`);
|
||||||
url = `${url_Backend_dwinzo}/api/v2/AssetFile/${data.data.modelfileID}`;
|
url = `${url_Backend_dwinzo}/api/v2/AssetFile/${data.data.modelfileID}`;
|
||||||
const modelBlob = await fetch(url).then((res) => res.blob());
|
const modelBlob = await fetch(url).then((res) => res.blob());
|
||||||
await storeGLTF(data.data.modelfileID, modelBlob);
|
await storeGLTF(data.data.modelfileID, modelBlob);
|
||||||
@@ -178,8 +178,8 @@ export default function SocketResponses({
|
|||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
THREE.Cache.remove(url);
|
THREE.Cache.remove(url);
|
||||||
const model = gltf.scene;
|
const model = gltf.scene;
|
||||||
model.uuid = data.data.modeluuid;
|
model.uuid = data.data.modelUuid;
|
||||||
model.userData = { name: data.data.modelname, modelId: data.data.modelfileID, modeluuid: data.data.modeluuid };
|
model.userData = { name: data.data.modelName, modelId: data.data.modelfileID, modelUuid: data.data.modelUuid };
|
||||||
model.position.set(...data.data.position as [number, number, number]);
|
model.position.set(...data.data.position as [number, number, number]);
|
||||||
model.rotation.set(data.data.rotation.x, data.data.rotation.y, data.data.rotation.z);
|
model.rotation.set(data.data.rotation.x, data.data.rotation.y, data.data.rotation.z);
|
||||||
model.scale.set(...CONSTANTS.assetConfig.defaultScaleBeforeGsap);
|
model.scale.set(...CONSTANTS.assetConfig.defaultScaleBeforeGsap);
|
||||||
@@ -204,8 +204,8 @@ export default function SocketResponses({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newFloorItem: Types.FloorItemType = {
|
const newFloorItem: Types.FloorItemType = {
|
||||||
modeluuid: data.data.modeluuid,
|
modelUuid: data.data.modelUuid,
|
||||||
modelname: data.data.modelname,
|
modelName: data.data.modelName,
|
||||||
modelfileID: data.data.modelfileID,
|
modelfileID: data.data.modelfileID,
|
||||||
position: [...data.data.position as [number, number, number]],
|
position: [...data.data.position as [number, number, number]],
|
||||||
rotation: {
|
rotation: {
|
||||||
@@ -226,7 +226,7 @@ export default function SocketResponses({
|
|||||||
gsap.to(model.position, { y: data.data.position[1], duration: 1.5, ease: 'power2.out' });
|
gsap.to(model.position, { y: data.data.position[1], duration: 1.5, ease: 'power2.out' });
|
||||||
gsap.to(model.scale, { x: 1, y: 1, z: 1, duration: 1.5, ease: 'power2.out', onComplete: () => { toast.success("Model Added!") } });
|
gsap.to(model.scale, { x: 1, y: 1, z: 1, duration: 1.5, ease: 'power2.out', onComplete: () => { toast.success("Model Added!") } });
|
||||||
|
|
||||||
THREE.Cache.add(data.data.modelname, gltf);
|
THREE.Cache.add(data.data.modelName, gltf);
|
||||||
}, () => {
|
}, () => {
|
||||||
TempLoader(new THREE.Vector3(...data.data.position), isTempLoader, tempLoader, itemsGroup);
|
TempLoader(new THREE.Vector3(...data.data.position), isTempLoader, tempLoader, itemsGroup);
|
||||||
});
|
});
|
||||||
@@ -234,7 +234,7 @@ export default function SocketResponses({
|
|||||||
|
|
||||||
} else if (data.message === "Model updated successfully") {
|
} else if (data.message === "Model updated successfully") {
|
||||||
itemsGroup.current?.children.forEach((item: THREE.Group) => {
|
itemsGroup.current?.children.forEach((item: THREE.Group) => {
|
||||||
if (item.uuid === data.data.modeluuid) {
|
if (item.uuid === data.data.modelUuid) {
|
||||||
item.position.set(...data.data.position as [number, number, number]);
|
item.position.set(...data.data.position as [number, number, number]);
|
||||||
item.rotation.set(data.data.rotation.x, data.data.rotation.y, data.data.rotation.z);
|
item.rotation.set(data.data.rotation.x, data.data.rotation.y, data.data.rotation.z);
|
||||||
}
|
}
|
||||||
@@ -246,7 +246,7 @@ export default function SocketResponses({
|
|||||||
}
|
}
|
||||||
let updatedItem: any = null;
|
let updatedItem: any = null;
|
||||||
const updatedItems = prevItems.map((item) => {
|
const updatedItems = prevItems.map((item) => {
|
||||||
if (item.modeluuid === data.data.modeluuid) {
|
if (item.modelUuid === data.data.modelUuid) {
|
||||||
updatedItem = {
|
updatedItem = {
|
||||||
...item,
|
...item,
|
||||||
position: [...data.data.position] as [number, number, number],
|
position: [...data.data.position] as [number, number, number],
|
||||||
@@ -269,15 +269,15 @@ export default function SocketResponses({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (data.message === "Model deleted successfully") {
|
if (data.message === "Model deleted successfully") {
|
||||||
const deletedUUID = data.data.modeluuid;
|
const deletedUUID = data.data.modelUuid;
|
||||||
let items = JSON.parse(localStorage.getItem("FloorItems")!);
|
let items = JSON.parse(localStorage.getItem("FloorItems")!);
|
||||||
|
|
||||||
const updatedItems = items.filter(
|
const updatedItems = items.filter(
|
||||||
(item: { modeluuid: string }) => item.modeluuid !== deletedUUID
|
(item: { modelUuid: string }) => item.modelUuid !== deletedUUID
|
||||||
);
|
);
|
||||||
|
|
||||||
const storedItems = JSON.parse(localStorage.getItem("FloorItems") || '[]');
|
const storedItems = JSON.parse(localStorage.getItem("FloorItems") || '[]');
|
||||||
const updatedStoredItems = storedItems.filter((item: { modeluuid: string }) => item.modeluuid !== deletedUUID);
|
const updatedStoredItems = storedItems.filter((item: { modelUuid: string }) => item.modelUuid !== deletedUUID);
|
||||||
localStorage.setItem("FloorItems", JSON.stringify(updatedStoredItems));
|
localStorage.setItem("FloorItems", JSON.stringify(updatedStoredItems));
|
||||||
|
|
||||||
itemsGroup.current.children.forEach((item: any) => {
|
itemsGroup.current.children.forEach((item: any) => {
|
||||||
@@ -519,7 +519,7 @@ export default function SocketResponses({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (data.message === "wallitem deleted") {
|
if (data.message === "wallitem deleted") {
|
||||||
const deletedUUID = data.data.modeluuid;
|
const deletedUUID = data.data.modelUuid;
|
||||||
let WallItemsRef = wallItems;
|
let WallItemsRef = wallItems;
|
||||||
const Items = WallItemsRef.filter((item: any) => item.model?.uuid !== deletedUUID);
|
const Items = WallItemsRef.filter((item: any) => item.model?.uuid !== deletedUUID);
|
||||||
|
|
||||||
@@ -531,7 +531,7 @@ export default function SocketResponses({
|
|||||||
const { model, ...rest } = item;
|
const { model, ...rest } = item;
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
modeluuid: model?.uuid,
|
modelUuid: model?.uuid,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -550,9 +550,9 @@ export default function SocketResponses({
|
|||||||
}
|
}
|
||||||
if (data.message === "wallIitem created") {
|
if (data.message === "wallIitem created") {
|
||||||
const loader = new GLTFLoader();
|
const loader = new GLTFLoader();
|
||||||
loader.load(AssetConfigurations[data.data.modelname].modelUrl, async (gltf) => {
|
loader.load(AssetConfigurations[data.data.modelName].modelUrl, async (gltf) => {
|
||||||
const model = gltf.scene;
|
const model = gltf.scene;
|
||||||
model.uuid = data.data.modeluuid;
|
model.uuid = data.data.modelUuid;
|
||||||
model.children[0].children.forEach((child) => {
|
model.children[0].children.forEach((child) => {
|
||||||
if (child.name !== "CSG_REF") {
|
if (child.name !== "CSG_REF") {
|
||||||
child.castShadow = true;
|
child.castShadow = true;
|
||||||
@@ -563,7 +563,7 @@ export default function SocketResponses({
|
|||||||
const newWallItem = {
|
const newWallItem = {
|
||||||
type: data.data.type,
|
type: data.data.type,
|
||||||
model: model,
|
model: model,
|
||||||
modelname: data.data.modelname,
|
modelName: data.data.modelName,
|
||||||
scale: data.data.scale,
|
scale: data.data.scale,
|
||||||
csgscale: data.data.csgscale,
|
csgscale: data.data.csgscale,
|
||||||
csgposition: data.data.csgposition,
|
csgposition: data.data.csgposition,
|
||||||
@@ -578,7 +578,7 @@ export default function SocketResponses({
|
|||||||
const { model, ...rest } = item;
|
const { model, ...rest } = item;
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
modeluuid: model?.uuid,
|
modelUuid: model?.uuid,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -589,7 +589,7 @@ export default function SocketResponses({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (data.message === "wallIitem updated") {
|
} else if (data.message === "wallIitem updated") {
|
||||||
const updatedUUID = data.data.modeluuid;
|
const updatedUUID = data.data.modelUuid;
|
||||||
|
|
||||||
setWallItems((prevItems: any) => {
|
setWallItems((prevItems: any) => {
|
||||||
const updatedItems = prevItems.map((item: any) => {
|
const updatedItems = prevItems.map((item: any) => {
|
||||||
@@ -610,7 +610,7 @@ export default function SocketResponses({
|
|||||||
const { model, ...rest } = item;
|
const { model, ...rest } = item;
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
modeluuid: model?.uuid,
|
modelUuid: model?.uuid,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -170,8 +170,8 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newFloorItem: Types.FloorItemType = {
|
const newFloorItem: Types.FloorItemType = {
|
||||||
modeluuid: obj.uuid,
|
modelUuid: obj.uuid,
|
||||||
modelname: obj.userData.name,
|
modelName: obj.userData.name,
|
||||||
modelfileID: obj.userData.modelId,
|
modelfileID: obj.userData.modelId,
|
||||||
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z, },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z, },
|
||||||
@@ -206,8 +206,8 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
|||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
organization,
|
organization,
|
||||||
modeluuid: newFloorItem.modeluuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
modelname: newFloorItem.modelname,
|
modelName: newFloorItem.modelName,
|
||||||
modelfileID: newFloorItem.modelfileID,
|
modelfileID: newFloorItem.modelfileID,
|
||||||
position: newFloorItem.position,
|
position: newFloorItem.position,
|
||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
@@ -220,9 +220,9 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
|||||||
socket.emit("v2:model-asset:add", data);
|
socket.emit("v2:model-asset:add", data);
|
||||||
|
|
||||||
obj.userData = {
|
obj.userData = {
|
||||||
name: newFloorItem.modelname,
|
name: newFloorItem.modelName,
|
||||||
modelId: newFloorItem.modelfileID,
|
modelId: newFloorItem.modelfileID,
|
||||||
modeluuid: newFloorItem.modeluuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
eventData: updatedEventData
|
eventData: updatedEventData
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -148,8 +148,8 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newFloorItem: Types.FloorItemType = {
|
const newFloorItem: Types.FloorItemType = {
|
||||||
modeluuid: obj.uuid,
|
modelUuid: obj.uuid,
|
||||||
modelname: obj.userData.name,
|
modelName: obj.userData.name,
|
||||||
modelfileID: obj.userData.modelId,
|
modelfileID: obj.userData.modelId,
|
||||||
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z, },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z, },
|
||||||
@@ -184,8 +184,8 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
|||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
organization,
|
organization,
|
||||||
modeluuid: newFloorItem.modeluuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
modelname: newFloorItem.modelname,
|
modelName: newFloorItem.modelName,
|
||||||
modelfileID: newFloorItem.modelfileID,
|
modelfileID: newFloorItem.modelfileID,
|
||||||
position: newFloorItem.position,
|
position: newFloorItem.position,
|
||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
@@ -198,9 +198,9 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
|||||||
socket.emit("v2:model-asset:add", data);
|
socket.emit("v2:model-asset:add", data);
|
||||||
|
|
||||||
obj.userData = {
|
obj.userData = {
|
||||||
name: newFloorItem.modelname,
|
name: newFloorItem.modelName,
|
||||||
modelId: newFloorItem.modelfileID,
|
modelId: newFloorItem.modelfileID,
|
||||||
modeluuid: newFloorItem.modeluuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
eventData: updatedEventData
|
eventData: updatedEventData
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
|||||||
if (keyCombination === "G") {
|
if (keyCombination === "G") {
|
||||||
if (selectedAssets.length > 0) {
|
if (selectedAssets.length > 0) {
|
||||||
moveAssets();
|
moveAssets();
|
||||||
itemsData.current = floorItems.filter((item: { modeluuid: string }) => selectedAssets.some((asset: any) => asset.uuid === item.modeluuid));
|
itemsData.current = floorItems.filter((item: { modelUuid: string }) => selectedAssets.some((asset: any) => asset.uuid === item.modelUuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (keyCombination === "ESCAPE") {
|
if (keyCombination === "ESCAPE") {
|
||||||
@@ -151,7 +151,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
|||||||
|
|
||||||
|
|
||||||
const moveAssets = () => {
|
const moveAssets = () => {
|
||||||
const updatedItems = floorItems.filter((item: { modeluuid: string }) => !selectedAssets.some((asset: any) => asset.uuid === item.modeluuid));
|
const updatedItems = floorItems.filter((item: { modelUuid: string }) => !selectedAssets.some((asset: any) => asset.uuid === item.modelUuid));
|
||||||
setFloorItems(updatedItems);
|
setFloorItems(updatedItems);
|
||||||
setMovedObjects(selectedAssets);
|
setMovedObjects(selectedAssets);
|
||||||
selectedAssets.forEach((asset: any) => { selectionGroup.current.attach(asset); });
|
selectedAssets.forEach((asset: any) => { selectionGroup.current.attach(asset); });
|
||||||
@@ -170,8 +170,8 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
|||||||
if (itemsGroupRef.current) {
|
if (itemsGroupRef.current) {
|
||||||
|
|
||||||
const newFloorItem: Types.FloorItemType = {
|
const newFloorItem: Types.FloorItemType = {
|
||||||
modeluuid: obj.uuid,
|
modelUuid: obj.uuid,
|
||||||
modelname: obj.userData.name,
|
modelName: obj.userData.name,
|
||||||
modelfileID: obj.userData.modelId,
|
modelfileID: obj.userData.modelId,
|
||||||
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z, },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z, },
|
||||||
@@ -180,17 +180,17 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (obj.userData.eventData) {
|
if (obj.userData.eventData) {
|
||||||
const eventData = useEventsStore.getState().getEventByModelUuid(obj.userData.modeluuid);
|
const eventData = useEventsStore.getState().getEventByModelUuid(obj.userData.modelUuid);
|
||||||
const productData = useProductStore.getState().getEventByModelUuid(useSelectedProduct.getState().selectedProduct.productId, obj.userData.modeluuid);
|
const productData = useProductStore.getState().getEventByModelUuid(useSelectedProduct.getState().selectedProduct.productId, obj.userData.modelUuid);
|
||||||
|
|
||||||
if (eventData) {
|
if (eventData) {
|
||||||
useEventsStore.getState().updateEvent(obj.userData.modeluuid, {
|
useEventsStore.getState().updateEvent(obj.userData.modelUuid, {
|
||||||
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
||||||
rotation: [obj.rotation.x, obj.rotation.y, obj.rotation.z],
|
rotation: [obj.rotation.x, obj.rotation.y, obj.rotation.z],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (productData) {
|
if (productData) {
|
||||||
useProductStore.getState().updateEvent(useSelectedProduct.getState().selectedProduct.productId, obj.userData.modeluuid, {
|
useProductStore.getState().updateEvent(useSelectedProduct.getState().selectedProduct.productId, obj.userData.modelUuid, {
|
||||||
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
||||||
rotation: [obj.rotation.x, obj.rotation.y, obj.rotation.z],
|
rotation: [obj.rotation.x, obj.rotation.y, obj.rotation.z],
|
||||||
})
|
})
|
||||||
@@ -223,8 +223,8 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
|||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
organization,
|
organization,
|
||||||
modeluuid: newFloorItem.modeluuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
modelname: newFloorItem.modelname,
|
modelName: newFloorItem.modelName,
|
||||||
modelfileID: newFloorItem.modelfileID,
|
modelfileID: newFloorItem.modelfileID,
|
||||||
position: newFloorItem.position,
|
position: newFloorItem.position,
|
||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
if (event.key.toLowerCase() === "r") {
|
if (event.key.toLowerCase() === "r") {
|
||||||
if (selectedAssets.length > 0) {
|
if (selectedAssets.length > 0) {
|
||||||
rotateAssets();
|
rotateAssets();
|
||||||
itemsData.current = floorItems.filter((item: { modeluuid: string }) => selectedAssets.some((asset: any) => asset.uuid === item.modeluuid));
|
itemsData.current = floorItems.filter((item: { modelUuid: string }) => selectedAssets.some((asset: any) => asset.uuid === item.modelUuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.key.toLowerCase() === "escape") {
|
if (event.key.toLowerCase() === "escape") {
|
||||||
@@ -128,7 +128,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
});
|
});
|
||||||
|
|
||||||
const rotateAssets = () => {
|
const rotateAssets = () => {
|
||||||
const updatedItems = floorItems.filter((item: { modeluuid: string }) => !selectedAssets.some((asset: any) => asset.uuid === item.modeluuid));
|
const updatedItems = floorItems.filter((item: { modelUuid: string }) => !selectedAssets.some((asset: any) => asset.uuid === item.modelUuid));
|
||||||
setFloorItems(updatedItems);
|
setFloorItems(updatedItems);
|
||||||
|
|
||||||
const box = new THREE.Box3();
|
const box = new THREE.Box3();
|
||||||
@@ -170,8 +170,8 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
if (itemsGroupRef.current) {
|
if (itemsGroupRef.current) {
|
||||||
|
|
||||||
const newFloorItem: Types.FloorItemType = {
|
const newFloorItem: Types.FloorItemType = {
|
||||||
modeluuid: obj.uuid,
|
modelUuid: obj.uuid,
|
||||||
modelname: obj.userData.name,
|
modelName: obj.userData.name,
|
||||||
modelfileID: obj.userData.modelId,
|
modelfileID: obj.userData.modelId,
|
||||||
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z, },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z, },
|
||||||
@@ -180,17 +180,17 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (obj.userData.eventData) {
|
if (obj.userData.eventData) {
|
||||||
const eventData = useEventsStore.getState().getEventByModelUuid(obj.userData.modeluuid);
|
const eventData = useEventsStore.getState().getEventByModelUuid(obj.userData.modelUuid);
|
||||||
const productData = useProductStore.getState().getEventByModelUuid(useSelectedProduct.getState().selectedProduct.productId, obj.userData.modeluuid);
|
const productData = useProductStore.getState().getEventByModelUuid(useSelectedProduct.getState().selectedProduct.productId, obj.userData.modelUuid);
|
||||||
|
|
||||||
if (eventData) {
|
if (eventData) {
|
||||||
useEventsStore.getState().updateEvent(obj.userData.modeluuid, {
|
useEventsStore.getState().updateEvent(obj.userData.modelUuid, {
|
||||||
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
||||||
rotation: [obj.rotation.x, obj.rotation.y, obj.rotation.z],
|
rotation: [obj.rotation.x, obj.rotation.y, obj.rotation.z],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (productData) {
|
if (productData) {
|
||||||
useProductStore.getState().updateEvent(useSelectedProduct.getState().selectedProduct.productId, obj.userData.modeluuid, {
|
useProductStore.getState().updateEvent(useSelectedProduct.getState().selectedProduct.productId, obj.userData.modelUuid, {
|
||||||
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
position: [worldPosition.x, worldPosition.y, worldPosition.z],
|
||||||
rotation: [obj.rotation.x, obj.rotation.y, obj.rotation.z],
|
rotation: [obj.rotation.x, obj.rotation.y, obj.rotation.z],
|
||||||
})
|
})
|
||||||
@@ -223,8 +223,8 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
organization,
|
organization,
|
||||||
modeluuid: newFloorItem.modeluuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
modelname: newFloorItem.modelname,
|
modelName: newFloorItem.modelName,
|
||||||
modelfileID: newFloorItem.modelfileID,
|
modelfileID: newFloorItem.modelfileID,
|
||||||
position: newFloorItem.position,
|
position: newFloorItem.position,
|
||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import CopyPasteControls from "./copyPasteControls";
|
|||||||
import MoveControls from "./moveControls";
|
import MoveControls from "./moveControls";
|
||||||
import RotateControls from "./rotateControls";
|
import RotateControls from "./rotateControls";
|
||||||
import useModuleStore from "../../../../store/useModuleStore";
|
import useModuleStore from "../../../../store/useModuleStore";
|
||||||
|
import { useEventsStore } from "../../../../store/simulation/useEventsStore";
|
||||||
|
import { useProductStore } from "../../../../store/simulation/useProductStore";
|
||||||
|
|
||||||
const SelectionControls: React.FC = () => {
|
const SelectionControls: React.FC = () => {
|
||||||
const { camera, controls, gl, scene, pointer } = useThree();
|
const { camera, controls, gl, scene, pointer } = useThree();
|
||||||
@@ -206,7 +208,7 @@ const SelectionControls: React.FC = () => {
|
|||||||
const storedItems = JSON.parse(localStorage.getItem("FloorItems") || "[]");
|
const storedItems = JSON.parse(localStorage.getItem("FloorItems") || "[]");
|
||||||
const selectedUUIDs = selectedAssets.map((mesh: THREE.Object3D) => mesh.uuid);
|
const selectedUUIDs = selectedAssets.map((mesh: THREE.Object3D) => mesh.uuid);
|
||||||
|
|
||||||
const updatedStoredItems = storedItems.filter((item: { modeluuid: string }) => !selectedUUIDs.includes(item.modeluuid));
|
const updatedStoredItems = storedItems.filter((item: { modelUuid: string }) => !selectedUUIDs.includes(item.modelUuid));
|
||||||
localStorage.setItem("FloorItems", JSON.stringify(updatedStoredItems));
|
localStorage.setItem("FloorItems", JSON.stringify(updatedStoredItems));
|
||||||
|
|
||||||
selectedAssets.forEach((selectedMesh: THREE.Object3D) => {
|
selectedAssets.forEach((selectedMesh: THREE.Object3D) => {
|
||||||
@@ -218,13 +220,16 @@ const SelectionControls: React.FC = () => {
|
|||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
organization: organization,
|
organization: organization,
|
||||||
modeluuid: selectedMesh.uuid,
|
modelUuid: selectedMesh.uuid,
|
||||||
modelname: selectedMesh.userData.name,
|
modelName: selectedMesh.userData.name,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit("v2:model-asset:delete", data);
|
socket.emit("v2:model-asset:delete", data);
|
||||||
|
|
||||||
|
useEventsStore.getState().removeEvent(selectedMesh.uuid);
|
||||||
|
useProductStore.getState().deleteEvent(selectedMesh.uuid);
|
||||||
|
|
||||||
selectedMesh.traverse((child: THREE.Object3D) => {
|
selectedMesh.traverse((child: THREE.Object3D) => {
|
||||||
if (child instanceof THREE.Mesh) {
|
if (child instanceof THREE.Mesh) {
|
||||||
if (child.geometry) child.geometry.dispose();
|
if (child.geometry) child.geometry.dispose();
|
||||||
@@ -243,7 +248,7 @@ const SelectionControls: React.FC = () => {
|
|||||||
itemsGroupRef.current?.remove(selectedMesh);
|
itemsGroupRef.current?.remove(selectedMesh);
|
||||||
});
|
});
|
||||||
|
|
||||||
const updatedItems = floorItems.filter((item: { modeluuid: string }) => !selectedUUIDs.includes(item.modeluuid));
|
const updatedItems = floorItems.filter((item: { modelUuid: string }) => !selectedUUIDs.includes(item.modelUuid));
|
||||||
setFloorItems(updatedItems);
|
setFloorItems(updatedItems);
|
||||||
}
|
}
|
||||||
toast.success("Selected models removed!");
|
toast.success("Selected models removed!");
|
||||||
|
|||||||
@@ -36,12 +36,12 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let armItems = floorItems?.filter((val: any) =>
|
let armItems = floorItems?.filter((val: any) =>
|
||||||
val.modeluuid === "3abf5d46-b59e-4e6b-9c02-a4634b64b82d"
|
val.modelUuid === "3abf5d46-b59e-4e6b-9c02-a4634b64b82d"
|
||||||
);
|
);
|
||||||
// Get the first matching item
|
// Get the first matching item
|
||||||
let armItem = armItems?.[0];
|
let armItem = armItems?.[0];
|
||||||
if (armItem) {
|
if (armItem) {
|
||||||
const targetMesh = scene?.getObjectByProperty("uuid", armItem.modeluuid);
|
const targetMesh = scene?.getObjectByProperty("uuid", armItem.modelUuid);
|
||||||
if (targetMesh) {
|
if (targetMesh) {
|
||||||
targetMesh.visible = activeModule !== "simulation"
|
targetMesh.visible = activeModule !== "simulation"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ function Simulation() {
|
|||||||
const { products } = useProductStore();
|
const { products } = useProductStore();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('events: ', events);
|
// console.log('events: ', events);
|
||||||
}, [events])
|
}, [events])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('products: ', products);
|
// console.log('products: ', products);
|
||||||
}, [products])
|
}, [products])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ function Vehicles() {
|
|||||||
actionType: "travel",
|
actionType: "travel",
|
||||||
unLoadDuration: 10,
|
unLoadDuration: 10,
|
||||||
loadCapacity: 2,
|
loadCapacity: 2,
|
||||||
|
steeringAngle:0,
|
||||||
pickUpPoint: { position: { x: 98.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } },
|
pickUpPoint: { position: { x: 98.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } },
|
||||||
unLoadPoint: { position: { x: 105.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } },
|
unLoadPoint: { position: { x: 105.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } },
|
||||||
triggers: [
|
triggers: [
|
||||||
@@ -71,6 +72,7 @@ function Vehicles() {
|
|||||||
actionType: "travel",
|
actionType: "travel",
|
||||||
unLoadDuration: 10,
|
unLoadDuration: 10,
|
||||||
loadCapacity: 2,
|
loadCapacity: 2,
|
||||||
|
steeringAngle:0,
|
||||||
pickUpPoint: { position: { x: 90, y: 0, z: 28 }, rotation: { x: 0, y: 0, z: 0 } },
|
pickUpPoint: { position: { x: 90, y: 0, z: 28 }, rotation: { x: 0, y: 0, z: 0 } },
|
||||||
unLoadPoint: { position: { x: 20, y: 0, z: 10 }, rotation: { x: 0, y: 0, z: 0 } },
|
unLoadPoint: { position: { x: 20, y: 0, z: 10 }, rotation: { x: 0, y: 0, z: 0 } },
|
||||||
triggers: [
|
triggers: [
|
||||||
@@ -114,6 +116,7 @@ function Vehicles() {
|
|||||||
actionType: "travel",
|
actionType: "travel",
|
||||||
unLoadDuration: 15,
|
unLoadDuration: 15,
|
||||||
loadCapacity: 5,
|
loadCapacity: 5,
|
||||||
|
steeringAngle:0,
|
||||||
pickUpPoint: { position: { x: 98.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } },
|
pickUpPoint: { position: { x: 98.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } },
|
||||||
unLoadPoint: { position: { x: 20, y: 0, z: 10 }, rotation: { x: 0, y: 0, z: 0 } },
|
unLoadPoint: { position: { x: 20, y: 0, z: 10 }, rotation: { x: 0, y: 0, z: 0 } },
|
||||||
triggers: [
|
triggers: [
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||||
|
|
||||||
export const deleteFloorItem = async (organization: string, modeluuid: string, modelname: string) => {
|
export const deleteFloorItem = async (organization: string, modelUuid: string, modelName: string) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deletefloorItem`, {
|
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deletefloorItem`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ organization, modeluuid, modelname }),
|
body: JSON.stringify({ organization, modelUuid, modelName }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||||
export const setFloorItemApi = async (
|
export const setFloorItemApi = async (
|
||||||
organization: string,
|
organization: string,
|
||||||
modeluuid?: string,
|
modelUuid?: string,
|
||||||
modelname?: string,
|
modelName?: string,
|
||||||
modelfileID?: string,
|
modelfileID?: string,
|
||||||
position?: Object,
|
position?: Object,
|
||||||
rotation?: Object,
|
rotation?: Object,
|
||||||
@@ -10,7 +10,7 @@ export const setFloorItemApi = async (
|
|||||||
isVisible?: boolean,
|
isVisible?: boolean,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const body: any = { organization, modeluuid, modelname, position, rotation, modelfileID, isLocked, isVisible };
|
const body: any = { organization, modelUuid, modelName, position, rotation, modelfileID, isLocked, isVisible };
|
||||||
|
|
||||||
const response = await fetch(`${url_Backend_dwinzo}/api/v2/setasset`, {
|
const response = await fetch(`${url_Backend_dwinzo}/api/v2/setasset`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||||
|
|
||||||
export const deleteWallItem = async (organization: string, modeluuid: string, modelname: string) => {
|
export const deleteWallItem = async (organization: string, modelUuid: string, modelName: string) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteWallItem`, {
|
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteWallItem`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ organization, modeluuid, modelname }),
|
body: JSON.stringify({ organization, modelUuid, modelName }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
|
|||||||
|
|
||||||
export const setWallItem = async (
|
export const setWallItem = async (
|
||||||
organization: string,
|
organization: string,
|
||||||
modeluuid: string,
|
modelUuid: string,
|
||||||
modelname: string,
|
modelName: string,
|
||||||
type: string,
|
type: string,
|
||||||
csgposition: Object,
|
csgposition: Object,
|
||||||
csgscale: Object,
|
csgscale: Object,
|
||||||
@@ -17,7 +17,7 @@ export const setWallItem = async (
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ organization, modeluuid, modelname, position, type, csgposition, csgscale, quaternion, scale }),
|
body: JSON.stringify({ organization, modelUuid, modelName, position, type, csgposition, csgscale, quaternion, scale }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ onmessage = (event) => {
|
|||||||
const itemPosition = new THREE.Vector3(...item.position);
|
const itemPosition = new THREE.Vector3(...item.position);
|
||||||
const distance = cameraPos.distanceTo(itemPosition);
|
const distance = cameraPos.distanceTo(itemPosition);
|
||||||
|
|
||||||
if (distance <= renderDistance && !uuids.includes(item.modeluuid)) {
|
if (distance <= renderDistance && !uuids.includes(item.modelUuid)) {
|
||||||
toAdd.push(item);
|
toAdd.push(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -35,7 +35,7 @@ onmessage = (event) => {
|
|||||||
|
|
||||||
// Check for items to be removed
|
// Check for items to be removed
|
||||||
uuids.forEach((uuid) => {
|
uuids.forEach((uuid) => {
|
||||||
const floorItem = floorItems.find((item) => item.modeluuid === uuid);
|
const floorItem = floorItems.find((item) => item.modelUuid === uuid);
|
||||||
if (floorItem) {
|
if (floorItem) {
|
||||||
const itemPosition = new THREE.Vector3(...floorItem.position);
|
const itemPosition = new THREE.Vector3(...floorItem.position);
|
||||||
const distance = cameraPos.distanceTo(itemPosition);
|
const distance = cameraPos.distanceTo(itemPosition);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||||
|
|
||||||
export const deleteProductDataApi = async (productId: string, organization: string) => {
|
export const deleteProductApi = async (productId: string, organization: string) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productDataDelete?productId=${productId}&organization=${organization}`, {
|
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productDataDelete?productId=${productId}&organization=${organization}`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
@@ -13,6 +13,7 @@ type ProductsStore = {
|
|||||||
// Event-level actions
|
// Event-level actions
|
||||||
addEvent: (productId: string, event: EventsSchema) => void;
|
addEvent: (productId: string, event: EventsSchema) => void;
|
||||||
removeEvent: (productId: string, modelUuid: string) => void;
|
removeEvent: (productId: string, modelUuid: string) => void;
|
||||||
|
deleteEvent: (modelUuid: string) => void;
|
||||||
updateEvent: (productId: string, modelUuid: string, updates: Partial<EventsSchema>) => void;
|
updateEvent: (productId: string, modelUuid: string, updates: Partial<EventsSchema>) => void;
|
||||||
|
|
||||||
// Point-level actions
|
// Point-level actions
|
||||||
@@ -119,6 +120,14 @@ export const useProductStore = create<ProductsStore>()(
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
deleteEvent: (modelUuid: string) => {
|
||||||
|
set((state) => {
|
||||||
|
for (const product of state.products) {
|
||||||
|
product.eventDatas = product.eventDatas.filter(e => 'modelUuid' in e && e.modelUuid !== modelUuid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
updateEvent: (productId, modelUuid, updates) => {
|
updateEvent: (productId, modelUuid, updates) => {
|
||||||
set((state) => {
|
set((state) => {
|
||||||
const product = state.products.find(p => p.productId === productId);
|
const product = state.products.find(p => p.productId === productId);
|
||||||
@@ -440,7 +449,7 @@ export const useProductStore = create<ProductsStore>()(
|
|||||||
getPointByUuid: (productId, modelUuid, pointUuid) => {
|
getPointByUuid: (productId, modelUuid, pointUuid) => {
|
||||||
const event = get().getEventByModelUuid(productId, modelUuid);
|
const event = get().getEventByModelUuid(productId, modelUuid);
|
||||||
if (!event) return undefined;
|
if (!event) return undefined;
|
||||||
|
|
||||||
if ('points' in event) {
|
if ('points' in event) {
|
||||||
return (event as ConveyorEventSchema).points.find(p => p.uuid === pointUuid);
|
return (event as ConveyorEventSchema).points.find(p => p.uuid === pointUuid);
|
||||||
} else if ('point' in event && (event as any).point.uuid === pointUuid) {
|
} else if ('point' in event && (event as any).point.uuid === pointUuid) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ interface VehiclesStore {
|
|||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
setVehicleActive: (modelUuid: string, isActive: boolean) => void;
|
setVehicleActive: (modelUuid: string, isActive: boolean) => void;
|
||||||
|
updateSteeringAngle: (modelUuid: string, steeringAngle: number) => void;
|
||||||
incrementVehicleLoad: (modelUuid: string, incrementBy: number) => void;
|
incrementVehicleLoad: (modelUuid: string, incrementBy: number) => void;
|
||||||
decrementVehicleLoad: (modelUuid: string, decrementBy: number) => void;
|
decrementVehicleLoad: (modelUuid: string, decrementBy: number) => void;
|
||||||
setVehicleState: (modelUuid: string, newState: VehicleStatus['state']) => void;
|
setVehicleState: (modelUuid: string, newState: VehicleStatus['state']) => void;
|
||||||
@@ -76,6 +77,15 @@ export const useVehicleStore = create<VehiclesStore>()(
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateSteeringAngle: (modelUuid, steeringAngle) => {
|
||||||
|
set((state) => {
|
||||||
|
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
||||||
|
if (vehicle) {
|
||||||
|
vehicle.point.action.steeringAngle = steeringAngle;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
incrementVehicleLoad: (modelUuid, incrementBy) => {
|
incrementVehicleLoad: (modelUuid, incrementBy) => {
|
||||||
set((state) => {
|
set((state) => {
|
||||||
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
||||||
|
|||||||
1
app/src/types/simulationTypes.d.ts
vendored
1
app/src/types/simulationTypes.d.ts
vendored
@@ -44,6 +44,7 @@ interface VehiclePointSchema {
|
|||||||
actionType: "travel";
|
actionType: "travel";
|
||||||
unLoadDuration: number;
|
unLoadDuration: number;
|
||||||
loadCapacity: number;
|
loadCapacity: number;
|
||||||
|
steeringAngle: number;
|
||||||
pickUpPoint: { position: { x: number; y: number, z: number }, rotation: { x: number; y: number, z: number } } | null;
|
pickUpPoint: { position: { x: number; y: number, z: number }, rotation: { x: number; y: number, z: number } } | null;
|
||||||
unLoadPoint: { position: { x: number; y: number, z: number }, rotation: { x: number; y: number, z: number } } | null;
|
unLoadPoint: { position: { x: number; y: number, z: number }, rotation: { x: number; y: number, z: number } } | null;
|
||||||
triggers: TriggerSchema[];
|
triggers: TriggerSchema[];
|
||||||
|
|||||||
8
app/src/types/world/worldTypes.d.ts
vendored
8
app/src/types/world/worldTypes.d.ts
vendored
@@ -189,8 +189,8 @@ export type RefTubeGeometry = React.MutableRefObject<THREE.TubeGeometry | null>;
|
|||||||
|
|
||||||
// Type for individual items placed on the floor, with positioning and rotation metadata
|
// Type for individual items placed on the floor, with positioning and rotation metadata
|
||||||
export type FloorItemType = {
|
export type FloorItemType = {
|
||||||
modeluuid: string;
|
modelUuid: string;
|
||||||
modelname: string;
|
modelName: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: { x: number; y: number; z: number };
|
rotation: { x: number; y: number; z: number };
|
||||||
modelfileID: string;
|
modelfileID: string;
|
||||||
@@ -238,8 +238,8 @@ export type AssetConfigurations = { [key: string]: AssetConfiguration; };
|
|||||||
interface WallItem {
|
interface WallItem {
|
||||||
type: "Fixed-Move" | "Free-Move" | undefined;
|
type: "Fixed-Move" | "Free-Move" | undefined;
|
||||||
model?: THREE.Group;
|
model?: THREE.Group;
|
||||||
modeluuid?: string;
|
modelUuid?: string;
|
||||||
modelname?: string;
|
modelName?: string;
|
||||||
scale?: [number, number, number];
|
scale?: [number, number, number];
|
||||||
csgscale?: [number, number, number];
|
csgscale?: [number, number, number];
|
||||||
csgposition?: [number, number, number];
|
csgposition?: [number, number, number];
|
||||||
|
|||||||
Reference in New Issue
Block a user