kolibril13 commited on
Commit
97207ee
1 Parent(s): cb29d05

add anoter example

Browse files
pages/01_minimal.ipynb CHANGED
@@ -2,9 +2,81 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": null,
6
  "metadata": {},
7
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  "source": [
9
  "import solara\n",
10
  "import bpy\n",
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 1,
6
  "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stdout",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "Device with name Apple M1 supports metal minimum requirements\n"
13
+ ]
14
+ },
15
+ {
16
+ "data": {
17
+ "application/vnd.jupyter.widget-view+json": {
18
+ "model_id": "1aef7aecdfaa46b6951f529d7650bf05",
19
+ "version_major": 2,
20
+ "version_minor": 0
21
+ },
22
+ "text/html": [
23
+ "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>)."
24
+ ],
25
+ "text/plain": [
26
+ "Cannot show ipywidgets in text"
27
+ ]
28
+ },
29
+ "metadata": {},
30
+ "output_type": "display_data"
31
+ },
32
+ {
33
+ "name": "stdout",
34
+ "output_type": "stream",
35
+ "text": [
36
+ "METAL API - DETECTED GPU: Apple M1\n",
37
+ "Fra:1 Mem:14.55M (Peak 15.20M) | Time:00:00.08 | Syncing Light\n",
38
+ "Fra:1 Mem:14.55M (Peak 15.20M) | Time:00:00.08 | Syncing Camera\n",
39
+ "Fra:1 Mem:14.56M (Peak 15.20M) | Time:00:00.08 | Syncing Torus\n",
40
+ "Fra:1 Mem:15.94M (Peak 15.94M) | Time:00:00.09 | Rendering 1 / 64 samples\n",
41
+ "Fra:1 Mem:15.16M (Peak 15.94M) | Time:00:00.19 | Rendering 26 / 64 samples\n",
42
+ "Fra:1 Mem:15.16M (Peak 15.94M) | Time:00:00.25 | Rendering 51 / 64 samples\n",
43
+ "Fra:1 Mem:15.16M (Peak 15.94M) | Time:00:00.28 | Rendering 64 / 64 samples\n",
44
+ "Saved: 'test.png'\n",
45
+ " Time: 00:00.37 (Saving: 00:00.09)\n",
46
+ "\n",
47
+ "Fra:1 Mem:15.90M (Peak 15.90M) | Time:00:00.00 | Syncing Light\n",
48
+ "Fra:1 Mem:15.90M (Peak 15.90M) | Time:00:00.00 | Syncing Camera\n",
49
+ "Fra:1 Mem:15.90M (Peak 15.90M) | Time:00:00.00 | Syncing Torus.001\n",
50
+ "Fra:1 Mem:17.25M (Peak 17.25M) | Time:00:00.00 | Rendering 1 / 64 samples\n",
51
+ "Fra:1 Mem:16.34M (Peak 17.25M) | Time:00:00.08 | Rendering 26 / 64 samples\n",
52
+ "Fra:1 Mem:16.34M (Peak 17.25M) | Time:00:00.14 | Rendering 51 / 64 samples\n",
53
+ "Fra:1 Mem:16.34M (Peak 17.25M) | Time:00:00.17 | Rendering 64 / 64 samples\n",
54
+ "Saved: 'test.png'\n",
55
+ " Time: 00:00.18 (Saving: 00:00.00)\n",
56
+ "\n",
57
+ "Fra:1 Mem:17.07M (Peak 17.07M) | Time:00:00.00 | Syncing Light\n",
58
+ "Fra:1 Mem:17.07M (Peak 17.07M) | Time:00:00.00 | Syncing Camera\n",
59
+ "Fra:1 Mem:17.08M (Peak 17.08M) | Time:00:00.00 | Syncing Torus.002\n",
60
+ "Fra:1 Mem:18.42M (Peak 18.42M) | Time:00:00.00 | Rendering 1 / 64 samples\n",
61
+ "Fra:1 Mem:17.51M (Peak 18.42M) | Time:00:00.08 | Rendering 26 / 64 samples\n",
62
+ "Fra:1 Mem:17.57M (Peak 18.42M) | Time:00:00.14 | Rendering 51 / 64 samples\n",
63
+ "Fra:1 Mem:17.51M (Peak 18.42M) | Time:00:00.17 | Rendering 64 / 64 samples\n",
64
+ "Saved: 'test.png'\n",
65
+ " Time: 00:00.18 (Saving: 00:00.00)\n",
66
+ "\n",
67
+ "Fra:1 Mem:18.31M (Peak 18.31M) | Time:00:00.00 | Syncing Light\n",
68
+ "Fra:1 Mem:18.31M (Peak 18.31M) | Time:00:00.00 | Syncing Camera\n",
69
+ "Fra:1 Mem:18.32M (Peak 18.32M) | Time:00:00.00 | Syncing Torus.003\n",
70
+ "Fra:1 Mem:19.66M (Peak 19.66M) | Time:00:00.00 | Rendering 1 / 64 samples\n",
71
+ "Fra:1 Mem:18.69M (Peak 19.66M) | Time:00:00.08 | Rendering 26 / 64 samples\n",
72
+ "Fra:1 Mem:18.69M (Peak 19.66M) | Time:00:00.13 | Rendering 51 / 64 samples\n",
73
+ "Fra:1 Mem:18.69M (Peak 19.66M) | Time:00:00.16 | Rendering 64 / 64 samples\n",
74
+ "Saved: 'test.png'\n",
75
+ " Time: 00:00.18 (Saving: 00:00.00)\n",
76
+ "\n"
77
+ ]
78
+ }
79
+ ],
80
  "source": [
81
  "import solara\n",
82
  "import bpy\n",
pages/{02_molecule.ipynb → 02_blue.ipynb} RENAMED
@@ -2,18 +2,57 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": null,
6
  "metadata": {},
7
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  "source": [
9
  "import solara\n",
10
  "import bpy\n",
11
  "from IPython.display import Image, display\n",
12
  "\n",
13
  "light_position = solara.reactive(3)\n",
14
- "\n",
15
- "\n",
16
- "\n",
17
  "start_button = solara.reactive(False)\n",
18
  "\n",
19
  "@solara.component\n",
@@ -24,8 +63,6 @@
24
  " else:\n",
25
  " solara.Success(\"Rendering complete. \")\n",
26
  "\n",
27
- "\n",
28
- "\n",
29
  " solara.SliderInt(\"Pos:\", value=light_position, min=0, max=10)\n",
30
  " \n",
31
  " # Delete all mesh objects from the scene\n",
@@ -42,19 +79,28 @@
42
  " align=\"WORLD\",\n",
43
  " location=(0, 1, 1),\n",
44
  " )\n",
 
 
 
 
 
 
 
 
 
45
  " \n",
46
- " # # Light\n",
47
  " light = bpy.data.objects[\"Light\"]\n",
48
  " light.location = (light_position.value, 0, 2) # Position the light\n",
49
  " \n",
50
- " # # Camera\n",
51
  " camera = bpy.data.objects[\"Camera\"]\n",
52
  " camera.location = (5, -3, 4)\n",
53
  " camera.data.dof.use_dof = True\n",
54
  " camera.data.dof.focus_distance = 5\n",
55
  " camera.data.dof.aperture_fstop = 4\n",
56
  " \n",
57
- " # # Render\n",
58
  " path = \"test.png\"\n",
59
  " bpy.context.scene.render.resolution_x = 400\n",
60
  " bpy.context.scene.render.resolution_y = 200\n",
@@ -65,7 +111,7 @@
65
  " \n",
66
  " display(Image(path))\n",
67
  "\n",
68
- "Page()"
69
  ]
70
  },
71
  {
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 1,
6
  "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stdout",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "Device with name Apple M1 supports metal minimum requirements\n"
13
+ ]
14
+ },
15
+ {
16
+ "data": {
17
+ "application/vnd.jupyter.widget-view+json": {
18
+ "model_id": "058aeee5506f4eb0aed392e4bcb9c43e",
19
+ "version_major": 2,
20
+ "version_minor": 0
21
+ },
22
+ "text/html": [
23
+ "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>)."
24
+ ],
25
+ "text/plain": [
26
+ "Cannot show ipywidgets in text"
27
+ ]
28
+ },
29
+ "metadata": {},
30
+ "output_type": "display_data"
31
+ },
32
+ {
33
+ "name": "stdout",
34
+ "output_type": "stream",
35
+ "text": [
36
+ "METAL API - DETECTED GPU: Apple M1\n",
37
+ "Fra:1 Mem:14.56M (Peak 15.21M) | Time:00:00.08 | Syncing Light\n",
38
+ "Fra:1 Mem:14.56M (Peak 15.21M) | Time:00:00.08 | Syncing Camera\n",
39
+ "Fra:1 Mem:14.57M (Peak 15.21M) | Time:00:00.08 | Syncing Torus\n",
40
+ "Fra:1 Mem:15.98M (Peak 15.98M) | Time:00:00.09 | Rendering 1 / 64 samples\n",
41
+ "Fra:1 Mem:15.19M (Peak 15.98M) | Time:00:00.19 | Rendering 26 / 64 samples\n",
42
+ "Fra:1 Mem:15.19M (Peak 15.98M) | Time:00:00.24 | Rendering 51 / 64 samples\n",
43
+ "Fra:1 Mem:15.19M (Peak 15.98M) | Time:00:00.27 | Rendering 64 / 64 samples\n",
44
+ "Saved: 'test.png'\n",
45
+ " Time: 00:00.37 (Saving: 00:00.08)\n",
46
+ "\n"
47
+ ]
48
+ }
49
+ ],
50
  "source": [
51
  "import solara\n",
52
  "import bpy\n",
53
  "from IPython.display import Image, display\n",
54
  "\n",
55
  "light_position = solara.reactive(3)\n",
 
 
 
56
  "start_button = solara.reactive(False)\n",
57
  "\n",
58
  "@solara.component\n",
 
63
  " else:\n",
64
  " solara.Success(\"Rendering complete. \")\n",
65
  "\n",
 
 
66
  " solara.SliderInt(\"Pos:\", value=light_position, min=0, max=10)\n",
67
  " \n",
68
  " # Delete all mesh objects from the scene\n",
 
79
  " align=\"WORLD\",\n",
80
  " location=(0, 1, 1),\n",
81
  " )\n",
82
+ "\n",
83
+ " # Access the torus directly through the bpy.data.objects list\n",
84
+ " torus = bpy.data.objects[\"Torus\"]\n",
85
+ "\n",
86
+ " # Create a blue material and assign it to the torus\n",
87
+ " blue_mat = bpy.data.materials.new(name=\"Blue_Material\")\n",
88
+ " blue_mat.diffuse_color = (0, 0, 1, 1) # RGBA for blue\n",
89
+ " torus.data.materials.append(blue_mat)\n",
90
+ "\n",
91
  " \n",
92
+ " # Light\n",
93
  " light = bpy.data.objects[\"Light\"]\n",
94
  " light.location = (light_position.value, 0, 2) # Position the light\n",
95
  " \n",
96
+ " # Camera\n",
97
  " camera = bpy.data.objects[\"Camera\"]\n",
98
  " camera.location = (5, -3, 4)\n",
99
  " camera.data.dof.use_dof = True\n",
100
  " camera.data.dof.focus_distance = 5\n",
101
  " camera.data.dof.aperture_fstop = 4\n",
102
  " \n",
103
+ " # Render\n",
104
  " path = \"test.png\"\n",
105
  " bpy.context.scene.render.resolution_x = 400\n",
106
  " bpy.context.scene.render.resolution_y = 200\n",
 
111
  " \n",
112
  " display(Image(path))\n",
113
  "\n",
114
+ "Page()\n"
115
  ]
116
  },
117
  {
pages/03_molecule.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  bpy
2
  solara
 
 
1
  bpy
2
  solara
3
+ molecularnodes