Add detectModel option to allow turning auto-detection off

This commit is contained in:
yushijinhun 2018-07-02 20:13:01 +08:00
parent 670647109a
commit 25805bfa59
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4
3 changed files with 10 additions and 1 deletions

View File

@ -21,6 +21,10 @@
skinUrl: "./1_8_texturemap_redux.png"
});
// By default, the skin model is automatically detected. You can turn it off in this way:
// skinViewer.detectModel = false;
// skinViewer.playerObject.skin.slim = true;
let control = new skinview3d.createOrbitControls(skinViewer);
skinViewer.animation = new skinview3d.CompositeAnimation();

View File

@ -123,6 +123,7 @@ class SkinViewer {
constructor(options) {
this.domElement = options.domElement;
this.animation = options.animation || null;
this.detectModel = options.animation !== false; // true by default
this.animationPaused = false;
this.animationTime = 0;
this.disposed = false;
@ -189,7 +190,9 @@ class SkinViewer {
skinContext.drawImage(this.skinImg, 0, 0, this.skinCanvas.width, this.skinCanvas.height);
}
this.playerObject.skin.slim = isSlimSkin(skinContext, this.skinCanvas.width);
if (this.detectModel) {
this.playerObject.skin.slim = isSlimSkin(skinContext, this.skinCanvas.width);
}
this.skinTexture.needsUpdate = true;
this.layer1Material.needsUpdate = true;

2
types/viewer.d.ts vendored
View File

@ -9,6 +9,7 @@ export interface SkinViewerOptions {
capeUrl?: string;
width?: number;
height?: number;
detectModel?: boolean;
}
export class SkinViewer {
@ -21,6 +22,7 @@ export class SkinViewer {
public animation: Animation;
public animationPaused: boolean;
public animationTime: number;
public detectModel: boolean;
public readonly playerObject: PlayerObject;
public readonly scene: THREE.Scene;
public readonly camera: THREE.PerspectiveCamera;