// https://github.com/takahirox/mmd-parser#readme !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.MMDParser=t.MMDParser||{})}(this,function(t){"use strict";function e(){}function n(t,n){this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===n||n,this.encoder=new e}function a(){}function o(){}e.prototype.s2u=function(t){for(var e=this.s2uTable,n="",a=0;a=0&&o<=126||o>=161&&o<=223)&&a0;){var n=this.getUint8();if(t--,0===n)break;e+=String.fromCharCode(n)}for(;t>0;)this.getUint8(),t--;return e},getSjisStringsAsUnicode:function(t){for(var e=[];t>0;){var n=this.getUint8();if(t--,0===n)break;e.push(n)}for(;t>0;)this.getUint8(),t--;return this.encoder.s2u(new Uint8Array(e))},getUnicodeStrings:function(t){for(var e="";t>0;){var n=this.getUint16();if(t-=2,0===n)break;e+=String.fromCharCode(n)}for(;t>0;)this.getUint8(),t--;return e},getTextBuffer:function(){var t=this.getUint32();return this.getUnicodeStrings(t)}},a.prototype={constructor:a,leftToRightVector3:function(t){t[2]=-t[2]},leftToRightQuaternion:function(t){t[0]=-t[0],t[1]=-t[1]},leftToRightEuler:function(t){t[0]=-t[0],t[1]=-t[1]},leftToRightIndexOrder:function(t){var e=t[2];t[2]=t[0],t[0]=e},leftToRightVector3Range:function(t,e){var n=-e[2];e[2]=-t[2],t[2]=n},leftToRightEulerRange:function(t,e){var n=-e[0],a=-e[1];e[0]=-t[0],e[1]=-t[1],t[0]=n,t[1]=a}},o.prototype.parsePmd=function(t,e){var a={},o=new n(t);a.metadata={},a.metadata.format="pmd",a.metadata.coordinateSystem="left";var i=function(){var t=a.metadata;if(t.magic=o.getChars(3),"Pmd"!==t.magic)throw"PMD file magic is not Pmd, but "+t.magic;t.version=o.getFloat32(),t.modelName=o.getSjisStringsAsUnicode(20),t.comment=o.getSjisStringsAsUnicode(256)},r=function(){var t=function(){var t={};return t.position=o.getFloat32Array(3),t.normal=o.getFloat32Array(3),t.uv=o.getFloat32Array(2),t.skinIndices=o.getUint16Array(2),t.skinWeights=[o.getUint8()/100],t.skinWeights.push(1-t.skinWeights[0]),t.edgeFlag=o.getUint8(),t},e=a.metadata;e.vertexCount=o.getUint32(),a.vertices=[];for(var n=0;n0&&(t.englishModelName=o.getSjisStringsAsUnicode(20),t.englishComment=o.getSjisStringsAsUnicode(256))},p=function(){var t=function(){var t={};return t.name=o.getSjisStringsAsUnicode(20),t},e=a.metadata;if(0!==e.englishCompatibility){a.englishBoneNames=[];for(var n=0;n