UNPKG

bvh-loader

Version:
126 lines (76 loc) • 3.06 kB
# bvh-loader.js ### Objective 1 [100% DONE] ### bvh.py to bvh.js ā˜• ### Npm package link: https://www.npmjs.com/package/bvh-loader ### Objective 2 Implement loader/draws intro matrix-engine-wgpu. šŸ¤ž Make pseudo (primitives) Skeletal Mesh and adapt it to the bvh loader output data. DONE ## Project structure <pre> ā”œā”€ā”€ javascript-bvh/ [Vanila JS] | ā”œā”€ā”€ bvh-loader.js | ā”œā”€ā”€ example.bvh | ā”œā”€ā”€ index.html [test page] ā”œā”€ā”€ module/ [module JS - npm] | ā”œā”€ā”€ bvh-loader.js ā”œā”€ā”€ index.js ā”œā”€ā”€ test.js [test module] ā”œā”€ā”€ module.html [test module] ā”œā”€ā”€ package.json ā”œā”€ā”€ LINCENCE ā”œā”€ā”€ README.md </pre> ### NPM Service Navigate to module.html it is local test for npm package. This link also use npm service via cdn.skypack.dev - https://codepen.io/zlatnaspirala/pen/vYdVxQR #### Use great `cdn.skypack.dev` free service. No build , free hosting library. Just put in test.js - `import MEBvh from "https://cdn.skypack.dev/bvh-loader@0.0.3";` ``` import MEBvh from "https://cdn.skypack.dev/bvh-loader@0.0.3"; var anim = new MEBvh(); anim.parse_file("https://raw.githubusercontent.com/zlatnaspirala/Matrix-Engine-BVH-test/main/javascript-bvh/example.bvh").then(() => { console.info("plot_hierarchy no function") anim.plot_hierarchy(); var r = anim.frame_pose(0); console.log("FINAL P => ", r[0].length) console.log("FINAL R => ", r[1].length) var KEYS = anim.joint_names(); for(var x = 0;x < r[0].length;x++) { console.log("->" + KEYS[x] + "-> position: " + r[0][x] + " rotation: " + r[1][x]); } var all = anim.all_frame_poses(); console.log("Final All -> ", all); }); ``` #### Local test ```js import MEBvh from "./index"; var anim = new MEBvh(); anim.parse_file("https://raw.githubusercontent.com/zlatnaspirala/Matrix-Engine-BVH-test/main/javascript-bvh/example.bvh").then(() => { console.info("plot_hierarchy no function") anim.plot_hierarchy(); var r = anim.frame_pose(0); console.log("FINAL P => ", r[0].length) console.log("FINAL R => ", r[1].length) var KEYS = anim.joint_names(); for(var x = 0;x < r[0].length;x++) { console.log("->" + KEYS[x] + "-> position: " + r[0][x] + " rotation: " + r[1][x]); } var all = anim.all_frame_poses(); console.log("Final All -> ", all); }); ``` #### New features: - 1.0.0 added matrixFromKeyframe intro class MEBvhJoint. Last version is in module folder [npm use last version]. bvh loader now is adapted also for matrix-engine-webgpu. I use webgpu-matrix npm package for `matrixFromKeyframe` used in matrix-engine-webgpu project for skinnedMesh glb import. ### Licence https://maximumroulette.com GNU GENERAL PUBLIC LICENSE Version 3 But only if you modify source of loader if you use it from npm no need to publish you code. Use it it is free... ### Credits Original source: https://github.com/dabeschte/npybvh