Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
bounding_box = scene.bounding_box
extent = max([p[1]-p[0] for p in zip(*bounding_box)]) * 1.2
logger.debug(f"extent : {extent}")
camera = OrthographicCamera(
-extent, +extent, extent, -extent, -2000, 2000, position=[0,0,10]
)
cam_target = tuple(-i for i in scene.origin)
controls = OrbitControls(target=cam_target, controlling=camera)
camera.lookAt(cam_target)
scene2render.children = scene2render.children + (
AmbientLight(color="#cccccc", intensity=0.75),
DirectionalLight(color="#ccaabb", position=[0, 20, 10], intensity=0.5),
camera
)
renderer = Renderer(
camera=camera,
background="white",
background_opacity=1,
scene=scene2render,
controls=[controls],
width=500,
height=500,
antialias=True,
)
logger.debug("Start drawing to the notebook")
display(renderer)
-height/2*scale,children=[light],
position=list(pos),
zoom=scale)
if isinstance(S,System):
c=sys2mesh(S)
elif isinstance(S,Component):
c=comp2mesh(S,(0,0,0),(0,0,0))
else:
c=surf2mesh(S,(0,0,0),(0,0,0))
scene = py3js.Scene(children=[c, alight,cam],background="#000000")
oc=py3js.OrbitControls(controlling=cam)
oc.target=center
renderer = py3js.Renderer(camera=cam, background='black', background_opacity=1,
scene=scene, controls=[oc],width=width*scale, height=height*scale)
return(renderer)
spec.update(**draw_specs)
children = [
py3js.DirectionalLight(color="#ccaabb", position=[0, 5, 0]),
py3js.AmbientLight(color="#cccccc"),
]
if spec["edge"]["visible"]:
lines = edge_lines(sheet, coords, **spec)
children.append(lines)
if spec["face"]["visible"]:
faces = triangular_faces(sheet, coords, **spec)
children.append(faces)
scene = py3js.Scene(children=children)
cam = py3js.PerspectiveCamera(position=[0, 5, 5])
renderer = py3js.Renderer(
camera=cam, scene=scene, controls=[py3js.OrbitControls(controlling=cam)]
)
return renderer, scene
def __init__(self, settings):
self.__update_settings(settings)
self._light = p3s.DirectionalLight(color='white', position=[0, 0, 1], intensity=0.6)
self._light2 = p3s.AmbientLight(intensity=0.5)
self._cam = p3s.PerspectiveCamera(position=[0, 0, 1], lookAt=[0, 0, 0], fov=self.__s["fov"],
aspect=self.__s["width"]/self.__s["height"], children=[self._light])
self._orbit = p3s.OrbitControls(controlling=self._cam)
self._scene = p3s.Scene(children=[self._cam, self._light2], background=self.__s["background"])#"#4c4c80"
self._renderer = p3s.Renderer(camera=self._cam, scene = self._scene, controls=[self._orbit],
width=self.__s["width"], height=self.__s["height"], antialias=self.__s["antialias"])
self.__objects = {}
self.__cnt = 0
newcols = rendered_obj.base_cols.copy()
newcols[face*3:(face+1)*3] = np.array(SELECTED_FACE_RGB, dtype='float32')
select_point_mesh.position = close_vert.tolist()
obj_geometry.attributes['color'].array = newcols
with out:
make_arrow(arrow_cyl_mesh, arrow_head_mesh, edge_start_vert, edge_end_vert, radius/2, radius, radius*3, SELECTED_EDGE_COLOR)
except:
with out:
print(traceback.format_exc())
click_picker.observe(on_dblclick, names=['point'])
renderer_obj = pjs.Renderer(camera=camera, background='#cccc88',
background_opacity=0, scene=scene,
controls=[pjs.OrbitControls(controlling=camera), click_picker],
width=self.width,
height=self.height)
display_things = [top_msg, renderer_obj, out]
if self.draw_grids:
s = """
<svg height="30" width="{}">
<rect style="fill:none;stroke-width:1;stroke:rgb(0,255,0)" y="0" x="{}" height="20" width="20"></rect>
<text y="15" x="{}">={:.1f}</text>
Sorry, your browser does not support inline SVG.
</svg>""".format(self.width, self.width//2, self.width//2+25, space)
display_things.append(HTML(s))
# -*- coding: UTF-8 -*-
#
# Copyright (c) 2016, Yung-Yu Chen
#
# All rights reserved.
from traitlets import (Unicode, Int, Instance, Enum, List, Dict, Float,
Any, CFloat, Bool, This, CInt, TraitType)
import pythreejs as ptjs
from .surface import Surface
class Viewer(ptjs.Renderer):
"""
Represent a window (canvas) for viewing SOLVCON results.
"""
_view_module = Unicode('nbextensions/solvcon/solvcon', sync=True)
_view_name = Unicode('ViewerView', sync=True)
def __init__(self, *args, **kw):
camera = kw.pop('camera', None)
if not camera:
position = kw.pop('position', [0,0,0])
up = kw.pop('up', [0,1,0])
camera = ptjs.PerspectiveCamera(position=position, up=up)
kw['camera'] = camera