UArNode.line constructor

UArNode.line({
  1. required String id,
  2. required UArVector3 from,
  3. required UArVector3 to,
  4. double thickness = 0.004,
  5. Color color = const Color(0xFFFFFFFF),
  6. String? anchorId,
  7. bool renderOnTop = false,
})

A thin bar between two points, e.g. a measuring line.

Implementation

factory UArNode.line({
  required String id,
  required UArVector3 from,
  required UArVector3 to,
  double thickness = 0.004,
  Color color = const Color(0xFFFFFFFF),
  String? anchorId,
  bool renderOnTop = false,
}) {
  final UArVector3 delta = to - from;
  final double length = delta.length;
  final UArQuaternion rotation = length < 1e-6 ? UArQuaternion.identity : UArQuaternion.lookRotation(delta);
  return UArNode(
    id: id,
    type: UArNodeType.box,
    width: thickness,
    height: thickness,
    depth: length,
    position: from.lerp(to, 0.5),
    rotation: rotation,
    anchorId: anchorId,
    material: UArMaterial(color: color, unlit: true, renderOnTop: renderOnTop),
    castShadow: false,
    hittable: false,
  );
}