File size: 6,796 Bytes
0dface2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f4ce92ce",
   "metadata": {},
   "source": [
    "# PyGfx Cube Example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f00886ec",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WGPU could not load some backends:\n",
      "jupyter: No module named 'jupyter_rfb'\n"
     ]
    },
    {
     "ename": "ImportError",
     "evalue": "WGPU Could not load any of the supported GUI backends.\n  You may need to ``pip install -U jupyter_rfb``.",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mImportError\u001b[0m                               Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[1], line 18\u001b[0m\n\u001b[1;32m     16\u001b[0m disp\u001b[38;5;241m.\u001b[39mbefore_render \u001b[38;5;241m=\u001b[39m animate\n\u001b[1;32m     17\u001b[0m disp\u001b[38;5;241m.\u001b[39mstats \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[0;32m---> 18\u001b[0m \u001b[43mdisp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mshow\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcube\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/voila-huggingface/venv/lib/python3.11/site-packages/pygfx/utils/show.py:165\u001b[0m, in \u001b[0;36mDisplay.show\u001b[0;34m(self, object, up)\u001b[0m\n\u001b[1;32m    162\u001b[0m \u001b[39m# Process renderer\u001b[39;00m\n\u001b[1;32m    164\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mrenderer \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mcanvas \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[0;32m--> 165\u001b[0m     \u001b[39mfrom\u001b[39;00m \u001b[39mwgpu\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mgui\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mauto\u001b[39;00m \u001b[39mimport\u001b[39;00m WgpuCanvas\n\u001b[1;32m    167\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mcanvas \u001b[39m=\u001b[39m WgpuCanvas()\n\u001b[1;32m    168\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mrenderer \u001b[39m=\u001b[39m WgpuRenderer(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mcanvas)\n",
      "File \u001b[0;32m~/voila-huggingface/venv/lib/python3.11/site-packages/wgpu/gui/auto.py:190\u001b[0m\n\u001b[1;32m    186\u001b[0m         \u001b[39myield\u001b[39;00m backend_name, \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00mlibname\u001b[39m}\u001b[39;00m\u001b[39m can be imported\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m    189\u001b[0m \u001b[39m# Load!\u001b[39;00m\n\u001b[0;32m--> 190\u001b[0m module \u001b[39m=\u001b[39m select_backend()\n\u001b[1;32m    191\u001b[0m WgpuCanvas, run, call_later \u001b[39m=\u001b[39m module\u001b[39m.\u001b[39mWgpuCanvas, module\u001b[39m.\u001b[39mrun, module\u001b[39m.\u001b[39mcall_later\n",
      "File \u001b[0;32m~/voila-huggingface/venv/lib/python3.11/site-packages/wgpu/gui/auto.py:75\u001b[0m, in \u001b[0;36mselect_backend\u001b[0;34m()\u001b[0m\n\u001b[1;32m     71\u001b[0m     msg \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m  Install glfw using e.g. ``pip install -U glfw``,\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m     72\u001b[0m     msg \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m (\n\u001b[1;32m     73\u001b[0m         \u001b[39m\"\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m  or install a qt framework using e.g. ``pip install -U pyside6``.\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m     74\u001b[0m     )\n\u001b[0;32m---> 75\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mImportError\u001b[39;00m(msg) \u001b[39mfrom\u001b[39;00m \u001b[39mNone\u001b[39;00m\n",
      "\u001b[0;31mImportError\u001b[0m: WGPU Could not load any of the supported GUI backends.\n  You may need to ``pip install -U jupyter_rfb``."
     ]
    }
   ],
   "source": [
    "\n",
    "import pygfx as gfx\n",
    "import pylinalg as la\n",
    "\n",
    "cube = gfx.Mesh(\n",
    "    gfx.box_geometry(200, 200, 200),\n",
    "    gfx.MeshPhongMaterial(color=\"#336699\"),\n",
    ")\n",
    "\n",
    "\n",
    "def animate():\n",
    "    rot = la.quat_from_euler((0.005, 0.01), order=\"XY\")\n",
    "    cube.local.rotation = la.quat_mul(rot, cube.local.rotation)\n",
    "\n",
    "\n",
    "disp = gfx.Display()\n",
    "disp.before_render = animate\n",
    "disp.stats = True\n",
    "disp.show(cube)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cc0ca8b1",
   "metadata": {},
   "outputs": [
    {
     "ename": "",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31mJupyter cannot be started. Error attempting to locate Jupyter: Running cells with 'Python 3.11.6 ('venv': venv)' requires jupyter and notebook package.\n",
      "\u001b[1;31mRun the following command to install 'jupyter and notebook' into the Python environment. \n",
      "\u001b[1;31mCommand: 'python -m pip install jupyter notebook -U\n",
      "\u001b[1;31mor\n",
      "\u001b[1;31mconda install jupyter notebook -U'\n",
      "Click <a href='https://aka.ms/installJupyterForVSCode'>here</a> for more info."
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c964ed64",
   "metadata": {},
   "outputs": [
    {
     "ename": "",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31mJupyter cannot be started. Error attempting to locate Jupyter: Running cells with 'Python 3.11.6 ('venv': venv)' requires jupyter and notebook package.\n",
      "\u001b[1;31mRun the following command to install 'jupyter and notebook' into the Python environment. \n",
      "\u001b[1;31mCommand: 'python -m pip install jupyter notebook -U\n",
      "\u001b[1;31mor\n",
      "\u001b[1;31mconda install jupyter notebook -U'\n",
      "Click <a href='https://aka.ms/installJupyterForVSCode'>here</a> for more info."
     ]
    }
   ],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.11.6 ('venv': venv)",
   "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.11.6"
  },
  "vscode": {
   "interpreter": {
    "hash": "74b572f558bec4b6e8ae72dcaeb196eb4b5b3785afbb5ff05f58614eacab3cc1"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}