Anyone have code for replicating a node's position?

I need to create a scenegraph node of a different type that completely mimics another node’s position (rotation, translation, etc.).

Does anyone have any code for this, or any hints?

You can read every property of an existing node, create a new node with a different type, and apply those properties to the new node. I don’t have an example code for this. Other on the forum might…?

Yes, that’s what I’m trying, but that involves setting both rotation and placingInParent–you can’t just set the read-only translation matrix–, which together aren’t obvious how to use.

@stevekwak helped me greatly by fixing my broken code.

For the record, here’s the very useful resulting snippet.

// Make the new node correspond to the existing
// node's position and rotation, etc.
// Assumes both share their parent.
// We've already taken care of scale by using
// the original node's size as a basis for
// newNode creation, so the only components left
// are translation and rotation.
const makeNodeCongruentTo = (newNode, node) => {
      x: newNode.localBounds.x,
      y: newNode.localBounds.y,
    { x: node.topLeftInParent.x, y: node.topLeftInParent.y }
  if (newNode.rotation != node.rotation)
    newNode.rotateAround(node.rotation - newNode.rotation, {
      x: newNode.localBounds.x,
      y: newNode.localBounds.y,