Skip to content
import SliceViewModel from "@arcgis/core/widgets/Slice/SliceViewModel.js";
Inheritance:
SliceViewModelAccessor
Since
ArcGIS Maps SDK for JavaScript 4.10

Provides the logic for the Slice widget and component. SliceViewModel provides access to the slice plane and the layers that can be excluded from the slice widget.

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.

analysis

autocast Property
Type
SliceAnalysis
Since
ArcGIS Maps SDK for JavaScript 4.23

The slice analysis object being created or modified by the view model.

If no analysis is provided, the view model automatically creates its own analysis and adds it to the view. In this case, the analysis will also be automatically removed from the view when the view model is destroyed.

Example
// Construct a slice analysis object outside of the view model
const sliceAnalysis = new SliceAnalysis({
shape: {
type: "plane", // autocasts as new SlicePlane()
position: {
type: "point",
x: -0.1,
y: 51.5
},
width: 50,
height: 50,
tilt: 45
},
tiltEnabled: true
});
// Ensure that the analysis is added to the view
view.analyses.add(sliceAnalysis);
// Frame the analysis in the view
view.goTo(sliceAnalysis.extent);
// Pass the analysis object as a constructor parameter to modify it using the view model
const sliceViewModel = new SliceViewModel({
analysis: sliceAnalysis,
view: view
});

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>

Add layers to this collection to exclude them from the slice. Layers that are draped on the ground surface are not affected by this property

excludeGroundSurface

Property
Type
boolean

Indicates whether the Ground and layers that are draped on the ground surface are excluded from the slice.

Default value
false

shape

autocast Property
Type
SlicePlane | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.16

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

Example
// Clone the shape to modify its properties
const shape = sliceViewModel.shape.clone();
// Set new values for heading and tilt
shape.heading = 180;
shape.tilt = 45;
// Set the new properties on the slice view model's shape
sliceViewModel.shape = shape;

state

readonly Property
Type
"disabled" | "ready" | "slicing" | "sliced"

The view model's state.

ValueDescription
disablednot ready yet
readyready for slicing
slicingcurrently slicing
slicedfinished slicing
Default value
"disabled"

tiltEnabled

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.16

Enable tilting the slice shape. If set to true, the slice shape will orient itself as best as possible to the surface under the cursor when first placing the shape. If set to false, the slice shape is restricted to be either horizontal or vertical.

Default value
false

view

Property
Type
SceneView | null | undefined

The view from which the widget will operate.

Methods

MethodSignatureClass
clear(): void
start(): Promise<void>

clear

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

Clears the shape of the slice, effectively removing it from the view. Other properties like excludedLayers and excludeGroundSurface are not modified.

Returns
void

start

Method
Signature
start (): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 4.16

Starts the interactive creation of a new slice, clearing the previous shape.

Returns
Promise<void>