OrbPro2 a Cesium distribution

DraggableEntities

new Cesium.DraggableEntities(viewer, options)

Name Type Description
viewer Viewer The Cesium Viewer instance.
options DraggableEntities.Options optional Configuration options for the drag and drop handler.
Examples:
// Make a single entity draggable
const handler = new DraggableEntities(viewer, {
  entities: singleEntity,
  dragDelay: 200,
  onDrag: function(context) {
    console.log('Drag started at', context.screenPosition);
  },
  onDragging: function(context) {
    console.log('Dragging at', context.screenPosition);
  },
  onDrop: function(context) {
    console.log('Dropped at', context.screenPosition);
  }
});
// Make multiple entities draggable
const handler = new DraggableEntities(viewer, {
  entities: [entity1, entity2, entity3],
  onDrag: function(context) { /* ... *\/ },
  onDragging: function(context) { /* ... *\/ },
  onDrop: function(context) { /* ... *\/ }
});
// Make all entities in a collection draggable
const collection = new Cesium.EntityCollection();
// Add entities to the collection
const handler = new DraggableEntities(viewer, {
  entities: collection,
  onDrag: function(context) { /* ... *\/ },
  onDragging: function(context) { /* ... *\/ },
  onDrop: function(context) { /* ... *\/ }
});

Members

_initialEnableTranslate : boolean

_initialHeight : number|undefined

_initialPositionCartesian : Cartesian3|undefined

The internal TransformGizmo instance, or null if gizmo is not enabled. Use this to toggle `showTranslate` / `showRotate` at runtime.
Check if the handler is active.
Check if dragging is currently active.
The entity currently selected for the transform gizmo.

Methods

static Cesium.DraggableEntities.enlargeEllipsoid(e, m)Ellipsoid

Enlarge an ellipsoid by a given amount.
Name Type Description
e Ellipsoid The original ellipsoid.
m number The amount to enlarge each radius.
Returns:
The enlarged ellipsoid.

_clampAboveSurface(position)Cartesian3|undefined

Clamp a position so it never goes below the terrain surface (or ellipsoid when terrain height is unavailable) plus a small buffer.
Name Type Description
position Cartesian3 | undefined The position to clamp.
Returns:
The clamped position, or the original if already above.

_convertCartesian2ToPosition(position)Cartesian3|undefined

Convert a screen position to a Cartesian3 position based on the dragMode.
Name Type Description
position Cartesian2 The screen position.
Returns:
The Cartesian3 position or undefined.

_createContext(position, screenPosition)DraggableEntities.Context|undefined

Create a context object for the current drag/drop operation.
Name Type Description
position Cartesian3 | undefined The current position.
screenPosition Cartesian2 The current screen position.
Returns:
The context object or undefined.
Handle LEFT_CLICK for gizmo entity selection/deselection.
Name Type Description
e Object The event object.
Handle the drag start event.
Name Type Description
e Object The event object containing the position.
Handle the dragging event.
Name Type Description
e Object The event object containing start and end positions.
Handle the drop event.
Name Type Description
e Object The event object containing the position.
Pick a draggable entity at the given screen position.
Name Type Description
position Cartesian2 The screen position to pick.
Returns:
The picked entity or undefined.

_resetHeight(position)Cartesian3|undefined

Reset the height of the position based on the initial height.
Name Type Description
position Cartesian3 | undefined The position to reset.
Returns:
The position with reset height or the original position.
Add an entity to the set of draggable entities.
Name Type Description
entity Entity The entity to make draggable.
Cancel the current dragging operation.
Clear all draggable entities.
Destroy this handler and release resources. Once destroyed, the handler should not be used.
Disable the drag and drop functionality.
Enable the drag and drop functionality.
Check if an entity is in the draggable set.
Name Type Description
entity Entity The entity to check.
Returns:
True if the entity is draggable.
Check if this handler has been destroyed.
Returns:
True if destroyed.

removeEntity(entity)boolean

Remove an entity from the set of draggable entities.
Name Type Description
entity Entity The entity to remove.
Returns:
True if the entity was removed, false if it wasn't in the set.

Type Definitions

Cesium.DraggableEntities.Context

Properties:
Name Type Attributes Description
entity Entity The current entity being manipulated.
position Cartesian3 <optional>
The current position in Cartesian3 coordinates.
screenPosition Cartesian2 The current screen position.
initialPositionCartesian Cartesian3 <optional>
The initial position in Cartesian3 coordinates.
initialScreenPosition Cartesian2 The initial screen position.

Cesium.DraggableEntities.Options

Options for configuring the DragDropHandler.
Properties:
Name Type Attributes Default Description
initialDisabled boolean <optional>
false If `true`, prevents drag and drop from being automatically enabled.
dragMode '2D' | '3D' | 'FIXED_DISTANCE' <optional>
'2D' The dragging mode: - '2D': Uses camera.pickEllipsoid, best for entities on the ellipsoid surface. - '3D': Uses scene.pickPosition, best for entities on terrain. - 'FIXED_DISTANCE': Maintains entity's distance from camera, best for objects in space (lights, satellites).
dragDelay number <optional>
0 The number of milliseconds to wait before starting the drag.
dragInputType ScreenSpaceEventType <optional>
ScreenSpaceEventType.LEFT_DOWN The event type to initiate dragging.
draggingInputType ScreenSpaceEventType <optional>
ScreenSpaceEventType.MOUSE_MOVE The event type during dragging.
dropInputType ScreenSpaceEventType <optional>
ScreenSpaceEventType.LEFT_UP The event type to drop.
onDrag function <optional>
Callback invoked when dragging starts. Receives a single `Context` object.
onDragging function <optional>
Callback invoked during dragging. Receives a single `Context` object.
onDrop function <optional>
Callback invoked when dragging ends (drop). Receives a single `Context` object.
clampToSurface boolean <optional>
true When true, prevents entities from being dragged below terrain (or ellipsoid) plus a 0.1 m buffer.
entities Entity | Array.<Entity> | EntityCollection <optional>
The entity or entities to make draggable. If not specified, all entities in the viewer's default collection are draggable.
gizmo boolean <optional>
false Enable the transform gizmo (axis arrows + rotation circles). Click an entity to attach the gizmo.
gizmoSize number <optional>
World-space size of the gizmo in meters.
gizmoModelMatrix function <optional>
Optional callback(entity, time, result) returning an unscaled Matrix4 for the transform gizmo frame.
showTranslate boolean <optional>
true Show translation arrows on the gizmo.
showRotate boolean <optional>
true Show rotation circles on the gizmo.
onTranslate function <optional>
Callback(entity, newPosition) during axis-constrained translation.
onRotate function <optional>
Callback(entity, newOrientation) during axis-constrained rotation.
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.