gltf#

Animation([actors, length, loop, ...])

Keyframe animation class.

Camera

alias of vtkCamera

Matrix4x4

alias of vtkMatrix4x4

Texture

alias of vtkTexture

Transform

alias of vtkTransform

glTF(filename[, apply_normals])

export_scene(scene[, filename])

Generate gltf from FURY scene.

get_prim(vertex, index, color, tcoord, ...)

Return a Primitive object.

glb2gltf(source[, destination, override])

Save a .glb file as its .gltf equivalent.

gltf2glb(source[, destination, override])

Save a .gltf file as its .glb equivalent.

linear_interpolator(keyframes)

Linear interpolator for keyframes.

slerp(keyframes)

Spherical based rotation keyframes interpolator.

step_interpolator(keyframes)

Step interpolator for keyframes.

tan_cubic_spline_interpolator(keyframes)

Cubic spline interpolator for keyframes using tangents.

write_accessor(gltf, bufferview, ...[, max, min])

Write accessor in the gltf.

write_buffer(gltf, byte_length, uri)

Write buffer int the gltf

write_bufferview(gltf, buffer, byte_offset, ...)

Write bufferview in the gltf.

write_camera(gltf, camera)

Create and add camera.

write_material(gltf, basecolortexture, uri)

Write Material, Images and Textures

write_mesh(gltf, primitives)

Create mesh and add primitive.

write_node(gltf[, mesh_id, camera_id])

Create node

write_scene(gltf, nodes)

Create scene

Animation#

class fury.gltf.Animation(actors=None, length=None, loop=True, motion_path_res=None)[source]#

Bases: object

Keyframe animation class.

Animation is responsible for keyframe animations for a single or a group of actors. It’s used to handle multiple attributes and properties of Fury actors such as transformations, color, and scale. It also accepts custom data and interpolates them, such as temperature. Linear interpolation is used by default to interpolate data between the main keyframes.

actors#

Actor/s to be animated.

Type:

Actor or list[Actor], optional, default: None

length#

the fixed length of the animation. If set to None, the animation will get its duration from the keyframes being set.

Type:

float or int, default: None, optional

loop#

Whether to loop the animation (True) of play once (False).

Type:

bool, optional, default: True

motion_path_res#

the number of line segments used to visualizer the animation’s motion path (visualizing position).

Type:

int, default: None

__init__(actors=None, length=None, loop=True, motion_path_res=None)[source]#
property actors#

Return a list of actors.

Returns:

List of actors controlled by the Animation.

Return type:

list

add(item)[source]#

Add an item to the Animation. This item can be an Actor, Animation, list of Actors, or a list of Animations.

Parameters:

item (Animation, vtkActor, list[Animation], or list[vtkActor]) – Actor/s to be animated by the Animation.

add_actor(actor, static=False)[source]#

Add an actor or list of actors to the Animation.

Parameters:
  • actor (vtkActor or list(vtkActor)) – Actor/s to be animated by the Animation.

  • static (bool) – Indicated whether the actor should be animated and controlled by the animation or just a static actor that gets added to the scene along with the Animation.

add_child_animation(animation)[source]#

Add child Animation or list of Animations.

Parameters:

animation (Animation or list[Animation]) – Animation/s to be added.

add_static_actor(actor)[source]#

Add an actor or list of actors as static actor/s which will not be controlled nor animated by the Animation. All static actors will be added to the scene when the Animation is added to the scene.

Parameters:

actor (vtkActor or list(vtkActor)) – Static actor/s.

add_to_scene(scene)[source]#

Add this Animation, its actors and sub Animations to the scene

add_to_scene_at(timestamp)[source]#

Set timestamp for adding Animation to scene event.

Parameters:

timestamp (float) – Timestamp of the event.

add_update_callback(callback, prop=None)[source]#

Add a function to be called each time animation is updated This function must accept only one argument which is the current value of the named property.

Parameters:
  • callback (callable) – The function to be called whenever the animation is updated.

  • prop (str, optional, default: None) – The name of the property.

Notes

If no attribute name was provided, current time of the animation will be provided instead of current value for the callback.

property child_animations: list[fury.animation.animation.Animation]#

Return a list of child Animations.

Returns:

List of child Animations of this Animation.

Return type:

list

property current_timestamp#

Return the current time of the animation.

Returns:

The current time of the animation.

Return type:

float

property duration#

