Widget 3d position & rotation update, delete

This commit is contained in:
2025-04-04 18:32:19 +05:30
parent c76886cab1
commit 35d4268a72
5 changed files with 45 additions and 159 deletions

View File

@@ -42,46 +42,6 @@ export class assetsFloorservice {
);
return res.status(201).json(updatevalue);
} else {
// const validateConveyorPoint = (point: any): boolean => {
// return (
// Array.isArray(point?.rotation) &&
// Array.isArray(point?.actions) &&
// Array.isArray(point?.triggers)
// // point.actions.every(
// // (action: any) => action.uuid && action.name && action.type
// // ) &&
// // (!point.triggers ||
// // point.triggers.every(
// // (trigger: any) =>
// // trigger.uuid &&
// // trigger.name &&
// // trigger.type &&
// // trigger.bufferTime !== undefined
// // ))
// );
// };
// const validateVehiclePoint = (point: any): boolean => {
// return (
// !point.rotation &&
// Array.isArray(point?.actions) &&
// Array.isArray(point?.triggers)
// // point.actions.every(
// // (action: any) =>
// // action.uuid &&
// // action.name &&
// // action.type &&
// // action.hitCount !== undefined &&
// // action.start !== undefined &&
// // action.end !== undefined &&
// // action.buffer !== undefined
// // ) &&
// // (!point.triggers ||
// // point.triggers.every(
// // (trigger: any) => trigger.uuid && trigger.name && trigger.type
// // ))
// );
// };
let assetData: any = {
modeluuid,
modelname,
@@ -94,24 +54,8 @@ export class assetsFloorservice {
console.log("eventData: ", eventData);
if (eventData) {
// console.log("checkpointType?.type: ", checkpointType?.type);
// console.log("eventData.typ: ", eventData.type);
// if (checkpointType?.type !== eventData.type) {
// return res.send("Type mismatch");
// }
if (eventData.type === "Conveyor") {
assetData.speed = eventData.speed;
// console.log("eventData.points: ", typeof eventData.points);
// if (!Array.isArray(eventData.points) || eventData.points) {
// return res
// .status(400)
// .json({ message: "Points must be an array" });
// }
// if (!eventData.points.every(validateConveyorPoint)) {
// return res
// .status(400)
// .json({ message: "Invalid Conveyor point structure" });
// }
} else if (eventData.type === "Vehicle") {
assetData.speed = eventData.points.speed;
if (!eventData.points) {
@@ -119,7 +63,6 @@ export class assetsFloorservice {
.status(400)
.json({ message: "Vehicle points must be a single object" });
}
// if(eventData.poin)
if (eventData.points.rotation) {
return res.status(400).json({
message: "Rotation is not allowed for Vehicle points",
@@ -136,66 +79,6 @@ export class assetsFloorservice {
assetData.points = eventData.points;
assetData.type = eventData.type;
}
// if (eventData) {
// let pointRefs: any[] = [];
// if (Array.isArray(eventData.points)) {
// for (const point of eventData.points) {
// let actionRefs: any[] = [];
// let triggerRefs: any[] = [];
// if (Array.isArray(point.actions)) {
// for (const action of point.actions) {
// const actionDoc = await actionModel(organization).create({
// pointsUUID: point.uuid,
// isArchive: false,
// uuid: action.uuid,
// name: action.name,
// type: action.type,
// material: action.material,
// delay: action.delay,
// spawn_Interval: action.spawn_Interval,
// });
// await actionDoc.save();
// actionRefs.push(actionDoc._id);
// }
// }
// if (Array.isArray(point.triggers)) {
// for (const trigger of point.triggers) {
// const triggerDoc = await triggerModel(organization).create({
// pointsUUID: point.uuid,
// isArchive: false,
// uuid: trigger.uuid,
// name: trigger.name,
// type: trigger.type,
// bufferTime: trigger.bufferTime,
// });
// await triggerDoc.save();
// triggerRefs.push(triggerDoc._id);
// }
// }
// // point.connections{
// // source:{
// // }
// // }
// pointRefs.push({
// uuid: point.uuid,
// position: point.position || [],
// rotation: point.rotation || [],
// actions: actionRefs,
// triggers: triggerRefs,
// connections: point.connections,
// });
// }
// }
// assetData.speed = eventData.speed;
// assetData.type = eventData.type;
// assetData.points = pointRefs;
// }
const assetDoc = await assetModel(organization).create(assetData);
await assetDoc.save();
@@ -204,9 +87,6 @@ export class assetsFloorservice {
modelId: assetDoc._id,
});
}
// } else {
// return res.json({ message: "Type not matched" });
// }
} catch (error) {
console.error("Error creating flooritems:", error);
res.status(500).json({ message: "Failed to create flooritems" });
@@ -224,8 +104,8 @@ export class assetsFloorservice {
}
const response = findValues.map((item) => {
console.log("item: ", item);
console.log("item: ", item.type);
// console.log("item: ", item);
// console.log("item: ", item.type);
// console.log('findValues: ', findValues);
// console.log("item.points: ", item.points);
const responseItem: any = {
@@ -329,16 +209,11 @@ export class assetsFloorservice {
if (existingModel.type === "Conveyor") {
speed = eventData?.speed;
}
// if (existingModel.type === "Vehicle") {
// speed = eventData?.points?.speed;
// }
const updatedModel = await assetModel(organization).findOneAndUpdate(
{ modeluuid, isArchive: false },
{
points: eventData?.points,
// speed: speed,
type: eventData?.type || existingModel?.type,
},
{ new: true }
);