-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Open
Description
Description
Currently, ShapeUtils.triangulateShape internally calls removeDupEndPts, which relies on Vector2.equals. This introduces a strong coupling to Vector2 instances, forcing users to instantiate potentially large numbers of Vector2 objects just to perform triangulation.
Ideally, triangulateShape should accept inputs adhering to the Vector2Like type ({ readonly x: number; readonly y: number; }) and avoid depending on Vector2.equals. This would allow users to pass plain objects without creating Vector2 instances, improving performance and reducing memory overhead in high-vertex-count scenarios.
Proposed solution
- Allow
triangulateShapeto acceptVector2Likeobjects. - Replace
Vector2.equalschecks inremoveDupEndPtswith a simple value comparison (v1.x === v2.x && v1.y === v2.y).
Reproduction steps
none
Code
const contour: Vector2Like[] = [];
const holes: Vector2Like[][] = [];
ShapeUtils.triangulateShape(contour, holes)Live example
none
Screenshots
No response
Version
r181
Device
No response
Browser
No response
OS
No response
Metadata
Metadata
Assignees
Labels
No labels