Return the duration of the animation.

Returns:

The duration of the animation.

Return type:

float

get_color(t)[source]#

Return the interpolated color.

Parameters:

t (float) – The time to interpolate color value at.

Returns:

The interpolated color.

Return type:

ndarray(1, 3)

get_current_value(attrib)[source]#

Return the value of an attribute at current time.

Parameters:

attrib (str) – The attribute name.

get_keyframes(attrib=None)[source]#

Get a keyframe for a specific or all attributes.

Parameters:

attrib (str, optional, default: None) – The name of the attribute. If None, all keyframes for all set attributes will be returned.

get_opacity(t)[source]#

Return the opacity value.

Parameters:

t (float) – The time to interpolate opacity at.

Returns:

The interpolated opacity.

Return type:

ndarray(1, 1)

get_position(t)[source]#

Return the interpolated position.

Parameters:

t (float) – The time to interpolate position at.

Returns:

The interpolated position.

Return type:

ndarray(1, 3)

get_rotation(t, as_quat=False)[source]#

Return the interpolated rotation.

Parameters:
  • t (float) – the time to interpolate rotation at.

  • as_quat (bool) – Returned rotation will be as quaternion if True.

Returns:

The interpolated rotation as Euler degrees by default.

Return type:

ndarray(1, 3)

get_scale(t)[source]#

Return the interpolated scale.

Parameters:

t (float) – The time to interpolate scale at.

Returns:

The interpolated scale.

Return type:

ndarray(1, 3)

get_value(attrib, timestamp)[source]#

Return the value of an attribute at any given timestamp.

Parameters:
  • attrib (str) – The attribute name.

  • timestamp (float) – The timestamp to interpolate at.

is_inside_scene_at(timestamp)[source]#

Check if the Animation is set to be inside the scene at a specific timestamp.

Returns:

True if the Animation is set to be inside the scene at the given timestamp.

Return type:

bool

Notes

If the parent Animation is set to be out of the scene at that time, all of their child animations will be out of the scene as well.

is_interpolatable(attrib)[source]#

Check whether a property is interpolatable.

Parameters:

attrib (str) – The name of the property.

Returns:

True if the property is interpolatable by the Animation.

Return type:

bool

Notes

True means that it’s safe to use Interpolator.interpolate(t) for the specified property. And False means the opposite.

property loop#

Get loop condition of the current animation.

Returns:

Whether the animation in loop mode (True) or play one mode (False).

Return type:

bool

property parent_animation#

Return the hierarchical parent Animation for current Animation.

Returns:

The parent Animation.

Return type:

Animation

remove_actor(actor)[source]#

Remove an actor from the Animation.

Parameters:

actor (vtkActor) – Actor to be removed from the Animation.

remove_actors()[source]#

Remove all actors from the Animation

remove_animations()[source]#

Remove all child Animations from the Animation

remove_from_scene(scene)[source]#

Remove Animation, its actors and sub Animations from the scene

remove_from_scene_at(timestamp)[source]#

Set timestamp for removing Animation to scene event.

Parameters:

timestamp (float) – Timestamp of the event.

set_color(timestamp, color, **kwargs)[source]#

Set color keyframe at a specific timestamp.

Parameters:
  • timestamp (float) – Timestamp of the keyframe

  • color (ndarray, shape(1, 3)) – Color keyframe value associated with the timestamp.

set_color_interpolator(interpolator, is_evaluator=False)[source]#

Set the color interpolator.

Parameters:
  • interpolator (callable) – The generator function of the interpolator that would handle the color keyframes.

  • is_evaluator (bool, optional) – Specifies whether the interpolator is time-only based evaluation function that does not depend on keyframes.

Examples

>>> Animation.set_color_interpolator(lab_color_interpolator)
set_color_keyframes(keyframes)[source]#

Set a dict of color keyframes at once. Should be in the following form: {timestamp_1: color_1, timestamp_2: color_2}

Parameters:

keyframes (dict) – A dict with timestamps as keys and color as values.

Examples

>>> color_keyframes = {1, np.array([1, 0, 1]), 3, np.array([0, 0, 1])}
>>> Animation.set_color_keyframes(color_keyframes)
set_interpolator(attrib, interpolator, is_evaluator=False, **kwargs)[source]#

Set keyframes interpolator for a certain property

