oriels/app/dofs/stretch-cursor/og/StretchCursor.cs
2022-10-03 17:28:37 -04:00

26 lines
513 B
C#

namespace Oriels;
class StretchCursor : dof {
// input
public Pose to, from;
// data
public Vec3 cursor;
public void Init() {}
public void Frame() {
Vec3 vec = to.position - from.position;
float len = vec.Length;
Vec3 dir = vec / len;
float stretch = Math.Max(len - deadzone, 0f);
cursor = to.position + dir * stretch * strength;
Mesh.Cube.Draw(Material.Default, Matrix.TS(cursor, 0.01f));
}
// design
public float deadzone = 0.1f;
public float strength = 3f;
}