Refactor floor management APIs: implement getFloorsApi, deleteFloorApi, and upsertFloorApi for enhanced floor data handling. Update FloorCreator for improved point snapping and floor creation logic. Modify ReferencePoint to include UUID and user data. Adjust usePointSnapping to handle temporary points more effectively.
This commit is contained in:
@@ -18,7 +18,7 @@ function FloorCreator() {
|
||||
const { addFloor, removeDecal, getFloorPointById, getFloorByPoints } = floorStore();
|
||||
const drag = useRef(false);
|
||||
const isLeftMouseDown = useRef(false);
|
||||
|
||||
|
||||
const [tempPoints, setTempPoints] = useState<Point[]>([]);
|
||||
const [isCreating, setIsCreating] = useState(false);
|
||||
const { floorDepth, isBeveled, bevelStrength, sideMaterial, topMaterial, snappedPosition, snappedPoint } = useBuilderStore();
|
||||
@@ -80,30 +80,34 @@ function FloorCreator() {
|
||||
newPoint.position = snappedPosition;
|
||||
}
|
||||
|
||||
if (pointIntersects && !snappedPoint) {
|
||||
if (tempPoints.length > 2 && isCreating && pointIntersects.object.userData.pointUuid === tempPoints[0].pointUuid) {
|
||||
if (tempPoints.length >= 3) {
|
||||
const floor: Floor = {
|
||||
floorUuid: THREE.MathUtils.generateUUID(),
|
||||
points: tempPoints,
|
||||
topMaterial,
|
||||
sideMaterial,
|
||||
floorDepth,
|
||||
isBeveled,
|
||||
bevelStrength,
|
||||
decals: [],
|
||||
};
|
||||
if (pointIntersects) {
|
||||
if (tempPoints.length > 2 && isCreating && pointIntersects.object.uuid === tempPoints[0].pointUuid) {
|
||||
const floor: Floor = {
|
||||
floorUuid: THREE.MathUtils.generateUUID(),
|
||||
points: tempPoints,
|
||||
topMaterial,
|
||||
sideMaterial,
|
||||
floorDepth,
|
||||
isBeveled,
|
||||
bevelStrength,
|
||||
decals: [],
|
||||
};
|
||||
|
||||
addFloor(floor);
|
||||
}
|
||||
addFloor(floor);
|
||||
setTempPoints([]);
|
||||
setIsCreating(false);
|
||||
} else if (tempPoints.length === 0) {
|
||||
tempPoints.push(pointIntersects.object.userData as Point);
|
||||
setIsCreating(true);
|
||||
} else {
|
||||
setTempPoints([]);
|
||||
setIsCreating(false);
|
||||
}
|
||||
} else {
|
||||
setTempPoints(prev => [...prev, newPoint]);
|
||||
setIsCreating(true);
|
||||
}
|
||||
|
||||
setTempPoints(prev => [...prev, newPoint]);
|
||||
setIsCreating(true);
|
||||
|
||||
};
|
||||
|
||||
const onContext = (event: any) => {
|
||||
@@ -157,7 +161,7 @@ function FloorCreator() {
|
||||
<>
|
||||
{toggleView &&
|
||||
<>
|
||||
<group name='Wall-Reference-Points-Group'>
|
||||
<group name='Floor-Reference-Points-Group'>
|
||||
{tempPoints.map((point) => (
|
||||
<ReferencePoint key={point.pointUuid} point={point} />
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user