{"library":"mmd-parser","title":"MMD Parser","description":"MMD Parser is a JavaScript library designed for parsing MMD (MikuMikuDance) data files, specifically PMD, PMX, VMD, and VPD formats. It takes ArrayBuffer or String inputs and outputs structured JavaScript objects representing the parsed model or motion data. The current stable version is 1.0.4, as indicated by the package metadata. This package serves as a low-level data interpreter for MMD assets, providing the raw data for applications that wish to display or manipulate MMD content programmatically, rather than being a renderer itself. Its primary function is to abstract the binary or text parsing of these complex 3D model and animation formats into easily consumable JavaScript objects. The library has been in a stable state, primarily focusing on parsing capabilities without frequent breaking changes or new feature additions, making it a reliable choice for integrating MMD data handling into JavaScript projects. It differentiates itself by focusing purely on parsing, leaving rendering and further processing to other libraries like Three.js.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mmd-parser"],"cli":null},"imports":["const { Parser } = require('mmd-parser');","const MMDParser = require('mmd-parser');\nconst parser = new MMDParser.Parser();","<script src=\"./build/mmdparser.js\"></script>\n<script>\n  var parser = new MMDParser.Parser();\n</script>"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const { Parser } = require('mmd-parser');\n\nconst parser = new Parser();\n\n// Simulate loading a PMD file as an ArrayBuffer\n// In a real application, you would load this from disk or network.\n// This is a minimal dummy buffer, a real PMD file is much larger.\n// A PMD file structure starts with a header, for example, \"Pmd\" magic string.\nconst dummyPmdBuffer = new ArrayBuffer(50);\nconst view = new DataView(dummyPmdBuffer);\n// Write 'P', 'm', 'd' magic bytes (ASCII codes 80, 109, 100)\nview.setUint8(0, 80);\nview.setUint8(1, 109);\nview.setUint8(2, 100);\n\n// Try parsing the dummy PMD buffer\ntry {\n  const pmdData = parser.parsePmd(dummyPmdBuffer, false); // false for right-handed coordinates\n  console.log('Successfully parsed dummy PMD header:');\n  // A real PMD object would have many properties, e.g., metadata, bones, faces, etc.\n  console.log('PMD header data:', pmdData.header);\n} catch (error) {\n  console.error('Error parsing PMD data:', error.message);\n  console.warn('Note: This is a dummy buffer and not a real PMD file, so parsing will likely fail or return incomplete data.');\n}\n\n// Example of parsing a dummy PMX buffer\nconst dummyPmxBuffer = new ArrayBuffer(50);\nconst pmxView = new DataView(dummyPmxBuffer);\npmxView.setUint8(0, 80);\npmxView.setUint8(1, 77);\npmxView.setUint8(2, 88);\npmxView.setUint8(3, 32); // ' PMX '\n\ntry {\n  const pmxData = parser.parsePmx(dummyPmxBuffer, false);\n  console.log('\\nSuccessfully parsed dummy PMX header:');\n  console.log('PMX header data:', pmxData.header);\n} catch (error) {\n  console.error('Error parsing PMX data:', error.message);\n  console.warn('Note: This is a dummy buffer and not a real PMX file, so parsing will likely fail or return incomplete data.');\n}","lang":"javascript","description":"Demonstrates how to instantiate the MMD Parser and attempt to parse simulated PMD and PMX ArrayBuffer data in a Node.js environment.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}