render to custom RenderTarget using Three.js

596
0
05-29-2018 02:05 AM
mofangbao
New Contributor

Hello,everyone:

    I'm working on render a three.js scene to texture,so i can postprocess the texture and  use in another scene,but i found that creating custom THREE.WebGLRenderTarget doesn't work. I'v read many articles and codes relate to externalRenderers and tried for serveral days,so if you can help,i will so appreciate.

    Here is my render method for renderer:

render(context?:any) {
this.updateCamera(context);
this.updateLights(context);
this.renderer.state.reset();
this.renderer.render(this.scene, this.camera);
for (let targetOptKey in this.targetsToRender) {
let targetOpt = this.targetsToRender[targetOptKey];
this.renderer.render(targetOpt.scene, this.camera, targetOpt.target);
targetOpt.rendered(targetOpt);
if (targetOpt.once) {
this.removeTarget(targetOptKey);
}
}
context.resetWebGLState();
this.fire('rendered', {});
if (this._animiating) {
this.fire('animiating', { delta: this.clock.getDelta(), tick: this.clock.getElapsedTime() });
externalRenderers.requestRender(this.view);
}
}

and also inject  context.bindRenderTarget() to three renderer's setRenderTarget method.

Thanks a lot.

Tags (1)
0 Kudos
0 Replies