1

I have a library building on top of three.js, and I'd like to run it in a ijavascript (jupyter + ijavascript) notebook. Does anyone know if that's possible?

From what I can tell, three.js runs just fine using require('three'), but I'm having trouble attaching the renderer.

Joshua M. Moore
  • 381
  • 6
  • 20

2 Answers2

2

There is already a mature solution where you can code in a more Pythonic way using Jupyter-Widigts.

pythreejs three.js embedded in a jupyter widgit

To show a green sphere in a notebook.

ball = Mesh(geometry=SphereGeometry(radius=1), 
        material=MeshLambertMaterial(color='#00ff00'),
        position=[0, 0, 0]) 
ball

Output

pSupaNova
  • 31
  • 3
1

I came up with a solution shortly after posting the question:

var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, 300 / 150, 0.1, 1000 );

$$html$$ = `<canvas></canvas>`
var renderer = new THREE.WebGLRenderer({canvas: $$html$$});
renderer.setSize( 300, 150 );
Joshua M. Moore
  • 381
  • 6
  • 20