From 25805bfa5955a38a7252deab8327452114add189 Mon Sep 17 00:00:00 2001 From: yushijinhun Date: Mon, 2 Jul 2018 20:13:01 +0800 Subject: [PATCH] Add detectModel option to allow turning auto-detection off --- examples/index.html | 4 ++++ src/viewer.js | 5 ++++- types/viewer.d.ts | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/index.html b/examples/index.html index 059b6c1..14da4d3 100644 --- a/examples/index.html +++ b/examples/index.html @@ -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(); diff --git a/src/viewer.js b/src/viewer.js index d548619..dbab733 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -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; diff --git a/types/viewer.d.ts b/types/viewer.d.ts index f199f6d..a5182c9 100644 --- a/types/viewer.d.ts +++ b/types/viewer.d.ts @@ -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;