ipv.view() sometimes produces skewed result
I observe a strange behavior for ipv.view() depending on the number of cells I use. This code in a single Jupyter cell works as expected, showing a "straight" empty cube:
import ipyvolume as ipv
fig = ipv.figure()
ipv.view(20, 20)
ipv.view(0, 0)
ipv.show()
But this code in two different cells produces a skewed cube:
import ipyvolume as ipv
fig = ipv.figure()
ipv.show()
ipv.view(20, 20)
ipv.view(0, 0)
Hi,
same issue here #294
My workaround atm:
# Reset View
ipv.view(0, 0, 2.)
f.camera.rotation = (0, 0, 0, 'XYZ')
f.camera.up = (0,0,1)
# Set desired View
ipv.view(15, 20, 2.)
I have noticed it is sometimes a difference if a call view() before or after show().
lso as soon as I start to rotate the figure with the mouse, the view() command does this skewed stuff.
Workaround is not perfect. If I execute
ipv.view(0, 0, 2.2)
f.camera.rotation = (0, 0, 0, 'XYZ')
f.camera.up = (0,0,1)
ipv.view(15, 30, 2.2) #<-------- THIS ONE is the issue
again and again, the figure is skewed every second time.
Here a the camera parameters after 2 consecutive executions of the call above. They are obviouly not identical.
Correct Results
{ '_model_module': 'jupyter-threejs',
'_model_module_version': '^2.1.0',
'_model_name': 'PerspectiveCameraModel',
'_msg_callbacks': <ipywidgets.widgets.widget.CallbackDispatcher object at 0x0000026D2B67E348>,
'_property_lock': {},
'_view_count': None,
'_view_module': None,
'_view_module_version': '',
'_view_name': None,
'aspect': 1.3333333333333333,
'castShadow': False,
'children': (),
'comm': <ipykernel.comm.comm.Comm object at 0x0000026D2B618948>,
'far': 2000.0,
'focus': 10.0,
'fov': 45.0,
'frustumCulled': True,
'keys': [ '_model_module', '_model_module_version', '_model_name',
'_view_count', '_view_module', '_view_module_version',
'_view_name', 'aspect', 'castShadow', 'children', 'far',
'focus', 'fov', 'frustumCulled', 'matrix', 'matrixAutoUpdate',
'matrixWorld', 'matrixWorldInverse', 'matrixWorldNeedsUpdate',
'modelViewMatrix', 'name', 'near', 'normalMatrix', 'position',
'projectionMatrix', 'quaternion', 'receiveShadow',
'renderOrder', 'rotation', 'scale', 'type', 'up', 'visible',
'zoom'],
'matrix': ( 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,
0.49311650969242943, 1.0999999999999999, 1.8403358682231779,
1.0),
'matrixAutoUpdate': True,
'matrixWorld': ( 1.0, 0.0, 0.0, 0.0, 0.0, 0.9999999999995,
1.0000000000842675e-06, 0.0, 0.0,
-1.0000000000842675e-06, 0.9999999999995, 0.0, 0.0,
-2.0000000001685336e-06, 1.999999999998999, 1.0),
'matrixWorldInverse': ( 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0,
1.0, 0.0, -0.49311650969242943,
-1.0999999999999999, -1.8403358682231779, 1.0),
'matrixWorldNeedsUpdate': False,
'modelViewMatrix': ( 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0, 0.0, 1.0),
'name': '',
'near': 0.1,
'normalMatrix': (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0),
'position': (0.49311650969242943, 1.0999999999999999, 1.8403358682231779),
'projectionMatrix': ( 1.8106601717798214, 0.0, 0.0, 0.0, 0.0,
2.4142135623730954, 0.0, 0.0, 0.0, 0.0,
-1.00010000500025, -1.0, 0.0, 0.0,
-0.200010000500025, 0.0),
'quaternion': (0.0, 0.0, 0.0, 1.0),
'receiveShadow': False,
'renderOrder': 0,
'rotation': (0.0, 0.0, 0.0, 'XYZ'),
'scale': (1.0, 1.0, 1.0),
'type': 'PerspectiveCamera',
'up': (0.0, 0.0, 1.0),
'visible': True,
'zoom': 1.0}
Wrong Result
{ '_model_module': 'jupyter-threejs',
'_model_module_version': '^2.1.0',
'_model_name': 'PerspectiveCameraModel',
'_msg_callbacks': <ipywidgets.widgets.widget.CallbackDispatcher object at 0x0000026D2B67E348>,
'_property_lock': {},
'_view_count': None,
'_view_module': None,
'_view_module_version': '',
'_view_name': None,
'aspect': 1.3333333333333333,
'castShadow': False,
'children': (),
'comm': <ipykernel.comm.comm.Comm object at 0x0000026D2B618948>,
'far': 2000.0,
'focus': 10.0,
'fov': 45.0,
'frustumCulled': True,
'keys': [ '_model_module', '_model_module_version', '_model_name',
'_view_count', '_view_module', '_view_module_version',
'_view_name', 'aspect', 'castShadow', 'children', 'far',
'focus', 'fov', 'frustumCulled', 'matrix', 'matrixAutoUpdate',
'matrixWorld', 'matrixWorldInverse', 'matrixWorldNeedsUpdate',
'modelViewMatrix', 'name', 'near', 'normalMatrix', 'position',
'projectionMatrix', 'quaternion', 'receiveShadow',
'renderOrder', 'rotation', 'scale', 'type', 'up', 'visible',
'zoom'],
'matrix': ( 0.9890190086314491, 0.14778836410782017, 0.0, 0.0,
-0.14778836410782017, 0.9890190086314491, 0.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.49311650969242943, 1.0999999999999999,
1.8403358682231779, 1.0),
'matrixAutoUpdate': True,
'matrixWorld': ( 1.0, 0.0, 0.0, 0.0, 0.0, 0.9999999999995,
1.0000000000842675e-06, 0.0, 0.0,
-1.0000000000842675e-06, 0.9999999999995, 0.0, 0.0,
-2.0000000001685336e-06, 1.999999999998999, 1.0),
'matrixWorldInverse': ( 0.9890190086314491, -0.14778836410782017, 0.0,
0.0, 0.14778836410782017, 0.9890190086314491, 0.0,
0.0, 0.0, 0.0, 1.0, 0.0, -0.6502688020744091,
-1.0150440272125916, -1.8403358682231779, 1.0),
'matrixWorldNeedsUpdate': False,
'modelViewMatrix': ( 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0, 0.0, 1.0),
'name': '',
'near': 0.1,
'normalMatrix': (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0),
'position': (0.49311650969242943, 1.0999999999999999, 1.8403358682231779),
'projectionMatrix': ( 1.8106601717798214, 0.0, 0.0, 0.0, 0.0,
2.4142135623730954, 0.0, 0.0, 0.0, 0.0,
-1.00010000500025, -1.0, 0.0, 0.0,
-0.200010000500025, 0.0),
- 'quaternion': (0.0, 0.0, 0.07409787908081751, 0.9972509735847465),
'receiveShadow': False,
'renderOrder': 0,
- 'rotation': (0.0, 0.0, 0.1483317056806517, 'XYZ'),
'scale': (1.0, 1.0, 1.0),
'type': 'PerspectiveCamera',
'up': (0.0, 0.0, 1.0),
'visible': True,
'zoom': 1.0}
Found another wired behavior:
If called directly after figure.show(), the resulting rotation is totally wrong. If I add a time.pause(0.5) between show and view, the result is correct.