Last updated

API / geotoolkit3d / util / intersection / Intersection3DUtil / Intersection3DUtil

Class: 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) => {
});

Table of contents

Constructors
Methods

Contents

Constructors

new Intersection3DUtil()

new Intersection3DUtil()

Methods

clearQueuedIntersections

Static clearQueuedIntersections(): void

Cancel the currently queued intersection Promises, causing them to reject early.

Returns

void


generateCellOutlineByIndex

Static generateCellOutlineByIndex(intersectionResults, cellIndex, options?): LineSegments

Generate the outline of a specific cell in the given intersection result, to be displayed in 3D.

Parameters

Name Type Description
intersectionResultsMeshPolyhedronResult[]the mesh/polyhedron results from the intersectObjects method. Multiple results can be passed at once.
cellIndexnumberThe cell index to generate highlight from.
Optional optionsOutlineVisualOptionsIntersection3DUtil.VisualOptions to configure the resulting outline visual properties.

Returns

LineSegments

the LineSegment 3D object that represent the cell outline, or null if no relevant cell was found for the given index.


generateIntersection

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)
For complex user-made objects such as instanced geometries, or objects made of multiple nested sub-Objects, it is the user's responsibility to implement the intersection interfaces so that intersections can be generated.
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.

Parameters

Name Type Description
objectAObject3D<Object3DEventMap> | IntersectableObject3D that is Intersection3DUtil.Intersectable or contains one Intersection3DUtil.Intersectable.
objectBObject3D<Object3DEventMap> | IntersectableObject3D that is Intersection3DUtil.Intersectable or contains one Intersection3DUtil.Intersectable.
Optional plotPlot(optional) Legacy parameter, no longer needed. Can be omitted safely.
Optional optionsIntersectionOptionsIntersection3DUtil.Options

Returns

Promise<Result>

Intersection3DUtil.Result


generateIntersectionVisuals

Static generateIntersectionVisuals(intersectionResult, options?): VisualResult

Generate intersection visual objects from intersection result

Parameters

Name Type Description
intersectionResultResultIntersection3DUtil.Result from Intersection3DUtil.intersectObjects method
Optional optionsVisualOptionsIntersection3DUtil.VisualOptions to configure visual effect of the intersection

Returns

VisualResult

Intersection3DUtil.VisualResult


getClassName

Static getClassName(): string

Returns

string


getIntersectableObjects

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().

Parameters

Name Type
objObject3D<Object3DEventMap>

Returns

Intersectable[]


intersectObjects

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)
For complex user-made objects such as instanced geometries, or objects made of multiple nested sub-Objects, it is the user's responsibility to implement the intersection interfaces so that intersections can be generated.
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.

Parameters

Name Type Description
objectAObject3D<Object3DEventMap> | IntersectableObject3D that is Intersection3DUtil.Intersectable or contains one Intersection3DUtil.Intersectable.
objectBObject3D<Object3DEventMap> | IntersectableObject3D that is Intersection3DUtil.Intersectable or contains one Intersection3DUtil.Intersectable.
Optional optionsIntersectionOptionsIntersection3DUtil.Options

Returns

Promise<Result>

Intersection3DUtil.Result


projectResultTo2D

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.

Parameters

Name Type Description
result3DResultthe intersection result to project to the given plane.
planeCorner0Vector3the 3D coordinate of the left top corner of the plane in business coordinate.
planeCorner1Vector3the 3D coordinate of the right top corner of the plane in business coordinate.
planeCorner2Vector3the 3D coordinate of the left bottom corner of the plane in business coordinate.

Returns

Result2D


projectResultToPlane

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.

Parameters

Name Type Description
result3DResultthe intersection result to project to the given plane.
planeIOverlayableObjectthe plane object.
Optional plotPlot(optional) Legacy parameter is deprecated since 5.1, no longer needed. Can be omitted safely.

Returns

Result2D