Log inGet started
Package

vrm.module

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

vrm

What a VRM avatar (.vrm, VRM 0.x or 1.0) states beside its glTF mesh, in the engine's vocabulary. The model importer reads every .vrm (and every .glb carrying the VRM extensions) through it and builds a standard avatar beside the bundle; a script reads a file the same way.

local vrm = require("@builtin::modules.vrm")
local d = vrm.read(vrm.document(vfs.read("/source/me.vrm")))
print(d.version, d.meta.name, table.concat(d.meta.authors, ", "), d.humanoid.head)
for name, e in d.expressions do print(name, #e.binds, e.overrideBlink) end
print(#d.springs, #d.colliders, #d.constraints)
local ok, why = vrm.permits(d.meta, "wear")

What read answers

FieldHolds
version"1.0" or "0.x"
metathe licence and credits in VRM 1.0's fields: name, version, authors, copyright, contact, references, licenseUrl, otherLicenseUrl, avatarPermission, commercialUsage, creditNotation, modification, allowRedistribution, allowExcessivelyViolentUsage, allowExcessivelySexualUsage, allowPoliticalOrReligiousUsage, allowAntisocialOrHateUsage (a 0.x file adds sourceLicense and otherPermissionUrl)
humanoid{ [vrmBone] = nodeName }, VRM 1.0's bone names
expressions{ [name] = { binds = {{ mesh, shape, weight }}, shape, isBinary, overrideBlink, overrideLookAt, overrideMouth } }, keyed by the VRM 1.0 preset or the custom expression's name
firstPerson{ bone, annotations = {{ mesh, type }} }, type auto, both, thirdPersonOnly or firstPersonOnly
lookAt`{ type = "bone"
springs{{ name, center, colliders, joints = {{ bone, tail, stiffness, drag, gravityPower, gravityDir, hitRadius }} }} (the SpringBones component's form)
colliders`{{ bone, shape = "sphere"
constraints`{{ kind = "rotation"
materials`{ [gltfMaterialIndex + 1] = { kind = "mtoon"

Bones and meshes are named by their glTF node's name, the name the imported body's entities and rig bones carry; blend shapes by the name their mesh declares.

VRM 0.x

A 0.x file is brought to 1.0's terms the way the VRM specification's migration states: its vectors (authored in Unity's space) have z turned around; the thumb's proximal and intermediate bones become metacarpal and proximal; the presets a i u e o, joy, sorrow, fun and blink_l / blink_r become aa ih ou ee oh, happy, sad, relaxed and blinkLeft / blinkRight, and a custom group named after a preset (Surprised) is that preset; bind weights come from 0..100 to 0..1; each bone group swings every bone under its roots, a bone's tail its first child, or 7 cm past it for a leaf; MToon's colours come from gamma to linear, its shade shift and toony pair are remapped and its outline width comes from centimetres to metres; and the licence's allowedUserName, usage flags and licenseName (CC0, the CC_BY family, Redistribution_Prohibited, Other) become 1.0's permissions.

Licence

vrm.permits(meta, use, opts) answers whether a meta permits use (vrm.uses): wear, redistribute, modify, modifyAndRedistribute, commercial, corporate, violent, sexual, political, antisocial, with the field and value that forbid it. wear under onlyAuthor or onlySeparatelyLicensedPerson holds only with { licensed = true }. An avatar asset answers the same through avatarRef:permits(use); avatar.wear and avatar.save refuse an avatar a person may not perform as.