feat: update PointsCreator to include getPointByUuidFromProduct and enhance point state management
This commit is contained in:
parent
542faf5ea9
commit
88d6c48c1d
|
@ -15,7 +15,7 @@ function PointsCreator() {
|
|||
const { gl, raycaster, scene, pointer, camera } = useThree();
|
||||
const { subModule } = useSubModuleStore();
|
||||
const { events, updatePoint, getPointByUuid, getEventByModelUuid } = useEventsStore();
|
||||
const { getEventByModelUuid: getEventByModelUuidFromProduct, updatePoint: updatePointFromProduct, getEventByModelUuid: getEventByModelUuidFromProduct2 } = useProductStore();
|
||||
const { getEventByModelUuid: getEventByModelUuidFromProduct, updatePoint: updatePointFromProduct, getEventByModelUuid: getEventByModelUuidFromProduct2, getPointByUuid: getPointByUuidFromProduct } = useProductStore();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
const { activeModule } = useModuleStore();
|
||||
const transformRef = useRef<any>(null);
|
||||
|
@ -76,7 +76,7 @@ function PointsCreator() {
|
|||
}, [selectedEventSphere]);
|
||||
|
||||
const updatePointToState = (selectedEventSphere: THREE.Mesh) => {
|
||||
let point = JSON.parse(
|
||||
let point: PointsScheme = JSON.parse(
|
||||
JSON.stringify(
|
||||
getPointByUuid(
|
||||
selectedEventSphere.userData.modelUuid,
|
||||
|
@ -90,28 +90,44 @@ function PointsCreator() {
|
|||
selectedEventSphere.position.y,
|
||||
selectedEventSphere.position.z,
|
||||
];
|
||||
point.rotation = [
|
||||
selectedEventSphere.rotation.x,
|
||||
selectedEventSphere.rotation.y,
|
||||
selectedEventSphere.rotation.z,
|
||||
];
|
||||
|
||||
const event = getEventByModelUuidFromProduct(selectedProduct.productId, selectedEventSphere.userData.modelUuid);
|
||||
|
||||
if (event && selectedProduct.productId !== '') {
|
||||
const updatedEvent = updatePointFromProduct(
|
||||
selectedProduct.productId,
|
||||
selectedEventSphere.userData.modelUuid,
|
||||
selectedEventSphere.userData.pointUuid,
|
||||
point
|
||||
)
|
||||
if (updatedEvent) {
|
||||
updatePoint(
|
||||
|
||||
const updatedPoint = JSON.parse(
|
||||
JSON.stringify(
|
||||
getPointByUuidFromProduct(selectedProduct.productId, selectedEventSphere.userData.modelUuid, selectedEventSphere.userData.pointUuid)
|
||||
)
|
||||
);
|
||||
if (updatedPoint) {
|
||||
updatedPoint.position = point.position;
|
||||
updatedPoint.rotation = point.rotation;
|
||||
|
||||
const updatedEvent = updatePointFromProduct(
|
||||
selectedProduct.productId,
|
||||
selectedEventSphere.userData.modelUuid,
|
||||
selectedEventSphere.userData.pointUuid,
|
||||
point
|
||||
updatedPoint
|
||||
)
|
||||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productId,
|
||||
organization,
|
||||
updatedEvent
|
||||
);
|
||||
if (updatedEvent) {
|
||||
updatePoint(
|
||||
selectedEventSphere.userData.modelUuid,
|
||||
selectedEventSphere.userData.pointUuid,
|
||||
point
|
||||
)
|
||||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productId,
|
||||
organization,
|
||||
updatedEvent
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue