{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from k3d import K3D\n", "from ipywidgets import interact, IntSlider\n", "\n", "width = height = length = 3\n", "\n", "color_map = (0xFF0000, 0x00FF00)\n", "voxels = (1,) * width * height * length\n", "obj = K3D.voxels(voxels, color_map, width=width, height=height, length=length)\n", "\n", "plot = K3D(voxel_paint_color=2)\n", "plot += obj\n", "\n", "@interact(color=IntSlider(value=plot.voxel_paint_color, min=0, max=len(color_map)))\n", "def color(color):\n", " plot.voxel_paint_color = color\n", "\n", "plot.display()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "obj.voxels.flatten() # initial data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Edit object (add/remove some voxels)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "obj.fetch_data() # this is an async operation" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "obj.voxels.flatten() # updated data" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }