Skip to content

Commit 0a95fae

Browse files
committed
Fix line demo
1 parent 905fbb6 commit 0a95fae

File tree

2 files changed

+22
-102
lines changed

2 files changed

+22
-102
lines changed

examples/Examples.ipynb

Lines changed: 21 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"metadata": {
77
"collapsed": true
88
},
@@ -24,19 +24,9 @@
2424
},
2525
{
2626
"cell_type": "code",
27-
"execution_count": 2,
27+
"execution_count": null,
2828
"metadata": {},
29-
"outputs": [
30-
{
31-
"data": {
32-
"application/vnd.jupyter.widget-view+json": {
33-
"model_id": "5a0317efcb07469392f4d41f1dad3b59"
34-
}
35-
},
36-
"metadata": {},
37-
"output_type": "display_data"
38-
}
39-
],
29+
"outputs": [],
4030
"source": [
4131
"ball = Mesh(geometry=SphereGeometry(radius=1), \n",
4232
" material=LambertMaterial(color='red'),\n",
@@ -56,7 +46,7 @@
5646
},
5747
{
5848
"cell_type": "code",
59-
"execution_count": 3,
49+
"execution_count": null,
6050
"metadata": {
6151
"collapsed": true
6252
},
@@ -67,7 +57,7 @@
6757
},
6858
{
6959
"cell_type": "code",
70-
"execution_count": 4,
60+
"execution_count": null,
7161
"metadata": {
7262
"collapsed": true
7363
},
@@ -91,30 +81,11 @@
9181
},
9282
{
9383
"cell_type": "code",
94-
"execution_count": 5,
84+
"execution_count": null,
9585
"metadata": {
9686
"scrolled": true
9787
},
98-
"outputs": [
99-
{
100-
"data": {
101-
"application/vnd.jupyter.widget-view+json": {
102-
"model_id": "dbbdb66ec0214df4ae0a2b8af5f483a5"
103-
}
104-
},
105-
"metadata": {},
106-
"output_type": "display_data"
107-
},
108-
{
109-
"data": {
110-
"application/vnd.jupyter.widget-view+json": {
111-
"model_id": "4149a2737a234f1db7c3813346685f5e"
112-
}
113-
},
114-
"metadata": {},
115-
"output_type": "display_data"
116-
}
117-
],
88+
"outputs": [],
11889
"source": [
11990
"nx, ny = (20, 20)\n",
12091
"xmax=1\n",
@@ -162,7 +133,7 @@
162133
},
163134
{
164135
"cell_type": "code",
165-
"execution_count": 6,
136+
"execution_count": null,
166137
"metadata": {
167138
"collapsed": true
168139
},
@@ -182,19 +153,9 @@
182153
},
183154
{
184155
"cell_type": "code",
185-
"execution_count": 7,
156+
"execution_count": null,
186157
"metadata": {},
187-
"outputs": [
188-
{
189-
"data": {
190-
"application/vnd.jupyter.widget-view+json": {
191-
"model_id": "82d74882be1a40abaa66bc448cd47ae1"
192-
}
193-
},
194-
"metadata": {},
195-
"output_type": "display_data"
196-
}
197-
],
158+
"outputs": [],
198159
"source": [
199160
"import numpy as np\n",
200161
"from scipy import ndimage\n",
@@ -238,19 +199,9 @@
238199
},
239200
{
240201
"cell_type": "code",
241-
"execution_count": 8,
202+
"execution_count": null,
242203
"metadata": {},
243-
"outputs": [
244-
{
245-
"data": {
246-
"application/vnd.jupyter.widget-view+json": {
247-
"model_id": "0912fdee6b9f492e9f0d20d410b7fd66"
248-
}
249-
},
250-
"metadata": {},
251-
"output_type": "display_data"
252-
}
253-
],
204+
"outputs": [],
254205
"source": [
255206
"# On windows, linewidth of the material has no effect\n",
256207
"size = 4\n",
@@ -260,14 +211,13 @@
260211
" [0, size, 0],\n",
261212
" [0, 0, 0],\n",
262213
" [0, 0, size]],\n",
263-
" faces=[[0,1,2],[2,3,1]],\n",
264214
" colors = ['red', 'red', 'green', 'green', 'white', 'orange'])\n",
265-
"lines = Mesh(geometry=linesgeom, \n",
266-
" material=BasicMaterial(linewidth=5, vertexColors='VertexColors'), \n",
215+
"lines = Line(geometry=linesgeom, \n",
216+
" material=LineBasicMaterial(linewidth=5, vertexColors='VertexColors'), \n",
267217
" type='LinePieces')\n",
268218
"scene = Scene(children=[lines, DirectionalLight(color='#ccaabb', position=[0,10,0]),AmbientLight(color='#cccccc')])\n",
269219
"c = PerspectiveCamera(position=[0, 10, 10])\n",
270-
"renderer = Renderer(camera=c, scene = scene, controls=[OrbitControls(controlling=c)])\n",
220+
"renderer = Renderer(camera=c, background='black', background_opacity=1, scene = scene, controls=[OrbitControls(controlling=c)])\n",
271221
"display(renderer)"
272222
]
273223
},
@@ -285,19 +235,9 @@
285235
},
286236
{
287237
"cell_type": "code",
288-
"execution_count": 9,
238+
"execution_count": null,
289239
"metadata": {},
290-
"outputs": [
291-
{
292-
"data": {
293-
"application/vnd.jupyter.widget-view+json": {
294-
"model_id": "59e7bbdd8d70458f8fdb9cc94750f1c8"
295-
}
296-
},
297-
"metadata": {},
298-
"output_type": "display_data"
299-
}
300-
],
240+
"outputs": [],
301241
"source": [
302242
"f = \"\"\"\n",
303243
"function f(origu,origv) {\n",
@@ -336,19 +276,9 @@
336276
},
337277
{
338278
"cell_type": "code",
339-
"execution_count": 11,
279+
"execution_count": null,
340280
"metadata": {},
341-
"outputs": [
342-
{
343-
"data": {
344-
"application/vnd.jupyter.widget-view+json": {
345-
"model_id": "a8630625d64d4f3f82d1a707b97d809d"
346-
}
347-
},
348-
"metadata": {},
349-
"output_type": "display_data"
350-
}
351-
],
281+
"outputs": [],
352282
"source": [
353283
"from pythreejs import *\n",
354284
"import numpy as np\n",
@@ -406,19 +336,9 @@
406336
},
407337
{
408338
"cell_type": "code",
409-
"execution_count": 13,
339+
"execution_count": null,
410340
"metadata": {},
411-
"outputs": [
412-
{
413-
"data": {
414-
"application/vnd.jupyter.widget-view+json": {
415-
"model_id": "7ab6910f90c24b52bfc1a9146e55f948"
416-
}
417-
},
418-
"metadata": {},
419-
"output_type": "display_data"
420-
}
421-
],
341+
"outputs": [],
422342
"source": [
423343
"from pythreejs import *\n",
424344
"import numpy as np\n",

pythreejs/pythreejs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ class PlainGeometry(Geometry):
273273

274274
# TODO: vertices: numpy shape (*, 3), dtype float32
275275
vertices = Array(dtype='float32').tag(sync=True, **array_serialization).valid(shape_constraints(None,3))
276-
faces = Array(dtype='uint32').tag(sync=True, **array_serialization).valid(shape_constraints(None,3))
276+
faces = Array(dtype='uint32', default_value=np.empty(shape=(0,3), dtype='uint32')).tag(sync=True, **array_serialization).valid(shape_constraints(None,3))
277277
# list of [[v1_r,v1_g,v1_b], [v2_r,v2_g,v2_b], [v3_r,v3_g,v3_b]] for each face
278278
faceColors = Array(dtype='float32', default_value=np.empty(shape=(0,3,3), dtype='float32')).tag(sync=True, **array_serialization).valid(shape_constraints(None, 3, 3))
279279
#vertices = List(vector3(CFloat)).tag(sync=True)

0 commit comments

Comments
 (0)