skinview3d/js/build/skinview3d.min.js

64 lines
24 KiB
JavaScript
Raw Normal View History

2018-02-11 17:01:28 +01:00
/**
* skinview3d (https://github.com/to2mbn/skinview3d)
*
* MIT License
*
2018-02-12 08:58:31 +01:00
* Copyright (c) 2014-2018 Kent Rasmussen
* Copyright (c) 2017-2018 Haowei Wen, Sean Boult and contributors
2018-02-11 17:01:28 +01:00
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
2018-05-13 06:05:28 +02:00
!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,t){"use strict";var n=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),i=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},o=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t};function r(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 s(e,t,n,a){return r(e,t,n,a,64,64)}function c(e,t,n,a){return r(e,t,n,a,64,32)}function h(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 d=.002,u=function(e){function a(e,i,r){n(this,a);var c=o(this,(a.__proto__||Object.getPrototypeOf(a)).call(this));c.slim=e,c.head=new t.Group;var u=new t.BoxGeometry(8,8,8,0,0,0);h(u,s(8,0,16,8),s(16,0,24,8),s(0,8,8,16),s(8,8,16,16),s(16,8,24,16),s(24,8,32,16));var m=new t.Mesh(u,i);c.head.add(m);var p=new t.BoxGeometry(9,9,9,0,0,0);h(p,s(40,0,48,8),s(48,0,56,8),s(32,8,40,16),s(40,8,48,16),s(48,8,56,16),s(56,8,64,16));var l=new t.Mesh(p,r);l.renderOrder=-1,c.head.add(l),c.add(c.head),c.body=new t.Group;var f=new t.BoxGeometry(8,12,4,0,0,0);h(f,s(20,16,28,20),s(28,16,36,20),s(16,20,20,32),s(20,20,28,32),s(28,20,32,32),s(32,20,40,32));var g=new t.Mesh(f,i);c.body.add(g);var v=new t.BoxGeometry(9,13.5,4.5,0,0,0);h(v,s(20,32,28,36),s(28,32,36,36),s(16,36,20,48),s(20,36,28,48),s(28,36,32,48),s(32,36,40,48));var b=new t.Mesh(v,r);c.body.add(b),c.body.position.y=-10,c.add(c.body),c.rightArm=new t.Group;var w=new t.Group,y=new t.BoxGeometry((e?3:4)-d,12-d,4-d,0,0,0);e?h(y,s(44,16,47,20),s(47,16,50,20),s(40,20,44,32),s(44,20,47,32),s(47,20,51,32),s(51,20,54,32)):h(y,s(44,16,48,20),s(48,16,52,20),s(40,20,44,32),s(44,20,48,32),s(48,20,52,32),s(52,20,56,32));var x=new t.Mesh(y,i);w.add(x);var M=new t.BoxGeometry((e?3.375:4.5)-d,13.5-d,4.5-d,0,0,0);e?h(M,s(44,32,47,36),s(47,32,50,36),s(40,36,44,48),s(44,36,47,48),s(47,36,51,48),s(51,36,54,48)):h(M,s(44,32,48,36),s(48,32,52,36),s(40,36,44,48),s(44,36,48,48),s(48,36,52,48),s(52,36,56,48));var k=new t.Mesh(M,r);k.renderOrder=1,w.add(k),w.position.y=-6,c.rightArm.add(w),c.rightArm.position.y=-4,c.rightArm.position.x=e?-5.5:-6,c.add(c.rightArm),c.leftArm=new t.Group;var E=new t.Group,O=new t.BoxGeometry((e?3:4)-d,12-d,4-d,0,0,0);e?h(O,s(36,48,39,52),s(39,48,42,52),s(32,52,36,64),s(36,52,39,64),s(39,52,43,64),s(43,52,46,64)):h(O,s(36,48,40,52),s(40,48,44,52),s(32,52,36,64),s(36,52,40,64),s(40,52,44,64),s(44,52,48,64));var I=new t.Mesh(O,i);E.add(I);var P=new t.BoxGeometry((e?3.375:4.5)-d,13.5-d,4.5-d,0,0,0);e?h(P,s(52,48,55,52),s(55,48,58,52),s(48,52,52,64),s(52,52,55,64),s(55,52,59,64),s(59,52,62,64)):h(P,s(52,48,56,52),s(56,48,60,52),s(48,52,52,64),s(52,52,56,64),s(56,52,60,64),s(60,52,64,64));var j=new t.Mesh(P,r);j.renderOrder=1,E.add(j),E.position.y=-6,c.leftArm.add(E),c.leftArm.position.y=-4,c.leftArm.position.x=e?5.5:6,c.add(c
/**
* @preserve
* The code was originally from https://github.com/mrdoob/three.js/blob/d45a042cf962e9b1aa9441810ba118647b48aacb/examples/js/controls/OrbitControls.js
*/
/**
* @license
* Copyright (C) 2010-2017 three.js authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
* @author qiao / https://github.com/qiao
* @author mrdoob / http://mrdoob.com
* @author alteredq / http://alteredqualia.com/
* @author WestLangley / http://github.com/WestLangley
* @author erich666 / http://erichaines.com
*/
2018-05-13 06:05:28 +02:00
function a(e,i){n(this,a);var r,s,c,h,d,u=o(this,(a.__proto__||Object.getPrototypeOf(a)).call(this));u.object=e,u.domElement=void 0!==i?i:document,u.enabled=!0,u.target=new t.Vector3,u.minDistance=0,u.maxDistance=1/0,u.minZoom=0,u.maxZoom=1/0,u.minPolarAngle=0,u.maxPolarAngle=Math.PI,u.minAzimuthAngle=-1/0,u.maxAzimuthAngle=1/0,u.enableDamping=!1,u.dampingFactor=.25,u.enableZoom=!0,u.zoomSpeed=1,u.enableRotate=!0,u.rotateSpeed=1,u.enablePan=!0,u.keyPanSpeed=7,u.autoRotate=!1,u.autoRotateSpeed=2,u.enableKeys=!0,u.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},u.mouseButtons={ORBIT:t.MOUSE.LEFT,ZOOM:t.MOUSE.MIDDLE,PAN:t.MOUSE.RIGHT},u.target0=u.target.clone(),u.position0=u.object.position.clone(),u.zoom0=u.object.zoom,u.getPolarAngle=function(){return w.phi},u.getAzimuthalAngle=function(){return w.theta},u.saveState=function(){m.target0.copy(m.target),m.position0.copy(m.object.position),m.zoom0=m.object.zoom},u.reset=function(){m.target.copy(m.target0),m.object.position.copy(m.position0),m.object.zoom=m.zoom0,m.object.updateProjectionMatrix(),m.dispatchEvent(p),m.update(),v=g.NONE},u.update=(r=new t.Vector3,s=(new t.Quaternion).setFromUnitVectors(e.up,new t.Vector3(0,1,0)),c=s.clone().inverse(),h=new t.Vector3,d=new t.Quaternion,function(){var e=m.object.position;return r.copy(e).sub(m.target),r.applyQuaternion(s),w.setFromVector3(r),m.autoRotate&&v===g.NONE&&V(2*Math.PI/60/60*m.autoRotateSpeed),w.theta+=y.theta,w.phi+=y.phi,w.theta=Math.max(m.minAzimuthAngle,Math.min(m.maxAzimuthAngle,w.theta)),w.phi=Math.max(m.minPolarAngle,Math.min(m.maxPolarAngle,w.phi)),w.makeSafe(),w.radius*=x,w.radius=Math.max(m.minDistance,Math.min(m.maxDistance,w.radius)),m.target.add(M),r.setFromSpherical(w),r.applyQuaternion(c),e.copy(m.target).add(r),m.object.lookAt(m.target),!0===m.enableDamping?(y.theta*=1-m.dampingFactor,y.phi*=1-m.dampingFactor):y.set(0,0,0),x=1,M.set(0,0,0),!!(k||h.distanceToSquared(m.object.position)>b||8*(1-d.dot(m.object.quaternion))>b)&&(m.dispatchEvent(p),h.copy(m.object.position),d.copy(m.object.quaternion),k=!1,!0)}),u.dispose=function(){m.domElement.removeEventListener("contextmenu",Q,!1),m.domElement.removeEventListener("mousedown",D,!1),m.domElement.removeEventListener("wheel",H,!1),m.domElement.removeEventListener("touchstart",Z,!1),m.domElement.removeEventListener("touchend",q,!1),m.domElement.removeEventListener("touchmove",W,!1),document.removeEventListener("mousemove",F,!1),document.removeEventListener("mouseup",Y,!1),window.removeEventListener("keydown",X,!1)};var m=u,p={type:"change"},l={type:"start"},f={type:"end"},g={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},v=g.NONE,b=1e-6,w=new t.Spherical,y=new t.Spherical,x=1,M=new t.Vector3,k=!1,E=new t.Vector2,O=new t.Vector2,I=new t.Vector2,P=new t.Vector2,j=new t.Vector2,C=new t.Vector2,T=new t.Vector2,A=new t.Vector2,L=new t.Vector2;function _(){return Math.pow(.95,m.zoomSpeed)}function V(e){y.theta-=e}function N(e){y.phi-=e}var S,U=(S=new t.Vector3,function(e,t){S.setFromMatrixColumn(t,0),S.multiplyScalar(-e),M.add(S)}),z=function(){var e=new t.Vector3;return function(t,n){e.setFromMatrixColumn(n,1),e.multiplyScalar(t),M.add(e)}}(),G=function(){var e=new t.Vector3;return function(n,a){var i=m.domElement===document?m.domElement.body:m.domElement;if(m.object instanceof t.PerspectiveCamera){var o=m.object.position;e.copy(o).sub(m.target);var r=e.length();r*=Math.tan(m.object.fov/2*Math.PI/180),U(2*n*r/i.clientHeight,m.object.matrix),z(2*a*r/i.clientHeight,m.object.matrix)}else m.object instanceof t.OrthographicCamera?(U(n*(m.object.right-m.object.left)/m.object.zoom/i.clientWidth,m.object.matrix),z(a*(m.object.top-m.object.bottom)/m.object.zoom/i.clientHeight,m.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),m.enablePan=!1)}}();function R(e){m.object instanceof t.PerspectiveCamera?x/=e:m.object instanceof t.OrthographicCamera?(m.object.zoom=Math.max(m.minZoom,Math.min(m.maxZoom,m.object.zoom*e)),m.object.updateProjectionMatrix(),k=!0):(console.warn("WARNING: OrbitControls.js enc
//# sourceMappingURL=skinview3d.min.js.map