I want to implement render on demand. I can not use this method. because the frame is constantly being redrawn by the framework. so I have to give the framework something each frame. however, it would be inefficient to render the scene in each frame. I was wondering if there is a way to render it only once and then save the pixels, and then keep giving the framework the saved pixels or buffer.
This is the framework I am using.
onDraw(
gl: WebGLRenderingContext,
transformer: google.maps.CoordinateTransformer
): void {
const { lat, lng, altitude } = this.anchor;
this.camera.projectionMatrix.fromArray(
transformer.fromLatLngAltitude(
{ lat, lng },
altitude,
this.rotation,
this.scale
)
);
if(!this.camera.projectionMatrix.equals(this.oldCameraMatrix)){
this.oldCameraMatrix.copy(this.camera.projectionMatrix);
this.canRender=true;
console.warn("cameraprojectionmatrix changed");
}
else{
this.canRender=false;
}
gl.disable(gl.SCISSOR_TEST);
this.requestRedraw();
if(this.canRender){
//render if sth changed
this.renderer.render(this.scene, this.camera);
this.canRender=false;
}
else{
//I need help here.if nth changed i just want to render the previous frame
}
}
this.renderer.resetState();
}