From High Fidelity Documentation
Jump to: navigation, search

MyAvatar API

JavaScript API

Your avatar is your in-world representation of you. One way to customize your avatar is to attach models to it. For example, you can give your avatar a hat to wear, a guitar to hold, or a surfboard to stand on.

The attach() function is used to attach models to your avatar.

Note: Attached models are models only. They are not entities and can not be manipulated using the entities API, nor can you use attach to attach an entity (such as a sphere or a box) to the avatar.


attach(modelURL, jointName, translation, rotation, scale, isSoft)


modelURL:string: The URL to the model you want to attach. Models can be .FBX or .OBJ format.

jointName:string: The joint name for the part of MyAvatar where the object will be attached. For the list of joint names, use getJointNames().

translation: object: A JavaScript object which takes x, y, and z name-value pairs specifying the translation of the attached object relative to the named joint position

rotation: object: A JavaScript object which takes x, y, z, and w name-value pairs specifying the rotation of the attached object

scale: float: The scale of the object to be attached

isSoft: bool: If the model has a skeleton, set this to true so that the bones of the attached model's skeleton will be rotated to fit the current avatar's pose. isSoft is used, for example, to have clothing that moves with the avatar. When true, the translation,rotation and scale parameters are ignored.


This example attaches a cowboy hat to your avatar's head.

var attachment = {
    modelURL: "",
    jointName: "Head",
    translation: {"x": 0, "y": 0.25, "z": 0},
    rotation: {"x": 0, "y": 0, "z": 0, "w": 1},
    scale: 1,
    isSoft: false


If you are using the default avatar, it should now look like this:



Check the High Fidelity source for more information and examples: