Closed bsekura closed 6 months ago
Hi @bsekura !
I did some test. First for all it is hard to reproduce your case without data. Many unexpected behaviour will happen if number of vertices will change during some keyframes. That is not allowed in fact (because how to interpolate values then?). If I fit to the same amount of vertices everything looks good:
My example:
import k3d
import numpy as np
N = 100
theta = np.linspace(0, 2.0 * np.pi, N)
phi = np.linspace(0, 2.0 * np.pi, N)
theta, phi = np.meshgrid(theta, phi)
def get_vertices():
global theta, phi
c, a = 2, 1
x = (c + a * np.cos(theta)) * np.cos(phi)
y = (c + a * np.cos(theta)) * np.sin(phi)
z = a * np.sin(theta)
return np.dstack([x, y, z]).astype(np.float32)
vertices1 = get_vertices()
vertices2 = get_vertices()
indices = (np.stack([
np.arange(N*N - N - 1) + 0, np.arange(N*N - N - 1) + N, np.arange(N*N - N - 1) + N + 1,
np.arange(N*N - N - 1) + 0, np.arange(N*N - N - 1) + N + 1, np.arange(N*N - N - 1) + 1
]).T).astype(np.uint32)
plot = k3d.plot()
vertices2 = vertices2 + (np.sin(vertices2 * 5) * 0.15) * np.array([0,1,0]) \
+ (np.cos(vertices2 * 3) * 0.15) * np.array([1,0,0])
vertices = {
"0.0": vertices1,
"1.0": vertices2,
"2.0": vertices1
}
mesh = k3d.mesh(vertices, indices, flat_shading=False,
shader='mesh',
attribute=phi,
color_map=k3d.matplotlib_color_maps.twilight,
color=0x00ff00)
plot += mesh
plot.colorbar_object_id = 0
plot.display()
Can you run that on your machine and tell me if you observed some problems?
@bsekura any updates?
However, the problem exists on different combinations of Python and OS: e.g. Python 3.10, Linux
Description
I am animating triangle mesh using timeseries. Basically, the keyframes are built first, as a list of
np.array(num_verts, 3)
and then packaged as dictionary:Problem
Occasionally, as the animation plays, some frames seem to contain garbled vertices, nans or infinities, which manifests itself as flickering and triangles exploding all over the place. It seems random: often it's perfect and then upon re-running the cell the animation has errors.
I have relatively large number of frames, in the range of 100-300, and at first I thought the problem was in a dictionary because of timestep being converted to string. However, I moved the dictionary creation to a preceding cell, so that it's created once. When I re-run the next cell that contains k3d plotting, sometimes results are perfect, sometimes garbled, so it seems to point to interpolation code on k3d side.
What I Did
I'm running jupyter-notebook locally, set up in a virtual env like this: