def new_obj_callback(msg): global avatars user_id = extract_user_id(msg["object_id"]) if user_id is None: return if "type" in msg and "face-features" == msg["type"] and user_id in avatars: if user_id not in avatars: avatars[user_id] = HeadRig(scene, user_id, Camera(**msg)) avatars[user_id].add_face(Object(**msg))
def new_obj_callback(scene, obj, msg): global avatars user_id = extract_user_id(obj.object_id) if user_id is None: return if "type" in obj and "face-features" == msg["type"] and user_id in avatars: if user_id not in avatars: avatars[user_id] = HeadRig(scene, user_id, Camera(object_id=obj.object_id)) avatars[user_id].add_face(obj)
def on_msg_callback(msg): global avatars user_id = extract_user_id(msg["object_id"]) if user_id is None: return if user_id in avatars: avatar = avatars[user_id] if avatar.has_avatar: avatar.rig_on() avatar.update() else: avatar.rig_off()
def callback(msg): global avatars msg_json = json.loads(msg) if "hasAvatar" in msg_json: user = extract_user_id(msg_json["object_id"]) if msg_json["hasAvatar"]: if user not in avatars: avatars[user] = Head(user) avatars[user].rig_on() else: if user in avatars: avatars[user].rig_off() del avatars[user] elif "hasFace" in msg_json and msg_json["hasFace"]: user = extract_user_id(msg_json["object_id"]) if user in avatars and avatars[user].rig_enabled: if not avatars[user].has_face: avatars[user].add_face(msg_json) else: avatars[user].update_face(msg_json)
def on_msg_callback(scene, obj, msg): global avatars user_id = extract_user_id(obj.object_id) if user_id is None: return if user_id in avatars: avatar = avatars[user_id] if avatar.has_avatar: avatar.rig_on() avatar.update() else: avatar.rig_off() if avatar.faceObj is None and "type" in obj and "face-features" == msg[ "type"]: avatar.add_face(obj)
def user_join_callback(camera): global avatars user_id = extract_user_id(camera.object_id) if user_id and user_id not in avatars: avatars[user_id] = HeadRig(scene, user_id, camera)