Parameters:
  • attrib (str) – The name of the property.

  • interpolator (callable) – The generator function of the interpolator to be used to interpolate/evaluate keyframes.

  • is_evaluator (bool, optional) – Specifies whether the interpolator is time-only based evaluation function that does not depend on keyframes such as: >>> def get_position(t): >>> return np.array([np.sin(t), np.cos(t) * 5, 5])

  • spline_degree (int, optional) – The degree of the spline in case of setting a spline interpolator.

Notes

If an evaluator is used to set the values of actor’s properties such as position, scale, color, rotation, or opacity, it has to return a value with the same shape as the evaluated property, i.e.: for scale, it has to return an array with shape 1x3, and for opacity, it has to return a 1x1, an int, or a float value.

Examples

>>> Animation.set_interpolator('position', linear_interpolator)
>>> pos_fun = lambda t: np.array([np.sin(t), np.cos(t), 0])
>>> Animation.set_interpolator('position', pos_fun)
set_keyframe(attrib, timestamp, value, update_interpolator=True, **kwargs)[source]#

Set a keyframe for a certain attribute.

Parameters:
  • attrib (str) – The name of the attribute.

  • timestamp (float) – Timestamp of the keyframe.

  • value (ndarray or float or bool) – Value of the keyframe at the given timestamp.

  • update_interpolator (bool, optional) – Interpolator will be reinitialized if Ture

  • in_cp (ndarray, shape (1, M), optional) – The in control point in case of using cubic Bézier interpolator.

  • out_cp (ndarray, shape (1, M), optional) – The out control point in case of using cubic Bézier interpolator.

  • in_tangent (ndarray, shape (1, M), optional) – The in tangent at that position for the cubic spline curve.

  • out_tangent (ndarray, shape (1, M), optional) – The out tangent at that position for the cubic spline curve.

set_keyframes(attrib, keyframes)[source]#

Set multiple keyframes for a certain attribute.

Parameters:
  • attrib (str) – The name of the attribute.

  • keyframes (dict) – A dict object containing keyframes to be set.

Notes

Keyframes can be on any of the following forms: >>> key_frames_simple = {1: [1, 2, 1], 2: [3, 4, 5]} >>> key_frames_bezier = {1: {‘value’: [1, 2, 1]}, >>> 2: {‘value’: [3, 4, 5], ‘in_cp’: [1, 2, 3]}} >>> pos_keyframes = {1: np.array([1, 2, 3]), 3: np.array([5, 5, 5])} >>> Animation.set_keyframes(‘position’, pos_keyframes)

set_opacity(timestamp, opacity, **kwargs)[source]#

Set opacity keyframe at a specific timestamp.

Parameters:
  • timestamp (float) – Timestamp of the keyframe

  • opacity (ndarray, shape(1, 3)) – Opacity keyframe value associated with the timestamp.

set_opacity_interpolator(interpolator, is_evaluator=False)[source]#

Set the opacity interpolator.

Parameters:
  • interpolator (callable) – The generator function of the interpolator that would handle the opacity keyframes.

  • is_evaluator (bool, optional) – Specifies whether the interpolator is time-only based evaluation function that does not depend on keyframes.

Examples

>>> Animation.set_opacity_interpolator(step_interpolator)
set_opacity_keyframes(keyframes)[source]#

Set a dict of opacity keyframes at once. Should be in the following form: {timestamp_1: opacity_1, timestamp_2: opacity_2}

Parameters:

keyframes (dict(float: ndarray, shape(1, 1) or float or int)) – A dict with timestamps as keys and opacities as values.

Notes

Opacity values should be between 0 and 1.

Examples

>>> opacity = {1, np.array([1, 1, 1]), 3, np.array([2, 2, 3])}
>>> Animation.set_scale_keyframes(opacity)
set_position(timestamp, position, **kwargs)[source]#

Set a position keyframe at a specific timestamp.

Parameters:
  • timestamp (float) – Timestamp of the keyframe

  • position (ndarray, shape (1, 3)) – Position value

  • in_cp (float) – The control point in case of using cubic Bézier interpolator when time exceeds this timestamp.

  • out_cp (float) – The control point in case of using cubic Bézier interpolator when time precedes this timestamp.

  • in_tangent (ndarray, shape (1, M), optional) – The in tangent at that position for the cubic spline curve.

  • out_tangent (ndarray, shape (1, M), optional) – The out tangent at that position for the cubic spline curve.

