THREE.JS:如何检查该对象组是否已呈现?

时间:2017-05-30 15:43:23

标签: canvas three.js screenshot render

我需要在我的对象组添加并在场景中渲染后制作屏幕截图;

我尝试将eventListener添加到“已添加”事件,该事件在对象添加到场景时触发,但仍未呈现,因此在屏幕截图中不存在;

    add: function ( object ) {

        if ( arguments.length > 1 ) {

            for ( var i = 0; i < arguments.length; i ++ ) {

                this.add( arguments[ i ] );

            }

            return this;

        }

        if ( object === this ) {

            console.error( "THREE.Object3D.add: object can't be added as a child of itself.", object );
            return this;

        }

        if ( (object && object.isObject3D) ) {

            if ( object.parent !== null ) {

                object.parent.remove( object );

            }

            object.parent = this;
            object.dispatchEvent( { type: 'added' } );
  

object.dispatchEvent({type:'added'});

            this.children.push( object );

        } else {

            console.error( "THREE.Object3D.add: object not an instance of THREE.Object3D.", object );

        }

        return this;

    },

据我所知它对我没有帮助,因为在向场景添加对象并创建截图后调用了render,这就是为什么这个订阅对我没有帮助;

这里是代码示例:

   let group = new THREE.Group();   

    // here some objects were added to group

    scene.add(group);

    window.open(renderer.domElement.toDataURL('image/png'), 'screenshot');

有什么建议吗?

0 个答案:

没有答案