Skip to content
import SliceAnalysis from "@arcgis/core/analysis/SliceAnalysis.js";
Inheritance:
SliceAnalysisAnalysisAccessor
Since
ArcGIS Maps SDK for JavaScript 4.23

SliceAnalysis can be used to programmatically create a plane that slices through 3D features in a 3D SceneView.

slice

A slice takes a SlicePlane as an input, which can be set through the shape property. If the shape has a tilt angle other than 0, the angle is only considered if the tiltEnabled property is set to true.

const sliceAnalysis = new SliceAnalysis({
shape: new SlicePlane({
position: new Point({ }),
width: 50,
height: 50,
tilt: 45
}),
tiltEnabled: true
});
view.analyses.add(sliceAnalysis);

SceneView.analyses can contain multiple slice analyses, but only one of them can be active at a time. When working with multiple slices, set the SliceAnalysisView3D.active property of a slice analysis view to true to occlude the parts of the 3D features that are in front of the slice plane. When a slice analysis view is activated, all other slice analysis views are automatically deactivated.

const sliceAnalysisView = await view.whenAnalysisView(sliceAnalysis);
// make the slice active in the view (only one slice can be active at a time)
sliceAnalysisView.active = true;

To place a slice interactively, use the SliceAnalysisView3D.place() method.

const abortController = new AbortController();
try {
await analysisView.place({ signal: abortController.signal });
} catch (error) {
if (error.name === "AbortError") {
console.log("Placement operation was cancelled.");
}
}
// cancel the placement operation at some later point
abortController.abort();

Similarly, to interactively exclude layers from the slicing, use the SliceAnalysisView3D.pickLayerToExclude() method.

const abortController = new AbortController();
try {
await analysisView.pickLayerToExclude({ signal: abortController.signal });
} catch (error) {
if (error.name === "AbortError") {
console.log("Picking excluded layers operation was cancelled.");
}
}
// cancel the operation at some later point
abortController.abort();

Use the Slice component to display a user interface for the slice analysis. The component allows users to interactively place a slice and exclude layers from the analysis.

Known Limitations

This analysis is only supported in a 3D SceneView.

See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

excludedLayers

autocast Property
Type
Collection<SliceableLayer>
Since
ArcGIS Maps SDK for JavaScript 4.33

A collection of layers that should be excluded from the slice analysis.

excludeGroundSurface

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.33

A flag that indicates whether the ground surface should be excluded from the slice analysis.

Default value
false

id

readonlyinherited Property
Type
string
Inherited from: Analysis

A user settable identifier for the analysis. A unique value is automatically generated when the analysis is created if it is not set explicitly during construction.

origin

autocast inherited Property
Type
AnalysisOriginWebScene | null | undefined
Inherited from: Analysis

The origin of the analysis. The origin can be of type web-scene when the analysis was applied from the WebScene.initialViewProperties or a Slide.

shape

autocast Property
Type
SlicePlane | null | undefined

The shape used to slice elements in a 3D scene. Currently the only supported shape is a plane.

tiltEnabled

Property
Type
boolean

Whether the shape supports a tilt angle or not. If set to true, the SlicePlane.tilt angle is respected. By default it is set to false, so the tilt value of the shape is not taken into consideration.

Default value
false

type

readonly Property
Type
"slice"

The type of analysis. For slice analysis, this is always "slice".

uid

readonlyinherited Property
Type
string
Inherited from: IdentifiableMixin
Since
ArcGIS Maps SDK for JavaScript 4.33

An automatically generated unique identifier assigned to the instance. The unique id is generated each time the application is loaded.

valid

readonly Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.33

Indicates whether the analysis is ready to be computed and interacted with in the view. It requires a shape with a position to be set.

Methods

MethodSignatureClass
fromJSON
inherited static
fromJSON(json: any): any
clear(): void
clone
inherited
clone(): this
equals
inherited
equals(other: this): boolean
toJSON
inherited
toJSON(): any

fromJSON

inheritedstatic Method
Signature
fromJSON (json: any): any
Inherited from: JSONSupportMixin

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameters
ParameterTypeDescriptionRequired
json
any

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns
any

Returns a new instance of this class.

clear

Method
Signature
clear (): void
Since
ArcGIS Maps SDK for JavaScript 5.0

Clears the analysis by resetting the shape property.

Returns
void

clone

inherited Method
Signature
clone (): this
Inherited from: ClonableMixin

Creates a deep clone of this object. Any properties that store values by reference will be assigned copies of the referenced values on the cloned instance.

Returns
this

A deep clone of the class instance that invoked this method.

equals

inherited Method
Signature
equals (other: this): boolean
Inherited from: Analysis
Since
ArcGIS Maps SDK for JavaScript 5.0

Compares this analysis with another analysis to determine whether they are equivalent.

Parameters
ParameterTypeDescriptionRequired
other

The other analysis to compare against.

Returns
boolean

true if the analyses are equivalent and false otherwise.

toJSON

inherited Method
Signature
toJSON (): any
Inherited from: JSONSupportMixin

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns
any

The ArcGIS portal JSON representation of an instance of this class.