Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

demo of pythreejs - use plain jupyter server

Project: Staging
Views: 340
Kernel: Python 3 (Ubuntu Linux)

pythreejs demo in cocalc

Code cells below are from the start of the notebook here:

Do these setup steps in a .term before running this notebook:

pip3 install --user pythreejs jupyter nbextension install --user --py pythreejs jupyter nbextension enable --user --py pythreejs # it may be necessary to restart the jupyter server smc-jupyter restart

This notebook must be run using "Plain Jupyter Server", which can be launched from lower right of the Project Settings tab (wrench icon) in CoCalc.

from pythreejs import * import numpy as np from IPython.display import display from ipywidgets import HTML, Text, Output, VBox from traitlets import link, dlink
ball = Mesh(geometry=SphereGeometry(radius=1), material=MeshLambertMaterial(color='red'), position=[2, 1, 0]) c = PerspectiveCamera(position=[0, 5, 5], up=[0, 1, 0], children=[DirectionalLight(color='white', position=[3, 5, 1], intensity=0.5)]) scene = Scene(children=[ball, c, AmbientLight(color='#777777')]) renderer = Renderer(camera=c, scene=scene, controls=[OrbitControls(controlling=c)]) display(renderer)
ball.geometry.radius = 0.5
import time, math ball.material.color = '#4400dd' for i in range(1, 150, 2): ball.geometry.radius = i / 100. ball.position = [math.cos(i / 10.), math.sin(i / 50.), i / 100.] time.sleep(.05)