viromedia / virocore

ViroCore cross-platform AR/VR renderer
MIT License
370 stars 108 forks source link

A way to copy a node? #258

Open toniuyt123 opened 5 years ago

toniuyt123 commented 5 years ago

Is there a way to copy a node? Right now I've created a NodeBuilder and have set all of it's components to be the same as the node I want to copy. Then I build the new node and add it to the corresponding parent. What I get from this is that the old Node becomes an empty node with node geometry and the new one constructs correctly. I assume the geometry gets referenced to the new node and transfers there. Is there a way to keep both nodes?

        Node.NodeBuilder builder = new Node.NodeBuilder<>();
        builder.name(node.getName())
            .geometry(node.getGeometry())
            .clickListener(node.getClickListener())
            .children((ArrayList<Node>) node.getChildNodes())
            .scale(node.getScaleRealtime())
            .position(node.getWorldTransformRealTime().extractTranslation())
            .visible(true);
        Node newNode = builder.build();
        node.getParentNode().addChildNode(newNode);