
How Mochi and Onigiri became 3D
Two VRM avatars built from code, stage by stage: shapes, parts, skeleton, skin, expressions, toon shading, spring bones and the file itself
By Dara O Shayda and Hikari Noor Hoshino (星野ヌール)
AI System Programming Laboratory, Computational Classnotes · 3 December
2026
Made at the owner’s request of 3 December 2026, 21:38 (“design a
3D version of both characters with tiny feet (stubs) in .vrm format”)
and 21:57 (“a complete detailed, stage by stage with lots of images, and
comments in the code, copyrights and placed in the library and man
pages”). The avatars: art/vrm/mochi.vrm and art/vrm/onigiri.vrm. The
code: tools/make-vrm.py,
which builds them, and tools/vrm-figures.py,
which drew every picture here. Every function of both has its page in the Pyon manual, sections 3vrm and
3vrmfig.
Contents
- What a VRM file is, and why code
- Stage 1 · Colours
- Stage 2 · The building blocks
- Stage 3 · Parts
- Stage 4 · The skeleton
- Stage 5 · The skin
- Stage 6 · Mochi and Onigiri, part by part
- Stage 7 · The expressions
- Stage 8 · Writing the file: materials, meshes, the VRM extensions, spring bones
- Stage 9 · Checking
- Using them, and changing them
Figures
- Figure 1 · Mochi and Onigiri in 3D
- Figure 2 · The building blocks
- Figure 3 · The skeletons
- Figure 4 · The skin weights
- Figure 5 · Poses
- Figure 6 · Mochi, part by part
- Figure 7 · Onigiri’s body
- Figure 8 · Onigiri, part by part
- Figure 9 · Mochi’s expressions
- Figure 10 · Onigiri’s expressions
- Figure 11 · Inside a .glb
- Figure 12 · Plain and toon
- Figure 13 · Spring bones
- Figure 14 · The thumbnails
1. What a VRM file is, and why code
- VRM is the file format of 3D avatars: the format of
VTubing programs, of VRoid Studio, cluster and many games. A
.vrmfile is a binary glTF 2.0 file (a.glb) with extra sections, the VRM extensions, which tell an avatar program what a plain 3D model cannot say for itself: 1.1. which of its bones is the head, the hips, the left foot (the humanoid), so that any program can make any avatar walk, wave or nod; 1.2. how its face blinks, smiles and speaks (the expressions); 1.3. how its hair, ears or tail sway (the spring bones); 1.4. how it is drawn (the MToon toon shading of anime avatars, with outlines); 1.5. who made it and how it may be used (the meta data and licence). - We wrote both avatars in Python, with NumPy, and nothing else. No modelling program (no Blender, no VRoid Studio, no Unity) was used. Every shape is a formula, every bone a line in a list, every expression a small change of shape, and the file is written byte by byte. So every curve and colour can be changed in a line and the avatars rebuilt in a second, and the code is kept with everything else, under the same licence.
- Units and axes: metres; Y up; the avatar faces +Z, so its left is +X (the rule of VRM 1.0). Both creatures stand 0.64 m tall.
- The stages below follow the code from top to bottom; each names the functions that do the work.
2. Stage 1 · Colours
- The colours are the drawings’ own, from Pyon’s
LOOKSinsrc/pyon.html: Mochi’s cream body#f3e6d3, the pink inside of her ears#ffb3c1, the eyes#1b1b2e, the cheeks#ff9aa8; Onigiri’s white#fafafa, its nori#1f3b2dand the orange dot#ff8c1a. - They are turned into linear light by
lin(), because glTF’s colours are linear while drawings are in sRGB; without this step every colour would come out pale.
def lin(hexs, a=1.0):
c = [int(hexs[i:i + 2], 16) / 255 for i in (1, 3, 5)]
return [((v / 12.92) if v <= 0.04045 else ((v + 0.055) / 1.055) ** 2.4) for v in c] + [a]- The shade side of each toon material is the same
colour a little darker, made by
darker().
3. Stage 2 · The building blocks
Every shape is returned in the same form, (V, N, I): the
positions of its vertices, their unit normals (which way the surface
faces at each), and its triangles as triples of vertex numbers.
sphere(): a unit sphere as a grid of slices and rings. The first and last column meet at the seam but stay separate vertices, so that the grid is regular; on a unit sphere each normal is the position itself.ellipsoid(): the sphere stretched by three radii, turned and moved. The normals are stretched by the inverse of the radii, the rule for normals under scaling, so the light falls correctly on a squat ball. Mochi’s body is one ellipsoid, 0.60 m wide, 0.54 m tall and 0.52 m deep; the eyes, cheeks, feet and the mouth are small ones.lathe(): a body of revolution, as a potter turns it: a profile of (radius, height) pairs turned round an axis. Each ear is one, a rounded cone leaning out.smooth()andtube(): six hand-placed points are passed through a Catmull-Rom curve, which makes them a smooth path;tube()then wraps a tube round it. Each ring of the tube is kept square to the path, and its orientation is carried from ring to ring (a parallel transport frame), so the tube never twists. Mochi’s tail is one; so are Onigiri’s closed eyes and both smiles, which are tiny curved tubes.rot_to()turns a flat shape so that it faces along a given direction, for laying an eye or a cheek on a curved body.
4. Stage 3 · Parts
- A
Partis one piece of a creature: its name; its material (a key of its colours); its shape; which bones it follows (one bone’s name, or a rule giving each vertex its bones and weights); which mesh it belongs to: body (body, ears, tail, feet) or face (eyes, cheeks, mouth: the mesh that carries the expressions); and its morphs, its shape in each expression. on_surface()finds the point on the front of Mochi’s ellipsoid above a given (x, y), and the surface’s normal there, so that each eye and cheek sits on the body and faces out.squash()scales a part about a point and lifts it: the single tool of every expression.
5. Stage 4 · The skeleton
skeleton()lists the bones as (name, parent, position). VRM 1.0’s humanoid requires hips, spine, head, both upper and lower arms, hands, upper and lower legs and feet; we add chest, neck and toes: 19 humanoid bones.- The tiny stub feet hang on the foot bones, so that any program that makes the avatar walk or run moves them.
- The arm bones sit inside the body and carry nothing. Mochi and Onigiri have no arms in their drawings, but VRM requires the bones, so they are there for the programs and hidden from sight.
- Bones of their own, outside the humanoid: Mochi’s tail has three bones and an end; each ear has a bone and an end. These are the spring bones’ chains (section 9.5).
- The rest pose is the bones’ translations alone, with no rotation, as VRM 1.0 asks.
6. Stage 5 · The skin
- Skinning ties each vertex of the surface to up to four bones, each with a weight; the weights sum to 1. When a bone moves, the vertex moves with it in proportion.
- The bodies are skinned by height
(
y_weights()): the bottom follows the hips, then the spine, the chest and the head, each band blended smoothly into the next by a smoothstep. So a round body bends softly when the avatar leans, rather than breaking at a seam. - The tail is skinned along its length, from half on the hips at its root to wholly on its last bone at its tip; the ears follow their own bones; the feet follow the foot bones; the face follows the head.
Colours: hips orange-red, spine amber, chest green, neck and head blue, the left foot violet, the right foot pink, the tail’s three bones cyan, aqua and lime, the left ear red and the right ear yellow. Where two colours blend, a point follows two bones.
- The skin at work: the same weights, with one leg raised and the head and spine tilted.
7. Stage 6 · Mochi and Onigiri, part by part
7.1 Mochi
- The body: one ellipsoid, skinned by height.
- The stub feet: two small ellipsoids, a little forward of the body, each wholly on its foot bone.
- The ears: two rounded cones turned on a lathe, leaning out by about 24°, each with a smaller pink cone set inside it.
- The tail: six points from the lower back, curling up; made smooth (8 steps between each two points), then a tube about 4 cm thick at its root, thinning to 2.8 cm at its tip.
- The eyes: flattened ellipsoids laid on the body by
on_surface(), each with a white highlight up and to one side. - The cheeks, the smile and the mouth: pink ellipses on the cheeks; the smile is a shallow U made of a tiny tube; the mouth behind it is an ellipsoid only 2 mm tall, hidden until an expression opens it.
7.2 Onigiri
- The body is a sphere reshaped by one function,
shape(), applied to every vertex: narrow at the top (52 % of the width) and wide at the bottom, a little wider still near the base, and deeper at the bottom than at the top, as a hand-pressed onigiri. Its normals are then worked out again from the new surface: each triangle adds its normal to its three corners.
- The nori is a clean strip made on the unit sphere (a band a little over a third of the width, swept under the bottom from the back to the front), given the same rice-ball shape, and lifted 6 mm off the body, so that it never sinks into it.
- The orange dot sits on the nori in front.
- The ears: white rounded cones, as Mochi’s but plainer.
- The stub feet, as Mochi’s.
- The face: closed, smiling eyes (curved tubes, ^ ^), pink cheeks, a small “w” mouth, and the hidden mouth behind it.
8. Stage 7 · The expressions
- Seven morph targets are made on the face by
targets_for_face(), each a set of moved positions: blinkL and blinkR (an eye squashed flat, its highlight shrunk away); mouthOpen; mouthWide; mouthRound; happyEyes (eyes closed into upward curves); wideEyes. A part not named in a target stays still. - The thirteen VRM preset expressions are mixtures of
these seven (
expressions()): blink, blinkLeft, blinkRight; the five mouth shapes of lip sync, aa, ih, ee, ou, oh; and happy, surprised, relaxed, sad, angry. happy blocks blinking while it shows. Avatar programs set these by name: when the wearer speaks, aa to oh follow the voice; when the wearer blinks, blink.
- Mochi’s happy face shows how a target is made: the eye is first squashed thin, then its middle is lifted, more at the centre than at the ends, into an arch:
hv = squash(eye.V, c, sy=.22, dy=.002 * s) # a thin eye…
rx_ = np.ptp(eye.V[:, 0]) / 2 or 1
hv[:, 1] += .014 * s * (1 - ((eye.V[:, 0] - c[0]) / rx_) ** 2) # …bent upwards in the middle: ^
eye.morphs[5] = hv- Onigiri’s eyes are always closed, so its blink lowers them a little, its happy face raises them, and its surprised face stretches them.
9. Stage 8 · Writing the file
9.1 The file’s layout
GLBgathers the file as it is built: its JSON, and one binary buffer. Each array (positions, normals, bones and weights, triangles, morph deltas, matrices, the thumbnail) is appended to the buffer through a bufferView (a range of bytes) and an accessor (how to read it: component type, element type, count, and for positions their bounds).GLB.write()writes the 12-byte header, the JSON chunk padded with spaces and the binary chunk padded with zeros, each to 4 bytes, with Python’s ownstructandjson:
out = (struct.pack("<III", 0x46546C67, 2, 12 + 8 + len(js) + 8 + len(b)) # "glTF", version 2, length
+ struct.pack("<II", len(js), 0x4E4F534A) + js # the JSON chunk
+ struct.pack("<II", len(b), 0x004E4942) + b) # the binary chunk9.2 Materials: the toon look
mtoon()makes each material with VRM’s toon shading,VRMC_materials_mtoon: the lit colour, a slightly darker shade colour with a hard edge between them (two tones, as in a drawing), no rim light, and an outline.add_materials()gives the body, the feet and the nori an outline 4.5 mm wide: the body’s and feet’s in the drawing’s line colour, the nori’s a darker green. The eyes, cheeks and mouth have none.
9.3 Nodes, skeleton and skin
add_skeleton()writes a root node named after the creature, one node per bone with its translation from its parent, and the skin: every bone as a joint, with its inverse bind matrix. Since no bone is rotated at rest, that matrix is simply a move by minus the bone’s position.add_meshes()writes two skinned meshes, Body and Face, each with one primitive per material. Every vertex gets its four bones and weights (JOINTS_0,WEIGHTS_0). The Face mesh also gets the seven morph targets as position deltas. The mesh nodes stand at the scene’s root, as glTF asks for skinned meshes.
9.4 The VRM extension
vrm_meta(): the name, the authors, © Computational Classnotes · CC BY-NC-SA 4.0, and the licence: the VRM Public License 1.0 with CC BY-NC-SA 4.0. Anyone may use the avatars, personally and non-commercially, with credit; redistribution and changes are allowed under the same terms; no violent, sexual, political, religious, antisocial or hateful use. The 1024-pixel thumbnail is embedded beside it.- The humanoid names the 19 bones; first person hides the face from the wearer’s own camera; look-at starts from between the eyes; the expressions are those of section 8.
"humanoid": {"humanBones": {"hips": {"node": 1}, "spine": {"node": 2}, "chest": {"node": 3}, "neck": {"node": 4},
"head": {"node": 5}, "leftUpperLeg": {"node": 6}, "leftFoot": {"node": 8}, …}}9.5 Spring bones
springs()writesVRMC_springBone: one chain for the tail and one for each ear. The avatar program swings each chain behind the body as it moves, as a spring would. The tail is soft (stiffness 0.9) and droops a little with gravity; the ears are stiffer (1.6) and only wobble.- The pictures show Mochi from behind, at rest, then twice during a quick quarter turn: the tail swings out and the ears catch up late.
9.6 The thumbnails
- Each file carries a 1024 × 1024 picture of itself,
which avatar programs show in their lists.
tools/vrm-figures.pydraws it with the real VRM loader;make-vrm.py --thumbsputs it in the file.
10. Stage 9 · Checking
- The Khronos glTF validator (the format’s own checker, run with Node.js): 0 errors and 0 warnings for both files. Its first report found three things, all mended: the meshes’ nodes were inside the root rather than at the scene’s root; some vertices named a bone with a weight of 0; and Onigiri’s two poles had normals of length 0.
- pixiv’s three-vrm 3.6, the reference VRM loader for the web, in a headless Chrome: both files load; it reads the meta and licence, the 19 humanoid bones, the 13 expressions, the spring joints and the MToon materials. Every picture in this paper is its drawing of the files.
- Mistakes seen in the pictures and mended: the first tubes faced inwards, so the smiles and Onigiri’s eyes showed only their round ends (the triangles’ order was reversed); the rim light washed the bodies out (turned off); Onigiri’s first nori, cut from the body’s own triangles, had a ragged edge (replaced by the clean strip of section 7.2); the tail was faceted (smoothed through a Catmull-Rom curve); Mochi’s happy eyes were only flattened (bent into an arch).
- In a game: the owner ran both as the runner of Clown Run (CCN Casual Games), through the Humanoid Laboratory’s Use in the games, on 3 December 2026: “both worked great”, with one very minor issue to be reported.
11. Using them, and changing them
- To use them: load either file as an avatar in a
VTubing program that reads VRM 1.0 (such as VSeeFace, Warudo or VNyan),
import it into Unity with UniVRM or into Blender with its VRM add-on, or
show it on the web with three.js and
@pixiv/three-vrm. - To change them: change
tools/make-vrm.py(a colour, a radius, a curve, an expression), never the files, then run:
python3 tools/vrm-figures.py --work /tmp/vrm-figures # the pictures and the thumbnails
python3 tools/make-vrm.py --thumbs /tmp/vrm-figures/thumbs # the two avatars- The manual has a page for every function of both
tools: section 3vrm
(
make-vrm.py) and section 3vrmfig (vrm-figures.py).
© Computational Classnotes · CC BY-NC-SA 4.0