UNPKG

bytev-charts-beta

Version:

基于echarts和JavaScript及ES6封装的一个可以直接调用的图表组件库,内置主题设计,简单快捷,且支持用户自定义配置; npm 安装方式: npm install bytev-charts 若启动提示还需额外install插件,则运行 npm install @babel/runtime-corejs2 即可;

193 lines (167 loc) 6.32 kB
import "core-js/modules/es.date.to-string.js"; import "core-js/modules/es.object.to-string.js"; import "core-js/modules/es.regexp.to-string.js"; import "core-js/modules/es.array.iterator.js"; import "core-js/modules/es.array-buffer.slice.js"; import "core-js/modules/es.typed-array.uint8-array.js"; import "core-js/modules/es.typed-array.copy-within.js"; import "core-js/modules/es.typed-array.every.js"; import "core-js/modules/es.typed-array.fill.js"; import "core-js/modules/es.typed-array.filter.js"; import "core-js/modules/es.typed-array.find.js"; import "core-js/modules/es.typed-array.find-index.js"; import "core-js/modules/es.typed-array.for-each.js"; import "core-js/modules/es.typed-array.includes.js"; import "core-js/modules/es.typed-array.index-of.js"; import "core-js/modules/es.typed-array.iterator.js"; import "core-js/modules/es.typed-array.join.js"; import "core-js/modules/es.typed-array.last-index-of.js"; import "core-js/modules/es.typed-array.map.js"; import "core-js/modules/es.typed-array.reduce.js"; import "core-js/modules/es.typed-array.reduce-right.js"; import "core-js/modules/es.typed-array.reverse.js"; import "core-js/modules/es.typed-array.set.js"; import "core-js/modules/es.typed-array.slice.js"; import "core-js/modules/es.typed-array.some.js"; import "core-js/modules/es.typed-array.sort.js"; import "core-js/modules/es.typed-array.subarray.js"; import "core-js/modules/es.typed-array.to-locale-string.js"; import "core-js/modules/es.typed-array.to-string.js"; import "core-js/modules/es.array.index-of.js"; import "core-js/modules/es.array.slice.js"; import "core-js/modules/es.array.join.js"; import "core-js/modules/es.function.name.js"; import "core-js/modules/es.regexp.exec.js"; import "core-js/modules/es.string.replace.js"; import "core-js/modules/es.promise.js"; import "core-js/modules/es.string.sub.js"; import _Object$keys from "@babel/runtime-corejs2/core-js/object/keys"; import _parseInt from "@babel/runtime-corejs2/core-js/parse-int"; console.warn("THREE.MMDExporter: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/#manual/en/introduction/Installation."); /** * Dependencies * - mmd-parser https://github.com/takahirox/mmd-parser */ THREE.MMDExporter = function () { // Unicode to Shift_JIS table var u2sTable; function unicodeToShiftjis(str) { if (u2sTable === undefined) { var encoder = new MMDParser.CharsetEncoder(); var table = encoder.s2uTable; u2sTable = {}; var keys = _Object$keys(table); for (var i = 0, il = keys.length; i < il; i++) { var key = keys[i]; var value = table[key]; key = _parseInt(key); u2sTable[value] = key; } } var array = []; for (var i = 0, il = str.length; i < il; i++) { var code = str.charCodeAt(i); var value = u2sTable[code]; if (value === undefined) { throw 'cannot convert charcode 0x' + code.toString(16); } else if (value > 0xff) { array.push(value >> 8 & 0xff); array.push(value & 0xff); } else { array.push(value & 0xff); } } return new Uint8Array(array); } function getBindBones(skin) { // any more efficient ways? var poseSkin = skin.clone(); poseSkin.pose(); return poseSkin.skeleton.bones; } /* TODO: implement // mesh -> pmd this.parsePmd = function ( object ) { }; */ /* TODO: implement // mesh -> pmx this.parsePmx = function ( object ) { }; */ /* * skeleton -> vpd * Returns Shift_JIS encoded Uint8Array. Otherwise return strings. */ this.parseVpd = function (skin, outputShiftJis, useOriginalBones) { if (skin.isSkinnedMesh !== true) { console.warn('THREE.MMDExporter: parseVpd() requires SkinnedMesh instance.'); return null; } function toStringsFromNumber(num) { if (Math.abs(num) < 1e-6) num = 0; var a = num.toString(); if (a.indexOf('.') === -1) { a += '.'; } a += '000000'; var index = a.indexOf('.'); var d = a.slice(0, index); var p = a.slice(index + 1, index + 7); return d + '.' + p; } function toStringsFromArray(array) { var a = []; for (var i = 0, il = array.length; i < il; i++) { a.push(toStringsFromNumber(array[i])); } return a.join(','); } skin.updateMatrixWorld(true); var bones = skin.skeleton.bones; var bones2 = getBindBones(skin); var position = new THREE.Vector3(); var quaternion = new THREE.Quaternion(); var quaternion2 = new THREE.Quaternion(); var matrix = new THREE.Matrix4(); var array = []; array.push('Vocaloid Pose Data file'); array.push(''); array.push((skin.name !== '' ? skin.name.replace(/\s/g, '_') : 'skin') + '.osm;'); array.push(bones.length + ';'); array.push(''); for (var i = 0, il = bones.length; i < il; i++) { var bone = bones[i]; var bone2 = bones2[i]; /* * use the bone matrix saved before solving IK. * see CCDIKSolver for the detail. */ if (useOriginalBones === true && bone.userData.ik !== undefined && bone.userData.ik.originalMatrix !== undefined) { matrix.fromArray(bone.userData.ik.originalMatrix); } else { matrix.copy(bone.matrix); } position.setFromMatrixPosition(matrix); quaternion.setFromRotationMatrix(matrix); var pArray = position.sub(bone2.position).toArray(); var qArray = quaternion2.copy(bone2.quaternion).conjugate().multiply(quaternion).toArray(); // right to left pArray[2] = -pArray[2]; qArray[0] = -qArray[0]; qArray[1] = -qArray[1]; array.push('Bone' + i + '{' + bone.name); array.push(' ' + toStringsFromArray(pArray) + ';'); array.push(' ' + toStringsFromArray(qArray) + ';'); array.push('}'); array.push(''); } array.push(''); var lines = array.join('\n'); return outputShiftJis === true ? unicodeToShiftjis(lines) : lines; }; /* TODO: implement // animation + skeleton -> vmd this.parseVmd = function ( object ) { }; */ };