2d undo redo bug fix

This commit is contained in:
2025-08-23 15:27:17 +05:30
parent 51a5805756
commit e3bd30743d
8 changed files with 153 additions and 24 deletions

View File

@@ -66,7 +66,7 @@ function MoveControls2D({
const onPointerUp = (event: PointerEvent) => {
if (!isMoving && movedObjects.length > 0 && event.button === 0) {
event.preventDefault();
placeMovedAssets();
placeMovedPoints();
}
if (!isMoving && movedObjects.length > 0 && event.button === 2) {
event.preventDefault();
@@ -180,6 +180,7 @@ function MoveControls2D({
const positions: Record<string, THREE.Vector3> = {};
selectedPoints.forEach((point: THREE.Object3D) => { positions[point.uuid] = new THREE.Vector3().copy(point.position); });
console.log('positions: ', positions);
setInitialPositions(positions);
raycaster.setFromCamera(pointer, camera);
@@ -221,7 +222,7 @@ function MoveControls2D({
}, 0)
};
const placeMovedAssets = () => {
const placeMovedPoints = () => {
if (movedObjects.length === 0) return;
const undoPoints: UndoRedo2DDataTypeSchema[] = [];
@@ -262,11 +263,11 @@ function MoveControls2D({
lineData: {
...updatedAisle,
points: [
updatedAisle.points[0].pointUuid === point.pointUuid
? { ...updatedAisle.points[0], position: [old.position.x, old.position.y, old.position.z] }
initialStates[updatedAisle.points[0].pointUuid] ?
{ ...updatedAisle.points[0], position: initialStates[updatedAisle.points[0].pointUuid].position }
: updatedAisle.points[0],
updatedAisle.points[1].pointUuid === point.pointUuid
? { ...updatedAisle.points[1], position: [old.position.x, old.position.y, old.position.z] }
initialStates[updatedAisle.points[1].pointUuid] ?
{ ...updatedAisle.points[1], position: initialStates[updatedAisle.points[1].pointUuid].position }
: updatedAisle.points[1]
] as [Point, Point],
},
@@ -302,11 +303,11 @@ function MoveControls2D({
lineData: {
...updatedWall,
points: [
updatedWall.points[0].pointUuid === point.pointUuid
? { ...updatedWall.points[0], position: [old.position.x, old.position.y, old.position.z] }
initialStates[updatedWall.points[0].pointUuid] ?
{ ...updatedWall.points[0], position: initialStates[updatedWall.points[0].pointUuid].position }
: updatedWall.points[0],
updatedWall.points[1].pointUuid === point.pointUuid
? { ...updatedWall.points[1], position: [old.position.x, old.position.y, old.position.z] }
initialStates[updatedWall.points[1].pointUuid] ?
{ ...updatedWall.points[1], position: initialStates[updatedWall.points[1].pointUuid].position }
: updatedWall.points[1]
] as [Point, Point],
},