refactor: Update color scheme for Floor and Zone components; enhance snapping logic in ReferenceFloor and ReferenceZone

This commit is contained in:
2025-06-30 12:54:25 +05:30
parent 7124a819b6
commit 943ad3ba49
7 changed files with 13 additions and 8 deletions

View File

@@ -36,7 +36,7 @@ function Floor2DInstance({ floor }: { floor: Floor }) {
userData={floor} userData={floor}
> >
<meshBasicMaterial <meshBasicMaterial
color={savedTheme === "dark" ? "#d2baff" : "#6f42c1"} color={savedTheme === "dark" ? "#808080" : "#808080"}
side={DoubleSide} side={DoubleSide}
transparent transparent
opacity={0.4} opacity={0.4}

View File

@@ -25,7 +25,7 @@ function ReferenceFloor({ tempPoints }: Readonly<ReferenceFloorProps>) {
const [currentPosition, setCurrentPosition] = useState<[number, number, number]>(tempPoints[0]?.position); const [currentPosition, setCurrentPosition] = useState<[number, number, number]>(tempPoints[0]?.position);
const directionalSnap = useDirectionalSnapping(currentPosition, tempPoints[tempPoints.length - 1]?.position || null); const directionalSnap = useDirectionalSnapping(currentPosition, tempPoints[tempPoints.length - 1]?.position || null);
const { snapFloorPoint } = usePointSnapping({ uuid: 'temp-floor', pointType: 'Floor', position: directionalSnap.position || [0, 0, 0], }); const { snapFloorPoint } = usePointSnapping({ uuid: 'temp-Floor', pointType: 'Floor', position: directionalSnap.position || [0, 0, 0], });
useFrame(() => { useFrame(() => {
if (toolMode === 'Floor' && toggleView && tempPoints.length > 0) { if (toolMode === 'Floor' && toggleView && tempPoints.length > 0) {
@@ -36,7 +36,7 @@ function ReferenceFloor({ tempPoints }: Readonly<ReferenceFloorProps>) {
setCurrentPosition([intersectionPoint.x, intersectionPoint.y, intersectionPoint.z]); setCurrentPosition([intersectionPoint.x, intersectionPoint.y, intersectionPoint.z]);
if (!intersectionPoint) return; if (!intersectionPoint) return;
const snapped = snapFloorPoint([intersectionPoint.x, intersectionPoint.y, intersectionPoint.z], [tempPoints[0]]); const snapped = snapFloorPoint([intersectionPoint.x, intersectionPoint.y, intersectionPoint.z], tempPoints.length > 2 ? [tempPoints[0]] : []);
if (snapped.isSnapped && snapped.snappedPoint) { if (snapped.isSnapped && snapped.snappedPoint) {
finalPosition.current = snapped.position; finalPosition.current = snapped.position;
@@ -158,7 +158,7 @@ function Floor({ floor }: { floor: Point[] }) {
position={[0, 0, 0]} position={[0, 0, 0]}
receiveShadow receiveShadow
> >
<meshStandardMaterial color={savedTheme === "dark" ? "#d2baff" : "#6f42c1"} depthWrite={false} transparent opacity={0.3} side={THREE.DoubleSide} /> <meshStandardMaterial color={savedTheme === "dark" ? "#808080" : "#808080"} depthWrite={false} transparent opacity={0.3} side={THREE.DoubleSide} />
</Extrude> </Extrude>
</group> </group>
); );

View File

@@ -131,7 +131,7 @@ function Point({ point }: { readonly point: Point }) {
const finalSnapped = snapFloorPoint(floorSnapped.position); const finalSnapped = snapFloorPoint(floorSnapped.position);
setFloorPosition(point.pointUuid, finalSnapped.position); setFloorPosition(point.pointUuid, finalSnapped.position);
} else if (point.pointType === 'Zone') { } else if (point.pointType === 'Zone') {
const zoneSnapped = snapAisleAngle(newPosition); const zoneSnapped = snapZoneAngle(newPosition);
const finalSnapped = snapZonePoint(zoneSnapped.position); const finalSnapped = snapZonePoint(zoneSnapped.position);
setZonePosition(point.pointUuid, finalSnapped.position); setZonePosition(point.pointUuid, finalSnapped.position);
} }

View File

@@ -36,7 +36,7 @@ function Zone2DInstance({ zone }: { zone: Zone }) {
userData={zone} userData={zone}
> >
<meshBasicMaterial <meshBasicMaterial
color={savedTheme === "dark" ? "green" : "green"} color={savedTheme === "dark" ? "#007BFF" : "#007BFF"}
side={DoubleSide} side={DoubleSide}
transparent transparent
opacity={0.4} opacity={0.4}

View File

@@ -13,6 +13,10 @@ function ZoneInstances() {
const { zones } = zoneStore(); const { zones } = zoneStore();
const { toggleView } = useToggleView(); const { toggleView } = useToggleView();
useEffect(() => {
// console.log('zones: ', zones);
}, [zones])
const allPoints = useMemo(() => { const allPoints = useMemo(() => {
const points: Point[] = []; const points: Point[] = [];
const seenUuids = new Set<string>(); const seenUuids = new Set<string>();

View File

@@ -36,7 +36,7 @@ function ReferenceZone({ tempPoints }: Readonly<ReferenceZoneProps>) {
setCurrentPosition([intersectionPoint.x, intersectionPoint.y, intersectionPoint.z]); setCurrentPosition([intersectionPoint.x, intersectionPoint.y, intersectionPoint.z]);
if (!intersectionPoint) return; if (!intersectionPoint) return;
const snapped = snapZonePoint([intersectionPoint.x, intersectionPoint.y, intersectionPoint.z], [tempPoints[0]]); const snapped = snapZonePoint([intersectionPoint.x, intersectionPoint.y, intersectionPoint.z], tempPoints.length > 2 ? [tempPoints[0]] : []);
if (snapped.isSnapped && snapped.snappedPoint) { if (snapped.isSnapped && snapped.snappedPoint) {
finalPosition.current = snapped.position; finalPosition.current = snapped.position;
@@ -156,7 +156,7 @@ function Zone({ zone }: { zone: Point[] }) {
position={[0, 0, 0]} position={[0, 0, 0]}
receiveShadow receiveShadow
> >
<meshStandardMaterial color={savedTheme === "dark" ? "#d2baff" : "#6f42c1"} depthWrite={false} transparent opacity={0.3} side={THREE.DoubleSide} /> <meshStandardMaterial color={savedTheme === "dark" ? "#007BFF" : "#007BFF"} depthWrite={false} transparent opacity={0.3} side={THREE.DoubleSide} />
</Extrude> </Extrude>
</group> </group>
); );

View File

@@ -29,6 +29,7 @@ function ZoneGroup() {
useEffect(() => { useEffect(() => {
if (projectId && selectedVersion) { if (projectId && selectedVersion) {
getZonesApi(projectId, selectedVersion?.versionId || '').then((zones) => { getZonesApi(projectId, selectedVersion?.versionId || '').then((zones) => {
console.log('zones: ', zones);
if (zones && zones.length > 0) { if (zones && zones.length > 0) {
setZones(zones); setZones(zones);
} else { } else {