Notes

in_cp and out_cp only needed when using the cubic bezier interpolation method.

set_position_interpolator(interpolator, is_evaluator=False, **kwargs)[source]#

Set the position interpolator.

Parameters:
  • interpolator (callable) –

    The generator function of the interpolator that would handle the

    position keyframes.

  • is_evaluator (bool, optional) – Specifies whether the interpolator is time-only based evaluation function that does not depend on keyframes.

  • degree (int) – The degree of the spline interpolation in case of setting the spline_interpolator.

Examples

>>> Animation.set_position_interpolator(spline_interpolator, degree=5)
set_position_keyframes(keyframes)[source]#

Set a dict of position keyframes at once. Should be in the following form: {timestamp_1: position_1, timestamp_2: position_2}

Parameters:

keyframes (dict) – A dict with timestamps as keys and positions as values.

Examples

>>> pos_keyframes = {1, np.array([0, 0, 0]), 3, np.array([50, 6, 6])}
>>> Animation.set_position_keyframes(pos_keyframes)
set_rotation(timestamp, rotation, **kwargs)[source]#

Set a rotation keyframe at a specific timestamp.

Parameters:
  • timestamp (float) – Timestamp of the keyframe

  • rotation (ndarray, shape(1, 3) or shape(1, 4)) – Rotation data in euler degrees with shape(1, 3) or in quaternions with shape(1, 4).

Notes

Euler rotations are executed by rotating first around Z then around X, and finally around Y.

set_rotation_as_vector(timestamp, vector, **kwargs)[source]#

Set a rotation keyframe at a specific timestamp.

Parameters:
  • timestamp (float) – Timestamp of the keyframe

  • vector (ndarray, shape(1, 3)) – Directional vector that describes the rotation.

set_rotation_interpolator(interpolator, is_evaluator=False)[source]#

Set the rotation interpolator .

Parameters:
  • interpolator (callable) – The generator function of the interpolator that would handle the rotation (orientation) keyframes.

  • is_evaluator (bool, optional) – Specifies whether the interpolator is time-only based evaluation function that does not depend on keyframes.

Examples

>>> Animation.set_rotation_interpolator(slerp)
set_scale(timestamp, scalar, **kwargs)[source]#

Set a scale keyframe at a specific timestamp.

Parameters:
  • timestamp (float) – Timestamp of the keyframe

  • scalar (ndarray, shape(1, 3)) – Scale keyframe value associated with the timestamp.

set_scale_interpolator(interpolator, is_evaluator=False)[source]#

Set the scale interpolator.

Parameters:
  • interpolator (callable) – TThe generator function of the interpolator that would handle the scale keyframes.

  • is_evaluator (bool, optional) – Specifies whether the interpolator is time-only based evaluation function that does not depend on keyframes.

Examples

>>> Animation.set_scale_interpolator(step_interpolator)
set_scale_keyframes(keyframes)[source]#

Set a dict of scale keyframes at once. Should be in the following form: {timestamp_1: scale_1, timestamp_2: scale_2}

Parameters:

keyframes (dict) – A dict with timestamps as keys and scales as values.

Examples

>>> scale_keyframes = {1, np.array([1, 1, 1]), 3, np.array([2, 2, 3])}
>>> Animation.set_scale_keyframes(scale_keyframes)
property static_actors#

Return a list of static actors.

Returns:

List of static actors.

Return type:

list

property timeline#

Return the Timeline handling the current animation.

Returns:

The Timeline handling the current animation, None, if there is no associated Timeline.

Return type:

Timeline

update_animation(time=None)[source]#

Update the animation.

Update the animation at a certain time. This will make sure all attributes are calculated and set to the actors at that given time.

Parameters:

time (float or int, optional, default: None) – The time to update animation at. If None, the animation will play without adding it to a Timeline.

update_duration()[source]#

Update and return the duration of the Animation.

Returns:

The duration of the animation.

Return type:

float

update_motion_path()[source]#

Update motion path visualization actor

Camera#

fury.gltf.Camera#

alias of vtkCamera

Matrix4x4#

fury.gltf.Matrix4x4#

alias of vtkMatrix4x4

Texture#

fury.gltf.Texture#

alias of vtkTexture

Transform#

fury.gltf.Transform#

alias of vtkTransform

glTF#

class fury.gltf.glTF(filename, apply_normals=False)[source]#

