Spaces:
Sleeping
Sleeping
kolibril13
commited on
Commit
·
f6fad86
1
Parent(s):
e653671
add rendering button
Browse files- pages/01_widget.ipynb +63 -5
pages/01_widget.ipynb
CHANGED
|
@@ -2,9 +2,45 @@
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
-
"execution_count":
|
| 6 |
"metadata": {},
|
| 7 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
"source": [
|
| 9 |
"import bpy\n",
|
| 10 |
"from IPython.display import display\n",
|
|
@@ -32,14 +68,36 @@
|
|
| 32 |
" gltf_path.unlink()\n",
|
| 33 |
" return data\n",
|
| 34 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
"data = make_gltf_model()\n",
|
| 36 |
"\n",
|
| 37 |
"@solara.component\n",
|
| 38 |
"def Page():\n",
|
| 39 |
-
" viewer = Viewer(gltf_data=data)\n",
|
| 40 |
-
" display(viewer)\n",
|
| 41 |
-
"\n",
|
| 42 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
"Page()"
|
| 44 |
]
|
| 45 |
},
|
|
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
+
"execution_count": 9,
|
| 6 |
"metadata": {},
|
| 7 |
+
"outputs": [
|
| 8 |
+
{
|
| 9 |
+
"name": "stdout",
|
| 10 |
+
"output_type": "stream",
|
| 11 |
+
"text": [
|
| 12 |
+
"13:25:11 | ERROR: Draco mesh compression is not available because library could not be found at /Users/jan-hendrik/projects/bpy-sol-interacitve/pages/Resources/3.6/python/lib/python3.10/site-packages/libextern_draco.dylib\n",
|
| 13 |
+
"13:25:11 | INFO: Starting glTF 2.0 export\n",
|
| 14 |
+
"13:25:11 | INFO: Extracting primitive: Cube.017\n",
|
| 15 |
+
"13:25:11 | INFO: Primitives created: 1\n",
|
| 16 |
+
"13:25:11 | INFO: Finished glTF 2.0 export in 0.00244140625 s\n",
|
| 17 |
+
"\n",
|
| 18 |
+
"13:25:11 | ERROR: Draco mesh compression is not available because library could not be found at /Users/jan-hendrik/projects/bpy-sol-interacitve/pages/Resources/3.6/python/lib/python3.10/site-packages/libextern_draco.dylib\n",
|
| 19 |
+
"13:25:11 | INFO: Starting glTF 2.0 export\n",
|
| 20 |
+
"13:25:11 | INFO: Extracting primitive: Cube.018\n",
|
| 21 |
+
"13:25:11 | INFO: Primitives created: 1\n",
|
| 22 |
+
"13:25:11 | INFO: Finished glTF 2.0 export in 0.002207040786743164 s\n",
|
| 23 |
+
"\n"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"data": {
|
| 28 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 29 |
+
"model_id": "b843398fcd2449c9a3c8bdc5ae1867ec",
|
| 30 |
+
"version_major": 2,
|
| 31 |
+
"version_minor": 0
|
| 32 |
+
},
|
| 33 |
+
"text/html": [
|
| 34 |
+
"Cannot show widget. You probably want to rerun the code cell above (<i>Click in the code cell, and press Shift+Enter <kbd>⇧</kbd>+<kbd>↩</kbd></i>)."
|
| 35 |
+
],
|
| 36 |
+
"text/plain": [
|
| 37 |
+
"Cannot show ipywidgets in text"
|
| 38 |
+
]
|
| 39 |
+
},
|
| 40 |
+
"metadata": {},
|
| 41 |
+
"output_type": "display_data"
|
| 42 |
+
}
|
| 43 |
+
],
|
| 44 |
"source": [
|
| 45 |
"import bpy\n",
|
| 46 |
"from IPython.display import display\n",
|
|
|
|
| 68 |
" gltf_path.unlink()\n",
|
| 69 |
" return data\n",
|
| 70 |
"\n",
|
| 71 |
+
"\n",
|
| 72 |
+
"data = make_gltf_model()\n",
|
| 73 |
+
" \n",
|
| 74 |
+
"\n",
|
| 75 |
+
"do_render = solara.reactive(False)\n",
|
| 76 |
+
"\n",
|
| 77 |
"data = make_gltf_model()\n",
|
| 78 |
"\n",
|
| 79 |
"@solara.component\n",
|
| 80 |
"def Page():\n",
|
|
|
|
|
|
|
|
|
|
| 81 |
"\n",
|
| 82 |
+
" def render():\n",
|
| 83 |
+
" if do_render.value:\n",
|
| 84 |
+
" return data\n",
|
| 85 |
+
" \n",
|
| 86 |
+
" result = solara.use_thread(render, [do_render.value])\n",
|
| 87 |
+
" if not do_render.value:\n",
|
| 88 |
+
" solara.Button(\"Start Rendering\", on_click=lambda: do_render.set(True), color=\"orange\")\n",
|
| 89 |
+
" else:\n",
|
| 90 |
+
" if result.state == solara.ResultState.RUNNING:\n",
|
| 91 |
+
" solara.Info(\"Rendering in progress...\")\n",
|
| 92 |
+
" solara.ProgressLinear()\n",
|
| 93 |
+
" elif result.state == solara.ResultState.ERROR:\n",
|
| 94 |
+
" solara.Error(\"Rendering failed!: %s\" % result.error)\n",
|
| 95 |
+
" elif result.state == solara.ResultState.FINISHED:\n",
|
| 96 |
+
" with solara.Column():\n",
|
| 97 |
+
" solara.Success(\"Rendering complete. \")\n",
|
| 98 |
+
" if result.value:\n",
|
| 99 |
+
" viewer = Viewer(gltf_data=result.value)\n",
|
| 100 |
+
" display(viewer)\n",
|
| 101 |
"Page()"
|
| 102 |
]
|
| 103 |
},
|