Skip to content

Commit 1a5248b

Browse files
authored
Merge pull request #94 from vidartf/auto-gen-cleanup
Autogen cleanup
2 parents 6c47d0c + f35729d commit 1a5248b

21 files changed

+1061
-737
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ node_modules/
99

1010
# Compiled javascript
1111
pythreejs/static/
12+
pythreejs/staticlab/
1213

1314
# OS X
1415
.DS_Store
16+
17+
18+
*_autogen.py
19+
*.autogen.js
20+
js/src/**/index.js
21+
pythreejs/**/__init__.py

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
recursive-include pythreejs/static *.*
2+
recursive-include pythreejs/staticlab *.*

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ pythreejs/traits.py
6767
# Overridden classes
6868
js/src/core/Object3D.js
6969
js/src/textures/DataTexture.js
70-
js/src/textures/ImageTexture.js # custom classed created to ease image texture loading
7170
js/src/renderers/WebGLRenderer.js
7271
pythreejs/core/Object3D.py
7372
pythreejs/renderers/WebGLRenderer.py
7473
74+
# Custom classes
75+
js/src/textures/ImageTexture.js # created to ease image texture loading
76+
js/src/textures/TextTexture.js # created to ease creation of textures of rasterized text
77+
7578
# Updated examples notesbooks
7679
examples/Examples.ipynb
7780
examples/Geometries.ipynb
@@ -94,6 +97,12 @@ js/src/examples/renderers/Projector.js
9497

9598
TODO: Everything below here is probably outdated.
9699