Bases: object

__init__(filename, apply_normals=False)[source]#

Read and generate actors from glTF files.

Parameters:
  • filename (str) – Path of the gltf file

  • apply_normals (bool, optional) – If True applies normals to the mesh.

actors()[source]#

Generate actors from glTF file.

Returns:

actors – List of vtkActors with texture.

Return type:

list

apply_morph_vertices(vertices, weights, cnt)[source]#

Calculate weighted vertex from the morph data.

Parameters:
  • vertices (ndarray) – Vertices of a actor.

  • weights (ndarray) – Morphing weights used to calculate the weighted average of new vertex.

  • cnt (int) – Count of the actor.

apply_skin_matrix(vertices, joint_matrices, actor_index=0)[source]#

Apply the skinnig matrix, that transform the vertices.

Parameters:
  • vertices (ndarray) – Vertices of an actor.

  • join_matrices (list) – List of skinning matrix to calculate the weighted transformation.

Returns:

vertices – Modified vertices.

Return type:

ndarray

generate_tmatrix(transf, prop)[source]#

Create transformation matrix from TRS array.

Parameters:
  • transf (ndarray) – Array containing translation, rotation or scale values.

  • prop (str) – String that defines the type of array (values: translation, rotation or scale).

Returns:

matrix – ransformation matrix of shape (4, 4) with respective transforms.

Return type:

ndarray (4, 4)

get_acc_data(acc_id)[source]#

Get the correct data from buffer using accessors and bufferviews.

Parameters:

acc_id (int) – Accessor index

Returns:

buffer_array – Numpy array extracted from the buffer.

Return type:

ndarray

get_animations()[source]#

Return list of animations.

Returns:

animations – List of animations containing actors.

Return type:

List

get_buff_array(buff_id, d_type, byte_length, byte_offset, byte_stride)[source]#

Extract the mesh data from buffer.

Parameters:
  • buff_id (int) – Buffer Index

  • d_type (type) – Element data type

  • byte_length (int) – The lenght of the buffer data

  • byte_offset (int) – The offset into the buffer in bytes

  • byte_stride (int) – The stride, in bytes

Returns:

out_arr – Numpy array of size byte_length from buffer.

Return type:

ndarray

get_joint_actors(length=0.5, with_transforms=False)[source]#

Create an arrow actor for each bone in a skinned model.

Parameters:
  • length (float (default = 0.5)) – Length of the arrow actor

  • with_transforms (bool (default = False)) – Applies respective transformations to bone. Bones will be at origin if set to False.

get_materials(mat_id)[source]#

Get the material data.

Parameters:

mat_id (int) – Material index

Returns:

materials – Dictionary of all textures.

Return type:

dict

get_matrix_from_sampler(prop, node, anim_channel, sampler: Sampler)[source]#

Return transformation matrix for a given timestamp from Sampler data. Combine matrices for a given common timestamp.

Parameters:
  • prop (str) – Property of the array (‘translation’, ‘rotation’ or ‘scale’)

  • node (int) – Node index of the sampler data.

  • anim_channel (dict) – Containing previous animations with node as keys.

  • sampler (gltflib.Sampler) – Sampler object for an animation channel.

get_morph_data(target, mesh_id)[source]#
get_sampler_data(sampler: Sampler, node_id: int, transform_type)[source]#

Get the animation and transformation data from sampler.

Parameters:
  • sampler (glTFlib.Sampler) – pygltflib sampler object.

  • node_id (int) – Node index of the current animation channel.

  • transform_type (str) – Property of the node to be transformed.

Returns:

sampler_data – dictionary of data containing timestamps, node transformations and interpolation type.

Return type:

dict

get_skin_data(skin_id)[source]#

Get the inverse bind matrix for each bone in the skin.

Parameters:

skin_id (int) – Index of the skin.

Returns:

  • joint_nodes (list) – List of bones in the skin.

  • inv_bind_matrix (ndarray) – Numpy array containing inverse bind pose for each bone.

get_texture(tex_id)[source]#

Read and convert image into vtk texture.

Parameters:

tex_id (int) – Texture index

Returns:

atexture – Returns flipped vtk texture from image.

Return type:

Texture

initialize_skin(animation, bones=False, length=0.2)[source]#

Create bones and add to the animation and initialise update_skin

