Yes, you are right, the distance is constant. Only when the surfacecolor is a general function of (x,y,z), it changes during the rotation.
I experimented a similar approach as your, and it works. Compare the code below with your code and eventually you could detect what is wrong.
import numpy as np
from numpy import sqrt
import plotly.graph_objects as go
def rot3d(alpha,beta,gamma): #planar rotation of alpha radians
return np.array([[np.cos(alpha)*np.cos(beta), np.cos(alpha)*np.sin(beta)*np.sin(gamma)-np.sin(alpha)*np.cos(gamma), np.cos(alpha)*np.sin(beta)*np.cos(gamma)+np.sin(alpha)*np.sin(gamma)],
[np.sin(alpha)*np.cos(beta), np.sin(alpha)*np.sin(beta)*np.sin(gamma)+np.cos(alpha)*np.cos(gamma), np.sin(alpha)*np.sin(beta)*np.cos(gamma)-np.cos(alpha)*np.sin(gamma)],
[-np.sin(beta), np.cos(beta)*np.sin(gamma), np.cos(beta)*np.cos(gamma)]])
u = np.linspace(0, 2*np.pi, 50)
v = np.linspace(-1, 1, 8)
u,v = np.meshgrid(u,v)
tp = 1 + 0.5*v*np.cos(u/2.)
x = tp*np.cos(u)
y = tp*np.sin(u)
z = 0.5*v*np.sin(u/2.)
dist = sqrt(x**2+y**2+z**2)
fig= go.Figure(go.Surface(x=x, y=y, z=z,
surfacecolor=dist,
colorscale='balance',
colorbar_thickness=25))
m, n = x.shape
X = x.flatten()
Y= y.flatten()
Z= z.flatten()
xyz = np.vstack((X,Y,Z))
T = np.linspace(0,2*np.pi, 36)
frames =[]
for t in T:
xf, yf, zf = rot3d(t, np.pi/4, 0) @ xyz
xs, ys, zs = xf.reshape((m,n)), yf.reshape((m,n)), zf.reshape((m,n))
#ds = sqrt(xs**2+ys**2+zs**2)
frames.append(go.Frame(data=[go.Surface(x=xs, y=ys, z=zs, surfacecolor=dist )]))
fig.update(frames=frames)
fig.update_scenes(xaxis_visible=False, yaxis_visible=False, zaxis_visible=False)
#camera_eye=dict(x=1.5, y=1.5, z=1))
fig.update_layout(
title='Animation Test',
width=600,
height=600,
updatemenus=[dict(type='buttons',
showactive=False,
y=1,
x=0.8,
xanchor='left',
yanchor='bottom',
pad=dict(t=45, r=10),
buttons=[dict(label='Play',
method='animate',
args=[None, dict(frame=dict(duration=5, redraw=True),
transition=dict(duration=0),
fromcurrent=True,
mode='immediate'
)]
)
]
)
]
)
Maybe either your data definition or its handling led to the weird surface texture.