- Removed CalculateAreaGroup and computeArea function as they were no longer needed. - Updated Floor2DInstance and Zone2DInstance to calculate area and centroid using new utility functions. - Refactored WallInstances to include Floor2D rendering and improved area display. - Cleaned up imports and ensured consistent formatting across files. - Enhanced performance by memoizing calculations for area and centroid. - Removed deprecated state management for rooms and version history visibility.
11 lines
309 B
TypeScript
11 lines
309 B
TypeScript
import { Vector2 } from "three";
|
|
|
|
export default function getArea(points: Vector2[]): number {
|
|
let sum = 0;
|
|
for (let i = 0; i < points.length; i++) {
|
|
const j = (i + 1) % points.length;
|
|
sum += points[i].x * points[j].y - points[j].x * points[i].y;
|
|
}
|
|
return Math.abs(sum / 2);
|
|
}
|