Class DraggableModel
Component that makes a 3D model draggable with smooth animations. Provides lift, follow, and drop animations for drag and drop interactions.
Inherited Members
Namespace: PopcorningGuineaPig.Engine.Gameplay
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public class DraggableModel
Constructors
| Edit this page View SourceDraggableModel(Model, Vector3, Vector3, Vector3)
Declaration
public DraggableModel(Model model, Vector3 position, Vector3 rotation, Vector3 scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Model | model | |
| Vector3 | position | |
| Vector3 | rotation | |
| Vector3 | scale |
Properties
| Edit this page View SourceDragFollowRate
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.
Declaration
public float DragFollowRate { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
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.
Declaration
public bool IsAnimating { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsDragging
Declaration
public bool IsDragging { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsValidDropTarget
Declaration
public bool IsValidDropTarget { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
LiftHeight
Declaration
public float LiftHeight { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Model
Declaration
public Model Model { get; set; }
Property Value
| Type | Description |
|---|---|
| Model |
OriginalPosition
Declaration
public Vector3 OriginalPosition { get; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
Position
Declaration
public Vector3 Position { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
Rotation
Declaration
public Vector3 Rotation { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
Scale
Declaration
public Vector3 Scale { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
Tint
Declaration
public Color Tint { get; set; }
Property Value
| Type | Description |
|---|---|
| Color |
Methods
| Edit this page View SourceCheckRayCollision(Ray)
Checks if a ray intersects with this model.
Declaration
public RayCollision CheckRayCollision(Ray ray)
Parameters
| Type | Name | Description |
|---|---|---|
| Ray | ray | The ray to test |
Returns
| Type | Description |
|---|---|
| RayCollision | Collision information |
GetWorldBoundingBox()
Gets the world space bounding box for this model.
Declaration
public BoundingBox GetWorldBoundingBox()
Returns
| Type | Description |
|---|---|
| BoundingBox | The bounding box in world coordinates |
Render()
Renders the model with current transform and any visual effects.
Declaration
public void Render()
ReturnToOriginalPosition()
Returns the model to its original position with animation.
Declaration
public void ReturnToOriginalPosition()
StartDrag(Vector3)
Starts dragging this model with a lift animation.
Declaration
public void StartDrag(Vector3 dragOffset)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | dragOffset | Offset from model center to mouse position |
StopDrag(Vector3, bool)
Stops dragging and animates the model to the target position.
Declaration
public void StopDrag(Vector3 targetPosition, bool updateOriginalPosition = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | targetPosition | Final position for the model |
| bool | updateOriginalPosition | Whether to update the original position |
Update(double)
Updates the draggable model, handling animations and drag state.
Declaration
public void Update(double deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| double | deltaTime | Time since last update in seconds |
UpdateDrag(Vector3, double)
Updates the drag position to follow the mouse with smooth interpolation.
Declaration
public void UpdateDrag(Vector3 mouseWorldPosition, double deltaTime = 0.016666666666666666)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | mouseWorldPosition | Current mouse position in world space |
| double | deltaTime | Seconds since the last update. Smoothing is frame-rate independent, so the model tracks identically at 30, 60 and 144 fps. |