{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import k3d\n", "from ipywidgets import interact, IntSlider\n", "\n", "model_matrix = [\n", " 0.9, 0.1, -0.4, 0.0,\n", " 0.0, 0.9, 0.4, 0.0,\n", " 0.4, -0.4, 0.9, 0.0,\n", " 0.0, 0.0, 0.0, 1.0\n", "]\n", "\n", "vertices = [\n", " -10.0, -15.0, 0.0,\n", " -10.0, 5.0, 0.0,\n", " 10.0, 5.0, 0.0,\n", " -10.0, -15.0, 0.0,\n", " 10.0, -15.0, 0.0,\n", " -10.0, 5.0, 0.0,\n", " 0.0, 15.0, 0.0,\n", " 10.0, 5.0, 0.0,\n", " 10.0, -15.0, 0.0\n", "]\n", "\n", "line = k3d.line((0, 0, 0, 5, 10, 15), shader=\"simple\")\n", "lines = k3d.line(vertices, model_matrix=model_matrix, color=0xff0000, width=2.5, shader=\"simple\") + line\n", "\n", "plot = k3d.plot(antialias=True, camera_auto_fit=True)\n", "plot += lines\n", "plot.display()\n", "\n", "# plot.camera_auto_fit = False # uncomment in order to keep camera at fixed distance on changes\n", "@interact(color=IntSlider(value=line.color, min=0, max=0xffffff))\n", "def update(color):\n", " line.color = color" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Not all implementations of WebGL support line width, this may not work:\n", "line.width = 5" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot -= line" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.objects" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot -= lines" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.6.5" } }, "nbformat": 4, "nbformat_minor": 1 }