editor › Globals › GridInferrer
Class: GridInferrer
Hierarchy
- GridInferrer
Index
Properties
Methods
- _debugSvg
- _deduplicateAlignmentsGeometrically
- _deduplicateAlignmentsNumerically
- _extractFeatures
- _getCandidateAlignments
- _removeOutsideAlignments
- _renderSurface
- inferGrid
- legacyInferGridForRectangle
Properties
Static Readonly criteria
▪ criteria: Array‹object› = [ { CriterionClass: NumberOfOccurrencesCriterion, higherIsBetter: true, weight: 0.5, }, { CriterionClass: NumberOfResultingSurfacesCriterion, higherIsBetter: false, weight: 2, }, { CriterionClass: ResultingSurfaceAreaCriterion, higherIsBetter: false, weight: 1, }, { CriterionClass: SameOrientationCriterion, higherIsBetter: true, weight: 0.1, }, { CriterionClass: OrientationTowardsGroundCriterion, higherIsBetter: true, weight: 0.2, }, { CriterionClass: PrismCriterion, higherIsBetter: true, weight: 0.5, }, { CriterionClass: DistanceToSurfaceCenterCriterion, higherIsBetter: false, weight: 0.2, }, { CriterionClass: ConnectorPreferabilityCriterion, higherIsBetter: true, weight: 0.25, }, { CriterionClass: BelowGroundCriterion, higherIsBetter: true, weight: 0.4, }, { CriterionClass: SymmetryCriterion, equalityThreshold: 0.25, higherIsBetter: true, weight: 2, }, ]
Defined in src/modules/kyub.core.boxel/src/GridInferring/GridInferrer.ts:48
The criteria to apply when scoring the candidate alignments. The results are normalized to [0..1].
Methods
Static Private _debugSvg
▸ _debugSvg(baseSurface: MeshSurface, alignments: Array‹object›, meshPoint: Vector3): void
Defined in src/modules/kyub.core.boxel/src/GridInferring/GridInferrer.ts:354
Parameters:
| Name | Type |
|---|---|
baseSurface |
MeshSurface |
alignments |
Array‹object› |
meshPoint |
Vector3 |
Returns: void
Static Private _deduplicateAlignmentsGeometrically
▸ _deduplicateAlignmentsGeometrically(alignments: Array‹object›): object[]
Defined in src/modules/kyub.core.boxel/src/GridInferring/GridInferrer.ts:302
Parameters:
| Name | Type |
|---|---|
alignments |
Array‹object› |
Returns: object[]
Static Private _deduplicateAlignmentsNumerically
▸ _deduplicateAlignmentsNumerically(alignments: IMeshLocalAlignment[]): object[]
Defined in src/modules/kyub.core.boxel/src/GridInferring/GridInferrer.ts:270
Removes duplicates of position/rotation pairs (@see _getPositionsRotationsOnPlate) in O(n²).
Parameters:
| Name | Type | Description |
|---|---|---|
alignments |
IMeshLocalAlignment[] | - |
Returns: object[]
Static Private _extractFeatures
▸ _extractFeatures(surface: MeshSurface, addReverseDirections: boolean): object[]
Defined in src/modules/kyub.core.boxel/src/GridInferring/GridInferrer.ts:520
Extracts features from the given surface. A feature is a position and several directions, where you can align things on the surface. In mesh-space.
Parameters:
| Name | Type | Description |
|---|---|---|
surface |
MeshSurface | - |
addReverseDirections |
boolean | If true, all directions will also be reversed for even more possibilities |
Returns: object[]
Static Private _getCandidateAlignments
▸ _getCandidateAlignments(connector: IConnector, baseSurface: MeshSurfaceAnchor, surfaceSide: PlateSide, meshPoint: Vector3): IMeshLocalAlignment[]
Defined in src/modules/kyub.core.boxel/src/GridInferring/GridInferrer.ts:431
Parameters:
| Name | Type |
|---|---|
connector |
IConnector |
baseSurface |
MeshSurfaceAnchor |
surfaceSide |
PlateSide |
meshPoint |
Vector3 |
Returns: IMeshLocalAlignment[]
Static Private _removeOutsideAlignments
▸ _removeOutsideAlignments(alignments: Array‹object›, surface: MeshSurface): object[]
Defined in src/modules/kyub.core.boxel/src/GridInferring/GridInferrer.ts:556
Parameters:
| Name | Type |
|---|---|
alignments |
Array‹object› |
surface |
MeshSurface |
Returns: object[]
Static Private _renderSurface
▸ _renderSurface(surface: MeshSurface, position: Vector3, rotation: Quaternion, obbPosition: Vector3, obbTranslation: Vector3, obbRotation: Quaternion, svgBuilder: any, parent: any, color: string): any
Defined in src/modules/kyub.core.boxel/src/GridInferring/GridInferrer.ts:332
Parameters:
| Name | Type |
|---|---|
surface |
MeshSurface |
position |
Vector3 |
rotation |
Quaternion |
obbPosition |
Vector3 |
obbTranslation |
Vector3 |
obbRotation |
Quaternion |
svgBuilder |
any |
parent |
any |
color |
string |
Returns: any
Static inferGrid
▸ inferGrid(baseSurfaceAnchor: MeshSurfaceAnchor, meshPoint: Vector3, surfaceSide: PlateSide, connectors: IConnector[], returnAllPositionsRotations: false, skipOutsideAlignments: boolean): object | undefined
Defined in src/modules/kyub.core.boxel/src/GridInferring/GridInferrer.ts:125
The returned alignments are in baseMesh-local coordinates. In order to apply the alignment, you first have to make the connectorMesh's coordinate system align with the baseMesh's coordinate system.
Calling this method does not change anything in the baseMesh or the connectorMesh and it is not required, that their coordinate systems match before calling this method.
Parameters:
| Name | Type | Description |
|---|---|---|
baseSurfaceAnchor |
MeshSurfaceAnchor | the surface that the grid should be inferred on |
meshPoint |
Vector3 | the point on the surface that the grid should be inferred at (in base mesh coordinates) |
surfaceSide |
PlateSide | 'front' or 'back' indicating on which side the interaction happened. The values of nextBoxel are in the direction of plateSide relative to the plate. |
connectors |
IConnector[] | an array of connectors inside the boxelAssembly |
returnAllPositionsRotations |
false | (optional) true if all possible alignments should be returned |
skipOutsideAlignments |
boolean | (optional) true if alignments that would make the connector exceed the basePlate should be ignored |
Returns: object | undefined
the boxel parameters
▸ inferGrid(baseSurfaceAnchor: MeshSurfaceAnchor, meshPoint: Vector3, surfaceSide: PlateSide, connectors: IConnector[], returnAllPositionsRotations: true, skipOutsideAlignments: boolean): Array‹object›
Defined in src/modules/kyub.core.boxel/src/GridInferring/GridInferrer.ts:133
Parameters:
| Name | Type |
|---|---|
baseSurfaceAnchor |
MeshSurfaceAnchor |
meshPoint |
Vector3 |
surfaceSide |
PlateSide |
connectors |
IConnector[] |
returnAllPositionsRotations |
true |
skipOutsideAlignments |
boolean |
Returns: Array‹object›
Static legacyInferGridForRectangle
▸ legacyInferGridForRectangle(plate: Plate, localPoint: Vector3, width: number, height: number): object
Defined in src/modules/kyub.core.boxel/src/GridInferring/GridInferrer.ts:226
This wraps the old usage of the plate-based GridInferrer.
deprecated
Parameters:
| Name | Type | Description |
|---|---|---|
plate |
Plate | - |
localPoint |
Vector3 | - |
width |
number | - |
height |
number | - |
Returns: object
-
localPosition: Vector3‹› = position
-
localRotation: Quaternion‹› = rotation