editor › Globals › CSGPolygonUtils
Class: CSGPolygonUtils
A collection of conversion related utils, mostly used for CSG. When methods are unused, they may still be used in the CSG server. Quite coupled to editor stuff, therefore not in kyutils.
Hierarchy
- CSGPolygonUtils
Index
Methods
- arrayPointPolygon3DToVectorPolygon3D
- arrayPointToVector3
- convertHalfEdgeCycle2DToNumberCycle2D
- convertNumberCycle2DToHalfEdgeCycle2D
- getPlaneForCCWCycle
- getPlaneForSurface
- getPlaneForVectorPolygon
- numberCycleContainsAllNumberHoles
- numberCycleContainsOtherNumberCycle
- polygonToVectorPolygon2D
- polygonToVectorPolygon3D
- vectorPolygon2DToVectorPolygon3D
- vectorPolygon3DToArrayPointPolygon3D
- vectorPolygon3DToPolygon
- vectorPolygon3DToVectorPolygon2D
Methods
Static arrayPointPolygon3DToVectorPolygon3D
▸ arrayPointPolygon3DToVectorPolygon3D(numberPolygon: ArrayPointPolygon3D): Vector3[][]
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:73
Parameters:
| Name | Type |
|---|---|
numberPolygon |
ArrayPointPolygon3D |
Returns: Vector3[][]
Static arrayPointToVector3
▸ arrayPointToVector3(point: ArrayPoint2 | ArrayPoint3): Vector3
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:128
Converts an ArrayPoint2 or ArrayPoint3 into a Vector3 without doing any projections
Parameters:
| Name | Type | Description |
|---|---|---|
point |
ArrayPoint2 | ArrayPoint3 | to convert to Vector3 |
Returns: Vector3
Static convertHalfEdgeCycle2DToNumberCycle2D
▸ convertHalfEdgeCycle2DToNumberCycle2D(cycle: MeshHalfEdge[]): ArrayPoint2[]
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:117
Return an array of 2D points in array form.
Parameters:
| Name | Type |
|---|---|
cycle |
MeshHalfEdge[] |
Returns: ArrayPoint2[]
Static convertNumberCycle2DToHalfEdgeCycle2D
▸ convertNumberCycle2DToHalfEdgeCycle2D(cycle: ArrayPoint2[]): MeshHalfEdge[]
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:110
Return a cycles of halfedges where points.z = 0.
Parameters:
| Name | Type |
|---|---|
cycle |
ArrayPoint2[] |
Returns: MeshHalfEdge[]
Static getPlaneForCCWCycle
▸ getPlaneForCCWCycle(cycle: ReadonlyVectorCycle3D, allPoints: ReadonlyVector3[], plane?: any): IPlane
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:136
Fit a plane through allPoints given (higher precision by taking more points) and ensure that it's normal is the same as the one of the special cycle given.
Parameters:
| Name | Type |
|---|---|
cycle |
ReadonlyVectorCycle3D |
allPoints |
ReadonlyVector3[] |
plane? |
any |
Returns: IPlane
Static getPlaneForSurface
▸ getPlaneForSurface(surface: MeshSurface, plane?: any): IPlane
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:158
Parameters:
| Name | Type |
|---|---|
surface |
MeshSurface |
plane? |
any |
Returns: IPlane
Static getPlaneForVectorPolygon
▸ getPlaneForVectorPolygon(polygon: ReadonlyVectorPolygon3D, plane?: any): IPlane
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:154
Fit a plane through the polygon. Ensures that it has the correct normal wrt the outline. Gives higher precision because we use all points of the polygon (also holes) for plane fitting.
Parameters:
| Name | Type |
|---|---|
polygon |
ReadonlyVectorPolygon3D |
plane? |
any |
Returns: IPlane
Static numberCycleContainsAllNumberHoles
▸ numberCycleContainsAllNumberHoles(outline: ArrayPoint2[], holes: ArrayPoint2[][]): boolean
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:85
Return true if the outline contains all holes. All holes need to have at least one point inside the outline polygon.
Parameters:
| Name | Type |
|---|---|
outline |
ArrayPoint2[] |
holes |
ArrayPoint2[][] |
Returns: boolean
Static numberCycleContainsOtherNumberCycle
▸ numberCycleContainsOtherNumberCycle(cycle1: ArrayPoint2[], cycle2: ArrayPoint2[]): boolean
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:99
Return true iff any of the points of cycle2 is inside cycle1. Doesnt care about shared points. Doesn't care about overlapping cycles (would then still return true if there are points of one inside the other).
Parameters:
| Name | Type |
|---|---|
cycle1 |
ArrayPoint2[] |
cycle2 |
ArrayPoint2[] |
Returns: boolean
Static polygonToVectorPolygon2D
▸ polygonToVectorPolygon2D(polygon: Polygon): Vector3[][]
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:20
Maps the Polygon outlines and holes to the usual Vector3[][] format.
Parameters:
| Name | Type |
|---|---|
polygon |
Polygon |
Returns: Vector3[][]
Static polygonToVectorPolygon3D
▸ polygonToVectorPolygon3D(polygon: Polygon, plane: IPlane): Vector3[][]
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:26
Parameters:
| Name | Type |
|---|---|
polygon |
Polygon |
plane |
IPlane |
Returns: Vector3[][]
Static vectorPolygon2DToVectorPolygon3D
▸ vectorPolygon2DToVectorPolygon3D(polygon: Vector3[][], plane: IPlane): Vector3[][]
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:67
Unproject from the given plane.
Parameters:
| Name | Type |
|---|---|
polygon |
Vector3[][] |
plane |
IPlane |
Returns: Vector3[][]
Static vectorPolygon3DToArrayPointPolygon3D
▸ vectorPolygon3DToArrayPointPolygon3D(vectorPolygon: ReadonlyVectorPolygon3D): ArrayPointPolygon3D
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:77
Parameters:
| Name | Type |
|---|---|
vectorPolygon |
ReadonlyVectorPolygon3D |
Returns: ArrayPointPolygon3D
Static vectorPolygon3DToPolygon
▸ vectorPolygon3DToPolygon(polygonPoints: ReadonlyVectorPolygon3D, plane: IPlane, reverseDirection: boolean): Polygon
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:39
Convert Polygon given by Vector3[][] to a Polygon in a given plane.
Parameters:
| Name | Type | Default |
|---|---|---|
polygonPoints |
ReadonlyVectorPolygon3D | - |
plane |
IPlane | - |
reverseDirection |
boolean | false |
Returns: Polygon
Static vectorPolygon3DToVectorPolygon2D
▸ vectorPolygon3DToVectorPolygon2D(polygonPoints: Vector3[][], plane: IPlane): Vector3[][]
Defined in src/modules/kyub.core.editInBlender/src/CSGPolygonUtils.ts:30
Parameters:
| Name | Type |
|---|---|
polygonPoints |
Vector3[][] |
plane |
IPlane |
Returns: Vector3[][]