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 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]);
const formattedArea = `${area.toFixed(2)}`;
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} />
</ExtrudePolygon>

View File

@@ -154,16 +154,16 @@ function Floor2D({ room }: { readonly room: Point[] }) {
const centroid: [number, number, number] = useMemo(() => {
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]);
const formattedArea = `${area.toFixed(2)}`;
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} />
</ExtrudePolygon>

View File

@@ -17,16 +17,16 @@ function Zone2DInstance({ zone }: { readonly zone: Zone }) {
const centroid: [number, number, number] = useMemo(() => {
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]);
const formattedArea = `${area.toFixed(2)}`;
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} />
</ExtrudePolygon>

View File

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

View File

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