add 'preserveDrawingBuffer' option

The default value of 'preserveDrawingBuffer' is changed back to false
due to performance concern. To turn it on, you have to specify
'preserveDrawingBuffer: true' in SkinViewerOptions.

Related: #65, #67
This commit is contained in:
Haowei Wen 2020-09-09 14:06:53 +08:00
parent 5e89411f87
commit 0b9cccfa68
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4
1 changed files with 8 additions and 2 deletions

View File

@ -27,6 +27,11 @@ export type SkinViewerOptions = {
* A new canvas is created if this parameter is unspecified.
*/
canvas?: HTMLCanvasElement;
/**
* Whether to preserve the buffers until manually cleared or overwritten. Default is false.
*/
preserveDrawingBuffer?: boolean;
}
function toMakeVisible(options?: LoadOptions): boolean {
@ -75,8 +80,9 @@ class SkinViewer {
this.renderer = new WebGLRenderer({
canvas: this.canvas,
alpha: options.alpha !== false, // alpha is on by default
preserveDrawingBuffer: true
alpha: options.alpha !== false, // default: true
preserveDrawingBuffer: options.preserveDrawingBuffer === true // default: false
});
this.renderer.setPixelRatio(window.devicePixelRatio);