Error in Animation.ipynb on binder
moorepants opened this issue · 2 comments
moorepants commented
I ran the repository with binder today (tip of master) to try out the examples/Animation.ipynb. In cell 17 I get this error:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-17-56e4cb37e829> in <module>
2
3 # Set up morph targets:
----> 4 vertices = np.array(morph.attributes['position'].array)
5 for i in range(len(vertices)):
6 if vertices[i, 0] > 0:
KeyError: 'position'
Cell 17's contents:
import numpy as np
# Set up morph targets:
vertices = np.array(morph.attributes['position'].array)
for i in range(len(vertices)):
if vertices[i, 0] > 0:
vertices[i, 0] += 1
morph.morphAttributes = {'position': [
BufferAttribute(vertices),
]}
morphMesh = Mesh(morph, MeshPhongMaterial(
color='#ff3333', shininess=150, morphTargets=True))
vidartf commented
Thanks for the report. Did you see the notice in the comment in cell 16?
# This lets three.js create the geometry, then syncs back vertex positions etc.
# For this reason, you should allow for the sync to complete before executing
# the next cell.
I believe that is what you are seeing here. In summary, you will need to wait a little while after executing cell 16, to allow the buffers generated in the browser (by three.js) to sync back to the kernel. This is also why I would recommend to rely on from_geometry
as little as possible!
vidartf commented
Closing as answered.