Class DraggableModel
Component that makes a 3D model draggable with smooth animations. Provides lift, follow, and drop animations for drag and drop interactions.
public class DraggableModel
- Inheritance
-
DraggableModel
- Inherited Members
Constructors
DraggableModel(Model, Vector3, Vector3, Vector3)
public DraggableModel(Model model, Vector3 position, Vector3 rotation, Vector3 scale)
Parameters
Properties
DragFollowRate
How fast the dragged model converges on the cursor, per second. High enough that the model reads as held by the cursor (~95% in 0.075s) instead of trailing behind it — drop targeting is cursor-based, so a laggy model misleads the player about where the piece will land.
public float DragFollowRate { get; set; }
Property Value
IsAnimating
True while a lift, drop or return-to-origin tween is still running. Lets callers wait for the model to settle — e.g. to play a landing sound on contact rather than when the move was committed.
public bool IsAnimating { get; }
Property Value
IsDragging
public bool IsDragging { get; }
Property Value
IsValidDropTarget
public bool IsValidDropTarget { get; set; }
Property Value
LiftHeight
public float LiftHeight { get; set; }
Property Value
Model
public Model Model { get; set; }
Property Value
- Model
OriginalPosition
public Vector3 OriginalPosition { get; }
Property Value
Position
public Vector3 Position { get; set; }
Property Value
Rotation
public Vector3 Rotation { get; set; }
Property Value
Scale
public Vector3 Scale { get; set; }
Property Value
Tint
public Color Tint { get; set; }
Property Value
- Color
Methods
CheckRayCollision(Ray)
Checks if a ray intersects with this model.
public RayCollision CheckRayCollision(Ray ray)
Parameters
rayRayThe ray to test
Returns
- RayCollision
Collision information
GetWorldBoundingBox()
Gets the world space bounding box for this model.
public BoundingBox GetWorldBoundingBox()
Returns
- BoundingBox
The bounding box in world coordinates
Render()
Renders the model with current transform and any visual effects.
public void Render()
ReturnToOriginalPosition()
Returns the model to its original position with animation.
public void ReturnToOriginalPosition()
StartDrag(Vector3)
Starts dragging this model with a lift animation.
public void StartDrag(Vector3 dragOffset)
Parameters
dragOffsetVector3Offset from model center to mouse position
StopDrag(Vector3, bool)
Stops dragging and animates the model to the target position.
public void StopDrag(Vector3 targetPosition, bool updateOriginalPosition = true)
Parameters
targetPositionVector3Final position for the model
updateOriginalPositionboolWhether to update the original position
Update(double)
Updates the draggable model, handling animations and drag state.
public void Update(double deltaTime)
Parameters
deltaTimedoubleTime since last update in seconds
UpdateDrag(Vector3, double)
Updates the drag position to follow the mouse with smooth interpolation.
public void UpdateDrag(Vector3 mouseWorldPosition, double deltaTime = 0.016666666666666666)