深度克隆(使用材质)不再适用于v0.91

时间:2018-03-27 13:17:33

标签: three.js

我使用版本0.79。要克隆一些网格,我使用这些原型:

// Prototypes
THREE.Object3D.prototype.GdeepCloneMaterials = function() 
{

                var object = this.clone( new THREE.Object3D(), false );
                for ( var i = 0; i < this.children.length; i++ ) 
                {
                        var child = this.children[ i ];
                        if ( child.GdeepCloneMaterials ) 
                        {
                                object.add( child.GdeepCloneMaterials() );
                        } 
                        else 
                        {
                                object.add( child.clone() );
                        }
                }
                return object;
};

THREE.Mesh.prototype.GdeepCloneMaterials = function( object, recursive ) 
{
        if ( object === undefined ) {
                object = new THREE.Mesh( this.geometry, this.material.clone() );
        }
        THREE.Object3D.prototype.GdeepCloneMaterials.call( this, object, recursive );
        return object;
};
/////////////

loader = new THREE.ColladaLoader();
loader.load( '/public/scene/Spawn.dae', function(geometry) 
{
        clone=geometry.scene.GdeepCloneMaterials();
});

我想更新到版本0.91,但深度克隆方法不再有效,我收到错误:

 Uncaught TypeError: this.material.clone is not a function
at Mesh.THREE.Mesh.GdeepCloneMaterials at Group.THREE.Object3D.GdeepCloneMaterials 

如何解决?感谢。

0 个答案:

没有答案