Closed jpanetta closed 6 years ago
Thanks, I opened a PR to fix this in #210. Are there any other attributes that need to be pushed back?
Great, thanks! I believe this is enough to restore my viewer state.
Hmm, when I actually test this, it still doesn't work for me: with the example below, I'm still reading the default (0.0, 0.0, 0.0)
value from the target
variable. By setting a breakpoint on the synchronization code you added in #210 I can see that this.obj.target
holds the correct nonzero value--it's just somehow not making it to Python.
from pythreejs import *
import time
scene = Scene(children=[AmbientLight(intensity=0.5)])
vertices = BufferAttribute(array=np.array(
[[-1.0, -1.0, 0.0],
[ 1.0, -1.0, 0.0],
[ 1.0, 1.0, 0.0]], dtype=np.float32), normalized=False)
index = BufferAttribute(array=np.array(
[[0, 1, 2]], dtype=np.uint16).ravel(), normalized=False)
geom = BufferGeometry(attributes={
'position': vertices,
'index': index,
})
surf=Mesh(geometry=geom, material=MeshLambertMaterial(color='red'))
scene.add(surf)
c = PerspectiveCamera(position=[0, 0, 1], up=[0, 0, 1])
controls = OrbitControls(controlling=c)
Renderer(camera=c, scene=scene, controls=[controls])
# Drag with the right mouse button to change the target, then run:
controls.target
Went a little quick! New attempt in #214. This time I also tested the code, and it works locally. Can you confirm?
Yes, this change fixes things for me too. Thanks again!
The
target
member variable of myTrackballControls
Python object doesn't update when I use the panning gesture (though changes made to this variable in Python are pushed to JavaScript). I made the following two attempts inTrackballControls.update
, but neither of these functions exist:How can I go about this (I'm trying to save and load the entire viewer state from my notebook)?