import { createFromElevation, createElevationSampler, merge, convertVertexSpace } from "@arcgis/core/geometry/support/meshUtils.js";const { createFromElevation, createElevationSampler, merge, convertVertexSpace } = await $arcgis.import("@arcgis/core/geometry/support/meshUtils.js");- Since
- ArcGIS Maps SDK for JavaScript 4.7
Various utilities and convenience functions for working with Mesh objects.
Functions
| Name | Return Type | Object |
|---|---|---|
| | ||
| | ||
| | ||
| |
createFromElevation
Creates a mesh geometry by sampling elevation data from an elevation service on a regular grid.
- Signature
-
createFromElevation (source: ElevationLayer | Ground | ElevationSampler, extent: Extent, options?: CreateFromElevationParameters): Promise<Mesh>
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| source | The source from which to query the elevation data. | | |
| extent | The extent from which to create the mesh. | | |
| options | Additional options. | |
Example
// Create a mesh by sampling the groundmeshUtils.createFromElevation(map.ground, extent) .then(function(mesh) { // Do something with the mesh });
// Create a mesh by sampling the ground surface currently in viewmeshUtils.createFromElevation(view.groundView.elevationSampler, view.extent) .then(function(mesh) { // Do something with the mesh }); createElevationSampler
- Since
- ArcGIS Maps SDK for JavaScript 4.12
Creates an elevation sampler from a mesh. The sampler can be used to query elevation values on the surface of the mesh. The elevation sampler uses a snapshot of the Mesh geometry and will not update if the mesh changes after the sampler has been created.
- Signature
-
createElevationSampler (mesh: Mesh, options?: CreateElevationSamplerParameters): Promise<ElevationSampler>
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| mesh | The mesh geometry used to create the elevation sampler. | | |
| options | Additional options. | |
- Returns
- Promise<ElevationSampler>
An elevation sampler.
merge
Merges multiple meshes into a single mesh. All mesh geometries must be in the same spatial reference.
- Signature
-
merge (geometries: Mesh[]): Mesh | null | undefined
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometries | Mesh[] | One or more meshes. | |
Example
const mergedMesh = meshUtils.merge([mesh1, mesh2]); convertVertexSpace
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Converts a mesh to a new vertex space. Any transform defined on the mesh will be applied to the vertex attributes as part of the conversion.
- Signature
-
convertVertexSpace (mesh: Mesh, targetVertexSpace: MeshVertexSpaceUnion, options?: AbortOptions): Promise<Mesh>
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| mesh | the mesh geometry to convert. | | |
| targetVertexSpace | the vertex space to convert to. | | |
| options | Additional options. | |
Examples
// convert cartesian model data to a mesh with absolute coordinates in WebMercatorconst converted = await convertVertexSpace( new Mesh({ vertexSpace: new MeshLocalVertexSpace({ origin: location }), vertexAttributes, spatialReference: SpatialReference.WebMercator }), new MeshGeoreferencedVertexSpace());// convert a georeferenced WebMercator mesh to a mesh with a local tangent coordinate frame// at the center of the meshconst center = mesh.extent.center;const origin = [center.x, center.y, center.z];const converted = await convertVertexSpace(mesh, new MeshLocalVertexSpace({ origin }));// convert an existing mesh to absolute coordinates and place a graphic on the highest vertexconst converted = await convertVertexSpace(mesh, new MeshGeoreferencedVertexSpace());const position = converted.vertexAttributes.position;
const highestPoint = new Point({ x: 0, y: 0, z: 0, spatialReference: converted.spatialReference });
for (let i = 0; i < position.length; i += 3) { if (position[i + 2] > highestPoint.z) { highestPoint.x = position[i]; highestPoint.y = position[i + 1]; highestPoint.z = position[i + 2]; }}
view.graphics.add(new Graphic({ geometry: highestPoint }));