05ccebad8d
- Restore TS frontend source (canvas, tools, CRDT, components, services) - Keep 5 JSX components that TS code depends on (CADCanvas, LayerPanel, BlockLibrary, PluginRegistry, Toolbar) - Keep JS services (api.js, blockService.js) that components depend on - Fix vite/plugin-react version mismatch (downgrade to v4 for vite 6) - Add axios dependency - Skip tsc in build script (vite/esbuild handles transpilation) - Fix index.html lang=de, favicon path - Add vite proxy config for /api and /ws - Backend unchanged (already from deployed containers)
87 lines
2.2 KiB
TypeScript
87 lines
2.2 KiB
TypeScript
class SnapEngine {
|
|
private isEnabled: boolean;
|
|
private gridSize: number;
|
|
private tolerance: number;
|
|
private activeZoom: number;
|
|
|
|
constructor(gridSize: number = 10) {
|
|
this.isEnabled = true;
|
|
this.gridSize = gridSize;
|
|
this.tolerance = 5;
|
|
this.activeZoom = 1;
|
|
}
|
|
|
|
// Toggle snap on/off with F3
|
|
toggleSnap(): void {
|
|
this.isEnabled = !this.isEnabled;
|
|
}
|
|
|
|
// Set active zoom level
|
|
setZoom(zoom: number): void {
|
|
this.activeZoom = zoom;
|
|
}
|
|
|
|
// Snap to grid
|
|
snapToGrid(x: number, y: number): {x: number, y: number} | null {
|
|
if (!this.isEnabled) return null;
|
|
// Implementation for snap to grid
|
|
return null;
|
|
}
|
|
|
|
// Snap to endpoint
|
|
snapToEndpoint(x: number, y: number): {x: number, y: number} | null {
|
|
if (!this.isEnabled) return null;
|
|
// Implementation for snap to endpoint
|
|
return null;
|
|
}
|
|
|
|
// Snap to midpoint
|
|
snapToMidpoint(x: number, y: number): {x: number, y: number} | null {
|
|
if (!this.isEnabled) return null;
|
|
// Implementation for snap to midpoint
|
|
return null;
|
|
}
|
|
|
|
// Snap to center
|
|
snapToCenter(x: number, y: number): {x: number, y: number} | null {
|
|
if (!this.isEnabled) return null;
|
|
// Implementation for snap to center
|
|
return null;
|
|
}
|
|
|
|
// Snap to intersection
|
|
snapToIntersection(x: number, y: number): {x: number, y: number} | null {
|
|
if (!this.isEnabled) return null;
|
|
// Implementation for snap to intersection
|
|
return null;
|
|
}
|
|
|
|
// Snap to perpendicular
|
|
snapToPerpendicular(x: number, y: number): {x: number, y: number} | null {
|
|
if (!this.isEnabled) return null;
|
|
// Implementation for snap to perpendicular
|
|
return null;
|
|
}
|
|
|
|
// Snap to tangent
|
|
snapToTangent(x: number, y: number): {x: number, y: number} | null {
|
|
if (!this.isEnabled) return null;
|
|
// Implementation for snap to tangent
|
|
return null;
|
|
}
|
|
|
|
// Snap to nearest
|
|
snapToNearest(x: number, y: number): {x: number, y: number} | null {
|
|
if (!this.isEnabled) return null;
|
|
// Implementation for snap to nearest
|
|
return null;
|
|
}
|
|
|
|
// Render visual snap markers on canvas
|
|
renderSnapMarkers(context: CanvasRenderingContext2D): void {
|
|
// Implementation for rendering snap markers
|
|
}
|
|
}
|
|
|
|
export default SnapEngine;
|