skinview3d
Advanced tools
Comparing version 1.2.0-alpha.1 to 1.2.0
@@ -20,3 +20,4 @@ import * as THREE from "three"; | ||
constructor(layer1Material: THREE.MeshBasicMaterial, layer2Material: THREE.MeshBasicMaterial); | ||
slim: boolean; | ||
get slim(): boolean; | ||
set slim(value: boolean); | ||
private getBodyParts; | ||
@@ -23,0 +24,0 @@ setInnerLayerVisible(value: boolean): void; |
@@ -10,4 +10,4 @@ /** | ||
typeof define === 'function' && define.amd ? define(['exports', 'three'], factory) : | ||
(factory((global.skinview3d = {}),global.THREE)); | ||
}(this, (function (exports,THREE) { 'use strict'; | ||
(global = global || self, factory(global.skinview3d = {}, global.THREE)); | ||
}(this, (function (exports, THREE) { 'use strict'; | ||
@@ -82,2 +82,4 @@ /*! ***************************************************************************** | ||
_this.outerLayer = outerLayer; | ||
innerLayer.name = "inner"; | ||
outerLayer.name = "outer"; | ||
return _this; | ||
@@ -102,2 +104,3 @@ } | ||
_this.head = new BodyPart(headMesh, head2Mesh); | ||
_this.head.name = "head"; | ||
_this.head.add(headMesh, head2Mesh); | ||
@@ -113,2 +116,3 @@ _this.add(_this.head); | ||
_this.body = new BodyPart(bodyMesh, body2Mesh); | ||
_this.body.name = "body"; | ||
_this.body.add(bodyMesh, body2Mesh); | ||
@@ -153,2 +157,3 @@ _this.body.position.y = -10; | ||
_this.rightArm = new BodyPart(rightArmMesh, rightArm2Mesh); | ||
_this.rightArm.name = "rightArm"; | ||
_this.rightArm.add(rightArmPivot); | ||
@@ -196,2 +201,3 @@ _this.rightArm.position.y = -4; | ||
_this.leftArm = new BodyPart(leftArmMesh, leftArm2Mesh); | ||
_this.leftArm.name = "leftArm"; | ||
_this.leftArm.add(leftArmPivot); | ||
@@ -215,2 +221,3 @@ _this.leftArm.position.y = -4; | ||
_this.rightLeg = new BodyPart(rightLegMesh, rightLeg2Mesh); | ||
_this.rightLeg.name = "rightLeg"; | ||
_this.rightLeg.add(rightLegPivot); | ||
@@ -232,2 +239,3 @@ _this.rightLeg.position.y = -16; | ||
_this.leftLeg = new BodyPart(leftLegMesh, leftLeg2Mesh); | ||
_this.leftLeg.name = "leftLeg"; | ||
_this.leftLeg.add(leftLegPivot); | ||
@@ -283,5 +291,7 @@ _this.leftLeg.position.y = -16; | ||
_this.skin = new SkinObject(layer1Material, layer2Material); | ||
_this.skin.name = "skin"; | ||
_this.skin.visible = false; | ||
_this.add(_this.skin); | ||
_this.cape = new CapeObject(capeMaterial); | ||
_this.cape.name = "cape"; | ||
_this.cape.position.z = -2; | ||
@@ -600,2 +610,3 @@ _this.cape.position.y = -4; | ||
this.disposed = false; | ||
this._renderPaused = false; | ||
this.domElement = options.domElement; | ||
@@ -631,2 +642,3 @@ this.animation = options.animation || null; | ||
this.playerObject = new PlayerObject(this.layer1Material, this.layer2Material, this.capeMaterial); | ||
this.playerObject.name = "player"; | ||
this.scene.add(this.playerObject); | ||
@@ -662,16 +674,18 @@ // texture loading | ||
this.height = options.height; | ||
var draw = function () { | ||
if (_this.disposed) | ||
return; | ||
window.requestAnimationFrame(draw); | ||
if (!_this.animationPaused) { | ||
_this.animationTime++; | ||
if (_this.animation) { | ||
invokeAnimation(_this.animation, _this.playerObject, _this.animationTime / 100.0); | ||
} | ||
window.requestAnimationFrame(function () { return _this.draw(); }); | ||
} | ||
SkinViewer.prototype.draw = function () { | ||
var _this = this; | ||
if (this.disposed || this._renderPaused) { | ||
return; | ||
} | ||
if (!this.animationPaused) { | ||
this.animationTime++; | ||
if (this.animation) { | ||
invokeAnimation(this.animation, this.playerObject, this.animationTime / 100.0); | ||
} | ||
_this.renderer.render(_this.scene, _this.camera); | ||
}; | ||
draw(); | ||
} | ||
} | ||
this.renderer.render(this.scene, this.camera); | ||
window.requestAnimationFrame(function () { return _this.draw(); }); | ||
}; | ||
SkinViewer.prototype.setSize = function (width, height) { | ||
@@ -689,2 +703,17 @@ this.camera.aspect = width / height; | ||
}; | ||
Object.defineProperty(SkinViewer.prototype, "renderPaused", { | ||
get: function () { | ||
return this._renderPaused; | ||
}, | ||
set: function (value) { | ||
var _this = this; | ||
var toResume = !this.disposed && !value && this._renderPaused; | ||
this._renderPaused = value; | ||
if (toResume) { | ||
window.requestAnimationFrame(function () { return _this.draw(); }); | ||
} | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SkinViewer.prototype, "skinUrl", { | ||
@@ -712,3 +741,4 @@ get: function () { | ||
get: function () { | ||
return this.renderer.getSize().width; | ||
var target = new THREE.Vector2(); | ||
return this.renderer.getSize(target).width; | ||
}, | ||
@@ -723,3 +753,4 @@ set: function (newWidth) { | ||
get: function () { | ||
return this.renderer.getSize().height; | ||
var target = new THREE.Vector2(); | ||
return this.renderer.getSize(target).height; | ||
}, | ||
@@ -1233,14 +1264,14 @@ set: function (newHeight) { | ||
exports.SkinObject = SkinObject; | ||
exports.BodyPart = BodyPart; | ||
exports.CapeObject = CapeObject; | ||
exports.CompositeAnimation = CompositeAnimation; | ||
exports.OrbitControls = OrbitControls; | ||
exports.PlayerObject = PlayerObject; | ||
exports.RotatingAnimation = RotatingAnimation; | ||
exports.RunningAnimation = RunningAnimation; | ||
exports.SkinObject = SkinObject; | ||
exports.SkinViewer = SkinViewer; | ||
exports.OrbitControls = OrbitControls; | ||
exports.WalkingAnimation = WalkingAnimation; | ||
exports.createOrbitControls = createOrbitControls; | ||
exports.invokeAnimation = invokeAnimation; | ||
exports.CompositeAnimation = CompositeAnimation; | ||
exports.WalkingAnimation = WalkingAnimation; | ||
exports.RunningAnimation = RunningAnimation; | ||
exports.RotatingAnimation = RotatingAnimation; | ||
exports.isSlimSkin = isSlimSkin; | ||
@@ -1247,0 +1278,0 @@ |
@@ -7,2 +7,16 @@ /** | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("three")):"function"==typeof define&&define.amd?define(["exports","three"],t):t(e.skinview3d={},e.THREE)}(this,function(e,U){"use strict";var a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function t(e,t){function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function i(e,t,n,a,i,o){return[new U.Vector2(e/i,1-a/o),new U.Vector2(n/i,1-a/o),new U.Vector2(n/i,1-t/o),new U.Vector2(e/i,1-t/o)]}function V(e,t,n,a){return i(e,t,n,a,64,64)}function o(e,t,n,a){return i(e,t,n,a,64,32)}function A(e,t,n,a,i,o,s){e.faceVertexUvs[0]=[],e.faceVertexUvs[0][0]=[o[3],o[0],o[2]],e.faceVertexUvs[0][1]=[o[0],o[1],o[2]],e.faceVertexUvs[0][2]=[a[3],a[0],a[2]],e.faceVertexUvs[0][3]=[a[0],a[1],a[2]],e.faceVertexUvs[0][4]=[t[3],t[0],t[2]],e.faceVertexUvs[0][5]=[t[0],t[1],t[2]],e.faceVertexUvs[0][6]=[n[0],n[3],n[1]],e.faceVertexUvs[0][7]=[n[3],n[2],n[1]],e.faceVertexUvs[0][8]=[i[3],i[0],i[2]],e.faceVertexUvs[0][9]=[i[0],i[1],i[2]],e.faceVertexUvs[0][10]=[s[3],s[0],s[2]],e.faceVertexUvs[0][11]=[s[0],s[1],s[2]]}var C=.002,z=function(a){function e(e,t){var n=a.call(this)||this;return n.innerLayer=e,n.outerLayer=t,n}return t(e,a),e}(U.Group),s=function(D){function e(e,t){var n=D.call(this)||this;n.modelListeners=[],n._slim=!1;var a=new U.BoxGeometry(8,8,8,0,0,0);A(a,V(8,0,16,8),V(16,0,24,8),V(0,8,8,16),V(8,8,16,16),V(16,8,24,16),V(24,8,32,16));var i=new U.Mesh(a,e),o=new U.BoxGeometry(9,9,9,0,0,0);A(o,V(40,0,48,8),V(48,0,56,8),V(32,8,40,16),V(40,8,48,16),V(48,8,56,16),V(56,8,64,16));var s=new U.Mesh(o,t);s.renderOrder=-1,n.head=new z(i,s),n.head.add(i,s),n.add(n.head);var r=new U.BoxGeometry(8,12,4,0,0,0);A(r,V(20,16,28,20),V(28,16,36,20),V(16,20,20,32),V(20,20,28,32),V(28,20,32,32),V(32,20,40,32));var h=new U.Mesh(r,e),c=new U.BoxGeometry(9,13.5,4.5,0,0,0);A(c,V(20,32,28,36),V(28,32,36,36),V(16,36,20,48),V(20,36,28,48),V(28,36,32,48),V(32,36,40,48));var d=new U.Mesh(c,t);n.body=new z(h,d),n.body.add(h,d),n.body.position.y=-10,n.add(n.body);var l=new U.BoxGeometry(1,1,1,0,0,0),p=new U.Mesh(l,e);n.modelListeners.push(function(){p.scale.x=(n.slim?3:4)-C,p.scale.y=12-C,p.scale.z=4-C,n.slim?A(l,V(44,16,47,20),V(47,16,50,20),V(40,20,44,32),V(44,20,47,32),V(47,20,51,32),V(51,20,54,32)):A(l,V(44,16,48,20),V(48,16,52,20),V(40,20,44,32),V(44,20,48,32),V(48,20,52,32),V(52,20,56,32)),l.uvsNeedUpdate=!0,l.elementsNeedUpdate=!0});var u=new U.BoxGeometry(1,1,1,0,0,0),m=new U.Mesh(u,t);m.renderOrder=1,n.modelListeners.push(function(){m.scale.x=(n.slim?3.375:4.5)-C,m.scale.y=13.498,m.scale.z=4.498,n.slim?A(u,V(44,32,47,36),V(47,32,50,36),V(40,36,44,48),V(44,36,47,48),V(47,36,51,48),V(51,36,54,48)):A(u,V(44,32,48,36),V(48,32,52,36),V(40,36,44,48),V(44,36,48,48),V(48,36,52,48),V(52,36,56,48)),u.uvsNeedUpdate=!0,u.elementsNeedUpdate=!0});var f=new U.Group;f.add(p,m),f.position.y=-6,n.rightArm=new z(p,m),n.rightArm.add(f),n.rightArm.position.y=-4,n.modelListeners.push(function(){n.rightArm.position.x=n.slim?-5.5:-6}),n.add(n.rightArm);var y=new U.BoxGeometry(1,1,1,0,0,0),g=new U.Mesh(y,e);n.modelListeners.push(function(){g.scale.x=(n.slim?3:4)-C,g.scale.y=12-C,g.scale.z=4-C,n.slim?A(y,V(36,48,39,52),V(39,48,42,52),V(32,52,36,64),V(36,52,39,64),V(39,52,43,64),V(43,52,46,64)):A(y,V(36,48,40,52),V(40,48,44,52),V(32,52,36,64),V(36,52,40,64),V(40,52,44,64),V(44,52,48,64)),y.uvsNeedUpdate=!0,y.elementsNeedUpdate=!0});var v=new U.BoxGeometry(1,1,1,0,0,0),w=new U.Mesh(v,t);w.renderOrder=1,n.modelListeners.push(function(){w.scale.x=(n.slim?3.375:4.5)-C,w.scale.y=13.498,w.scale.z=4.498,n.slim?A(v,V(52,48,55,52),V(55,48,58,52),V(48,52,52,64),V(52,52,55,64),V(55,52,59,64),V(59,52,62,64)):A(v,V(52,48,56,52),V(56,48,60,52),V(48,52,52,64),V(52,52,56,64),V(56,52,60,64),V(60,52,64,64)),v.uvsNeedUpdate=!0,v.elementsNeedUpdate=!0});var b=new U.Group;b.add(g,w),b.position.y=-6,n.leftArm=new z(g,w),n.leftArm.add(b),n.leftArm.position.y=-4,n.modelListeners.push(function(){n.leftArm.position.x=n.slim?5.5:6}),n.add(n.leftArm);var M=new U.BoxGeometry(4-C,12-C,4-C,0,0,0);A(M,V(4,16,8,20),V(8,16,12,20),V(0,20,4,32),V(4,20,8,32),V(8,20,12,32),V(12,20,16,32));var x=new U.Mesh(M,e),E=new U.BoxGeometry(4.498,13.498,4.498,0,0,0);A(E,V(4,32,8,36),V(8,32,12,36),V(0,36,4,48),V(4,36,8,48),V(8,36,12,48),V(12,36,16,48));var L=new U.Mesh(E,t);L.renderOrder=1;var S=new U.Group;S.add(x,L),S.position.y=-6,n.rightLeg=new z(x,L),n.rightLeg.add(S),n.rightLeg.position.y=-16,n.rightLeg.position.x=-2,n.add(n.rightLeg);var P=new U.BoxGeometry(4-C,12-C,4-C,0,0,0);A(P,V(20,48,24,52),V(24,48,28,52),V(16,52,20,64),V(20,52,24,64),V(24,52,28,64),V(28,52,32,64));var O=new U.Mesh(P,e),k=new U.BoxGeometry(4.498,13.498,4.498,0,0,0);A(k,V(4,48,8,52),V(8,48,12,52),V(0,52,4,64),V(4,52,8,64),V(8,52,12,64),V(12,52,16,64));var I=new U.Mesh(k,t);I.renderOrder=1;var j=new U.Group;return j.add(O,I),j.position.y=-6,n.leftLeg=new z(O,I),n.leftLeg.add(j),n.leftLeg.position.y=-16,n.leftLeg.position.x=2,n.add(n.leftLeg),n.slim=!1,n}return t(e,D),Object.defineProperty(e.prototype,"slim",{get:function(){return this._slim},set:function(e){this._slim=e,this.modelListeners.forEach(function(e){return e()})},enumerable:!0,configurable:!0}),e.prototype.getBodyParts=function(){return this.children.filter(function(e){return e instanceof z})},e.prototype.setInnerLayerVisible=function(t){this.getBodyParts().forEach(function(e){return e.innerLayer.visible=t})},e.prototype.setOuterLayerVisible=function(t){this.getBodyParts().forEach(function(e){return e.outerLayer.visible=t})},e}(U.Group),r=function(a){function e(e){var t=a.call(this)||this,n=new U.BoxGeometry(10,16,1,0,0,0);return A(n,o(1,0,11,1),o(11,0,21,1),o(11,1,12,17),o(12,1,22,17),o(0,1,1,17),o(1,1,11,17)),t.cape=new U.Mesh(n,e),t.cape.position.y=-8,t.cape.position.z=-.5,t.add(t.cape),t}return t(e,a),e}(U.Group),h=function(i){function e(e,t,n){var a=i.call(this)||this;return a.skin=new s(e,t),a.skin.visible=!1,a.add(a.skin),a.cape=new r(n),a.cape.position.z=-2,a.cape.position.y=-4,a.cape.rotation.x=25*Math.PI/180,a.cape.visible=!1,a.add(a.cape),a}return t(e,i),e}(U.Group);function c(e,t,n){e instanceof Function?e(t,n):e.play(t,n)}var d=function(){function e(e){this.paused=!1,this.speed=1,this._paused=!1,this._lastChange=null,this._speed=1,this._lastChangeX=null,this.animation=e}return e.prototype.play=function(e,t){if(null===this._lastChange)this._lastChange=t,this._lastChangeX=0;else if(this.paused!==this._paused||this.speed!==this._speed){var n=t-this._lastChange;!1===this._paused&&(this._lastChangeX+=n*this._speed),this._paused=this.paused,this._speed=this.speed,this._lastChange=t}if(!1===this.paused){n=t-this._lastChange;var a=this._lastChangeX+this.speed*n;c(this.animation,e,a)}},e.prototype.reset=function(){this._lastChange=null},e.prototype.remove=function(){},e}(),n=function(){function e(){this.handles=new Set}return e.prototype.add=function(e){var t=this,n=new d(e);return n.remove=function(){return t.handles.delete(n)},this.handles.add(n),n},e.prototype.play=function(t,n){this.handles.forEach(function(e){return e.play(t,n)})},e}();function l(e,t,n,a,i){for(var o=e.getImageData(t,n,a,i),s=0;s<a;s++)for(var r=0;r<i;r++){var h=4*(s+r*a);if(255!==o.data[h+3])return!0}return!1}function p(e){return e/64}function u(r,e){var h=p(e),t=function(e,t,n,a,i,o,s){return function(e,t,n,a,i,o,s,r){var h=e.getImageData(t,n,a,i);if(r)for(var c=0;c<i;c++)for(var d=0;d<a/2;d++){var l=4*(d+c*a),p=4*(a-d-1+c*a),u=h.data[l],m=h.data[l+1],f=h.data[l+2],y=h.data[l+3],g=h.data[p],v=h.data[p+1],w=h.data[p+2],b=h.data[p+3];h.data[l]=g,h.data[l+1]=v,h.data[l+2]=w,h.data[l+3]=b,h.data[p]=u,h.data[p+1]=m,h.data[p+2]=f,h.data[p+3]=y}e.putImageData(h,o,s)}(r,e*h,t*h,n*h,a*h,i*h,o*h,s)};!function(i,e){if(!l(i,0,0,e,e/2)){var o=p(e),t=function(e,t,n,a){return i.clearRect(e*o,t*o,n*o,a*o)};t(40,0,8,8),t(48,0,8,8),t(32,8,8,8),t(40,8,8,8),t(48,8,8,8),t(56,8,8,8)}}(r,e),t(4,16,4,4,20,48,!0),t(8,16,4,4,24,48,!0),t(0,20,4,12,24,52,!0),t(4,20,4,12,20,52,!0),t(8,20,4,12,16,52,!0),t(12,20,4,12,28,52,!0),t(44,16,4,4,36,48,!0),t(48,16,4,4,40,48,!0),t(40,20,4,12,40,52,!0),t(44,20,4,12,36,52,!0),t(48,20,4,12,32,52,!0),t(52,20,4,12,44,52,!0)}function m(e,t){var n=!1;if(t.width!==t.height){if(t.width!==2*t.height)throw new Error("Bad skin size: "+t.width+"x"+t.height);n=!0}var a=e.getContext("2d");if(n){var i=t.width;e.width=i,e.height=i,a.clearRect(0,0,i,i),a.drawImage(t,0,0,i,i/2),u(a,i)}else e.width=t.width,e.height=t.height,a.clearRect(0,0,t.width,t.height),a.drawImage(t,0,0,e.width,e.height)}function f(e){if(e instanceof HTMLCanvasElement){var i=p((n=e).width),o=n.getContext("2d"),t=function(e,t,n,a){return l(o,e*i,t*i,n*i,a*i)};return t(50,16,2,4)||t(54,20,2,12)||t(42,48,2,4)||t(46,52,2,12)}var n,a=e;return m(n=document.createElement("canvas"),a),f(n)}var y=function(){function e(e){var t=this;this.detectModel=!0,this.animationPaused=!1,this.animationTime=0,this.disposed=!1,this.domElement=e.domElement,this.animation=e.animation||null,!1===e.detectModel&&(this.detectModel=!1),this.skinImg=new Image,this.skinCanvas=document.createElement("canvas"),this.skinTexture=new U.Texture(this.skinCanvas),this.skinTexture.magFilter=U.NearestFilter,this.skinTexture.minFilter=U.NearestFilter,this.capeImg=new Image,this.capeCanvas=document.createElement("canvas"),this.capeTexture=new U.Texture(this.capeCanvas),this.capeTexture.magFilter=U.NearestFilter,this.capeTexture.minFilter=U.NearestFilter,this.layer1Material=new U.MeshBasicMaterial({map:this.skinTexture,side:U.FrontSide}),this.layer2Material=new U.MeshBasicMaterial({map:this.skinTexture,transparent:!0,opacity:1,side:U.DoubleSide,alphaTest:.5}),this.capeMaterial=new U.MeshBasicMaterial({map:this.capeTexture,transparent:!0,opacity:1,side:U.DoubleSide,alphaTest:.5}),this.scene=new U.Scene,this.camera=new U.PerspectiveCamera(40),this.camera.position.y=-12,this.camera.position.z=60,this.renderer=new U.WebGLRenderer({alpha:!0,antialias:!1}),this.renderer.setSize(300,300),this.renderer.context.getShaderInfoLog=function(){return""},this.domElement.appendChild(this.renderer.domElement),this.playerObject=new h(this.layer1Material,this.layer2Material,this.capeMaterial),this.scene.add(this.playerObject),this.skinImg.crossOrigin="anonymous",this.skinImg.onerror=function(){return console.error("Failed loading "+t.skinImg.src)},this.skinImg.onload=function(){m(t.skinCanvas,t.skinImg),t.detectModel&&(t.playerObject.skin.slim=f(t.skinCanvas)),t.skinTexture.needsUpdate=!0,t.layer1Material.needsUpdate=!0,t.layer2Material.needsUpdate=!0,t.playerObject.skin.visible=!0},this.capeImg.crossOrigin="anonymous",this.capeImg.onerror=function(){return console.error("Failed loading "+t.capeImg.src)},this.capeImg.onload=function(){!function(e,t){var n=!1;if(t.width!==2*t.height){if(17*t.width!=22*t.height)throw new Error("Bad cape size: "+t.width+"x"+t.height);n=!0}var a=e.getContext("2d");if(n){var i=64*t.width/22;e.width=i,e.height=i/2}else e.width=t.width,e.height=t.height;a.clearRect(0,0,e.width,e.height),a.drawImage(t,0,0,t.width,t.height)}(t.capeCanvas,t.capeImg),t.capeTexture.needsUpdate=!0,t.capeMaterial.needsUpdate=!0,t.playerObject.cape.visible=!0},e.skinUrl&&(this.skinUrl=e.skinUrl),e.capeUrl&&(this.capeUrl=e.capeUrl),e.width&&(this.width=e.width),e.height&&(this.height=e.height);var n=function(){t.disposed||(window.requestAnimationFrame(n),t.animationPaused||(t.animationTime++,t.animation&&c(t.animation,t.playerObject,t.animationTime/100)),t.renderer.render(t.scene,t.camera))};n()}return e.prototype.setSize=function(e,t){this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t)},e.prototype.dispose=function(){this.disposed=!0,this.domElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.skinTexture.dispose(),this.capeTexture.dispose()},Object.defineProperty(e.prototype,"skinUrl",{get:function(){return this.skinImg.src},set:function(e){this.skinImg.src=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"capeUrl",{get:function(){return this.capeImg.src},set:function(e){this.capeImg.src=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this.renderer.getSize().width},set:function(e){this.setSize(e,this.height)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this.renderer.getSize().height},set:function(e){this.setSize(this.width,e)},enumerable:!0,configurable:!0}),e}(),g=-1,v=0,w=1,b=2,M=3,x=4,E=5,L={type:"change"},S={type:"start"},P={type:"end"},O=function(a){function e(e,t,n){var o=a.call(this)||this;return o.object=e,o.domElement=void 0!==t?t:document,o.window=void 0!==n?n:window,o.enabled=!0,o.target=new U.Vector3,o.minDistance=0,o.maxDistance=1/0,o.minZoom=0,o.maxZoom=1/0,o.minPolarAngle=0,o.maxPolarAngle=Math.PI,o.minAzimuthAngle=-1/0,o.maxAzimuthAngle=1/0,o.enableDamping=!1,o.dampingFactor=.25,o.enableZoom=!0,o.zoomSpeed=1,o.enableRotate=!0,o.rotateSpeed=1,o.enablePan=!0,o.keyPanSpeed=7,o.autoRotate=!1,o.autoRotateSpeed=2,o.enableKeys=!0,o.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},o.mouseButtons={ORBIT:U.MOUSE.LEFT,ZOOM:U.MOUSE.MIDDLE,PAN:U.MOUSE.RIGHT},o.target0=o.target.clone(),o.position0=o.object.position.clone(),o.zoom0=o.object.zoom,o.updateOffset=new U.Vector3,o.updateQuat=(new U.Quaternion).setFromUnitVectors(e.up,new U.Vector3(0,1,0)),o.updateQuatInverse=o.updateQuat.clone().inverse(),o.updateLastPosition=new U.Vector3,o.updateLastQuaternion=new U.Quaternion,o.state=g,o.scale=1,o.spherical=new U.Spherical,o.sphericalDelta=new U.Spherical,o.panOffset=new U.Vector3,o.zoomChanged=!1,o.rotateStart=new U.Vector2,o.rotateEnd=new U.Vector2,o.rotateDelta=new U.Vector2,o.panStart=new U.Vector2,o.panEnd=new U.Vector2,o.panDelta=new U.Vector2,o.dollyStart=new U.Vector2,o.dollyEnd=new U.Vector2,o.dollyDelta=new U.Vector2,o.panLeftV=new U.Vector3,o.panUpV=new U.Vector3,o.panInternalOffset=new U.Vector3,o.onMouseDown=function(e){if(!1!==o.enabled){if(e.preventDefault(),e.button===o.mouseButtons.ORBIT){if(!1===o.enableRotate)return;o.rotateStart.set(e.clientX,e.clientY),o.state=v}else if(e.button===o.mouseButtons.ZOOM){if(!1===o.enableZoom)return;o.dollyStart.set(e.clientX,e.clientY),o.state=w}else if(e.button===o.mouseButtons.PAN){if(!1===o.enablePan)return;o.panStart.set(e.clientX,e.clientY),o.state=b}o.state!==g&&(document.addEventListener("mousemove",o.onMouseMove,!1),document.addEventListener("mouseup",o.onMouseUp,!1),o.dispatchEvent(S))}},o.onMouseMove=function(e){if(!1!==o.enabled)if(e.preventDefault(),o.state===v){if(!1===o.enableRotate)return;o.rotateEnd.set(e.clientX,e.clientY),o.rotateDelta.subVectors(o.rotateEnd,o.rotateStart);var t=o.domElement===document?o.domElement.body:o.domElement;o.rotateLeft(2*Math.PI*o.rotateDelta.x/t.clientWidth*o.rotateSpeed),o.rotateUp(2*Math.PI*o.rotateDelta.y/t.clientHeight*o.rotateSpeed),o.rotateStart.copy(o.rotateEnd),o.update()}else if(o.state===w){if(!1===o.enableZoom)return;o.dollyEnd.set(e.clientX,e.clientY),o.dollyDelta.subVectors(o.dollyEnd,o.dollyStart),0<o.dollyDelta.y?o.dollyIn(o.getZoomScale()):o.dollyDelta.y<0&&o.dollyOut(o.getZoomScale()),o.dollyStart.copy(o.dollyEnd),o.update()}else if(o.state===b){if(!1===o.enablePan)return;o.panEnd.set(e.clientX,e.clientY),o.panDelta.subVectors(o.panEnd,o.panStart),o.pan(o.panDelta.x,o.panDelta.y),o.panStart.copy(o.panEnd),o.update()}},o.onMouseUp=function(e){!1!==o.enabled&&(document.removeEventListener("mousemove",o.onMouseMove,!1),document.removeEventListener("mouseup",o.onMouseUp,!1),o.dispatchEvent(P),o.state=g)},o.onMouseWheel=function(e){!1===o.enabled||!1===o.enableZoom||o.state!==g&&o.state!==v||(e.preventDefault(),e.stopPropagation(),e.deltaY<0?o.dollyOut(o.getZoomScale()):0<e.deltaY&&o.dollyIn(o.getZoomScale()),o.update(),o.dispatchEvent(S),o.dispatchEvent(P))},o.onKeyDown=function(e){if(!1!==o.enabled&&!1!==o.enableKeys&&!1!==o.enablePan)switch(e.keyCode){case o.keys.UP:o.pan(0,o.keyPanSpeed),o.update();break;case o.keys.BOTTOM:o.pan(0,-o.keyPanSpeed),o.update();break;case o.keys.LEFT:o.pan(o.keyPanSpeed,0),o.update();break;case o.keys.RIGHT:o.pan(-o.keyPanSpeed,0),o.update()}},o.onTouchStart=function(e){if(!1!==o.enabled){switch(e.touches.length){case 1:if(!1===o.enableRotate)return;o.rotateStart.set(e.touches[0].pageX,e.touches[0].pageY),o.state=M;break;case 2:if(!1===o.enableZoom)return;var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,a=Math.sqrt(t*t+n*n);o.dollyStart.set(0,a),o.state=x;break;case 3:if(!1===o.enablePan)return;o.panStart.set(e.touches[0].pageX,e.touches[0].pageY),o.state=E;break;default:o.state=g}o.state!==g&&o.dispatchEvent(S)}},o.onTouchMove=function(e){if(!1!==o.enabled)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:if(!1===o.enableRotate)return;if(o.state!==M)return;o.rotateEnd.set(e.touches[0].pageX,e.touches[0].pageY),o.rotateDelta.subVectors(o.rotateEnd,o.rotateStart);var t=o.domElement===document?o.domElement.body:o.domElement;o.rotateLeft(2*Math.PI*o.rotateDelta.x/t.clientWidth*o.rotateSpeed),o.rotateUp(2*Math.PI*o.rotateDelta.y/t.clientHeight*o.rotateSpeed),o.rotateStart.copy(o.rotateEnd),o.update();break;case 2:if(!1===o.enableZoom)return;if(o.state!==x)return;var n=e.touches[0].pageX-e.touches[1].pageX,a=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(n*n+a*a);o.dollyEnd.set(0,i),o.dollyDelta.subVectors(o.dollyEnd,o.dollyStart),0<o.dollyDelta.y?o.dollyOut(o.getZoomScale()):o.dollyDelta.y<0&&o.dollyIn(o.getZoomScale()),o.dollyStart.copy(o.dollyEnd),o.update();break;case 3:if(!1===o.enablePan)return;if(o.state!==E)return;o.panEnd.set(e.touches[0].pageX,e.touches[0].pageY),o.panDelta.subVectors(o.panEnd,o.panStart),o.pan(o.panDelta.x,o.panDelta.y),o.panStart.copy(o.panEnd),o.update();break;default:o.state=g}},o.onTouchEnd=function(e){!1!==o.enabled&&(o.dispatchEvent(P),o.state=g)},o.onContextMenu=function(e){e.preventDefault()},o.domElement.addEventListener("contextmenu",o.onContextMenu,!1),o.domElement.addEventListener("mousedown",o.onMouseDown,!1),o.domElement.addEventListener("wheel",o.onMouseWheel,!1),o.domElement.addEventListener("touchstart",o.onTouchStart,!1),o.domElement.addEventListener("touchend",o.onTouchEnd,!1),o.domElement.addEventListener("touchmove",o.onTouchMove,!1),o.window.addEventListener("keydown",o.onKeyDown,!1),o.update(),o}return t(e,a),e.prototype.update=function(){var e=this.object.position;return this.updateOffset.copy(e).sub(this.target),this.updateOffset.applyQuaternion(this.updateQuat),this.spherical.setFromVector3(this.updateOffset),this.autoRotate&&this.state===g&&this.rotateLeft(this.getAutoRotationAngle()),this.spherical.theta+=this.sphericalDelta.theta,this.spherical.phi+=this.sphericalDelta.phi,this.spherical.theta=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,this.spherical.theta)),this.spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this.spherical.phi)),this.spherical.makeSafe(),this.spherical.radius*=this.scale,this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius)),this.target.add(this.panOffset),this.updateOffset.setFromSpherical(this.spherical),this.updateOffset.applyQuaternion(this.updateQuatInverse),e.copy(this.target).add(this.updateOffset),this.object.lookAt(this.target),!0===this.enableDamping?(this.sphericalDelta.theta*=1-this.dampingFactor,this.sphericalDelta.phi*=1-this.dampingFactor):this.sphericalDelta.set(0,0,0),this.scale=1,this.panOffset.set(0,0,0),!!(this.zoomChanged||1e-6<this.updateLastPosition.distanceToSquared(this.object.position)||1e-6<8*(1-this.updateLastQuaternion.dot(this.object.quaternion)))&&(this.dispatchEvent(L),this.updateLastPosition.copy(this.object.position),this.updateLastQuaternion.copy(this.object.quaternion),!(this.zoomChanged=!1))},e.prototype.panLeft=function(e,t){this.panLeftV.setFromMatrixColumn(t,0),this.panLeftV.multiplyScalar(-e),this.panOffset.add(this.panLeftV)},e.prototype.panUp=function(e,t){this.panUpV.setFromMatrixColumn(t,1),this.panUpV.multiplyScalar(e),this.panOffset.add(this.panUpV)},e.prototype.pan=function(e,t){var n=this.domElement===document?this.domElement.body:this.domElement;if(this.object instanceof U.PerspectiveCamera){var a=this.object.position;this.panInternalOffset.copy(a).sub(this.target);var i=this.panInternalOffset.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*e*i/n.clientHeight,this.object.matrix),this.panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object instanceof U.OrthographicCamera?(this.panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this.panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)},e.prototype.dollyIn=function(e){this.object instanceof U.PerspectiveCamera?this.scale/=e:this.object instanceof U.OrthographicCamera?(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom*e)),this.object.updateProjectionMatrix(),this.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)},e.prototype.dollyOut=function(e){this.object instanceof U.PerspectiveCamera?this.scale*=e:this.object instanceof U.OrthographicCamera?(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/e)),this.object.updateProjectionMatrix(),this.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)},e.prototype.getAutoRotationAngle=function(){return 2*Math.PI/60/60*this.autoRotateSpeed},e.prototype.getZoomScale=function(){return Math.pow(.95,this.zoomSpeed)},e.prototype.rotateLeft=function(e){this.sphericalDelta.theta-=e},e.prototype.rotateUp=function(e){this.sphericalDelta.phi-=e},e.prototype.getPolarAngle=function(){return this.spherical.phi},e.prototype.getAzimuthalAngle=function(){return this.spherical.theta},e.prototype.dispose=function(){this.domElement.removeEventListener("contextmenu",this.onContextMenu,!1),this.domElement.removeEventListener("mousedown",this.onMouseDown,!1),this.domElement.removeEventListener("wheel",this.onMouseWheel,!1),this.domElement.removeEventListener("touchstart",this.onTouchStart,!1),this.domElement.removeEventListener("touchend",this.onTouchEnd,!1),this.domElement.removeEventListener("touchmove",this.onTouchMove,!1),document.removeEventListener("mousemove",this.onMouseMove,!1),document.removeEventListener("mouseup",this.onMouseUp,!1),this.window.removeEventListener("keydown",this.onKeyDown,!1)},e.prototype.reset=function(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(L),this.update(),this.state=g},e}(U.EventDispatcher);e.SkinObject=s,e.BodyPart=z,e.CapeObject=r,e.PlayerObject=h,e.SkinViewer=y,e.OrbitControls=O,e.createOrbitControls=function(e){var t=new O(e.camera,e.renderer.domElement);return t.enablePan=!1,t.target=new U.Vector3(0,-12,0),t.minDistance=10,t.maxDistance=256,t.update(),t},e.invokeAnimation=c,e.CompositeAnimation=n,e.WalkingAnimation=function(e,t){var n=e.skin;t*=8,n.leftLeg.rotation.x=.5*Math.sin(t),n.rightLeg.rotation.x=.5*Math.sin(t+Math.PI),n.leftArm.rotation.x=.5*Math.sin(t+Math.PI),n.rightArm.rotation.x=.5*Math.sin(t);var a=.02*Math.PI;n.leftArm.rotation.z=.03*Math.cos(t)+a,n.rightArm.rotation.z=.03*Math.cos(t+Math.PI)-a,n.head.rotation.y=.2*Math.sin(t/4),n.head.rotation.x=.1*Math.sin(t/5);var i=.06*Math.PI;e.cape.rotation.x=.06*Math.sin(t/1.5)+i},e.RunningAnimation=function(e,t){var n=e.skin;t*=15,n.leftLeg.rotation.x=1.3*Math.cos(t+Math.PI),n.rightLeg.rotation.x=1.3*Math.cos(t),n.leftArm.rotation.x=1.5*Math.cos(t),n.rightArm.rotation.x=1.5*Math.cos(t+Math.PI);var a=.1*Math.PI;n.leftArm.rotation.z=.1*Math.cos(t)+a,n.rightArm.rotation.z=.1*Math.cos(t+Math.PI)-a,e.position.y=Math.cos(2*t),e.position.x=.15*Math.cos(t),e.rotation.z=.01*Math.cos(t+Math.PI);var i=.3*Math.PI;e.cape.rotation.x=.1*Math.sin(2*t)+i},e.RotatingAnimation=function(e,t){e.rotation.y=t},e.isSlimSkin=f,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("three")):"function"==typeof define&&define.amd?define(["exports","three"],t):t((e=e||self).skinview3d={},e.THREE)}(this,(function(e,t){"use strict"; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function a(e,t){function a(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(a.prototype=t.prototype,new a)}function i(e,n,a,i,o,r){return[new t.Vector2(e/o,1-i/r),new t.Vector2(a/o,1-i/r),new t.Vector2(a/o,1-n/r),new t.Vector2(e/o,1-n/r)]}function o(e,t,n,a){return i(e,t,n,a,64,64)}function r(e,t,n,a){return i(e,t,n,a,64,32)}function s(e,t,n,a,i,o,r){e.faceVertexUvs[0]=[],e.faceVertexUvs[0][0]=[o[3],o[0],o[2]],e.faceVertexUvs[0][1]=[o[0],o[1],o[2]],e.faceVertexUvs[0][2]=[a[3],a[0],a[2]],e.faceVertexUvs[0][3]=[a[0],a[1],a[2]],e.faceVertexUvs[0][4]=[t[3],t[0],t[2]],e.faceVertexUvs[0][5]=[t[0],t[1],t[2]],e.faceVertexUvs[0][6]=[n[0],n[3],n[1]],e.faceVertexUvs[0][7]=[n[3],n[2],n[1]],e.faceVertexUvs[0][8]=[i[3],i[0],i[2]],e.faceVertexUvs[0][9]=[i[0],i[1],i[2]],e.faceVertexUvs[0][10]=[r[3],r[0],r[2]],e.faceVertexUvs[0][11]=[r[0],r[1],r[2]]}var h=.002,c=function(e){function t(t,n){var a=e.call(this)||this;return a.innerLayer=t,a.outerLayer=n,t.name="inner",n.name="outer",a}return a(t,e),t}(t.Group),d=function(e){function n(n,a){var i=e.call(this)||this;i.modelListeners=[],i._slim=!1;var r=new t.BoxGeometry(8,8,8,0,0,0);s(r,o(8,0,16,8),o(16,0,24,8),o(0,8,8,16),o(8,8,16,16),o(16,8,24,16),o(24,8,32,16));var d=new t.Mesh(r,n),l=new t.BoxGeometry(9,9,9,0,0,0);s(l,o(40,0,48,8),o(48,0,56,8),o(32,8,40,16),o(40,8,48,16),o(48,8,56,16),o(56,8,64,16));var p=new t.Mesh(l,a);p.renderOrder=-1,i.head=new c(d,p),i.head.name="head",i.head.add(d,p),i.add(i.head);var u=new t.BoxGeometry(8,12,4,0,0,0);s(u,o(20,16,28,20),o(28,16,36,20),o(16,20,20,32),o(20,20,28,32),o(28,20,32,32),o(32,20,40,32));var m=new t.Mesh(u,n),f=new t.BoxGeometry(9,13.5,4.5,0,0,0);s(f,o(20,32,28,36),o(28,32,36,36),o(16,36,20,48),o(20,36,28,48),o(28,36,32,48),o(32,36,40,48));var g=new t.Mesh(f,a);i.body=new c(m,g),i.body.name="body",i.body.add(m,g),i.body.position.y=-10,i.add(i.body);var y=new t.BoxGeometry(1,1,1,0,0,0),v=new t.Mesh(y,n);i.modelListeners.push((function(){v.scale.x=(i.slim?3:4)-h,v.scale.y=12-h,v.scale.z=4-h,i.slim?s(y,o(44,16,47,20),o(47,16,50,20),o(40,20,44,32),o(44,20,47,32),o(47,20,51,32),o(51,20,54,32)):s(y,o(44,16,48,20),o(48,16,52,20),o(40,20,44,32),o(44,20,48,32),o(48,20,52,32),o(52,20,56,32)),y.uvsNeedUpdate=!0,y.elementsNeedUpdate=!0}));var w=new t.BoxGeometry(1,1,1,0,0,0),b=new t.Mesh(w,a);b.renderOrder=1,i.modelListeners.push((function(){b.scale.x=(i.slim?3.375:4.5)-h,b.scale.y=13.5-h,b.scale.z=4.5-h,i.slim?s(w,o(44,32,47,36),o(47,32,50,36),o(40,36,44,48),o(44,36,47,48),o(47,36,51,48),o(51,36,54,48)):s(w,o(44,32,48,36),o(48,32,52,36),o(40,36,44,48),o(44,36,48,48),o(48,36,52,48),o(52,36,56,48)),w.uvsNeedUpdate=!0,w.elementsNeedUpdate=!0}));var M=new t.Group;M.add(v,b),M.position.y=-6,i.rightArm=new c(v,b),i.rightArm.name="rightArm",i.rightArm.add(M),i.rightArm.position.y=-4,i.modelListeners.push((function(){i.rightArm.position.x=i.slim?-5.5:-6})),i.add(i.rightArm);var E=new t.BoxGeometry(1,1,1,0,0,0),x=new t.Mesh(E,n);i.modelListeners.push((function(){x.scale.x=(i.slim?3:4)-h,x.scale.y=12-h,x.scale.z=4-h,i.slim?s(E,o(36,48,39,52),o(39,48,42,52),o(32,52,36,64),o(36,52,39,64),o(39,52,43,64),o(43,52,46,64)):s(E,o(36,48,40,52),o(40,48,44,52),o(32,52,36,64),o(36,52,40,64),o(40,52,44,64),o(44,52,48,64)),E.uvsNeedUpdate=!0,E.elementsNeedUpdate=!0}));var O=new t.BoxGeometry(1,1,1,0,0,0),L=new t.Mesh(O,a);L.renderOrder=1,i.modelListeners.push((function(){L.scale.x=(i.slim?3.375:4.5)-h,L.scale.y=13.5-h,L.scale.z=4.5-h,i.slim?s(O,o(52,48,55,52),o(55,48,58,52),o(48,52,52,64),o(52,52,55,64),o(55,52,59,64),o(59,52,62,64)):s(O,o(52,48,56,52),o(56,48,60,52),o(48,52,52,64),o(52,52,56,64),o(56,52,60,64),o(60,52,64,64)),O.uvsNeedUpdate=!0,O.elementsNeedUpdate=!0}));var P=new t.Group;P.add(x,L),P.position.y=-6,i.leftArm=new c(x,L),i.leftArm.name="leftArm",i.leftArm.add(P),i.leftArm.position.y=-4,i.modelListeners.push((function(){i.leftArm.position.x=i.slim?5.5:6})),i.add(i.leftArm);var S=new t.BoxGeometry(4-h,12-h,4-h,0,0,0);s(S,o(4,16,8,20),o(8,16,12,20),o(0,20,4,32),o(4,20,8,32),o(8,20,12,32),o(12,20,16,32));var A=new t.Mesh(S,n),T=new t.BoxGeometry(4.5-h,13.5-h,4.5-h,0,0,0);s(T,o(4,32,8,36),o(8,32,12,36),o(0,36,4,48),o(4,36,8,48),o(8,36,12,48),o(12,36,16,48));var k=new t.Mesh(T,a);k.renderOrder=1;var j=new t.Group;j.add(A,k),j.position.y=-6,i.rightLeg=new c(A,k),i.rightLeg.name="rightLeg",i.rightLeg.add(j),i.rightLeg.position.y=-16,i.rightLeg.position.x=-2,i.add(i.rightLeg);var I=new t.BoxGeometry(4-h,12-h,4-h,0,0,0);s(I,o(20,48,24,52),o(24,48,28,52),o(16,52,20,64),o(20,52,24,64),o(24,52,28,64),o(28,52,32,64));var U=new t.Mesh(I,n),D=new t.BoxGeometry(4.5-h,13.5-h,4.5-h,0,0,0);s(D,o(4,48,8,52),o(8,48,12,52),o(0,52,4,64),o(4,52,8,64),o(8,52,12,64),o(12,52,16,64));var C=new t.Mesh(D,a);C.renderOrder=1;var V=new t.Group;return V.add(U,C),V.position.y=-6,i.leftLeg=new c(U,C),i.leftLeg.name="leftLeg",i.leftLeg.add(V),i.leftLeg.position.y=-16,i.leftLeg.position.x=2,i.add(i.leftLeg),i.slim=!1,i}return a(n,e),Object.defineProperty(n.prototype,"slim",{get:function(){return this._slim},set:function(e){this._slim=e,this.modelListeners.forEach((function(e){return e()}))},enumerable:!0,configurable:!0}),n.prototype.getBodyParts=function(){return this.children.filter((function(e){return e instanceof c}))},n.prototype.setInnerLayerVisible=function(e){this.getBodyParts().forEach((function(t){return t.innerLayer.visible=e}))},n.prototype.setOuterLayerVisible=function(e){this.getBodyParts().forEach((function(t){return t.outerLayer.visible=e}))},n}(t.Group),l=function(e){function n(n){var a=e.call(this)||this,i=new t.BoxGeometry(10,16,1,0,0,0);return s(i,r(1,0,11,1),r(11,0,21,1),r(11,1,12,17),r(12,1,22,17),r(0,1,1,17),r(1,1,11,17)),a.cape=new t.Mesh(i,n),a.cape.position.y=-8,a.cape.position.z=-.5,a.add(a.cape),a}return a(n,e),n}(t.Group),p=function(e){function t(t,n,a){var i=e.call(this)||this;return i.skin=new d(t,n),i.skin.name="skin",i.skin.visible=!1,i.add(i.skin),i.cape=new l(a),i.cape.name="cape",i.cape.position.z=-2,i.cape.position.y=-4,i.cape.rotation.x=25*Math.PI/180,i.cape.visible=!1,i.add(i.cape),i}return a(t,e),t}(t.Group);function u(e,t,n){e instanceof Function?e(t,n):e.play(t,n)}var m=function(){function e(e){this.paused=!1,this.speed=1,this._paused=!1,this._lastChange=null,this._speed=1,this._lastChangeX=null,this.animation=e}return e.prototype.play=function(e,t){if(null===this._lastChange)this._lastChange=t,this._lastChangeX=0;else if(this.paused!==this._paused||this.speed!==this._speed){var n=t-this._lastChange;!1===this._paused&&(this._lastChangeX+=n*this._speed),this._paused=this.paused,this._speed=this.speed,this._lastChange=t}if(!1===this.paused){n=t-this._lastChange;var a=this._lastChangeX+this.speed*n;u(this.animation,e,a)}},e.prototype.reset=function(){this._lastChange=null},e.prototype.remove=function(){},e}(),f=function(){function e(){this.handles=new Set}return e.prototype.add=function(e){var t=this,n=new m(e);return n.remove=function(){return t.handles.delete(n)},this.handles.add(n),n},e.prototype.play=function(e,t){this.handles.forEach((function(n){return n.play(e,t)}))},e}();function g(e,t,n,a,i){for(var o=e.getImageData(t,n,a,i),r=0;r<a;r++)for(var s=0;s<i;s++){var h=4*(r+s*a);if(255!==o.data[h+3])return!0}return!1}function y(e){return e/64}function v(e,t){var n=y(t),a=function(t,a,i,o,r,s,h){return function(e,t,n,a,i,o,r,s){var h=e.getImageData(t,n,a,i);if(s)for(var c=0;c<i;c++)for(var d=0;d<a/2;d++){var l=4*(d+c*a),p=4*(a-d-1+c*a),u=h.data[l],m=h.data[l+1],f=h.data[l+2],g=h.data[l+3],y=h.data[p],v=h.data[p+1],w=h.data[p+2],b=h.data[p+3];h.data[l]=y,h.data[l+1]=v,h.data[l+2]=w,h.data[l+3]=b,h.data[p]=u,h.data[p+1]=m,h.data[p+2]=f,h.data[p+3]=g}e.putImageData(h,o,r)}(e,t*n,a*n,i*n,o*n,r*n,s*n,h)};!function(e,t){if(!g(e,0,0,t,t/2)){var n=y(t),a=function(t,a,i,o){return e.clearRect(t*n,a*n,i*n,o*n)};a(40,0,8,8),a(48,0,8,8),a(32,8,8,8),a(40,8,8,8),a(48,8,8,8),a(56,8,8,8)}}(e,t),a(4,16,4,4,20,48,!0),a(8,16,4,4,24,48,!0),a(0,20,4,12,24,52,!0),a(4,20,4,12,20,52,!0),a(8,20,4,12,16,52,!0),a(12,20,4,12,28,52,!0),a(44,16,4,4,36,48,!0),a(48,16,4,4,40,48,!0),a(40,20,4,12,40,52,!0),a(44,20,4,12,36,52,!0),a(48,20,4,12,32,52,!0),a(52,20,4,12,44,52,!0)}function w(e,t){var n=!1;if(t.width!==t.height){if(t.width!==2*t.height)throw new Error("Bad skin size: "+t.width+"x"+t.height);n=!0}var a=e.getContext("2d");if(n){var i=t.width;e.width=i,e.height=i,a.clearRect(0,0,i,i),a.drawImage(t,0,0,i,i/2),v(a,i)}else e.width=t.width,e.height=t.height,a.clearRect(0,0,t.width,t.height),a.drawImage(t,0,0,e.width,e.height)}function b(e){if(e instanceof HTMLCanvasElement){var t=y((i=e).width),n=i.getContext("2d"),a=function(e,a,i,o){return g(n,e*t,a*t,i*t,o*t)};return a(50,16,2,4)||a(54,20,2,12)||a(42,48,2,4)||a(46,52,2,12)}var i,o=e;return w(i=document.createElement("canvas"),o),b(i)}var M=function(){function e(e){var n=this;this.detectModel=!0,this.animationPaused=!1,this.animationTime=0,this.disposed=!1,this._renderPaused=!1,this.domElement=e.domElement,this.animation=e.animation||null,!1===e.detectModel&&(this.detectModel=!1),this.skinImg=new Image,this.skinCanvas=document.createElement("canvas"),this.skinTexture=new t.Texture(this.skinCanvas),this.skinTexture.magFilter=t.NearestFilter,this.skinTexture.minFilter=t.NearestFilter,this.capeImg=new Image,this.capeCanvas=document.createElement("canvas"),this.capeTexture=new t.Texture(this.capeCanvas),this.capeTexture.magFilter=t.NearestFilter,this.capeTexture.minFilter=t.NearestFilter,this.layer1Material=new t.MeshBasicMaterial({map:this.skinTexture,side:t.FrontSide}),this.layer2Material=new t.MeshBasicMaterial({map:this.skinTexture,transparent:!0,opacity:1,side:t.DoubleSide,alphaTest:.5}),this.capeMaterial=new t.MeshBasicMaterial({map:this.capeTexture,transparent:!0,opacity:1,side:t.DoubleSide,alphaTest:.5}),this.scene=new t.Scene,this.camera=new t.PerspectiveCamera(40),this.camera.position.y=-12,this.camera.position.z=60,this.renderer=new t.WebGLRenderer({alpha:!0,antialias:!1}),this.renderer.setSize(300,300),this.renderer.context.getShaderInfoLog=function(){return""},this.domElement.appendChild(this.renderer.domElement),this.playerObject=new p(this.layer1Material,this.layer2Material,this.capeMaterial),this.playerObject.name="player",this.scene.add(this.playerObject),this.skinImg.crossOrigin="anonymous",this.skinImg.onerror=function(){return console.error("Failed loading "+n.skinImg.src)},this.skinImg.onload=function(){w(n.skinCanvas,n.skinImg),n.detectModel&&(n.playerObject.skin.slim=b(n.skinCanvas)),n.skinTexture.needsUpdate=!0,n.layer1Material.needsUpdate=!0,n.layer2Material.needsUpdate=!0,n.playerObject.skin.visible=!0},this.capeImg.crossOrigin="anonymous",this.capeImg.onerror=function(){return console.error("Failed loading "+n.capeImg.src)},this.capeImg.onload=function(){!function(e,t){var n=!1;if(t.width!==2*t.height){if(17*t.width!=22*t.height)throw new Error("Bad cape size: "+t.width+"x"+t.height);n=!0}var a=e.getContext("2d");if(n){var i=64*t.width/22;e.width=i,e.height=i/2}else e.width=t.width,e.height=t.height;a.clearRect(0,0,e.width,e.height),a.drawImage(t,0,0,t.width,t.height)}(n.capeCanvas,n.capeImg),n.capeTexture.needsUpdate=!0,n.capeMaterial.needsUpdate=!0,n.playerObject.cape.visible=!0},e.skinUrl&&(this.skinUrl=e.skinUrl),e.capeUrl&&(this.capeUrl=e.capeUrl),e.width&&(this.width=e.width),e.height&&(this.height=e.height),window.requestAnimationFrame((function(){return n.draw()}))}return e.prototype.draw=function(){var e=this;this.disposed||this._renderPaused||(this.animationPaused||(this.animationTime++,this.animation&&u(this.animation,this.playerObject,this.animationTime/100)),this.renderer.render(this.scene,this.camera),window.requestAnimationFrame((function(){return e.draw()})))},e.prototype.setSize=function(e,t){this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t)},e.prototype.dispose=function(){this.disposed=!0,this.domElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.skinTexture.dispose(),this.capeTexture.dispose()},Object.defineProperty(e.prototype,"renderPaused",{get:function(){return this._renderPaused},set:function(e){var t=this,n=!this.disposed&&!e&&this._renderPaused;this._renderPaused=e,n&&window.requestAnimationFrame((function(){return t.draw()}))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skinUrl",{get:function(){return this.skinImg.src},set:function(e){this.skinImg.src=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"capeUrl",{get:function(){return this.capeImg.src},set:function(e){this.capeImg.src=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){var e=new t.Vector2;return this.renderer.getSize(e).width},set:function(e){this.setSize(e,this.height)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){var e=new t.Vector2;return this.renderer.getSize(e).height},set:function(e){this.setSize(this.width,e)},enumerable:!0,configurable:!0}),e}(),E={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},x={type:"change"},O={type:"start"},L={type:"end"},P=function(e){function n(n,a,i){var o=e.call(this)||this;return o.object=n,o.domElement=void 0!==a?a:document,o.window=void 0!==i?i:window,o.enabled=!0,o.target=new t.Vector3,o.minDistance=0,o.maxDistance=1/0,o.minZoom=0,o.maxZoom=1/0,o.minPolarAngle=0,o.maxPolarAngle=Math.PI,o.minAzimuthAngle=-1/0,o.maxAzimuthAngle=1/0,o.enableDamping=!1,o.dampingFactor=.25,o.enableZoom=!0,o.zoomSpeed=1,o.enableRotate=!0,o.rotateSpeed=1,o.enablePan=!0,o.keyPanSpeed=7,o.autoRotate=!1,o.autoRotateSpeed=2,o.enableKeys=!0,o.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},o.mouseButtons={ORBIT:t.MOUSE.LEFT,ZOOM:t.MOUSE.MIDDLE,PAN:t.MOUSE.RIGHT},o.target0=o.target.clone(),o.position0=o.object.position.clone(),o.zoom0=o.object.zoom,o.updateOffset=new t.Vector3,o.updateQuat=(new t.Quaternion).setFromUnitVectors(n.up,new t.Vector3(0,1,0)),o.updateQuatInverse=o.updateQuat.clone().inverse(),o.updateLastPosition=new t.Vector3,o.updateLastQuaternion=new t.Quaternion,o.state=E.NONE,o.scale=1,o.spherical=new t.Spherical,o.sphericalDelta=new t.Spherical,o.panOffset=new t.Vector3,o.zoomChanged=!1,o.rotateStart=new t.Vector2,o.rotateEnd=new t.Vector2,o.rotateDelta=new t.Vector2,o.panStart=new t.Vector2,o.panEnd=new t.Vector2,o.panDelta=new t.Vector2,o.dollyStart=new t.Vector2,o.dollyEnd=new t.Vector2,o.dollyDelta=new t.Vector2,o.panLeftV=new t.Vector3,o.panUpV=new t.Vector3,o.panInternalOffset=new t.Vector3,o.onMouseDown=function(e){if(!1!==o.enabled){if(e.preventDefault(),e.button===o.mouseButtons.ORBIT){if(!1===o.enableRotate)return;o.rotateStart.set(e.clientX,e.clientY),o.state=E.ROTATE}else if(e.button===o.mouseButtons.ZOOM){if(!1===o.enableZoom)return;o.dollyStart.set(e.clientX,e.clientY),o.state=E.DOLLY}else if(e.button===o.mouseButtons.PAN){if(!1===o.enablePan)return;o.panStart.set(e.clientX,e.clientY),o.state=E.PAN}o.state!==E.NONE&&(document.addEventListener("mousemove",o.onMouseMove,!1),document.addEventListener("mouseup",o.onMouseUp,!1),o.dispatchEvent(O))}},o.onMouseMove=function(e){if(!1!==o.enabled)if(e.preventDefault(),o.state===E.ROTATE){if(!1===o.enableRotate)return;o.rotateEnd.set(e.clientX,e.clientY),o.rotateDelta.subVectors(o.rotateEnd,o.rotateStart);var t=o.domElement===document?o.domElement.body:o.domElement;o.rotateLeft(2*Math.PI*o.rotateDelta.x/t.clientWidth*o.rotateSpeed),o.rotateUp(2*Math.PI*o.rotateDelta.y/t.clientHeight*o.rotateSpeed),o.rotateStart.copy(o.rotateEnd),o.update()}else if(o.state===E.DOLLY){if(!1===o.enableZoom)return;o.dollyEnd.set(e.clientX,e.clientY),o.dollyDelta.subVectors(o.dollyEnd,o.dollyStart),o.dollyDelta.y>0?o.dollyIn(o.getZoomScale()):o.dollyDelta.y<0&&o.dollyOut(o.getZoomScale()),o.dollyStart.copy(o.dollyEnd),o.update()}else if(o.state===E.PAN){if(!1===o.enablePan)return;o.panEnd.set(e.clientX,e.clientY),o.panDelta.subVectors(o.panEnd,o.panStart),o.pan(o.panDelta.x,o.panDelta.y),o.panStart.copy(o.panEnd),o.update()}},o.onMouseUp=function(e){!1!==o.enabled&&(document.removeEventListener("mousemove",o.onMouseMove,!1),document.removeEventListener("mouseup",o.onMouseUp,!1),o.dispatchEvent(L),o.state=E.NONE)},o.onMouseWheel=function(e){!1===o.enabled||!1===o.enableZoom||o.state!==E.NONE&&o.state!==E.ROTATE||(e.preventDefault(),e.stopPropagation(),e.deltaY<0?o.dollyOut(o.getZoomScale()):e.deltaY>0&&o.dollyIn(o.getZoomScale()),o.update(),o.dispatchEvent(O),o.dispatchEvent(L))},o.onKeyDown=function(e){if(!1!==o.enabled&&!1!==o.enableKeys&&!1!==o.enablePan)switch(e.keyCode){case o.keys.UP:o.pan(0,o.keyPanSpeed),o.update();break;case o.keys.BOTTOM:o.pan(0,-o.keyPanSpeed),o.update();break;case o.keys.LEFT:o.pan(o.keyPanSpeed,0),o.update();break;case o.keys.RIGHT:o.pan(-o.keyPanSpeed,0),o.update()}},o.onTouchStart=function(e){if(!1!==o.enabled){switch(e.touches.length){case 1:if(!1===o.enableRotate)return;o.rotateStart.set(e.touches[0].pageX,e.touches[0].pageY),o.state=E.TOUCH_ROTATE;break;case 2:if(!1===o.enableZoom)return;var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,a=Math.sqrt(t*t+n*n);o.dollyStart.set(0,a),o.state=E.TOUCH_DOLLY;break;case 3:if(!1===o.enablePan)return;o.panStart.set(e.touches[0].pageX,e.touches[0].pageY),o.state=E.TOUCH_PAN;break;default:o.state=E.NONE}o.state!==E.NONE&&o.dispatchEvent(O)}},o.onTouchMove=function(e){if(!1!==o.enabled)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:if(!1===o.enableRotate)return;if(o.state!==E.TOUCH_ROTATE)return;o.rotateEnd.set(e.touches[0].pageX,e.touches[0].pageY),o.rotateDelta.subVectors(o.rotateEnd,o.rotateStart);var t=o.domElement===document?o.domElement.body:o.domElement;o.rotateLeft(2*Math.PI*o.rotateDelta.x/t.clientWidth*o.rotateSpeed),o.rotateUp(2*Math.PI*o.rotateDelta.y/t.clientHeight*o.rotateSpeed),o.rotateStart.copy(o.rotateEnd),o.update();break;case 2:if(!1===o.enableZoom)return;if(o.state!==E.TOUCH_DOLLY)return;var n=e.touches[0].pageX-e.touches[1].pageX,a=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(n*n+a*a);o.dollyEnd.set(0,i),o.dollyDelta.subVectors(o.dollyEnd,o.dollyStart),o.dollyDelta.y>0?o.dollyOut(o.getZoomScale()):o.dollyDelta.y<0&&o.dollyIn(o.getZoomScale()),o.dollyStart.copy(o.dollyEnd),o.update();break;case 3:if(!1===o.enablePan)return;if(o.state!==E.TOUCH_PAN)return;o.panEnd.set(e.touches[0].pageX,e.touches[0].pageY),o.panDelta.subVectors(o.panEnd,o.panStart),o.pan(o.panDelta.x,o.panDelta.y),o.panStart.copy(o.panEnd),o.update();break;default:o.state=E.NONE}},o.onTouchEnd=function(e){!1!==o.enabled&&(o.dispatchEvent(L),o.state=E.NONE)},o.onContextMenu=function(e){e.preventDefault()},o.domElement.addEventListener("contextmenu",o.onContextMenu,!1),o.domElement.addEventListener("mousedown",o.onMouseDown,!1),o.domElement.addEventListener("wheel",o.onMouseWheel,!1),o.domElement.addEventListener("touchstart",o.onTouchStart,!1),o.domElement.addEventListener("touchend",o.onTouchEnd,!1),o.domElement.addEventListener("touchmove",o.onTouchMove,!1),o.window.addEventListener("keydown",o.onKeyDown,!1),o.update(),o}return a(n,e),n.prototype.update=function(){var e=this.object.position;return this.updateOffset.copy(e).sub(this.target),this.updateOffset.applyQuaternion(this.updateQuat),this.spherical.setFromVector3(this.updateOffset),this.autoRotate&&this.state===E.NONE&&this.rotateLeft(this.getAutoRotationAngle()),this.spherical.theta+=this.sphericalDelta.theta,this.spherical.phi+=this.sphericalDelta.phi,this.spherical.theta=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,this.spherical.theta)),this.spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this.spherical.phi)),this.spherical.makeSafe(),this.spherical.radius*=this.scale,this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius)),this.target.add(this.panOffset),this.updateOffset.setFromSpherical(this.spherical),this.updateOffset.applyQuaternion(this.updateQuatInverse),e.copy(this.target).add(this.updateOffset),this.object.lookAt(this.target),!0===this.enableDamping?(this.sphericalDelta.theta*=1-this.dampingFactor,this.sphericalDelta.phi*=1-this.dampingFactor):this.sphericalDelta.set(0,0,0),this.scale=1,this.panOffset.set(0,0,0),!!(this.zoomChanged||this.updateLastPosition.distanceToSquared(this.object.position)>1e-6||8*(1-this.updateLastQuaternion.dot(this.object.quaternion))>1e-6)&&(this.dispatchEvent(x),this.updateLastPosition.copy(this.object.position),this.updateLastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,!0)},n.prototype.panLeft=function(e,t){this.panLeftV.setFromMatrixColumn(t,0),this.panLeftV.multiplyScalar(-e),this.panOffset.add(this.panLeftV)},n.prototype.panUp=function(e,t){this.panUpV.setFromMatrixColumn(t,1),this.panUpV.multiplyScalar(e),this.panOffset.add(this.panUpV)},n.prototype.pan=function(e,n){var a=this.domElement===document?this.domElement.body:this.domElement;if(this.object instanceof t.PerspectiveCamera){var i=this.object.position;this.panInternalOffset.copy(i).sub(this.target);var o=this.panInternalOffset.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*e*o/a.clientHeight,this.object.matrix),this.panUp(2*n*o/a.clientHeight,this.object.matrix)}else this.object instanceof t.OrthographicCamera?(this.panLeft(e*(this.object.right-this.object.left)/this.object.zoom/a.clientWidth,this.object.matrix),this.panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/a.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)},n.prototype.dollyIn=function(e){this.object instanceof t.PerspectiveCamera?this.scale/=e:this.object instanceof t.OrthographicCamera?(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom*e)),this.object.updateProjectionMatrix(),this.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)},n.prototype.dollyOut=function(e){this.object instanceof t.PerspectiveCamera?this.scale*=e:this.object instanceof t.OrthographicCamera?(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/e)),this.object.updateProjectionMatrix(),this.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)},n.prototype.getAutoRotationAngle=function(){return 2*Math.PI/60/60*this.autoRotateSpeed},n.prototype.getZoomScale=function(){return Math.pow(.95,this.zoomSpeed)},n.prototype.rotateLeft=function(e){this.sphericalDelta.theta-=e},n.prototype.rotateUp=function(e){this.sphericalDelta.phi-=e},n.prototype.getPolarAngle=function(){return this.spherical.phi},n.prototype.getAzimuthalAngle=function(){return this.spherical.theta},n.prototype.dispose=function(){this.domElement.removeEventListener("contextmenu",this.onContextMenu,!1),this.domElement.removeEventListener("mousedown",this.onMouseDown,!1),this.domElement.removeEventListener("wheel",this.onMouseWheel,!1),this.domElement.removeEventListener("touchstart",this.onTouchStart,!1),this.domElement.removeEventListener("touchend",this.onTouchEnd,!1),this.domElement.removeEventListener("touchmove",this.onTouchMove,!1),document.removeEventListener("mousemove",this.onMouseMove,!1),document.removeEventListener("mouseup",this.onMouseUp,!1),this.window.removeEventListener("keydown",this.onKeyDown,!1)},n.prototype.reset=function(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(x),this.update(),this.state=E.NONE},n}(t.EventDispatcher);e.BodyPart=c,e.CapeObject=l,e.CompositeAnimation=f,e.OrbitControls=P,e.PlayerObject=p,e.RotatingAnimation=function(e,t){e.rotation.y=t},e.RunningAnimation=function(e,t){var n=e.skin;t*=15,n.leftLeg.rotation.x=1.3*Math.cos(t+Math.PI),n.rightLeg.rotation.x=1.3*Math.cos(t),n.leftArm.rotation.x=1.5*Math.cos(t),n.rightArm.rotation.x=1.5*Math.cos(t+Math.PI);var a=.1*Math.PI;n.leftArm.rotation.z=.1*Math.cos(t)+a,n.rightArm.rotation.z=.1*Math.cos(t+Math.PI)-a,e.position.y=Math.cos(2*t),e.position.x=.15*Math.cos(t),e.rotation.z=.01*Math.cos(t+Math.PI);var i=.3*Math.PI;e.cape.rotation.x=.1*Math.sin(2*t)+i},e.SkinObject=d,e.SkinViewer=M,e.WalkingAnimation=function(e,t){var n=e.skin;t*=8,n.leftLeg.rotation.x=.5*Math.sin(t),n.rightLeg.rotation.x=.5*Math.sin(t+Math.PI),n.leftArm.rotation.x=.5*Math.sin(t+Math.PI),n.rightArm.rotation.x=.5*Math.sin(t);var a=.02*Math.PI;n.leftArm.rotation.z=.03*Math.cos(t)+a,n.rightArm.rotation.z=.03*Math.cos(t+Math.PI)-a,n.head.rotation.y=.2*Math.sin(t/4),n.head.rotation.x=.1*Math.sin(t/5);var i=.06*Math.PI;e.cape.rotation.x=.06*Math.sin(t/1.5)+i},e.createOrbitControls=function(e){var n=new P(e.camera,e.renderer.domElement);return n.enablePan=!1,n.target=new t.Vector3(0,-12,0),n.minDistance=10,n.maxDistance=256,n.update(),n},e.invokeAnimation=u,e.isSlimSkin=b,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -7,3 +7,3 @@ /** | ||
import { Vector2, Group, BoxGeometry, Mesh, Texture, NearestFilter, MeshBasicMaterial, FrontSide, DoubleSide, Scene, PerspectiveCamera, WebGLRenderer, Vector3, MOUSE, Quaternion, Spherical, OrthographicCamera, EventDispatcher } from 'three'; | ||
import { Group, BoxGeometry, Vector2, Mesh, Texture, NearestFilter, MeshBasicMaterial, FrontSide, DoubleSide, Scene, PerspectiveCamera, WebGLRenderer, OrthographicCamera, Vector3, MOUSE, Quaternion, Spherical, EventDispatcher } from 'three'; | ||
@@ -78,2 +78,4 @@ /*! ***************************************************************************** | ||
_this.outerLayer = outerLayer; | ||
innerLayer.name = "inner"; | ||
outerLayer.name = "outer"; | ||
return _this; | ||
@@ -98,2 +100,3 @@ } | ||
_this.head = new BodyPart(headMesh, head2Mesh); | ||
_this.head.name = "head"; | ||
_this.head.add(headMesh, head2Mesh); | ||
@@ -109,2 +112,3 @@ _this.add(_this.head); | ||
_this.body = new BodyPart(bodyMesh, body2Mesh); | ||
_this.body.name = "body"; | ||
_this.body.add(bodyMesh, body2Mesh); | ||
@@ -149,2 +153,3 @@ _this.body.position.y = -10; | ||
_this.rightArm = new BodyPart(rightArmMesh, rightArm2Mesh); | ||
_this.rightArm.name = "rightArm"; | ||
_this.rightArm.add(rightArmPivot); | ||
@@ -192,2 +197,3 @@ _this.rightArm.position.y = -4; | ||
_this.leftArm = new BodyPart(leftArmMesh, leftArm2Mesh); | ||
_this.leftArm.name = "leftArm"; | ||
_this.leftArm.add(leftArmPivot); | ||
@@ -211,2 +217,3 @@ _this.leftArm.position.y = -4; | ||
_this.rightLeg = new BodyPart(rightLegMesh, rightLeg2Mesh); | ||
_this.rightLeg.name = "rightLeg"; | ||
_this.rightLeg.add(rightLegPivot); | ||
@@ -228,2 +235,3 @@ _this.rightLeg.position.y = -16; | ||
_this.leftLeg = new BodyPart(leftLegMesh, leftLeg2Mesh); | ||
_this.leftLeg.name = "leftLeg"; | ||
_this.leftLeg.add(leftLegPivot); | ||
@@ -279,5 +287,7 @@ _this.leftLeg.position.y = -16; | ||
_this.skin = new SkinObject(layer1Material, layer2Material); | ||
_this.skin.name = "skin"; | ||
_this.skin.visible = false; | ||
_this.add(_this.skin); | ||
_this.cape = new CapeObject(capeMaterial); | ||
_this.cape.name = "cape"; | ||
_this.cape.position.z = -2; | ||
@@ -596,2 +606,3 @@ _this.cape.position.y = -4; | ||
this.disposed = false; | ||
this._renderPaused = false; | ||
this.domElement = options.domElement; | ||
@@ -627,2 +638,3 @@ this.animation = options.animation || null; | ||
this.playerObject = new PlayerObject(this.layer1Material, this.layer2Material, this.capeMaterial); | ||
this.playerObject.name = "player"; | ||
this.scene.add(this.playerObject); | ||
@@ -658,16 +670,18 @@ // texture loading | ||
this.height = options.height; | ||
var draw = function () { | ||
if (_this.disposed) | ||
return; | ||
window.requestAnimationFrame(draw); | ||
if (!_this.animationPaused) { | ||
_this.animationTime++; | ||
if (_this.animation) { | ||
invokeAnimation(_this.animation, _this.playerObject, _this.animationTime / 100.0); | ||
} | ||
window.requestAnimationFrame(function () { return _this.draw(); }); | ||
} | ||
SkinViewer.prototype.draw = function () { | ||
var _this = this; | ||
if (this.disposed || this._renderPaused) { | ||
return; | ||
} | ||
if (!this.animationPaused) { | ||
this.animationTime++; | ||
if (this.animation) { | ||
invokeAnimation(this.animation, this.playerObject, this.animationTime / 100.0); | ||
} | ||
_this.renderer.render(_this.scene, _this.camera); | ||
}; | ||
draw(); | ||
} | ||
} | ||
this.renderer.render(this.scene, this.camera); | ||
window.requestAnimationFrame(function () { return _this.draw(); }); | ||
}; | ||
SkinViewer.prototype.setSize = function (width, height) { | ||
@@ -685,2 +699,17 @@ this.camera.aspect = width / height; | ||
}; | ||
Object.defineProperty(SkinViewer.prototype, "renderPaused", { | ||
get: function () { | ||
return this._renderPaused; | ||
}, | ||
set: function (value) { | ||
var _this = this; | ||
var toResume = !this.disposed && !value && this._renderPaused; | ||
this._renderPaused = value; | ||
if (toResume) { | ||
window.requestAnimationFrame(function () { return _this.draw(); }); | ||
} | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SkinViewer.prototype, "skinUrl", { | ||
@@ -708,3 +737,4 @@ get: function () { | ||
get: function () { | ||
return this.renderer.getSize().width; | ||
var target = new Vector2(); | ||
return this.renderer.getSize(target).width; | ||
}, | ||
@@ -719,3 +749,4 @@ set: function (newWidth) { | ||
get: function () { | ||
return this.renderer.getSize().height; | ||
var target = new Vector2(); | ||
return this.renderer.getSize(target).height; | ||
}, | ||
@@ -1229,2 +1260,2 @@ set: function (newHeight) { | ||
export { SkinObject, BodyPart, CapeObject, PlayerObject, SkinViewer, OrbitControls, createOrbitControls, invokeAnimation, CompositeAnimation, WalkingAnimation, RunningAnimation, RotatingAnimation, isSlimSkin }; | ||
export { BodyPart, CapeObject, CompositeAnimation, OrbitControls, PlayerObject, RotatingAnimation, RunningAnimation, SkinObject, SkinViewer, WalkingAnimation, createOrbitControls, invokeAnimation, isSlimSkin }; |
@@ -32,9 +32,17 @@ import * as THREE from "three"; | ||
readonly playerObject: PlayerObject; | ||
private _renderPaused; | ||
constructor(options: SkinViewerOptions); | ||
setSize(width: any, height: any): void; | ||
private draw; | ||
setSize(width: number, height: number): void; | ||
dispose(): void; | ||
skinUrl: string; | ||
capeUrl: string; | ||
width: number; | ||
height: number; | ||
get renderPaused(): boolean; | ||
set renderPaused(value: boolean); | ||
get skinUrl(): string; | ||
set skinUrl(url: string); | ||
get capeUrl(): string; | ||
set capeUrl(url: string); | ||
get width(): number; | ||
set width(newWidth: number); | ||
get height(): number; | ||
set height(newHeight: number); | ||
} |
{ | ||
"name": "skinview3d", | ||
"version": "1.2.0-alpha.1", | ||
"version": "1.2.0", | ||
"description": "Three.js powered Minecraft skin viewer", | ||
@@ -10,3 +10,3 @@ "module": "dist/skinview3d.module.js", | ||
"test": "karma start && npm run lint", | ||
"prepublishOnly": "npm test && rimraf dist && npm run build", | ||
"prepublishOnly": "rimraf dist && npm run build", | ||
"lint": "tslint --formatters-dir ./node_modules/tslint-formatter-beauty -t beauty -p .", | ||
@@ -37,9 +37,10 @@ "dev": "npm-run-all --parallel watch serve", | ||
"dependencies": { | ||
"three": "^0.97.0" | ||
"three": "^0.112.0" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "^6.0.0", | ||
"@types/chai": "^4.1.4", | ||
"@types/mocha": "^5.2.5", | ||
"@types/three": "^0.93.4", | ||
"chai": "^4.1.2", | ||
"chai": "^4.2.0", | ||
"karma": "^3.0.0", | ||
@@ -54,14 +55,13 @@ "karma-chrome-launcher": "^2.2.0", | ||
"rimraf": "^2.6.2", | ||
"rollup": "^0.66.6", | ||
"rollup-plugin-license": "^0.7.0", | ||
"rollup-plugin-node-resolve": "^3.3.0", | ||
"rollup-plugin-typescript2": "^0.17.1", | ||
"rollup-plugin-uglify": "^6.0.0", | ||
"rollup": "^1.27.14", | ||
"rollup-plugin-license": "^0.13.0", | ||
"rollup-plugin-terser": "^5.1.3", | ||
"rollup-plugin-typescript2": "^0.25.3", | ||
"ts-loader": "^5.2.2", | ||
"tslint": "^5.11.0", | ||
"tslint-formatter-beauty": "^3.0.0-beta.2", | ||
"typescript": "^3.0.1", | ||
"typescript": "^3.7.4", | ||
"url-loader": "^1.1.1", | ||
"webpack": "^4.17.1" | ||
"webpack": "^4.41.4" | ||
} | ||
} |
skinview3d | ||
======== | ||
[![Travis](https://img.shields.io/travis/bs-community/skinview3d.svg?style=flat-square)](https://travis-ci.org/bs-community/skinview3d) | ||
![](https://github.com/bs-community/skinview3d/workflows/CI/badge.svg) | ||
[![npm](https://img.shields.io/npm/v/skinview3d.svg?style=flat-square)](https://www.npmjs.com/package/skinview3d) | ||
@@ -6,0 +6,0 @@ [![license](https://img.shields.io/badge/license-MIT-yellowgreen.svg?style=flat-square)](https://github.com/bs-community/skinview3d/blob/master/LICENSE) |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
158536
2833
1
+ Addedthree@0.112.1(transitive)
- Removedthree@0.97.0(transitive)
Updatedthree@^0.112.0