Commit a7c516d1 authored by Dario Seyb's avatar Dario Seyb

Fixed half edge attributes (see TexturedQuadMesh example) and removed "index"...

Fixed half edge attributes (see TexturedQuadMesh example) and removed "index" property from Attribute API
parent e618caa0
......@@ -2,9 +2,59 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8ce65a6d94a04f459ce59cca1460668c",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Renderer</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Renderer(background='#dddddd', camera=PerspectiveCamera(aspect=1.5, children=(DirectionalLight(position=(-30.0, 50.0, 10.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(0.6234404316842783, 0.6234404316842783, 0.6234404316842783), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(aspect=1.5, children=(DirectionalLight(position=(-30.0, 50.0, 10.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(0.6234404316842783, 0.6234404316842783, 0.6234404316842783), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), target=(-0.016800811514258385, 0.1101529560983181, -0.0014822650700807571)), Picker(controlling=Scene(background=u'#dddddd', children=(AmbientLight(color=u'#aaaaaa', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), PerspectiveCamera(aspect=1.5, children=(DirectionalLight(position=(-30.0, 50.0, 10.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(0.6234404316842783, 0.6234404316842783, 0.6234404316842783), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=BufferGeometry(attributes={'index': <BufferAttribute shape=(14904L,), dtype=uint32>, 'normal': <BufferAttribute shape=(14904L, 3L), dtype=float32>, 'position': <BufferAttribute shape=(14904L, 3L), dtype=float32>}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'#dddddd', emissiveMap=None, envMap=None, lightMap=None, map=None, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), LineSegments(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[1., 0., 0.],\n",
" [1., 0., 0.],\n",
" [0., 1., 0.],\n",
" [0., 1., 0.],\n",
" [0., 0., 1.],\n",
" [0., 0., 1.]], dtype=float32)), 'index': BufferAttribute(array=array([0, 1, 2, 3, 4, 5], dtype=uint32), normalized=False), 'position': BufferAttribute(array=array([[-0.09438042, 0.0333099 , -0.06167917],\n",
" [ 0.0607788 , 0.0333099 , -0.06167917],\n",
" [-0.09438042, 0.0333099 , -0.06167917],\n",
" [-0.09438042, 0.18699601, -0.06167917],\n",
" [-0.09438042, 0.0333099 , -0.06167917],\n",
" [-0.09438042, 0.0333099 , 0.05871464]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', vertexColors='VertexColors'), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'[-0.094, 0.033, -0.062]')), position=(-0.09438042342662811, 0.017941287904977798, -0.0616791695356369), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.1413912245631218, 0.1413912245631218, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'0.155')), position=(0.02198899444192648, 0.033309899270534515, -0.0616791695356369), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.03842152841389179, 0.03842152841389179, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'0.154')), position=(-0.09438042342662811, 0.1485744845122099, -0.0616791695356369), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.03842152841389179, 0.03842152841389179, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'0.12')), position=(-0.09438042342662811, 0.033309899270534515, 0.028616187162697315), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.030737222731113435, 0.030737222731113435, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), event=u'dblclick', object=None)], localClippingEnabled=True, scene=Scene(background=u'#dddddd', children=(AmbientLight(color=u'#aaaaaa', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), PerspectiveCamera(aspect=1.5, children=(DirectionalLight(position=(-30.0, 50.0, 10.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(0.6234404316842783, 0.6234404316842783, 0.6234404316842783), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=BufferGeometry(attributes={'index': <BufferAttribute shape=(14904L,), dtype=uint32>, 'normal': <BufferAttribute shape=(14904L, 3L), dtype=float32>, 'position': <BufferAttribute shape=(14904L, 3L), dtype=float32>}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'#dddddd', emissiveMap=None, envMap=None, lightMap=None, map=None, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), LineSegments(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[1., 0., 0.],\n",
" [1., 0., 0.],\n",
" [0., 1., 0.],\n",
" [0., 1., 0.],\n",
" [0., 0., 1.],\n",
" [0., 0., 1.]], dtype=float32)), 'index': BufferAttribute(array=array([0, 1, 2, 3, 4, 5], dtype=uint32), normalized=False), 'position': BufferAttribute(array=array([[-0.09438042, 0.0333099 , -0.06167917],\n",
" [ 0.0607788 , 0.0333099 , -0.06167917],\n",
" [-0.09438042, 0.0333099 , -0.06167917],\n",
" [-0.09438042, 0.18699601, -0.06167917],\n",
" [-0.09438042, 0.0333099 , -0.06167917],\n",
" [-0.09438042, 0.0333099 , 0.05871464]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', vertexColors='VertexColors'), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'[-0.094, 0.033, -0.062]')), position=(-0.09438042342662811, 0.017941287904977798, -0.0616791695356369), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.1413912245631218, 0.1413912245631218, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'0.155')), position=(0.02198899444192648, 0.033309899270534515, -0.0616791695356369), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.03842152841389179, 0.03842152841389179, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'0.154')), position=(-0.09438042342662811, 0.1485744845122099, -0.0616791695356369), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.03842152841389179, 0.03842152841389179, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'0.12')), position=(-0.09438042342662811, 0.033309899270534515, 0.028616187162697315), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.030737222731113435, 0.030737222731113435, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import threevis\n",
"import openmesh as om\n",
......@@ -21,25 +71,32 @@
"\n",
"threevis.display(mesh, show_bounds=True)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 2",
"language": "python",
"name": "python3"
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3rc1"
"pygments_lexer": "ipython2",
"version": "2.7"
}
},
"nbformat": 4,
......
......@@ -2,9 +2,39 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9806ab94464a47778a64697f8e9ebb2c",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Renderer</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Renderer(background='#dddddd', camera=PerspectiveCamera(aspect=1.5, children=(DirectionalLight(position=(-30.0, 50.0, 10.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(0.6234404316842783, 0.6234404316842783, 0.6234404316842783), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(aspect=1.5, children=(DirectionalLight(position=(-30.0, 50.0, 10.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(0.6234404316842783, 0.6234404316842783, 0.6234404316842783), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), target=(-0.016800811514258385, 0.1101529560983181, -0.0014822650700807571)), Picker(controlling=Scene(background=u'#dddddd', children=(AmbientLight(color=u'#aaaaaa', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), PerspectiveCamera(aspect=1.5, children=(DirectionalLight(position=(-30.0, 50.0, 10.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(0.6234404316842783, 0.6234404316842783, 0.6234404316842783), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=BufferGeometry(attributes={'index': <BufferAttribute shape=(14904L,), dtype=uint32>, 'normal': <BufferAttribute shape=(14904L, 3L), dtype=float32>, 'position': <BufferAttribute shape=(14904L, 3L), dtype=float32>}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, clipShadows=True, clippingPlanes=(Plane(constant=0.05, normal=(1.0, 0.0, 0.0)),), color=u'#dddddd', emissiveMap=None, envMap=None, lightMap=None, map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), event=u'dblclick', object=None)], localClippingEnabled=True, scene=Scene(background=u'#dddddd', children=(AmbientLight(color=u'#aaaaaa', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), PerspectiveCamera(aspect=1.5, children=(DirectionalLight(position=(-30.0, 50.0, 10.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(0.6234404316842783, 0.6234404316842783, 0.6234404316842783), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=BufferGeometry(attributes={'index': <BufferAttribute shape=(14904L,), dtype=uint32>, 'normal': <BufferAttribute shape=(14904L, 3L), dtype=float32>, 'position': <BufferAttribute shape=(14904L, 3L), dtype=float32>}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, clipShadows=True, clippingPlanes=(Plane(constant=0.05, normal=(1.0, 0.0, 0.0)),), color=u'#dddddd', emissiveMap=None, envMap=None, lightMap=None, map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import threevis\n",
"import openmesh as om\n",
......@@ -20,30 +50,37 @@
" normals = threevis.calculateFaceNormals(vertices, faces))\n",
"\n",
"ctx = threevis.Context()\n",
"ctx.draw(mesh, shading='flat', clipping_planes=[threevis.Plane((1.0, 0.0, 0.0) , 0)])\n",
"ctx.draw(mesh, shading='flat', clipping_planes=[threevis.Plane((1.0, 0.0, 0.0) , 0.05)])\n",
"ctx.display()\n",
"\n",
"ctx.setCameraPosition([0.2, 0, 0])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 2",
"language": "python",
"name": "python3"
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3rc1"
"pygments_lexer": "ipython2",
"version": "2.7"
}
},
"nbformat": 4,
......
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Combined Camera\n",
"\n",
"A combined camera allows you to easily switch between a perspective camera and an orthographic camera."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from pythreejs import *\n",
"from IPython.display import display"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'Mesh' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-2-e4dd28f3c8c7>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmesh1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mMesh\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mSphereBufferGeometry\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m20\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m16\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m16\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mMeshPhysicalMaterial\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcolor\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'red'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mposition\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m20\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mmesh2\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mMesh\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mSphereBufferGeometry\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m20\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m16\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m16\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mMeshPhysicalMaterial\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcolor\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'green'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mposition\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m20\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'Mesh' is not defined"
]
}
],
"source": [
"mesh1 = Mesh(SphereBufferGeometry(20, 16, 16), MeshPhysicalMaterial(color='red'), position=[-20, 0, 0])\n",
"mesh2 = Mesh(SphereBufferGeometry(20, 16, 16), MeshPhysicalMaterial(color='green'), position=[20, 0, 0])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"view_width = 600\n",
"view_height = 400\n",
"camera = CombinedCamera(position=[0, 0, 60], width=view_width, height=view_height)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "27b0f193dd444c589b0a0b59c5411f9f",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Renderer</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Renderer(camera=CombinedCamera(height=400.0, position=(0.0, 0.0, 60.0), projectionMatrix=(1.4296712803397058, 0.0, 0.0, 0.0, 0.0, 2.1445069205095586, 0.0, 0.0, 0.0, 0.0, -1.00010000500025, -1.0, 0.0, 0.0, -0.200010000500025, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), type=u'PerspectiveCamera', up=(0.0, 1.0, 0.0), width=600.0), controls=[OrbitControls(controlling=CombinedCamera(height=400.0, position=(0.0, 0.0, 60.0), projectionMatrix=(1.4296712803397058, 0.0, 0.0, 0.0, 0.0, 2.1445069205095586, 0.0, 0.0, 0.0, 0.0, -1.00010000500025, -1.0, 0.0, 0.0, -0.200010000500025, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), type=u'PerspectiveCamera', up=(0.0, 1.0, 0.0), width=600.0))], scene=Scene(children=(Mesh(geometry=SphereBufferGeometry(heightSegments=16, radius=20.0, type=u'SphereBufferGeometry', widthSegments=16), material=MeshPhysicalMaterial(alphaMap=None, aoMap=None, bumpMap=None, color=u'red', defines={'PHYSICAL': ''}, displacementMap=None, emissiveMap=None, envMap=None, lightMap=None, map=None, metalnessMap=None, normalMap=None, normalScale=(1.0, 1.0), roughnessMap=None, type=u'MeshPhysicalMaterial'), position=(-20.0, 0.0, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=SphereBufferGeometry(heightSegments=16, radius=20.0, type=u'SphereBufferGeometry', widthSegments=16), material=MeshPhysicalMaterial(alphaMap=None, aoMap=None, bumpMap=None, color=u'green', defines={'PHYSICAL': ''}, displacementMap=None, emissiveMap=None, envMap=None, lightMap=None, map=None, metalnessMap=None, normalMap=None, normalScale=(1.0, 1.0), roughnessMap=None, type=u'MeshPhysicalMaterial'), position=(20.0, 0.0, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), PointLight(position=(-100.0, 100.0, 100.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), AmbientLight(intensity=0.4, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), CombinedCamera(height=400.0, position=(0.0, 0.0, 60.0), projectionMatrix=(1.4296712803397058, 0.0, 0.0, 0.0, 0.0, 2.1445069205095586, 0.0, 0.0, 0.0, 0.0, -1.00010000500025, -1.0, 0.0, 0.0, -0.200010000500025, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), type=u'PerspectiveCamera', up=(0.0, 1.0, 0.0), width=600.0)), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"key_light = PointLight(position=[-100, 100, 100])\n",
"ambient_light = AmbientLight(intensity=0.4)\n",
"scene = Scene(children=[mesh1, mesh2, key_light, ambient_light, camera])\n",
"renderer = Renderer(scene=scene, camera=camera, controls=[OrbitControls(controlling=camera)],\n",
" width=view_width, height=view_height)\n",
"display(renderer)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"camera.mode = 'orthographic'"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"camera.mode = 'perspective'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3rc1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Geometry types"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from pythreejs import *\n",
"from IPython.display import display\n",
"from math import pi"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6ac8e3b29d2b49deb8835235900fd9fe",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Preview</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Preview(child=BoxGeometry(depth=15.0, depthSegments=15, height=10.0, heightSegments=10, width=5.0, widthSegments=5), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"BoxGeometry(\n",
" width=5, \n",
" height=10, \n",
" depth=15,\n",
" widthSegments=5, \n",
" heightSegments=10,\n",
" depthSegments=15)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "56ed3497813b46b792fc0d9d32c0de1f",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Preview</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Preview(child=BoxBufferGeometry(depth=15.0, depthSegments=15, height=10.0, heightSegments=10, width=5.0, widthSegments=5), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"BoxBufferGeometry(\n",
" width=5, \n",
" height=10, \n",
" depth=15,\n",
" widthSegments=5, \n",
" heightSegments=10,\n",
" depthSegments=15)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ef0393c48feb46f4937fcdff4d4de49f",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Preview</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Preview(child=CircleGeometry(radius=10.0, segments=10, thetaLength=5.0, thetaStart=0.25), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"CircleGeometry(\n",
" radius=10,\n",
" segments=10,\n",
" thetaStart=0.25,\n",
" thetaLength=5.0)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fa2ee437d3934bfaaadec68d5a99fb1c",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Preview</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Preview(child=CircleBufferGeometry(radius=10.0, segments=10, thetaLength=5.0, thetaStart=0.25), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"CircleBufferGeometry(\n",
" radius=10,\n",
" segments=10,\n",
" thetaStart=0.25,\n",
" thetaLength=5.0)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "28ff002793ef4c36b6f4a23e4ca8c5ee",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Preview</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Preview(child=CylinderGeometry(height=15.0, heightSegments=10, radiusBottom=10.0, radiusTop=5.0), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"CylinderGeometry(\n",
" radiusTop=5, \n",
" radiusBottom=10, \n",
" height=15, \n",
" radialSegments=6, \n",
" heightSegments=10, \n",
" openEnded=False, \n",
" thetaStart=0, \n",
" thetaLength=2.0*pi)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "78a3f4576503473da775cdc758a975a9",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Preview</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Preview(child=CylinderBufferGeometry(height=15.0, heightSegments=10, radiusBottom=10.0, radiusTop=5.0), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"CylinderBufferGeometry(\n",
" radiusTop=5, \n",
" radiusBottom=10, \n",
" height=15, \n",
" radialSegments=6, \n",
" heightSegments=10, \n",
" openEnded=False, \n",
" thetaStart=0, \n",
" thetaLength=2.0*pi)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "59c8f7c9dfc64e1ea9a56cb45ff70267",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Preview</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Preview(child=DodecahedronGeometry(radius=10.0), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"DodecahedronGeometry(radius=10, detail=0, _flat=True)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"# TODO:\n",
"# EdgesGeometry(...)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# TODO:\n",
"# ExtrudeGeometry(...)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ac1d0f230a9c4cf68fee37cb225ede58",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Preview</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Preview(child=IcosahedronGeometry(radius=10.0), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"IcosahedronGeometry(radius=10, _flat=True)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a91bcd531caa44f9977f7b38c662c6b0",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Preview</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",