Skip to content

Commit

Permalink
Merge pull request #169 from Benjythebee/improv/add-VRM-bone-check
Browse files Browse the repository at this point in the history
works!, merging :)
  • Loading branch information
memelotsqui authored Oct 25, 2024
2 parents aa9eeef + 4e9122d commit 96f9d4f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/library/VRMExporterv0.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,19 @@ export default class VRMExporterv0 {
extensionsUsed.push("KHR_texture_basisu");
}

/**
* Check for bone count mismatch else the VRM will be broken
*/
for(const skin of outputSkins){
const mats = outputAccessors.filter(acc => acc.type == "MAT4");
for(let m of mats){
if(skin.joints.length != m.count){
throw new Error(`The number of joints in the skin is not equal to the number of Accessors of type MAT4. Got ${skin.joints.length} when accessors show ${m.count} This is usually because of a bone count mismatch in your VRMs!`);
}
}

}

const outputData = {
accessors: outputAccessors,
asset: exporterInfo,
Expand Down

0 comments on commit 96f9d4f

Please sign in to comment.