constructor( gl, texture ){ this.gl = gl; if(prg == null){ prg = WarpPRG(gl); } this.geom = Plane(); this.uvs = this.geom.uvs; this.prg = prg; // Setting up default buffers this.verticesBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer); gl.bufferData(gl.ARRAY_BUFFER, this.geom.vertices, gl.STATIC_DRAW); this.verticesBuffer.itemSize = this.geom.itemSize; this.verticesBuffer.numItems = this.geom.vertices.length / this.geom.itemSize; if(this.uvs){ this.textureBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.textureBuffer); gl.bufferData(gl.ARRAY_BUFFER, this.uvs, gl.STATIC_DRAW); } this.prg.use(); this.startTime = Date.now(); this.radius = 0.0; var ctrl = GUI.addFolder('warp'); ctrl.add(this, 'radius', 0, 1); this.texture = texture; // document.addEventListener('click', ()=>{ // this.hide(); // TweenMax.delayedCall(4, this.show.bind(this)); // }); // window.setInterval(()=>{ // this.hide(); // TweenMax.delayedCall(4, this.show.bind(this)); // }, 8000); // this.hide(); // TweenMax.delayedCall(4, this.show.bind(this)); document.addEventListener('mousedown', ()=>{ this.hide(); }); document.addEventListener('mouseup', ()=>{ this.show(); }); }
constructor(gl, texture){ this.gl = gl; if(prg == null){ prg = PlanePRG(gl); } this.geom = Plane(); this.uvs = this.geom.uvs; this.prg = prg; // Setting up default buffers this.verticesBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer); gl.bufferData(gl.ARRAY_BUFFER, this.geom.vertices, gl.STATIC_DRAW); this.verticesBuffer.itemSize = this.geom.itemSize; this.verticesBuffer.numItems = this.geom.vertices.length / this.geom.itemSize; if(this.uvs){ this.textureBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.textureBuffer); gl.bufferData(gl.ARRAY_BUFFER, this.uvs, gl.STATIC_DRAW); } this.prg.use(); this.exposure = 0.52; this.decay = 0.95; this.density = 1; this.weight = 0.24; this.lightPositionOnScreen = { x: 0.5, y: 0.5 }; this.prg.exposure( this.exposure ); this.prg.decay( this.decay ); this.prg.density( this.density ); this.prg.weight( this.weight ); var ctrl = GUI.addFolder('ambient'); ctrl.add(this, 'exposure', 0, 1); ctrl.add(this, 'decay', 0, 2); ctrl.add(this, 'density', 0, 1); ctrl.add(this, 'weight', 0, 1); this.texture = texture; }