{"id":17913347,"url":"https://github.com/mugen87/three-m2loader","last_synced_at":"2025-11-13T22:50:49.904Z","repository":{"id":58435496,"uuid":"530128541","full_name":"Mugen87/three-m2loader","owner":"Mugen87","description":"three.js loader for importing M2 assets from World of Warcraft.","archived":false,"fork":false,"pushed_at":"2024-08-05T08:30:50.000Z","size":183,"stargazers_count":26,"open_issues_count":6,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-19T00:15:09.514Z","etag":null,"topics":["javascript","m2","threejs","world-of-warcraft"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mugen87.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-29T08:21:01.000Z","updated_at":"2025-02-05T02:53:55.000Z","dependencies_parsed_at":"2023-12-30T17:49:21.677Z","dependency_job_id":"52fa3146-37b4-459b-98f1-c93167d9bdee","html_url":"https://github.com/Mugen87/three-m2loader","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"926ce27418c8f8a3199a822ab87b355cf9ed1399"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mugen87%2Fthree-m2loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mugen87%2Fthree-m2loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mugen87%2Fthree-m2loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mugen87%2Fthree-m2loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mugen87","download_url":"https://codeload.github.com/Mugen87/three-m2loader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245180651,"owners_count":20573706,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","m2","threejs","world-of-warcraft"],"created_at":"2024-10-28T19:51:04.190Z","updated_at":"2025-11-13T22:50:49.876Z","avatar_url":"https://github.com/Mugen87.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# three-m2loader \u0026middot; [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Mugen87/yuka/blob/master/LICENSE) [![NPM Package](https://img.shields.io/npm/v/three-m2loader.svg)](https://www.npmjs.com/package/three-m2loader)\n\n### M2 Loader for three.js\n\n`three-m2loader` allows you to import M2 assets from World of Warcraft into your `three.js` app.\n\n| druidcat2.m2  | 7ne_druid_worktable02.m2 | gilneas_fountain01.m2 |\n| ------------- | ------------- | ------------- |\n| \u003cimg width=\"831\" alt=\"image\" src=\"https://user-images.githubusercontent.com/12612165/187862354-6399b1f3-fc07-4d97-8043-8a896fd5d063.png\"\u003e  | \u003cimg width=\"863\" alt=\"image\" src=\"https://user-images.githubusercontent.com/12612165/187862411-97df95a5-ae00-4122-addf-31b1cb57bd6e.png\"\u003e  | \u003cimg width=\"952\" alt=\"image\" src=\"https://user-images.githubusercontent.com/12612165/187862560-14f23b79-eff0-413a-a010-22f67387b7fd.png\"\u003e |\n\n### Table of contents\n1. [Basic Usage](#basic-usage)\n2. [Animations](#animations)\n3. [Skin Textures](#skin-textures)\n4. [Misc](#misc)\n\n### Basic Usage  \u003ca id=\"basic-usage\"\u003e\u003c/a\u003e\n\nIf you want to load an asset into your `three.js` app, you have to put all external resources like `.blp` or `.skin` files into the same directory like the M2 file. Depending on the M2 version, you have to name resources files with their `FileDataID` or with their actual file name. \n\nA minimal code example looks like so:\n\n```js\nimport { M2Loader } from 'three-m2loader';\n\nconst loader = new M2Loader();\nloader.load( 'models/cat/druidcat2.m2', function ( group ) {\n\n    scene.add( group );\n\n} );\n```\n\n### Animations \u003ca id=\"animations\"\u003e\u003c/a\u003e\n\n#### Sequences\n\nAnimations in M2 are called *sequences*. The playback of sequences is managed with an instance of `SequenceManager`. You can access it in the `userData` field of the returned group. \n```js\nconst manager = group.userData.sequenceManager;\n```\n\nYou can list all available sequences of a M2 asset with `listSequences()`. The list represents an array with objects that hold the `id` and `name` of a sequence.\n```js\nconst sequences = manager.listSequences();\n```\nIf you want to play a sequence, you can use `playSequence()`. `stopSequence()` stops the playback.\n```js\nmanager.playSequence( sequence.id ); // start playback\nmanager.stopSequence( sequence.id ); // stop playback\n```\nIf you want to stop the playback of all active sequences, you can use the convenience method `stopAllSequences()`.\n\n#### Variations\n\nCertain sequences like `Stand` or `AttackUnarmed` have multiple variations. You can list them for a given sequence via `listVariations()`.\n\n```js\nconst variations = manager.listVariations( sequence.id );\n```\nKeep in mind that all sequences have at least one variation (default). If you want to play or stop a sequence with a specific variation, use the second parameter of `playSequence()` and `stopSequence()`.\n```js\nmanager.playSequence( sequence.id, variationIndex ); // start playback\nmanager.stopSequence( sequence.id, variationIndex ); // stop playback\n```\n\n#### Global Sequences\n\nCertain M2 assets have so-called *global sequences*. They represent animations that are active all the time like the flowing water of a fountain or the effects of elemental spirits.\nYou can check if a M2 asset has global sequences with `hasGlobalSequences()` and control the playback via `playGlobalSequences()` and `stopGlobalSequences()`.\n\n```js\nif ( manager.hasGlobalSequences() ) {\n\n    manager.playGlobalSequences();\n\n}\n```\n\n### Skin Textures \u003ca id=\"skin-textures\"\u003e\u003c/a\u003e\n\nSome models (especially creatures) require the definition of skin textures. This can be done with an instance of `M2Options` and the `setSkin( id1, id2, id3 )` method. You have to pass in the `FileDataID`s\nof the textures that should represent the skin.\n\n```js\nconst options = new M2Options();\noptions.setSkin( 2015464, 123060 ); // 2015464 and 123060 are FileDataIDs representing BLP textures\n\nconst loader = new M2Loader();\nloader.load( 'bearmount/bearmount.m2', function ( group ) {\n\n    scene.add( group );\n\n}, undefined, undefined, options );\n```\nYou can use the same approach to overwrite the default skin of creatures (e.g. to switch the body color).\n\nTo retain the parameter order of `three.js` loaders, the `options` parameter comes after the three callback functions `onLoad()`, `onProgress()` and `onError()`.\n \n### Misc \u003ca id=\"misc\"\u003e\u003c/a\u003e\n\nThis loader requires `three.js` in version `r144` or higher.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmugen87%2Fthree-m2loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmugen87%2Fthree-m2loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmugen87%2Fthree-m2loader/lists"}