Waypoints, deformation and pasting
Node view waypoints, deformation matrices and copyPaste.
Waypoints
A waypoint is a point the Node view draws a cable through. scene().waypoints lists them, each with its group, its place, what it hangs from and the in ports it leads to. buhayin.waypoint reads and changes them. Every change is an edit, so it is an undo step.
buhayin.waypoint
await buhayin.waypoint.add(group, name, x, y)
await buhayin.waypoint.deleteWaypoint(name)
await buhayin.waypoint.setCoord(name, x, y)
await buhayin.waypoint.coordX(name)
await buhayin.waypoint.coordY(name)add puts a waypoint at x, y in a group. Pass a falsy group to use the top. setCoord moves one, and coordX and coordY read where it is. A name that is not a waypoint throws "There is no waypoint called ...".
await buhayin.waypoint.add("", "Bend", 400, 200)
print(await buhayin.waypoint.coordX("Bend"))#### Linking
await buhayin.waypoint.linkOutportToWaypoint(node, port, name)
await buhayin.waypoint.linkWaypointToWaypoint(parent, child)
await buhayin.waypoint.linkWaypointToInport(name, node, port)These join a node's out port to a waypoint, a waypoint to another, and a waypoint to a node's in port.
#### Unlinking
await buhayin.waypoint.unlinkParent(name)
await buhayin.waypoint.unlinkChildInport(name, node, port)
await buhayin.waypoint.unlinkChildNode(name, node)
await buhayin.waypoint.unlinkChildWaypoint(parent, child)
await buhayin.waypoint.unlinkAllChildren(name)#### Reading
await buhayin.waypoint.parentNode(name)
await buhayin.waypoint.parentOutport(name)
await buhayin.waypoint.parentWaypoint(name)
await buhayin.waypoint.childNodes(name)
await buhayin.waypoint.childInports(name)
await buhayin.waypoint.childWaypoints(name)
await buhayin.waypoint.getWaypointsInGroup(group)
await buhayin.waypoint.getAllWaypointsAbove(node, inPort)
await buhayin.waypoint.getAllWaypointsBelow(node, outPort)getAllWaypointsAbove lists the waypoints on the cable into an in port, nearest the port first. getAllWaypointsBelow lists those on the cables under an out port, each followed by what hangs from it.
Deformation
buhayin.deformation
await buhayin.deformation.lastDeformMatrix(node, frame)
await buhayin.deformation.nextDeformMatrix(node, frame)
await buhayin.deformation.lastRestMatrix(node)
await buhayin.deformation.nextRestMatrix(node)Each gives a Matrix4x4 for a node of a deformation chain: where the chain's last piece starts (last) or where the chain ends (next), posed on a frame or at rest.
const pose = await buhayin.deformation.lastDeformMatrix("Arm", 12)
print(pose.origin())Copy and paste
buhayin.copyPaste
const taken = buhayin.copyPaste.copy(layers, startFrame, numFrames)
await buhayin.copyPaste.paste(taken, layers, startFrame, numFrames, options?)
buhayin.copyPaste.usePasteSpecial(on)
buhayin.copyPaste.getCurrentPasteOptions()copy notes a block of cells: the layers and the frames from startFrame for numFrames frames. It makes the block and does not touch the scene. paste lays it down on layers from startFrame as a pasteCells edit, one undo step.
const block = buhayin.copyPaste.copy(["Body"], 1, 12)
await buhayin.copyPaste.paste(block, ["Body"], 13, 12)With usePasteSpecial(true), a paste takes its options from Paste Special. With it off, a paste is the plain one, whatever the options say. getCurrentPasteOptions() gives a PasteOptions you can read and set, and you can pass one to paste as options.
Paste Special has 28 options. These decide what a paste does.
| Option | What it sets |
|---|---|
drawingPasteAction | "DO_NOTHING", "ADD_OR_REMOVE_EXPOSURE" (the default) or "UPDATE_PIVOT": whether the paste takes the exposure or the pivot. |
drawingFileMode | How drawings are made: "NEVER_CREATE", "ONLY_CREATE_IF_DOES_NOT_EXIST" (the default), "ALWAYS_CREATE", "ALWAYS_CREATE_AND_VERSION_IF_NECESSARY" or "REPLACE_EXISTING". |
addRemoveMotionKeyFrame, addRemoveAngleKeyFrame, addRemoveSkewKeyFrame, addRemoveScalingKeyFrame | Whether motion, rotation, skew and scale keys come along. All on by default. |
forceKeyframeAtBeginningAndEnd | Puts a key at each end of the pasted stretch. |
offsetKeyFrame | Offsets the keys. |
autoExtendExposure | Holds the last drawing to the next key. |
startFrameSource, numberOfFramesSource | Which frames of the copy to take: from which frame of it, and how many. A count of 0 takes the whole copy. |
The other options are kept and read back, but change nothing a paste does. A word an option does not accept leaves it as it was.