Parameters:
  • animation (Animation) – Skin animation object.

  • bones (bool) – Switches the visibility of bones in scene. (default=False)

  • length (float) – Length of the bones. (default=0.2)

inspect_scene(scene_id=0)[source]#

Loop over nodes in a scene.

Parameters:

scene_id (int, optional) – scene index of the glTF.

load_camera(camera_id, transform_mat)[source]#

Load the camera data of a node.

Parameters:
  • camera_id (int) – Camera index of a node.

  • transform_mat (ndarray (4, 4)) – Transformation matrix of the camera.

load_mesh(mesh_id, transform_mat, parent)[source]#

Load the mesh data from accessor and applies the transformation.

Parameters:
  • mesh_id (int) – Mesh index to be loaded

  • transform_mat (ndarray (4, 4)) – Transformation matrix.

main_animation()[source]#

Return main animation with all glTF animations.

Returns:

main_animation – A parent animation containing all child animations for simple animation.

Return type:

Animation

morph_animation()[source]#

Create animation for each channel in animations.

Returns:

root_animations – A dictionary containing animations as values and animation name as keys.

Return type:

Dict

skin_animation()[source]#

One animation for each bone, contains parent transforms.

Returns:

root_animations – An animation containing all the child animations for bones.

Return type:

Dict

transverse_animations(animation, bone_id, timestamp, joint_matrices, parent_bone_deform=array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]))[source]#

Calculate skinning matrix (Joint Matrices) and transform bone for each animation.

Parameters:
  • animation (Animation) – Animation object.

  • bone_id (int) – Bone index of the current transform.

  • timestamp (float) – Current timestamp of the animation.

  • joint_matrices (dict) – Empty dictionary that will contain joint matrices.

  • parent_bone_transform (ndarray (4, 4)) – Transformation matrix of the parent bone. (default=np.identity(4))

transverse_bones(bone_id, channel_name, parent_animation: Animation)[source]#

Loop over the bones and add child bone animation to their parent animation.

Parameters:
  • bone_id (int) – Index of the bone.

  • channel_name (str) – Animation name.

  • parent_animation (Animation) – The animation of the parent bone. Should be root_animation by default.

transverse_channels(animation: Animation, count: int)[source]#

Loop over animation channels and sets animation data.

Parameters:
  • animation (glTflib.Animation) – pygltflib animation object.

  • count (int) – Animation count.

transverse_node(nextnode_id, matrix, parent=None, is_joint=False)[source]#

Load mesh and generates transformation matrix.

Parameters:
  • nextnode_id (int) – Index of the node

  • matrix (ndarray (4, 4)) – Transformation matrix

  • parent (list, optional) – List of indices of parent nodes Default: None.

  • is_joint (Bool) – To determine if the current node is a joint/bone of skins. Default: False

update_morph(animation)[source]#

Update the animation and actors with morphing.

Parameters:

animation (Animation) – Animation object.

update_skin(animation)[source]#

Update the animation and actors with skinning data.

Parameters:

animation (Animation) – Animation object.

export_scene#

fury.gltf.export_scene(scene, filename='default.gltf')[source]#

Generate gltf from FURY scene.

Parameters:
  • scene (Scene) – FURY scene object.

  • filename (str, optional) – Name of the model to be saved

get_prim#

fury.gltf.get_prim(vertex, index, color, tcoord, normal, material, mode=4)[source]#

Return a Primitive object.

Parameters:
  • vertex (int) – Accessor index for the vertices data.

  • index (int) – Accessor index for the triangles data.

  • color (int) – Accessor index for the colors data.

  • tcoord (int) – Accessor index for the texture coordinates data.

  • normal (int) – Accessor index for the normals data.

  • material (int) – Materials index.

  • mode (int, optional) – The topology type of primitives to render. Default: 4

Returns:

prim – pygltflib primitive object.

Return type:

Primitive

glb2gltf#

fury.gltf.glb2gltf(source, destination=None, override=False)[source]#

Save a .glb file as its .gltf equivalent.

Parameters:
  • source (str) – Path to existing .glb file.

  • destination (Optional(str)) – Filename to write to (default is to use existing filename as base)

  • override (bool) – Override existing file.

gltf2glb#

fury.gltf.gltf2glb(source, destination=None, override=False)[source]#

Save a .gltf file as its .glb equivalent.

Parameters:
  • source (str) – Path to existing .gltf file.

  • destination (Optional(str)) – Filename to write to (default is to use existing filename as base)

  • override (bool) – Override existing file.

