API / geotoolkit3d / util / intersection / Intersection3DUtil / Intersection3DUtil
intersection.Intersection3DUtil.Intersection3DUtil
Utility class for generating and visualizing 3D intersections.
Example
Intersection3DUtil.intersectObjects(objectA, objectB, intersectOption)
.then((intersectionResult) => {
const visualResult = Intersection3DUtil.generateIntersectionVisuals(intersectionResult, visualOptions);
if (visualResult['linesegments'] != null) {
plot.getRoot().add(visualResult['linesegments']);
}
if (visualResult['pointset'] != null) {
plot.getRoot().add(visualResult['pointset']);
}
if (visualResult['surface'] != null) {
plot.getRoot().add(visualResult['surface']);
}
})
.catch((err) => {
});Constructors
Methods
Methods
▸ Static clearQueuedIntersections(): void
Cancel the currently queued intersection Promises, causing them to reject early.
void
▸ Static generateCellOutlineByIndex(intersectionResults, cellIndex, options?): LineSegments
Generate the outline of a specific cell in the given intersection result, to be displayed in 3D.
| Name | Type | Description |
|---|---|---|
intersectionResults | MeshPolyhedronResult[] | the mesh/polyhedron results from the intersectObjects method. Multiple results can be passed at once. |
cellIndex | number | The cell index to generate highlight from. |
Optional options | OutlineVisualOptions | Intersection3DUtil.VisualOptions to configure the resulting outline visual properties. |
the LineSegment 3D object that represent the cell outline, or null if no relevant cell was found for the given index.
▸ Static generateIntersection(objectA, objectB, plot?, options?): Promise<Result>
Generates the 3D intersection result for the given object pair, via an asynchronous Promise.
For the intersection to succeed, both objects should be intersectable. This means, both ObjectA and ObjectB should be, or contain at least one child who are either:
- A regular Three.js Mesh, not instanced.
- Implement one of the intersection interfaces such as [IIntersectableMesh](../classes/geotoolkit3d.util-5.intersection.iintersectablemesh.iintersectablemesh.md) and [IIntersectablePolyhedron](../classes/geotoolkit3d.util-5.intersection.iintersectablepolyhedron.iintersectablepolyhedron.md)
When both ObjectA and ObjectB parameters contain eligible objects for intersection, the first intersectable object in each group will be found and intersected.
If multiple intersectable objects are contained in either ObjectA or B, only one will be intersected by default and a warning will be logged.
The result will depend on the nature of the intersected objects, as well as how they intersect. For example, Mesh-Mesh intersection usually provide lines, but can occasionally produce points (when vertices share identical positions) or triangles (when two intersecting triangles are also co-planar).
Mesh-Polyhedron intersection provide triangles.
Important: For now, the intersection algorithm expect the polyhedron of the IIntersectablePolyhedron object to be convex. It can work with slightly concave polyhedron, but artifacts are expected. Affected Toolkit object includes ReservoirGrid, if the cell of a ReservoirGrid is concave, the intersection result will not be perfect.
More intersection types will be supported in the future.
Throws
if objectA or objectB lacks a valid intersectable object.
Throws
if not support intersection between objectA and objectB.
Throws
if current queued intersection Promises being cancelled.
Deprecated
since 5.1, plot parameter is no longer required. Please use Intersection3DUtil.intersectObjects instead.
| Name | Type | Description |
|---|---|---|
objectA | Object3D<Object3DEventMap> | Intersectable | Object3D that is Intersection3DUtil.Intersectable or contains one Intersection3DUtil.Intersectable. |
objectB | Object3D<Object3DEventMap> | Intersectable | Object3D that is Intersection3DUtil.Intersectable or contains one Intersection3DUtil.Intersectable. |
Optional plot | Plot | (optional) Legacy parameter, no longer needed. Can be omitted safely. |
Optional options | IntersectionOptions | Intersection3DUtil.Options |
Promise<Result>
Intersection3DUtil.Result
▸ Static generateIntersectionVisuals(intersectionResult, options?): VisualResult
Generate intersection visual objects from intersection result
| Name | Type | Description |
|---|---|---|
intersectionResult | Result | Intersection3DUtil.Result from Intersection3DUtil.intersectObjects method |
Optional options | VisualOptions | Intersection3DUtil.VisualOptions to configure visual effect of the intersection |
Intersection3DUtil.VisualResult
▸ Static getClassName(): string
string
▸ Static getIntersectableObjects(obj): Intersectable[]
Return the valid intersectable objects contained in the provided Object3D/Group.
Please note that intersectObjects() expects only one intersectable object on each side. To intersect more objects, we recommend to make multiple calls to intersectObjects() for each pair to intersect.
This method can be used by users to check how many objects can be intersected in the given group. If the returned array contain more than one intersectable, only the first in the array would be intersected by a single call to intersectObjects().
| Name | Type |
|---|---|
obj | Object3D<Object3DEventMap> |
▸ Static intersectObjects(objectA, objectB, options?): Promise<Result>
Generates the 3D intersection result for the given object pair, via an asynchronous Promise.
For the intersection to succeed, both objects should be intersectable. This means, both ObjectA and ObjectB should be, or contain at least one child who are either:
- A regular Three.js Mesh, not instanced.
- Implement one of the intersection interfaces such as [IIntersectableMesh](../classes/geotoolkit3d.util-5.intersection.iintersectablemesh.iintersectablemesh.md) and [IIntersectablePolyhedron](../classes/geotoolkit3d.util-5.intersection.iintersectablepolyhedron.iintersectablepolyhedron.md)
When both ObjectA and ObjectB parameters contain eligible objects for intersection, the first intersectable object in each group will be found and intersected.
If multiple intersectable objects are contained in either ObjectA or B, only one will be intersected by default and a warning will be logged.
The result will depend on the nature of the intersected objects, as well as how they intersect. For example, Mesh-Mesh intersection usually provide lines, but can occasionally produce points (when vertices share identical positions) or triangles (when two intersecting triangles are also co-planar).
Mesh-Polyhedron intersection provide triangles.
Important: For now, the intersection algorithm expect the polyhedron of the IIntersectablePolyhedron object to be convex. It can work with slightly concave polyhedron, but artifacts are expected. Affected Toolkit object includes ReservoirGrid, if the cell of a ReservoirGrid is concave, the intersection result will not be perfect.
More intersection types will be supported in the future.
Throws
if objectA or objectB lacks a valid intersectable object.
Throws
if not support intersection between objectA and objectB.
Throws
if current queued intersection Promises being cancelled.
| Name | Type | Description |
|---|---|---|
objectA | Object3D<Object3DEventMap> | Intersectable | Object3D that is Intersection3DUtil.Intersectable or contains one Intersection3DUtil.Intersectable. |
objectB | Object3D<Object3DEventMap> | Intersectable | Object3D that is Intersection3DUtil.Intersectable or contains one Intersection3DUtil.Intersectable. |
Optional options | IntersectionOptions | Intersection3DUtil.Options |
Promise<Result>
Intersection3DUtil.Result
▸ Static projectResultTo2D(result3D, planeCorner0, planeCorner1, planeCorner2): Result2D
Convert the 3D intersection results into the given 2D plane.
To do so, the orientation of the 2D plane must be located in 3D space first, using 3 points. If the 2D plane have an equivalent plane/rectangle shape in 3D, these points would be its corners.
The result returned will be a deep copy of the original results, where instead the X and Y values will be updated, and the Z values will be set to 0.
The Rect of the given plane is also returned so that the result can be further transformed to any canvas or texture coordinate.
| Name | Type | Description |
|---|---|---|
result3D | Result | the intersection result to project to the given plane. |
planeCorner0 | Vector3 | the 3D coordinate of the left top corner of the plane in business coordinate. |
planeCorner1 | Vector3 | the 3D coordinate of the right top corner of the plane in business coordinate. |
planeCorner2 | Vector3 | the 3D coordinate of the left bottom corner of the plane in business coordinate. |
▸ Static projectResultToPlane(result3D, plane, plot?): Result2D
Convert the 3D intersection results into the given plane object.
The result returned will be a deep copy of the original results, where instead the X and Y values will be updated, and the Z values will be set to 0.
The Rect of the given plane is also returned so that the result can be further transformed to any canvas or texture coordinate.
| Name | Type | Description |
|---|---|---|
result3D | Result | the intersection result to project to the given plane. |
plane | IOverlayableObject | the plane object. |
Optional plot | Plot | (optional) Legacy parameter is deprecated since 5.1, no longer needed. Can be omitted safely. |