Skip to content

Commit

Permalink
update notebooks for binder
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Mar 8, 2024
1 parent 0962274 commit f0ddad9
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 95 deletions.
18 changes: 14 additions & 4 deletions notebooks/00_basics.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"%pip install compas_notebook"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -9,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -20,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -29,7 +39,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand All @@ -44,7 +54,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "75509c7781b64199bcefa5beac0a9f19",
"model_id": "4f3f899780144ac1938a528b5025e7e9",
"version_major": 2,
"version_minor": 0
},
Expand Down
85 changes: 34 additions & 51 deletions notebooks/10_scene.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,46 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"%pip install compas_notebook"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"import compas\n",
"import compas.geometry as geometry\n",
"from compas.colors import Color\n",
"from compas.datastructures import Mesh\n",
"from compas.geometry import Box\n",
"from compas_notebook.viewer import Viewer"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"box = geometry.Box()\n",
"box = Box()\n",
"mesh = Mesh.from_obj(compas.get('tubemesh.obj'))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 35,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PyThreeJS SceneObjects registered.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "374d5f3bb0834894ba256248c4aaa0a7",
"model_id": "14f00c69ebfa47ddbe57f51eddfaadc9",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -53,13 +56,13 @@
"source": [
"viewer = Viewer()\n",
"viewer.scene.add(box, color=Color.red())\n",
"viewer.scene.add(mesh, color=Color.green())\n",
"viewer.scene.add(mesh, facecolor=Color.green(), show_edges=True)\n",
"viewer.show()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 36,
"metadata": {},
"outputs": [
{
Expand All @@ -76,16 +79,16 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 37,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"└── <TreeNode root>\n",
" ├── <TreeNode Box>\n",
" └── <TreeNode Mesh>\n"
"└── <TreeNode: ROOT>\n",
" ├── <ThreeBoxObject: Box>\n",
" └── <ThreeMeshObject: Mesh>\n"
]
}
],
Expand All @@ -95,16 +98,16 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<TreeNode root>"
"<TreeNode: ROOT>"
]
},
"execution_count": 7,
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -115,16 +118,16 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<TreeNode Box>, <TreeNode Mesh>]"
"[<ThreeBoxObject: Box>, <ThreeMeshObject: Mesh>]"
]
},
"execution_count": 8,
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -135,16 +138,16 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<TreeNode Box>"
"<ThreeBoxObject: Box>"
]
},
"execution_count": 13,
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -155,43 +158,23 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<TreeNode root>"
"<TreeNode: ROOT>"
]
},
"execution_count": 14,
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"viewer.scene.tree.root.children[0].parent"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<compas_notebook.scene.boxobject.BoxObject at 0x10f0f1f40>"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"viewer.scene.tree.root.children[0].object"
]
}
],
"metadata": {
Expand Down
35 changes: 23 additions & 12 deletions notebooks/20_geometry.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"%pip install compas_notebook"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from compas.geometry import Pointcloud\n",
"from compas.geometry import Point, Line, Polyline\n",
Expand All @@ -14,7 +24,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -27,20 +37,13 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PyThreeJS SceneObjects registered.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f99cbe15ecf74fa9b6c7307ea8d265b2",
"model_id": "1765ca6cd7b74861bda14b7a22ac7087",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -54,14 +57,22 @@
],
"source": [
"viewer = Viewer()\n",
"viewer.config.ui.sidebar.show = False\n",
"\n",
"viewer.scene.add(point, color=Color.red())\n",
"viewer.scene.add(point, color=Color.red(), pointsize=0.3)\n",
"viewer.scene.add(line)\n",
"viewer.scene.add(polyline, color=Color.blue())\n",
"viewer.scene.add(cloud, color=Color.green())\n",
"viewer.scene.add(cloud, color=Color.green(), pointsize=0.3)\n",
"\n",
"viewer.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading

0 comments on commit f0ddad9

Please sign in to comment.