If we assume that the container
is an instance of Object3D
.
When you use Object3D.add( child )
, it automatically removes the child from its current parent.
To achieve this, you can follow these steps:
var parentNode1 = new THREE.Object3D();
var childNode1 = new THREE.Object3D();
var childNode2 = new THREE.Object3D();
parentNode1.add( childNode1 );
parentNode1.add( childNode2 );
scene.add( parentNode1 );
var parentNode2 = new THREE.Object3D();
parentNode2.add( childNode2 ); // adding child to a new parent
scene.add( parentNode2 );
console.log( 'parentNode1.children', parentNode1.children );
console.log( 'parentNode2.children', parentNode2.children );
console.log( 'scene.children', scene.children );
Using three.js r.58