skinview3d/js/dist/skinview3d.min.js

22 lines
26 KiB
JavaScript
Raw Normal View History

/**
* skinview3d (https://github.com/bs-community/skinview3d)
*
* MIT License
*/
2020-01-07 06:29:51 +01: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=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 o(e,n,a,o,i,r){return[new t.Vector2(e/i,1-o/r),new t.Vector2(a/i,1-o/r),new t.Vector2(a/i,1-n/r),new t.Vector2(e/i,1-n/r)]}function i(e,t,n,a){return o(e,t,n,a,64,64)}function r(e,t,n,a){return o(e,t,n,a,64,32)}function s(e,t,n,a,o,i,r){e.faceVertexUvs[0]=[],e.faceVertexUvs[0][0]=[i[3],i[0],i[2]],e.faceVertexUvs[0][1]=[i[0],i[1],i[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]=[o[3],o[0],o[2]],e.faceVertexUvs[0][9]=[o[0],o[1],o[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 o=e.call(this)||this;o.modelListeners=[],o._slim=!1;var r=new t.BoxGeometry(8,8,8,0,0,0);s(r,i(8,0,16,8),i(16,0,24,8),i(0,8,8,16),i(8,8,16,16),i(16,8,24,16),i(24,8,32,16));var d=new t.Mesh(r,n),l=new t.BoxGeometry(9,9,9,0,0,0);s(l,i(40,0,48,8),i(48,0,56,8),i(32,8,40,16),i(40,8,48,16),i(48,8,56,16),i(56,8,64,16));var p=new t.Mesh(l,a);p.renderOrder=-1,o.head=new c(d,p),o.head.name="head",o.head.add(d,p),o.add(o.head);var u=new t.BoxGeometry(8,12,4,0,0,0);s(u,i(20,16,28,20),i(28,16,36,20),i(16,20,20,32),i(20,20,28,32),i(28,20,32,32),i(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,i(20,32,28,36),i(28,32,36,36),i(16,36,20,48),i(20,36,28,48),i(28,36,32,48),i(32,36,40,48));var y=new t.Mesh(f,a);o.body=new c(m,y),o.body.name="body",o.body.add(m,y),o.body.position.y=-10,o.add(o.body);var g=new t.BoxGeometry(1,1,1,0,0,0),v=new t.Mesh(g,n);o.modelListeners.push((function(){v.scale.x=(o.slim?3:4)-h,v.scale.y=12-h,v.scale.z=4-h,o.slim?s(g,i(44,16,47,20),i(47,16,50,20),i(40,20,44,32),i(44,20,47,32),i(47,20,51,32),i(51,20,54,32)):s(g,i(44,16,48,20),i(48,16,52,20),i(40,20,44,32),i(44,20,48,32),i(48,20,52,32),i(52,20,56,32)),g.uvsNeedUpdate=!0,g.elementsNeedUpdate=!0}));var w=new t.BoxGeometry(1,1,1,0,0,0),b=new t.Mesh(w,a);b.renderOrder=1,o.modelListeners.push((function(){b.scale.x=(o.slim?3.375:4.5)-h,b.scale.y=13.5-h,b.scale.z=4.5-h,o.slim?s(w,i(44,32,47,36),i(47,32,50,36),i(40,36,44,48),i(44,36,47,48),i(47,36,51,48),i(51,36,54,48)):s(w,i(44,32,48,36),i(48,32,52,36),i(40,36,44,48),i(44,36,48,48),i(48,36,52,48),i(52,36,56,48)),w.uvsNeedUpdate=!0,w.elementsNeedUpdate=!0}));var M=new t.Group;M.add(v,b),M.position.y=-6,o.rightArm=new c(v,b),o.rightArm.name="rightArm",o.rightArm.add(M),o.rightArm.position.y=-4,o.modelListeners.push((function(){o.rightArm.position.x=o.slim?-5.5:-6})),o.add(o.rightArm);var E=new t.BoxGeometry(1,1,1,0,0,0),x=new t.Mesh(E,n);o.modelListeners.push((function(){x.scale.x=(o.slim?3:4)-h,x.scale.y=12-h,x.scale.z=4-h,o.slim?s(E,i(36,48,39,52),i(39,48,42,52),i(32,52,36,64),i(36,52,39,64),i(39,52,43,64),i(43,52,46,64)):s(E,i(36,48,40,52),i(40,48,44,52),i(32,52,36,64),i(36,52,40,64),i(40,52,44,64),i(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,o.modelListeners.push((function(){L.scale.x=(o.slim?3.375:4.5)-h,L.scale.y=13.5-h,L.scale.z=4.5-h,o.slim?s(O,i(52,48,55,52),i(55,48,58,52),i(48,52,52,64),i(52,52,55,64),i(55,52,59,64),i(59,52,62,64)):s(O,i(52,48,56,52),i(56,48,60,52),i(48,52,52,64),i(52,52,56,64),i(56,52,60,64),i(60,52,64,64)),O.uvsNeedUpdate=!0,O.elementsNeedUpdate=!0}));var P=new t.Group;P.add(x,L),P.position.y=-6,o.leftArm=new c(x,L),o.leftArm.name="leftArm",o.leftArm.add(P),o.leftArm.position.y