lib/utils.js
/**
 * Test is the provided object contains the necessary
 * bones and blendShapes from a ReadyPlayerMe avatar
 *
 * @param {HTMLElement} avatarRootEl
 */
Test is the provided object contains the necessary
bones and blendShapes from a ReadyPlayerMe avatar


Test is the provided object contains the necessary bones and blendShapes from a ReadyPlayerMe avatar
function isValidAvatar(avatarRootEl) {
  try {
    const face = avatarRootEl.querySelector('.Wolf3D_Head').object3DMap.skinnedmesh
    const bones = {}
    avatarRootEl.object3D.traverse((o) => {
      if (o.isBone) {
        bones[o.name] = o
      }
    })
    const requiredBlendShapes = blendShapeNames.filter((name) => !name.includes('eyeLook'))
    const hasRequiredBlendShapes = requiredBlendShapes.every((name) => name in face.morphTargetDictionary)
    const requiredBones = ['Head', 'RightEye', 'LeftEye']
    const hasRequireBones = requiredBones.every((name) => name in bones)
    return hasRequiredBlendShapes && hasRequireBones
  } catch (e) {
    return false
  }
}
function isValidAvatar ( avatarRootEl ) { try { const face = avatarRootEl . querySelector ( '.Wolf3D_Head' ) . object3DMap . skinnedmesh const bones = { } avatarRootEl . object3D . traverse ( ( o ) => { if ( o . isBone ) { bones [ o . name ] = o } } ) const requiredBlendShapes = blendShapeNames . filter ( ( name ) => ! name . includes ( 'eyeLook' ) ) const hasRequiredBlendShapes = requiredBlendShapes . every ( ( name ) => name in face . morphTargetDictionary ) const requiredBones = [ 'Head' , 'RightEye' , 'LeftEye' ] const hasRequireBones = requiredBones . every ( ( name ) => name in bones ) return hasRequiredBlendShapes && hasRequireBones } catch ( e ) { return false } }
Test is the provided object contains the necessary
 bones and blendShapes from a ReadyPlayerMe avatar
Test is the provided object contains the necessary bones and blendShapes from a ReadyPlayerMe avatar
// RPM face skinnedMesh doesn't include eye blendShapes, don't check for those