diff --git a/CQ examples.ipynb b/CQ examples.ipynb
index b286fc2f..16ec05c9 100644
Binary files a/CQ examples.ipynb and b/CQ examples.ipynb differ
diff --git a/cadquery/occ_impl/jupyter_tools.py b/cadquery/occ_impl/jupyter_tools.py
index 0a27f1be..c5cae1c8 100644
--- a/cadquery/occ_impl/jupyter_tools.py
+++ b/cadquery/occ_impl/jupyter_tools.py
@@ -1,5 +1,9 @@
from OCC.Display.WebGl.x3dom_renderer import X3DExporter
+from OCC.gp import gp_Quaternion, gp_Vec
from uuid import uuid1
+from math import tan
+
+from .geom import BoundBox
N_HEADER_LINES = 10
BOILERPLATE = \
@@ -8,7 +12,7 @@ BOILERPLATE = \
-
+
{src}
@@ -20,16 +24,43 @@ BOILERPLATE = \
scr.src = 'http://www.x3dom.org/download/x3dom.js';
scr.async = false;
scr.id = 'X3DOM_JS_MODULE';
+ scr.onload = function () {{
+ x3dom.reload();
+ }}
head.insertBefore(scr, head.lastChild);
}}
- x3dom.reload();
- document.getElementById('{id}').runtime.fitAll()
+ else {{
+ x3dom.reload();
+ }}
+
+ //$(document).ready(function() {{
+ // x3dom.reload();
+ //}})
+
+ //document.getElementById('{id}').runtime.fitAll()
'''
-def add_x3d_boilerplate(src, height=400):
+#https://stackoverflow.com/questions/950087/how-do-i-include-a-javascript-file-in-another-javascript-file
+#better if else
- return BOILERPLATE.format(src=src, id=uuid1(), height=height)
+ROT = (0.77,0.3,0.55,1.28)
+ROT = (0.,0,0,1.)
+FOV = 0.2
+
+def add_x3d_boilerplate(src, height=400, center=(0,0,0), d=(0,0,15), fov=FOV, rot='{} {} {} {} '.format(*ROT)):
+
+ return BOILERPLATE.format(src=src,
+ id=uuid1(),
+ height=height,
+ x=d[0],
+ y=d[1],
+ z=d[2],
+ x0=center[0],
+ y0=center[1],
+ z0=center[2],
+ fov=fov,
+ rot=rot)
def x3d_display(shape,
vertex_shader=None,
@@ -59,4 +90,14 @@ def x3d_display(shape,
x3d_str = exporter.to_x3dfile_string()
x3d_str = '\n'.join(x3d_str.splitlines()[N_HEADER_LINES:])
- return add_x3d_boilerplate(x3d_str)
\ No newline at end of file
+ bb = BoundBox._fromTopoDS(shape)
+ d = max(bb.xlen,bb.ylen,bb.zlen)
+ c = bb.center
+
+ vec = gp_Vec(0,0,d/1.5/tan(FOV/2))
+ quat = gp_Quaternion(*ROT)
+ vec = quat*(vec) + c.wrapped
+
+ return add_x3d_boilerplate(x3d_str,
+ d=(vec.X(),vec.Y(),vec.Z()),
+ center=(c.x,c.y,c.z))
\ No newline at end of file
diff --git a/environment.yml b/environment.yml
index ec7e9288..c2bc5717 100644
--- a/environment.yml
+++ b/environment.yml
@@ -29,7 +29,7 @@ dependencies:
- conda-forge::libxcb=1.12=1
- conda-forge::libxml2=2.9.4=4
- conda-forge::pcre=8.39=0
-- conda-forge::qt=5.6.2=3
+- conda-forge::qt=5
- conda-forge::sip=4.18=py27_1
- conda-forge::tbb=2017_20170226=0
- conda-forge::xorg-libxau=1.0.8=3
@@ -127,7 +127,6 @@ dependencies:
- wrapt=1.10.11=py27_0
- yaml=0.1.6=0
- zeromq=4.1.5=0
-- zlib=1.2.11=0
- pip:
- backports-abc==0.5
- backports.functools-lru-cache==1.4