transform property

  1. @nonVirtual
Transform get transform

Where the object is, how it's turned and how big it is, relative to its parent: localPosition, localRotation and localScale in one. position and rotation are the world's. Reading it makes no call into the engine. Setting it checks the value at once, as the engine would, and sends it with the frame's other moves in one call when something next reads the engine's transforms (a view's frame, World.raycast, worldTransform). It reads back exactly as it was set; the engine keeps it in 32-bit floats, so what it draws may differ in the last digits.

Implementation

@nonVirtual
Transform get transform {
  if (_described case final d?) return d.transform;
  final w = _engine('its transform can\'t be read');
  if (_transform case final t?) return t;
  check(fy_transform_get(w, id, scratch.transform));
  final t = scratch.transform.ref;
  return _transform = Transform._(t.position.read(), t.rotation.read(), t.scale.read());
}
  1. @nonVirtual
set transform (Transform value)

Implementation

@nonVirtual
set transform(Transform value) {
  if (_described case final d?) {
    _check(value, this);
    d.transform = value;
    return;
  }
  final w = _engine('its transform can\'t be set');
  if (_transform == null && !fy_exists(w, _id)) {
    throw StateError('$this was destroyed, or never added');
  }
  _check(value, this);
  _setTransform(value);
}