def update_scene(self, scene_graph, materials_only): """Update a scene using scene_graph description Arguments: scene_graph {SceneGraph} -- scene description materials_only {bool} -- update only shape materials """ for uid, pb_node in scene_graph.nodes.items(): node = NodePath(f'pb_node_{uid:03d}') for pb_shape in pb_node.shapes: filename = shape_filename(pb_shape) if not filename: continue shape = self._loader.load_model(filename) shape.set_mat(Mat4(*pb_shape.pose.matrix)) shape.reparent_to(node) if shape.has_material: shape.set_material(PbMaterial(pb_shape.material), 1) texture_id = pb_shape.material.diffuse_texture if texture_id > -1: texture = scene_graph.texture(texture_id) shape.set_texture(texture.filename) node.flatten_light() node.reparent_to(self.scene) self._node_dict[uid] = node