CoCalc Shared FilesJUPYTER_TESTS / pythreejs-s.ipynbOpen in CoCalc with one click!
Authors: Janis Dou, John Jeng, Harald Schilly, Hal SiteTest, Hal Snyder, ℏal Snyder, William A. Stein
Views : 14
Description: demo of pythreejs - use plain jupyter server

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.

In [1]:
from pythreejs import * import numpy as np from IPython.display import display from ipywidgets import HTML, Text, Output, VBox from traitlets import link, dlink
In [2]:
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)
In [3]:
ball.geometry.radius = 0.5
In [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)
In [ ]: