Skip to content

Instantly share code, notes, and snippets.

I am attesting that this GitHub handle santi-grau is linked to the Tezos account tz1TQDnNCwU6DYTGFY7HZrFHivNBJW1LthbS for tzprofiles
sig:edsigtvgSQDN8JZKCinyMtJ1iPoCuwrxGGDWLFgYNM27aj8zpW9HdDAfmCHvePoaQS7t4J9U9yrHKqNxbmTEshffrSz4VKmefCd
@santi-grau
santi-grau / EffectComposerGolfed.js
Created March 2, 2022 23:45
Golfed version of EffectComposer
class EC{constructor(r){this.r=r;let s=r.getSize(new THREE.Vector2());this.p=r.getPixelRatio();this.w=s.width;this.h=s.height;let t=new THREE.WebGLRenderTarget(this.w*this.p,this.h*this.p,{minFilter:1006,magFilter:1006,format:1023});this.u=t;this.v=t.clone();this.b=this.u;this.readBuffer=this.v;this.renderToScreen=1;this.t=[];this.c=new THREE.Clock();}sb(){let tmp=this.readBuffer;this.readBuffer=this.b;this.b=tmp;}addPass(p){this.t.push(p);p.setSize(this.w*this.p,this.h*this.p);}lp(p){for(let i=p+1;i<this.t.length;i++)if(this.t[i].enabled)return 0;return 1;}render(){let d=this.c.getDelta(),c=this.r.getRenderTarget();this.t.forEach(p=>{p.renderToScreen=this.renderToScreen&&this.lp(i);p.render(this.r,this.b,this.readBuffer,d,0);if(p.needsSwap)this.sb();});this.r.setRenderTarget(c);};setSize(w,h){this.w=w;this.h=h;let x=this.w*this.p,y=this.h*this.p;this.u.setSize(x,y);this.v.setSize(x,y);this.t.forEach(p=>p.setSize(x,y)); }};