bug fix on shortcuts and polygon

This commit is contained in:
2025-09-15 11:52:00 +05:30
parent 304364eb65
commit b6c9d3b57d
5 changed files with 40 additions and 40 deletions

View File

@@ -17,16 +17,16 @@ function Floor2DInstance({ floor }: { readonly floor: Floor }) {
const centroid: [number, number, number] = useMemo(() => { const centroid: [number, number, number] = useMemo(() => {
const center = getCenteroidPoint(points2D); const center = getCenteroidPoint(points2D);
if (!center) return [0, Constants.floorConfig.height + 0.01, 0]; if (!center) return [0, Constants.floorConfig.height, 0];
return [center.x, Constants.floorConfig.height + 0.01, center.y] as [number, number, number]; return [center.x, Constants.floorConfig.height, center.y] as [number, number, number];
}, [points2D]); }, [points2D]);
const formattedArea = `${area.toFixed(2)}`; const formattedArea = `${area.toFixed(2)}`;
return ( return (
<> <>
<ExtrudePolygon castShadow receiveShadow name={`Floor-2D-${floor.floorUuid}`} points={floor.points} options={{ depth: 0, bevelEnabled: false }} userData={floor}> <ExtrudePolygon castShadow receiveShadow name={`Floor-2D-${floor.floorUuid}`} position={[0, 0.05, 0]} points={floor.points} options={{ depth: 0, bevelEnabled: false }} userData={floor}>
<meshBasicMaterial color={savedTheme === "dark" ? Constants.lineConfig.floorColor : Constants.lineConfig.floorColor} side={DoubleSide} transparent opacity={0.4} depthWrite={false} /> <meshBasicMaterial color={savedTheme === "dark" ? Constants.lineConfig.floorColor : Constants.lineConfig.floorColor} side={DoubleSide} transparent opacity={0.4} depthWrite={false} />
</ExtrudePolygon> </ExtrudePolygon>

View File

@@ -154,16 +154,16 @@ function Floor2D({ room }: { readonly room: Point[] }) {
const centroid: [number, number, number] = useMemo(() => { const centroid: [number, number, number] = useMemo(() => {
const center = getCenteroidPoint(points2D); const center = getCenteroidPoint(points2D);
if (!center) return [0, Constants.floorConfig.height + 0.01, 0]; if (!center) return [0, Constants.floorConfig.height, 0];
return [center.x, Constants.floorConfig.height + 0.01, center.y] as [number, number, number]; return [center.x, Constants.floorConfig.height, center.y] as [number, number, number];
}, [points2D]); }, [points2D]);
const formattedArea = `${area.toFixed(2)}`; const formattedArea = `${area.toFixed(2)}`;
return ( return (
<> <>
<ExtrudePolygon points={room} receiveShadow castShadow name="Wall-Floor" options={{ depth: 0, bevelEnabled: false }}> <ExtrudePolygon points={room} receiveShadow castShadow name="Wall-Floor" position={[0, 0.05, 0]} options={{ depth: 0, bevelEnabled: false }}>
<meshBasicMaterial color={savedTheme === "dark" ? Constants.lineConfig.wallColor : Constants.lineConfig.wallColor} side={DoubleSide} transparent opacity={0.4} depthWrite={false} /> <meshBasicMaterial color={savedTheme === "dark" ? Constants.lineConfig.wallColor : Constants.lineConfig.wallColor} side={DoubleSide} transparent opacity={0.4} depthWrite={false} />
</ExtrudePolygon> </ExtrudePolygon>

View File

@@ -17,16 +17,16 @@ function Zone2DInstance({ zone }: { readonly zone: Zone }) {
const centroid: [number, number, number] = useMemo(() => { const centroid: [number, number, number] = useMemo(() => {
const center = getCenteroid(points2D); const center = getCenteroid(points2D);
if (!center) return [0, Constants.floorConfig.height + 0.01, 0]; if (!center) return [0, Constants.floorConfig.height, 0];
return [center.x, Constants.floorConfig.height + 0.01, center.y] as [number, number, number]; return [center.x, Constants.floorConfig.height, center.y] as [number, number, number];
}, [points2D]); }, [points2D]);
const formattedArea = `${area.toFixed(2)}`; const formattedArea = `${area.toFixed(2)}`;
return ( return (
<> <>
<ExtrudePolygon points={zone.points} options={{ depth: 0, bevelEnabled: false }} castShadow receiveShadow name={`Zone-2D-${zone.zoneUuid}`} userData={zone}> <ExtrudePolygon points={zone.points} options={{ depth: 0, bevelEnabled: false }} position={[0, 0.05, 0]} castShadow receiveShadow name={`Zone-2D-${zone.zoneUuid}`} userData={zone}>
<meshBasicMaterial color={savedTheme === "dark" ? Constants.lineConfig.zoneColor : Constants.lineConfig.zoneColor} side={DoubleSide} transparent opacity={0.4} depthWrite={false} /> <meshBasicMaterial color={savedTheme === "dark" ? Constants.lineConfig.zoneColor : Constants.lineConfig.zoneColor} side={DoubleSide} transparent opacity={0.4} depthWrite={false} />
</ExtrudePolygon> </ExtrudePolygon>

View File

@@ -1,35 +1,35 @@
// Function to detect if Shift, Ctrl, Alt, or combinations are pressed // Function to detect if Shift, Ctrl, Alt, or combinations are pressed
// and return the corresponding key combination string // and return the corresponding key combination string
export const detectModifierKeys = (event: KeyboardEvent): string => { export const detectModifierKeys = (event: KeyboardEvent): string => {
const modifiers = [ const modifiers = [
event.ctrlKey ? "Ctrl" : "", event.ctrlKey ? "Ctrl" : "",
event.altKey ? "Alt" : "", event.altKey ? "Alt" : "",
event.shiftKey ? "Shift" : "", event.shiftKey ? "Shift" : "",
event.metaKey ? "Meta" : "", // Add support for Command/Win key event.metaKey ? "Meta" : "", // Add support for Command/Win key
].filter(Boolean); ].filter(Boolean);
// Ignore modifier keys when they're pressed alone // Ignore modifier keys when they're pressed alone
const isModifierKey = [ const isModifierKey = [
"Control", "Control",
"Shift", "Shift",
"Alt", "Alt",
"Meta", "Meta",
"Ctrl", "Ctrl",
"AltGraph", "AltGraph",
"OS", // Additional modifier key aliases "OS", // Additional modifier key aliases
].includes(event.key); ].includes(event.key);
const mainKey = isModifierKey ? "" : event.key.toUpperCase(); const mainKey = isModifierKey ? "" : event.key.toUpperCase();
// Handle special cases for keys with different representations // Handle special cases for keys with different representations
const normalizedKey = mainKey === " " ? "Space" : mainKey; const normalizedKey = mainKey === " " ? "Space" : mainKey;
// Build the combination string // Build the combination string
if (modifiers.length > 0 && normalizedKey) { if (modifiers.length > 0 && normalizedKey) {
return `${modifiers.join("+")}+${normalizedKey}`; return `${modifiers.join("+")}+${normalizedKey}`;
} else if (modifiers.length > 0) { } else if (modifiers.length > 0) {
return modifiers.join("+"); return modifiers.join("+");
} else { } else {
return normalizedKey; return normalizedKey;
} }
}; };

View File

@@ -96,13 +96,13 @@ const KeyPressListener: React.FC = () => {
// These should only apply in 2D view // These should only apply in 2D view
const twoDToolConfigs: Record<string, { tool: string; mode: string }> = { const twoDToolConfigs: Record<string, { tool: string; mode: string }> = {
Q: { tool: "draw-wall", mode: "Wall" }, Q: { tool: "draw-wall", mode: "Wall" },
"6": { tool: "draw-wall", mode: "Wall" }, // "6": { tool: "draw-wall", mode: "Wall" },
R: { tool: "draw-aisle", mode: "Aisle" }, R: { tool: "draw-aisle", mode: "Aisle" },
"7": { tool: "draw-aisle", mode: "Aisle" }, // "7": { tool: "draw-aisle", mode: "Aisle" },
E: { tool: "draw-zone", mode: "Zone" }, E: { tool: "draw-zone", mode: "Zone" },
"8": { tool: "draw-zone", mode: "Zone" }, // "8": { tool: "draw-zone", mode: "Zone" },
T: { tool: "draw-floor", mode: "Floor" }, T: { tool: "draw-floor", mode: "Floor" },
"9": { tool: "draw-floor", mode: "Floor" }, // "9": { tool: "draw-floor", mode: "Floor" },
}; };
const config = twoDToolConfigs[key]; const config = twoDToolConfigs[key];