UNPKG

bytev-charts

Version:

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

108 lines (95 loc) 4.14 kB
import "core-js/modules/es.array-buffer.slice.js"; import "core-js/modules/es.data-view.js"; import "core-js/modules/es.object.to-string.js"; import "core-js/modules/es.array.iterator.js"; import "core-js/modules/es.typed-array.float32-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.fill.js"; import "core-js/modules/es.function.name.js"; import _Object$assign from "@babel/runtime-corejs2/core-js/object/assign"; import _Object$create from "@babel/runtime-corejs2/core-js/object/create"; /** * MDD is a special format that stores a position for every vertex in a model for every frame in an animation. * Similar to BVH, it can be used to transfer animation data between different 3D applications or engines. * * MDD stores its data in binary format (big endian) in the following way: * * number of frames (a single uint32) * number of vertices (a single uint32) * time values for each frame (sequence of float32) * vertex data for each frame (sequence of float32) */ import { AnimationClip, BufferAttribute, FileLoader, Loader, NumberKeyframeTrack } from "../../../build/three.module.js"; var MDDLoader = function MDDLoader(manager) { Loader.call(this, manager); }; MDDLoader.prototype = _Object$assign(_Object$create(Loader.prototype), { constructor: MDDLoader, load: function load(url, onLoad, onProgress, onError) { var scope = this; var loader = new FileLoader(this.manager); loader.setPath(this.path); loader.setResponseType('arraybuffer'); loader.load(url, function (data) { onLoad(scope.parse(data)); }, onProgress, onError); }, parse: function parse(data) { var view = new DataView(data); var totalFrames = view.getUint32(0); var totalPoints = view.getUint32(4); var offset = 8; // animation clip var times = new Float32Array(totalFrames); var values = new Float32Array(totalFrames * totalFrames).fill(0); for (var i = 0; i < totalFrames; i++) { times[i] = view.getFloat32(offset); offset += 4; values[totalFrames * i + i] = 1; } var track = new NumberKeyframeTrack('.morphTargetInfluences', times, values); var clip = new AnimationClip('default', times[times.length - 1], [track]); // morph targets var morphTargets = []; for (var i = 0; i < totalFrames; i++) { var morphTarget = new Float32Array(totalPoints * 3); for (var j = 0; j < totalPoints; j++) { var stride = j * 3; morphTarget[stride + 0] = view.getFloat32(offset); offset += 4; // x morphTarget[stride + 1] = view.getFloat32(offset); offset += 4; // y morphTarget[stride + 2] = view.getFloat32(offset); offset += 4; // z } var attribute = new BufferAttribute(morphTarget, 3); attribute.name = 'morph_' + i; morphTargets.push(attribute); } return { morphTargets: morphTargets, clip: clip }; } }); export { MDDLoader };