|
9 | 9 | "from pythreejs import *\n",
|
10 | 10 | "import numpy as np\n",
|
11 | 11 | "from IPython.display import display\n",
|
12 |
| - "from ipywidgets import HTML, Text\n", |
| 12 | + "from ipywidgets import HTML, Text, Output, VBox\n", |
13 | 13 | "from traitlets import link, dlink"
|
14 | 14 | ]
|
15 | 15 | },
|
|
124 | 124 | "\n",
|
125 | 125 | "# Set up picking responses:\n",
|
126 | 126 | "# Add a new marker when double-clicking:\n",
|
| 127 | + "out = Output()\n", |
127 | 128 | "def f(change):\n",
|
128 | 129 | " value = change['new']\n",
|
129 |
| - " print('Clicked on %s' % value)\n", |
| 130 | + " with out:\n", |
| 131 | + " print('Clicked on %s' % (value,))\n", |
130 | 132 | " point = Mesh(geometry=SphereGeometry(radius=0.05), \n",
|
131 | 133 | " material=MeshLambertMaterial(color='red'),\n",
|
132 | 134 | " position=value)\n",
|
|
143 | 145 | " h.value = 'Green point at (%.3f, %.3f, %.3f)' % tuple(change['new'])\n",
|
144 | 146 | "g({'new': hover_point.position})\n",
|
145 | 147 | "hover_picker.observe(g, names=['point'])\n",
|
146 |
| - "display(h)\n", |
147 |
| - "display(renderer)" |
| 148 | + "\n", |
| 149 | + "display(VBox([h, renderer, out]))" |
148 | 150 | ]
|
149 | 151 | },
|
150 | 152 | {
|
|
153 | 155 | "metadata": {},
|
154 | 156 | "outputs": [],
|
155 | 157 | "source": [
|
156 |
| - "# when we change the z values of the geometry, we need to also change the height map\n", |
157 | 158 | "surf_g.z = list((-z[::-1]).flat)\n",
|
158 | 159 | "surf.material.map = height_texture(-z[::-1])"
|
159 | 160 | ]
|
|
0 commit comments