Call setSize in constructor

This commit is contained in:
yushijinhun 2020-01-31 01:35:02 +08:00
parent d72b310772
commit 6c7ac2a8d2
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4
1 changed files with 8 additions and 5 deletions

View File

@ -64,7 +64,6 @@ export class SkinViewer {
this.camera.position.z = 60;
this.renderer = new WebGLRenderer({ alpha: true });
this.renderer.setSize(300, 300); // default size
this.domElement.appendChild(this.renderer.domElement);
this.playerObject = new PlayerObject(this.skinTexture, this.capeTexture);
@ -96,10 +95,14 @@ export class SkinViewer {
this.playerObject.cape.visible = true;
};
if (options.skinUrl) this.skinUrl = options.skinUrl;
if (options.capeUrl) this.capeUrl = options.capeUrl;
if (options.width) this.width = options.width;
if (options.height) this.height = options.height;
if (options.skinUrl !== undefined) {
this.skinUrl = options.skinUrl;
}
if (options.capeUrl !== undefined) {
this.capeUrl = options.capeUrl;
}
this.width = options.width === undefined ? 300 : options.width;
this.height = options.height === undefined ? 300 : options.height;
window.requestAnimationFrame(() => this.draw());
}