| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Object with the following properties:
|
Example:
const snapper = await Cesium.IonSnapService.fromAssetId(123456);
const canvas = viewer.scene.canvas;
const result = await snapper.snap({
elementId: "0x30000000df2",
testPoint: pickedPosition,
camera: viewer.camera,
canvasWidth: canvas.clientWidth,
canvasHeight: canvas.clientHeight,
});
if (Cesium.defined(result)) {
console.log("snapped to", result.snapPoint);
}
Experimental
This feature is not final and is subject to change without Cesium's standard deprecation policy.
See:
Members
The default snap tolerance used by
IonSnapService#snap when
options.snapAperture is not provided, in CSS pixels of the
world-to-view output space. This is SnapService's
DEFAULT_SNAP_APERTURE for this implementation.
Experimental
This feature is not final and is subject to change without Cesium's standard deprecation policy.
The ion asset id this snapper operates on.
readonly ecefTransform : Matrix4
A 4x4 transformation matrix from the source BIM/CAD Database reference frame local to the world's fixed reference frame.
Methods
async static Cesium.IonSnapService.fromAssetId(assetId, options) → Promise.<IonSnapService>
Creates an
IonSnapService for the given ion asset, fetching
the asset's ECEF transform from the ion REST API.
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
assetId |
number | The ion ID of a 3D Tiles asset backed by a BIM/CAD Database model. | ||||||||||||
options |
object |
optional
Object with the following properties:
|
Returns:
A snapper bound to the asset.
Throws:
-
RuntimeError : The asset is not geolocated, so view-correct snapping is not possible.
Experimental
This feature is not final and is subject to change without Cesium's standard deprecation policy.
async snap(options) → Promise.<(IonSnapService.Result|undefined)>
Requests a snap against an element of this asset.
A view-correct world-to-view matrix is composed from
options.camera, options.canvasWidth, and
options.canvasHeight so view-dependent snapping (nearest
ordering, pixel apertures, surface tracking) matches the current view.
Only 3D views are supported: the camera must be viewing in
SceneMode.SCENE3D.
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Object with the following properties:
|
Returns:
The snap result, or
undefined if the element was not found or no snap was possible for it.
Experimental
This feature is not final and is subject to change without Cesium's standard deprecation policy.
Type Definitions
The result of a successful
IonSnapService#snap. Extends
SnapService.Result with ion-specific fields.
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
snapPoint |
Cartesian3 |
<optional> |
The snapped point. This is the point to consume. |
hitPoint |
Cartesian3 |
<optional> |
The point where the cursor hit the geometry: the nearest edge point when within the snap aperture, otherwise the surface point under the cursor. |
heat |
IonSnapHeat |
<optional> |
How close the snap point is to the close point in view space. |
geometryType |
IonSnapGeometryType |
<optional> |
The type of geometry snapped to. |
parentGeometryType |
IonSnapParentGeometryType |
<optional> |
The type of the parent geometry snapped to. |
normal |
object |
<optional> |
The surface normal at the snap point, in the model's local cartesian frame. |
curve |
object |
<optional> |
The curve geometry near the snap point, with points as WGS84 degrees objects. |