linear_interpolator#

fury.gltf.linear_interpolator(keyframes)[source]#

Linear interpolator for keyframes.

This is a general linear interpolator to be used for any shape of keyframes data.

Parameters:

keyframes (dict) – Keyframe data to be linearly interpolated.

Returns:

The interpolation function that take time and return interpolated value at that time.

Return type:

function

slerp#

fury.gltf.slerp(keyframes)[source]#

Spherical based rotation keyframes interpolator.

A rotation interpolator to be used for rotation keyframes.

Parameters:

keyframes (dict) – Rotation keyframes to be interpolated at any time.

Returns:

The interpolation function that take time and return interpolated value at that time.

Return type:

function

Notes

Rotation keyframes must be in the form of quaternions.

step_interpolator#

fury.gltf.step_interpolator(keyframes)[source]#

Step interpolator for keyframes.

This is a simple step interpolator to be used for any shape of keyframes data.

Parameters:

keyframes (dict) – Keyframe data containing timestamps and values to form the spline

Returns:

The interpolation function that take time and return interpolated value at that time.

Return type:

function

tan_cubic_spline_interpolator#

fury.gltf.tan_cubic_spline_interpolator(keyframes)[source]#

Cubic spline interpolator for keyframes using tangents. glTF contains additional tangent information for the cubic spline interpolator.

Parameters:

keyframes (dict) – Keyframe data containing timestamps and values to form the cubic spline curve.

Returns:

The interpolation function that take time and return interpolated value at that time.

Return type:

function

write_accessor#

fury.gltf.write_accessor(gltf, bufferview, byte_offset, comp_type, count, accssor_type, max=None, min=None)[source]#

Write accessor in the gltf.

Parameters:
  • gltf (GLTF2) –

    Pygltflib GLTF2 objecomp_type

    bufferview: int

    BufferView Index

  • byte_offset (int) – ByteOffset of the accessor

  • comp_type (type) – Type of a single component

  • count (int) – Elements count of the accessor

  • accssor_type (type) – Type of the accessor(SCALAR, VEC2, VEC3, VEC4)

  • max (ndarray, optional) – Maximum elements of an array

  • min (ndarray, optional) – Minimum elements of an array

write_buffer#

fury.gltf.write_buffer(gltf, byte_length, uri)[source]#

Write buffer int the gltf

Parameters:
  • gltf (GLTF2) – Pygltflib GLTF2 object

  • byte_length (int) – Length of the buffer

  • uri (str) – Path to the external .bin file.

write_bufferview#

fury.gltf.write_bufferview(gltf, buffer, byte_offset, byte_length, byte_stride=None)[source]#

Write bufferview in the gltf.

Parameters:
  • gltf (GLTF2) – Pygltflib GLTF2 object

  • buffer (int) – Buffer index

  • byte_offset (int) – Byte offset of the bufferview

  • byte_length (int) – Byte length ie, Length of the data we want to get from the buffer

  • byte_stride (int, optional) – Byte stride of the bufferview.

write_camera#

fury.gltf.write_camera(gltf, camera)[source]#

Create and add camera.

Parameters:
  • gltf (GLTF2) – Pygltflib GLTF2 object.

  • camera (vtkCamera) – scene camera.

write_material#

fury.gltf.write_material(gltf, basecolortexture: int, uri: str)[source]#

Write Material, Images and Textures

Parameters:
  • gltf (GLTF2) – Pygltflib GLTF2 object.

  • basecolortexture (int) – BaseColorTexture index.

  • uri (str) – BaseColorTexture uri.

write_mesh#

fury.gltf.write_mesh(gltf, primitives)[source]#

Create mesh and add primitive.

Parameters:
  • gltf (GLTF2) – Pygltflib GLTF2 object.

  • primitives (list) – List of Primitive object.

write_node#

fury.gltf.write_node(gltf, mesh_id=None, camera_id=None)[source]#

Create node

Parameters:
  • gltf (GLTF2) – Pygltflib GLTF2 object

  • mesh_id (int, optional) – Mesh index

  • camera_id (int, optional) – Camera index.

write_scene#

fury.gltf.write_scene(gltf, nodes)[source]#

Create scene

Parameters:
  • gltf (GLTF2) – Pygltflib GLTF2 object

  • nodes (list) – List of node indices.