Custom scene navigation commands


PurposeThis sample provides a set of Scene commands and tools that can be used in conjunction with the SceneControl. It is assumed you have previous experience in creating custom tools and commands.

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Build the project.
  2. Do one of the following: a) Add the commands to the ToolbarControl programmatically using the IToolbarControl.AddItem method; b) Use the commands directly with the SceneControl programmatically by creating a new instance of a command and passing the SceneControl to its OnCreate event; c) Add the commands interactively to the ToolbarControl by clicking the Add from File button in the ToolbarControl's Customizing dialog box, (available through the property pages) and browsing to the *.tlb file; or d) Add the commands interactively to the ToolbarControl by dragging them from the Sample_SceneControl category in the ToolbarControl's Customizing dialog box.

Additional information

This sample uses the following:
  • ZoomIn and ZoomOut tools—Windows Graphical Device Interface (GDI) calls are used to draw the tracked rectangle on the SceneControl in the OnMouseMove event. The ICamera.Zoom and ICamera.ZoomToRect methods are used in the OnMouseUp event to zoom in and out.
  • ZoomInOut tool—The ICamera.Zoom method is used in the OnMouseMove event.
  • Pan tool—The ICamera.Pan method is used in the OnMouseMove event.
  • FullExtent command—The ICamera.SetDefaultsMBB property is set to the SceneGraph.Extent to zoom to a minimum bounding box.
  • ExpandFieldOfView and NarrowFieldOfView commands—The ICamera.ViewFieldAngle property is set and the ISceneViewer.Redraw method is used to reflect the change.
  • Fly tool—The OnMouseUp event is used to start, stop, and alter the speed of a fly-through. Once a fly-through has been started, the ICamera.Observer, ICamera.Target, and ICamera.RollAngle properties are constantly updated based on the current mouse coordinates. The IMessageDispatcher interface is used to determine whether the Escape (Esc) key is pressed to stop the fly-through. The KeyUp, KeyRight, KeyDown, and KeyLeft keys can also be used to increase and decrease the speed of the fly-through.
  • Navigate tool—The OnKeyUp event uses the ICamera.Move, ICamera.HTurnAround, and ICamera.PolarUpdate methods to pan, zoom, and update the camera's observer position. Use the KeyUp, KeyDown, KeyLeft, and KeyRight keys to update the camera observer position. Use the same keys in combination with the Shift key to pan and the Ctrl key to zoom in and out.

    The OnMouseMove event uses the ICamera.Pan, ICamera.Zoom, and ICamera.PolarUpdate methods to pan, zoom, and update the camera's observer position. Use the right mouse button to zoom in and out, and the left and right mouse buttons together to pan. Use the left mouse button to update the camera observer position. If the ISceneViewer.GestureEnabled property is true, using the left mouse button will cause the scene to spin by continuously updating the camera observer position based on the ISceneViewer.GestureSensitivity property. The IMessageDispatcher interface is used to determine whether the Esc key is pressed to stop the scene from spinning. The ISceneViewer.GestureEnabled property can be toggled in the OnKeyDown event by holding both the Shift and Ctrl keys. The Page Up and Page Down keys can be used to increase and decrease the spin speed.
  • TargetCenter, ZoomTarget, and SetObserver tools—In the OnMouseUp event, the ISceneGraph.Locate method is used to create a new target or observer based on the screen coordinates. The ICamera.Target and ICamera.Observer properties are gradually moved toward the new target or observer based on the ISceneGraph.GetDrawingTimeInfo method.
  • Select Features tool—The ISceneGraph.Locate method is used in the OnMouseUp event to create a new point and owner object based on screen coordinates. If the owner object is a selectable FeatureLayer, the IScene.SelectByShape method is used to select features. If the Shift key is held down, selected features are added to the existing selection; otherwise a new selection is made.
  • SelectGraphics tool—The ISceneGraph.Locate method is used in the OnMouseUp event to create a new point and object based on screen coordinates. If the object is an element, it is added to the GraphicsSelection. If the Shift key is held down, selected graphics are added to the existing selection; otherwise, a new selection is made.


AssemblyInfo.cs Assembly information.
ExpandFOV.cs Class file.
Fly.cs Class file.
FullExtent.cs Class file.
NarrowFOV.cs Class file.
Navigate.cs Class file.
Pan.cs Class file.
SelectFeatures.cs Class file.
SelectGraphics.cs Class file.
SetObserver.cs Class file.
TargetCenter.cs Class file.
TargetZoom.cs Class file.
ZoomIn.cs Class file.
ZoomInOut.cs Class file.
ZoomOut.cs Class file.
Download the C# files
AssemblyInfo.vb Assembly information.
ExpandFOV.vb Form file.
Fly.vb Class file.
FullExtent.vb Class file.
NarrowFOV.vb Class file.
Navigate.vb Class file.
Pan.vb Class file.
SelectFeatures.vb Class file.
SelectGraphics.vb Class file.
SetObserver.vb Class file.
TargetCenter.vb Class file.
TargetZoom.vb Class file.
ZoomIn.vb Class file.
ZoomInOut.vb Class file.
ZoomOut.vb Class file.
Download the VB.NET files

Download the files for all languages

See Also:

SceneHookHelper Class
ISceneHookHelper Interface




Development licensing Deployment licensing
Engine Developer Kit Engine: 3D Analyst
ArcGIS for Desktop Basic: 3D Analyst
ArcGIS for Desktop Standard: 3D Analyst
ArcGIS for Desktop Advanced: 3D Analyst