How to clone models in program

hello ,I want to load a dae model into my program,for example a teapot and I want to have 10 teapots in the scene I use the clone function as follow,but the object seems to refer to its parent,and then refer to itself so I can’t clone it ,how can I have 10 copies of my object?

var dae;
var dae = [];
var loader = new THREE.ColladaLoader();
    loader.options.convertUpAxis = true;
    loader.load( 'teapot.dae',function colladaReady( collada ) {
        dae = collada.scene;
        for(var i = 0;i < 10;++i){
            daes[i] = clone(dae);
        }
    });
}
function clone(obj){
    if(obj == null || typeof(obj) != 'object')
        return obj;
    var temp = new Object();//obj.constructor(); // changed
    for(var key in obj)
        temp[key] = clone(obj[key]);
    return temp;
}

Author: Fantashit

1 thought on “How to clone models in program

  1. Please don’t post at threads which are closed for years. Open a new issue instead, provide your dae file and the respective three.js code.

Comments are closed.