In Swift, performance is the state passed to ClayfacesView. On
the web, avatar is the result of await createClayfaces(host).
See the Swift playback example or
web playback example for a complete picker.
Share one character
Save the look as JSON. An iOS app can export a character that a website can reopen with
the same kit version. Store the selected performance ID separately if you want to replay a
particular expression.
This chooses the yellow complexion and the “Few” freckle pattern. skin is a
zero-based palette index. shade ranges from −1 to 1, with 0 at the midpoint.
Under values, use the exact field ID and its numeric value. Omitting an
override uses that field’s initial value.
To check a round trip, save a look in the bundled web example, decode the JSON with
AvatarRecipe.decode(data) in Swift, and pass the result to
ClayfacesView. For the return trip, use try look.encoded(),
parse the JSON on the web, then call await avatar.setAppearance(recipe).
Appearance controls
Look up the exact recipe key, default and accepted values for each of the 95 controls.
Search by field name, section or option name. Use these same IDs on iOS and web.
95 fields
Skin details/FrecklesSkin · Menu
Default 2 · None.
Accepted option values
None2
Few3
Some4
Many5
Skin details/CheeksSkin · Menu
Default 2 · None.
Accepted option values
None2
Flushed3
Apples4
Cheekbones5
Angled6
Skin details/Cheek colorSkin · Menu
Default 2 · Blush Pink.
Accepted option values
Blush Pink2
Blush Red3
Blush Purple4
Blush Orange5
Blush Mauve6
Blush Brown7
Red8
Orange9
Yellow10
Green11
Blue12
Purple13
Pink14
White15
Black16
Skin details/Cheek shadeSkin · Float
Default 0.
Accepts any finite number from −1 to 1.
Skin details/Beauty spotsSkin · Menu
Default 2 · None.
Accepted option values
None2
Upper left lip3
Upper right lip4
Lower left lip5
Lower right lip6
Upper left cheek7
Upper right cheek8
Hairstyle/StyleHairstyle · Menu
Default 144 · No hair.
Accepted option values
Long dreadlocks with side part2
Long microbraid half up with center part3
Long and straight half up puff4
Long tight curls with side part5
Long straight with side part6
Long dreadlocks extending back7
Long and curly with center part8
Long and wavy with fringe9
Long and curly with center part and fringe10
Long and straight with fringe11
Long microbraid tucked behind ear with side part12
Long and wavy smooth with center part13
Long and curly with side part14
Long loose curls with center part15
Long loose curls with side part16
Long microbraid with center part17
Long microbraid with side part18
Long and wavy with center part19
Long and wavy with side part20
Long and straight with center part21
Long and straight with side swept side part22
High ponytail curly and long23
Long and curly in high ponytail with fringe24
Long loose curls in ponytail with fringe25
High and long messy ponytail26
Long straight ponytail back of head27
Long and straight medium high ponytail with fringe28
Long Goddess braids29
Long boxer braids30
Long box braids31
Long and wavy braided ponytail32
Long double braids starting behind ears33
Long corn rows extending back34
Long and straight beehive35
Medium and straight victory rolls36
Medium and wavy with fringe37
Medium loose curls with center part38
Medium loose curls with side part39
Medium and wavy with side part40
Medium and wavy with center part · down41
Medium and wavy with center part · mid height42
Medium length tight curls with blowout and side part43
Medium and curly with side part44
Medium and curly with center part and fringe45
Medium and curly with center part46
Medium and straight with center part47
Medium and straight side swept with side part48
Medium straight with side part mid height49
Medium and straight with fringe50
Medium micro braid extending back with strand on forehead51
Medium micro braid with center part52
Medium micro braid with side part53
Medium dreadlocks extending back54
Medium dreadlocks with side part55
Short wavy bob with side part56
Medium and wavy flapper57
Medium and straight mid half fade58
Medium and straight up half fade59
Short loose curls in bob60
Short loose curls with half shave61
Medium tight curls spiky62
Short tight curls with half swoop63
Short microbraid with half swoop64
Medium and straight flared bob65
Medium short straight and spiky66
Medium corn rows extending back67
Medium and curly with side locks68
Short and curly with side locks69
Medium and curly slicked back70
Medium short combed back71
Medium short tight curls with blowout and side part72
Short tight curls with blowout and side part73
Medium layered microbraid with side part74
Short layered microbraid with side part75
Medium pigtail buns just below ears76
Long tight curls in high puff77
Long and curly in updo with fringe78
Long dreadlocks updo79
Long and straight top knot80
Long tight curls in top knot81
Long tight curls in up bun82
Long and curly mid up bun83
Long and curly in up bun84
Long and straight up bun85
Long and straight bun up high with fringe86
Long braided up do87
Long braided updo with fringe88
Long and wavy updo89
Long and wavy up do with fringe90
Long braided mid bun91
Long Micro braid mid updo92
Long corn rows in up bun93
Long and curly double bun up94
Long tight curls in up double bun95
Long microbraid double bun up high96
Medium and wavy double bun up high97
Long and straight double bun up high98
Short and straight high pigtails with fringe99
Long tight curls up ball100
Medium tight curls up ball101
Short tight curls up ball102
Short and straight shag103
Short and wavy with side part swept to side104
Short and straight pageboy cut105
Short and straight with fringe106
Short and straight with fringe swept down in front107
Short and wavy tousled top108
Short and straight combed back with side part109
Medium and straight bun with fade110
Short and wavy with side part mid height111
Short and straight with side part112
Short and straight with center part113
Short and straight with mid height center part114
Short and straight combed back115
Short and straight up do with side part116
Short and straight tousled117
Short and straight spiky118
Short and straight fauxhawk119
Short and straight with spiked top120
Medium and curly up121
Short and curly up122
Short tight curls spiked up123
Medium and curly up fade124
Short and curly up fade125
Short and curly top with fade126
Medium tight curls low top fade127
Short tight curls with low top fade128
Straight Short Up Crew Cut129
Short tight curls in up knots130
Short corn rows extending back and to right131
Short corn rows extending back132
Medium and straight mohawk133
Short tight curls in waves134
Short Shaped135
Short Natural136
Short with widows peak137
Bald top with very close-cut sides extending near top of head138
Balding top with short sides139
Buzzed Shaped140
Buzzed141
Buzzed with widows peak142
Bald top with buzzed sides143
No hair144
Hairstyle/Color modeHairstyle · Menu
Default 2 · One Color.
Accepted option values
One Color2
Multiple Colors3
Hairstyle/Base colorHairstyle · Menu
Default 4 · Soft Black.
Accepted option values
Gray2
Black3
Soft Black4
Maple5
Auburn6
Golden Brown7
Flaxen8
Golden Blond9
Red10
Orange11
Yellow12
Green13
Blue14
Purple15
Pink16
Hairstyle/Base shadeHairstyle · Float
Default 0.
Accepts any finite number from −1 to 1.
Hairstyle/Highlight styleHairstyle · Menu
Default 2 · Modern.
Accepted option values
Modern2
Gradient3
Classic4
Hairstyle/Highlight colorHairstyle · Menu
Default 4 · Soft Black.
Accepted option values
Gray2
Black3
Soft Black4
Maple5
Auburn6
Golden Brown7
Flaxen8
Golden Blond9
Red10
Orange11
Yellow12
Green13
Blue14
Purple15
Pink16
Hairstyle/Highlight shadeHairstyle · Float
Default 0.
Accepts any finite number from −1 to 1.
Eyebrows/ShapeBrows · Menu
Default 2 · Even Rounded Thin.
Accepted option values
Even Rounded Thin2
Even Rounded Medium3
Even Rounded Thick4
Even Angled Thin5
Even Angled Medium6
Even Angled Thick7
Willow Leaf Rounded Thin8
Willow Leaf Rounded Medium9
Willow Leaf Rounded Thick10
Willow Leaf Angled Thin11
Willow Leaf Angled Medium12
Willow Leaf Angled Thick13
Double Curve Rounded Thin14
Double Curve Rounded Medium15
Double Curve Rounded Thick16
Double Curve Angled Thin17
Double Curve Angled Medium18
Double Curve Angled Thick19
Tadpole Rounded Thin20
Tadpole Rounded Medium21
Tadpole Rounded Thick22
Tadpole Angled Thin23
Tadpole Angled Medium24
Tadpole Angled Thick25
None26
Eyebrows/ColorBrows · Menu
Default 4 · Soft Black.
Accepted option values
Gray2
Black3
Soft Black4
Maple5
Auburn6
Golden Brown7
Flaxen8
Golden Blond9
Red10
Orange11
Yellow12
Green13
Blue14
Purple15
Pink16
Eyebrows/ShadeBrows · Float
Default 0.
Accepts any finite number from −1 to 1.
Forehead marks/StyleBrows · Menu
Default 2 · None.
Accepted option values
None2
Small circle3
Large circle4
Forehead marks/ColorBrows · Menu
Default 2 · White.
Accepted option values
White2
Black3
Red4
Orange5
Yellow6
Green7
Blue8
Purple9
Pink10
Forehead marks/ShadeBrows · Float
Default 0.
Accepts any finite number from −1 to 1.
Brow piercings/StyleBrows · Menu
Default 2 · No piercings.
Accepted option values
No piercings2
Left eyebrow pierced with barbell3
Right eyebrow pierced with barbell4
Each eyebrow pierced with barbell5
Left eyebrow pierced with ring6
Right eyebrow pierced with ring7
Each eyebrow pierced with ring8
Bridge of nose pierced with barbell9
Brow piercings/FinishBrows · Menu
Default 2 · Silver.
Accepted option values
Silver2
Gold3
Rose Gold4
Metallic Bright Red5
Metallic Bright Orange6
Metallic Bright Yellow7
Metallic Bright Green8
Metallic Bright Blue9
Metallic Bright Violet10
Metallic Bright Pink11
Brow piercings/ShadeBrows · Float
Default 0.
Accepts any finite number from −1 to 1.
Eyes/ShapeEyes · Menu
Default 2 · Large Straight.
Accepted option values
Large Straight2
Medium Straight3
Small Straight4
Large Straight with tapered eyelid5
Medium Straight with tapered eyelid6
Small Straight with tapered eyelid7
Large Upturned8
Medium Upturned9
Small Upturned10
Large Upturned with tapered eyelid11
Medium Upturned with tapered eyelid12
Small Upturned with tapered eyelid13
Large Downturned14
Medium Downturned15
Small Downturned16
Large Downturned with tapered eyelid17
Medium Downturned with tapered eyelid18
Small Downturned with tapered eyelid19
Eyes/Color modeEyes · Menu
Default 2 · One Color.
Accepted option values
One Color2
Two Colors3
Eyes/Primary irisEyes · Menu
Default 3 · Brown.
Accepted option values
Black2
Brown3
Green4
Blue5
Unpigmented6
Hazel7
Artificial Red8
Artificial Orange9
Artificial Yellow10
Artificial Green11
Artificial Blue12
Artificial Purple13
Artificial Pink14
Gray15
Eyes/Primary shadeEyes · Float
Default 0.
Accepts any finite number from −1 to 1.
Eyes/Secondary irisEyes · Menu
Default 3 · Brown.
Accepted option values
Black2
Brown3
Green4
Blue5
Unpigmented6
Hazel7
Artificial Red8
Artificial Orange9
Artificial Yellow10
Artificial Green11
Artificial Blue12
Artificial Purple13
Artificial Pink14
Gray15
Eyes/Secondary shadeEyes · Float
Default 0.
Accepts any finite number from −1 to 1.
Eyelashes/StyleEyes · Menu
Default 2 · Natural Thin.
Accepted option values
Natural Thin2
Natural Medium3
Natural Thick4
Cat eye5
Puppy eye6
Smoke and bottom lined7
Curly8
Curly and bottom lined9
Curly thick10
Short and spread out extending along lash line11
Long and spread out extending along lash line12
Short and full extending along lash line13
Long and full extending along full lash line14
None15
Eye makeup/Eyeliner styleEyes · Menu
Default 9 · No eyeliner.
Accepted option values
Thick liner on top only2
Thick top and liner on outer lower lash line3
Thick top and liner on full lower lash line4
Feline flick top only5
Feline flick top and outer lash line6
Feline flick top and lower lash line7
Feline flick top and thick lower lash line8
No eyeliner9
Eye makeup/Eyeliner colorEyes · Menu
Default 2 · Eyeliner Black.
Accepted option values
Eyeliner Black2
Eyeliner Blue3
Eyeliner Green4
Eyeliner Brown5
Eyeliner Purple6
Eyeliner Red7
Red8
Orange9
Yellow10
Green11
Blue12
Purple13
Pink14
White15
Black16
Eye makeup/Eyeliner shadeEyes · Float
Default -1.
Accepts any finite number from −1 to 1.
Eye makeup/Eyeshadow styleEyes · Menu
Default 2 · No eyeshadow.
Accepted option values
No eyeshadow2
Rounded shape top only3
Rounded shape top and shadow along lash line4
Cat eye top only5
Cat eye top and shadow along lash line6
Eye makeup/Eyeshadow colorEyes · Menu
Default 2 · Eyeshadow Stone.
Accepted option values
Eyeshadow Stone2
Eyeshadow Color13
Eyeshadow Color24
Eyeshadow Color35
Eyeshadow Color46
Eyeshadow Color57
Red8
Orange9
Yellow10
Green11
Blue12
Purple13
Pink14
White15
Black16
Eye makeup/Eyeshadow shadeEyes · Float
Default 0.
Accepts any finite number from −1 to 1.
Head shape/FamilyHead · Menu
Default 2 · Round.
Accepted option values
Round2
Triangle3
Full4
Square5
Trapezoid6
Head shape/SizeHead · Menu
Default 3 · Medium.
Accepted option values
Small2
Medium3
Large4
Head shape/AgeHead · Menu
Default 6 · Younger Adult.
Accepted option values
Younger Child2
Young Child3
Child4
Older Child5
Younger Adult6
Adult7
Young Older Adult8
Older Adult9
Old Older Adult10
Nose/ShapeNose · Menu
Default 3 · Medium Button.
Accepted option values
Small Button2
Medium Button3
Large Button4
Small Triangle5
Medium Triangle6
Large Triangle7
Small Snub8
Medium Snub9
Large Snub10
Small Upturned11
Medium Upturned12
Large Upturned13
Nose piercings/StyleNose · Menu
Default 2 · No piercings.
Accepted option values
No piercings2
Stud left nostril3
Stud right nostril4
Studs left and right nostril5
Ring left nostril6
Ring right nostril7
Rings left and right nostril8
Ring through base of nose9
Nose piercings/FinishNose · Menu
Default 2 · Silver.
Accepted option values
Silver2
Gold3
Rose Gold4
Metallic Bright Red5
Metallic Bright Orange6
Metallic Bright Yellow7
Metallic Bright Green8
Metallic Bright Blue9
Metallic Bright Violet10
Metallic Bright Pink11
Nose piercings/ShadeNose · Float
Default 0.
Accepts any finite number from −1 to 1.
Oxygen tube/StyleNose · Menu
Default 2 · No oxygen tube.
Accepted option values
No oxygen tube2
Oxygen tube3
Mouth/ShapeMouth · Menu
Default 3 · Medium Oval.
Accepted option values
Thin Oval2
Medium Oval3
Full Oval4
Thin Oval with rounded peaks5
Medium Oval with rounded peaks6
Full Oval with rounded peaks7
Thin Oval with angular peaks8
Medium Oval with angular peaks9
Full Oval with angular peaks10
Mouth/ColorMouth · Menu
Default 2 · Natural.
Accepted option values
Natural2
Lipstick Pink3
Lipstick Red4
Lipstick Purple5
Lipstick Orange6
Lipstick Mauve7
Lipstick Black8
Red9
Orange10
Yellow11
Green12
Blue13
Purple14
Pink15
White16
Black17
Mouth/ShadeMouth · Float
Default 0.
Accepts any finite number from −1 to 1.
Teeth/StyleMouth · Menu
Default 2 · Standard.
Accepted option values
Standard2
Braces3
Fangs4
Missing upper-left tooth5
Upper center gap6
Gold upper-left tooth7
Mouth piercings/StyleMouth · Menu
Default 2 · No piercings.
Accepted option values
No piercings2
Upper lip left side3
Upper lip right side4
Upper lip each side5
Lower lip ring left side6
Lower lip ring right side7
Lower lip ring each side8
Under lip left side9
Under lip right side10
Under lip each side11
Upper lip center12
Lower lip center13
Mouth piercings/FinishMouth · Menu
Default 2 · Silver.
Accepted option values
Silver2
Gold3
Rose Gold4
Metallic Bright Red5
Metallic Bright Orange6
Metallic Bright Yellow7
Metallic Bright Green8
Metallic Bright Blue9
Metallic Bright Violet10
Metallic Bright Pink11
Mouth piercings/ShadeMouth · Float
Default 0.
Accepts any finite number from −1 to 1.
Tongue piercings/StyleMouth · Menu
Default 2 · No piercings.
Accepted option values
No piercings2
Single bead piercing at center3
Tongue piercings/FinishMouth · Menu
Default 2 · Silver.
Accepted option values
Silver2
Gold3
Rose Gold4
Metallic Bright Red5
Metallic Bright Orange6
Metallic Bright Yellow7
Metallic Bright Green8
Metallic Bright Blue9
Metallic Bright Violet10
Metallic Bright Pink11
Tongue piercings/ShadeMouth · Float
Default 0.
Accepts any finite number from −1 to 1.
Ears/ShapeEars · Menu
Default 3 · Medium.
Accepted option values
Small2
Medium3
Large4
Earrings/Match earsEars · Bool
Default 1.
Use 0 for off and 1 for on.
Earrings/Left styleEars · Menu
Default 2 · None.
Accepted option values
None2
Round Stud3
Minimalist line4
Stud on cartilage flap at front of ear5
Triangle stud6
Heart stud7
Small Hoop8
Spiral through ear9
Multiple Piercings Lower Lobe10
Captive Bead11
Industrial Barbells12
Multiple Hoops Top of Lobe13
Ear cuff14
Ear cuff with chain15
Round shape beaded with white center16
Habesha17
Pearl drop earring18
Jhumka19
Fulani20
Arracada21
Teardrop22
Hamsa or handshaped earring23
Drop bead on chain24
Rectangle drop earring25
Large Hoop26
Torpedo drop earring27
Chandbali28
Triangle pendant29
Earrings/Left finishEars · Menu
Default 2 · Silver.
Accepted option values
Silver2
Gold3
Rose Gold4
Metallic Bright Red5
Metallic Bright Orange6
Metallic Bright Yellow7
Metallic Bright Green8
Metallic Bright Blue9
Metallic Bright Violet10
Metallic Bright Pink11
Earrings/Left shadeEars · Float
Default 0.
Accepts any finite number from −1 to 1.
Earrings/Right styleEars · Menu
Default 2 · None.
Accepted option values
None2
Round Stud3
Minimalist line4
Stud on cartilage flap at front of ear5
Triangle stud6
Heart stud7
Small Hoop8
Spiral through ear9
Multiple Piercings Lower Lobe10
Captive Bead11
Industrial Barbells12
Multiple Hoops Top of Lobe13
Ear cuff14
Ear cuff with chain15
Round shape beaded with white center16
Habesha17
Pearl drop earring18
Jhumka19
Fulani20
Arracada21
Teardrop22
Hamsa or handshaped earring23
Drop bead on chain24
Rectangle drop earring25
Large Hoop26
Torpedo drop earring27
Chandbali28
Triangle pendant29
Earrings/Right finishEars · Menu
Default 2 · Silver.
Accepted option values
Silver2
Gold3
Rose Gold4
Metallic Bright Red5
Metallic Bright Orange6
Metallic Bright Yellow7
Metallic Bright Green8
Metallic Bright Blue9
Metallic Bright Violet10
Metallic Bright Pink11
Earrings/Right shadeEars · Float
Default 0.
Accepts any finite number from −1 to 1.
Audio accessories/Match earsEars · Bool
Default 1.
Use 0 for off and 1 for on.
Audio accessories/Left styleEars · Menu
Default 2 · No audio accessory.
Accepted option values
No audio accessory2
AirPod3
Hearing aid4
Cochlear implant5
Audio accessories/Left colorEars · Menu
Default 2 · White.
Accepted option values
White2
Black3
Beige4
Brown5
Bright Red6
Bright Orange7
Bright Yellow8
Bright Green9
Bright Blue10
Bright Violet11
Bright Pink12
Audio accessories/Left shadeEars · Float
Default 0.
Accepts any finite number from −1 to 1.
Audio accessories/Right styleEars · Menu
Default 2 · No audio accessory.
Accepted option values
No audio accessory2
AirPod3
Hearing aid4
Cochlear implant5
Audio accessories/Right colorEars · Menu
Default 2 · White.
Accepted option values
White2
Black3
Beige4
Brown5
Bright Red6
Bright Orange7
Bright Yellow8
Bright Green9
Bright Blue10
Bright Violet11
Bright Pink12
Audio accessories/Right shadeEars · Float
Default 0.
Accepts any finite number from −1 to 1.
Facial hair/SideburnsFacial Hair · Menu
Default 2 · None.
Accepted option values
None2
Short3
Long4
Facial hair/StyleFacial Hair · Menu
Default 2 · No mustache no beard.
Accepted option values
No mustache no beard2
Shadow mustache and beard3
Soul Patch No mustache4
Soul Patch No mustache and Shadow5
Anchor beard No mustache6
Anchor beard No mustache and Shadow7
Goatee No mustache8
Goatee No mustache and Shadow9
Brett beard No mustache10
Brett beard No mustache and Shadow11
Mutton Chops No mustache12
Mutton Chops No mustache and Shadow13
Short beard No mustache14
Short beard No mustache and Shadow15
Ducktail beard No mustache16
Ducktail beard No mustache and Shadow17
Full beard No mustache18
Full beard No mustache and Shadow19
Broad beard No mustache20
Broad beard No mustache and Shadow21
Horseshoe mustache no beard22
Horseshoe mustache Shadow beard23
Horseshoe mustache with Soul Patch24
Horseshoe mustache with Soul Patch and Shadow25
Horseshoe mustache Anchor beard26
Horseshoe mustache Anchor beard and Shadow27
Horseshoe mustache with Goatee28
Horseshoe mustache with Goatee and Shadow29
Horseshoe mustache Brett beard30
Horseshoe mustache Brett beard and Shadow31
Horseshoe Mutton Chops32
Horseshoe Mutton Chops and Shadow33
Horseshoe mustache Short beard34
Horseshoe mustache Ducktail beard35
Horseshoe mustache Full beard36
Horseshoe mustache Broad beard37
Chevron mustache no beard38
Chevron mustache Shadow beard39
Chevron mustache Soul Patch40
Chevron mustache Soul Patch and Shadow41
Chevron mustache Anchor beard42
Chevron mustache Anchor beard and Shadow43
Chevron mustache Goatee44
Chevron mustache Goatee and Shadow45
Chevron mustache Brett beard46
Chevron mustache Brett beard and Shadow47
Chevron mustache Mutton Chops48
Chevron mustache Mutton Chops and Shadow49
Chevron mustache Short beard50
Chevron mustache Ducktail beard51
Chevron mustache Full beard52
Chevron mustache Broad beard53
Walrus mustache no beard54
Walrus mustache Shadow beard55
Walrus mustache with Soul Patch56
Walrus mustache with Soul Patch and Shadow57
Walrus mustache Anchor beard58
Walrus mustache Anchor beard and Shadow59
Walrus mustache with Goatee60
Walrus mustache with Goatee and Shadow61
Walrus mustache Brett beard62
Walrus mustache Brett beard and Shadow63
Walrus mustache with Mutton Chops64
Walrus mustache with Mutton Chops and Shadow65
Walrus mustache short beard66
Walrus mustache Ducktail beard67
Walrus mustache Full beard68
Walrus mustache Broad beard69
Pencil mustache no beard70
Pencil mustache Shadow beard71
Pencil mustache with Soul Patch72
Pencil mustache with Soul Patch and Shadow73
Pencil mustache Anchor beard74
Pencil mustache Anchor beard and Shadow75
Pencil mustache with Goatee76
Pencil mustache with Goatee and Shadow77
Pencil mustache Brett beard78
Pencil mustache Brett beard and Shadow79
Pencil mustache with Mutton Chops80
Pencil mustache with Mutton Chops and Shadow81
Pencil mustache Short beard82
Pencil mustache Ducktail beard83
Pencil mustache Full beard84
Pencil mustache Broad beard85
English mustache no beard86
English mustache Shadow beard87
English mustache with Soul Patch88
English mustache with Soul Patch and Shadow89
English mustache Anchor beard90
English mustache Anchor beard and Shadow91
English mustache with Goatee92
English mustache with Goatee and Shadow93
English mustache Brett beard94
English mustache Brett beard and Shadow95
English mustache with Mutton Chops96
English mustache with Mutton Chops and Shadow97
English mustache Short beard98
English mustache Ducktail beard99
English mustache Full beard100
English mustache Broad beard101
Handlebar no beard102
Handlebar mustache Shadow beard103
Handlebar mustache with Soul Patch104
Handlebar mustache with Soul Patch and Shadow105
Handlebar mustache Anchor beard106
Handlebar mustache Anchor beard and Shadow107
Handlebar mustache with Goatee108
Handlebar mustache with Goatee and Shadow109
Handlebar mustache Brett beard110
Handlebar mustache Brett beard and Shadow111
Handlebar mustache with Mutton Chops112
Handlebar mustache with Mutton Chops and Shadow113
Handlebar mustache Short beard114
Handlebar mustache Ducktail beard115
Handlebar mustache Full beard116
Handlebar mustache Broad beard117
Wild West mustache no beard118
Wild West mustache Shadow beard119
Wild West mustache with Soul Patch120
Wild West mustache with Soul Patch and Shadow121
Wild West mustache Anchor beard122
Wild West mustache Anchor beard and Shadow123
Wild West mustache with Goatee124
Wild West mustache with Goatee and Shadow125
Wild West mustache Brett beard126
Wild West mustache Brett beard and Shadow127
Wild West mustache Mutton Chops beard128
Wild West mustache Mutton Chops beard and Shadow129
Wild West mustache Short beard130
Wild West mustache Ducktail beard131
Wild West mustache Full beard132
Wild West mustache Broad beard133
Facial hair/Color modeFacial Hair · Menu
Default 2 · One Color.
Accepted option values
One Color2
Multiple Colors3
Facial hair/Base colorFacial Hair · Menu
Default 4 · Soft Black.
Accepted option values
Gray2
Black3
Soft Black4
Maple5
Auburn6
Golden Brown7
Flaxen8
Golden Blond9
Red10
Orange11
Yellow12
Green13
Blue14
Purple15
Pink16
Facial hair/Base shadeFacial Hair · Float
Default 0.
Accepts any finite number from −1 to 1.
Facial hair/Highlight styleFacial Hair · Menu
Default 2 · Gradient.
Accepted option values
Gradient2
Classic3
Facial hair/Highlight colorFacial Hair · Menu
Default 4 · Soft Black.
Accepted option values
Gray2
Black3
Soft Black4
Maple5
Auburn6
Golden Brown7
Flaxen8
Golden Blond9
Red10
Orange11
Yellow12
Green13
Blue14
Purple15
Pink16
Facial hair/Highlight shadeFacial Hair · Float
Default 0.
Accepts any finite number from −1 to 1.
Eyewear/StyleEyewear · Menu
Default 47 · None.
Accepted option values
Emoji style with rounded top2
Emoji style wire frame3
Emoji style rimless4
Rectangle5
Rectangle wire frame6
Rectangle rimless7
Round8
Round wire frame9
Round rimless10
Aviator11
Aviator wire frame12
Aviator rimless13
Sport14
Sport wire frame15
Sport rimless16
Square17
Square wire frame18
Square rimless19
Semi Rimless20
Semi rimless wire frame21
Semi Rimless style no rims22
Shield23
Shield wire frame24
Shield rimless25
Cat Eye26
Cat eye wire frame27
Cat eye rimless28
Oval29
Oval wire frame30
Oval rimless31
Horizontal Oval32
Horizontal Oval wire frame33
Horizontal Oval rimless34
Star35
Star wire frame36
Star rimless37
Heart38
Heart wire frame39
Heart rimless40
Small Oval41
Small Oval wire frame42
Small Oval rimless43
Monocle44
Monocle wire frame45
Monocle rimless46
None47
Eyewear/Color modeEyewear · Menu
Default 2 · Frame Color.
Accepted option values
Frame Color2
Frame and Lens Color3
Eyewear/Frame colorEyewear · Menu
Default 3 · Black.
Accepted option values
White2
Black3
Beige4
Brown5
Red6
Orange7
Yellow8
Green9
Blue10
Purple11
Pink12
Silver13
Gold14
Rose Gold15
Clear16
Eyewear/Frame shadeEyewear · Float
Default 0.
Accepts any finite number from −1 to 1.
Eyewear/Lens colorEyewear · Menu
Default 2 · Clear.
Accepted option values
Clear2
Dark3
Beige4
Brown5
Red6
Orange7
Yellow8
Green9
Blue10
Purple11
Pink12
Eyewear/Lens shadeEyewear · Float
Default 0.
Accepts any finite number from −1 to 1.
Eyewear/PatchEyewear · Menu
Default 2 · No eyepatch.
Accepted option values
No eyepatch2
Left eyepatch3
Right eyepatch4
Eyewear/Patch colorEyewear · Menu
Default 2 · White.
Accepted option values
White2
Black3
Beige4
Brown5
Olive6
Denim7
Red8
Orange9
Yellow10
Green11
Blue12
Purple13
Pink14
Eyewear/Patch shadeEyewear · Float
Default 0.
Accepts any finite number from −1 to 1.
Headwear/StyleHeadwear · Menu
Default 2 · None.
Accepted option values
None2
Beanie3
Service Cap4
Knotted Headscarf5
Durag6
Bonnet7
Backwards billed cap8
Swim Cap with Goggles on Forehead9
Bandana10
Billed Cap11
Skullcap12
Gandhi Cap13
Kufi14
Flatcap15
Military Cap16
Fur hat sides and front folded up17
Headscarf tied at the neck18
Tichel headscarf knotted in the back19
Volumized Tichel20
Transportation Attendant Cap21
Dixie Cup22
Pakol23
Turban24
Peaked turban wrap25
Tall Turban Wrap26
Headscarf27
Khimar veil covering neck and chest28
Keffieh29
Beanie with pompom30
Field Service Cap31
Cycling Helmet32
Beanie with ears33
Hard Hat34
Surgical Cap35
Military Beret36
Beret37
Mortar Board with Tassel38
Baker39
Rasta40
Chef Hat41
Nurse Cap42
Sailor Hat43
Officer Cap44
Soft helmet45
Bucket Hat46
Firefighter Helmet47
Straw hat48
Fedora49
Campaign Hat50
Cowboy Hat51
Porkpie Boater52
Porkpie53
Top Hat54
Wide brimmed sun hat55
Slouch hat56
Sombrero57
Mage hat58
Jester59
Santa60
Crown61
Headwear/Color modeHeadwear · Menu
Default 2 · One Color.
Accepted option values
One Color2
Multiple Colors3
Headwear/Main colorHeadwear · Menu
Default 2 · White.
Accepted option values
White2
Black3
Beige4
Brown5
Olive6
Denim7
Red8
Orange9
Yellow10
Green11
Blue12
Purple13
Pink14
Headwear/Main shadeHeadwear · Float
Default 0.
Accepts any finite number from −1 to 1.
Headwear/Second colorHeadwear · Menu
Default 3 · Black.
Accepted option values
White2
Black3
Beige4
Brown5
Olive6
Denim7
Red8
Orange9
Yellow10
Green11
Blue12
Purple13
Pink14
Headwear/Second shadeHeadwear · Float
Default -0.5.
Accepts any finite number from −1 to 1.
Headwear/Third colorHeadwear · Menu
Default 3 · Black.
Accepted option values
White2
Black3
Beige4
Brown5
Olive6
Denim7
Red8
Orange9
Yellow10
Green11
Blue12
Purple13
Pink14
Headwear/Third shadeHeadwear · Float
Default 0.5.
Accepts any finite number from −1 to 1.
Headwear/FacewearHeadwear · Menu
Default 2 · None.
Accepted option values
None2
Face Covering with pleats3
Face Covering with center seam4
Headwear/Facewear colorHeadwear · Menu
Default 2 · White.
Accepted option values
White2
Black3
Scrubs Green4
Scrubs Blue5
Scrubs Pink6
Beige7
Brown8
Olive9
Denim10
Red11
Orange12
Yellow13
Green14
Blue15
Purple16
Pink17
Headwear/Facewear shadeHeadwear · Float
Default 0.
Accepts any finite number from −1 to 1.
No matching fields. Try another search or category.
The kit includes machine-readable copies in Catalog/ClayfacesControls.json,
Catalog/ClayfacesPalette.json and Catalog/Actions.json.
Skin palette
Set skin at the top level of the recipe. These swatches show the midpoint of
each tone’s 33 shade samples. The default is 12, Yellow.
Extended 30
Fitzpatrick 51
Extended 22
Fitzpatrick 4.53
Fitzpatrick 44
Fitzpatrick 35
Fitzpatrick 26
Fitzpatrick 17
Extended 18
Gray9
Red10
Orange11
Yellow12
Green13
Blue14
Purple15
Pink16
Facial channels
The web kit exposes 52 named facial controls through avatar.channels. Each
weight ranges from 0 to 1. Pass the exact channel names to
setExpression() and call setExpression(null) to release the
pose. The SwiftUI player exposes named performances. The
web expression example shows a manual pose.
All 52 channel names
Blink left
Blink right
Inner brows up
Jaw open
Left brow down
Left brow up
Pucker
Right brow down
Right brow up
Smile left
Smile right
Tongue out
cheekPuff
cheekSquintLeft
cheekSquintRight
eyeLookDownLeft
eyeLookDownRight
eyeLookInLeft
eyeLookInRight
eyeLookOutLeft
eyeLookOutRight
eyeLookUpLeft
eyeLookUpRight
eyeSquintLeft
eyeSquintRight
eyeWideLeft
eyeWideRight
jawForward
jawLeft
jawRight
mouthClose
mouthDimpleLeft
mouthDimpleRight
mouthFrownLeft
mouthFrownRight
mouthFunnel
mouthLeft
mouthLowerDownLeft
mouthLowerDownRight
mouthPressLeft
mouthPressRight
mouthRight
mouthRollLower
mouthRollUpper
mouthShrugLower
mouthShrugUpper
mouthStretchLeft
mouthStretchRight
mouthUpperUpLeft
mouthUpperUpRight
noseSneerLeft
noseSneerRight
Inside the download
iOS/
The local Swift package with its shaders, models and resource bundle. Open
Example/ClayfacesExample.xcodeproj to run the working SwiftUI integration.
Web/
Browser player, TypeScript declarations, the example editor and the vendored Three.js
dependency with its license. Import Web/character.js from an ES module.
WebAssets/
Appearance catalogs, manifest, compressed geometry packets, artwork, textures, the idle
track and 54 sampled performance tracks. Keep this folder beside the web player or
provide its URL through the assets option.
Catalog/
Readable copies of Actions.json, ClayfacesControls.json and
ClayfacesPalette.json. The player reads equivalent catalogs from its
platform resources.
Artwork/ and Conversion/
Editable sticker SVGs, their layout and the Python tools for rebuilding derived assets.
Verification/
The release test report, captured simulator and browser images, and the web recipe used
for the Wave check.
README.md and PLAN.md
Quick starts, release status and the scope of this version.
Edit sticker artwork
Seventeen performances use 26 transparent sticker textures. Choose
Stickers in the animation library to preview
those actions. For example, Dizzy Birds uses separate foreground and background layers as
the birds circle the head.
In a working copy of the extracted kit, edit the matching SVG in
Artwork/Stickers/. Keep the original canvas dimensions and sprite
placement. The animation uses that transparent space to position the artwork.
Use Artwork/sticker-layout.json to inspect the layers and texture
references for each action. If you rename a master, update its references, including
trails.
From the kit root, run the authoring script using Python 3.12. These tools are needed
only when rebuilding artwork.
The script rebuilds the native sticker resource and web image and packet indexes. Use the
rebuilt iOS package and matching WebAssets in your integrations.
Replay the edited action in each bundled example to check scale, transparency and
placement.
Compare all 17 sticker performances on iOS and web
iOS Simulator on the left of each pair, Chrome on the right. The two captures use
slightly different times.
Versions and verification
This guide covers the 0.1.2 private engineering build. Its README
records that commercial redistribution permissions remain unverified. If you have the release
archive, verify it against the checksum below before adding it to your project.
Verify the downloaded ZIP on macOS
shasum -a 256 Clayfaces-0.1.2.zip
Expected SHA-256 for 0.1.2 is
e7cb694444e31663d102fcc84d7ed8daa11dcc5d87a7f427d9c7cea594d0b148.
Update an integration
Extract the new release beside the current one. Back up any edited source artwork and a
few representative saved recipes.
For iOS, point the app at the new local package, rebuild, and ship the new app version.
For web, deploy its matching Web and WebAssets together under
a versioned path. Keep the old path available to pages that still import it.
Reopen a saved character in both integrations. Check the first-load portrait on iOS, a
hand gesture, a face-only gesture and a sticker performance. Use the released action
catalog to validate any saved action IDs.
What was tested in this release
The release report records 949 individual appearance changes, 270 sampled web frames
across all 54 actions and simulator captures of all 17 sticker performances. Native
playback computes hand contact for the current look. On the web, placements follow a 24
fps track recorded with the default head. Extreme head shapes or headwear can shift where
a hand or sticker meets the face. Physical iPhone playback and pixel parity across
browsers were outside the release verification.
What you can do on iOS
Choose a task to see the Swift code and where to put it. New project?
Add the Swift package.
Bind a picker to one entry in the current recipe. Every other appearance selection survives the
change. An omitted freckles entry uses the catalog default of None.
In the body of a SwiftUI view that displays the current look. Declare @State private var look =
AvatarRecipe().
Preload the head, shared hands and neutral portrait on the preceding screen. The player shows
the matching saved portrait until its first live frame. A new custom look without a portrait can
show a person icon. The portrait cache is managed internally.
Attach this modifier to the screen before the avatar. Supply the same AvatarRecipe named look to
both screens. Import OSLog, SwiftUI and Clayfaces.
Build a new event on every tap. Tapping Wink twice replays the wink. Replacing it with Wave
switches the active performance. Assign nil to return to idle.
In a SwiftUI view’s body. Supply a recipe named look and declare @State private var performance:
ClayfacesPerformance? in the view.
Typing “hello” or 👋 finds Wave. Search returns matching IDs in ranked order. Use the catalog’s
display name as the button label.
Place inside a NavigationStack. Declare @State private var query = "" and @State
private var performance: ClayfacesPerformance?. Pass performance to the player.
Swift · Search expressions by word or emoji
List(CoupleExpression.matchingIDs(for: query), id: \.self) { id in
Button(CoupleExpression.name(for: id) ?? id) {
performance = ClayfacesPerformance(id)
}
}
.searchable(text: $query, prompt: "Try hello or 👋")
Store the encoded recipe whenever the editor publishes a change. An encoding error leaves the
previous save intact.
Attach to the parent of your editor. It owns @State private var look = AvatarRecipe() and @State
private var saveError: String?. Display saveError in your existing error UI.
Swift · Save edits on this device
.onChange(of: look) { _, edited in
do {
let data = try edited.encoded()
UserDefaults.standard.set(data, forKey: "profile.avatar")
saveError = nil
} catch {
saveError = error.localizedDescription
}
}
Read the same defaults key on launch. A missing or invalid record opens the basic face. Use a
distinct storage key for each profile in a multi-user app.
In a Swift file that imports Foundation and Clayfaces. Initialize your view with @State private
var look = restoredAvatar().
Swift · Restore the last saved face
func restoredAvatar() -> AvatarRecipe {
let data = UserDefaults.standard.data(forKey: "profile.avatar")
return AvatarRecipe.decode(data) ?? AvatarRecipe()
}
Write the complete appearance to a JSON file and pass the returned URL to your app’s share
sheet. The bundled web editor can import that file.
In a Swift file that imports Foundation and Clayfaces. Call try exportAvatar(look) from your
export action. Remove the temporary file after sharing finishes.
Read the web editor’s exported JSON, or send JSON.stringify(avatar.getAppearance()) from your
own site. Decode before assigning the result so invalid data leaves the user’s current face
intact.
In a Swift file importing Foundation and Clayfaces. After your file picker reads the JSON bytes,
use look = try importAvatar(data) and handle the error in the caller.
Assign a fresh ClayfacesPerformance to the state passed into your
ClayfacesView each time you play or replay a gesture.
See the SwiftUI button example.
Customize any appearance control
In a SwiftUI view, keep the editable recipe in
@State private var look = AvatarRecipe() and pass look to
ClayfacesView(appearance: look). Find a feature and open it to choose an exact value
and copy the code that applies it.
For the 17 base complexions, see the skin palette.
Install the Swift package
Use an iOS 26 or later app target, an iOS 26 or later SDK and a Swift 6.2 or later
toolchain. The SwiftUI view renders with Metal. The download contains the library, its
resource bundle and an example app.
Unzip the kit into a stable project directory. Keep
iOS/Package.swift alongside iOS/Sources.
In Xcode, open your app and choose
File → Add Package Dependencies → Add Local. Select the extracted
iOS directory. Choose the Clayfaces library product and add it
to the app target that will import it.
Build the app and add import Clayfaces to your Swift view. Swift Package
Manager processes the models, appearance catalog, preview and Metal resources as part of
the target.
Run the included app first
Open iOS/Example/ClayfacesExample.xcodeproj inside the extracted kit, choose
the ClayfacesExample scheme and run it on a compatible iPhone or iOS
simulator. Tap Edit character, change a feature and tap
Done. Choose Wave and tap
Play performance. Quit and reopen the example to check that your edited
character returns.
Show a live avatar
Start with a view that takes a binding to the appearance. The parent owns the recipe, so
the editor and player always see the same saved character. For a quick test, show
AvatarCard(look: .constant(AvatarRecipe())). Use a writable binding when you
enable editing.
Give the stage space for a square, including the area beside the face where a hand can
appear. The stage draws a head and each expression’s own hands and props. A close crop
around the face can cut off the wave. Omit performance to show the idle
avatar alone.
UIKit and accessibility
In a UIKit navigation stack, push
UIHostingController(rootView: AvatarProfile()). The
AvatarProfile below owns the editable state. The example hides the decorative
stage from VoiceOver and gives the picker and both buttons text labels. Where the avatar
identifies a person, give that person a visible name or an accessible label. Keep named
expression controls available to people who use Reduce Motion. The stage reads the system
setting and pauses its idle timeline when the performance is nil.
Play and replay expressions
ClayfacesPerformance.actions returns all 54 expressions as
[CoupleExpression]. Each entry has an id for playback and a
name for display. The ID for Wave is person_waving. Preserve
case and punctuation, including callMe and beKind.
Assign a newClayfacesPerformance(id) each time someone taps Play.
Each event has its own identity, so tapping the same expression twice restarts it.
Replacing the event starts the new selection. Assign nil to return the stage
to idle. An unknown ID produces nil. For an incoming string, check it before
replacing the current event if you want to preserve playback on invalid input.
Call these catalog helpers from the main actor. The search helper matches names, IDs and
related words such as “hello.” A blank query lists every ID in catalog order.
CoupleExpression.name(for:) accepts an optional ID and returns an optional
display name. The public event API takes one ID. Version 0.1.2 exposes no Swift
playback-completion callback, seek position or public speed control. Keep sequencing and
button state in the host view.
Edit a character
Open ClayfacesEditor(appearance: $look) in a sheet as shown in
AvatarCard. The editor owns a draft. Done commits the edited
recipe to your binding and dismisses the sheet. Cancel discards the
draft. Done becomes available when the preview matches the current selections.
The bundled catalog has 95 appearance controls across Skin, Hairstyle, Brows, Eyes, Head,
Nose, Mouth, Ears, Facial Hair, Eyewear and Headwear. The skin palette contains 17 base
tones. In the editor, drag the head to rotate, pinch to zoom, or double-tap to face
forward. The options menu can also restore the basic face in the current draft.
The expression picker and facial sliders let someone inspect the character’s face in the
editor. The saved recipe contains appearance controls, skin and shade. Editor expression,
camera angle and zoom belong to the editing session. To play a gesture in the app, pass a
performance to ClayfacesView.
Preload and show a saved preview
As soon as you know which recipe the next screen will display, call
try await ClayfacesView.preload(appearance: look). Put the task on the
preceding screen so it has time to finish before navigation. The following link opens the
same AvatarCard while preparation happens independently.
AvatarProfileLink.swift
import OSLog
import SwiftUI
import Clayfaces
struct AvatarProfileLink: View {
@Binding var look: AvatarRecipe
private let log = Logger(subsystem: "AvatarDemo", category: "Preload")
var body: some View {
NavigationLink("Open avatar") { AvatarCard(look: $look) }
.task(id: look) {
do {
try await ClayfacesView.preload(appearance: look)
} catch {
guard !Task.isCancelled else { return }
log.error("Could not preload avatar: \(error.localizedDescription)")
}
}
}
}
Place this link inside a NavigationStack. The keyed task runs again after a
recipe change. Preload prepares the neutral head and shared resting hands, renders a
neutral portrait and saves it locally. Gesture-specific hand animation is loaded when that
performance is requested. Preloading every possible look can evict the one a user is about
to open.
What appears before the first Metal frame?
Saved preview above, first live render below. Captured in the iOS simulator.
Default face. A portrait ships in the package and is available on the
first launch.
Previously prepared custom face. The stage checks its memory cache,
then reads the matching saved PNG from disk. The still uses skull coordinates for
alignment and yields to the first live frame.
First visit to a new custom face. If the disk lookup misses, the stage
shows a person icon until rendering is ready. A successful preload before navigation
avoids this first-visit fallback. Rendering the stage or tapping Done in the editor also
prepares a portrait.
In 0.1.2, the renderer keeps three recently prepared looks. The in-memory portrait cache
has a 12 MiB cost limit and the disk cache retains up to 32 PNGs under the app’s
Caches/Clayfaces/Portraits-v1 directory. iOS can clear cache files. Persist
the recipe separately so a new portrait can be generated after eviction.
Save, restore and share a recipe
AvatarRecipe is a Codable, Hashable,
Sendable value. try look.encoded() produces sorted-key JSON
bytes. AvatarRecipe.decode(_:) accepts optional Data and returns
an optional validated recipe. This view restores one local profile at startup and writes
it after an edit. Add it beside AvatarCard.swift and show
AvatarProfile() in your app.
AvatarProfile.swift
import OSLog
import SwiftUI
import Clayfaces
struct AvatarProfile: View {
private static let key = "profile.clayfaces.recipe"
private let log = Logger(subsystem: "AvatarDemo", category: "Storage")
@State private var look: AvatarRecipe
init() {
let data = UserDefaults.standard.data(forKey: Self.key)
_look = State(initialValue: AvatarRecipe.decode(data) ?? AvatarRecipe())
}
var body: some View {
AvatarCard(look: $look)
.onChange(of: look) { _, edited in
do {
let data = try edited.encoded()
UserDefaults.standard.set(data, forKey: Self.key)
} catch {
log.error("Could not save avatar: \(error.localizedDescription)")
}
}
}
}
The three fields on disk
values maps stable catalog IDs to numeric overrides.
skin selects the base palette entry and shade adjusts its tone
from −1 through 1. The default is an empty values object, skin 12 and shade
0. For example, this recipe changes a real cheek-shade control and uses base skin 6.
To share a look with the web player, transfer this JSON object, including all three
fields. An animation ID is separate from the recipe. For multiple people, give each
profile its own storage key. Transport and synchronization belong to the host app.
Handling older or invalid data
The Swift decoder returns nil for malformed or incomplete data, inputs over
32,768 bytes, skin outside 0…255, shade outside −1…1, more than 512 controls, keys over
128 UTF-8 bytes, or values outside −65,536…65,536. The sample falls back to the basic
face.
For a valid recipe, the view draws the controls supported by its installed catalog.
Unknown IDs and invalid option selections are skipped. Unsupported palette entries use
skin 12. Float controls are clamped to −1…1 and Boolean controls use 0 or 1. Rendering
works on a compatible copy. If an older client needs to preserve newer selections through
an edit, retain the original JSON and merge the fields your app intends to change.
If the example runs but your app cannot render
“No such module ‘Clayfaces’.” Check that the library product is linked
to the target that imports it, then build for iOS 26 or later.
Missing model or appearance catalog. Check the local package reference
and its Sources/Clayfaces/Resources directory. Build the intact package so
SwiftPM embeds its resource bundle. The native stage displays renderer errors and the
editor offers Retry.
A button appears to do nothing. Log the selected ID, validate it with
ClayfacesPerformance(id) and assign the newly constructed event. Confirm
that the supported action is visible in the bundled example. A previously assigned
event, an unknown ID or a tightly clipped hand can each explain this symptom.
What you can do on the web
Choose a task to see the JavaScript code and where to put it. New project?
Install the web kit.
Call play with the same ID on each click to replay it. Choosing another gesture interrupts the
current one. The promise settles when the performance is prepared.
After mounting avatar. Add buttons with ids "wave", "wink", and
"laugh".
Close and open both eyelids over about 240 milliseconds. Small time steps keep the blink visible
if the device drops frames. Release manual control at the end.
After mounting avatar. Run on a user-triggered blink and let it finish before tearing down the
player.
Read a web or iOS recipe and apply it to the mounted avatar. The player validates the field IDs
and values. A failed import leaves the previous look available.
After mounting avatar. Add <input type="file" id="look-file"
accept=".json,application/json"> and a status element with
id="import-status".
In these examples, avatar is the player returned by
await createClayfaces(host). Find a feature and open it to choose an exact value and
copy the code that applies it.
For the 17 base complexions, see the skin palette.
Install and serve the web kit
Unzip the release and copy Web/ and WebAssets/ into the same
public directory. The included example runs on a static HTTP server. Three.js, the
character data, and all 54 performances ship in the download.
Terminal · run inside the extracted kit directory
python3 -m http.server 8000 --bind 127.0.0.1
Open http://127.0.0.1:8000/Web/. The bundled editor lets you try looks, play
performances, adjust facial channels, and import or export recipe JSON. To build your own
page, keep the directory structure below.
Public files · abbreviated
avatar.html Your page
Web/
character.js ES module entry point
character.d.ts Public TypeScript declarations
index.html Bundled example
vendor/ Three.js and its license
… Keep the remaining modules
WebAssets/
manifest.json Asset index
LumaControls.json Editable fields and option IDs
LumaPalette.json Skin ramps and color swatches
Actions.json Performance IDs and display names
chunks/ Compressed geometry and materials
stages/ Idle and performance timelines
artwork/ and artwork.json Performance artwork
*.png Face and eye detail maps
For a production build, copy both complete folders as static files. Preserve filenames,
case, and relative paths. Version the directories together when upgrading so an old player
cannot read a new manifest with missing chunks. Serve JavaScript modules with a JavaScript
MIME type. A same-origin URL works with the defaults. A separate asset origin must allow
the page to fetch its resources through CORS.
Mount your first character
Save this as avatar.html beside both folders, then open
http://127.0.0.1:8000/avatar.html. Give the host a width and a height or
aspect ratio. Clayfaces appends a transparent canvas and fits the character inside it.
The button becomes available after the requested look is assembled. For an immediate first
impression, place your own saved portrait over the host while loading. Remove it after the
first render opportunity and keep it available if the device cannot create a WebGL 2
context.
Configure the player
Call await createClayfaces(host, options) in a mounted browser view. The
returned player belongs to that host. TypeScript projects can use the adjacent
Web/character.d.ts declarations.
assets · string or URL
Directory containing manifest.json. The default is
../WebAssets/ resolved against character.js. Include the final
slash when supplying a directory URL.
appearance · partial recipe
Initial skin, shade, and values. Omitted
properties take their kit defaults. Supply the saved recipe here when you already have
it at mount.
idle · boolean
Defaults to natural idle motion. Set it to false for a neutral resting
pose. The system reduced-motion preference also selects neutral rest. Explicit
performances still play when requested.
After mounting, read avatar.fields for the editor catalog,
avatar.palette for colors, avatar.actions for the performance
menu, and avatar.channels for supported facial weights. Use these collections
as read-only data.
Build an appearance editor
Each of the 95 fields has an id, display name,
section, category, kind,
initial value, and an options array. Render the 66
Menu fields from their option names and numeric values. The 27
Float fields accept finite numbers from −1 to 1. The two
Bool fields accept numeric 0 or 1.
The following module code runs after mounting avatar. It creates a labeled
hairstyle picker. setAppearance rebuilds from the supplied recipe and fills
omitted settings with defaults. Keep the complete desired recipe while applying rapid
edits, and use the resolved result to reflect the installed look.
A superseded appearance request can resolve to undefined. Installing a new
look interrupts a performance in progress. For a slider, commit expensive appearance
changes on release or debounce them. Manual facial weights use a separate, synchronous
API.
Use avatar.palette.skinNames for the 17 skin labels. The skin value is a
zero-based index. Each palette.skin[index] is a ramp of RGB triplets in the
range 0–1. The center sample represents shade 0. palette.swatches provides
additional colors keyed by field ID. The bundled Web/example.js shows how to
build controls for every field.
Save and restore a recipe
A recipe contains the skin index, a shade from −1 to 1, and a map of numeric field values.
Defaults are skin: 12, shade: 0, and values: {}. A
successful update omits field entries equal to their defaults.
getAppearance() returns a copy of the last installed recipe. Camera angle,
facial channel weights, and the current performance are separate from appearance.
JavaScript · persist one local profile
const key = 'profile.avatar.v1';
function saveLook(avatar) {
try {
localStorage.setItem(key, JSON.stringify(avatar.getAppearance()));
} catch (error) {
console.warn('Avatar storage unavailable', error);
}
}
async function restoreLook(avatar) {
try {
const raw = localStorage.getItem(key);
if (raw === null) return;
const recipe = JSON.parse(raw);
if (!recipe || typeof recipe !== 'object' || Array.isArray(recipe)) {
throw new Error('Expected a recipe object');
}
await avatar.setAppearance(recipe);
} catch (error) {
console.warn('Could not restore the saved look', error);
}
}
Call restoreLook(avatar) after mounting the default look when importing
untrusted or older JSON. Call saveLook(avatar) after a successful edit. A
known field with an invalid option, an unknown field ID, or an out-of-range shade causes a
rejected promise. Legacy keys beginning with Body/ or
Clothing/ are ignored.
The same recipe JSON can be passed to the iOS kit. Keep the original on import failure so
it remains available to a newer release. Store the recipe in local storage, export it as a
file, or sync it through your own account system. The player fetches assets from your
configured origin and leaves recipe storage and transfer to your app.
Play a performance
Each of the 54 entries in avatar.actions has a stable identifier for playback
and a display name for the menu. The example below adds a performance picker and a Play
button to a mounted player. A second click on the same choice replays it from the
beginning.
JavaScript · list and replay performances
const actions = document.createElement('select');
actions.setAttribute('aria-label', 'Performance');
for (const { id, name } of avatar.actions) actions.add(new Option(name, id));
const play = document.createElement('button');
play.type = 'button';
play.textContent = 'Play';
document.body.append(actions, play);
play.addEventListener('click', async () => {
try {
await avatar.play(actions.value);
} catch (error) {
console.error('Could not play this performance', error);
}
});
The first play fetches its timeline and any required hands, textures, or effects.
await avatar.play(id) settles after preparation. Playback then advances on
animation frames and returns to idle or neutral at its end. A new
play() replaces the previous performance. A manual expression or a newly
installed appearance also interrupts it. An unknown ID rejects with
RangeError.
Version 0.1.2 exposes no playback completion event, public duration property on an action,
queue, seek, or pause method. Use explicit controls for motion-sensitive users. To
interrupt a performance and release the face to its resting behavior, call
avatar.setExpression(null).
Pose a facial channel
Use manual weights for abilities such as responding to a microphone level or animating a
smile yourself. avatar.channels contains the 52 case-sensitive rig names.
Each call replaces the entire weight map. Supply finite values from 0 through 1. An
unknown key or invalid weight throws RangeError synchronously.
An empty map holds the neutral face. Passing null releases manual control and
resumes the configured resting behavior. Manual facial weights control the face only. Use
play(id) when a gesture needs its recorded head motion, hands, or effects.
Handle layout and teardown
The host is observed for size changes. A square shows the intended framing. In a wider or
taller host, Clayfaces fits the square performance into the available space. Canvas
resolution follows the device pixel ratio up to 2. The player supports pointer drag to
orbit, focused Left and Right arrow keys to turn, and double-click or
avatar.resetCamera() to face forward.
Mount a player once per live character. On a route change, disconnect the player with
dispose(). This removes its canvas, stops the render loop, disconnects the
resize observer, and releases GPU resources. A neutral or hidden mounted player can still
render frames. For offscreen lists, show portraits and mount players where interaction is
needed.
JavaScript · component mount and cleanup
import { createClayfaces } from './Web/character.js';
function mountAvatar(host, options, onError) {
let removed = false;
let player;
createClayfaces(host, options).then(created => {
if (removed) created.dispose();
else player = created;
}).catch(error => {
if (!removed) onError(error);
});
return () => {
removed = true;
player?.dispose();
player = undefined;
};
}
const unmount = mountAvatar(document.querySelector('#avatar'), {}, console.error);
// Call unmount() in the route or component's teardown hook.
This cleanup also handles navigation while the first appearance loads. Remove your own
timers, DOM listeners, or observers when their view is destroyed. Create a fresh player
when the view returns.
Diagnose a failed load
The module fails to import
Serve the extracted files over HTTP or HTTPS. In the Network panel, open
Web/character.js and its relative imports. Check for a JavaScript MIME type
and for a router returning HTML in place of a file.
The canvas is blank
Give the host measurable dimensions and check the rejected startup promise and browser
console. The renderer needs WebGL 2, ES modules, ResizeObserver, and gzip
DecompressionStream. Keep a static portrait or a text fallback on a device
with unavailable graphics.
A specific look or gesture fails
Look for the first failed request under WebAssets/. A missing chunk may
only be requested by one hairstyle or gesture. Check exact case, version, asset-base
trailing slash, and access from the page origin. Rebuilds should deploy both runtime
folders as one release.
A binary packet cannot decompress
Serve .cf files as binary with their packaged gzip bytes intact. The player
runs its own decoder. A Content-Encoding: gzip header applied to the
original packet causes browsers to consume its compression layer before the player gets
it. The timeline loader accepts either gzipped or already-decoded JSON for
stages/*.json.gz.
A saved look fails validation
Inspect the reported field ID. Use the numeric option value in its catalog entry, check
index and shade bounds, and retain the original JSON if from a later kit. Test a default
{} recipe to distinguish a data mismatch from an asset-loading failure.
The first request takes longer
The initial mount loads the catalogs, idle track, rig, textures, and the requested
appearance. Additional chunks load on demand. Serve versioned static files with normal
HTTP caching and show a saved portrait while mounting. Offline access to a remote site
requires your app to cache or otherwise provide the files it will need.