UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

59 lines (58 loc) 1.62 kB
import Graph from "./Graph.mjs"; import TexturePool from "./TexturePool.mjs"; import FrameBuffer from "../FrameBuffer.mjs"; var Compositor = Graph.extend( function() { return { _outputs: [], _texturePool: new TexturePool(), _frameBuffer: new FrameBuffer({ depthBuffer: false }) }; }, { addNode: function(node) { Graph.prototype.addNode.call(this, node); node._compositor = this; }, render: function(renderer, frameBuffer) { if (this._dirty) { this.update(); this._dirty = false; this._outputs.length = 0; for (var i = 0; i < this.nodes.length; i++) { if (!this.nodes[i].outputs) { this._outputs.push(this.nodes[i]); } } } for (var i = 0; i < this.nodes.length; i++) { this.nodes[i].beforeFrame(); } for (var i = 0; i < this._outputs.length; i++) { this._outputs[i].updateReference(); } for (var i = 0; i < this._outputs.length; i++) { this._outputs[i].render(renderer, frameBuffer); } for (var i = 0; i < this.nodes.length; i++) { this.nodes[i].afterFrame(); } }, allocateTexture: function(parameters) { return this._texturePool.get(parameters); }, releaseTexture: function(parameters) { this._texturePool.put(parameters); }, getFrameBuffer: function() { return this._frameBuffer; }, dispose: function(renderer) { this._texturePool.clear(renderer); } } ); var Compositor$1 = Compositor; export { Compositor$1 as default };