从r68开始在THRE.js上获取Descendants()的正确方法

Proper way to getDescendants() on THREE.js as of r68

本文关键字:方法 Descendants 获取 开始 r68 THRE js      更新时间:2023-09-26

自r68以来,getDescendants()方法已从THREE.Object3D中删除。

现在执行相同功能的推荐方法是什么?(由于没有提供警告消息…)

这是从r.68:中删除的getDescendants()方法

THREE.Object3D.prototype.getDescendants = function ( array ) {
    if ( array === undefined ) array = [];
    Array.prototype.push.apply( array, this.children );
    for ( var i = 0, l = this.children.length; i < l; i ++ ) {
        this.children[ i ].getDescendants( array );
    }
    return array;
};

如果你想写一些自定义的东西,你可以使用Object3D.traverse()方法;

object.traverse( function( node ) {
    // your code here
} );

three.js r.68