12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /**
- * @author sunag / http://www.sunag.com.br/
- */
- import { InputNode } from '../core/InputNode.js';
- import { NodeMaterial } from '../materials/NodeMaterial.js';
- import { TextureNode } from './TextureNode.js';
- function RTTNode( width, height, node, options ) {
- this.node = node;
-
- this.clear = true;
-
- this.rtt = new THREE.WebGLRenderTarget( width, height, options );
-
- this.material = new THREE.NodeMaterial();
-
- this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
- this.scene = new THREE.Scene();
- this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), this.material );
- this.quad.frustumCulled = false; // Avoid getting clipped
- this.scene.add( this.quad );
- TextureNode.call( this, this.rtt.texture );
- };
- RTTNode.prototype = Object.create( TextureNode.prototype );
- RTTNode.prototype.constructor = RTTNode;
- RTTNode.prototype.nodeType = "RTT";
- RTTNode.prototype.generate = function ( builder, output ) {
-
- this.material.fragment.value = this.node;
-
- return TextureNode.prototype.generate.call( this, builder, output );
- };
- RTTNode.prototype.updateFrame = function ( frame ) {
-
- if ( frame.renderer ) {
-
- frame.renderer.render( this.scene, this.camera, this.rtt, this.clear );
-
- } else {
-
- console.warn("RTTNode need a renderer in NodeFrame")
-
- }
-
- };
- export { RTTNode };
|