skinview3d
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -629,3 +629,2 @@ /** | ||
this.renderer.setSize(300, 300); // default size | ||
this.renderer.context.getShaderInfoLog = function () { return ""; }; // shut firefox up | ||
this.domElement.appendChild(this.renderer.domElement); | ||
@@ -632,0 +631,0 @@ this.playerObject = new PlayerObject(this.layer1Material, this.layer2Material, this.capeMaterial); |
@@ -21,2 +21,2 @@ /** | ||
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})})); | ||
***************************************************************************** */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 U=new t.BoxGeometry(4-h,12-h,4-h,0,0,0);s(U,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 D=new t.Mesh(U,n),I=new t.BoxGeometry(4.5-h,13.5-h,4.5-h,0,0,0);s(I,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(I,a);C.renderOrder=1;var V=new t.Group;return V.add(D,C),V.position.y=-6,i.leftLeg=new c(D,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.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})})); |
@@ -625,3 +625,2 @@ /** | ||
this.renderer.setSize(300, 300); // default size | ||
this.renderer.context.getShaderInfoLog = function () { return ""; }; // shut firefox up | ||
this.domElement.appendChild(this.renderer.domElement); | ||
@@ -628,0 +627,0 @@ this.playerObject = new PlayerObject(this.layer1Material, this.layer2Material, this.capeMaterial); |
{ | ||
"name": "skinview3d", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Three.js powered Minecraft skin viewer", | ||
@@ -36,3 +36,3 @@ "module": "dist/skinview3d.module.js", | ||
"dependencies": { | ||
"three": "^0.112.0" | ||
"three": "^0.112.1" | ||
}, | ||
@@ -43,3 +43,2 @@ "devDependencies": { | ||
"@types/mocha": "^5.2.5", | ||
"@types/three": "^0.93.4", | ||
"chai": "^4.2.0", | ||
@@ -46,0 +45,0 @@ "karma": "^3.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
23
0
158252
2831
Updatedthree@^0.112.1