add 'renderPaused' option to SkinViewerOptions
This commit is contained in:
parent
3aa66bfae0
commit
da09d950aa
|
@ -39,7 +39,7 @@ export class FXAASkinViewer extends SkinViewer {
|
|||
this.fxaaPass.material.uniforms["resolution"].value.y = 1 / (this.height * pixelRatio);
|
||||
}
|
||||
|
||||
protected doRender(): void {
|
||||
render(): void {
|
||||
this.composer.render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,12 @@ export type SkinViewerOptions = {
|
|||
* Whether to preserve the buffers until manually cleared or overwritten. Default is false.
|
||||
*/
|
||||
preserveDrawingBuffer?: boolean;
|
||||
|
||||
/**
|
||||
* The initial value of `SkinViewer.renderPaused`. Default is false.
|
||||
* If this option is true, rendering and animation loops will not start.
|
||||
*/
|
||||
renderPaused?: boolean;
|
||||
}
|
||||
|
||||
function toMakeVisible(options?: LoadOptions): boolean {
|
||||
|
@ -92,8 +98,6 @@ class SkinViewer {
|
|||
this.playerObject.cape.visible = false;
|
||||
this.scene.add(this.playerObject);
|
||||
|
||||
window.requestAnimationFrame(() => this.draw());
|
||||
|
||||
if (options.skin !== undefined) {
|
||||
this.loadSkin(options.skin);
|
||||
}
|
||||
|
@ -106,6 +110,12 @@ class SkinViewer {
|
|||
if (options.height !== undefined) {
|
||||
this.height = options.height;
|
||||
}
|
||||
|
||||
if (options.renderPaused === true) {
|
||||
this._renderPaused = true;
|
||||
} else {
|
||||
window.requestAnimationFrame(() => this.draw());
|
||||
}
|
||||
}
|
||||
|
||||
protected skinLoaded(model: ModelType, options?: LoadOptions): void {
|
||||
|
@ -136,11 +146,15 @@ class SkinViewer {
|
|||
return;
|
||||
}
|
||||
this.animations.runAnimationLoop(this.playerObject);
|
||||
this.doRender();
|
||||
this.render();
|
||||
window.requestAnimationFrame(() => this.draw());
|
||||
}
|
||||
|
||||
protected doRender(): void {
|
||||
/**
|
||||
* Renders the scene to the canvas.
|
||||
* This method does not change the animation progress.
|
||||
*/
|
||||
render(): void {
|
||||
this.renderer.render(this.scene, this.camera);
|
||||
}
|
||||
|
||||
|
@ -161,6 +175,11 @@ class SkinViewer {
|
|||
return this._disposed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether rendering and animations are paused.
|
||||
* Setting this property to true will stop both rendering and animation loops.
|
||||
* Setting it back to false will resume them.
|
||||
*/
|
||||
get renderPaused(): boolean {
|
||||
return this._renderPaused;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue