Mesh Transition#
Mesh Transition
from pynodes import *
from pynodes.math import *
@tree
def mesh_transition(mesh1: Mesh, mesh2: Mesh, factor: Float = (0, 0, 1), smooth: Boolean = False):
with frame("Old Position"):
old_pos = mesh1.capture_vector_on_points(mesh1.position)
with frame("New Position"):
new_pos = mesh2.sample_vector_at_index(mesh2.position, mesh2.sample_nearest())
mesh1.set_position(old_pos.mix(new_pos, factor))
return mesh1.set_shade_smooth(shade_smooth=smooth & (factor < 1))