SliceViewModel

AMD: require(["esri/widgets/Slice/SliceViewModel"], (SliceViewModel) => { /* code goes here */ });
ESM: import SliceViewModel from "@arcgis/core/widgets/Slice/SliceViewModel.js";
Class: esri/widgets/Slice/SliceViewModel
Inheritance: SliceViewModel Accessor
Since: ArcGIS Maps SDK for JavaScript 4.10

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

See also

Constructors

SliceViewModel

Constructor
new SliceViewModel(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class

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

SliceViewModel

The name of the class.

Accessor

Add layers to this collection to exclude them from the slice.

SliceViewModel

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

SliceViewModel

The shape used to slice elements in a 3D scene.

SliceViewModel

The view model's state.

SliceViewModel

Enable tilting the slice shape.

SliceViewModel

The view from which the widget will operate.

SliceViewModel

Property Details

analysis

Property
analysis SliceAnalysisautocastreadonly
Since: ArcGIS Maps SDK for JavaScript 4.23 SliceViewModel since 4.10, analysis added at 4.23.

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

This property can be set during view model construction, to provide an existing analysis to the view model for modification. Properties on the analysis can also be updated once it's assigned to the view model.

If no analysis is provided during view model construction, 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 analysis = 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(analysis);

// Frame the analysis in the view
view.goTo(analysis.extent);

// Pass the analysis object as a constructor parameter to modify it using the view model
const viewModel = new SliceViewModel({
  analysis: analysis,
  view: view
});

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

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

excludedLayers

Property
excludedLayers Collection<(Layer|BuildingComponentSublayer)>

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
excludeGroundSurface Boolean

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

Default Value:false

shape

Property
shape SlicePlaneautocast
Since: ArcGIS Maps SDK for JavaScript 4.16 SliceViewModel since 4.10, shape added at 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 = viewModel.shape.clone();

// Set new values for heading and tilt
shape.heading = 180;
shape.tilt = 45;

// Set the new properties on the viewModel's shape
viewModel.shape = shape;

state

Property
state Stringreadonly

The view model's state.

Value Description
disabled not ready yet
ready ready for slicing
slicing currently slicing
sliced finished slicing

Possible Values:"disabled" |"ready" |"slicing" |"sliced"

Default Value:disabled

tiltEnabled

Property
tiltEnabled Boolean
Since: ArcGIS Maps SDK for JavaScript 4.16 SliceViewModel since 4.10, tiltEnabled added at 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
view SceneView

The view from which the widget will operate.

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor

Clears the shape of the slice, effectively removing it from the view.

SliceViewModel

Returns true if a named group of handles exist.

Accessor

Removes a group of handles owned by the object.

Accessor

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

SliceViewModel

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

clear

Method
clear()
Since: ArcGIS Maps SDK for JavaScript 4.16 SliceViewModel since 4.10, clear added at 4.16.

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

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

start

Method
start()
Since: ArcGIS Maps SDK for JavaScript 4.16 SliceViewModel since 4.10, start added at 4.16.

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

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.