View on GitHub Sample viewer app

A camera follows a graphic while the graphic’s position and rotation are animated.

Image of animate 3D graphic

How to use the sample

Animation Controls (Top Left Corner):

  • Select a mission — selects a location with a route for plane to fly.
  • Mission progress — shows how far along the route the plane is. Slide to change keyframe in animation.
  • Play/Stop — toggles playing and stopping the animation.
  • Follow/Free Cam — toggles camera following plane.

Speed Slider (Top Right Corner):

  • Controls speed of animation.

2D Map Controls (Bottom Left Corner):

  • Plus and Minus — controls distance of 2D view from ground level.

How it works

  1. Create a ModelSceneSymbol object.
  2. Create a Graphic object and set its geometry to a Point.
  3. Set the ModelSceneSymbol object to the graphic.
  4. Add heading, pitch, and roll attributes to the graphic. Get the attributes from the graphic with Graphic.getAttributes().
  5. Create a SimpleRenderer object and set its expression properties.
  6. Add graphic and a renderer to the graphics overlay.
  7. Create a OrbitGeoElementCameraController which is set to target the graphic.
  8. Assign the camera controller to the SceneView.
  9. Update the graphic’s location, heading, pitch, and roll.

Relevant API

  • ArcGISScene
  • Camera
  • GlobeCameraController
  • Graphic
  • GraphicsOverlay
  • ModelSceneSymbol
  • OrbitGeoElementCameraController
  • Renderer
  • SceneProperties
  • SceneView
  • SurfacePlacement

Tags

animation, camera, heading, pitch, roll, rotation, visualize

Sample Code

module-info.java module-info.java Animate3dGraphicController.java Animate3dGraphicSample.java AnimationModel.java
/*
* Copyright 2022 Esri.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module com.esri.samples.animate_3d_graphic {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
// make all @FXML annotated objects reflectively accessible to the javafx.fxml module
opens com.esri.samples.animate_3d_graphic to javafx.fxml;
exports com.esri.samples.animate_3d_graphic;
}