WEBGL pointLight issue with Graphics buffer


#1

Hi, does anyone know why the light source in this example is not changing position?
Thanks!

let gl;
let offsetX = 0;
function setup() {
  createCanvas(400, 400);
	gl = createGraphics(100, 100, WEBGL);
}

function draw() {
		background(0);
        gl.background(0);
		gl.pointLight(255, 255, 255, -100+offsetX, -100, 20);
		gl.plane(100, 100);
		gl.normalMaterial()
		image(gl, 200, 200)
		offsetX++;
}

Here is live example https://editor.p5js.org/r4nd0m_jump/sketches/BJBPHpYCQ


#2

Ok, so after inspecting p5 github repo, I concluded that calling

gl._renderer._update();

at the and of draw function solves the problem.
But I’m not familiar with lifecycle, and why this doesn’t work with gl = createGraphics()??