jupyter-widgets / pythreejs

A Jupyter - Three.js bridge
https://pythreejs.readthedocs.io
Other
936 stars 185 forks source link

PythreeJs cannot render more than 1000 objects if you use example helper #279

Open TakodaS opened 5 years ago

TakodaS commented 5 years ago

This may be a trivial issue but I took a bit of time to sort it out and maybe this will save someone else some time.

If you use use_example_model_ids() as is done in many of the pythreejs examples, you are limited to only being able to render 1000 objects on the screen because the iterator that creates new ids for each object only goes up to 1000.

import pythreejs as p3
p3._example_helper.use_example_model_ids()
upper=1000
for i in range(upper):
    geometry = p3.SphereBufferGeometry(1.5,6,6)

will fail with a StopIterationError however any lower value of upper will work. This is because the 1000 object id limit is hard coded in _example_helper.py. In order to render more models, simply remove p3._example_helper.use_example_model_ids()

Sorry if this is trivial but I wasted a bit of time over it and thought it was good to report. What is the use of example model ids anyway?

vidartf commented 5 years ago

@TakodaS All the helper does is give deterministic model IDs for the widgets. As the example notebooks are stored in the repo with the widget data embedded, this prevents churn on the model IDs every time they are regenerated. It is not meant for use outside the example notebooks. If you would want to do a PR where a comment is added to the code to better highlight this, I'd appreciate it !