widgetti / ipyvolume

3d plotting for Python in the Jupyter notebook based on IPython widgets using WebGL
MIT License
1.95k stars 236 forks source link

`ipyvolume.save` fails to serialize `pythreejs.OrbitControls` due to +-Infinity #405

Open notEvil opened 2 years ago

notEvil commented 2 years ago

Hi,

the following code

import ipyvolume
import pythreejs
import sys

figure = ipyvolume.figure()
controls = pythreejs.OrbitControls(controlling=figure.camera)
if False:
    controls.maxAzimuthAngle = sys.float_info.max
    controls.maxDistance = sys.float_info.max
    controls.maxZoom = sys.float_info.max
    controls.minAzimuthAngle = -sys.float_info.max
figure.controls = controls
ipyvolume.save("./2022-02-18 min.html")

produces "JSON.parse: unexpected character at line 417 column 28 of the JSON data". Its because the object contains a couple of +-Infinity. With if True the error disappears.

notEvil commented 2 years ago

There is https://github.com/jupyter-widgets/pythreejs/issues/366, looks like a pythreejs issue spilling over