resolveMove method
({Vector2 marker, Transform2 transform})?
resolveMove(
- ToolContext ctx,
- Handle node,
- Transform2 delta
For a root-level instance whose library entry carries
againstWallTag, with object snap on, the library ready and an
orthonormal transform (W-8: a file's scaled instance never attaches,
so its scale is never dropped): attachToWall for the plain-moved
back-centre delta · T · c (S-1), its own instance excluded from the
neighbours, its mirror kept, and, while canRotate refuses, its
linear part kept; the marker is the face point. Else null.
Implementation
@override
({Transform2 transform, Vector2 marker})? resolveMove(
ToolContext ctx, Handle node, Transform2 delta) {
final doc = ctx.document;
if (!(ctx.snap?.objectSnap ?? true)) return null;
final lib = library();
if (lib == null || !isSymbolInstance(doc, node)) return null;
final entry = entryOfInstance(lib, doc, node);
if (entry == null || !entry.tags.contains(againstWallTag)) return null;
final instance = doc.tree[node]! as InstanceNode;
final t = instance.transform;
if (!isOrthonormal(t)) return null;
final box = faces.boxOf(doc, instance.definition);
if (box == null) return null;
final moved = delta.multiply(t);
final p = moved.transformPoint(box.backCentre);
final scale = ctx.camera.value.scale;
final attached = faces.attach(doc, box, p, kWallAttachPixels / scale,
mirrored: t.a * t.d - t.b * t.c < 0,
edgeCaptureWorld: kSnapAperturePixels / scale,
exclude: node,
keep: (canRotate?.call() ?? true) ? null : moved);
if (attached == null) return null;
return (transform: attached.transform, marker: attached.q);
}