100+
Getting Started
101+
---------------
102+
103+
### Try it online with [Binder](http://mybinder.org/)
104+
105+
[![Binder](http://mybinder.org/badge.svg)](http://mybinder.org:/repo/jovyan/pythreejs/notebooks/examples)
97106

98107
Installation
99108
------------
@@ -124,5 +133,3 @@ $ jupyter nbextension enable --py --sys-prefix pythreejs
124133
Note for developers: the `--symlink` argument on Linux or OS X allows one to
125134
modify the JavaScript code in-place. This feature is not available
126135
with Windows.
127-
128-

environment.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: pythreejs
2+
channels:
3+
- nodefaults
4+
- conda-forge
5+
dependencies:
6+
- pythreejs
7+
- matplotlib
8+
- scipy
9+
- scikit-image

examples/Examples.ipynb

Lines changed: 135 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "code",
55
"execution_count": null,
66
"metadata": {
7-
"collapsed": false
7+
"collapsed": true
88
},
99
"outputs": [],
1010
"source": [
@@ -17,19 +17,15 @@
1717
},
1818
{
1919
"cell_type": "markdown",
20-
"metadata": {
21-
"collapsed": true
22-
},
20+
"metadata": {},
2321
"source": [
2422
"# Simple sphere and text"
2523
]
2624
},
2725
{
2826
"cell_type": "code",
2927
"execution_count": null,
30-
"metadata": {
31-
"collapsed": false
32-
},
28+
"metadata": {},
3329
"outputs": [],
3430
"source": [
3531
"ball = Mesh(geometry=SphereGeometry(radius=1), \n",
@@ -52,7 +48,7 @@
5248
"cell_type": "code",
5349
"execution_count": null,
5450
"metadata": {
55-
"collapsed": false
51+
"collapsed": true
5652
},
5753
"outputs": [],
5854
"source": [
@@ -63,7 +59,7 @@
6359
"cell_type": "code",
6460
"execution_count": null,
6561
"metadata": {
66-
"collapsed": false
62+
"collapsed": true
6763
},
6864
"outputs": [],
6965
"source": [
@@ -87,7 +83,6 @@
8783
"cell_type": "code",
8884
"execution_count": null,
8985
"metadata": {
90-
"collapsed": false,
9186
"scrolled": true
9287
},
9388
"outputs": [],
@@ -140,7 +135,7 @@
140135
"cell_type": "code",
141136
"execution_count": null,
142137
"metadata": {
143-
"collapsed": false
138+
"collapsed": true
144139
},
145140
"outputs": [],
146141
"source": [
@@ -159,9 +154,7 @@
159154
{
160155
"cell_type": "code",
161156
"execution_count": null,
162-
"metadata": {
163-
"collapsed": false
164-
},
157+
"metadata": {},
165158
"outputs": [],
166159
"source": [
167160
"import numpy as np\n",
@@ -207,9 +200,7 @@
207200
{
208201
"cell_type": "code",
209202
"execution_count": null,
210-
"metadata": {
211-
"collapsed": false
212-
},
203+
"metadata": {},
213204
"outputs": [],
214205
"source": [
215206
"# On windows, linewidth of the material has no effect\n",
@@ -226,7 +217,7 @@
226217
" type='LinePieces')\n",
227218
"scene = Scene(children=[lines, DirectionalLight(color='#ccaabb', position=[0,10,0]),AmbientLight(color='#cccccc')])\n",
228219
"c = PerspectiveCamera(position=[0, 10, 10])\n",
229-
"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",
230221
"display(renderer)"
231222
]
232223
},
@@ -245,9 +236,7 @@
245236
{
246237
"cell_type": "code",
247238
"execution_count": null,
248-
"metadata": {
249-
"collapsed": false
250-
},
239+
"metadata": {},
251240
"outputs": [],
252241
"source": [
253242
"f = \"\"\"\n",
@@ -276,6 +265,126 @@
276265
"display(renderer)"
277266
]
278267
},
268+
{
269+
"cell_type": "markdown",
270+
"metadata": {},
271+
"source": [
272+
"# Indexed Geometries\n",
273+
"\n",
274+
"The PlainGeometry lets you specify vertices and faces for a surface."
275+
]
276+
},
277+
{
278+
"cell_type": "code",
279+
"execution_count": null,
280+
"metadata": {},
281+
"outputs": [],
282+
"source": [
283+
"from pythreejs import *\n",
284+
"import numpy as np\n",
285+
"from IPython.display import display\n",
286+
"\n",
287+
"vertices = np.asarray([\n",
288+
"[0, 0, 0],\n",
289+
"[0, 0, 1],\n",
290+
"[0, 1, 0],\n",
291+
"[0, 1, 1],\n",
292+
"[1, 0, 0],\n",
293+
"[1, 0, 1],\n",
294+
"[1, 1, 0],\n",
295+
"[1, 1, 1]\n",
296+
"], dtype='float32')\n",
297+
"\n",
298+
"faces = np.asarray([\n",
299+
" [0, 1, 3],\n",
300+
" [0, 2, 3],\n",
301+
" [0, 2, 4],\n",
302+
" [2, 4, 6],\n",
303+
" [0, 1, 4],\n",
304+
" [1, 4, 5],\n",
305+
" [2, 3, 6],\n",
306+
" [3, 6, 7],\n",
307+
" [1, 3, 5],\n",
308+
" [3, 5, 7],\n",
309+
" [4, 5, 6],\n",
310+
" [5, 6, 7]\n",
311+
" ])\n",
312+
"\n",
313+
"vertexcolors = np.asarray([(0,0,0), (0,0,1), (0,1,0), (1,0,0), (0,1,1), (1,0,1), (1,1,0), (1,1,1)])\n",
314+
"facecolors = [[vertexcolors[i] for i in f] for f in faces]\n",
315+
"cubeGeometry = PlainGeometry(vertices=vertices, faces=faces, faceColors = facecolors)\n",
316+
"\n",
317+
"myobjectCube = Mesh(geometry=cubeGeometry, material = LambertMaterial(vertexColors = 'VertexColors'))\n",
318+
"cCube = PerspectiveCamera(position=[3, 3, 3], fov=20,\n",
319+
" children=[DirectionalLight(color='#ffffff', position=[-3, 5, 1], intensity=0.5)])\n",
320+
"sceneCube = Scene(children=[myobjectCube, AmbientLight(color='#dddddd')])\n",
321+
"\n",
322+
"rendererCube = Renderer(camera=cCube, background='black', background_opacity=1,\n",
323+
" scene = sceneCube, controls=[OrbitControls(controlling=cCube)])\n",
324+
"\n",
325+
"display(rendererCube)"
326+
]
327+
},
328+
{
329+
"cell_type": "markdown",
330+
"metadata": {},
331+
"source": [
332+
"# Buffer Geometries\n",
333+
"\n",
334+
"The PlainBufferGeometry object uses several tricks to speed up both the transfer of data and the rendering of the data."
335+
]
336+
},
337+
{
338+
"cell_type": "code",
339+
"execution_count": null,
340+
"metadata": {},
341+
"outputs": [],
342+
"source": [
343+
"from pythreejs import *\n",
344+
"import numpy as np\n",
345+
"from IPython.display import display\n",
346+
"\n",
347+
"vertices = np.asarray([\n",
348+
"[0, 0, 0],\n",
349+
"[0, 0, 1],\n",
350+
"[0, 1, 0],\n",
351+
"[0, 1, 1],\n",
352+
"[1, 0, 0],\n",
353+
"[1, 0, 1],\n",
354+
"[1, 1, 0],\n",
355+
"[1, 1, 1]\n",
356+
"], dtype='float32')\n",
357+
"\n",
358+
"faces = np.asarray([\n",
359+
" [0, 1, 3],\n",
360+
" [0, 2, 3],\n",
361+
" [0, 2, 4],\n",
362+
" [2, 4, 6],\n",
363+
" [0, 1, 4],\n",
364+
" [1, 4, 5],\n",
365+
" [2, 3, 6],\n",
366+
" [3, 6, 7],\n",
367+
" [1, 3, 5],\n",
368+
" [3, 5, 7],\n",
369+
" [4, 5, 6],\n",
370+
" [5, 6, 7]\n",
371+
" ])\n",
372+
"\n",
373+
"vertexcolors = np.asarray([(0,0,0), (0,0,1), (0,1,0), (1,0,0), (0,1,1), (1,0,1), (1,1,0), (1,1,1)])\n",
374+
"\n",
375+
"cubeGeometry = PlainBufferGeometry(vertices=vertices, faces=faces, colors = vertexcolors)\n",
376+
"\n",
377+
"myobjectCube = Mesh(geometry=cubeGeometry, material = LambertMaterial(vertexColors = 'VertexColors'))\n",
378+
"cCube = PerspectiveCamera(position=[3, 3, 3], fov=20,\n",
379+
" children=[DirectionalLight(color='#ffffff', position=[-3, 5, 1], intensity=0.5)])\n",
380+
"sceneCube = Scene(children=[myobjectCube, AmbientLight(color='#dddddd')])\n",
381+
"\n",
382+
"rendererCube = Renderer(camera=cCube, background='black', background_opacity=1,\n",
383+
" scene = sceneCube, controls=[OrbitControls(controlling=cCube)])\n",
384+
"\n",
385+
"display(rendererCube)"
386+
]
387+
},
279388
{
280389
"cell_type": "markdown",
281390
"metadata": {},
@@ -292,21 +401,21 @@
292401
],
293402
"metadata": {
294403
"kernelspec": {
295-
"display_name": "Python [py27]",
404+
"display_name": "Python 3",
296405
"language": "python",
297-
"name": "Python [py27]"
406+
"name": "python3"
298407
},
299408
"language_info": {
300409
"codemirror_mode": {
301410
"name": "ipython",
302-
"version": 2
411+
"version": 3
303412
},
304413
"file_extension": ".py",
305414
"mimetype": "text/x-python",
306415
"name": "python",
307416
"nbconvert_exporter": "python",
308-
"pygments_lexer": "ipython2",
309-
"version": "2.7.12"
417+
"pygments_lexer": "ipython3",
418+
"version": "3.5.2"
310419
}
311420
},
312421
"nbformat": 4,

0 commit comments

Comments
 (0)