Skip to content

Commit 9cb8fe7

Browse files
committed
Update renderer limit example
1 parent 068ca99 commit 9cb8fe7

File tree

1 file changed

+95
-75
lines changed

1 file changed

+95
-75
lines changed

examples/renderer_limit.ipynb

Lines changed: 95 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,19 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
6-
"metadata": {
7-
"collapsed": true
8-
},
5+
"execution_count": 1,
6+
"metadata": {},
97
"outputs": [],
108
"source": [
119
"from pythreejs import *\n",
12-
"from IPython.display import display\n",
10+
"from ipywidgets.widgets import HBox, VBox, Layout\n",
1311
"import time"
1412
]
1513
},
1614
{
1715
"cell_type": "code",
18-
"execution_count": null,
19-
"metadata": {
20-
"collapsed": false
21-
},
16+
"execution_count": 2,
17+
"metadata": {},
2218
"outputs": [],
2319
"source": [
2420
"# Setup our objects\n",
@@ -39,43 +35,52 @@
3935
},
4036
{
4137
"cell_type": "code",
42-
"execution_count": null,
38+
"execution_count": 3,
4339
"metadata": {
44-
"collapsed": false
40+
"scrolled": false
4541
},
46-
"outputs": [],
42+
"outputs": [
43+
{
44+
"data": {
45+
"application/vnd.jupyter.widget-view+json": {
46+
"model_id": "d40831377da84caeb759c7ccb42be35a",
47+
"version_major": "2",
48+
"version_minor": "0"
49+
},
50+
"text/plain": [
51+
"A Jupyter Widget"
52+
]
53+
},
54+
"metadata": {},
55+
"output_type": "display_data"
56+
}
57+
],
4758
"source": [
4859
"# This will render our meshes, each multiple times, resulting in 30 different renderings\n",
4960
"# Each of the 30 is a separate widget. \n",
5061
"# This test demonstrates:\n",
5162
"# - rendering shared objects in multiple places\n",
5263
"# - maintaining interactivity for all renderings\n",
5364
"# - no prior image is lost because of subsequent renderings\n",
54-
"display(mesh1, mesh2, mesh3, mesh4, mesh5, mesh6, \n",
55-
" mesh1, mesh2, mesh3, mesh4, mesh5, mesh6, \n",
56-
" mesh1, mesh2, mesh3, mesh4, mesh5, mesh6, \n",
57-
" mesh1, mesh2, mesh3, mesh4, mesh5, mesh6, \n",
58-
" mesh1, mesh2, mesh3, mesh4, mesh5, mesh6, \n",
59-
" mesh1, mesh2, mesh3, mesh4, mesh5, mesh6)"
65+
"VBox(children=[\n",
66+
" HBox(children=[\n",
67+
" PreviewWidget(mesh, _width=150, _height=150, layout=Layout(padding='2px'))\n",
68+
" for mesh in [mesh1, mesh2, mesh3, mesh4, mesh5, mesh6]])\n",
69+
" for _ in range(5)\n",
70+
"])"
6071
]
6172
},
6273
{
6374
"cell_type": "code",
6475
"execution_count": null,
65-
"metadata": {
66-
"collapsed": true
67-
},
76+
"metadata": {},
6877
"outputs": [],
69-
"source": [
70-
"time.sleep(2)"
71-
]
78+
"source": []
7279
},
7380
{
7481
"cell_type": "code",
75-
"execution_count": null,
76-
"metadata": {
77-
"collapsed": true
78-
},
82+
"execution_count": 4,
83+
"metadata": {},
7984
"outputs": [],
8085
"source": [
8186
"# Test using raw WebGLRenderer\n",
@@ -98,97 +103,112 @@
98103
},
99104
{
100105
"cell_type": "code",
101-
"execution_count": null,
102-
"metadata": {
103-
"collapsed": true
104-
},
105-
"outputs": [],
106+
"execution_count": 5,
107+
"metadata": {},
108+
"outputs": [
109+
{
110+
"data": {
111+
"application/vnd.jupyter.widget-view+json": {
112+
"model_id": "e5f7a9aac2db4f4f857ea1a5fd2d9d4f",
113+
"version_major": "2",
114+
"version_minor": "0"
115+
},
116+
"text/plain": [
117+
"A Jupyter Widget"
118+
]
119+
},
120+
"metadata": {},
121+
"output_type": "display_data"
122+
}
123+
],
106124
"source": [
107-
"scene"
125+
"Renderer(camera=cam, scene=scene, controls=[OrbitControls(cam)])"
108126
]
109127
},
110128
{
111129
"cell_type": "code",
112-
"execution_count": null,
113-
"metadata": {
114-
"collapsed": true
115-
},
130+
"execution_count": 6,
131+
"metadata": {},
116132
"outputs": [],
117133
"source": [
118134
"renderer = WebGLRenderer(width=50, height=50)\n",
119-
"r = renderer\n",
120-
"display(r, r, r, r, r,\n",
121-
" r, r, r, r, r,\n",
122-
" r, r, r, r, r,\n",
123-
" r, r, r, r, r,\n",
124-
" r, r, r, r, r)"
125-
]
126-
},
127-
{
128-
"cell_type": "code",
129-
"execution_count": null,
130-
"metadata": {
131-
"collapsed": true
132-
},
133-
"outputs": [],
134-
"source": [
135-
"time.sleep(3)"
135+
"r = renderer"
136136
]
137137
},
138138
{
139139
"cell_type": "code",
140-
"execution_count": null,
140+
"execution_count": 7,
141141
"metadata": {
142-
"collapsed": false
142+
"scrolled": true
143143
},
144-
"outputs": [],
144+
"outputs": [
145+
{
146+
"data": {
147+
"application/vnd.jupyter.widget-view+json": {
148+
"model_id": "139a07776e2e47a4a1d337a49e4092d2",
149+
"version_major": "2",
150+
"version_minor": "0"
151+
},
152+
"text/plain": [
153+
"A Jupyter Widget"
154+
]
155+
},
156+
"metadata": {},
157+
"output_type": "display_data"
158+
}
159+
],
145160
"source": [
146-
"renderer.render(scene, cam)"
161+
"hboxes = []\n",
162+
"for i in range(5):\n",
163+
" views = []\n",
164+
" for j in range(5):\n",
165+
" views.append(r)\n",
166+
" hbox = HBox(children=views)\n",
167+
" hboxes.append(hbox)\n",
168+
"vbox = VBox(children=hboxes)\n",
169+
"r.layout.padding = '5px'\n",
170+
"vbox"
147171
]
148172
},
149173
{
150174
"cell_type": "code",
151-
"execution_count": null,
152-
"metadata": {
153-
"collapsed": true
154-
},
175+
"execution_count": 9,
176+
"metadata": {},
155177
"outputs": [],
156178
"source": [
157-
"scene = Scene()\n",
158-
"scene.add(mesh2)\n",
159-
"scene.add(cam)"
179+
"for _ in range(10):\n",
180+
" renderer.render(scene, cam)\n",
181+
" time.sleep(1)"
160182
]
161183
},
162184
{
163185
"cell_type": "code",
164186
"execution_count": null,
165-
"metadata": {
166-
"collapsed": true
167-
},
187+
"metadata": {},
168188
"outputs": [],
169189
"source": []
170190
}
171191
],
172192
"metadata": {
173193
"anaconda-cloud": {},
174194
"kernelspec": {
175-
"display_name": "Python [py27]",
195+
"display_name": "Python 3",
176196
"language": "python",
177-
"name": "Python [py27]"
197+
"name": "python3"
178198
},
179199
"language_info": {
180200
"codemirror_mode": {
181201
"name": "ipython",
182-
"version": 2
202+
"version": 3
183203
},
184204
"file_extension": ".py",
185205
"mimetype": "text/x-python",
186206
"name": "python",
187207
"nbconvert_exporter": "python",
188-
"pygments_lexer": "ipython2",
189-
"version": "2.7.12"
208+
"pygments_lexer": "ipython3",
209+
"version": "3.5.3"
190210
}
191211
},
192212
"nbformat": 4,
193-
"nbformat_minor": 0
213+
"nbformat_minor": 1
194214
}

0 commit comments

Comments
 (0)